# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: run, never read (tonight's rule treats all of its source as closed, though the BBC files carry BSD-3-Clause lines: [sources.md](sources.md)). It is a detector, tier 5. One process at a time, short runs, `nice` and `taskset -c 24-31`. ## Devices (`mame -listdevices`) **bbcb** (Model B): `maincpu` "MOS Technology 6502 @ 2.00 MHz"; `crtc` "Hitachi HD6845S CRTC @ 2.00 MHz"; `saa5050` @ 6.00 MHz; `sysvia`, `uservia` "MOS 6522 VIA @ 1.00 MHz"; `sn` "SN76489A @ 4.00 MHz"; `acia` MC6850; `serproc` "Acorn Serial ULA (SERPROC) @ 1.23 MHz"; `upd7002` @ 1.00 MHz; `latch` "74LS259 Addressable Latch"; `fdc` slot with `acorn8271` → `i8271` @ 4.00 MHz; `mc6854` ADLC; `vsp` slot (TMS5220 @ 640 kHz + TMS6100); four `romslot`s; `1mhzbus`, `tube`, `userport`, `analogue`, `rs423`, `cassette` ports; software lists `bbc_cass`, `bbc_rom`, `bbcb_flop`, `bbcb_flop_orig`, `bbc_hdd`, `bbc_vsm`. **bbcbp** (B+ 64K): `maincpu` "MOS Technology 6512 @ 2.00 MHz"; `wdfdc` "Western Digital WD1770 FDC @ 8.00 MHz"; five 32K `romslot`s; otherwise as `bbcb`. **bbcm** (Master 128): `maincpu` "GTE G65SC12 @ 2.00 MHz"; two Electron-style cartridge slots; internal and external Tube ports; internal modem port; the rest as above. Observations against the documents: - The CRTC is listed at 2.00 MHz for all three (the 6845's character clock switches between 1 and 2 MHz with the Video ULA's bit 4: AUG 19.1.4). OBSERVED, not checked further. - The PSG is named "SN76489A" against Acorn's "SN76489" (C5). - **MAME's cycle count does not show cycle stretching.** In the boot trace, the MOS's keyboard-scan loop at &DA08-&DA0E (DEX; `STX &FE40`; a 2-cycle compare; a taken branch) repeats every 11 cycles, with `STX &FE40` (a write to the system VIA, a slow device) counted as 4 cycles (507,359 → 507,363), which is the unstretched 6502 count; the real machine adds 1 or 2 (SM85-1 figure 1.2). OBSERVED. MAME may model the delay some other way not visible in `totalcycles`; either way **its timing cannot judge or even detect stretching**, and a lockstep against MAME must compare instruction streams and written values, not cycle counts, across slow accesses. ## Romsets From `$MAME_ROMPATH` (non-merged sets): `bbcb.zip` (OS 0.1, 0.92, 1.00, 1.20; BASIC I, II; DFS 0.90, 0.98; DNFS 1.00, 1.20; Watford DFS 1.30-1.44; the speech PHROM; the SAA5050), `bbcbp.zip`, `bbcm.zip` and the rest: [census.md](census.md). The default BIOS of `bbcb` boots OS 1.20 with Acorn DFS (the first screen above). ## The commands ```sh python -I scripts/mame_trace.py --snap 3 # bbcb, untraced, PNG at frame 150 (~1 s wall) python -I scripts/mame_trace.py --driver bbcm --snap 3 # Master 128 python -I scripts/mame_trace.py --frames 50 # bbcb, main 6502 traced (~11 s wall, 16 MB log) ``` What the script passes: `-rompath $MAME_ROMPATH -homepath -snapshot_directory -cfg_directory -nvram_directory (all under ) -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 `manager.machine.debugger.visible_cpu` to `:maincpu`, issues `trace S.trace,,noloop, {logerror "S %X %X %X %X %X %X %d\n",pc,a,x,y,p,sp,totalcycles}` and two `wpset` watchpoints over &FE00-&FEFF (writes "W addr data cycles", reads "R ..."), then a frame notifier saves a snapshot at the frame count and exits. ## Traps met - The trace action's register names for MAME's 6502 are `pc`, `a`, `x`, `y`, `p`, `sp` (w65c02-python's recipe); `s` and `curpc` in the first attempt gave **no trace lines at all, silently** (only the watchpoint lines appeared). That run was moved to `trash/`. - The 50 Hz machine: frames are counted at 50 a second (`--snap 3` = 150 frames). - The log carries "Error opening sample" lines for the cassette motor and floppy sounds (MAME's optional samples are not installed): noise, not findings. ## Output `reference/mame/-snap/` and `reference/mame/bbcb-trace/` (git-ignored): `run.log` (the trace and watchpoint lines and MAME's own log), `snap//0000.png`, `stdout.txt`. The trace also gave the MOS's own 6845 programming for mode 7 (R0-R13), which corrects two values in the AUG's appendix F ([crtc6845.md](crtc6845.md), C3, C4): a fact about the firmware, which MAME merely carried.