# Build progress (for whoever resumes) The specification is [handoff-brief.md](handoff-brief.md); its open decisions were all settled on 2026-11-12 as recommended. This file says what is done, with measured numbers, what is in progress and what is left. Certification detail per milestone is in [validation.md](validation.md) ("Build record"); contradictions and unknowns found in the build are C11-C14 and U15-U16 in [undocumented-behavior.md](undocumented-behavior.md). ## Pins - 6502-python `741419a33d1de400a63f7c24c7916bb600694ca2` (its `origin/main`), pokey-python `6ed1ffa73220a967cb2add7e978eabfe11502af0` (2026-11-14: the restarted core; the archived core was pinned at `e276d27`, before that `5a06587`), both `git+file` from the local clones (`pyproject.toml`). Save-state version 3 since this repin. Gates before and after: status.md. - Acid800 1.2 archive `reference/test-roms/Acid800-1.2.7z` (pinned by SHA-256 in `scripts/pinned_files.json`), extracted to `tests/test_roms/acid800/` (ignored): `7z x reference/test-roms/Acid800-1.2.7z 'out/Release/Acid5200/*' 'src/*' README.html -otests/test_roms/acid800`. - MAME 0.285 (the Debian package: `mame` on PATH, hash path `/usr/share/games/mame/hash`; `$MAME`, `$MAME_HASHPATH` override); Atari800 `98cc2dc` as `reference/build-atari800/libatari800.so`. - Python: CPython 3.14.4 (`.venv`), PyPy 3.11.15 / 7.3.23 (`.venv-pypy`). ## How to run Romsets come from the environment (exported in `~/.profile`; a non-interactive shell may need `. ~/.profile`): `NO_INTRO_DIR` (the 5200 set is its `Atari - Atari 5200` folder), `MAME_ROMPATH` (`a5200.zip`, and `a5200a.zip` in a non-merged set), optional `A5200_EXTRA_DIRS`, `MAME_HASHPATH`, `MAME` (`scripts/romsets.py`). The Acid5200 runs need the BIOS: one of those variables, `$A5200_BIOS`, or `~/.local/share/a5200-python/bios/`. ```sh .venv-pypy/bin/python -m pytest -q # unit tests (no ROMs needed) .venv-pypy/bin/python -m a5200_python.acid cpu_ # Acid5200 tests by prefix .venv-pypy/bin/python -m a5200_python.acid gtia_vdelay --switch gtia_at_d000=1 .venv-pypy/bin/python -m a5200_python ROM --frames 300 --png out.png --wav out.wav .venv-pypy/bin/python scripts/lockstep_mame.py TRACE_DIR CART # M1 (a) .venv-pypy/bin/python scripts/dma_charts.py --mode 2 # M2 charts .venv-pypy/bin/python scripts/compare_atari800.py CART --frame 600 # M3 detector .venv-pypy/bin/python scripts/formats_sweep.py [--run 900] # M5 .venv-pypy/bin/python scripts/trak_titles.py CART --press 400:start:10 --play 700 --out DIR # M7 CX53 ``` `PYPY_GC_NURSERY=1M` for parallel PyPy runs; at most 4 at once, `nice -n 19`. Debug helpers used during the build live in the scratchpad only; the observers on `Board.bus_observers` ("R", "W", "D" DMA, "S" WSYNC-repeated read) are the way to trace a run. ## Acid5200 by group (latest full run, 2026-11-12) | Group | Pass | Failing | | --- | --- | --- | | CPU | 7 / 7 | - | | ANTIC | 20 / 20 | - | | GTIA | 10 / 11 | `gtia_vdelay` (C12: the test writes to $D000; passes with `--switch gtia_at_d000=1`) | | POKEY | 9 / 10 | `pokey_twotone` (issue-pokey-0001) | Session 3 baseline (2026-11-12, PyPy, before any change): 46 of 48 standalone tests (20 + 7 + 10 + 9), the same two failures. ## Milestones ### 1. The CPU on the board: PASSED (2026-11-12, commit 2ddb755) MAME lockstep to 10,000 cartridge instructions on River Raid and Pac-Man, 29,868 cycles per frame, the six CPU tests (and `cpu_timing`). Numbers in validation.md. POKEY is the real `pokey-python` from the start. Residue closed 2026-11-12: Pac-Man's 908 divergences are MAME's VBI placement and lumped steal (C15); the board follows [AHRM] 4.8 and the Acid5200 NMI tests. ### 2. ANTIC's time: PASSED (2026-11-12) All 20 `antic_*` and `cpu_timing` pass. `antic_hscrolbug` passes since the playfield request gate and the line buffer's address counter were modelled from [IJOR] sheets 4 and 6 (U15 settled; U17 new). U2 settled at tier 3; U6 settled (behaviour tier 3, the two-cycle pulse from [IJOR] sheet 2). DMA charts: `scripts/dma_charts.py --compare reference/docs/Altirra-Hardware-Reference-Manual-2026-01-02.pdf` reads every cell of [AHRM] PDF pages 90-96 and compares every mode 2-F: 340 rows, 38,760 cells, 36 differ, all C16. Seeded fault `steal_one_short` makes `antic_dmapattern` fail. ### 3. The picture: NOT MET GTIA 10/11: `gtia_vdelay` cannot pass on a real 5200 as built (C12, answered from the 5200 build's listing, [AHRM] 13.2 and the [FSM] decoder: $D000-$DFFF is unconnected); the exit "all 11" therefore stays unmet as written. BIOS logo (frame 150) and Pac-Man's title (frame 600) equal Atari800's frames pixel for pixel; Centipede and River Raid differ only where explained (validation.md); the rest of the smoke list's titles were not compared frame by frame (milestone 5 looks at each). PAM v2.3's ANTIC and GTIA pages run with no error text (GTIA to frame 4,800); v1.1's power-up screen matches [FSM] 3-3. ### 4. POKEY adopted, controllers: NOT MET pokey-python pinned from the start. POKEY 9/10 (`pokey_twotone`, filed in `docs/issue-pokey-0001-twotone-space.md`); the full `acid5200.rom` reaches its summary: 45 passed, 2 failed (one of them `gtia_vdelay`, C12: so the "no failure" exit cannot be met as written either). Controllers wired (RC pots, keypad double scan, KR2 top button, CONSOL). Judged 2026-11-12 (validation.md has the numbers): PAM v2.3 CPU, RAM, ROM pages and v1.1 RAM / Verify OS ROM show no errors, **but a seeded RAM data bit fault is not reported by either cartridge** as driven then (explained in session 3, below); v1.1 Pokey Adjust matches [FSM] Figure 3-4 and follows a scripted stick; v2.3 Pokey Adjust's "no" is its own pot power toggling (disassembled). Keypad and trigger checks live in the Port Test, which needs the loopback board: not judged. Audio in gameplay (`scripts/audio_compare.py`): Pac-Man r = 0.939, Missile Command 0.903, Centipede 0.796 (level envelopes against Atari800), onsets within 1-4 frames, pitch checked against the POKEY writes. **Session 3: the RAM-fault puzzle is explained** (validation.md "the RAM fault, explained"): the fault reached both tests; v1.1 redraws its Error Summary only when the next command starts, v2.3 restarts the pass on a miscompare and shows its lists only when the test ends. Driven that way both catch the seeded fault: v1.1 "00 01" (code 0, chip U25), v2.3 soft errors "10 02" with a transient fault (`--fault-until`). The RAM pages are now a working judge (tier 2 test program). Milestone 4 stays NOT MET on its other exits (`pokey_twotone`, the full suite's two failures, Port Test). Tools: `scripted_run.py --wav --pokey-log --stick --fault ram-bit [--fault-until F]`, `atari800_run.py --press --wav` (it now removes its ROM copies). The two smoke-sweep shards left running at the previous hand-off finished at 14:29 and 14:31 on 2026-11-12, during this session (the session's first process check cut its listing at 20 lines and missed them). ### 5. Every format, every dump: NOT MET (no full sweep) Smoke list at 900 frames, every picture looked at (2026-11-12): 35 of 36 reach a title or attract screen; PAM v2.0 is misclassified by MAME's list (two-chip; one-chip shows its title), see validation.md. Session 3: the loader reads observed-boot rows (`table.json` "measured", docs/cartridge.md "Measured rows"); PAM v2.0 loads one-chip with a reported CONFLICT against the CC0 seed and shows its title; its program still jams after the power-up checks under both readings (U18). Exit (c) done: the 39 unknown 16K dumps booted under both readings, all 39 settled by eye (13 one chip, 26 two chips, none both or neither; the walk wrong once, RealSports Soccer (Beta)); verdicts in `tests/detectors/observed-boot-2026-11-12.tsv`, built into the table. All 286 local images now load by default (size 124, CC0 table 111, measured 51). Still owed for the milestone: the full 900-frame sweep of (b) and the table entries of (d). (Before session 3: 283 of 286 local images loaded by default, U16); `.car` round trips and the type-159 twin resolve to the same payload SHA-1. The 900-frame run was done on the smoke list only (`tests/smoke_dumps.txt`, results in `tests/detector_runs/smoke900_*.tsv`), logging CONSOL values and POT/TRIG reads per dump. ### 6. 2-port row and BIOS revision A: PASSED (2026-11-12, session 3) K-Razy Shoot-Out, Pitfall! and (with input) Mountain King fail on revision A because they copy the 4-port BIOS's vector table from $FE95-$FEA0 (Mountain King: 1.6 M BRK entries in 1,500 frames; runs on the 4-port BIOS); confirmed as the machine's known incompatibility by [AHRM] F.2 (tier 3, mechanism) and MAME's comment (tier 5, the three titles). $BFE7 = 0 boots on revision A (C1). Super Breakout four players: ports 1-4 selected in turn on the 4-port row; the 2-port row stalls at "PLAYER 3 UP" (POT4-7 228, no TRIG2). `a5200a` lockstep: River Raid 1 divergence (power-on), Pac-Man 899 (C15 kind), both to 10,000 cartridge instructions. Seeded fault (4-port BIOS on the 2-port row): K-Razy runs, so the gate sees it. ### 7. Trak-ball, frontend, sweep: NOT MET (session 3) - CX53 model: `controllers.TrakBall` (U11: labelled constants), unit tests in `tests/test_controllers.py`, `scripted_run.py --trak FRAME:VX:VY[:PORT]`. Exercised on Centipede only (the shooter follows a scripted roll left, right and up; a stick run with no input stays centred): 1 of the 12 [FAQ] titles. **Session 5**: all 12 with `scripts/trak_titles.py` (RAM judge plus pictures, stick controls where in doubt): 10 follow, RealSports Football and Baseball not shown (U21); Football and Soccer carry their own trak-ball test (pot power off, POT != 228) and accept the model. No model change; U11 now records [FSM] section 7 and [DANB]'s component values. Table in validation.md. - pygame-ce window: **not built**. pygame-ce is installed in neither venv, and installing it (`pip install pygame-ce` into `.venv-pypy`) was refused by the permission system this session; there is no display here to try a window on anyway. - Speed (2026-11-12, Pac-Man frames 61-300 after a 60-frame warm-up, load ~14): PyPy 3.11.15 16.9 frames/s (504 k cycles/s); CPython 3.14.4 2.6 frames/s (78 k cycles/s). Earlier figures (PyPy 4.9, CPython 2.0) were at load 25-40. - Full sweep against Atari800 at frame 900 (`scripts/sweep_atari800.py`, 4 shards, ~75 min): 182 distinct payloads, 77 identical, 26 within 1 %, 79 beyond, 2 board jams (3-D Asteroids Demo, PAM v2.0), 0 Atari800 failures. Table `tests/detectors/sweep900-atari800-2026-11-12.tsv`; the 79 are the next smoke list, `tests/smoke_next.txt`. ### Session 4 (2026-11-12): the 79 large divergences explained Every one of the sweep's 79 large rows (the 2 jams included) is classed and the class proven (validation.md milestone 7, "The 79 large divergences explained"): 35 edge columns or alignment artefacts, 32 seed-dependent (Atari800 seeds RANDOM from the clock: six runs per title), 2 power-on state, 3 where Atari800 fails the Acid5200 test that covers the case (`pokey_noise`: Ballblazer x2; `antic_pfstarttiming`: Decathlon), 1 KBCODE power-on value (Congo Bongo, U20), 1 neither detector runs (Bounty Bob), 3 a board fault, fixed (Rescue on Fractalus! x2, Behind Jaggi Lines!: players and missiles in GTIA modes, commit e5a875c), 2 jams (PAM v2.0 U18, 3-D Asteroids U19: pots unpowered until the demo sets CONSOL bit 2). POKEY repinned to e276d27 on request (commit b1036a7): Acid5200 46/48, the same two misses, pytest 33 on both interpreters, Pac-Man audio unchanged. Session-4 tools (scratchpad, not committed): six clock-spaced Atari800 runs per title; board power-on variants (`PowerOn(line=131)`, `cycle=57`); board/Atari800 RAM per frame (`libatari800_get_main_memory_ptr`) to find the first differing variable; probes that shift POKEY's polynomial phase, force pot power or preset KBCODE. Each probe is a measurement, not a model. ### Specification close-out (2026-11-13, charter tier x-python) One commit per item of the family's specification brief: provenance wave 2 (no rewrite rows; the Altirra 16K-detection fact withdrawn, provenance.md); romsets by `NO_INTRO_DIR` / `MAME_ROMPATH` (`scripts/romsets.py`); SPDX headers, `NOTICE` and the wave-1 cite rows; the lineage line in README; [status.md](status.md); evidence tags on every constant, rule and quirk in `src/`; [architecture.md](architecture.md). No behaviour change: the only code change in `src/` is where `bios.py` looks for the BIOS (found by SHA-1 as before). The gate's numbers are in status.md. pokey-python was restarted from a clean commit; the board repinned to it on 2026-11-14 (`6ed1ffa`, both venvs reinstalled; gates before and after in status.md). pygame-ce 2.5.8 was installed into `.venv-pypy` this time (`--no-deps`): the window is buildable now, but there is no display here to try it on. ## Left (in the order I would take it; updated 2026-11-12, end of session 4) 1. ~~Loader: read the table's "measured" section~~ done (session 3). 2. ~~Milestone 5 (c): the 39 unknown 16K dumps~~ done (session 3). 3. ~~Why neither PAM cartridge's RAM test reports a seeded fault~~ explained and judged (session 3). 4. ~~Milestone 6~~ passed (session 3). 5. Milestone 7, what remains: ~~classify the 79 large divergences~~ done (session 4; `tests/smoke_next.txt` now lists only the undecidable or uncompared images); ~~fixed-offset (32, 8) counts in `scripts/sweep_atari800.py`~~ done (session 5; the search's offset is still printed); take several Atari800 runs per title in the script (its RANDOM is clock-seeded: done by hand so far); ~~exercise the trak-ball on the other 11 [FAQ] titles and read [DANB]'s schematic~~ done (session 5; U21: scripts that reach Football's running play and Baseball's fielding are owed); build the pygame-ce window once pygame-ce may be installed (the install was refused this session). 6. Milestone 5 (b) "leaves the BIOS" for every image and (d) controller use into the table (the sweep checked jams only); milestone 3 and 4 exits stay unmet as written (C12, `pokey_twotone`, Port Test hardware). 7. Lineage manifest in `/data/emu/emulator-lineage/projects/` (outside this repository; not touched by this build). ## Provenance (session 3, under the owner's rule of 2026-11-12) Nothing written this session was taken from GPL, LGPL or unlicensed code. GPL programs were only run as black boxes (MAME 0.285 `a5200a` traces, libatari800 frames). One GPL file was opened, for a fact and not for how anything is computed: a comment in MAME's GPL driver naming the three titles revision A breaks (that file is no longer fetched, 2026-11-24) (quoted in validation.md milestone 6). The trak-ball model comes from [DANB]'s prose and [AHRM] 13.3; the RAM-test and PAM v2.0 findings from disassembling Atari's own cartridges with 6502-python's disassembler. Earlier sessions' code was not re-audited here (an audit agent is reviewing the repository). Session 4: no GPL, LGPL or unlicensed source file was opened. Atari800 (libatari800) and MAME 0.285 were run as black boxes (frames, RAM through the library's public API, snapshots, Acid5200 ROMs run on them). The GTIA fix comes from [AHRM] 6.5 and 6.9; the cartridges' code was read with 6502-python's disassembler; Acid800's MIT sources were read for what `pokey_noise` and `gtia_collision2` assert. Session 5: no GPL, LGPL or unlicensed source file was opened. Atari800 was run as a black box (the rerun, six extra Pole Position (Beta) runs). The trak-ball work read [FSM] section 7, [DANB]'s trak-ball page and redrawn schematic, [AHRM] 13.3, [BUCH] and the [FAQ]; the games' trak-ball tests were read with 6502-python's disassembler. ## Traps found 1. **PyPy venv's pip 24.0 rejects `git+file:///...@rev` URLs** ("Invalid URL"); upgrade pip in `.venv-pypy` first. 2. **ANTIC's "no NMI armed" sentinel must not be 0**: cycle 0 matched it and fired a phantom NMI at cycle 0 of line 248 (found by `cpu_bugs`). 3. **A stale DMA-clock stop flag** cleared the next line's start token: the clear request must be dropped when the clock is empty (found by a synthetic mode-line test, `tests/test_picture.py`). 4. **Acid5200 comments count cycles one lower than [AHRM]'s charts** (C11). Read the test's behaviour, not its cycle comments. 5. **INC WSYNC's second write must not move RDY's start**: RDY falls two cycles after the first write; a write at 104+ while an earlier latch is pending starts a separate wait for the next line (`antic_wsync`). 6. POKEY's `tick()` is ~60 % of the board's time on CPython (profile of the BIOS logo): about 30 k cycles/s on CPython and 60-300 k on PyPy on this loaded machine. Not the board's to fix. 7. Phase 0 left extracted commercial images in ignored run directories; they were removed. `scripts/mame_trace.py` and `scripts/atari800_run.py` extract into ignored directories: remove each copy after the run (`scripts/compare_atari800.py` does). 8. **Atari800's randomness is clock-seeded**: two runs more than a second apart give different frames for any RANDOM-driven title. Compare against several runs, never one (session 4). 9. **`best_alignment` in `scripts/compare_atari800.py` samples every 8th row** and keeps the first minimum: on full-width or sparse screens it picks a wrong offset (x 22/36, y 7). Recompare at (32, 8). 10. **`cd DIR && (A) & B` puts the `cd` in the background group**: B then runs from the old directory (another project's venv, here). Use absolute paths in parallel shell lines. ## The bounded rerun owed at the end of session 4: done (session 5) Redone from the start (the 11 partial rows of `sweep900b/` were not reused) into `tests/detector_runs/sweep900c/` (ignored, raw frames kept): 156 images, 4 shards, PyPy, niced. `scripts/sweep_atari800.py` now writes fixed-offset (32, 8) `interior` and `edge` columns and, with `--raw`, both frames. Result (`tests/detectors/sweep900-atari800-2026-11-12b.tsv`, validation.md milestone 7): 78 identical (all 77 stay identical, plus Spitfire), 35 interior-identical with edge differences, 31 seed-class, 12 other, each in its session-4 class. One row looked out of class, Pole Position (Beta) (336 interior pixels); six fresh Atari800 runs all match the board's interior, so it is seed-dependent in Atari800. No regression from the GTIA fix or the POKEY repin. `tests/smoke_next.txt` holds the four undecidable or uncompared images. Gates: Acid5200 46/48, pytest 33 on both interpreters.