Llamasoft History - Part 4
"The Joy Of ZX & Hex"
16 Back at college, access to machine language was the final step needed for us to begin creating some proper games at last. Soon, the cassette buffer became too confined for serious programs, and we worked out how to force the PET to leave a section of main memory free for us to use for code, and how to make the cassette load and save routines work with data that wasn't lines of BASIC code. And I learned to count again…
It turned out that because of the way data is organised inside computers, CPUs like things arranged in clumps of powers of two, and so quite often you needed to refer to things in clumps of twos or fours or eights or sixteens.
Counting stuff that needs to be laid out that way is a bit awkward using human-familiar base-10 counting. If you choose a different number base (in this case base 16 - 16 being a power of 2) then inspecting a computer's memory, and dealing with things like the op-codes of a machine language, actually becomes a lot easier.
Base 16 is called ‘hexadecimal’, and all it means is that you add in a few extra digits between 9 and 10. It's natural enough to use letters of the alphabet for these extra digits, so you count ‘0,1,2,3,4, 5,6,7,8,9,A,B,C,D,E,F,10’. When you reach 99, instead of the next number being 100, you count ‘A0, A1, A2’... and so on, until you reach ‘FF’, and only then do you get to 100.
It may not seem obvious HOW that makes things easier, so here are a couple of examples…
A computer holds data arranged in ‘bytes’, each of which contains eight ‘bits’ of binary data. The number of discrete states that can be held in 8 bits - and therefore the maximum number o f numbers that one 8-bit byte can hold - is given by 2 to the power 8, or 256. The number ‘256’ isn't a particularly pleasing or round one in decimal, but in hex it's a nice round 100.
Likewise the number of bytes addressable by an 8-bit CPU like the 6502 in the PET is 65,536. Again, an awkward number in decimal, but in hex a nice round 10000. So, if you're inspecting computer memory, a 10x10 table of memory contents printed in decimal would look confusing indeed, but a 16x16 table printed in hexadecimal would look much less so, and make it easier to find numbers based on the kind of 4, 8 and 16-number boundaries that often occur inside the machine.
You could actually ‘read’ machine language directly fairly easily if you used hex. To the CPU, any number in a byte could be a command to do something - and since a byte holds 256 numbers, that meant that potentially there were 256 instructions the machine could understand.
Consider the ‘LD A’ command I used as an example earlier - in decimal that’s instruction 169, so if you wanted to look it up in the list of instructions you'd have to count through to the 169th entry, which is a bit awkward.
But if you have a table of op-codes laid out in a 16x16 grid, and you label the rows and columns from 0 to F in hexadecimal, and look at the op-code itself in hexadecimal, you can quickly see it’s instruction ‘A9’. You just look in row A, column 9 and there's your instruction - easy.
Really, it is. Take my word for it. Honestly.
So, I wrote a little program (a ‘monitor’) to let me enter numbers into memory in hexadecimal, and to look at memory in hexadecimal - something that other machines had built in. This made entering and testing machine language programs much easier than all that mucking about with BASIC and POKEing values into memory by hand.
At first we used machine language sparingly - just little routines called from a still predominantly BASIC program to assist with the things that BASIC was slow to do, like drawing large blocks of graphics data. This allowed for bigger objects onscreen in our games. These hybrid programs were an ideal way for us to get used to harnessing the power of the CPU directly. Programming in machine language was a lot more painstaking than writing code in BASIC, and it would be a while before any of us would attempt an entire game coded that way.
17 There was a degree of life outside college. My seventeenth birthday rolled around and I celebrated it by going hang-gliding near Marlborough. Gary Numan, the God of the geeks, came around touring the ‘Telekon’ album, and I went to the first music concert of my life, seeing him at the Mayflower in Southampton.
All of us geeks were major sci-fi nuts, and so the release of ‘The Empire Strikes Back’ warranted an expedition up to London to see it at the cinema in Leicester Square. It was excellent - I thought the Taun-Tauns were cute, and was quite sad when Luke had to slice one of them open.
Best of all, we got to spend time afterwards hanging out in the numerous arcades in that part of London. There was one that was a particular favourite of mine – the Piccadilly Arcade (now long since demolished and its location buried underneath the Trocadero). The Piccadilly Arcade was a proper arcade – the kind your parents warned you about. Dingy and filled with flashing machines and dodgy characters (indeed I remember hearing on the news once that someone got stabbed in there). But there was nothing seedy in my interest. It was simply the fact that they had lots and lots of good games. I played Targ and Galaxian and Space Invaders and sit-down Turbo... But there was one game in there which got most of my attention.
It was a big hulking sit-down cabinet with a large colour monitor inside. As I walked past, I saw the game spell out its name in bright, glowing letters (and in blatant plagiarisation of the ‘Star Wars’ logo)…
“Exidy EXCITEMENT Brings You... STAR FIRE"...
…shortly followed by the attract mode, which revealed a first-person space shooting game heavily based on Star Wars – right down to the enemy craft having the same ball-with-wings shape as the TIE Fighters. This was of course irresistible to someone fresh out of the cinema from just seeing Empire Strikes Back, and I climbed eagerly into the cockpit with a Luke Skywalkerish attitude and prepared to spend a few happy minutes sending Darth and his chums off to oblivion.
The game was primitive by modern standards, but impressive for its time, in which first-person games of any description were rare indeed. For control you had a throttle lever and a flight yoke, and before long you found yourself swooping through the simple 3D starfields with ease, chasing squadrons of TIE fighters, dodging shots, getting a ‘laser lock’ on the enemy ships and seeing them break apart into colourful chunks as your lasers hit home.
Every now and then, a differently-shaped ship - looking a lot like a Colonial Viper from out of Battlestar Galactica with ‘EXIDY’ written on the side - would fly by, and if you managed to line up and shoot that ship you would get a bonus and the words ‘GOT US!’ would appear in large, flashing letters.
Simple though it was, Star Fire was one of the first ever games that I found to be truly immersive. Sitting in that cockpit with that large colour screen filling myfield of view, it felt for a while like looking out of a craft instead of merely remote-piloting one from above, as was the norm in most other games. I became pretty good at the game, and before long could post up a boardful of ‘JCM’ hi-scores which would still be there on returning to the arcade a few hours later – no mean feat for a machine in a popular arcade in London.
18 In college, some of us would occasionally attempt versions of popular arcade games, in our own simple way on the PET. Rup put together a pretty decent Space Invaders, and I decided that, as my Big Project, I would attempt to bring something of Star Fire over to the PET... and that I would write the entire program in machine language.
One problem we had with the PET was that there was no sound generator built in to the machine, which made designing satisfying games a bit harder - games aren't really games without a few electronic burbles to signify the firing of shots and the explosions of enemies.
However, we discovered a way to work around it. If you placed an AM radio near the machine while it was working, the CPU would generate RF noise that could be picked up as interference on the radio. And we found that if you altered what the CPU was doing you could cause variations in that noise. If you stuck it into a tight loop, and then caused that loop to lengthen slightly with each iteration, then you could actually hear quite a passable ‘zap’ noise in the interference on the radio.
And so that’s how the sound effects were generated for my first ever all-machine-code game -from a radio standing on top of the cassette deck picking up RF interference tuned into sound effects by sculpting CPU loop lengths!
Eventually the teacher whose name i forget but who looked a bit like Phineas out of the Freak Brothers came up with a small hardware device which attached to the I/O port on the PET and which could generate sound by toggling one of the I/O bits, and that made for slightly better sound effects, but i still have a special fondness for our AM radio hack.
19 Star Fire was to be my PET magnum opus, taking several weeks to complete. Hand-compiling the machine code for a game of any reasonable complexity was a painstaking task. But between us, me and the rest of the PET geeks had amassed a fairly large body of work by this time, and we were never short of games to play when we weren't directly engaged in creating more.
In the second year I was at sixth form, the computing department had been moved into its own small building – a wooden hut with a few small rooms, each of which housed one machine and one large classroom. People - even some non-geeks - would congregate in the PET room to play the games, and, since this was before it was really practical to save hi-scores, before long the walls of the PET room got covered in hi-score lists as people wrote down their personal bests on the wall in biro. This eventually came to the attention of the Powers That Be, who were not amused and the whole lot had to be painted over.
We also acquired a new PET - still only 8K, but with a green screen and a proper keyboard instead of the somewhat cramped calculator-style one on the original. On the very day it was delivered I was queueing up to get a crack at it. I managed to be the first one on the new machine, and I duly loaded up my game.
Steering in Star Fire was accomplished using the numeric pad - 8 for down, 2 for up, other directions and diagonals derived from the keys around the ‘5’ key – and I think it was ‘space’ to fire. In the course of a game, the keying action could get quite hectic as you scrolled the field of little PET-character TIE fighters around into your laser sights. I'd even put in an Exidy-style bonus ship that would come around once in a while and which, if shot, would refuel your ship and restore your shields (in the wonderfully weird logic of games of that era).
I sat down at the new PET and began to play - noting with admiration that there was a lot less ‘snow’ interference from accessing video RAM than on the old machines (this was way before I'd heard of VSYNC).
I got into the rhythm of the game and wave after wave of green TIE fighters succumbed to my lasers. Then, in the throes of manoeuvring my ship with the numeric pad, my finger slipped off a key that I was holding down - and with a SPANG!, the key sprang up and flew off the keyboard and halfway across the computer room - just as Phineas Freak came in to check that the new machine was working properly.
Fortunately, it proved easy enough to clip the key back onto the keyboard again, and I escaped with a minor bollocking, but for a few moments I'd been convinced that I'd broken the new machine within minutes of its arrival.
A man called Sinclair – a bit of a boffin from the looks of him – had designed a really cheap computer, and he'd gone to a school with some prototype machines for the pupils to try out. The news footage showed pupils sitting in front of televisions to which were attached odd-looking little machines, looking a bit like squashed calculators but without any LED numbers.
The keyboard appeared to be printed on, being totally flat, and - at the time I assumed it was some kind of TV interference - the display on the tellies seemed to flicker whenever anyone entered a keystroke. It was certainly no PET - but it was recognisably a computer, evidently running BASIC - and it was to be introduced at a then stunningly low prove of £100. A price that even I might be able to afford, given a bit of saving and cleaning of the offices at Lansing Bagnall.
When my parents came home, I excitedly told them about the cheap computer I'd seen on telly, and although at first they were dubious (why did I want one of those? surely I'd get one and then it'd be unused in a cupboard after a few weeks…) but, eventually they relented, and I even extracted a promise that if I could save up fifty quid on my own they'd match that so I could have the machine sooner.
Excellent stuff. At last, nearly two years after I'd first set eyes on a computer, there was a real chance that I could get one of my own. The idea of having your own machine that you could use exclusively and never have to worry about the next person shoving you off to claim their time slot was tremendously exciting. I don't think I'd keenly anticipated a purchase so much in my life. I went on cleaning my offices at Lansing Bagnall and putting away a few quid each week towards my goal.
A couple of months after the news piece on telly, the little machine was released and adverts and articles about it started appearing in computer magazines. Us geeks devoured these hungrily, soaking up every detail and collectively drooling in anticipation. The machine was called the Sinclair ZX-80, and it really was a barely minimal machine - made out of snap-together vacuum-formed plastic, with a small membrane keyboard, and with only 1K of memory inside (you could buy a plug-in ‘RAM pack’ to increase the memory to 4K). But still, we were ingenious coders, and I was sure that somehow I'd be able to make some simple games even in that tiny amount of RAM.
Demand for the machine was overwhelming the small company that Sinclair had formed to sell it, and at first there was a six-week waiting time between ordering one and actually receiving it. I couldn't afford to order mine yet, but Rup managed to acquire some funds and he ordered his straight away. Eventually, it arrived, and the same weekend I set out on my bicycle to visit his house so that I could finally have a hands-on look at it.
We sat and geeked the evening away, writing small BASIC programs on the ZX-80's odd little keyboard. It was strange. It insisted on entering whole keywords with a single keypress, and there were different SHIFT modes you had to use to get particular keywords, and some you had to type in full (these were listed in a small sticker on the front of the machine's white plastic lid). Not at all like the PET's screen-oriented editing, and a bit awkward at first.
And that flicker I'd seen on the news piece wasn't TV interference at all, it was a result of the fact that if the little machine was actually doing ANYTHING else apart from generating the display - running a program or even reading a key-press - then it had to turn off the TV display. This was a little disappointing. How were we going to make games move if the computer could only run programs with the screen off? It also made entering code a somewhat epilepsy-inducing experience.
None of which was enough to put me off buying one. Just the prospect of being able to write code, at home, on my own machine, whenever I felt like it was enough for me to forgive any of its little foibles (and it had plenty of ‘em). I continued saving my Lansing Bagnall money...
21 Back in the real world, I carried on doing what I'd actually came to college to do - get my A-levels and ultimately a place at University. I can't say I shone at any of my subjects, mainly because most of my learning and studying energy was focussed entirely on the school's computers.
By that time, me and Rup knew considerably more than any of the teaching staff about the minutiae of how CPUs worked just through the practical knowledge we gained from writing our games. But, unlike Rup, who was properly on the comp.sci A-level, I would end up with no qualification to show for it, since i wasn't on the course and wouldn't get to take the exam. I muddled along, barely competently, in maths, physics and Eng Lit.
I got conditional offers from a couple of Universities and was invited along for interview. The first place I went to was the University of Aberystwyth - a Welsh seaside town I'd visited when i was a child going on holiday to Wales every summer. I took the train there and arranged to stay overnight in a bed and breakfast - quite an exciting thing for me in those days, since I hadn't been away from home much.
I remember being met at the university by a girl called Sian Rhys, the daughter of a Welsh family who'd been our neighbours when I was a kid. She was already a couple of years into her degree at Aber, and she kindly met me and showed me around, and told me about the vast number of pubs in Aber, which sounded OK to me.
About the interview itself I don't remember a lot - I am certain that I enquired about the possibility of transferring to a computing course, but was told that the A-levels I was going for would admit me only to the physics course I'd specified, and that comp.sci courses were oversubscribed, and I needed the matching A-level to get a place on one. Apart from that, it was standard stuff. I'd get in if I got certain grades on my A-levels.
Interview over, I had the evening to myself, so I set out in search of sustenance, and had fish and chips and, in one of the many pubs, a couple of beers. As it was a seaside town, there was a pier, and at the foot of the pier was an arcade. Replete and happy after my couple of libations, I set out in search of gaming…
22 I don't remember what else was in that arcade, because one machine captured my full attention - a big black Atari Lunar Lander vector cab. The objective of the game was simple - control the orientation of your lunar module with the buttons, and fire the craft's engine with a big, satisfying throttle handle.
The sound on the cab was turned up very loud and the machine shook with the roar of the engine when at full thrust. You had a limited amount of fuel with which to decelerate your craft from orbit and achieve a soft landing on one of several plateaux amongst the lunar mountains, depicted in glowing white vectors.
The game was tricky at first, and my first few attempts ended with the module flying into pieces and a little message appearing telling me that I'd destroyed a very expensive spaceship and made a large crater in the ground. The controls were simple but gave good control once mastered, and before long I was able to set the spacecraft down intact – at first on the widest and lowest-scoring plateau, and eventually, gently easing it down onto the smaller, higher-scoring, but much trickier landing sites.
I really loved the feel of the game – bleeding off the speed with prudent firings of the rocket motor, taking advantage of freefall and inertia to get where I wanted to go without using too much fuel, but being certain to allow time and fuel to decelerate and land gently before the fuel ran out. It felt really good being able to interact with this simple physical simulation, and it planted in my mind an appreciation of such games that I still have to this day, especially when I fire up STEem for a game of ‘Virus’ or VICE for a bash on ‘Thrust’.
Eventually, the college year started to come to a close and it was time for the A-level exams. I really can't remember that much about the taking of them - it was the usual curious exam-time mix of anxiety and freedom, in that you had to actually sit the exams, but in between them you had no lessons and were free to do whatever you like. In our case, this meant driving round our usual haunts in Mole's Vauxhall Viva, or just mooching round Basingstoke (and, of course, playing our games on the college machines).
Then, it was all over. I remember that we all had leaving interviews with the head teacher (and I got bollocked one last time for not wearing a tie) and then we were free – out of the educational system for the first time in our lives. Not yet sure if we'd get to re-enter it as University students after the summer.
And finally I got enough money together and put in my order to Sinclair Research for my very own ZX-80.
A few weeks later, one morning, two items of mail arrived addressed to me. My mum brought them into my bedroom, along with a nice cup of tea. One was an envelope containing my A-level results, and the other was a parcel from Sinclair Research, containing my ZX-80.
The contents of one of those items was to determine the path of the next twenty-four years of my life...
Jeff Minter, June 2004.