# Status Where a5200-python stands as a specification (charter tier `x-python`), measured. Detail: [validation.md](validation.md) (records per milestone), [build-progress.md](build-progress.md) (what was done and what is left), [claims.md](claims.md) (each claim and its strength), [architecture.md](architecture.md) (modelling level per component, domains and channels), [provenance.md](provenance.md). ## Save states anywhere: save-state version 4 (2026-11-14) a5200-rust found it (its docs/status.md, "Findings about the reference"): a save taken while a CX53 trak-ball rolls did not continue identically. `state.snapshot` did not hold the trak-ball lag (`Controllers._balls[n].out`), and `state.restore` called `Controllers.apply()`, which stepped the lag once more (Missile Command: lag 164.0 at the save, 139.0 after the restore; POT0's target ten frames on 18696 against 18693). Fixed: a restore no longer calls `apply()` at all; what `apply()` derived at the last frame start (the lag outputs, the trak-ball pins, the eight pot targets) is saved and restored as it stood. Three more of the same class, found by the new tests and fixed in the same change: - **the pads' key sets were shared** between the live pads and the snapshot (`vars(pad).copy()` is shallow): a frontend that mutates `pad.keys` in place changed the saved state after the save. Star Raiders saved mid-frame diverged (RAM). - **targets re-derived from the pads**: a frontend that changed a pad after the frame's `apply()` (a stick moved mid-frame) made the restore re-derive targets the machine had not yet applied. - **GTIA's trigger latches re-set**: the old restore's `apply()` called `set_trigger`, which latches a pressed trigger again even if the program had cleared the latch since the frame start (fixed by construction; no title here shows it). Also: `restore` now refuses a state from another machine row (the machine name was saved but never checked), and the pot-target cache `Controllers._counts` is gone (targets are written every frame; identical behaviour). Save-state version 4: version-3 states do not load. New tests (`tests/test_state.py`): a synthetic BIOS busy in every chip (DMA, VBI NMI, POKEY timer and keyboard IRQs, two tones, pot power toggled every other frame, keypad, trigger, WSYNC), saved at nine points (frame boundary; cycles 1, 7001, 15013, 29801 into a frame; a WSYNC pending; POKEY's /IRQ risen but not yet handed to the CPU; /IRQ held with I set; an NMI pending), the pads changed after the save, restored into fresh consoles from a pickled copy made after the original played on and from the very dict (as rewind does), compared per frame (frame CRC, RAM, cycles, CPU, POKEY, GTIA, pot targets and charge, pad positions) and over the audio from the save on. On 844355d: 10 of 11 fail. Slow (`-m slow`, need `$NO_INTRO_DIR`): the Missile Command repro, and a mid-frame save (frame 600 plus 12,345 cycles, 6 frames on with sound and inputs) on Missile Command and Centipede (trak-ball), Star Raiders (keypad), Pac-Man (stick): 4 of 5 fail on 844355d, 5 of 5 pass now. Seeded faults in the save, each run through the synthetic tests: not saving `_irq_line` (a5200-rust's /IRQ blind spot), not saving the lag, not saving the trak-ball pins, re-deriving the targets, restoring by `apply()`, sharing the key set: **all caught**. Equivalent at an instruction boundary (saved anyway, not counted): `_irq_next` (equals POKEY's /IRQ after every cycle), `data_bus` (the next cycle drives it before anything reads it), `_stack_writes` (an interrupt sequence's dummy reads clear it first). Saves are taken between CPU steps (instruction boundaries), as anywhere a host can call in. `media.AudioTap`'s sample phase is the host's and is not saved. | Gate | Before (844355d) | After | | --- | --- | --- | | pytest PyPy 3.11.15 / CPython 3.14.4 | 33 / 33 | **43 / 43** (10 new in `test_state.py`) | | `pytest -m slow tests/test_state.py` | (did not exist) | 5 passed | | Acid5200 standalone | 46 of 48 | **46 of 48**, the same two misses (`gtia_vdelay`, `pokey_twotone`) | | the 78 images identical to Atari800 at frame 900 (fixed offset) | 78 of 78 | **78 of 78** identical (interior 0, edge 0), 3 shards, PyPy | **a5200-rust should repin to the commit that adds this section** (fix, tests and docs in one commit: `git log -1 --format=%h -S"Save states anywhere" -- docs/status.md`), then move its `cases-upstream.tsv` into the main table and extend its round trip to mid-frame saves. ## The restarted pokey-python adopted (2026-11-14, pin 6ed1ffa) The POKEY core was archived for provenance and rebuilt (provenance.md); the board now pins the restarted core at `6ed1ffa` and is wired as its `docs/adoption.md` says: `POKEY(C012294)`; one `tick()` per machine cycle, halted and stalled cycles included, after the cycle's bus access (unchanged order); pots through the core's `rc.PotRC` on `pot_level` and `on_dump`, a stick at count p a target of p x 114 cycles of charging; the keypad function unchanged (bit 0 for the four aliased codes, bit 1 the upper button); /IRQ handed to the CPU at the next cycle (unchanged); audio from `mix()` (unchanged). Save-state version 3 (new POKEY snapshot shape; the capacitors' charge is saved). Before = the last commit on the old core (baaf212, numbers from this file and validation.md); after = fresh runs on this tree, PyPy 3.11.15 / CPython 3.14.4, niced. | Gate | Before (old core, e276d27) | After (6ed1ffa) | Why it moved | | --- | --- | --- | --- | | pytest PyPy / CPython | 33 / 33 | 33 / 33 | | | Acid5200 standalone | 46 of 48 | 46 of 48: ANTIC 20/20, CPU 7/7, GTIA 10/11 (`gtia_vdelay`), POKEY 9/10 | | | the 10 `pokey_*` | addrmirror, asyncrecv, default, inittiming, irqtiming, noise, seroc, timergranularity, timerirq pass; twotone fails "Too few timer 2 interrupts on space: 0 (should be 32)" | the same nine pass; twotone fails with the same message | the restarted core also leaves the serial output shifter unbuilt (its decision 2): issue-pokey-0001 updated, not a new corner | | Acid5200 full ROM | 45 passed, 2 failed (session 3, before the `antic_hscrolbug` fix; not rerun at 45fc4dd) | 46 passed, 1 failed (`pokey_twotone`), 1,260 frames | the second old failure was ANTIC's, fixed in session 3; nothing POKEY | | the 78 images identical to Atari800 at frame 900 (fixed offset) | 78 of 78 | **78 of 78** identical (interior 0, edge 0), none jammed; 3 shards, PyPy | | | save state into a fresh console (Pac-Man, saved at frame 800 mid-game, 150 frames on, stick moved after) | (not run) | frame, RAM, cycles and POKEY state identical | | | BIOS POT shadows, sticks set to 20/200 and 1/228, ports 3-4 empty (Pac-Man, frame 300) | (not run) | 20 200 1 228 228 228 228 228: exactly as set | | | gameplay audio, Pac-Man (same script, START at 700; Atari800 run of 2026-11-12) | lag +1, r = 0.939, together 708/758, pitch 469/705 | lag +1, **r = 0.918**, together 708/758, pitch 467/705 | the board's POKEY writes are identical in value and frame (1,578; frames 900 and 1,500 identical pictures); only their cycles moved around the START press (the new core's keyboard scan registers the key about 1,735 cycles earlier, so the BIOS's handler lands elsewhere). The level the core gives for the same writes changed (RMS over 10-25 s 0.098 to 0.084; new board against old board r = 0.992). With the core's `LINEAR` mix instead of the fitted curve r = 0.922, so the curve accounts for little of it; the rest is the restarted output stage. A change in the chip, recorded, not tuned | | gameplay audio, Missile Command | lag +4, r = 0.903, together 651/663 | lag +2, **r = 0.874**, together 765/780, pitch 260/565 | not like for like: the old trigger script was not recorded (validation.md says "triggers from 900"); the after run uses START at 700 and a 5-frame trigger every 30 frames from 900, on the board and a fresh Atari800 run alike. The board's writes equal the old run's to frame 824, then the play diverges (RANDOM, and Atari800 seeds from the clock) | | gameplay audio, Centipede | lag +1, r = 0.796, together 522/629 | lag +1, **r = 0.727**, together 526/645, pitch 212/334 | as Missile Command: reconstructed trigger script, fresh Atari800 run, RANDOM-seeded play (U8) | Not rerun: the seeded faults (no board code they touch changed), MAME lockstep. ## Measured at 45fc4dd (2026-11-13, end of the specification close-out) The same gates rerun after every close-out commit (provenance wave 2, romsets by environment variable, SPDX headers, evidence tags, architecture): nothing moved. | Gate | Result at 45fc4dd | | --- | --- | | pytest, PyPy 3.11.15 / CPython 3.14.4 | 33 passed / 33 passed | | Acid5200 standalone | 46 of 48, the same two misses (`gtia_vdelay`, `pokey_twotone`) | | fixed-offset frames against Atari800 at frame 900, the 78 identical images | 78 of 78 identical (interior 0, edge 0), 3 shards, PyPy, niced; run with `MAME_ROMPATH` on the non-merged set (BIOS found by SHA-1) | | seeded faults | `drop_dummy_read`: `cpu_bugs` fails ("BRK handler should not have executed"), `cpu_timing` fails ("Incorrect DEX/BNE cycle count: 4"); `steal_one_short`: `antic_dmapattern` fails ("Incorrect timing for mode 02-a"). All caught | `cpu_bugs`'s message under `drop_dummy_read` differs from the one recorded in validation.md milestone 1 ("NMI handler executed too early or late: 22"); the fault is still caught. Spitfire's search-offset count (2,254) is the known alignment trap (build-progress trap 9); at the fixed offset it is identical, as on 2026-11-12. pygame-ce 2.5.8 is now installed in `.venv-pypy` (2026-11-13, `--no-deps`; the permission system allowed it this time). The window is still to be built. ## Measured at 95b3ec2 (2026-11-13, start of the specification close-out) | Gate | Command | Result | | --- | --- | --- | | unit tests, PyPy 3.11.15 | `.venv-pypy/bin/python -m pytest -q` | 33 passed | | unit tests, CPython 3.14.4 | `.venv/bin/python -m pytest -q` | 33 passed | | Acid5200 standalone | `.venv-pypy/bin/python -m a5200_python.acid` | 46 of 48: ANTIC 20/20, CPU 7/7, GTIA 10/11, POKEY 9/10 | | Acid5200 full ROM | `... -m a5200_python.acid --full` | 45 passed, 2 failed (session 3 figure; not rerun here) | | fixed-offset frames against Atari800 98cc2dc at frame 900 | `scripts/sweep_atari800.py --list` (the 78 rows identical in `tests/detectors/sweep900-atari800-2026-11-12b.tsv`) | 78 of 78 identical (2026-11-12, session 5) | | seeded faults | `acid --fault drop_dummy_read cpu_bugs cpu_timing`; `--fault steal_one_short antic_dmapattern` | each caught | The two Acid5200 misses are recorded and expected: `gtia_vdelay` writes $D000, which selects no chip on a 5200 (C12, [FSM] decoder; passes with `--switch gtia_at_d000=1`); `pokey_twotone` is a pokey-python matter (docs/issue-pokey-0001-twotone-space.md). The Atari800 comparison is a detector (an emulator agreeing), not hardware evidence. The romsets come from `NO_INTRO_DIR` and `MAME_ROMPATH` (`scripts/romsets.py`); the Acid5200 runs need the BIOS through one of them, `$A5200_BIOS` or `~/.local/share/a5200-python/bios/`. ## What passes, what does not, what is unverified - Passes: milestones 1, 2 and 6 as written; every DMA chart of [AHRM] 4.14 machine-compared (36 of 38,760 cells differ, all C16); PAM RAM pages catch a seeded RAM fault; all 286 local images load; the sweep's 79 large divergences each classed and the class proven. - Not met as written: milestones 3 and 4 (the two Acid5200 misses above; the PAM Port Test needs loopback hardware), 5 ((b) "leaves the BIOS" per image and (d) controller use in the table) and 7 (no window: pygame-ce not installed; 2 of 12 trak-ball titles not shown, U21). - Unverified (no hardware judge exists here: no 5200 console): power-on state (U8), the floating bus (U5), $F000-$F7FF (C8), the one-chip $4000 mirror (C4), trak-ball constants (U11), line-buffer unselected reads (U17), audio levels. Every Acid5200 verdict is tier 3 (author-stated hardware passes, no recorded 5200 run, U7). ## What is left, in order 1. The pygame-ce window (milestone 7): pygame-ce is installed in `.venv-pypy` now; there is no display on this machine to try it on. 2. Scripts reaching RealSports Football's running play and Baseball's fielding (U21). 3. Milestone 5 (b) and (d): "leaves the BIOS" for every image, controller use into the table. 4. Several Atari800 runs per title inside `scripts/sweep_atari800.py` (its RANDOM is clock-seeded; done by hand so far). 5. (Done 2026-11-14: the restarted pokey-python pinned at 6ed1ffa, gates above.) pokey-python's rung 8 waits for register logs from boards: `scripts/scripted_run.py --pokey-log` writes them (Pac-Man's is in `tests/detector_runs/repin6ed1/audio/`). 6. The x-rust transcription (a5200-rust) can start from this tree: the modelling levels and the serial order of record are in architecture.md. ## Open decisions for Aubrey 1. Where the pygame-ce window gets tried (no display here). 2. Whether to add a closed-box Altirra run (Wine) as a detector: today it cannot run (U12), so the Altirra fact about 16K detection stays withdrawn. 3. Repinned 2026-11-14 to the restarted pokey-python; `pokey_twotone` still fails there (its decision 2 leaves the serial output shifter unbuilt). Whether the core builds it is pokey-python's decision.