# MAME 0.285 as a closed-box detector: the recipe as run MAME is GPL-2.0+ as a whole (some files BSD-3-Clause): **closed box only** here. Its binary (the distribution's `mame` 0.285) is run; its source is never fetched or opened by this repository (sources.md; the family's closed-box rule). What it does is tier 5: it finds differences, it never decides them. One MAME process at a time, short runs. ## Commands run (2026-11-26) ```sh MAME_ROMPATH=... python -I scripts/mame_trace.py cf2700 --seconds 3 MAME_ROMPATH=... python -I scripts/mame_trace.py cf2700 --no-trace --seconds 12 \ --cart "$NO_INTRO_DIR/Microsoft - MSX/Gradius 2 (Japan, Europe) (En) (Wii U Virtual Console).zip" ``` `mame_trace.py` builds the command ``` mame [-cart1 IMAGE] -rompath $MAME_ROMPATH -homepath \ -snapshot_directory snap -video none -sound none -nothrottle -noreadconfig \ -skip_gameinfo -log -seconds_to_run N [-debug -debugger none -autoboot_script trace.lua] ``` with this Lua script (the family's headless recipe; `logerror` drops lines with more than 14 values, so the trace carries 14): ```lua local dbg = manager.machine.debugger dbg.visible_cpu = manager.machine.devices[":maincpu"] dbg:command('trace z80.trace,,noloop,{logerror "%X %X %X %X %X %X %X %X %X %X %X %d %d %d\\n",pc,b@pc,af,bc,de,hl,ix,iy,sp,i,r,totalcycles,beamy,beamx}') dbg:command('wpiset 0,10000,w,1,{logerror "IW %X %X %d\\n",wpaddr&0xff,wpdata,totalcycles; g}') dbg:command('wpiset 0,10000,r,1,{logerror "IR %X %X %d\\n",wpaddr&0xff,wpdata,totalcycles; g}') dbg:command("go") ``` Each run gets a fresh directory under `reference/mame/` (git-ignored); `error.log` lands in the working directory, which the script sets to that directory. ## Results **Run 1, `cf2700`, no cartridge, 3 s with the trace:** 31.6 s wall; **1,374,251 instructions**; I/O: VDP data (98h) 8,109 writes, VDP control (99h) 716 writes and 110 reads; PSG address (A0h) 156 writes, data (A1h) 81 writes, read (A2h) 149; PPI port A (A8h, slots) 8,240 writes and 4,124 reads, port B (A9h, keyboard) 444 reads, port C (AAh) 445 writes and 74 reads, mode (ABh) 1 write; printer (90h) 1 write. Clock deltas by first opcode byte (the M1 wait as MAME applies it; cpu.md): LD A,n 8; LD A,(HL) 8; INC HL 7; CB xx 10; JR 13; DJNZ 9 or 14; JR NZ 13 or 8; ED repeats 23. The snapshot at 3 s is a plain cyan screen with a black left strip (start-up still in progress, no text yet; MAME's "Caps" lamp overlay in the corner). **Run 2, `cf2700` with *Gradius 2* (Konami SCC), 12 s, no trace:** 0.8 s wall; the snapshot shows the game's title screen ("PLAY SELECT"), so MAME's `konami_scc` device and the machine's slots run the cartridge. ## What it can and cannot decide - **Can** (as a detector): the instruction stream and I/O order of the BIOS from reset, for lockstep against the board at milestone 1 (as colecovision-python did: 945,993 instructions, 0 unexplained); a mapper's bank writes in a game; pictures to triage. - **Cannot**: the M1 wait on acknowledges (MAME's choice is a reading; U1), VDP access timing (VATT judges that), the SCC's corners (U15-U17), the mix (U9), power-on states (U13, U20). Where the board and MAME differ, the documents and VATT decide, and the departure is recorded with a switch so the lockstep can still run in MAME's mode. ## Other closed boxes (not run here) openMSX (GPL-2.0), blueMSX (mixed GPL-2.0/zlib tree), fMSX (Marat Fayzullin, non-commercial), WebMSX (no licence), the ESE-VDP/OCM HDL and MSX_MiSTer (non-commercial clause 3), MSX1_MiSTer (GPL-3.0). If one is wanted as a detector it is built and run from emu-tools-gpl (GPL) or emu-tools-gpl2 (GPL-2.0-only and non-commercial), and this repository reads only its outputs. openMSX is the strongest candidate (its authors measured real machines); its `doc/internal` hardware recordings may be used as data (as sources.md already allows for `vdp-status-race`). Clock Signal (MIT) is a readable tier-5 detector and is pinned sparse (`reference/src/CLK`, the MSX machine and four components); it was read only for the disk interface map (disk.md), and was not built.