# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: its binary is run, its source is not read. Tier 5: a detector. One MAME process at a time, short runs. ## Devices (`mame -listdevices invaders`) `maincpu` Intel 8080 @ 1.99 MHz; `mb14241` MB14241 Data Shifter; `screen` @ 4.99 MHz; `soundboard` "Taito Space Invaders Audio" with `discrete`, `snsnd` (TI SN76477 CSG) and `mono`; `watchdog`. `-listxml invaders`: raster, `rotate="270"`, 260 x 224, refresh 59.541985 Hz, pixclock 4992000, htotal 320, hbstart 260, vtotal 262, vbstart 224; driver status good; no samples. `sitv` is the same. ## Commands ```sh python -I scripts/mame_trace.py --frames 30 # trace from reset (about 5 s wall) python -I scripts/mame_trace.py --skip 600 --frames 3 # trace 3 frames after 10 s python -I scripts/mame_trace.py --snap 4 # untraced; PNG at frame 240 python -I scripts/mame_trace.py --driver sitv --frames 30 ``` What the script passes: `-rompath $MAME_ROMPATH -homepath -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -seconds_to_run N -autoboot_script run.lua`, and when tracing `-debug -debugger none`. The Lua sets `debugger.visible_cpu`, issues `trace S.trace,:maincpu,noloop,{logerror "S %X ... %d %d\n",pc,a,b,c,d,e,h,l,sp,totalcycles,beamy}` and `wpiset 0,8,w,1,{logerror "OUT %X %X %d %d\n",wpaddr,wpdata,totalcycles,beamy; g}` (I/O-space write watchpoints), then a frame notifier saves a snapshot and exits. With `--skip N` the trace and watchpoints are issued from the frame notifier at frame N. ## Runs made tonight | Run | Result | | --- | --- | | `--frames 3` | 13,778 instruction lines; no port writes and no interrupts yet (the program is still in its start-up) | | `--frames 30` | 118,767 lines; port writes: 6 x49 (watchdog), 3 x1, 5 x1 (both 0, at line 62); entries at 0x0008: 21 on line 96 and one on line 63; at 0x0010: 20 on line 224 | | `--snap 4` | `reference/mame/invaders-snap/snap/invaders/0000.png` | The line-63 entry is the first interrupt after the program enables interrupts: the request raised at line 96 was still held (start-here.md). i8080-python's own recipe (its `docs/mame-oracle.md`) adds register fields and 60-frame runs; its lockstep matched 230,313 instructions. ## Traps - `error.log` lands in the working directory: the script runs MAME from the output directory and renames it `run.log`. Its first line starts with a byte-order mark. - There is no trace line for the injected `RST`: the next line is the handler entry with SP already lowered (i8080-python's notes). - `-seconds_to_run` takes whole seconds; the script stops by frame count from Lua.