# MAME 0.285 as a detector The binary is the machine's installed `mame` (`0.285 (unknown)`). Its CPU files (`src/devices/cpu/sm8500/sm8500.cpp`, `sm85ops.h`, `sm8500d.cpp`, Wilbert Pol) carry `license:BSD-3-Clause` (first lines read 2026-11-26 at tag `mame0285`); by sources.md's rules they would be "code OK (with notice)", but this Phase 0 keeps them closed as the brief asked (decision 2). Only the binary runs. ## What MAME says it runs (`mame -listxml gamecom`) CPU "Sharp SM8500" (tag `maincpu`) at 5,529,600 Hz: MAME's device for the SM8521 is named after the series. ROMs `internal.bin` (4 KB, region `maincpu`) and `external.bin` (256 KB, region `kernel`). Debugger state symbols (Lua `cpu.state`, 2026-11-26): `PC`, `PS`, `SP`, `SYS`, `RR0`, `RR2` ... `RR14`, plus `CURPC`, `GENPC`, `CURFLAGS`. There is no separate PS0/PS1: `PS` is the pair. ## The recipe (run) ```sh MAME_ROMPATH=... python -I scripts/mame_trace.py --seconds 2 --table tests/detectors/mame-gamecom-bios-opcodes-.txt MAME_ROMPATH=... python -I scripts/mame_trace.py --cart "$NO_INTRO_DIR/Tiger - Game.com/Centipede (USA).zip" --seconds 3 ``` runs, in a fresh `tests/mame_traces/gamecom-/` (git-ignored): ``` mame gamecom [-cart1 ] -rompath $MAME_ROMPATH -homepath -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -debug -debugger none -log -seconds_to_run N -autoboot_script trace.lua ``` with `trace cpu.trace,,noloop,{logerror "%X %X %X %X %d\n",pc,b@pc,ps,sp,totalcycles}`. ## Run 2026-11-26, the firmware alone (`tests/detectors/mame-gamecom-bios-2026-11-26.txt`) - 2 emulated seconds, 24 s wall time: **1,413,464 instructions, 11,114,564 cycles, 7.863 cycles per instruction** (0.71 M instructions per emulated second). - First lines: `1020 FF 0 0 0`, `1021 FF 0 0 2`, `1022 FF 0 0 4`, `1023 FE 0 0 6`: reset at 1020h (DS), NOPs (2 cycles each), then DI. - MAME counts 5.56 M cycles per emulated second **from reset**: it does not model the reset clock of fCK/32 or the switch at the first STOP (DS p. 19, cpu.md): **C5**. - 130 of 256 first opcode bytes executed; the per-opcode table of MAME's cycle deltas is `tests/detectors/mame-gamecom-bios-opcodes-2026-11-26.txt` (decode-and-timing.md quotes the rows that meet DS's one worked example). - With a cartridge in slot 1 the firmware stays in its menu: starting a cartridge needs the stylus on the "CARTRIDGE" icon, and pressing the A button through Lua did not start it (gamecom-python mame-oracle.md). So no cartridge code was traced in this Phase 0 (**U6**: the build needs a scripted stylus press, or a cartridge start by MAME's own input mapping). ## What MAME can and cannot decide - **Can detect:** decode (by its disassembler, as a closed-box measurement); differences in PC flow, registers and flags in lockstep; its own timing model's cycle counts. - **Cannot decide:** any cycle count as hardware fact; the reset clock and clock switching (it ignores them, C5); flags DS does not define; illegal encodings' behaviour.