Ahh.. the tape loading era!

Released at Sundown 2009, “Ahh.. the tape loading era!” is another ZX Spectrum demo by me. It’s a 128 only demo with a simple tune and a few fairly basic effects. It placed first in the Oldschool Competition.

So how did such a simple sounding demo place so high? The secret is in the special sauce of course – the demo is running the effects and playing the music at the same time as it is being loaded from tape.

I’ve always been a little jealous of the C64 demo writers – they’ve had a disk drive as standard in their arsenal for quite some time. The disk is used to stream in more data as their demos run, allowing them to write demos that are far bigger than the C64s standard RAM size. Now of course we have our own benefits on the Speccy (more memory for one) but there has never really been a standard disk system. The +3 never really took off (and has not been adopted by demo writers) and flash memory systems like the divIDE really only emulate the tape interface unless you fancy some really hard work. Those crazy Russians have their own Speccy clones that often have disk drives too but they haven’t really made it over to Europe. Besides, whilst I could use a disk drive or a divIDE they were not readily available until way after the Spectrums best years were behind it and that feels like cheating.

This means that we can’t have streaming demos on the Speccy, right? Wrong. It just means that we have to use the tape. Now, loading from tape is notoriously slow. It takes something like 40 seconds to load a single full-colour graphics screen. But if you look closely at a disassembly of the Spectrums ROM loading routines you’ll notice that it’s full of delays. These delays are great because they allow a lot of variation in the loading speed. This means that a mangled tape playing on your dads beaten up old portable cassette player still had a fighting chance of loading successfully. As we progress through Spectrum history we come across the so-called “turbo loaders”. These special loaders reduced the lengths of these gaps, making games load faster but at a the cost of greatly reduced reliability.

So delays in a tape loading routine are good, right? Yes. But who says we should just sit and wait for a few hundred clock cycles. Who says we can’t do something interesting in those delays? No-one, and yet very few people seem to have tried. Check the txt file from the demo to see some references to what other people have done but, as far as I can tell, I am the first person to do something this complex with a Spectrum loader.

A few people have asked if the demo is real or if I am cheating. I can happily say that it’s very real. I’m even happier to say that it runs on both actual hardware and emulators, though you may need to change some settings to get emulators to run it properly. The demo uses a slightly modified version of the standard Spectrum loading routines. In fact, it only really differs in two ways. Firstly, the data loaded from tape goes into a small, cyclic buffer. Secondly, I replace the inherent delays in the loading routine with something more interesting. What that interesting thing does exactly depends on what part of the demo you are watching. In some parts it’s copying data out of the cyclic buffer into another part of memory. In others it is actually running that data as code to display the effects that you see. Both of these things have to happen in tiny time-slices so as not to upset the timing of the loading – if a routine takes too long or runs too quickly then data will be corrupted and the loader will crash. Look very closely at the ROM code I linked to above and you’ll see the comment “Wait 358 T states before entering the sampling loop” – that’s the secret to this demo ;)

You can grab the final demo from here

It’s also here on YouTube

And it’s also up on Pouet

This entry was posted in atebit, Computers, Demoscene, Development. Bookmark the permalink.

1 Response to Ahh.. the tape loading era!

  1. Equinox says:

    Nice. The drawing onto the screen reminds me of Gremlin’s “Compendium” games, which did this while loading (a good place to put the instructions), but I’ve never seen AY music during loading before. No doubt you chose something with long chords so you didn’t have to keep updating the sound chip registers, or what not.

Leave a Reply

Your email address will not be published. Required fields are marked *