# SPDX-License-Identifier: MIT """Rung 4: MAME 0.285 replays in lockstep (emulator tier: a value detector; replay.py). Each run is ``scripts/mame_gsu_trace.py CART --start-frame F --frames 2 (or 6) --ram --all-banks --arm-on-start --out tests/mame_traces/`` (BYOR, gitignored). The MAME-switched core must match every G/H pair and host read (0 findings); every default-core divergence must be explained by one contested switch. """ from __future__ import annotations import pytest from conftest import TRACES, require from gsu_python.model import GSU1, GSU2, MC1 from gsu_python.replay import replay RUNS = { "StarFox_replay": MC1, "StuntRaceFX_replay": GSU1, "Vortex_replay": GSU1, "Doom_replay": GSU2, "Yoshi_replay": GSU2, "WinterGold_replay": GSU2, } @pytest.mark.slow @pytest.mark.parametrize("run", sorted(RUNS)) def test_replay(run): folder = require(TRACES / run) ram = require(folder / "ram_at_start.bin").read_bytes() rom_path = next(p for p in sorted(folder.glob("*.sfc")) if not p.name.startswith("mirrored-")) result = replay(folder / "gsu.log.gz", rom_path.read_bytes(), ram, model=RUNS[run]) print(run, result.summary(), sep="\n") assert result.instructions > 50_000 assert not result.findings, result.summary() assert not result.unexplained, result.summary()