# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: run, never read. Its SH-4 files (`src/devices/cpu/sh/sh4*.cpp`) carry `license:BSD-3-Clause` (R. Belmont; only the header lines were read, 2026-11-26, through raw.githubusercontent.com at tag `mame0285`), the Dreamcast driver `sega/dc.cpp` and `dccons.cpp` carry `license:LGPL-2.1+`. By the brief for this batch all of MAME is treated as closed; whether the BSD files may be read is open decision 7. Tier 5: a detector. ## Device (`mame -listdevices dc`) `maincpu` "Hitachi SH7091 @ 200.00 MHz"; `soundcpu` "ARM7 (little) @ 2.82 MHz"; `aica` @ 22.57 MHz; `powervr2`; `sb_g2if` @ 25.00 MHz; `screen` @ 26.91 MHz; `gdrom` on an ATA bus; `maple_dc` with four `dcctrl`; `dcflash` "Fujitsu MBM29LV002TC Flash". ## Commands ```sh python -I scripts/mame_trace.py --start 0 --frames 3 # from reset python -I scripts/mame_trace.py --start 1000 --frames 1 # one frame in the boot ROM's menu ``` The script runs `mame dc -rompath $MAME_ROMPATH ... -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -nodrc -debug -debugger none -autoboot_script run.lua`; the Lua script sets `manager.machine.debugger.visible_cpu` to `:maincpu`, issues `trace S.trace,:maincpu,noloop,{logerror "S %X %X %X %X %d\n",pc,sr,pr,r15,totalcycles}` at the start frame (from a frame notifier), and exits after the last. It then summarises the window (`summary.txt`). ## What ran | Run | Result | | --- | --- | | frames 0-3 from reset (the same Lua, run by hand before the script existed) | 7,376,144 instructions, 10,010,008 MAME cycles (1.357 a instruction), 152 distinct PCs: a memory-clear loop at 8C0000E8 (35 %) and a 3-instruction delay loop at 8C00B6B8 (65 %). Not representative. 139 s wall | | frames 1000-1003 (by hand) | 7,817,016 instructions, 10,010,009 cycles (1.281), 12,405 distinct PCs; 20 PCs cover 90 %: a wait loop at 8C0BA506-8C0BA52C and 8C0B926A. 231 s wall including 1000 untraced frames under `-debug` | | `scripts/mame_trace.py --start 1000 --frames 1` | 2,605,142 instructions, 3,336,667 cycles (1.281), 12,229 distinct PCs, 20 PCs for 90 %. 127 s wall | 200 MHz / 60 Hz is 3.33 M cycles a frame, which the windows match (3 x 3.34 M). The boot ROM shows its Set Date/Time dialog by frame 600 (at frame 300 only the background is drawn) with an empty NVRAM (dreamcast-python docs/mame-oracle.md has the picture's run). ## What it can decide, and what not - **Can**: the instruction stream of the boot ROM for the first rungs' lockstep (PC, SR, PR, R15 per instruction); which code paths the boot ROM takes; register-write order to the board's devices (the log's unmapped-write lines name several). - **Cannot**: cycle counts (MAME charges its own, about 1.28-1.36 a instruction here; dual issue is not modelled as far as the figures show); FPU bit patterns of FIPR/FTRV (MAME's arithmetic is its own); cache, TLB or store-queue timing. ## Traps - `-nodrc` is required or the trace stays empty (the recompiler bypasses the debugger). - `pc`, `sr`, `pr`, `r15` are valid SH-4 symbols in MAME's debugger; the ARM7's PC is `curpc` (`pc` printed 0: dreamcast-python's recipe). - One traced frame is about 130 MB of log; the script moves the disassembly file (`S.trace`) to `trash/`. Keep windows to one to three frames. - The log's "Unmapped write" lines for `ccr_w`, `bcr1_w`, `wcr1_w`, `mcr_w`, `sdmr3_w` are MAME's SH-4 not modelling those BSC/cache registers: the boot ROM's own values for CCR (00000929, 00000905, 0000090D, 00000800), BCR1 (A3020008), BCR2 (0001), WCR1 (01110111), WCR2 (618066D8), MCR (800A0E24 then C00A0E24), SDMR3 (90). Useful as the boot ROM's BSC setup; MAME's own handling of them is not evidence.