Space Chase, hand-assembled

Two pages of the notebook are not a program listing. They are six programs compiled by hand into raw ROM addresses, five nibbles to a line, with the mnemonics inked in beside them — an attempt at a faster Space Chase, written out on ruled paper in about 1989. Nothing on this page runs. It is here to be read.

The key

The nibbles are stored least significant first, so the page is unreadable until you turn each cell round. A8000 reversed is 0008A, which is 138 — and 138 is exactly the number written beside it. That one fact decodes the whole document.

Every cell is either an address — a pointer to a routine in the calculator's ROM, run in sequence — or a number sitting inline. The button switches between the two readings.

What the pages give up

Small numbers were free; large ones cost double

A number like 548 needs two cells: 11920 to say “a number follows”, then the number itself. But 1, 3, 8 and 9 each get a single cell — they are pointers to constants already sitting in ROM. Reverse those four addresses and they land in a straight line, ten nibbles apart:

1 → 0x071B3 3 → 0x071C7 8 → 0x071F9 9 → 0x07203 0x071B3 + 2×0xA = 0x071C7 ✓ + 7×0xA = 0x071F9 ✓ + 8×0xA = 0x07203 ✓

So the small integers live in one contiguous table, each entry ten nibbles long, and referring to one costs a single pointer. Nobody wrote that down. The addresses say it on their own.

DUP is struck out in all four movement programs

The same cell, A4020, is crossed through on UP, DOWN, LEFT and RIGHT, with CD570 written in the left margin beside each one. The mnemonic DUP is left standing, so the operation did not change — the address did. A4020 is used unstruck on page 6, so whatever went wrong, it went wrong only here. That is a revision caught mid-flight and I cannot tell you what prompted it.

This is the notebook's Space Chase, not the published one

LEFT assembles to DUP 9 548 SUB SWAP 1 8 SUB + and RIGHT to DUP 540 548 SUB SWAP 1 539 SUB + — a rotation of eight bytes one way and nine the other. The version Selden printed in 1990 is symmetric at six each way. The hand-assembly follows the notebook exactly, one cell per token, which puts it on the earlier of the two versions.

Four cells in CH1 that should not be there

Between 8 ROLL and DUP 9 ROLLD sit four cells that are not an address at all. Read as a name object — prologue, then a length, then characters, all low nibble first — they say:

21D20 50259 47484 45 21D20 → prologue 0x02D12 50 → length 5 25 → R 94 → I 74 → G 84 → H 45 → T

A global called RIGHT, sitting in the middle of the collision test, where there is no role for it and where the routine reads perfectly well without it. It is transcribed here and left unexplained rather than quietly dropped.

What it was all for

CH1 is the frame and the collision test from SPACE, with one change: the starfield is dug out of the stack with 8 ROLL and pushed back with 9 ROLLD instead of being recalled from a global every frame. We decided a variable lookup per frame was the thing worth removing, and then hand-compiled six programs into ROM addresses to get rid of it.