It would be an understatement to say that the Commodore 64 demo scene is quite amazing. For those who are unaware, a ‘demo’ in this context is essentially a technological demonstration. Usually to show off particular effects or other (visual) properties that either push the limits of the platform on which it is being run, or use its hardware in a special fashion. In the case of [Linus Åkesson]’s A Mind Is Born demo, the challenge was to do as much as possible in 256 bytes, while providing an audiovisual experience.
Although at first glance 256 bytes may sound like a lot to work with, this code has to generate the entire melody that is output via the Commodore 64’s SID audio chip, while simultaneously generating an attractive visual pattern. This is quite an undertaking, as the video capture of the result (included after the break) makes clear. The secret sauce here is to make use of the C64’s SID audio & VIC-II video chips.
Driven by a 60 Hz timer interrupt, the three voices of the SID are used to play the kick drum and bass, melody and drone respectively, creating the 64 total bars of the music using a linear-feedback shift register (LFSR). This means that the melody is in a sense randomly generated, but deterministically enough to sound pleasing to the human ear.
For the visual side, the C64 runs in Extended Character Mode, using fonts along with a background color to create interesting patterns using what is essentially a cellular automaton algorithm. While there are some visual glitches due overwriting of video data, and a race condition, these end up adding to the charm. The resulting audio track is pretty catchy too, and absolutely worthy of a listen.
Thanks for the tip, Johannes!
(That banner image? That _is_ the whole code.)