# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: run, never read. It is a detector, tier 5. One process at a time, short traces only (taskset to CPUs 24-31, `nice`). ## Devices (`mame -listdevices c64`) `u7` MOS Technology 6510 @ 1.02 MHz; `u19` MOS 6567 VIC-II @ 1.02 MHz; `u18` MOS 6581 SID @ 1.02 MHz; `u1`, `u2` MOS 6526 CIA @ 1.02 MHz; `u17` 82S100-series PLA; `exp` expansion port; `iec8` with `c1541`: `ucd5` 6502 @ 1.00 MHz, `uab1` and `ucd4` 6522 VIAs @ 1.00 MHz, `uc4` 64H156 @ 16.00 MHz with an ALPS floppy mechanism; `tape` with a 1530; two Atari/CBM joystick ports; the user port; a quickload device. ## Romsets From `$MAME_ROMPATH`: `c64.zip` (NTSC) or `c64p.zip` (PAL), plus `c1541.zip` for the default drive on IEC device 8 ([census.md](census.md)). ## The commands ```sh python -I scripts/mame_trace.py --snap 4 # untraced, PNG at frame 240 (1.3 s wall) python -I scripts/mame_trace.py --frames 3 # 6510 traced, 3 frames (0.8 s wall) python -I scripts/mame_trace.py --frames 180 # 6510 traced to READY (16 s wall, 26 MB log) python -I scripts/mame_trace.py --cpu drive --frames 60 # the 1541's 6502, 1 s ``` What the script passes: `-rompath $MAME_ROMPATH -homepath -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 sets `manager.machine.debugger.visible_cpu`, issues `trace C.trace,,noloop,{logerror "C %X %X %X %X %X %X %d\n",pc,a,x,y,p,sp,totalcycles}` (the state at the start of each instruction) and, for the 6510, `wpset` write watchpoints on the VIC ($D000, $2F bytes) and both CIAs, then a frame notifier saves a snapshot and exits. ## Results (OBSERVED) - **Snapshot at frame 240**: the BASIC V2 start screen, "64K RAM SYSTEM 38911 BASIC BYTES FREE", READY. - **3-frame trace**: 14,211 instructions from reset ($FCE2) to cycle 51,283 (3 x 17,095 NTSC cycles = 51,285), still in the KERNAL's RAM test; one VIC write and 17 CIA writes. A second run's first 14,211 lines are identical (SHA-1 prefix `647a806d018e99a5` both times): MAME's boot is deterministic. - **180-frame trace**: 885,448 instructions; the KERNAL reaches its keyboard wait loop at $E5CD at **instruction 593,433, cycle 2,128,094** (2.08 s of NTSC time), i.e. 3.59 cycles per instruction over the boot; 1,054 distinct PCs; 48 VIC register writes (each of $D000-$D02E once, $D016 twice) and 144 CIA writes. - **1541, 60 frames**: 283,621 instructions in 1,002,901 drive cycles (3.54 cycles an instruction), the DOS's power-on and idle loop. These are the M1 lockstep targets: the board's 6510 stream from reset to the READY loop equal to MAME's, PC and registers per instruction, or a named reason for each difference (the VIC's and CIAs' timing in MAME are themselves approximations: a difference is a question, not a verdict). ## Traps met - MAME logs missing floppy sound samples (`525_spin_*`): harmless. - ALSA prints a sequencer permission error on stdout with `-sound none`: harmless. - The 6502 debugger's register names are lowercase `pc,a,x,y,p,sp`; the drive CPU's tag is `:iec8:c1541:ucd5`. - Nothing needed `-nodrc` (the 6510 has no recompiler in MAME). ## Output `reference/mame/c64-snap/`, `c64-main-3f/`, `c64-main/`, `c64-drive/` (git-ignored): `run.log`, `snap/c64/*.png`, `stdout.txt`.