Vault · archived work, not current thinking

Space Chase

1989 · HP-28S calculator

The HP-28S display: three black pixel spacecraft of different designs scattered across a pale green LCD strewn with single-pixel stars. One at left has a round body between two flat side panels, one at centre has a domed hull with two antennae, and one at upper right has three prongs.

▶ Play it in your browser

Three ships drift across a 137×32 pixel screen. Two of them move at random. One of them is yours, and the game ends the moment they touch. There is a starfield of thirty pixels behind it, a hyperspace jump you can use three times, and a score that counts tenths of a second survived.

It was written on an HP-28S — a clamshell calculator with an alphabetic keyboard on the left half and a scientific one on the right. Randy Weems and I got them in a first-year calculus course at Tennessee Tech taught by John Selden, who was publishing on the 28S as a programming environment rather than a graphing aid, and who created a third-quarter course in “algorithm design” so a few of us could keep going. Space Chase came out of that course.

The HP-28S appeared in 1988 at $235. Hewlett-Packard introduced it at the January meeting of the American Mathematical Society — to a room of mathematicians, which is how a calculus professor came to be publishing on it as a programming environment two years later. It replaced a 1987 model, the 28C, that had two kilobytes of memory. The 28S had thirty-two.

I was an electrical engineering student, and it was the only programmable machine I owned that fit in a pocket. That is the whole reason any of this exists. You wrote the program on the machine that ran it, sitting wherever you happened to be sitting — no host computer, no cross-compiler, no editor but the calculator’s own alphabetic keyboard. The iPhone was eighteen years away.

The whole thing is one idea. The 28S display is 137×32 pixels, which is 548 bytes, and the calculator’s →LCD command takes a plain character string. So the screen is a string. Each ship is a 548-byte string with the sprite in it, and moving a ship means rotating its string — UP shifts by 137 bytes, exactly one page, and LEFT and RIGHT shift by six. Drawing the frame is OR. Detecting a collision is XOR and a comparison against what should be there. There is no collision-detection routine anywhere in the program, because the same operation that composites the screen also answers the question.

The six programs that read the controls are named UP, DOWN, LEFT, RIGHT, SHIFT and INS, and that is not a naming convention. The 28S KEY command returns the name of whatever key you pressed; the game’s entire input system is IF KEY THEN STR→ END, which compiles that name and runs it. The legends printed on the calculator’s case are the dispatch table. Rename a program and the key stops working.

You can watch all of that happen a token at a time: Space Chase, one token at a time runs the published listing on the interpreter with the stack and the screen beside the code, in three passes — how a ship gets built out of twelve numbers and a round trip through the display, what one frame does, and why moving a ship is a string cut in half with the halves swapped. The game in the middle pass runs on a fixed seed, so it plays the same seventeen frames every time and ends in a collision you can step into.

An HP-28S opened flat. The left half holds a printed object-type reference card above an A-to-Z keypad; the right half holds the Hewlett-Packard badge, a blank LCD strip, and a scientific keypad with six blank softkeys along its top row. The dispatch table, printed on the case. Six blank softkeys run under the display, and the legends sit above them on the shell: INS, DEL, and the four cursor arrows. Photo by striegel, CC BY 2.0.

Why it only exists on paper

The HP-28S had no wire port. Infrared out to a printer and nothing else — no way to send a program to a computer, no way to save one anywhere. Whatever survives from that machine survives because somebody printed or wrote it down.

So this game appears in none of the floppy backups. Those are all from the HP-48SX that came later, and by then Space Chase was two years old and had never been anywhere a disk could reach. What did survive was a photocopied set of notebook pages: a hand-written manual with a drawing of the keyboard, a printed listing of all ten programs, and two pages of hand-assembled System RPL for a faster version, five nibbles to a line with the mnemonics inked in beside them. Those two pages are transcribed and decoded at Space Chase, hand-assembled — the nibbles are written least significant first, and turning them round is the only thing you need to know to read the whole document.

It turns out there was a second copy. Selden put our programs in his conference paper — The HP-28S, Calculus, and Programming, Ohio State, 1990 — so the full listing has also been sitting in university libraries since before I could legally drink. The published version differs slightly from the notebook: the horizontal step is symmetric at six bytes rather than drifting eight-and-nine, and the key handler has a type check the notebook version lacks.

The pages

Both copies are here.

The scan is a photocopy of a dot-matrix printout and it had not improved with age, so it is flat-fielded and pushed for contrast here; the untouched capture is in the repository. In the transcription, the few characters I had to supply are marked [+] and the few I could not read cleanly [?].

Read the two listings side by side and you can watch a program get revised: MAKE is called L→LCD in the paper, the starfield is built from an explicit PPAR rather than PMIN/PMAX, and the horizontal step settles down to six.

The version here

You can play it above. It is not an emulation — there is no legally distributable HP-28S ROM, so nothing can run the original binary in a browser. Instead it is a small interpreter for the subset of HP-28S RPL the game uses, executing the 1990 published listing directly. The ships, the starfield, the hyperspace sweep from 512 Hz to 1500 Hz, the score in tenths of a second: all of that comes out of the listing rather than being reimplemented.

One number is not evidence. Nothing anywhere records how fast the game actually ran, and a real 28S was pushing several 548-byte string operations through an interpreter every frame. The default speed is the one that feels right to me, which is memory, not measurement. The other two settings are there because I could be wrong.

Written with Randy Weems and Shawn Yeager. The drawing tool that made the ships is Doodle.

The photograph of the calculator is by striegel, via Wikimedia Commons, under CC BY 2.0; the studio background has been removed here. Mine is long gone.

← Back to games