Mission Impossible!

As I delved into the murky depths of machine code programming, I discovered interrupts. In short, interrupts are a way of intercepting whatever the computer is doing and running a short amount of code, before letting it carry on with whatever it was doing before. An example of use would be a communications port of some description. When the communications port received some data, the electronics of the port can interrupt the CPU, run a short program to get the data from the port, store it somewhere useful and let the CPU carry on with whatever it was doing before.

The ZX81 had an interrupt connected to a clock which “ticked” 50 times per second. I thought it would be a cool idea to have a clock always displayed on the screen. This is, of course, no big deal on today’s modern computers, but back then, it was.

“It can’t be done! You’re fighting the ROM!”, my physics tutor at college declared, when I told him of my intentions.

Unperturbed, I persisted, and sure enough after about a week, presented him with a demonstration of a simple BASIC program running, whilst a clock continually and independently, showed in the top right corner of the screen. It wasn’t perfect, because it wasn’t totally persistent. He had been partially right about fighting the ROM. When in edit mode, the clock only stayed on the screen until you pressed [New Line] or when a running program switched from SLOW to FAST mode, or vice versa. This seemed to satisfy his sense of being right, resulting in a slight smirk and derisory snort as he walked away. Oh, well, I was pleased with it.

In continuation of performing the impossible with a ZX81, the next step was producing high-res graphics (256×192 pixels was considered high resolution in those days, on most modern PCs this would be little more than an image thumbnail).
A quirk of the ZX81 was that when programs were loaded or saved to cassette, the screen would flicker with moving horizontal bands of black and white. Essentially, in order to save cost, Sinclair had used the same output for both tape and for screen raster scans. Once in control of interrupts, I figured that it would be possible to, bypass the computer’s own screen drawing code and send data directly to this port. With the correct timing, this was indeed possible, though it left very little time to do anything else. No wonder the ZX81 was so slow, most of its time was spent drawing the screen.