My First Game

Marco Lopes bio photo By Marco Lopes Comment

Recently I found myself reminiscing about the first game I ever made… Actually, it was the second game I ever made. The first one was a text only game, where the computer would prompt you to enter some values related with managing a space station, and you had to keep the space station going for as long as possible, by deciding how much to invest in different things, what to buy, and so on.The objective was to last for as many turns as possible, but somehow, I never managed to quite get the balancing of the game right and would never last more than 5 or 6 turns. But that’s not the game I’m here to talk about.

The game I’m here to talk about, my first ever game featuring graphics and animations, happened some time around 1990 or 1991. I was in secondary school then, and had a computer science class where we used Pascal. Pascal, for those of you who don’t know is a compiled programming language that was quite popular in teaching institutions back then. The story begins one day, when the teacher gave us an assignment where we had to make a game. While everyone else decided to go with a text based game (including someone who made one called President which was exactly the same game mechanic I had made for my Space Station game a year or so before, but featuring a country), I decided to go crazy and make a game with graphics and stuff moving on the screen.

Because the context changed so much since then, I feel I should explain what I mean by a “text game” and a “graphics game”. What I’m telling here, happened in a pre Windows as OS era, around the same year when Linus Torvalds first started making the Linux kernel, and during Apple’s phase after Steve Jobs had been kicked out and the company was almost dying. What this means, is that personal computers at the time basically had one option. Running DOS.


In DOS you had text mode, which would give you a 80x25, or optionally 40x25 grid (VGA and later Super-VGA would give you a few other grid sizes) where you could put characters. Then, there was this magical thing called “graphics mode”, where you would use some assembly to send some instructions to the hardware, and the screen would switch to a different resolution and allow you to put things on the screen pixel by pixel. It’s been 26 years now, so I can’t remember much, but I think it involved the numbers 10, 13, something called interrupts, and registers (AH and AL maybe?). We would do this, and we would be at the amazing resolution of 320x200 with 16 colours, if I recall correctly. Then, we would have to, still in assembly, implement a function to put pixels on the screen, and if we needed, a line, circle, etc…

So back to the game. I decided that using ASCII and 80x25 was not where I wanted to go with my game, so the first thing I needed was some graphics. Unlike today, creating, loading graphics, and putting them on the screen was another tricky problem. My solution at the time was to make a simple editor where I could select colours from that pallete of 16, and then colour pixels in a large window, with a small preview of how the image was going to look on the side. This editor would then save the file and allow me to edit the next image which would then be saved contiguously in the same file. Each image had to have the same size, and I seem to remember that the size was passed as a parameter to the editor, which meant that if I passed the wrong size, the file would be loaded but the screen would just show a bunch of rubbish (as the editor would read all the wrong bits of the file). The file format was basically a map of bits that could be passed directly to the memory of the graphics card. This means that there were no transparent pixels or alphas.

Now for the game itself. The game would load this file, pick up a specific image, which was a cross-hair, and put it on the screen. I can’t recall how it would find that image, but it was either stored in a separate file, or the game just knew its position in the file. This was what the player would control in the game. Then it would pick up the other images from the file, randomly, and render them on the screen, moving left to right, with a random vertical delta being applied at each frame. The player would then control the cross-hair which had a random shaking effect, and press space to shot at the images flying across the screen. If the player managed to hit the flying images, the score would increase.

Another thing that might be worth to mention, for those who didn’t deal with these things back then is that movement wasn’t like nowadays, where we just update an X and a Y, and some framework takes care of everything else. Moving objects on the screens, also involved storing the previous position and deleting the image from that position. Basically how it was done was, we had a sequence of bytes that represented the pixels and the colours they were lit at. We would send that sequence of bits to the screen, and that would change what was being displayed. Given this, the option to draw a screen would be to either rebuild the whole thing, which would be slow, or just update the parts we needed, making sure that we were also replacing the bytes that represented the previous position of the screen. This means that you also have to manually keep track of what is in front of what so that you draw it last.

Something else that had to be dealt with was vertical synchronisation of the screen. We had to wait for the refresh to hit the top of the screen to put things in the graphics card memory, otherwise we could start drawing mid refresh, which meant that part of the screen would still have the previous frame. This would last just a fraction of a second, but would cause flickering, and sometimes that effect where it looks like part of the character or the scenario has already moved forward/back and other part hasn’t (otherwise known as screen tear).

In the end, I delivered the assignment and the game wasn’t working on the teacher’s computer, so he wanted to give me a bad grade. By now, all of my classmates had played the game, so we started joking, saying that he did play the game, but didn’t want to admit because he got a crap score. He acquiesced to to try and play it in one of the school’s computer, where it worked flawlessly and I ended up having a good grade on the assignment.