Programming PCs circa 2000

 As a teenager I spent a lot of time programming. I was mostly interested in making games, and for this I had to get involved in the fairly low-level structures, such as interrupts, system calls, and I/O ports. While I mostly programmed in C (DJGPP — a C clone that was available for free for PCs, implementing an extended memory module which allowed me to finally relax the limitation of being able to use up at most 640 kB of memory in my games), I had to implement some assembly routines because using a high-level language for this was simply too slow. The most complex graphics routine I implemented was a routine to copy a rectangular block of pixels from one place (usually an off-the-screen buffer) to another in a way to preserve all pixels marked with a special color (a mask).

It was a wonderful world–there is something magical about dealing with low-level operations. The information I needed to display pixels on screen, or to control the mouse felt in a way like knowing a secret code that unlocks the door with the treasure behind it.

Around 2000 I had enough knowledge (all before I ever got a modem!) to compile it into a kind of cheatsheet. Now, about ten years later, it’s time to share it with the world. Of course, very little of it is relevant anymore — although most if not all of the information should still produce the same effects, thanks for the crippling yet comforting fact that PCs have been painfully backwards compatible for the past decade or more.

The PDF is a little dense, so it deserves a brief walkthrough.

  • Some operations were possibly simply by inspecting a fixed location in the computer’s memory. Most of the information could simply be read, but some could also be fetched by writing a particular set of codes in specific locations. Putting information directly in the computer’s memory has never been recommended (and these days, virtual memory makes it almost impossible), but by inserting bytes directly in memory the computer’s behavior could be changed wildly — most times it would crash the OS, but sometimes it allowed you to get infinite lives in your favorite game or get some creepy screen effects. I used to stay up at night and hunt for locations in memory, mucking with which produced the most spectacular effects.
  • Most low-level operations were provided through issuing a set of interrupt operations to the microprocessor. The OS (in this case DOS) would interpret them in a particular way. Usually you needed to specify additional information — you did that by writing directly to the processor’s registers
  • I spent a lot of time figuring out how to display graphics on the screen. Back in the early 2000, everyone’s resolution of choice was a 320×200 resolution with a color table of 256 colors. Since every pixel was a byte, and the colors could be changed globally, this allowed for a number of games that displayed graphics fast and cycled through the colors. Extended modes (called VESA) were also possible and they offered higher resolutions and full color spectra (15-bit, 16-bit or 24-bit)
  • When you wrote a game, you pretty much had to intercept everything that the OS (MS-DOS) tried to do for you. The default mouse offered by MS-DOS was awful, the keyboard had a frustrating delay that you couldn’t get rid of and the OS wouldn’t even inform you when most of the keys were pressed. Fortunately, it was possible to handle the keyboard and the mouse through similar OS interrupts
  • Finally, the document concludes with some common file formats.

Fortunately, technology today has great abstractions and high level routines that make it unnecessary to know most of what’s in the cheatsheet. I am proud to have had to figure all this out, though — in an extension to many Java jokes, I think in order to be a great programmer, you have to understand the technology stack all the way down to microprocessor commands. The effect is a kind of deep connection with technology, the ability to make optimizations based on what’s going on deeper in the stack (such as my need to write assembly code back in 2000), but also a good deal of humility.

Here it is: programming-cheatsheet-2000.pdf