# MAME as a detector: the 32X recipe and what it did MAME 0.285 is installed as `/usr/games/mame` (the version megadrive-python pins and traces against). Its 32X is `src/mame/shared/mega32x.cpp` (pinned sparse in `reference/src/mame`; BSD-3-Clause by its first line, so it may be read; the rest of MAME is GPL and run only), with drivers `32x` (Genesis with 32X, USA NTSC), `32xj`, `32xe`, `32x_scd`, `32x_mcd`, `32x_mcdj`. It is a **detector**, and a weak one for the 32X: its own source lists much as unimplemented, and the two programs that judge this board both go wrong on it (below). ## The command ```sh mame 32x -cart \ -rompath "$MAME_ROMPATH" \ -homepath -snapshot_directory /snap -video none -sound none -nothrottle \ -noreadconfig -skip_gameinfo -seconds_to_run -log ``` `-video none` still writes the exit snapshot (`snap/32x/0000.png`). The `32x` set needs the user's boot ROMs in MAME's romset (`32x.zip` in the rompath above: `32x_g_bios.bin`, `32x_m_bios.bin`, `32x_s_bios.bin`, the SHA-1s in [start-here.md](start-here.md); `32x_m_bios_sdk.bin` is listed as a bad dump and may be absent). This repository never copies them; MAME reads them where the user keeps them. For instruction traces, megadrive-python's `scripts/mame_trace.py` recipe applies (`-debug -debugger none`, an autoboot Lua script with `trace` on `:maincpu`); the SH-2s are the devices `:sega32x:32x_master_sh2` and `:sega32x:32x_slave_sh2` (from `mame -listdevices 32x`: `sega32x`, `32x_master_sh2`, `32x_slave_sh2`, all at 23.01 MHz). Not yet run here: tracing waits for milestone 2, and the device tags should be confirmed with `mame -listdevices` and the Lua console before the first trace. ## What it produced (2026-10-21) | Program | Seconds | Result | Snapshot | | --- | --- | --- | --- | | testpico, hardware build `testpico-30a5783.bin` | 30 | fails Mega Drive timing tests (the visible ones: "time hblank h40", "time hblank h32", "time vdp vram w", "timer ab sync"; earlier lines scrolled off), then takes **exception 4 (illegal instruction)**; never reaches the 32X tests | red failures, then the exception screen | | Mars Check Program (USA) (Program) | 420 | stops at test **39/161**, ERROR COUNT **2**, on "MD & SH2 SYSTEM REGISTER R/W CHECK" | the stuck counter | Rerun 2026-10-23 for milestone 0 with an autoboot Lua script (`emu.register_frame_done`, `manager.machine.video:snapshot()` every frame for testpico, every 600 for the Mars Check Program; `-autoboot_script`, the rest of the command as above): testpico fails tests 1, 2, 6, 9-11, 13, 15, 16, 21, 22, 26-33 and 37, then takes the exception (PC `$000778`) within 40 frames. The Mars Check Program, rerun 2026-10-24 with a snapshot every second frame, passes tests 1-37, fails 38 ("SH2 MASTER TIMEOUT ERROR") and 39 ("MD&SH MASTER COMMUNICATION ERROR" at `$A15128`) and stalls in 40, ERROR COUNT 2. Per-test tables: [validation.md](validation.md), "Milestone 0". For comparison, PicoDrive (irixxxx 1008a98, no boot ROMs, its built-in start; a closed box, OBSERVED) runs the Mars Check Program to its end, ERROR COUNT 0 and "すべて正常に終了しました" ("all finished normally") within 8,000 frames, and testpico 54/57 ([validation.md](validation.md)). So on 2026-10-21 MAME 0.285 is not a usable detector for the 32X's registers; it may still serve for SH-2 instruction traces of games it runs. ## Traps 1. **The boot ROMs come from the user's MAME romset.** If `32x.zip` is missing MAME refuses to start; do not "fix" that by fetching. 2. **The exit snapshot is all `-video none` gives.** For more frames, use `-snapshot_directory` with Lua `manager.machine.video:snapshot()` at chosen frames, as megadrive-python's `mame_media.py` does. 3. **MAME's 32X picture** is composed by MAME's own approximation of the priority rule; never use it to judge the composite.