# MAME 0.285 as a detector MAME is an emulator (tier 5), run as a closed box: it finds differences, it never decides them. Its Atari 8-bit driver and its ANTIC and GTIA files are GPL-2.0+ and are not fetched or read; only the installed binary is run. (The BSD-3 cartridge, SIO and drive devices under `src/devices/bus/a800/` are pinned and may be read: [sources.md](sources.md).) ## Machines `mame -listxml` (OBSERVED) lists a400, a400pal, a800, a800pal, a1200xl, a600xl, a800xl, a800xlp, a65xe, a65xea, a130xe, a800xe and xegs, and the drives atari810 and atari1050 as devices; ROMs and SHA-1s in [firmware.md](firmware.md). The cartridge slot is `-cart1` (and `-cart2` on the a800), disks `-flop1`, cassette `-cass`. ## The recipe (run 2026-11-26) `scripts/mame_trace.py` wraps it; output goes to `reference/mame//` (git-ignored): ```sh MAME_ROMPATH=... python -I scripts/mame_trace.py a800xl --seconds 3 --snapshot 150 MAME_ROMPATH=... python -I scripts/mame_trace.py a800 --seconds 4 --snapshot 200 \ --cart "$NO_INTRO_DIR/Atari - 8-bit Family/Galaxian (USA).zip" ``` which runs, in the run directory, one process at a time, niced: ```sh mame a800xl -rompath "$MAME_ROMPATH" [-cart1 IMAGE] -homepath DIR -snapshot_directory DIR/snap \ -cfg_directory DIR/cfg -nvram_directory DIR/nvram -video none -sound none -nothrottle \ -noreadconfig -skip_gameinfo -debug -debugger none -log -seconds_to_run 3 \ -autoboot_script DIR/trace.lua ``` with a Lua script that sets `dbg.visible_cpu` to `:maincpu`, starts `trace cpu.trace,,noloop,{logerror "%X %X %X %X %X %X %d %X\n",pc,a,x,y,p,sp,totalcycles,b@d40b}`, sets write watchpoints on GTIA ($D000-$D01F), POKEY ($D200-$D20F), the PIA ($D300-$D303) and ANTIC ($D400-$D40F) that log `W addr value totalcycles`, and holds a frame notifier in a global (notifiers are collected otherwise) that logs `F` each frame and takes the snapshot. `error.log` lands in the working directory. ## What the two runs showed (OBSERVED) | Run | Wall time | Result | | --- | --- | --- | | a800xl, no cartridge, 3 s | 30.3 s (MAME at 9.8 % of real time under the debugger, machine loaded) | 1,649,124 instructions; 179 frame marks, 29,866-29,870 cycles apart (262 x 114 = 29,868); writes: POKEY 2,291, GTIA 211, ANTIC 204, PIA 114; PORTB $FF, $FF, $FF, $FD at cycles 192,360-192,469, $7D at 1,729,541 (self-test ROM mapped), $FD at 2,303,421; code in $C000-$CFFF (568,336 instructions) and $E000-$FFFF: the XL OS v2. The frame-150 picture: the blue editor screen with the cursor, no READY yet | | a800 + Galaxian (USA), 4 s | 29.4 s | MAME warns "co12499b.rom ROM NEEDS REDUMP", "co14599b.rom ROM NEEDS REDUMP" (C2); 1,398,602 instructions, 239 frame marks, the same 29,866-29,870 spacing; 1.23 M instructions in the cartridge's $B000 page; the frame-200 picture is Galaxian's attract screen ("© 1982 ATARI, INC."), with heavy mid-frame register traffic (GTIA 196,147 writes, ANTIC 50,202; which are WSYNC and DLI work was not broken down) | ## What it can and cannot decide here - It **can** detect: boot order and the OS's instruction stream (a lockstep detector at milestone 1, as a5200-python used it), PORTB and PIA writes, which code runs from which ROM, frame counts and pictures to compare by eye or by hash. - It **cannot** judge cycle positions inside a line: on the 5200 it was found to place the VBI seven cycles early (a5200-python C15), and its ANTIC is a per-line renderer (a5200-python mame-oracle.md, kept there as HYPOTHESIS from a reading made before the closed-box rule). Expect the same driver here. - `totalcycles` includes ANTIC's stolen cycles (frame marks 29,868 apart). - Save states and the floating buses: unknown in this driver; not relied on.