# Worklog Newest last. What was done, what was found, what is owed. ## 2026-11-12: build begins (Phase 1) - Pinned the cores by commit from their local clones (`git+file`, as the sibling boards are while local): z80-python `f97c0f5` (branch `m1-fetch-hook-rebased`, the `read_m1` hook), tms9918-python `df9d8ae`. **sn76489-python with the `SN76489A` row (`1eeb583`, branch `sn76489a-variant`, in `/data/emu/sn76489-python-sn76489a`) does not exist on this machine**: the directory is absent and no repository under `/data/emu` holds that commit; `/data/emu/sn76489-python` is at `c0d88a6` on `main` with only the `SN76489AN` row. M4's sound wiring waits on it. (Superseded the same day: that pin was withdrawn with the old core; the board now pins the restarted core's `c0d88a6`, below.) - The PyPy venv's pip 24.0 rejects `git+file` URLs with a commit (`Invalid URL`); `pip install -U pip` in the venv (26.x) fixes it. - M1: board, decode, M1 and READY waits, sockets, MAME log reader and lockstep. The 2-second BIOS trace matched on the first full run (945,993 instructions, 0 differences). The M1 wait came straight from `read_m1`; I/O placement inside an instruction from z80-python's `timing.instruction_timing`. - Found: tms9918-python cannot start its counters at a chosen phase; running it to MAME's phase sets F on the way. Stopgap and issue: `docs/core-issues/0001`. - M2: picture comparison by colour index against MAME snapshots and Gearcoleco frames: 0 differing pixels on the three screens, both option sets. Mode tests through the board's ports. The 4K watch-point turns out to matter only with non-zero power-on VRAM: `docs/core-issues/0002`. Gearcoleco will not load a headerless image, so the no-cartridge screen has one detector. - M3: built the detector harness. First picture runs disagreed with MAME by a frame after inputs; measured instead of assumed: MAME's frame notifier fires every 59,736.0056 CPU clocks (its pixel clock is 5,369,317 Hz, not 5,369,317.5), MAME frame k is the board's frame k + 1, and a field set in a notifier reaches the game one notifier later. Then an I/O-only MAME log (`scripts/mame_io.py`, about 1 s per 1,000 frames) replayed against the board found the NMI arriving one instruction off: MAME's video drifts against its CPU (the rounding above) and its interrupt lands about one CPU clock early; both reproduced under `mame_options()` only (`mame_video_rounding`, fitted bias of 3 master clocks). Controller reads now pull scripted inputs at their own clock (`Board.input_hook`). After that every smoke title runs until a status read whose sprite bits differ (core issue 0003); Mr. Do! runs its whole 1,701 frames identical. - M4: the PSG pin is absent; sound streams compared without the chip; a MAME sweep of writes to `$E0-$FF` over the library answers where periods 0 and 1 are audible. - M5, M6: spinner devices, Super Action, Roller, driving module; MegaCart, X-in-1, Activision with a 24Cxx two-wire EEPROM; the Final Test controller screen blanks. - M7: full sweep at the commit point (200 cartridges, 600 pictures); the 8 failing titles all triaged by port replay, 7 to core issue 0003 and one (Squish'em) to the core's slot-fetch rendering; MAME's PAL machine resets at its own vertical-blank start, so the NTSC phase constant serves PAL unchanged; PAL BIOS lockstep exact on the first run. - M4 finished: the coordinator gave the restarted sn76489-python, `main` `c0d88a6`, in place of the withdrawn `1eeb583`. Read its README, api, claims and restart documents; no GPL or LGPL sound-chip source was opened for this work (the restart's rule). The `SN76489AN` row is wired at `$FF` (run to each write's clock, READY kept as the board's 28-clock wait), a mixer (box filter to 44,100 Hz, DC blocker) and WAV output. Sound compared only as outputs: MAME's `-wavwrite` recording of the Final Test Cartridge against the board's rendering. - Rerunning the smoke list after the wiring first showed frame 900 differing by about 49,000 pixels in 10 titles: the M7 sweep (no inputs) had rewritten the detectors' cached frame-900 pictures of the M3 list (with inputs) in the same directory. A harness bug, not a board change: caches are now per title and input script. With fresh pictures every count is as before. The M7 failure list had also been written with titles cut at 40 characters; fixed by hand and in the summary script. - Open for the next session: the Super Controller Tester's procedure; instruction-level traces longer than 2 s were not made (27 MB per emulated second); the full sweep on CPython. - Rule slip: three scratch scripts were written into the scratchpad with shell heredocs (`cat > file <