# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here, tier 5, a detector. Its VIC-20 files carry `license:BSD-3-Clause` (checked tonight through raw.githubusercontent.com at tag `mame0285`, the first 300 bytes of each file only: `mame/commodore/vic20.cpp`, `sound/mos6560.cpp/.h`, `machine/6522via.cpp/.h`, `bus/vic20/{exp,std,vic1110,vic1111,vic1210,fe3,megacart,user}.cpp`, `bus/cbmiec/{c1541,cbmiec}.cpp`, `machine/64h156.cpp`, `bus/pet/{cass,c2n}.cpp`, `lib/formats/{cbm_tap,d64_dsk,g64_dsk,cbm_crt}.cpp`, `cpu/m6502/m6502.cpp`, `mame/commodore/cbm_snqk.cpp`). Tonight's brief keeps it closed regardless: nothing of it was read beyond those header lines, nothing fetched (open decision 9). ## Devices (`mame -listdevices vic20`, `vic20p`) `ue10` MOS 6502 @ 1.02 MHz (PAL 1.10); `ub7` MOS 6560 VIC (PAL: 6561); `uab3` and `uab1` MOS 6522 VIA; `exp` expansion port (slots: 3k, 8k, 16k, exp, fe3, speakez, videopak); `tape` with `c1530`; IEC slots 4, 8-11 with **a `c1541` on device 8 by default** (`ucd5` 6502 @ 1 MHz, VIAs `uab1`, `ucd4`, `uc4` 64H156 @ 16 MHz); `joy1` VCS-style port; `user` port; quickload. Screens: 200 x 248 at "60.000000" Hz (vic20), 224 x 296 at 50 Hz (vic20p), "Deprecated legacy Old Style screen" by MAME's own log line. ## Commands ```sh python -I scripts/mame_trace.py --snap 4 # untraced, PNG after 4 s (0.7 s wall) python -I scripts/mame_trace.py --snap 4 --driver vic20p python -I scripts/mame_trace.py --frames 120 # 6502 traced, 2 s (10 s wall, 17 MB log) ``` The script passes `-rompath $MAME_ROMPATH -homepath -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -seconds_to_run N -autoboot_script run.lua`, plus `-debug -debugger none` when tracing. The Lua sets `debugger.visible_cpu` to `:ue10`, issues `trace S.trace,:ue10,noloop,{logerror "S %X %X %X %X %X %X %d\n",pc,a,x,y,p,sp,totalcycles}` and `wpset` write watchpoints on $9000 (16 bytes), $9110 and $9120, and a frame notifier saves a snapshot and exits. One MAME process at a time, under `nice`, on CPUs 24-31. ## Results | Run | Result | | --- | --- | | `--snap 4` (vic20) | "**** CBM BASIC V2 **** / 3583 BYTES FREE / READY." on the white screen with cyan border; 200 x 248 PNG | | `--snap 4 --driver vic20p` | the same banner, 224 x 296 | | `--frames 120` (vic20) | **606,646 instructions in 2,045,451 CPU cycles** (3.37 cycles an instruction; mostly the KERNAL's RAM test loop at $E5E8-$E5EF, 112,900 times each); 305 VIC/VIA register writes; first instruction at $FD22 (the reset vector's target) at cycle 8 | From the watchpoints (OBSERVED, detector): the KERNAL first touches the VIAs at cycle 503,667 (after the RAM test): IERs $7F, ACRs $40, PCRs $FE/$DE, DDRs, VIA1 IER $82, VIA2 IER $C0, VIA2 T1 $4289; then the VIC from $900F down to $9000 (`$900F=$1B`, `$9005=$C0` then `$F0`, `$9003=$2E`, `$9002=$16` then `$96`, `$9001=$19`, `$9000=$05`). ## Traps met - 120 frames took 2,045,451 cycles: MAME's NTSC frame is 17,045.4 cycles (its 60.000 Hz legacy screen), not the VIC's 65 x 261 = 16,965 (C1). Count by CPU cycles, never by MAME frames, when comparing. - The default 1541 runs in every vic20 run and its floppy-sound samples are missing (log noise). MAME's usual empty-slot option (`-iec8 ""`) should detach it: untested. - `-seconds_to_run` takes whole seconds; the Lua frame notifier stops the run.