From 3a63d55b67dc472a1c1f6d29598b63e298850246 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Thu, 3 Dec 2026 16:31:14 -0500 Subject: [PATCH] M3.4: long scrolling runs and measured frame budget; timing bar build - People movement moved out of the vertical blank (it overran the first map line with nearly all 16 people in view); drawn at the next vertical blank. - Optional timing bar (--asm-define TIMING_BAR, tools/run.ps1 -TimingBar) in a separate PRG; hook labels frame_start, frame_done, rebuild_ready. - tools/check-scroll.ps1: per-frame budget from CPU clocks, rebuild length, -Long 5-minute tour with 21 byte-exact stops, -ParseOnly, right-edge fix. - tools/lib.ps1: asmDefines for ca65 symbols. - docs: MT3.2 long-run steps, new MT3.4, toolchain, verification status. Co-Authored-By: Claude Opus 5.5 --- docs/manual-tests.md | 44 ++++++++- docs/milestones.md | 2 +- docs/toolchain.md | 4 +- docs/verification-status.md | 13 ++- project.json | 30 +++++- src/main.s | 29 +++++- src/people.inc | 6 +- src/scroll.inc | 1 + src/status.inc | 13 ++- tools/check-scroll.ps1 | 184 ++++++++++++++++++++++++++++++------ tools/lib.ps1 | 1 + tools/run.ps1 | 14 ++- 12 files changed, 299 insertions(+), 42 deletions(-) diff --git a/docs/manual-tests.md b/docs/manual-tests.md index 62db527..0b33ff0 100644 --- a/docs/manual-tests.md +++ b/docs/manual-tests.md @@ -157,16 +157,56 @@ Verifies: R1, R5 Setup: VICE x64sc, NTSC (-ntsc), warp off. Start: `pwsh -File tools/run.ps1 -Target c64` +Automated first (M3.4): `pwsh -File tools/check-scroll.ps1 -Long` (takes about 10 minutes) +should print `[PASS] all 4 scroll scenarios: ...`; its `tour` line reports the stops checked +byte for byte. + Steps: 1. Scroll slowly past several people. +2. From M3.4: scroll around the whole world for about 5 minutes (every direction, with + stops), then stop with several people in view and watch them for a minute. +3. From M3.4: find a place where many dots are in view near the top of the map (or wait + for them to gather) and scroll left and right there. Expected: -- Dots stay on the terrain they walk on +- Dots stay on the terrain they walk on, while scrolling and after long runs - 16 dots in total across the world -- No trails left behind +- No trails or damaged terrain left behind, even after 5 minutes +- No flicker or tearing of the dots near the top of the map, even with many dots in view Verifies: R2, R3, R5 +### MT3.4: Frame budget timing bar (c64, M3.4) + +Setup: VICE x64sc, NTSC (-ntsc), warp off. +Start: `pwsh -File tools/run.ps1 -Target c64 -TimingBar` (a separate build, +`build/land-map-64-timing.prg`; the normal program is not changed). + +The border colour shows what the CPU is doing during each frame: + +| Border | Work | +|---|---| +| white | scroll step, buffer flip, people restore and draw (vertical blank) | +| yellow | keys, status text, people movement | +| cyan | rebuilding the hidden buffer for the next scroll step | +| red | raster interrupt (the split to the status area, and the top of the frame) | +| brown | idle, waiting for the next frame | + +Steps: +1. Leave the view still for a few seconds. +2. Hold a cursor key and watch the border while the map scrolls. + +Expected: +- View still: the border is mostly brown, with a thin red stripe at the status split + (the white and yellow work happens in lines the border mostly does not show). +- Scrolling: the border is cyan down to near the bottom of the screen (the rebuild uses + the frame's spare time), with the red stripe at the split and a little brown below. +- In both cases the border pattern is steady from frame to frame, not rolling or + jumping: the program keeps up with every frame. (Small specks at colour changes are + normal for a border-colour timing bar.) + +Verifies: R3.3, A4 (measured numbers: tools/check-scroll.ps1 budget lines) + ### MT3.3: Status area (c64) Setup: VICE x64sc, NTSC (-ntsc), warp off. diff --git a/docs/milestones.md b/docs/milestones.md index ea5fd42..51fe95e 100644 --- a/docs/milestones.md +++ b/docs/milestones.md @@ -53,6 +53,6 @@ Requirements: R5, R6, R3, R2 | M3.1 | Keyboard matrix reading for the cursor keys with SHIFT, held-key repeat. | R5 | Scroll direction from keys | Manual test MT3.1 | | M3.2 | Split screen: raster interrupts switch to text below a 20-row map and back at the top of the frame; status text screen and ROM font copy in both banks; status lines with the people-in-view count. | R6, R1 | Steady 20-row map with 5 status lines below | Manual test MT3.3 | | M3.3 | Fine scroll via $D016/$D011 in the 38-column, 20-row map area; rebuild the hidden buffer from tiles over 8 frames and flip on wrap; stop at world edges; show the view position in the status area; draw people relative to the view (in the shown buffer during vertical blank while a rebuild runs). | R5, R3, R6, R2 | Smooth scrolling across the world under a fixed status area, people in place | Manual tests MT3.1, MT3.2 and MT3.3 | -| M3.4 | Check that people stay aligned with the terrain over long scrolling runs; measure the frame budget with a border-colour timing bar. | R2, R3, R5, R6 | People stay aligned with terrain over long runs; budget measured | Manual tests MT3.2 and MT3.3 | +| M3.4 | Check that people stay aligned with the terrain over long scrolling runs; measure the frame budget with a border-colour timing bar. | R2, R3, R5, R6 | People stay aligned with terrain over long runs; budget measured | Manual tests MT3.2, MT3.3 and MT3.4 | Manual verification: see docs/manual-tests.md section M3. diff --git a/docs/toolchain.md b/docs/toolchain.md index 0348d9c..e5ee0c9 100644 --- a/docs/toolchain.md +++ b/docs/toolchain.md @@ -40,6 +40,8 @@ Check them with `pwsh -File tools/check-prereqs.ps1`. Lookup order for each tool | Build all targets | `pwsh -File tools/build.ps1` | | Build one target | `pwsh -File tools/build.ps1 -Target ` | | Run in VICE | `pwsh -File tools/run.ps1 -Target ` (add `-Video ntsc` to try NTSC) | +| Run with the timing bar | `pwsh -File tools/run.ps1 -Target c64 -TimingBar` (assembles with `--asm-define TIMING_BAR` into `build/land-map-64-timing.prg`; cl65's `-D` only defines C symbols, so assembler symbols go in the build's `asmDefines`) | +| Long scrolling run | `pwsh -File tools/check-scroll.ps1 -Long` (adds the 5-minute tour; about 10 minutes; `-ParseOnly -NoBuild` re-checks the last run's logs) | | Automated smoke test | `pwsh -File tools/smoke.ps1` (exit 0 pass, 1 fail, 2 missing tool, 3 manual only) | ## Target settings and verification status @@ -59,7 +61,7 @@ Starter configurations marked verified were exercised by the Foundry's automated - World check: `pwsh -File tools/check-world.ps1` validates the tile data saved by the smoke test. - Split check: `pwsh -File tools/check-split.ps1` runs VICE headless for 20,000,000 cycles. It logs the raster line and cycle of the three mode writes at `split_store` (src/status.inc) every frame and requires them to start between line 210 cycle 53 and line 210 cycle 64. That window was measured by building with split delays 6-12 under `+autostart-delay-random`: starts at 210:40-51 damaged the last map line, starts at 211:0-11 damaged the first text line, and 210:50-211:1 were clean; the shipped delay starts at 210:55-61 at y-scroll 3. Tracepoints on the `key_row_*` instructions fake "no key" and then scroll down three cells and back up (phase byte at $CFF0, VICE conditional checkpoints), so every map y-scroll value 0-7 is split and checked against the same window (y-scroll 2, a bad line at line 210, uses a shorter delay; measured 2026-12-03: starts at 210:58-64). It also checks that a split happens every frame, that after each status update the people-in-view digits equal the number of people whose dot is at least partly in the visible window (computed by the script from the people table and view), and (coarsely) the screenshot colours at the boundary. Output: `build/check-split/`. - 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` 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/`. -- Scroll check: `pwsh -File tools/check-scroll.ps1` runs three headless VICE scenarios (edges, middle, reverse). Each is a list of phases: fake held keys (as in the key check) until a condition on the program state is met at `people_moved` (a `move_frame` value or a view position). The phase number is kept in free RAM at $CFF0 and moved on by VICE conditional checkpoints (`trace exec $addr if (@cpu:$addr == $nn) && (...)`: the parentheses are needed, and checkpoints at one address run in the order they were defined, so phase changes are defined latest first). Every frame it logs the phase, view, scroll registers, visible buffer, flip state and people table. It checks that the view moves at most one pixel per axis per frame and only in the direction of the keys read the frame before, stays inside 0-336 x 0-244 and stops at the edges, that $D011/$D016 match the fine scroll, that in every frame the shown buffer is complete and built for the view's cell (a half-rebuilt buffer on screen tears the top of the map), that nothing is stored into the shown buffer's map screen RAM or bitmap during raster 55-210, that no frame is missed and the people update ends before raster 55, and reports frames where a held key did not move the view (stalls, allowed up to 40). At the end it compares the buffer about to be shown, byte for byte, with a fresh render of the world at the view plus the people's dots (and, when a flip is pending, the shown buffer with the previous frame's dots). Any monitor script error fails the check. Output: `build/check-scroll/`. +- Scroll check: `pwsh -File tools/check-scroll.ps1` runs three headless VICE scenarios (edges, middle, reverse). Each is a list of phases: fake held keys (as in the key check) until a condition on the program state is met at `people_moved` (a `move_frame` value or a view position). The phase number is kept in free RAM at $CFF0 and moved on by VICE conditional checkpoints (`trace exec $addr if (@cpu:$addr == $nn) && (...)`: the parentheses are needed, and checkpoints at one address run in the order they were defined, so phase changes are defined latest first). Every frame it logs the phase, view, scroll registers, visible buffer, flip state and people table. It checks that the view moves at most one pixel per axis per frame and only in the direction of the keys read the frame before, stays inside 0-336 x 0-244 and stops at the edges, that $D011/$D016 match the fine scroll, that in every frame the shown buffer is complete and built for the view's cell (a half-rebuilt buffer on screen tears the top of the map), that nothing is stored into the shown buffer's map screen RAM or bitmap during raster 55-210, that no frame is missed and the people update ends before raster 55, and reports frames where a held key did not move the view (stalls, allowed up to 40). At the end it compares the buffer about to be shown, byte for byte, with a fresh render of the world at the view plus the people's dots (and, when a flip is pending, the shown buffer with the previous frame's dots). It also logs the CPU clock at `frame_start`, `people_moved`, `frame_done`, the KERNAL interrupt entry ($FF48) and exit ($EA81), `start_rebuild` and `rebuild_ready`, and prints a budget line per scenario: frame period, vertical blank work, main loop busy and idle cycles, interrupt cycles, and how many frames each hidden-buffer rebuild took. With `-Long` it adds a `tour` scenario (about 23,000 frames, six laps over the whole world by rows and by columns, 21 stops) that saves and checks both buffers byte for byte at the end of every stop. Any monitor script error fails the check. Output: `build/check-scroll/`. - 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 10c6615..eb752dc 100644 --- a/docs/verification-status.md +++ b/docs/verification-status.md @@ -17,10 +17,21 @@ manual = `pending`, `confirmed by user ()`, `problem reported ():