# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: run, never read. Its Apple II files are BSD-3-Clause by their `license:` lines ([sources.md](sources.md)), but this phase did not open them (open decision 7). It is a detector, tier 5. ## Devices (`mame -listdevices `) | Driver | CPU | Video | Default cards | | --- | --- | --- | --- | | `apple2`, `apple2p` | "MOS Technology 6502 @ 1.02 MHz" | `a2video` "Apple II video (composite) @ 14.31 MHz" | `kbd` (new keyboard, AY-5-3600); sl4 Mockingboard (via1, via2, ay1, ay2 "AY-3-8913 PSG @ 1.02 MHz"); sl6 `diskiing` "Apple Disk II NG controller (16-sector) @ 7.15 MHz"; slots sl0-sl7 "@ 7.15 MHz" | | `apple2e` | "MOS Technology 6502 @ 1.02 MHz" | "Apple II video (composite/RGB)" | sl4 Mockingboard, sl6 Disk II NG; sl1-sl7 | | `apple2ee` | "WDC W65C02 @ 1.02 MHz" | as `apple2e` | as `apple2e` | | `apple2c` | "WDC W65C02 @ 1.02 MHz" | composite | "sl4" Mockingboard Sound/Speech I, "sl6" Disk II NG controller (MAME's arrangement for the built-ins) | | `apple2gs` | "WDC W65C816 @ 2.86 MHz" | `a2video` | `fdc` "Apple IWM floppy controller @ 7.15 MHz", `ensoniq`; sl1-sl7 | ## Romsets From `$MAME_ROMPATH`: `apple2.zip`, `apple2p.zip`, `apple2jp.zip`, `apple2e.zip`, `apple2ee.zip`, `apple2ep.zip`, `apple2c*.zip`, `apple2gs*.zip`, and the devices `a2diskiing.zip` (P5 341-0027 + P6 341-0028), `diskii13.zip` (P5 341-0009 + P6 341-0028), `mockingboardd.zip`, `a2thunpl.zip` and others ([census.md](census.md)). ## The commands ```sh python -I scripts/mame_trace.py apple2p --frames 180 --snap --label snap # ~1 s wall python -I scripts/mame_trace.py apple2p --frames 60 --trace --bus --label trace # ~3 s wall python -I scripts/mame_trace.py apple2p --frames 300 --bus --label bus python -I scripts/mame_trace.py apple2p --frames 120 --trace --bus --range C0E0-C0EF \ --label diskboot --flop1 "" # ~13 s wall python -I scripts/mame_trace.py apple2ee --frames 900 --snap --label akalabeth --flop1 "<...>" ``` What the script passes: `-rompath $MAME_ROMPATH -homepath -snapshot_directory /snap -cfg_directory /cfg -nvram_directory /nvram -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -autoboot_script run.lua`, plus `-debug -debugger none` for `--trace` or `--bus`, and `-flop1 `. The Lua script issues `trace cpu.trace,,noloop,{logerror "%X %X %X %X %X %X %d\n",pc,a,x,y,sp,p,totalcycles}` (so `error.log` gets one line per instruction and `cpu.trace` the disassembly), and for `--bus` two debugger watchpoints over the range, `wpset ,,r,1,{logerror "R %X %X\n",wpaddr,wpdata; go}` and the same for `w`; a frame notifier counts frames, saves a snapshot and exits. ## Results (2026-11-26) | Run | Result | | --- | --- | | `apple2p` 180 frames, snap | "APPLE ][" at the top, otherwise black (the Autostart ROM searching slot 6); the snapshot is 560 x 192 | | `apple2p` 60 frames, trace + bus | first lines `FA62 0 80 0 1FD 36 8`, `FA63 0 80 0 1FD 36 10`, `FE84 0 80 0 1FB 36 16` (the reset vector to $FA62, SETNORM); last `FCAA 9 60 24 1FA 35 1021798`: **403,852 instructions, CPU cycle 1,021,798 at the end of frame 60** (60 x 17,030 = 1,021,800); 294 reads in $C000-$C0FF: 192 of $C030, 11-12 of each stepper phase $C0E0-$C0E7, one each of $C0EA and $C0EE | | `apple2p` 300 frames, bus | 307,297 reads: 306,932 of $C0EC (306,931 return $80, one $00), the rest as above with 20-21 per phase | | `apple2p` 120 frames, WOZ boot | 783,811 instructions to CPU cycle 2,043,597; 35,789 reads of $C0EC, 9,647 with bit 7 set; the first `D5 AA 96` address prologue appears in the de-duplicated byte stream after about 5,500 bytes | | `apple2ee` 900 frames, WOZ boot | the Akalabeth title text ("WELCOME, FOOLISH MORTAL ...") | ## Traps met - **Lua memory taps are dropped** on this driver: `install_read_tap` on the program space logged two accesses and then nothing, presumably when the driver remaps its banks; debugger watchpoints (`wpset`) record every access. Use watchpoints. - The 6502's stack register symbol is `sp`; with `s` the `logerror` action prints empty lines. - `-video none` without `-seconds_to_run` draws a warning; the run is stopped from Lua. - The log starts with "Error opening sample '525_...'" lines (no floppy-sound samples): noise. - MAME's `-flop1` takes a zip holding a WOZ directly, so images are read in place. - With no disk, MAME's controller returns $80 at $C0EC; what a real controller returns with no disk depends on the MC3470's noise (WOZ notes): MAME is a detector here, not a reference. ## Output `reference/mame/-