The world's first 1541 disk drive graphics demo
July 4, 2021 2:15 AM   Subscribe

Matthias Kramm, a demo coder, shows us his setup: a Commodore 64, a monitor, and a 1541 disk drive, all connected together. He show us he's loaded a small program into the drive's memory. Then, he disconnects the computer from the monitor and the drive, severs and strips the drive's cable still plugged into the drive, connects them directly to the monitor with a resistor spliced in, opens and closes the drive's door, and the show begins. The fact that the demo has music without speakers isn't close to the most impressive part of it. There's an overview on his site, which has links to more details.
posted by JHarris (49 comments total) 69 users marked this as a favorite
 
On rewatching, he doesn't plug the disk cable wires directly into the monitor, but instead severs and strips the monitor's cable too, and splices them together with the resistor. Management apologizes for the error.
posted by JHarris at 2:29 AM on July 4 [1 favorite]


It's been a staple in the demo scene for decades to recognise that the 1541 has a comparable processor to the C64, and a reasonable amount of RAM. When emulators first added "drive noises" to their sound output, it was largely because demos often relied on fast-seek clicking sounds to provide the percussion track.

A lot of demos used to put the logic for the soundtrack onto the drive, and feed the SID cues in over serial while the C64's RAM and processor were primarily occupied with the visuals. If you can afford the interrupts, it steps up your capabilities by quite a bit!

So it doesn't surprise me that there's a demo for the 1541 on its own, and that it can produce sounds without extra hardware.

That looks like a 1571 to me, though.
posted by rum-soaked space hobo at 3:06 AM on July 4 [16 favorites]


"Install a driver on the floppy drive"? That's what leaped out at me from his intro. The secret to this, I guess, is that the C64 disk drive must be a programmable computer. And he's programmed that primitive computer to send signals on its DATA and CLK lines, shunting out bits retrieved from off the floppy. His demo is using the drive as a very simple videodisc player. The large size of the graphics blocks is necessary because the floppy can't deliver bits fast enough to make a high-resolution image.

ETA: Woot! I see rum-soaked space hobo has confirmed my guess!
posted by Harvey Kilobit at 3:08 AM on July 4 [4 favorites]


After some quick checking, I realised that the drive in the video is almost certainly a 1541-II, which was a model that was sold with the 64c (which you can see him switching off and removing early in the video). So it's definitely a 1541, but just a late-80s 1541.

The 1541 had a 6502 processor, which was nearly identical from an assembly programmer's perspective to the sort of "souped up 6502" the C64 used. It also had 2K of RAM, but you must also remember that you nearly always had a diskette inside that could hold more like 170K of data, if you needed. The ROM contained enough routines to jump into for reading and writing off the disk directly into that 2k buffer without the lag of the serial bus, so you could really treat it like virtual memory if you kept to some strict constraints.

One thing you'd be missing for a demo like this is the character ROM, which is over on the C64 you just unplugged. I expect that this demo implemented only the characters that would appear on the screen, and it's possible it re-used those bit patterns for other data (like the bar codes that scroll and weave during the demo).
posted by rum-soaked space hobo at 3:33 AM on July 4 [4 favorites]


I was expecting more of a singing-dog sort of thing (you know, who cares how well the dog sings, it's a singing dog!) but this is kind of mesmerizing.
posted by Ampersand692 at 3:51 AM on July 4 [3 favorites]


IIRC, the only souped-upness of the C64's 6510 was that the two lowest memory locations were repurposed as bank-switching registers, allowing ROM and RAM to be swapped. Other than that, it's a vanilla 6502.

One thinks of the C64 as a quantum leap ahead of the VIC-20, though it's essentially a VIC-20 with more RAM and better graphics and sound chips, down to the ~1MHz clock speed. One can say similar things about the C-16 and Plus/4 (additionally, them having stripped out the SID chip because Tramiel thought it would make it insufficiently serious to be a credible business computer); Commodore's 8-bit line was quite conservative in choice of technologies.
posted by acb at 3:58 AM on July 4 [4 favorites]


It's been a staple in the demo scene for decades to recognise that the 1541 has a comparable processor to the C64, and a reasonable amount of RAM. When emulators first added "drive noises" to their sound output, it was largely because demos often relied on fast-seek clicking sounds to provide the percussion track.

This is news to me. I know the 1541 can make sounds, but what demos used those sounds in addition to the SID? I can't think of a single one.
posted by ymgve at 5:00 AM on July 4


The 1541 feature/bug that led to a lot of corrupted floppies. It held transactions in a buffer until it received a write or file close instruction. Users who thought the floppy could be removed any time the disk wasn't spinning paid a price. It quite a while for Commodore to determine and disseminate the cause of the disk corruption issue.
posted by SemiSalt at 5:05 AM on July 4 [6 favorites]


next week on hoonigan whip'n'buggy edition....
posted by lalochezia at 5:52 AM on July 4 [1 favorite]


These things just baffle me, as a non-programmer and somebody who dimly remembers Raid on Bungeling Bay, Wasteland and Legacy of the Ancients as the great gaming experiences of my young life. I can't even imagine the tenacity it must take to delve into this sort of thing.
posted by Shepherd at 6:33 AM on July 4 [1 favorite]


Yep, the drive is a 1541-II, he mentions that in one of the links on the site. Those links also mention that part of the essential hack of the demo isn't just that it runs solely on the drive, but it also involves streaming parts of the demo code in off the disk while it's playing, which means storing it in such a way so that it can both be loaded without pausing the demo perceptibly and stored in such a way that the demo can still be downloaded and traded using standard D64 disk images.

AND remember, the 1541 has no video hardware! The signal is literally bashed together racing-the-beam style!
posted by JHarris at 7:12 AM on July 4 [17 favorites]


Ha, was just coming here to post this. Tremendous.
posted by cortex at 7:51 AM on July 4 [3 favorites]


If I saw this technique in a movie showing a "hacker" altering a computer, I'd be rolling my eyes. Incredible.
posted by gwint at 8:06 AM on July 4 [7 favorites]


Truly astounding.
posted by hijinx at 8:58 AM on July 4 [1 favorite]


I have friends who know exactly how this is done, and they still can't believe it.

Commodore did love their 6502 variants: 6502 in the KIM, PET and VIC-20; 6510/8500 in the C64; 7501/8501 in the C16/+4; 8502 in the C128. Then there are the micro-controller versions in 1520 plotter and the Amiga keyboard. I guess owning MOS Technologies meant they saved on costs.
posted by scruss at 8:59 AM on July 4 [2 favorites]


Commodore specifically bought MOS Technologies to save on costs. They, like Burroughs, aimed to be a completely vertically integrated computer manufacturer. If your design needed a part that wasn't manufactured in-house, it wasn't considered worth developing.
posted by rum-soaked space hobo at 9:03 AM on July 4 [4 favorites]


Whew. Respect!!!
posted by praemunire at 9:15 AM on July 4


That is fully amazing. I skimmed the post and I was expecting him to unplug the monitor, but then he gets rid of the computer and takes a knife out. I don't know why he provided the instruction only for putting the resistor in - not knowing the size of resistor is the very least of the things preventing me from understanding this.
posted by Wrinkled Stumpskin at 9:48 AM on July 4 [1 favorite]


ymgve: I can't recall the names, but it was in a whole slew of them I remember running in VICE around 2002 or so.
posted by rum-soaked space hobo at 9:53 AM on July 4 [1 favorite]


...100 ohm resistor...

Amazing. Makes me want to boot up my old Altair. There's a program for it that plays "Fool on the Hill" using code loops to generate tones you can pick up with a nearby AM radio.
posted by cosmac at 10:16 AM on July 4 [4 favorites]


Of special interest to me, one of the technical detail pages mentions this fun fact (hyperlink added):
Note the use of the illegal opcode "RRA" here. It has been used before (e.g. in six sprites over FLI), but as far as we're aware, this is the first time a demo uses it on every scanline, in almost every effect. :)
posted by Callisto Prime at 10:23 AM on July 4 [4 favorites]


This small note is stupendous: If needed, the 100 Ω resistor can be harvested out of the C64. (E.g. the not strictly necessary R14 AUD IN pulldown.) As such, this demo runs on stock C64 hardware and doesn't need any extra components.
posted by BungaDunga at 10:29 AM on July 4 [12 favorites]


This is phenomenal. Much love to the MeFi user who is all "it doesn't surprise me". The dude wired a 35 year old floppy drive directly to a monitor cable and made music and video. Holy shit!

My only complaint was going to be the graphics are a little dull for demoscene (although pretty good for, you know, a floppy drive). But then I got to the magnifier effect at the end applied to the text and was like holy shit! Really nice.

I always knew the C64's floppy drive was a complex standalone computer. The Apple ][ drives were much simpler and driven mostly by the CPU. What I've never quite understood though is why the C64 drives were so slow. I'd have guessed it was the serial bus; 3200 bits/second. But Apple's Disk II transferred data at 120,000 bits/second and I think it was also a serial interface. Huh.

Did old-school C64 copy protection run as drivers on the 1541 itself? That must have made cracking exciting. The Apple ][ stuff was all in the main system RAM so with enough effort you could usually reverse engineer it with just a disassembler.
posted by Nelson at 10:35 AM on July 4 [1 favorite]


Also don't overlook the page on how he recorded the demo
we made a special version of freespin that instead runs at 49.23Hz, recorded that, and then sped it back up to 50Hz using ffmpeg. (And then combined it with the sound of a special version of freespin that had to run at 50.095Hz to compensate for the frames the camera dropped....)
posted by Nelson at 10:40 AM on July 4 [8 favorites]


I was going to write a comment for all the people who look at this with astonishment, about how sometimes getting really close to the metal removes whole encyclopædias of interfaces and options and provides clarity of purpose with a limited toolset. It may look wizardly to see someone coding in an obscure VM and reading values in hex, but from their perspective the "You mean there are only 32 instructions, and four addressing modes I need to think about?" is liberating.

And to some degree, this is true here. Generating a monochrome PAL signal by bit-banging a line is well-trodden territory. And the 6502 is absolutely that old pair of shoes that you put away for the winter but feel snug and soft the moment you put them back on.

But the data pipeline reading off the disk and executing in the slices between other interrupts, playing sounds between that and other interrupts, and going on to use the really weird half-unreliable instructions to tie it all together? That's just spinning plates on sticks of fragile dried spaghetti instead of steel rods. Truly a genius demo!
posted by rum-soaked space hobo at 10:47 AM on July 4 [9 favorites]


Nelson, there were a lot of weird design compromises that went into the 1541 as a "cost-cutting" model, but ultimately the slowness of the 1541 has always been regarded as a bug. This was confirmed when the 1571 came out, using the faster side of the serial bus, and achieved much faster speeds.

Most folks with C64s used the EPYX FASTLOAD CARTRIDGE (or equivalent) to compensate for the design flaws in the 1541. I believe that the "kernal" (never get used to typing that) replacements often include similar workarounds:
However, by violating the Commodore IEC serial protocol, considerably faster serial transfers could be accomplished with existing hardware - sending data clocked faster, and down by 2 wires (Clock, AND data), for example - and thus the turboloader was born. EPYX's Vorpal / Epyx Fastload cartridge was one of the more successful. So your typical fastloader would download a short program into the 1541 RAM, and run that code instead of the 1541's native IEC code.
posted by rum-soaked space hobo at 10:54 AM on July 4 [3 favorites]


Oh boy 6502. I programmed in 6502 Assembler in my third year of CompSci at university. I don't remember much of it except that it was way more fun than 8080 Assembler.
posted by storybored at 11:05 AM on July 4 [2 favorites]


I would really be impressed if the disk image was readable by a stock C64 and had enough of a small directory / allocated space to hold the driver program that the C64 uses to flash the drive and really impressed if that program was also like a fastload type of thing that would let the C64 decode the signals and just put them on the screen itself so you didn't have to cut the cables. :)

After watching enough Ben Eater videos the whole get just the floppy to make a video signal isn't much of a problem, playing the sounds by banging the floppy motors around isn't that much of a problem. Doing both at the same time fast enough to keep the video signal in time takes some thinking. Using data from the disk to make it longer than just some test pattern and repeating noise in a loop is the interesting part. Having to not use the ROM for that for timing reasons and doing the reads yourself by abusing duplicated data on the disk that isn't even simple bytes of real data. That's pretty cool.
posted by zengargoyle at 11:23 AM on July 4 [1 favorite]


Always love these, and this one’s conceptually outstanding. Just to be clear (I know no programming/hardware but I think I’ve got a gist of the demoscene process by now): what are the physical parts of the drive that are “playing” the sound/music? If the video signal is being bit-banged to the monitor, is the audio also being bit-banged, and if yes, to what? (I’m trying to imagine what the “composing” of the track entails; unlike the plasma effect grid paper layout he shows, how would he have planned/designed the music to this?
posted by progosk at 11:32 AM on July 4


This was my first computer, and I was 7 or so when I got it (to be shared with my parents but kept in my room). It’s a core memory of mine, my stepdad excitedly explaining that the 1541 had the same processor as the computer itself and that’s why it was so expensive. I know I’ve shared this on Metafilter before but in the same breath he reassured me that I couldn’t break the computer (if I followed basic rules like not eating or drinking around it) and that single reassurance basically fueled my entire career of breaking things ON the computer…and then figuring out how to fix them.
posted by annathea at 11:46 AM on July 4 [10 favorites]


Commodore specifically bought MOS Technologies to save on costs. They, like Burroughs, aimed to be a completely vertically integrated computer manufacturer. If your design needed a part that wasn't manufactured in-house, it wasn't considered worth developing.

This was up until the Amiga, which used a Motorola processor. While their ownership of MOS Technologies undoubtedly helped Commodore, it destroyed an up-and-coming chip fabricator. MOS created one of the most popular processors in the world, it's still used today, but it was both their first and last major processor project, their later chip designs were mostly made for Commodore. It's probably why we don't have huge, multicore, 64-bit 6502 variants now.

If the video signal is being bit-banged to the monitor, is the audio also being bit-banged, and if yes, to what?

The drive motor, in a manner like the Floppotron.
posted by JHarris at 3:04 PM on July 4 [4 favorites]


Even having previously been aware that the 1541 and its ilk had a 6502 and knowing that it's possible to generate video signals without actual video hardware this is still quite impressive.
posted by wierdo at 3:17 PM on July 4


Oh boy 6502. I programmed in 6502 Assembler in my third year of CompSci at university. I don't remember much of it except that it was way more fun than 8080 Assembler.

I grew up writing 6502 machine code! I say machine code because I had no assembler at first, I had to write opcodes as numbers in DATA statements that were POKEd into memory. Twice I wrote the main loops of games I made this way. I often think sadly about what I would have been capable of if I had a real assembler.

I wonder what it is that makes assembly for one processor more fun than another?
posted by JHarris at 3:22 PM on July 4 [2 favorites]


ymgve: I can't recall the names, but it was in a whole slew of them I remember running in VICE around 2002 or so.

I think you remember "True drive emulation" which had nothing to do with drive sound, but means that the emulator also emulates the disk drive at CPU level, which is necessary to install custom disk transfer protocols, which demos often did. Without that, the drive is just emulated as a basic 1541-DOS interface, and can only talk the standard KERNAL transfer protocols.
posted by ymgve at 3:25 PM on July 4


TIL: the bits stored on a floppy disk are not in fact the bits stored on a floppy disk.
posted by motty at 3:27 PM on July 4 [3 favorites]


So I went down some 1541-related rabbit holes today and there is now a fastloader that promises to load stuff fifty times faster than the original c64/1451 routines. https://csdb.dk/release/?id=197710

As a benchmark, Epyx's much-beloved Fastload cartridge (which pretty much never left my c64's cartridge port once I got it, especially after a friend who knew his way around a soldering iron added a button that would reset the c64 so I could poke around in memory) was a mere five times as fast as a stock c64, according to Wikipedia. If they had a time machine they could make a mint.
posted by egypturnash at 4:33 PM on July 4 [4 favorites]




JHarris... about the same but a bit less. I learned 6502 because of a book and that there was this Apple ][ game that I could grok the POKEs for playing the music but couldn't find the POKEs that loaded the machine code routine. Time would have it that this was when the Apple ][ clone made by Apple Computer, Inc. v. Franklin Computer Corp. clones were in my high school and they had a nice built in debugger with assembler/disassembler, so I used them instead.

Then I got an Amiga and went all 68k.

But then I went off to university and this guy down the hall was totally doing call -550 or whatnot to get into the ROM monitor sort of thing that Apple ][ had and was spending his time typing in hex code directly into memory trying to write a TRON light-cycle game using the joystick the hard way. Props.

I was like 17 at the time and went old-school CE/CS on big UNIX machines doing PDP-11 sort of things and totally missed the whole C64-ish era. Born too early or too late depending on how you look at it.

That's what make this so meh/cool/impressive at the same time. Too much lack of C64 specific knowledge to know the details and constraints. It's The Story of Mel adjacent.

Let's abuse the hardware.
posted by zengargoyle at 5:37 PM on July 4 [1 favorite]


MOS created one of the most popular processors in the world, it's still used today, but it was both their first and last major processor project, their later chip designs were mostly made for Commodore.

Were Commodore/MOS behind the 65816, or was that essentially 6502 fan fiction?
posted by acb at 1:26 AM on July 5


So I went down some 1541-related rabbit holes today and there is now a fastloader that promises to load stuff fifty times faster than the original c64/1451 routines.

Note that this requires the files on disk to be in a specific format. 50x is really fast, but 25x has been possible for decades with the warp*25 loader system, again with a custom format on disk. Also this new format is better in that it respects the sector encoding standards, which warp*25 didn't.
posted by ymgve at 3:09 AM on July 5 [1 favorite]


Were Commodore/MOS behind the 65816, or was that essentially 6502 fan fiction?

I thought to check before I made my bold statement, it seems it was made by WDC instead, at least according to Wikipedia.
posted by JHarris at 3:43 AM on July 5


motty, a couple of links you may find interesting:

4am's writeup about Gumball includes Chapter 19, a longform writeup of how the 6-and-2 encoding on Apple II floppy disks is eventually translated into bytes for the machine to use — and after that, it heads off into a discussion about how the copy protection scheme used on Gumball takes advantage of those underlying non-bytes in various respects.

scarybeasts' writeup about oscilliscope data recovery goes even further down, talking about how to recover data from disks when their magnetic fields are distorted or damaged. It includes fun things like loading up a floppy disk's magnetic record in Audacity and hand-drawing peaks in the magnetic data based on a visual inspection.
posted by Callisto Prime at 11:26 AM on July 5 [1 favorite]


Commodore specifically bought MOS Technologies to save on costs

I've heard that Commodore bought MOS through loading up on orders and paying for them late, forcing MOS close to bankruptcy
posted by scruss at 4:03 PM on July 5 [1 favorite]


I don't know about that (literally), but the 6502 was a hot property that ended up used in a ton of things by lots of companies, it seems unlikely that one company's orders could have accomplished that. There is no mention of that in this history. That said, I would have put it past Jack Tramiel at all.
posted by JHarris at 11:07 PM on July 5


Makes you wonder what our modern computers would be capable of, if we pushed their limits as hard as the demo makers who continue to innovate on ancient hardware. It's a bit disappointing that modern computers can play full-screen video with as much resolution and frame rate as the human eye can process. That means that we will never again see something on a computer screen that we thought was impossible, because anything could just be video playback.
posted by qxntpqbbbqxl at 1:08 PM on July 7


Demo makers are kind of a special case though, I did some C64 coding back in the day, and can tell you even then they pulled off tricks I couldn't do. Part of it is they formed groups that trade knowledge between them, and developed a deep body knowledge of what the hardware could do and how it could do it. The fact that the hardware was largely the same between them facilitates that. And they just found it interesting to get the most out of it.

On to video playback. Video has its limitations, not just of resolution and framerate but encoding, filesize, and non-interactivity. That last one is huge, it's why laserdisc arcade gaming wasn't the huge advance some thought it was, because it could only show prerendered video clips. Also, there's other domains to optimize over than just video quality. There is .kkrieger, a FPS implemented in around 96K, and other games like it that are evading my ability to Google for them right now.
posted by JHarris at 3:56 PM on July 7 [2 favorites]


It's a great demo in the classic demoscene style. What I want to know is where this guy gets new 5 pin DIN cables that he can afford to just cut them up!

Also with this being a 6502 and he's basically racing the beam as JHarris says, this isn't that different from being an Atari 2600 game, except with everything being on disk instead of in ROM.
posted by GuyZero at 8:55 AM on July 10 [3 favorites]


If it's a straight 5-pin DIN cable, they sell them as MIDI cables.
posted by acb at 3:01 PM on July 10 [2 favorites]


> I've heard that Commodore bought MOS through loading up on orders and paying for them late, forcing MOS close to bankruptcy

Wikipedia says the acquisition happened because both Commodore and MOS took a bad hit to the books when TI, the primary seller of chips to calculator companies, began selling calculators themselves and undercutting all the companies they had been an OEM for. At the time, MOS had just begun selling the KIM-1. Commodore only entered the computer market after the merger, when MOS executives convinced them to.
posted by ardgedee at 9:53 AM on July 11 [1 favorite]


« Older The Nonsense Laboratory, or Th nn-n-schn's lpbr...   |   This country dog won't die in the city Newer »


You are not currently logged in. Log in or create a new account to post comments.