# MAME 0.285 as a GBA detector MAME's `gba` driver (`src/mame/nintendo/gba.cpp`, `gba_lcd.cpp`; sources pinned sparse at `reference/src/mame`) is the weakest detector here: it is far behind NanoBoyAdvance and mGBA on every hardware test run ([validation.md](validation.md), C10 in [undocumented-behavior.md](undocumented-behavior.md)). It is kept for two reasons: it is installed already (`/usr/games/mame`, 0.285), and its debugger can trace and watch what the other detectors cannot be scripted to. Use it to find gross faults, never to decide a cycle. ## The recipe (verified 2026-10-21) ```sh python scripts/mame_run.py --bios "" ROM.gba [ROM.gba ...] [--frames 600] ``` What the script does, so it can be reproduced by hand: 1. `mame -listroms gba` wants `gba.bin`, 16,384 bytes, CRC `81977335`, SHA-1 `300c20df6731a33952ded8c436f7f186d25d3492` (the retail BIOS). The script copies your dump to `/gba/gba.bin` and passes `-rompath `. Nothing lands in the repository. 2. It runs, in `tests/mame_runs//` (ignored by git): `mame gba -cart ROM.gba -rompath -homepath . -snapshot_directory snap -video none -sound none -nothrottle -skip_gameinfo -autoboot_script run.lua`. 3. `run.lua` counts frames with `emu.add_machine_frame_notifier` (kept in a global: a collected subscription stops firing), and at the chosen frame writes PC, CPSR and R12 to `result.txt`, saves a snapshot (`snap/gba/0000.png`; `-video none` still snapshots) and calls `manager.machine:exit()`. About 26× real time on this machine. ## What it showed - **The free BIOS does not boot**: with Cult-of-GBA's `bios.bin` as `gba.bin`, MAME warns about the checksum and then stays on the Cult-of-GBA splash screen (PC `0C04`) for good. Retail BIOS only. - **Read the screen, not R12.** At a frame boundary MAME's CPU is usually in the BIOS's IRQ handler (PC `0188` or `00DC`), where R12 is the BIOS's value, not the test's. jsmolka's ROMs print "All tests passed" or "Failed test N". - State symbols (Lua `cpu.state`): `R0`–`R15`, `PC`, `CPSR`, `CURPC`, `GENPC`, banked `FR8`–`FR14`, `IR13`, `IR14`, `SR13`, `SR14`, `AR13`, `AR14`, `UR13`, `UR14`, `*R16` (the SPSRs), `CURFLAGS`, `LOGTLB`. - Results: [validation.md](validation.md) "MAME 0.285". ## Tracing The same pattern as gameboy-python's `mame_trace.py` works: add `-debug -debugger none` and in the Lua script `manager.machine.debugger:command('trace cpu.trace,,noloop,{...}')` plus `wpset` watchpoints on I/O. Not scripted here yet; write it when a trace is needed.