Day 32: The Least Impressive Demo of All Time
So, I’d written my VT100 emulator. I’d built out EEPROM carrier boards to emulate 8Kx8 24-DIP ROMs. I’d successfully booted modified firmware on the terminal. What’s left?
Oh, right. The screensaver.
Since I was limiting myself to the base 8K (instead of using extended memory on the AVO board), the first task was to free up space in the existing firmware for my own code. Unfortunately there’s really not a lot of room in there; there’s only 41 bytes of free storage at the end of the ROM, which isn’t a lot to play with. The trick was to see what bits of code I could cut out without reducing functionality. Two obvious candidates came to mind:
the ROM checksum code, and
the full RAM test, which zeroes memory and tests each byte with two patterns (0x55 and 0xaa).
Since a failure of either of these diagnostic checks causes the VT100 to fail at startup, I didn’t see too much harm in taking them out. I pulled out the code, clearing up an additional 100 bytes or so, plugged in some of my own code, and tested it in the emulator. It looked fine, so I burned it on a ROM and plugged it into the VT100.
It promptly crashed. This is because emulators are horrible.
Well, not horrible, but they make assumptions. In this case the simulator was essentially getting the memory zeroed for free, while the VT100 hardware’s RAM was full of noise at startup. I ended up having to re-add the memory zeroing code, bringing me down to 83 bytes freed, or a total of 124 bytes to squeeze my screensaver code into.
Ouch.
In the interest of getting it done, I dropped every feature I had planned on except for the core functionality: blank the screen after a fixed period of time, and restore it immediately on a byte coming in on the UART or a keystroke. Since the video memory is basically represented as a linked list of lines, it’s pretty easy to “blank” the screen: all you need to do is store the address of the second line in the list, and change the “next” link in the first line (which is always blank) to point to itself. On a keystroke, the address is restored, and you’re looking at the original data.
The timing is based on the vertical refresh rate. On boot, a keypress, or a byte on the UART, a fixed value is loaded into a memory location (0x22c2 if you must know), and is decremented on every vertical refresh interrupt. When it hits zero, the screensaver kicks in.
And it really was that easy. After some adjustment to get the code squeezed into the right places, the screensaver pretty much worked the first time: after waiting long enough, the screen went blank. Pressing a key restored the text.
This was, truly, the lamest victory.
Next: lessons learned of desperation.
















