# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: run, never read (its Data East files' licences are checked by their `license:` lines only, [sources.md](sources.md)). It is a tier-5 detector. One MAME process at a time, a few emulated seconds per run, `nice` and `taskset -c 24-31`. ## Devices (`mame -listdevices`) | Machine | Family | Devices and clocks MAME declares | | --- | --- | --- | | `robocop` | dec0 (HuC6280 sub) | `maincpu` MC68000 @ 10.00 MHz; `audiocpu` Rockwell R65C02 @ 1.50 MHz; `sub` HuC6280 @ 1.34 MHz with its PSG @ 671 kHz; `dem01` "Fujitsu MB8421 8-bit Dual-Port SRAM with Interrupts"; `ym1` YM2203 @ 1.50 MHz; `ym2` YM3812 @ 3.00 MHz; `oki` MSM6295 @ 1.00 MHz; `tilegen1..3` "DECO BAC06 Tilemap"; `spritegen` "DECO MXC06 Sprite"; `spriteram` buffered 16-bit sprite RAM; `soundlatch`; `audio_irq` input merger; `screen` @ 6.00 MHz | | `baddudes` | dec0 (i8751) | as `robocop`, with `mcu` Intel 8751 @ 8.00 MHz in place of `sub` and `dem01` | | `midres` | dec0 (HuC6280 sound) | 68000 @ 10 MHz; `audiocpu` HuC6280 @ 2.00 MHz; BAC06 x3, MXC06 | | `cninja` | deco16 | 68000 @ 12.00 MHz; `audiocpu` HuC6280 @ 4.02 MHz with PSG @ 2.01 MHz; `ioprot` "DECO 104 Protection"; `irq` "Data East IRQ Controller"; `tilegen1`, `tilegen2` "DECO 55 / 56 / 74 / 141 Tilemap Generator"; `spritegen1` "DECO 52 Sprite"; `spriteram1`; `ym1` YM2203 @ 4.02 MHz; `ym2` YM2151 @ 3.58 MHz; `oki1` @ 1.00 MHz, `oki2` @ 2.01 MHz; `screen` @ 6.00 MHz | Screens from `-listxml`: dec0 machines 6.000 MHz pixel clock, 384 x 272 total, 256 x 240 visible (lines 8-247), 57.444853 Hz; `cninja` 6.000 MHz, 376 x 274, 58.238857 Hz; `darkseal`, `vaportra` a plain 58 Hz with no raw timing (MAME has none for them). ## The commands ```sh python -I scripts/mame_trace.py robocop --snap 20 # untraced, PNG at frame 1160 python -I scripts/mame_trace.py robocop --frames 3 # the 68000 python -I scripts/mame_trace.py robocop --frames 3 --cpu sub # the HuC6280 beside the MB8421 python -I scripts/mame_trace.py baddudes --frames 3 --cpu mcu # the i8751 python -I scripts/mame_trace.py midres --frames 3 --cpu sound # the sound HuC6280 python -I scripts/mame_trace.py cninja --frames 60 --watch 0,1000000 # every 68000 write ``` The script passes `-rompath $MAME_ROMPATH -homepath -cfg_directory /cfg -nvram_directory /nvram -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 script sets `manager.machine.debugger.visible_cpu`, issues `trace S.trace,,noloop,{logerror "S %X ... %d\n",,totalcycles}` and, with `--watch`, `wpset ,,w,1,{logerror "W %X %X %X %d\n",wpaddr,wpsize,wpdata,totalcycles; g}`; a frame notifier saves a snapshot and exits. **Register symbols that work on MAME 0.285**: 68000 `pc,sr,d0,sp`; R65C02, 6502 and HuC6280 `pc,a,x,p`; i8751 `pc,a,sp,psw`. **The trap**: a symbol the CPU does not define, but which spells a hex number, is accepted and logged as that constant. `a7` on the 68000 logs `A7` on every line, and `acc` on the i8751 logs `ACC`. Both were caught here only because the column never changed. system16-python's recipe uses `pc,sr,d0,a7` and `pc,acc,sp`, and its stored traces show the constants (`reference/mame/*/run.log` there): its "byte-identical" FD1094 comparison compared PC, SR, D0 and cycles, not A7. Reported, not touched. ## What came out (OBSERVED in MAME; a detector's numbers, not hardware's) | Run | Wall | Result | | --- | ---: | --- | | `robocop --snap 20` | 1.6 s | 1160 frames; the attract's Robocop figure partly drawn, 256 x 240 PNG | | `robocop --frames 3` (68000) | 0.9 s | 37,489 instructions in 522,231 cycles: **13.9 cycles an instruction**; first PCs 0x124, 0x128, 0x12E with SR 0x2700 and SP 0xFFC000 (the top of work RAM) | | `robocop --frames 3 --cpu sub` (HuC6280) | | 15,580 instructions in 70,098 cycles at 1.342 MHz (4.5 cycles an instruction); PC starts at 0xFE00 | | `baddudes --frames 3` (68000) | 1.0 s | 37,811 instructions in 522,238 cycles (13.8); the log shows the 68000 writing the i8751's ports (`dec0_mcu_port1_w: b3`, `port3_w: fe`, ...), MAME's own debug lines | | `baddudes --frames 3 --cpu mcu` (i8751) | 0.8 s | 17,495 instructions in 34,815 machine cycles (8 MHz / 12 = 666,667 a second: 11,600 a frame), 1.99 machine cycles an instruction; reset at 0, a jump to 0x900 | | `baddudes --frames 3 --cpu sound` (R65C02) | 0.8 s | 27,792 instructions in 78,334 cycles at 1.5 MHz (2.8 cycles an instruction: a polling loop); reset vector to 0x8000 | | `midres --frames 3 --cpu sound` (HuC6280) | 0.9 s | 15,362 instructions in 104,445 cycles at MAME's 2 MHz (6.8 cycles an instruction); PC starts at 0xE000 | | `cninja --frames 3` (68000) | 1.2 s | 52,743 instructions in 618,135 cycles: **11.7 cycles an instruction** at 12 MHz; SP 0x188000 | | `cninja --frames 3 --cpu sound` (HuC6280) | 1.0 s | 42,841 instructions in 207,463 cycles at 4.03 MHz (4.8) | | `actfancr --frames 3` (main HuC6280) | 1.3 s | 68,055 instructions in 357,952 cycles at 7.16 MHz (5.3) | | `robocop --frames 60 --watch 0,1000000` | | 643,115 instructions; 234,794 writes, by 2 KB block: 180000-180FFF (2,972), 240000-24DFFF (12,667), 30C000 (86), 310000 and 314000 (4,560 each), FF8000-FFC7FF (211,000; 196,723 of them in FF8000-FF87FF) ([memory-map.md](memory-map.md)) | | `cninja --frames 60 --watch 0,1000000` | | 661,566 instructions; 456,321 writes: 140000-14FFFF and 150000-15FFFF (the two DECO 55s, 18,700 each), 184000-187FFF (RAM; 400,151 in 184800-184FFF), 190000 (308), 19C000-19DFFF (2,048), 1A4000 (1,536), 1B0000 and 1B4000 (6 each), 1BC000 (167) | | `baddudes --frames 3 --cpu mcu --fields pc,a,sp,psw` | | the accumulator column varies (0x80 on 12,700 lines, 0x0B on 4,479): the corrected symbols | ## MAME's log lines worth a unit test later - `robocop`, `baddudes`: "warning - write 00 to unmapped memory address 30c01a" and "write 303 to ... 30c01e" at reset: the game writes there; MAME maps nothing (U8). - `cninja`: six "unmapped program memory write to 1B0002 ... 1B000C" at reset, then "[:ioprot] LOAD XOR REGISTER 0000 ffff" and "LOAD SOUND LATCH: 779d" from MAME's DECO 104 model (its own debug text; meanings unread). ## Traps met - Non-merged sets: the zip name is the machine name; no parent zip is needed. - `-cfg_directory`/`-nvram_directory` inside the run directory keep MAME from writing NVRAM into a shared place between runs. - The dec0 frame is 57.44 Hz: `--snap N` uses 58 frames a second. - `S.trace` (the debugger's disassembly) is deleted after a run; `run.log` has the state. ## Output `reference/mame/-/` and `reference/mame/-snap/` (git-ignored): `run.log`, `stdout.txt`, `run.lua`, `snap//*.png`.