My best programming story
When I was 16 (in 1980), I got a ZX-80 for christmas. It was my first computer. I'd been reading about computers for years, from the Popular Science accounts of the Altair and MITS8080, and the Apple I and II. I'd seen an Apple II at a science fair once, part of someone's project -- I remember wondering where his parents had got the $1700 they cost. It wasn't even jealousy-- that sort of money was just unattainable. The TRS-80 was coming out, my best friend would later get an Atari 400, and in second semester that year I was part of the first computer class at our high school.
It was a year 11 enriched math class (I was in year 12). We got a Commodore PET for a month. It was being shared among a number of schools. After that, we used FORTRAN on coding sheets that got sent in to the education office, where keypunchers would turn them into punch cards and run them through their mainframe. It would take about three days from submitting sheets to get the program run and the result (or, just as often, the error report) back, on those old large format printer sheets.
Anyway, I was very keen, and I got a ZX-80 for christmas. We attached it to an old black and white TV screen, and although something was on the screen, it wasn't working properly. I remember that peak of excitement, and that feeling of it all about to be dashed. We persevered, and with some mucking about with the horizontal and vertical controls got the screen mostly readable. I would later get a newer small B&W TV which worked much better. I was glued to the machine over the Xmas holidays and taught myself to program in ZX-80 Basic. Time passed.
I'd subscribed to Sync the ZX-80 magazine, and learned about peeking and poking to screen memory.
The ZX-80 had but 1K of RAM-- this held the program you typed in using it's clever membrane keyboard, as well as the memory needed to drive the screen. When calculations were taking place, the screen would flicker, and fuzz out for the length of time it took to get a response.
Much fun was had.
I had ambitions of making a little racing car game. The magazines had showed me a trick, where when you saved the program (onto cassette tape, of course) it saved the state of it's memory as part of that. So it was possible to write a program to dray a racetrack to the screen (peeking and poking to screen memory), and save that state to cassette, then restore it to change the program to add the racing car bit, given the existing race track -- because I couldn't have both in my 1K.
The track itself was just made of the block characters the ZX-80 had above the low ASCII. The magazines had also explained how screen memory worked-- and demystified peeking and poking directly to memory, enabling an image to stay on the screen while the program was running.
So that worked. I'd drawn this roughly oval track with walls 3 blocks thick, and I had this little block representing the car which would drive around. You could tap different keys to get the car to turn and accelerate up to 4 squares/tick, and I was poking the car into its new position in screen memory. I had some routine to test to make sure you didn't hit the wall-- I forget what was supposed to happen.
Anyway, I'd typed all this in, and was testing it. Sure enough, I could drive my little car around, the screen wasn't flickering because I wasn't doing any output, just changing it directly by pokeing into screen memory. Then I made my mistake. I moved to maximum acceleration-- 4 squares and jumped through my 3 square thick wall.
To simplify things, the car was just jumping from square to square, without passing through the intermediate squares. So the wall might as well not have been there. The screen memory and my program memory were contiguous, so after jumping the wall the car proceeded to drive through my program, until the program, and with it, the car, crashed.
I was briefly able to look at my listing; lodged in a line was the block representing the car, but I couldn't edit it, couldn't really do anything.
I never got around to trying it again.
Tags: computing