# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here: run, never read. Its Macintosh files are BSD-3-Clause by their `license:` lines ([sources.md](sources.md)), but this phase did not open them (open decision 2). It is a detector, tier 5, and on the decisive point of this board (RAM contention) it models nothing (below). ## Devices (`mame -listdevices `) | Driver | CPU | Notable devices | | --- | --- | --- | | `mac128k` | "Motorola MC68000 @ 7.83 MHz" | `fdc` "Apple IWM floppy controller @ 7.83 MHz"; `rtc` "Apple 343-0040 clock/PRAM @ 32.76 kHz"; `scc` "Zilog Z85C30 SCC @ 7.83 MHz"; `via6522_0` "MOS 6522 VIA @ 783.36 kHz"; `kbd` with `mpu` "Intel 8021 @ 3.00 MHz" | | `macplus` | the same | `fdc` with two "Apple/Sony 3.5 DD (400/800K GCR)" drives; `rtc` "Apple 343-0042-B"; `scsi` bus with `ncr5380`; `kbd` M0110A with `mpu` "Intel 8048 @ 6.00 MHz"; `screen` "@ 15.66 MHz"; `macpds` processor-direct slot | | `macse` | the same | `fdc` IWM "@ 15.66 MHz"; `macadb` "Mac ADB HLE"; `adbmodem` with a "GI PIC1654S @ 3.68 MHz"; `via6522_0` "Rockwell R65NC22 VIA"; `scsihelp` "Mac 5380 SCSI helper" | `mame -listsource`: every compact Mac (128K to Classic) is in `apple/mac128.cpp`. ## The commands ```sh python -I scripts/mame_trace.py macplus --frames 600 --snap --label snap # 0.8 s wall python -I scripts/mame_trace.py macplus --frames 1800 --snap --label snap30 # 2.6 s wall python -I scripts/mame_trace.py mac128k --frames 900 --snap --label snap # 1.0 s wall python -I scripts/mame_trace.py macplus --frames 120 --trace --label trace # 16.5 s wall python -I scripts/mame_trace.py macplus --frames 120 --bus --range E80000-EFFFFF --label via python -I scripts/mame_trace.py macplus --frames 120 --bus --range C00000-DFFFFF --label iwm ``` 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`/`--bus`. The Lua issues `trace cpu.trace,,noloop,{logerror "%X %X %X %d\n",curpc,sr,sp,totalcycles}` and, for `--bus`, `wpset ,,r,1,{logerror "R %X %X %d\n",wpaddr,wpdata,totalcycles; go}` and the same for `w`; a frame notifier exits. ## Results | Run | Result | | --- | --- | | `macplus` 600 frames | the grey desktop pattern, no icon yet (10 s: the Plus waits for SCSI and drives) | | `macplus` 1800 frames | the grey desktop, the pointer at the top left, the floppy icon (the blinking "?" caught between blinks) | | `mac128k` 900 frames | the grey desktop, pointer, **the "?" disk icon** | | `macplus` 120 frames, trace | first instruction $40002A `BRA $400042`, then `MOVEM.L $F80000,D0/A0` and `CMPI.L #$55AAAA55,D0`; **969,119 instructions to CPU cycle 15,628,793 at frame 120 = 130,240 a frame** (352 x 370 exactly) | | same, hot loops | the RAM-fill loop at $400E82: `MOVEM.L D2-D4,(A0)` takes **32 clocks in all 87,010 instances**, the 68000's nominal 8 + 8n: **no video contention modelled**; a VIA wait loop: 118,186 iterations of 30 + 10 clocks | | `macplus` 120 frames, VIA watch | 121,782 accesses: 121,672 reads of the IFR ($EFFBFE); **every read on the same phase mod 10 clocks** (121,630 at phase 9), 40 clocks apart (121,587 times): the E-clock wait is modelled for data cycles; first writes: DDRB ($EFE5FE) = $87 at cycle 268, ORB ($EFE1FE) = $87 at 289 | | `macplus` 120 frames, IWM watch | 9 accesses from cycle 5,740,341: motor off, Q6 on, Q7 off (status $80), **mode $1F written** at $DFFFFF, status read back $9F | ## Traps met - **`pc` in a 68000 `logerror` is the prefetch address**: MAME prints $40002C, $400E84 ... for instructions at $40002A, $400E82 (the `cpu.trace` disassembly shows the true addresses). The script now logs `curpc` and `sp` (checked with a 10-frame run: first line `40002A 2700 4D1F8172 34`); the result rows above were taken with `pc` and `a7`. - `a7` is not a valid symbol name in this context (it printed the letters); `sp` is. The first `sp` value is $4D1F8172: the reset SSP comes from the ROM's first long word, which is also its checksum (OBSERVED). - MAME accepts no zip member path for `-flop1` here; the census's disk images live in a collection zip, so no disk boot was run (nothing extracted: images are read in place only). A disk boot needs a player-supplied image path. - `-video none` without `-seconds_to_run` warns; the run is stopped from Lua. - ALSA "Permission denied" lines in stdout are noise. ## Output `reference/mame/-