# MAME 0.285 as a closed-box detector (tier 5) MAME is run as a binary. Its WonderSwan files (`src/mame/bandai/wswan.cpp`, `wswan_v.cpp`, `src/devices/bus/wswan/rom.cpp`, `slot.cpp`, `cpu/v30mz/v30mz.cpp`) carry `license:BSD-3-Clause` lines (Anthony Kruize, Wilbert Pol, Bryan McPhail; read 2026-11-26 from the first lines only, at tag mame0285); this batch's brief holds MAME's drivers closed, so their bodies were not opened (open decision 7). Its software lists (`hash/wswan.xml`, `wscolor.xml`) are CC0 and pinned. One MAME process of ours at a time (a `flock` on a shared lock file), short runs, `nice`, CPUs 24-31. ## Machines `wswan` (no cartridge needed), `wscolor` (refuses to start without a cartridge), `pockchv2`; no SwanCrystal machine. Devices: `maincpu NEC V30MZ @ 3.07 MHz`, `vdp`, `custom` (sound), `cartslot @ 384 kHz`, `nvram`. Screen: 224 x 144, htotal 256, vtotal 159, 75.471698 Hz, pixel clock 3.072 MHz (`-listxml`). Inputs (`:BUTTONS` Button A, B, Start; `:CURSX` X1-X4; `:CURSY` Y1-Y4; `:SOUND_OUTPUT`). CPU symbols: AW BW CW DW SP BP IX IY PS SS DS0 DS1 PSW IP. ## The recipe ```sh # with MAME_ROMPATH and NO_INTRO_DIR set (the family's profile) python -I scripts/mame_trace.py --machine wswan --frames 3 --trace-frames 1 python -I scripts/mame_trace.py --machine wscolor \ --cart "Bandai - WonderSwan Color/Final Fantasy (Japan).zip" --frames 300 --trace-frames 0 --snap ``` Outputs under `reference/mame/run/` (git-ignored): `trace.log` (the V30MZ from reset with registers), `io.log` (every I/O write through a Lua write tap on the CPU's I/O space: frame, even port address, 16-bit data, byte-lane mask), and `snap//0000.png`. Earlier logs are moved to `trash/` before a run. ## Runs, 2026-11-26 | Run | Result | | --- | --- | | `wswan`, no cartridge, 3 frames, 1 traced | `FRAMES 3 TIME 0.039750`; 7,148 instructions traced (the boot ROM's first frame, from `br 0FF00h:0h` at FFFF0h, FLAGS F002h); 78 I/O writes | | `wscolor`, Final Fantasy (Japan), 300 frames | `FRAMES 300 TIME 3.975000`; 2,185 I/O writes (most to 88h, 06h, B6h, B4h, C2h, the scroll and window ports); the snapshot shows the SQUARESOFT logo | The I/O log of the first run shows the boot ROM's own writes in order (B4h, A0h, BCh/BEh for the internal EEPROM, 16h/17h, the scroll, volume and sprite ports, ...): a detector for the board's boot-ROM run, port by port, frame by frame. v30mz-python's recipe adds `totalcycles` to the trace and runs WSCpuTest, which MAME 0.285 fails at NEG bytes (v30mz-python docs/mame-oracle.md): so MAME is a detector for instruction streams and port traffic, not for CPU flags. ## How the board uses it Milestone 1 compares the boot ROM's instruction stream and I/O writes with MAME's for the first frames, flags masked, each difference triaged; later milestones compare pictures (snapshots at fixed frames) and the I/O log of named games as detectors only.