# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: run, never read (its System 1 files' licences were 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 | Devices and clocks MAME declares | | --- | --- | | `wboy` | `maincpu` Sega 315-5177 @ 4.00 MHz; `soundcpu` Z80 @ 4.00 MHz; `pio` Z80 PIO @ 20.00 MHz; `sn1` SN76489A @ 2.00 MHz; `sn2` SN76489A @ 4.00 MHz; `sn_ready` "Input Merger (any low)"; `soundlatch` 8-bit latch; `soundirq` timer; `screen` @ 10.00 MHz | | `wbml` | `maincpu` MC-8123 @ 4.00 MHz; `ppi8255` Intel 8255 PPI; otherwise as `wboy` | | `choplift` | as `wbml` with a plain Z80 and `mcu` Intel 8751 @ 8.00 MHz | The `sn_ready` merger joins the two PSGs' READY outputs (an SN76489A holds READY low for about 32 input clocks after a write, sn76489-python `docs/spec.md` ยง3.8): in MAME's model the sound Z80 waits on PSG writes (OBSERVED in the device list; where READY goes on the board is U4). ## The commands ```sh python -I scripts/mame_trace.py wboyu --snap 20 # untraced, PNG at frame 1200 python -I scripts/mame_trace.py wboyu --frames 60 --ports # main Z80, ports and writes python -I scripts/mame_trace.py wboyu --frames 60 --cpu sound --ports python -I scripts/mame_trace.py choplift --frames 3 --cpu mcu # the 8751 python -I scripts/mame_trace.py flicky --views 0,8000 # opcode view vs data view ``` 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 for traces and views `-debug -debugger none`. The Lua script sets `manager.machine.debugger.visible_cpu`, issues `trace S.trace,,noloop,{logerror "S %X %X %X %d\n",pc,af,sp,totalcycles}` (the 8751: `pc,acc,sp`), and with `--ports` `wpiset 0,100,r|w,1,{logerror ...; g}` for I/O and `wpset 0,10000,w,1,{...}` for memory writes; a frame notifier saves a snapshot and exits. `--views` reads MAME's `program` and `opcodes` address spaces of `:maincpu` byte by byte at frame 2 and writes only counts and CRC-32s, never bytes. ## What came out (OBSERVED in MAME; a detector's numbers, not hardware's) | Run | Wall | Result | | --- | ---: | --- | | `wboyu --snap 20` | 1.5 s | 1200 frames at 1652% speed; the "THE BEST PLAYERS" attract screen, 512 x 224 | | `wboyu --frames 3` (main) | | 16,600 instructions in 199,669 cycles (12.0 a instruction); execution starts at 0x0000 | | `wboyu --frames 60 --ports` (main) | 6.5 s | 390,796 instructions in 3,993,587 cycles (10.2); **59 entries at 0x0038, none at 0x0066**: one maskable interrupt a frame, 66,552-66,570 cycles apart (4 MHz / 66,560 = 60.096 Hz, MAME's refresh) | | ports, same run | | reads of ports 0x00, 0x04, 0x08 once a frame, 0x0C and 0x10 once; writes to 0x19 once a frame, 0x18 once, 0x1A twice, 0x1B three times (a Z80 PIO's four registers at 0x18-0x1B in this PIO set: HYPOTHESIS, the PIO's register order by address is U2) | | memory writes, same run | | C000-CFFF (12,823 writes), D000-D3FF (272), D800-DFFF (1,885), E000-EFFF (8,415); none elsewhere | | `wboyu --frames 60 --cpu sound --ports` | | 376,097 instructions in 3,993,595 cycles (10.6); **237 entries at 0x0038** (about four a frame, 16,382-17,409 cycles apart) and **one at 0x0066**; writes to 8000-87FF (11,479), A000-A3FF (1,302), C000-C3FF (1,302); no I/O port access | | `choplift --frames 3 --cpu mcu` | 1.8 s | 19,503 8751 instructions in 33,278 machine cycles (8 MHz / 12 = 666,667 a second); MAME logs writes to the 8751's unhooked ports 0, 2, 3 | | `choplift --frames 3` and `--frames 30` (main) | | **no main-CPU instruction**: the Z80 is held; MAME's log shows the 8751 reading 49,152 bytes ("MCU movx read mode 5F", the size of the 48 KB main program ROM) and then polling ("mode 19 offset 0016") | | `choplift --snap 20` and `--snap 60` | | the screen says "IC CHECK" at both times; 1,069,885 polls by 60 s | | `chopliftu --snap 20`; `--frames 5` | | also "IC CHECK" at 20 s; its Z80 runs (27,794 instructions in 5 frames, 8,191 of them at 0x9417). Why both stay there under this recipe is not investigated (U9) | | `shtngmst --snap 20` | | "RAM CHECK" over a cyan pattern; 567% speed | | `wbmld --snap 20` | | Monster Land's attract play | | `--views 0,8000` on one set per encryption part (25 runs) | ~1.5 s each | see [protection.md](protection.md): 17 parts differ only in bits 7, 5, 3; 7 parts and the MC-8123 differ everywhere; both views differ from the raw ROM (CRC-32) on `flicky`, `wboy`, `wbml`; a plain set's view equals its ROM (`wboyu`, CRC-32 match, which checks the method) | ## Traps met - Non-merged sets: the zip name is the machine name; no parent zip is needed. - `wpset` on the I/O space did not log with the `0:maincpu.i` address form; `wpiset` (the debugger's I/O-space watchpoint command) works. `wptype` is not a debugger symbol here. - A plain Z80 has no `opcodes` space; `--views` falls back to `program` (the check above). - The 8751's log lines (`MCU movx read mode ...`) are MAME's own words for its model; the "mode" values are MAME's, not a hardware fact. ## Output `reference/mame/-/` (git-ignored): `run.log`, `stdout.txt`, `run.lua`, `views.txt`, `snap//*.png`.