From e7b23aa7cd3c0c53b9739d1cd88778ad80ddc257 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Thu, 3 Dec 2026 08:41:05 -0500 Subject: [PATCH] M3.1: read cursor keys, SHIFT and SPACE from the keyboard matrix Co-Authored-By: Claude Opus 5.5 --- docs/manual-tests.md | 23 ++++++ docs/toolchain.md | 1 + docs/verification-status.md | 3 +- src/keys.inc | 137 ++++++++++++++++++++++++++++++++++++ src/main.s | 18 ++--- tools/check-keys.ps1 | 127 +++++++++++++++++++++++++++++++++ tools/check-people.ps1 | 10 +-- 7 files changed, 305 insertions(+), 14 deletions(-) create mode 100644 src/keys.inc create mode 100644 tools/check-keys.ps1 diff --git a/docs/manual-tests.md b/docs/manual-tests.md index 51c0d84..2283298 100644 --- a/docs/manual-tests.md +++ b/docs/manual-tests.md @@ -122,6 +122,29 @@ Verifies: R3 Setup: VICE x64sc, NTSC (-ntsc), warp off. Start: `pwsh -File tools/run.ps1 -Target c64` +At M3.1 (keys only, no scrolling yet): run `pwsh -File tools/check-keys.ps1` and +expect `[PASS] all 8 key scenarios decode correctly`. Then start the program and, +while the map is shown, hold each key below for a second or two and release it. +Until M3.2 the border colour shows the direction that is held: + +| Keys held (VICE PC key) | Border | +|---|---| +| nothing | brown (same as the background) | +| CRSR RIGHT (Right arrow) | light green | +| SHIFT + CRSR RIGHT (Left arrow) | cyan | +| CRSR DOWN (Down arrow) | yellow | +| SHIFT + CRSR DOWN (Up arrow) | white | +| CRSR RIGHT + CRSR DOWN (Right + Down arrows) | orange | +| SHIFT + both (Left + Up arrows) | light blue | + +Expected at M3.1: the colour stays as long as the key is held and returns to +brown on release; both the left and the right SHIFT key work; the dots keep +moving smoothly. Tapping SPACE gives a new map; holding SPACE gives exactly one. +(Right + Up or Left + Down cannot be told apart on a real C64, because SHIFT +reverses both cursor keys; they show grey or one of the colours above.) + +From M3.2: + Steps: 1. Hold each cursor key (with SHIFT for up and left) until the view stops. diff --git a/docs/toolchain.md b/docs/toolchain.md index 4bf5c61..f98d40b 100644 --- a/docs/toolchain.md +++ b/docs/toolchain.md @@ -56,6 +56,7 @@ Starter configurations marked verified were exercised by the Foundry's automated - World generation reached its ready point (`MAP READY`) - C64 KERNAL reset vector at $FFFC (machine is in C64 mode) - World check: `pwsh -File tools/check-world.ps1` validates the tile data saved by the smoke test. +- Key check: `pwsh -File tools/check-keys.ps1` runs eight headless VICE scenarios. VICE's monitor cannot press keys, so tracepoints on the `key_row_*` instructions in `src/keys.inc` replace the port B row bits with those of held keys (`r a = `). It checks `scroll_dx`/`scroll_dy` and the border indicator for no key, right, left (right SHIFT), down, up (left SHIFT), down-right and up-left, and that SPACE held from frame 60 regenerates exactly once. Output: `build/check-keys/`. - People check: `pwsh -File tools/check-people.ps1` runs VICE headless (NTSC, warp) for 40,000,000 cycles, logs the people table at the `people_moved` hook every frame through the monitor, and checks that all 16 people stay inside the world, never stand on a water or stone tile, move at most one pixel per step, all move, and start spread over the four screens. It also saves both bitmap buffers before people are drawn and at the last frame, and checks byte for byte that the hidden buffer is the clean map plus the current dots and the visible buffer is the clean map plus the previous frame's dots (no trails, no damaged terrain). It checks that the main loop never misses a frame (x64sc NTSC frame: 263 lines x 65 = 17,095 cycles) and that each people update ends before raster line 51, the first visible line. Output: `build/check-people/`. ### How the smoke test works diff --git a/docs/verification-status.md b/docs/verification-status.md index ca46a6b..18d2959 100644 --- a/docs/verification-status.md +++ b/docs/verification-status.md @@ -14,13 +14,14 @@ manual = `pending`, `confirmed by user ()`, `problem reported ():