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.)
36 thoughts on “Linus Åkesson’s ‘A Mind Is Born’ Commodore 64 Demo In Just 256 Bytes”
A single frame from the video is more bytes than the entire program was written with
8192 bytes for full screen bitmap graphic to be exact for those who aren’t familiar with C64’s capabilities. Add another 1024 bytes for setting the color.
I was even just saying the 480p video from youtube.
How big is a frame of a YouTube video? There is a screenshot of super mario bros that is thrown around with a caption that the screenshot is larger than the ROM.
I have No opinion on how to calculate a single frame. Raw data? Sampling a bunch of videos?
Just a guess, 480 setting would be 640×480, 24 bits depth so maybe just under 1MB total for a single frame on video card? With video codec, easily smaller in several Kb range per frame?
The first paragraph of the article is 522 bytes (in ASCII).
I love lo-fi synth, glitchy visuals, cellular automata, demoscene, the works. I SHOULD really like this, but something about it makes me physically nauseous, like it is messing with my inner ear or something.
Anyone else getting that?
You’re getting everything from strobed balance/moire effects to autokinesis in this one.
Please tell me this will be used as the intro to a well-written sci-fi flick…
It is already in an sci fi short
Which one, I would LOVE to see this.
Good one. Linus piece is at the end credits, but the story itself is worth the watch also.
Yep, me too… as awesome as it is, it makes me feel nauseous/motion sick.
I think brilliant composition is the word you are looking for. Spoiled and stupid as I am, demos generally don’t wack my tail, except for A E S T H E T H I C ones, but this one got me hooked me straight on. It seems he’s using the glitches to sidechain the bassline with the graphics in a way that causes somewhat of a glitch between my visual and auditory sensors that feels waaaay better than that dopey asmr stuff. Thank you!
What a fantastic bit of code. The code on the surface looks deceptively simple. The title of this piece, with the cellular automata, and the final reboot into created brain.. brilliant. who the hell is this guy!
Linus Åkesson is a musician, coder, builder, creative genius of many trades.
Here’s some of his works that I really like: https://www.linusakesson.net/scene/craft/index.php
I first became aware of him after he did an impressive demo on a Parallax Propeller. I then checked out other demos he did, including one where he developed his own soft CPU core on an FPGA. The music and graphics are almost always top-notch. Look up his blog. I’m not exaggerating when I say the guy is a genius.
Linus Åkesson? We’ve covered a number of his hacks through the ages.
His CRAFT demo blew my mind waaaay long ago.
I was sure I saw it on Hackaday, circa 2008, but I can’t find it in our archives! Bitrot?
The earliest mention of Linus / [lft] I can find is here:
Always good to check the c64 scene database for more info.. https://csdb.dk/scener/?id=16473
Reminds me of one-line C music:
256 bytes? A mind is blown!
This is just insane! Makes me happy and sad at the same time. Happy because this is awesome. Sad because I will never be able to create such stuff :D
Oh, this takes me back …. 8-bit audio, glitchy graphics and incomprehensible gameplay/scenes produced using procedural graphics.
Hard to believe that the program is just 256 bytes long.
Where does it load, or is it position independent?
The program loads to the standard BASIC load address and starts with a clever BASIC command that doubles as a constant for the interrupt routine. Then it copies itself to the zero page and does its thing.
And then there’s the resulting composition…
Transcribing it back to a staff is somehow even funnier. A mind is blown.
Well suited for piano, I would love to hear this done by strings.
Started out in disbelief – then over the course of the article, I slowly convinced myself that this was possible. Then I read that the music generation was also in those 256 bytes too – and I was straight back at the start.
To be fair, the C64 had a pretty good synth chip onboard…
But to be even more fair, everything about this is brilliant.
256 bytes is probably even less than a PCs keyboard buffer
I have a sneaky feeling Linus was not even born when the C64 came out. Great job.
He was actually already one years old when it was released in the US.
Space version : https://www.youtube.com/watch?v=uJtkDWDs8WM
I remember it taking two to three floppies of code, the play a “blinded me with science” mp3 equivlent. It was so exisiting to hear real music from our c64 back in 1986
Please be kind and respectful to help make the comments section excellent. (Comment Policy)