# MAME as a detector (run 2026-11-26) MAME 0.285 (the installed binary) is a **tier-5 detector**: it finds differences, it never decides them. Its source is not read for this board. One process at a time, short runs only. ## Recipe (`scripts/mame_trace.py`) ```sh MAME_ROMPATH=... python -I scripts/mame_trace.py --snap 12 # PNG after 12 s MAME_ROMPATH=... python -I scripts/mame_trace.py --frames 40 --cia # 68000 trace + register writes MAME_ROMPATH=... python -I scripts/mame_trace.py --driver a500n --bios kick31 --snap 12 ``` The script writes a Lua autoboot script and runs MAME with `-video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log` (and `-debug -debugger none` when tracing); `error.log` becomes `reference/mame/--/run.log`. Tracing uses the debugger command `trace T.trace,:maincpu,noloop,{logerror "T %X %X %X %d\n",pc,sr,sp,totalcycles}` and two watchpoints that log every write to the custom registers (`wpset dff000,200,w`) and to both CIAs (`wpset bfd000,2000,w`) with `beamy`, `beamx`, `frame` and `totalcycles`. Device facts read from `mame -listxml a500` (not from source): `maincpu` MC68000 at 7,093,790 Hz; `cia_0`, `cia_1` MOS 8520 at 709,379 Hz; the keyboard `kbd:a500_us:mcu` MOS 6500/1 at 3,000,000 Hz; the screen 908 x 625 total at a pixel clock of 28,375,160 Hz, 50.000282 Hz refresh. So MAME's `beamx` counts 1/4 of a colour clock (908 = 227 x 4) and its `beamy` counts **half-lines of an interlaced frame** (vtotal 625), not Agnus's line counter: map both before comparing with VHPOSR. Traps met: the 68000's stack pointer symbol is `sp` (`a7` is not a symbol and printed garbage); the snapshot lands in `snap//0000.png`; the run's speed with no throttle was about 5.5 times real time untraced. ## What ran | Run | Result | | --- | --- | | `--snap 12` (a500, Kickstart 1.3, no disk) | the Kickstart 1.3 "insert Workbench" hand-and-disk screen with "V1.3" by 12 emulated seconds (`reference/mame/a500-kick13-snap/snap/a500/0000.png`, git-ignored); 2.7 s wall | | `--frames 5` | 709,366 68000 clocks in 5 frames: 141,873 a frame, which is 7,093,790 / 50 within one instruction. The first instruction at FC00D4 (SSP read as `11114EF9`, the ROM's first long word, then 00040000); the first 5 frames are a delay loop at FC00E0 | | `--frames 40 --cia` | 563,805 instructions traced (`noloop` collapses repeated loop bodies, so this is not an instruction count) over 5,674,998 clocks; only **8 register writes in 40 frames**: CIA-A at BFE201 (DDRA) = 03 and BFE001 (PRA) = 02 in frame 16 (bit 0, OVL, cleared: the ROM overlay at address 0 goes away; bit 1, /LED, high: HRM3 pdf172, pdf238), then INTENA = 7FFF, INTREQ = 7FFF, DMACON = 7FFF, BPLCON0 = 0200, BPL1DAT = 0000, COLOR00 = 0444 | So a cycle-exact board must spend about 16 PAL frames (the ROM's delay and its RAM sizing) before the first custom-chip write; the board's first lockstep case (M1) is this stream: the 68000's program counter sequence and the register-write sequence with the CPU clock of each write, against MAME, every difference triaged. ## What MAME cannot decide Everything about timing that MAME's authors fitted rather than measured: the DMA slot contention seen by the CPU, the Copper's wake-up, the blitter's per-channel cycle sequences, the CIA E-clock alignment, disk DMA timing. Those go to vAmigaTS's real-Amiga screenshots (tier 3) and the HRM (tier 2) first (validation.md).