# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: the installed binary is run, its source is never opened (the family treats MAME's sources as closed for this work). Tier 5: a detector. ## Devices (`mame -listdevices `) | Driver | CPU | Others | | --- | --- | --- | | `spectrum` | Zilog Z80 @ 3.50 MHz | screen @ 7.00 MHz, "Spectrum DMA Slot" (expansion) | | `spec128`, `specpls2` | Z80 @ 3.54 MHz | screen @ 7.09 MHz; `ay_slot` with an AY-3-8912A @ 1.77 MHz | | `specpl2a` | as above | | | `specpls3` | as above | `upd765` "NEC uPD765A FDC @ 4.00 MHz" with floppy sound | Romsets under `$MAME_ROMPATH`: `spectrum.zip`, `spec128.zip`, `specpls2.zip`, `specpl2a.zip`, `specpls3.zip`, all complete (census.md, firmware.md). ## The commands ```sh python -I scripts/mame_trace.py --driver spectrum --frames 300 # OUT log + PNG python -I scripts/mame_trace.py --driver spectrum --frames 100 --trace 2 # + Z80 trace python -I scripts/mame_trace.py --driver spec128 --frames 300 python -I scripts/mame_trace.py --driver specpls3 --frames 300 ``` The script passes `-rompath $MAME_ROMPATH -homepath -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -seconds_to_run N -autoboot_script run.lua`, plus `-debug -debugger none` when tracing. The Lua installs a write tap on the Z80's `io` space at start (held in a global) that writes `O port value frame seconds` lines to `outs.log`; with `--trace` it issues `trace T.trace,:maincpu,noloop,{logerror "T %X %d\n",pc,totalcycles}` and turns it off after N frames; a frame notifier saves a snapshot and exits. ## What the runs showed (OBSERVED; each well under 2 s of wall time) - **48K**: one OUT in 300 frames, `07FE <- 07` at 13 µs: the ROM's first instructions set the border white with `OUT (FE),A` while A = 7, and MAME puts A on the high address byte as the Z80 does for `OUT (n),A`. The picture at frame 300 is the "© 1982 Sinclair Research Ltd" screen. The trace starts `T 0 0`, `T 1 4` (DI at 0000, 4 T) and covers 17,478 instructions in two frames, ending at total cycle 139,766 (2 x 69,888 = 139,776). - **128K**: 1,722 OUTs in 300 frames: 7FFD written with banks 7, 6, ... 0 between 0.20 and 0.97 s (the RAM test), then AY setup (FFFD/BFFD: 406 register selects, 4 data writes), 1,311 writes to 7FFD in all. - **+3**: 3,350 OUTs: 7FFD 2,187, 1FFD 1,151 (values 00, 04, 08, 0C: ROM high bit and motor), 3FFD 7 (`03 AF 03` Specify, then `04 01` Sense Drive Status twice), FFFD and BFFD 2 each. The menu reads "Drives A: and M: available". ## Traps met - MAME 0.285's Lua screen object has no `hpos`/`vpos` (calling them raises "attempt to call a nil value"); the tap logs `manager.machine.time` instead. - A write tap installed in the first frame notifier misses the 48K's only OUT (it happens 13 µs after reset): install at script start. - The frame notifier fired 150 times in about 2 s of emulated time in one probe run: it counts host video updates, not 50 Hz frames, under `-video none`. Use emulated time, not the notifier count, when timing matters. - `-seconds_to_run` takes whole seconds; stop from Lua. ## Not run No tape or disc was mounted and no test program was run on MAME (the brief's rule: no emulator runs over a list; the test programs are for the board's ladder). Whether MAME's Spectrum drivers apply contention at all, and with which table, was not checked: its timing is not used as evidence anywhere in these documents. Output: `reference/mame//` (git-ignored): `outs.log`, `run.log`, `run.lua`, `stdout.txt`, `snap/`.