Vault · archived work, not current thinking

Doodle

1989

Doodle screenshot

▶ Play it in your browser

A drawing program for a calculator. Move the crosshairs, press INS to mark a point, press ON to commit. Mark two points instead of one and it draws the line between them. Draw over something that is already there and it disappears.

The machine is an HP-28S, a clamshell calculator I carried through school. Inside is a Saturn processor running at one megahertz, and thirty-two kilobytes of RAM to hold everything: programs, data, stack.

The screen is 137×32 pixels. That is 4,384 pixels, or 548 bytes, so one full-screen picture costs a little under two percent of everything the calculator has. Cheap enough to keep several of them around, which is what Space Chase does with its ships. Cheap enough that a drawing program for this machine fits in two hundred characters.

That last behaviour is not a separate erase mode. The commit is one line —

CLEAR LCD→ n RCL XOR DUP n STO

— which takes what is now on the screen, XORs it against the stored picture, and stores the result. Drawing a pixel that is already lit turns it off. The manual page says it plainly: “Erasing a point: same as drawing a point; just align the cross-hairs with the point to be erased.” One operation, both directions, no state to track.

Doodle is two programs. DOODL runs the loop and owns the picture; LINE does the interpolation, reading the plot parameters to work out the step size and walking from one endpoint to the other. Together they are about two hundred characters of RPL, which is short enough to print whole:

LINE
« → n
  « OVER PIXEL
    IF DUP2 ==
    THEN DROP PIXEL
    ELSE OVER - PPAR DUP 2 GET SWAP 1 GET - C→R 31 / SWAP 136 /
      3 PICK C→R 4 ROLL / ABS SWAP ROT / ABS MAX PPAR 4 GET /
      SWAP OVER / ROT 1 4 ROLL
      START OVER + DUP PIXEL
      NEXT
    END
  »
»

DOODL
« → n
  « n IFERR RCL THEN CLLCD LCD→ DUP ROT STO END
    WHILE →LCD DGTIZ CLLCD DEPTH DUP 0 ≠
    REPEAT
      IF 2 ==
      THEN n LINE
      ELSE PIXEL
      END CLEAR LCD→ n RCL XOR DUP n STO
    END CLLCD "   * * Saved * * " 2 DISP DROP .5 WAIT CLMF 'PPAR' PURGE
  »
»

You run it as 'PIC' DOODL, where PIC is the name you want the picture stored under. DGTIZ is the whole user interface — it hands the machine to the built-in graphics cursor and comes back with whatever points you marked on the stack. Zero points ends the loop, one is a pixel, two is a line.

If you’d rather watch that happen than read it: DOODL, one token at a time steps through the program on the real interpreter, with the stack and the screen beside the listing. It draws a point, draws a line, then marks the same point again and the point disappears — forty-four lit pixels, then forty-three, and nothing in the program ever knew the pixel was there.

Doodle redrawing SHIP1, one pixel at a time. The tool, remaking the thing it originally made.

What it was for

This is where the Space Chase ships came from. That game stores each ship as a list of twelve bytes — 255 24 24 36 102 90 90 102 36 24 24 255 — and read the right way, one byte per column of eight vertical pixels, it is a small winged fighter with a hexagonal cockpit. Someone sat with the crosshairs and placed those pixels.

The two halves came back separately and neither knew about the other. The ships arrived as a byte list in a photocopied program listing. The editor arrived as source printed on page 285 of a conference paper. Running DOODL again and feeding it those same pixels closes a loop that was open for thirty-seven years.

The paper

Both programs were published in The HP-28S, Calculus, and Programming — John Selden, Annie Selden, Michael Morrison, Randy Weems and Shawn Yeager, Addison-Wesley, 1990. John Selden taught the calculus course that put these calculators in our hands and built the follow-on course the programs came out of. The full account is on the catalog entry.

Annie Selden is professor emeritus at Tennessee Tech and a founding member of the Association for Women in Mathematics. John Selden died in 2024.

The pages

The notebook heads that manual page DOODLE, with an E, for a program named DOODL. Both are right. Nothing in that notebook runs past five characters — DEPOS for Deposit, BALAN for Balance, HISCR for High Score, SPACE for Space Chase — because five is how wide a menu label is. The ceiling that clipped the name is the same one Space Chase runs on: its controls are named after key legends, and key legends fit the same five.

The notebook listing and the one on page 285 of the paper agree line for line. That is not true of everything in that notebook — Space Chase drifted between the two copies, and the scrolling routines lost a program entirely — so it is worth saying where the record is clean.

The version here

You can draw with it above. As with Space Chase, it is an interpreter running the published listing rather than an emulation — there is no distributable HP-28S ROM. The digitizer is live, so the crosshairs are genuinely yours, and the XOR commit behaves exactly as the manual describes. The keys shown are only the ones this program listens for: the menu row under the display, and ON.

The calculator itself is not simulated. Only the parts that this program used.

← Back to tools