# MAME as a detector (closed box, tier 5) MAME 0.285 (`/usr/games/mame`, reports "0.285 (unknown)"). Its PlayStation machines are `psj` (parent; the zip also holds `psu/`, `pse/`, `psa/` sub-folders), `psu`, `pse`, `psa`, source `sony/psx.cpp`. The CPU device is "Sony CXD8530AQ/CQ" at 67,737,600 Hz (pse uses AQ, the others CQ). **Closed box**: the source is never opened. Per-file licence lines were read (only the `// license:` line, through the GitHub API at tag `mame0285`, 2026-11-25): `src/devices/cpu/psx/{psx,gte,dma,mdec,rcnt,irq,sio}.cpp`, `src/devices/video/psx.cpp`, `src/devices/sound/spu.cpp`, `src/mame/sony/psxcd.cpp`, `src/devices/bus/psx/{ctlrport,memcard}.cpp` say **BSD-3-Clause**; the driver `src/mame/sony/psx.cpp` says **GPL-2.0+**. Headers without a licence line are GPL-2.0+ (sources.md). Whether the BSD files may ever be read is an Open decision; until Aubrey says otherwise they stay closed like the rest. ## The recipe (run 2026-11-25) ```sh export MAME_ROMPATH=";" # psj.zip, psx_cd.zip python -I scripts/mame_trace.py --machine psu --bios 2.2a --start 0 --frames 2 \ --out tests/mame_traces/boot.trace # WINDOW 0.033430 s # 566120 instructions traced to .../tests/mame_traces/boot.trace python -I scripts/mame_trace.py --start 0 --frames 120 --regs "" \ --exe reference/src/PeterLemon-PSX/CPUTest/CPU/MULT/CPUMULT.exe --out tests/mame_traces/mult.trace # WINDOW 2.005814 s # 33967249 instructions traced ``` What the script does: writes `tests/mame_traces/trace.lua` and runs ``` nice mame psu -bios 2.2a -rompath "$MAME_ROMPATH" -video none -sound none -nothrottle \ -noreadconfig -skip_gameinfo -debug -debugger none -autoboot_script trace.lua \ -seconds_to_run N [-quik program.exe] ``` in `tests/mame_traces/` (git-ignored; error.log, cfg/ land there). The Lua issues `trace ,maincpu,noloop,{tracelog "SR=%08X Cause=%08X ",SR,Cause}` at frame `start` (or before `go` for start 0) and `trace off` after `frames` frames, counting frames with `emu.add_machine_frame_notifier` (held in a global, or it is collected). First lines: ``` SR=00400000 Cause=00000000 BFC00000: lui t0,0x0013 ; 0x0013243f SR=00400000 Cause=00000000 BFC00004: ori t0,t0,0x243f SR=00400000 Cause=00000000 BFC00008: lui at,0x1f80 SR=00400000 Cause=00000000 BFC0000C: sw t0,0x1010(at) ; 0x1f801010 ``` The same opening as psx-spx's logic-analyser boot listing (memorycontrol.md), so the trace starts at reset with BEV=1 (SR=00400000h). Screenshots work with `-video none`: `manager.machine.video:snapshot()` from a frame notifier writes `snap/psu/0000.png` (`-snapshot_directory snap`). PeterLemon's `CPUMULT.exe`, quickloaded, shows every row PASS under MAME after 300 frames (looked at, 2026-11-25). That is MAME agreeing with krom's hardware-checked expectations, not a judge. ## MAME's state symbols for the psx CPU (from `cpu.state`, 2026-11-25) General registers by ABI name (`zero at v0 v1 a0-a3 t0-t9 s0-s7 k0 k1 gp sp fp ra`), `pc`, `hi`, `lo`, `CURPC`, `GENPC`; COP0 `SR Cause EPC BadA TAR PRId DCIC BPC BPCM BDA BDAM` and TLB leftovers `!Index !Random !EntryLo !EntryHi !Context`; the load delay `delayr delayv`; `biu` (the BCC register); the GTE's data and control registers (`vxy0 vz0 ... mac0-mac3 ir0-ir3 sxy0-2 sxyp sz0-sz3 rgb0-2 otz irgb orgb lzcs lzcr res1 r11r12 ... l33 trx try trz rbk gbk bbk lr1lr2 ... lb3 rfc gfc bfc ofx ofy h dqa dqb zsf3 zsf4 flag`). ## What MAME can and cannot decide - It **can** find differences: a register, a branch, an exception entry that the build does differently on the same BIOS or EXE. MAME's psx CPU emulates the load delay (`delayr`/`delayv` exist) and the GTE. - It **cannot** judge timing. **OBSERVED**: in two 60-frame windows of the BIOS intro (frames 300-360 and 900-960, 1.001 s each) MAME executed 16,951,337 and 16,951,336 instructions; the quickloaded EXE run gave 33,967,249 in 2.006 s. That is 1.998 CPU cycles per instruction, the same in every window: MAME charges a near-fixed cost per instruction, while the hardware's cost depends on the i-cache, the bus and load scheduling (cpu.md). MAME's timing is a model, not a measurement. - Rung use: instruction-by-instruction comparison of register writes over the BIOS boot and over test EXEs (rung 2), with the comparison stopping at the first timing-dependent divergence (an interrupt taken at a different instruction), as the other cores' MAME rungs do.