# Build status: where the restarted build stands For the next agent. The restart (2026-11-19) is in [restart.md](restart.md); the plan is [handoff-brief.md](handoff-brief.md) "Milestones"; the numbers are in [status.md](status.md). Read restart.md's rules before touching anything: bsnes, Mesen2, snes9x, snes_spc and MAME's GPL files are run, never read; the archive is never read. ## How the board is being built The S-CPU side follows **ares 9408cb4 (ISC)** as its worked model, which the owner's brief permits ("code OK with notice"), with anomie's timing document and fullsnes as the documents and the console's probe-suite saves as the judge. Every rule names its source: `DOC` (anomie, fullsnes, wiki), `OBSERVED (ares ...)` (taken from ares's source, ISC), `MEASURED` (this project's console), `HYPOTHESIS` (power-on values nobody states), `DESIGN` (the header score, the port stub). The ISC notice is in NOTICE and in each file's header (`SPDX-License-Identifier: MIT AND ISC`). ares's `sfc/dsp` is excluded except for separate formulas (its DSP is "a rewrite of blargg's SPC_DSP"). ## Milestones | # | What | State | | --- | --- | --- | | 1 | S-CPU bus, cycle lengths, CPU I/O, DMA/HDMA, timing skeleton, LoROM/HiROM | **done**, MAME lockstep included (`scripts/mame_lockstep.py`, 2026-11-23: SMW, Chrono Trigger, DKC; every difference named; mame-oracle.md "The lockstep") | | 2 | PPU dot by dot (`ppu.py`, `ppu_render.py`, ported from ares `sfc/ppu`, ISC) | **built**; open: U9, U10, Q10, the OAM address during rendering, MIDF CG-active (docs/ppu-status.md) | | 3 | S-SMP + S-DSP (`smp.py`, `dsp/`, `apu.APU`) | **done through the board** (spctest, krom SPC700, blargg spc_timer/spc_smp/spc_mem_access_times); spc_dsp6 **111 of 111** (2026-11-23); the conformance kit (docs/dsp/status.md rung 4) | | 4 | Cartridges: maps, SRAM, header census, saves | header census **2,852/2,854** against MAME's CC0 software list (`scripts/header_census.py`); `.srm` saves (`Cartridge.battery()`/`load_battery()`); smoke list (`tests/smoke.txt`, `scripts/smoke.py`) against Mesen2, triaged; **full sweep** (`scripts/sweep.py`, 2026-11-24): 4,089 images at frame 300, 3,514 exact, 339 one step off (U10), 105 picture, 8 hang, 0 crash, 123 unsupported (status.md "The full sweep"); frame 900 owed | | 5-8 | coprocessors, probe sweep, Super FX/Cx4/SGB/MSU-1, frontend and PAL | not started; every one was marked rewrite/unclear in the first build's audit, so start from fullsnes and ares (`sfc/coprocessor`, ISC; MAME's BSD-3 `sa1.cpp`, `sdd1.cpp`, `upd7725` after a header check) | **2026-11-25, the S-SMP overshoot (board change).** `APU.catch_up` runs whole SPC700 instructions, so the S-SMP can stand up to an instruction past the S-CPU; S-CPU port writes were applied after the catch-up, so S-SMP reads and CONTROL clears in that last instruction saw them 0-3 S-SMP cycles late (measured, port-race.md "The overshoot, measured"). Now a write is posted at its own S-SMP cycle before the catch-up (`smp.CPUPorts.cpu_post`, `settle`; clears ordered by `cleared`), mirroring the store log. Both Kawasaki images boot (exact at 300 and 900 against Mesen2); Zenki does not: the port-race window is now exactly D S-SMP cycles (+21 clocks before), 1.8 clocks too long for Zenki's refresh gap. Gates in status.md (all hold; 13 smoke pictures moved phase, each looked at). Open: an S-SMP read in an *earlier* catch-up's overshoot still returns the old value (Kawasaki 16 in 400 frames, Zenki 0); a scratch experiment with port reads sampled at mid-cycle (FITTED to Mesen2) matches Mesen2's probe grid in all 286 cells and boots Zenki: not kept, it waits for the console's port-race save (PROBE-QUEUE.md #5). The full sweep was not rerun: its other blank or picture results may move too. **2026-11-24, tool move (no board change).** Every Mesen2 script runs mesen2-runner 0.2.0 through `EMU_TOOLS_GPL` (`scripts/emu_tools.py`; `SNES_GPL_TOOLS` and `gpl_tools.py` retired); Mesen2's frames now repeat run for run (zeros at power-on, no frame skipping); the smoke list stays 27/7/0 (status.md); the gate is in validation.md "Moved to mesen2-runner". No closed-box source is fetched or kept any more (provenance.md "Closed-box sources removed"). The smoke cache `tests/mame_traces/smoke/` holds the new frames (the old driver's are beside it, `smoke-old-driver-2026-11-23/`); the sweep cache still holds the old driver's frames, so a rerun of the full sweep should move `tests/mame_traces/sweep/` aside first. **Where I stopped (2026-11-24, third session: the full sweep).** 1. `scripts/sweep.py` runs the whole main No-Intro folder against Mesen2 (frame 300, +-30 frames, a PyPy worker pool under a CPU-time limit; resumable; `--rerun`, `--list`, `summary --failures`). The first sweep (0070aaf's board) and a full second one (f26826f) are in status.md, by category. The failures are `tests/sweep-failures.txt`, the next quick-sweep list; four of them joined `tests/smoke.txt`. 2. Header detection: three DESIGN rules (cartridge.md); 12 betas/protos change map; the census is unchanged. 3. Not fixed, the largest real class: **S-CPU/S-SMP port races** (Kishin Douji Zenki, Kawasaki Superbike Challenge x 2; status.md "The port races"). Experiments that did not fix them: exact port timing by a greenlet coroutine (16 % slower), start-of-cycle port sampling, the console's S-SMP clock. A console probe would settle it: an S-SMP loop that clears its input ports (CONTROL bits 4-5) and reads them N cycles later, against an S-CPU loop rewriting `$2141` every M master clocks, for a grid of N and M, saving whether the zero was seen; the board's 8-cycle window against a 126/166-clock write period says never, the game says sometimes. Built 2026-11-24 as `00-OURS/port-race.sfc` (branch port-race-probe; docs/port-race.md, PROBE-QUEUE.md #5), with the board's and Mesen2's predicted grids; waiting for the console. 4. The step (339) and most picture (105) failures are fades: U10's console photo (PROBE-QUEUE.md #4) now decides about 400 games' frame 300. The 448-pixel group is U9 (#3). 5. Sweep notes: the machine ran at load 70-130 (other sessions); one pass took 10.5 hours with 32 workers. The stdlib pool with `max_tasks_per_child` deadlocked after 1,280 games (fixed in 014cdb1: no recycling, a broken or silent pool is replaced). Mesen2 frames are cached per game under `tests/mame_traces/sweep/`, so a rerun costs the board side only. **Earlier (2026-11-23, second session):** items 1 and 2 of the brief are done; item 3 (milestone 2's open items) is queued on the console, not worked. 1. **spc_dsp6: 111 of 111** through the board (was 20). Six S-DSP fixes, each decoded from the board's own trace of the test's DSP writes and ARAM, a synthetic `.spc` case against the snes_spc referee, and, once, Mesen2's ARAM read by Lua (all closed boxes; the ROM's source is not published): docs/dsp/status.md has the table. The earlier note's "test 21" was test 22 (`KON/kon decoding when another kon`); 21 passed. U22 is settled as far as the counter pairing goes (the poll runs on even counter values); its phase against the timers stays open. D1 is settled (the referee's cast). All 16 synthetic cases value-exact. 2. **Smoke triage.** Rendering Ranger R2 was a board bug (S-SMP port stores visible up to an instruction early; 36bf2cf); it boots now. `smoke.py board --window 30` shows the rest is reset phase, U10, SRAM power-on contents or RNG (status.md "Triage"). 3. **Milestone 2's open items** (U9, U10, Q10, the OAM address during rendering, MIDF CG active): console runs queued in /data/emu/PROBE-QUEUE.md (#2 suite format 2 for OAWC/OAWD and MIDF, #3 photo-hires-edge for U9, #4 photo-brightness for U10). Q10 (INIDISP early read, brightness delay) has no console probe yet; undisbeliever's `inidisp_*` ROMs against Mesen2 are the lead (ppu-status.md). MIDF "CG active": the console's write lands at colour 1 (the BG1 pixel's index, the main-screen lookup) where the board's lands at 0 (the sub-screen lookup, chosen for CGWS's 63 rows); the half-dot that decides between them is the question, and the format-2 suite run will give both tests from one console session. Next, in order: the port races (above); frame 900 in the sweep when the machine is quiet; milestone 2's open items once the console saves arrive (`scripts/suite_results.py`); then milestones 5-8 (the sweep's unsupported list is their acceptance set: Super FX 55, SA-1 30 not exact plus 19 exact at frame 300, DSP 25, ...). Harness notes: `mame_lockstep.py` keeps both streams in memory (DKC at `--board-factor 4` took 4 GB); `smoke.py mesen` needs the system Python (Pillow) and `EMU_TOOLS_GPL` (since 2026-11-24 every Mesen2 script runs mesen2-runner 0.2.0, `$EMU_TOOLS_GPL/tools/mesen2/run.py`; its library is its own build of b9fa69d, or `MESEN_CORE`; validation.md "Mesen2"); `smoke.py board` runs under PyPy. spc_dsp6 is run by a scratch loop (board, IPL, text tapped from `$2118`); all 111 tests take under 9,000 frames (PASSED TESTS between frames 8,750 and 9,000), about 27 minutes on PyPy. Speed: SMW's first 2M instructions took 13 s on PyPy; the smoke games ran 900 frames in 19-57 s each, 6 in parallel. ## Console probes that would settle the biggest unknowns (for Aubrey's Super Famicom + X5) 1. **Power-on memory**: BUILT 2026-11-23 as `00-OURS/05-poweron.sfc` (probes/poweron), with the WAI-with-/IRQ-held question from the DKC lockstep. Detectors disagree (board zeros, MAME WRAM `$55`, Mesen2 random; WAI: MAME waits, board and Mesen2 resume). The X5's menu runs first, so only regions it leaves alone show true power-on contents. 2. **IRQ response**: a TIMEUP poll loop around HTIME 0-4, to split the FITTED extra poll between the timer and the CPU's response. 3. **WRMPYB rewritten while busy** at every gap 1-8 cycles with several operand pairs (MREP saw `$0000` at gap 7; nothing explains it). 4. **The S-DSP's power-on registers and ENDX after reset** (C11, C17), and the FIR saturation point (D1): a ROM that reads $F2/$F3 after reset and plays a saturating echo. 5. **Hi-res first dot (U9) and the brightness curve (U10)**: the photo probes in probe-pack/00-OURS (photos need a capture card or a careful camera). 6. **OAM address while drawing and after a mid-frame display toggle** (OAWA-OAWD, DISP E2): finer sweeps than the suite's. 7. **A CPU version 2 console** for Q9 (the S-CPU-A DMA failure) and the version-2 refresh and HDMA-init positions: the reference row is version 2, but the console is version 1. 8. **Reset to first instruction**: the board waits 132 clocks (ares); a reset-phase probe with a known reset point would pin it. ## Open items found while rebuilding - **Home Alone** trails Mesen2 by 8 frames at frame 900 since 36bf2cf (it matched at -6 before): reset phase, but the port fix changed it. - **WAI with /IRQ held** (DKC): the board resumes at once (WDC datasheet); MAME waits. Probe 05-poweron row A settles it. - **Power-on S**: the core leaves `$01FC` after reset from `$01FF` (HYPOTHESIS either way). - **MAME's instruction timing** differs from WDC's table in five places (mame-oracle.md); the board follows WDC, so nothing to do, but don't "fix" towards MAME. - **Header census**: *Battle Racers (Japan)* and *Undercover Cops (Retro-Bit)* are `lorom` in MAME's list but carry only a HiROM header and run only as HiROM (probable list errors). - **IRQ at H=0**: ares compares (H+1)*4 with the counter 10 clocks back (fires at clock 14 of the line); anomie says H=0 fires 1374 clocks after the previous line's dot 0 (clock 10). The board follows ares; a probe would settle it (status.md, probes). - **WRMPYB written while busy** (probe suite MREP): the console reads `$0000` at a gap of 7 cycles, where ares (and the board) give A x B2. Recorded, not fixed (no document explains it). - **STAT77 bits 4/5**: the board follows fullsnes (bit 5 open bus, bit 4 = 0); ares does the reverse. - **WRAM-to-WRAM DMA B to A**: the board writes the MDR (the console wrote `$AD` x 8, the opcode after `STA $420B`, so the console's DMA starts after the next opcode fetch); check that the board's MDR at that point is that opcode once the suite gate runs. - **Power-on contents** of WRAM, VRAM, OAM, CGRAM and the PPU latches: zeros (HYPOTHESIS). - **$4200 lock**: transitions raised by a `$4200` write reach the core one cycle late (`board._flush_deferred`); a transition already pending when a 16-bit `$4200` write is the second-to-last cycle is not delayed as ares delays it. Rare; noted in the code.