# MAME as a detector: the verified recipe MAME 0.285 (`/usr/games/mame`; source pinned at `f379cd0`, the binary's) is a **detector** for this board, never a judge, and a weak one for the CD itself: its Sega CD (`src/mame/sega/megacd.cpp`, the CDC and CDD in `src/mame/shared/megacdcd.cpp`, PCM in `src/devices/sound/rf5c68.cpp`) fails most of mcd-verificator. Those three files are BSD-3-Clause (each file's first line, checked 2026-11-19) and may be read, with MAME's notice kept for anything taken; what they say is an emulator fact (`OBSERVED` tier), not a hardware fact. MAME's other files are checked one by one, and the GPL ones are not opened. Its value is the debugger: it traces the main 68000, the sub 68000 and the Z80 instruction by instruction with cycle counts, which no other referee here does headless. Everything below was run on 2026-10-21. ## The command ```sh python scripts/mame_cd.py "DISCS/Sonic CD (USA).chd" \ --rompath "$MAME_ROMPATH" \ --frames 300 --trace --work runs/mame-trace ``` runs, in a fresh directory, ```sh mame segacd -rompath -cdrom -video none -sound none -nothrottle \ -skip_gameinfo -snapshot_directory snap -autoboot_script snap.lua \ [-debug -debugger none] ``` where `snap.lua` takes a snapshot at each wanted frame (`emu.register_frame_done`, `manager.machine.video:snapshot()`) and exits after the last, and with `--trace` first issues, through `manager.machine.debugger`, ``` trace main.tr,:maincpu,noloop,{tracelog "%X %X %d\n",curpc,sr,totalcycles} trace sub.tr,:segacd:segacd_68k,noloop,{tracelog "%X %X %d\n",curpc,sr,totalcycles} trace z80.tr,:genesis_snd_z80,noloop,{tracelog "%X %d\n",curpc,totalcycles} go ``` ## What it produced - **Sonic CD (USA), BIOS v1.10 (`segacd`), frame 1500**: the game's "Internal RAM is not initialized. Use the SEGA-CD control panel to format the RAM." screen -- the BIOS booted the disc and the game found blank backup RAM. About 105-114% of real time without tracing. - **300 frames traced**: `main.tr` 220 MB, `sub.tr` 71 MB, `z80.tr` 25 MB, at about 4% of real time. The sub trace starts at `$000200: jmp $256.l` (the BIOS's sub program after SRES is released); at 30 frames it is still empty. - **mcd-verificator as BIOS** (copied as `segacd/mpr-15045b.bin` under a scratch rompath; MAME reports "WRONG CHECKSUMS" and runs it), Sonic CD in the drive, frames 600 to 3600: | Row | MAME 0.285 | | --- | --- | | RAM CART | ERROR 01 | | COLOR CALC | ERROR 05 | | VAR TESTS | 24132, ERROR 02 | | IRQ TEST | 444, ERROR 09 | | REG X000 | ERROR 05 | | REG X002 | ERROR 26 | | REG 2006 | OK | | REG X00C | 3484, ERROR 02 | | REG 8030 | ERROR 02 | | CDC REGS | ERROR 01 | | PROG RAM | OK | | WORD RAM | ERROR 20 | | WRAM PMOD | OK | | CDC INIT | never finishes (unchanged from frame 2400 to 3600) | Genesis Plus GX and BlastEm on the same run: [validation.md](validation.md). ## The traps 1. **`-debugscript` does nothing with `-debugger none`.** Start traces from the Lua autoboot script through `manager.machine.debugger:command`. 2. **`segacd` has no cartridge slot** in MAME (`-listmedia`: `cdrom` only), so mode 1 (cartridge boot) cannot be run in MAME at all; mcd-verificator can only run there as the BIOS. 3. **The sub CPU's tag is `:segacd:segacd_68k`** (`-listdevices`); the main CPU's is `:maincpu`, the Z80 `:genesis_snd_z80`. 4. **Backup RAM persists** in the work directory's `nvram/`; use a fresh `--work` for each comparison, or the second run starts from a formatted RAM. 5. **The BIOS sets in the MAME romset mirror are the only ones checked**: every set MAME lists is there (`segacd` v1.10 `mpr-15045b.bin` CRC `c6d10268`, `segacd2`, `megacd`, `megacdj`, `megacd2`, `megacd2j`, `megacda`, `cdx`, `multmega`, `wmega`, `wmegam2`, `xeye`, `laseract`, `laseractj`, `aiwamcd`, `32x_scd`, `32x_mcd`, `32x_mcdj`). Bring your own; never copy them here. 6. **Trace size**: about 1 MB a frame for the three CPUs. Keep traces under `runs/` (ignored) and compress them, or trace windows. ## Driver facts Emulator facts (`OBSERVED`, MAME `f379cd0`), from running it and from its BSD-3 driver files: - Sub CPU 12.5 MHz (`SEGACD_CLOCK`), RF5C164 at 12.5 MHz, CD-DA at 44.1 kHz (`-listdevices`). - Interrupts to the sub CPU only (`m_scdcpu->set_input_line` for levels 1, 2, 3, the CDC and CDD, and `RESET`/`HALT`; `megacd.cpp`, BSD-3); nothing to `maincpu`. - The LC89510 has no device of its own; it lives in `megacdcd.cpp` with a comment that it should.