Think in bits. Spacewar! is written very close to the machine. The programmers have used a frightening array of bitwise manipulation tricks that you don't often see in modern programming. They rotate bits in memory using bit-shifting so that they can store two short numbers in space normally used for one long number. They shift number representations around so that they're in the left or right side of a memory address depending on where a particular instruction call requires that it needs to be, which crops up quite frequently with the display instruction "dpy". They use clever number representations, such as 2's complement, to do fancy arithmetic tricks. They use MACRO to repeatedly double numbers in the preprocessing stage so that they get bit-shifted to the location in memory that they want before execution. They add together the bit codes of instructions to create combined instructions. These tricks are very rarely commented and working out exactly what this "clever" code is doing and why often requires a lot of poking around and reverse engineering.
When we first started looking at the source code for Spacewar! we were struck by a strange section of code at the end, which was solely made up of repeated instructions along the lines of the code in the image on the right. A little bit of reflection and some background reading lead us to discover that this code was setting up a table of all the coordinates of the stars displayed in Spacewar!'s background. The code for doing this is a program in itself called Expensive Planetarium, written by Peter Samson, which displays a faithful recreation of the night sky as visible from MIT and was originally independent of Spacewar, but was later integrated into it.
With this discovery we had enough information to try reconstructing the outlines of the ships from the encodings by hand. Anxiously, we started sketching the outline of the first ship and were disappointed mid way through to find that it seemed like it mostly just a straight line and that there weren't enough instructions to possibly encode the whole outline of a ship. After reflecting for a moment though, we realized it makes sense that the needle ship would be mostly straight, so that was actually not a problem, but the final realization that made everything fit together was that only half of each ship's outline was being encoded; the programmers must have reflected them to draw the other halves.
« Older Conservative bon vivant Michael Anton writes about... | May 7 is International Tell Yo... Newer »
This thread has been archived and is closed to new comments
Buy a Shirt