Skip to content

Chess as a two-headed appliance: mirrored keypad/terminal UI and PGN save-games

Choose a tag to compare

@domschl domschl released this 22 Aug 14:02
· 313 commits to main since this release

The chess persona becomes a proper appliance: two input devices that behave like one machine, and
games that survive being switched off.

Mirrored two-device UI

The keypad/TFT board and a terminal were already one session for input (0.11.0), but rendering
still hung off whichever loop noticed a change — so typing a move redrew the ASCII board and left
the TFT on the previous position, while playing one on the keypad updated the TFT and left the
terminal showing raw key codes. Whichever device you were not looking at was silently stale.

Rendering now hangs off the position changing instead. A move from either device redraws the
terminal board, the TFT and the 7-segment slots alike, and the engine's replies appear on both, so
a session driven from both reads as one transcript.

PGN save-games (phase 14b)

Games are stored as real PGN with proper SAN — Nf3, exd5, O-O, Qxe7+, with correct
disambiguation — so any chess GUI or online import will open them. That notation is the substance
of the feature: the engine only had long algebraic (g1f3), which no GUI accepts.

  • Auto-save to /sd0/chess/current.pgn after every completed move, from either input device,
    and silent in both directions — a full or absent card must not stop the board being a chess
    computer.
  • Auto-restore when a session starts, which matters most on the persona that boots straight
    into chess with no shell to type load at.
  • new archives the outgoing game to chess/games/game-NNN.pgn first, so starting a new game
    never discards the old one.
  • Named saves at a terminal: save <name>, load <name>, games. The keypad keeps a single
    current game — an eight-character seven-segment display is a poor file picker.
  • Games begun from a custom position carry [SetUp]/[FEN] tags, so they reload as themselves.

A notation self-test ((chess-san-selftest)) round-trips every legal move across positions chosen
for the cases that break naive implementations, then saves and reloads whole games. It found a real
disambiguation bug on its first run.

Upgrade note: the old single-slot chess.save (FEN plus level, under the volume's system/
directory) is not read by this release. Nothing is deleted; the first move of your next game simply
writes a fresh current.pgn under /sd0/chess/.

Verified: 253/253 QEMU tests (RV32 NOMMU + RV64 Sv39), 24/24 hardware-in-the-loop tests against
real RP2350 silicon running these exact images.