C64-Demo generates itself from Soundtrack

22.04.2017 Tech #C64 #Coding

Share: Twitter Facebook Mail

Gewinnerdemo der Revision 2017 von Linus Akesson, ein C64-Hack in 256 Bytes: A Mind is born. Ich verstehe ja noch ein bisschen rudimentären C64-Assembler, aber hier bin ich lost. Soweit ich das gerafft habe, generiert sich die Demo selbst aus dem Soundtrack beziehungsweise aus den Werten der Register des SID-Chips, aber hier hört mein Verständnis dann auch schon auf. (via Algoritmic)

The demo is driven by its soundtrack, so in order to understand what the program needs to do, it helps to have a schematic overview of the various parts of the song.

The three voices of the SID chip are used as follows: Voice 1 is responsible for the kick drum and bass, Voice 2 plays the melody and Voice 3 plays a drone that ducks on all beats, mimicking the genre-typical side-chain compression effect.

All in all, the song contains 64 bars in 4/4 time. It is played back at 112.5 bpm by means of a 60 Hz timer interrupt. The interrupt handler is primarily responsible for music playback, while the visuals are mostly generated in main conext.

When bar $40 is reached, the program turns off the display and jumps through the system reset vector. In this way, the final few moments of the demo are actually managed by the system boot sequence: First, the SID is silenced. Then, there is a delay while the system is setting up data structures. Finally, the display goes back on, and the C64 home screen is rendered. A mind is born.