# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box: run, never read. Its Williams files are BSD-3-Clause by their `license:` lines ([sources.md](sources.md)); tonight's brief keeps them closed anyway. Tier 5, a detector. ## Devices and clocks (`mame -listxml`) Every first-generation set: `maincpu` Motorola MC6809E at 1,000,000 Hz; `soundcpu` MC6808 at 3,579,545 Hz (the input clock; E is a quarter); `dac` MC1408; `pia6821` devices; `watchdog`; `nvram`; display 292 x 240 at 60.096154 Hz, pixel clock 8 MHz, 512 x 260 total. Robotron, Joust, Bubbles, Sinistar: `williams_blitter_sc1_device`; Splat, Blaster: `williams_blitter_sc2_device`; Sinistar and PlayBall!: `hc55516`; Sinistar cockpit and Blaster: `soundcpu_b` and a second DAC. Second generation: sound CPU at 4 MHz, `gfxdecode`; Joust 2 adds a `s11_obg` board (MC6809E 2 MHz, YM2151, HC-55516). Mystic Marathon's display is 256 lines at 61.035 Hz (the only first- or second-generation set not at 260 lines). ## The command ```sh python -I scripts/mame_trace.py robotron --seconds 16 # board events python -I scripts/mame_trace.py sinistar --seconds 20 python -I scripts/mame_trace.py defender --seconds 8 python -I scripts/mame_trace.py robotron --seconds 2 --instructions # + every main-CPU instruction ``` It runs `nice mame -rompath $MAME_ROMPATH -homepath -nvram_directory /nvram -cfg_directory /cfg -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -debug -debugger none -seconds_to_run N -autoboot_script run.lua`. The Lua sets watchpoints (`wpset addr,len,r|w,1,{logerror "...",wpaddr,wpdata,totalcycles,beamy; g}`) on the main CPU's blitter registers, PIAs, vertical count, watchdog and bank latch, and on the sound CPU's PIA (by switching `manager.machine.debugger.visible_cpu` before the command), presses Advance when a fresh-CMOS game waits for it, and exits by frame count from a frame notifier. Output: `reference/mame//run.log` (git-ignored). ## Runs (all from a blank NVRAM, CPUs 24-31, `nice`) | Game | Emulated | Wall | Events | Notes | | --- | --- | --- | --- | --- | | robotron | 16 s | 3.8 s | 247,509 lines: 221,921 watchdog writes (39h), 11,034 sound-PIA accesses, 5,621 blitter register writes (634 blits: control 1Ah x 594, 3Ah x 40), 1,372 vertical-count reads, 2,199 bank writes | the ROM tests run to frame ~700, then the factory-settings wait; Advance pressed at frame 685 by the script | | sinistar | 20 s | not timed | 274,253 lines: 8,675 blits (1Ah x 8,219, 12h x 456), 204,842 watchdog writes, only 10 sound-PIA accesses | its fresh-CMOS loop sits at 4A26-4A30 (found here); no speech in 20 s of attract: a coin-up run is needed for a speech capture | | defender | 8 s | 2.0 s | 2,356 watchdog writes (38h to **C3FC**), 6,411 page-latch writes at D000 (pages 0, 1, 2, 3, 7), PIA accesses at CC00-CC07, 11,033 sound-PIA accesses | the I/O window is paged: a watchpoint on C000-CFFF also catches ROM-page reads | ## What the runs showed (OBSERVED, detector-grade) - Robotron's IRQ handler reads the vertical count as 0x00, 0x40, 0x80, 0xC0 (274 times each), i.e. at lines 0, 64, 128, 192: the VA11 falling edges. It read 0xFC once, at MAME's beam line 255. No read fell on lines 256-259 in this run, so whether MAME 0.285 still returns 0x00 there (Riddle's MAME 0.145-era finding) is not yet known: a WETS-style probe run is the test (U5). - Robotron and Sinistar **read write-only addresses**: CA01 (the blitter's mask) at the instructions after `7F CA 01` (`CLR $CA01`: the 6809's CLR reads its operand before writing it), and C010, C00A, C004 (colour RAM) at `36 36` (`PSHU`), where MAME's 6809 performs a read at the stack address before pushing. Neither read has an effect on these boards (the blitter and colour RAM have no read side), but a dummy read that lands on a PIA data register would clear its interrupt flags: the board needs the core's every bus cycle, with dummy cycles marked ([cpu-cores.md](cpu-cores.md) request 2). Whether the real 6809E reads the stack address in PSHU is the core's question (its data-sheet cycle tables). - MAME warns that the PIAs' CA1, CA2 and CB1 inputs have no read handlers on some PIAs (`[:pia_1] Error! no CB1 read handler`): MAME's wiring, not hardware facts. ## Traps met - `-seconds_to_run` takes whole seconds; stop by frame count from Lua. - A blank NVRAM sends Robotron, Joust and Sinistar through their ROM tests (about 11 s) into a wait for Advance with IRQs masked; the script presses it (m6809-python's addresses for Robotron and Joust; Sinistar's found here). Short runs that stop before frame ~700 see only the self-test. - `manager.machine.video:snapshot()` with `-video none` wrote PNGs in some runs only. - Watchpoint ranges on Defender must avoid the paged C000-CFFF window or they log ROM reads.