# MAME 0.285 as a detector MAME is an emulator (tier 5): it finds differences, it does not decide them. The binary is the machine's installed `mame` (`0.285 (unknown)`). Its Gamate files' `license:` lines were read (the first 120 bytes of each, at tag `mame0285`, 2026-11-26) and nothing further: | File | `license:` | Copyright holders | | --- | --- | --- | | `src/mame/bitcorp/gamate.cpp` (the driver) | GPL-2.0+ | Peter Trauner | | `src/mame/bitcorp/gamate_v.cpp`, `gamate_v.h` (video) | BSD-3-Clause | David Haywood, Peter Wilhelmsen, Kevtris | | `src/devices/bus/gamate/slot.cpp`, `rom.cpp`, `gamate_protection.cpp` | BSD-3-Clause | David Haywood | All are treated as closed boxes (the Phase 0 brief); the BSD files could be read under their licence (sources.md's per-file rule), but KH, whom the video file credits, is the primary source and is read directly. PeT's technical reference that CC65 cites appears to survive only inside the GPL driver's comments: not opened. ## What MAME says it runs (`mame -listxml gamate`, 2026-11-26) `gamate`, "Gamate" (Bit Corp, 1990), source `bitcorp/gamate.cpp`: CPU "MOS Technology 6502" at 2,216,500 Hz; "AY-3-8910A PSG" at 1,108,250 Hz; LCD 160 x 150 at 60.809300 Hz; BIOS sets `default` (`gamate_bios_umc.bin`) and `newer` (`gamate_bios_bit.bin`); cartridge slot devices plain, banked, 4-in-1 and a "Gamate Protection Mapper"; software list `gamate`. ## The recipe (run) ```sh MAME_ROMPATH=... flock taskset -c 24-31 nice \ python -I scripts/mame_trace.py --cart "$NO_INTRO_DIR/Bit Corporation - Gamate/Insect War (World).zip" --seconds 3 ``` runs, in a fresh `tests/mame_traces/-/` (git-ignored): ``` mame gamate -bios -cart -homepath -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -debug -debugger none -log -seconds_to_run N -autoboot_script trace.lua ``` `trace.lua` installs Lua write taps on 4000-5FFF (`IOW address data`) and 6000-DFFF (`CW address data`) and issues `trace cpu.trace,,noloop,{logerror "%X %X %X %X %X %X %X %d\n",pc,b@pc,a,x,y,sp,p,totalcycles}`. A 3-second run takes about 50 s wall time and ~21 MB of logs. ## Runs 2026-11-26 (`tests/detectors/mame-gamate-2026-11-26.txt`) | BIOS | Cart | Seconds | Instructions | Cycles | Cycles/instr | Outside the 151 NMOS opcodes | | --- | --- | ---: | ---: | ---: | ---: | --- | | default (UMC) | Insect War (banked, 512 KB) | 3 | 2,489,567 | 6,670,343 | 2.679 | none | | newer (Bit) | Witty Apee (plain, 32 KB) | 6 | 4,965,591 | 13,304,245 | 2.679 | none | Both start at `FC0D` after reset (`FC0D 78 ...`: `SEI`). Writes seen: 6000 x135 (the handshake, exactly KH's count) on both; 5900 x3 on both; LCD 5001, 5002, 5003, 5004/5005 (in pairs), 5007 (13,152 and 20,624 times); **no sound writes and no bank writes** in these windows. 13,304,245 cycles in 6 s = 2.217 M/s, MAME's clock. The games sit mostly in an `LDA zp / CMP / BCC` loop waiting on the IRQ counter (top opcodes A5, C9, 90). ## What MAME can and cannot decide - **Can detect:** a board that runs the BIOS or a game differently (PC paths, register writes, pictures); which opcodes software uses (cpu.md); the handshake's write count; the bank writes of each game (the `CW` tap), which is how U16 and U18 should be read off. - **Cannot decide:** NMOS vs CMOS bus shapes (it models an NMOS 6502, C1), VRAM contention, the greys, the AY's phase, the left/right question (C5), anything KH did not measure. - One process at a time (a shared `flock`), short runs: the family's rule.