# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: run, never read. Its X68000 files carry BSD-3-Clause `license:` lines (sources.md: only those lines were read), but this Phase 0's brief names the driver a closed box. It is a detector, tier 5. One MAME process at a time, short runs only, under `nice` and `taskset -c 24-31`. ## Devices (`mame -listdevices x68000`, OBSERVED) `maincpu` MC68000 @ 10.00 MHz; `hd63450` HD63450 DMAC @ 10.00 MHz; `mc68901` MC68901 MFP @ 4.00 MHz; `ym2151` YM2151 OPM @ 4.00 MHz; `okim6258` OKI MSM6258 ADPCM @ 4.00 MHz with two output volume filters; `upd72065` NEC uPD72065 FDC @ 8.00 MHz with four 5.25" HD drive connectors; `scc` Z8530 SCC @ 5.00 MHz; `rp5c15` RP5C15 RTC @ 32.76 kHz; `ppi8255`; `crtc` "IX0902/IX0903 VINAS CRTC @ 38.86 MHz"; `screen` @ 34.77 MHz; `nvram`; `keyboard` (an RS-232 port with the "Sharp X68000 Keyboard" device) and `mouse_port` (the "Sharp X68000 Mouse"); `joy1`, `joy2` MSX general-purpose ports with FM Towns pads; `x68k_hdc` "SASI Hard Disk"; two expansion slots; two software lists. `x68ksupr` adds a SCSI bus with the "Fujitsu MB89352 SCSI controller @ 5.00 MHz" at ID 7, a hard disk at 0 and a CD-ROM at 6; `x68030` has an "MC68030 @ 25.00 MHz". ## Romsets `x68000.zip`, `x68ksupr.zip`, `x68kxvi.zip`, `x68030.zip` (and the device set `x68k_cz6bs1.zip`) under `$MAME_ROMPATH`: the five IPL ROM versions as BIOS sets (`-bios ipl10 | ipl11 | ipl12 | ipl13 | cz600ce`), the CGROM, and each later model's SCSI ROM (census.md). ## The commands ```sh python -I scripts/mame_trace.py --snap 8 # untraced, PNG at frame 440 (~2.8 s wall) python -I scripts/mame_trace.py --frames 60 --reads # 68000 traced, I/O watched (~15 s wall, 22 MB log) python -I scripts/mame_trace.py --frames 60 --bios ipl13 # another IPL ROM (not run tonight) ``` What the script passes: `-rompath $MAME_ROMPATH -homepath -snapshot_directory -nvram_directory -cfg_directory /... -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -seconds_to_run N -autoboot_script run.lua`, and when tracing `-debug -debugger none`. The Lua script sets the debugger's visible CPU to `:maincpu`, issues `trace S.trace,:maincpu,noloop,{logerror "S %X %X %X %d\n",pc,sr,a7, totalcycles}` and one `wpset` watchpoint per I/O block (memory-map.md) logging `W|R wpaddr wpsize wpdata totalcycles`, then a frame notifier saves a snapshot and exits. The nvram directory is inside the run's output, so every run starts from MAME's empty SRAM. ## What came out - **Snap run** (8 s): the "cannot boot from disk, set the correct disk" box (in Japanese) with MAME's drive-lamp layout beside it. The log holds the SASI device's messages (SPECIFY, REQUEST SENSE, REZERO UNIT, "No HD connected" x4), the keyboard's (LED status 7f, repeat delay 500 ms, rate 30 ms), an unmapped write to E8C002 at PC FF8190, nine "visarea larger then reg[20]" lines and the floppy-sound sample warnings (MAME's samples are not installed: harmless). - **Trace run** (60 frames): 875,417 instruction lines, the first at PC FF0012 with SR 2700, the last at FF0D46 after 10,740,642 clocks (12.3 clocks an instruction). Watched accesses: MFP 10,444 reads and 70 writes, video controller and palette 276 writes, SCC 182, system port 116 writes and 59 reads, FDC 59 writes and 21 reads, CRTC 31, DMAC 31, RTC 10, sprite/BG registers 5, PPI 2, I/O controller 2 writes and 1 read, printer 1, area set 1; no OPM, ADPCM or SASI access in this second. The register values are quoted in the chip documents (video.md, dmac.md, mfp-keyboard-mouse.md, fdc.md). - Interrupts: the level-6 handler at FF133E runs 41 times (the MFP); four rises to mask 7 (at FF0EA2, FF61E4 twice, FF9032) are probably the IPL raising its own mask, not NMIs (not checked; found by scanning SR in the trace). ## Traps met - The 68000 has no DRC in MAME, so no `-nodrc` is needed (unlike the SH-2). - `error.log` lands in the process's working directory; the script runs MAME there and renames it `run.log`. - MAME's frame rate here is the CRTC's: 60 frames took 10.74 M clocks (55.9 Hz on average), while the programmed 768 x 512 mode gives 55.45 Hz; the early frames run on whatever timing the CRTC has before the IPL programs it (HYPOTHESIS, U12). - Watchpoints with reads on the MFP log every poll (10,444 lines a second): keep `--reads` for short runs. ## Output `reference/mame/x68000-default-snap/` and `reference/mame/x68000-default-trace/` (git-ignored): `run.log`, `run.lua`, `stdout.txt`, `snap/x68000/0000.png`.