# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is run as a closed box (tier 5, a detector). One process at a time, short runs. ## Devices (`mame -listdevices pacman`) `maincpu` Zilog Z80 @ 3.07 MHz; `mainlatch` 74LS259 addressable latch; `namco` "Namco @ 96.00 kHz"; `screen` @ 6.14 MHz; `gfxdecode`, `palette`, `mono`, `watchdog`. `-listxml pacman`: `rotate="90"`, 288 x 224, 60.606061 Hz, pixclock 6144000, htotal 384, vtotal 264, vbstart 224. `mspacman` and `pengo` have the same devices (Pengo's latch is named `latch`); `jrpacman` has two latches and no pixclock in its display entry. ## Commands ```sh python -I scripts/mame_trace.py --frames 30 # from reset (about 10 s wall) python -I scripts/mame_trace.py --skip 600 --frames 3 # 3 frames of attract, after 10 s python -I scripts/mame_trace.py --snap 10 # untraced, PNG at frame 600 ``` The script's Lua traces `:maincpu` with `pc,af,bc,de,hl,sp,i,im,iff1,totalcycles,beamy` and watches I/O writes (`wpiset 0,100,w`), the latch (`wpset 5000,8,w`) and the WSG registers (`wpset 5040,20,w`). With `--skip N` the trace starts from the frame notifier at frame N. ## Runs made tonight | Run | Result | | --- | --- | | `--frames 30` | 263,394 log lines. One I/O write: port 0 = 0xFA at T 47,747 (line 208). The latch cleared bit by bit (5000-5007 = 0) from T 51; 5000 = 1 (interrupts on) at T 47,779. One interrupt in 30 frames (the start-up tests run with interrupts mostly off), entering 0x3000 with I = 0x3F, IM 2 | | `--snap 10` | `reference/mame/pacman-snap/snap/pacman/0000.png` | | `--skip 600 --frames 3` | 16,199 lines; three interrupts (one a frame); each frame: 5000 = 0 at line 224 (written by the handler), coin lockout and lamps written, 5000 = 1 near line 4-5; 57 WSG register writes, starting at 5050 on line 224 | MAME also logs `Namco: freq fractional bits = 16: internal freq = 192000, output freq = 192000` at start: its internal resampling, not a board fact. ## Traps - `error.log` lands in the working directory (the script runs MAME there and renames it `run.log`); its first line starts with a byte-order mark. - `noloop` hides tight loops, so instruction counts per frame are not the CPU's real count; use `totalcycles` for time. - The Z80's register names in MAME's debugger are `af`, `bc`, ... (not `a`, `f`).