# MAME 0.285 as a closed-box detector MAME is run as a binary only. Its source is never fetched or kept here (charter, licences point 3). What it gives: machine descriptions (`-listxml`), instruction traces through its debugger, and its address maps through Lua. One MAME process at a time, a few emulated seconds per run. ## The recipe (run 2026-11-26) ```sh MAME_ROMPATH=... python -I scripts/mame_trace.py pacmania --cpu main --seconds 2 MAME_ROMPATH=... python -I scripts/mame_trace.py pacmania --cpu mcu --seconds 2 ``` It writes `reference/mame/-/run.lua`, runs ``` mame -rompath $MAME_ROMPATH -homepath -sound none -nothrottle -noreadconfig \ -skip_gameinfo -seconds_to_run N -autoboot_script run.lua -video none \ -debug -debugger none -log ``` with the Lua setting `dbg.visible_cpu` and issuing `trace T.trace,,noloop,{logerror "T %X ... %d %d %d\n",,totalcycles,frame,beamy}` then `go`. `error.log` (in the work folder, MAME's cwd) gets one line per instruction; `T.trace` the disassembly. Tags and register symbols: `:maincpu`, `:subcpu`, `:audiocpu` (pc a b x y u s dp cc); `:mcu` (pc a b x s cc; MAME's HD63701 has no `D` state entry). `scripts/mame_maps.lua` prints every address map ([memory-map.md](memory-map.md)). ## What the runs showed (Pac-Mania, 2 emulated seconds = 121 frames each) | CPU | Instructions | Notes | | --- | --- | --- | | main 6809 | 645,933 | totalcycles 3,091,964 at frame 121: 1.536 MHz | | sub 6809 | 507,826 | restarts at frame 110 (PC $F150, cycles to 0) | | sound 6809 | 517,825 | restarts at frame 110 (PC $D000) | | MCU (HD63701) | 541,708 | restarts at frame 110 (PC $F1BB); 45 mnemonics used, `OIM` among them, no $12/$13 | The first trace line of the main CPU appears twice with the same cycle count (OBSERVED; the cause is not known, likely the debugger's first-instruction hook); the board's lockstep must allow for it. All three slave processors restarting together at frame 110 is the first fact for U1 (who resets whom). ## Pictures `python -I scripts/mame_trace.py splatter --snap 2 --seconds 4` saved three PNGs (288 x 224) to `reference/mame/splatter-snap/snap/splatter/`; the second shows Splatter House's title screen. Without tracing, MAME ran this at 1,070% of real time on this loaded machine (one data point for its own interpreters, not a family measurement). ## Traps - ALSA warns `open /dev/snd/seq failed`; harmless with `-sound none`. - `totalcycles` is per CPU and starts again when that CPU is reset. - Run time: about 16% of real time with tracing on for one CPU on this loaded machine.