"""Rung 5: whole-frame replays of game streams from two machines, MAME as the detector. Six ColecoVision and six SG-1000 logs (docs/mame-oracle.md; the four of rung 2 plus the ten recorded for this rung) and one PAL ColecoVision log, replayed with windows off and on. Skipped when the git-ignored traces are absent. Expected differences are the ones attributed in docs/results.md; a change in any count fails the test. """ from __future__ import annotations import sys from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[1] TRACES = ROOT / "tests" / "mame_traces" sys.path.insert(0, str(ROOT / "validation")) # run -> (status reads differing, snapshot pixels differing); docs/results.md attributes # each: C7 (Frogger 1,181), C10 (BurgerTime 6), MAME's number bookkeeping (the rest), and # DokiDoki's two pixels to a name written at line 189 dot 26, after MAME drew the line # and before the core fetched it. EXPECTED = { "coleco-Zaxxon-play": (0, 0), "coleco-DonkeyKong": (0, 0), "coleco-BurgerTime": (121, 0), "coleco-CosmicAvenger": (0, 0), "coleco-Frogger": (1198, 0), "coleco-Gyruss": (2, 0), "sg1000-Flicky": (1, 0), "sg1000-ChampionProWrestling": (0, 0), "sg1000-SegaGalaga": (0, 0), "sg1000-Zaxxon": (1, 0), "sg1000-DokiDoki": (1, 2), "sg1000-ElevatorAction": (1, 0), "colecop-Zaxxon": (0, 0), } LOST = {"sg1000-Flicky": 7} # windows on: Flicky's 21-clock bursts def _need(run: str) -> Path: path = TRACES / run if not (path / "error.log").exists(): pytest.skip(f"{run}: MAME trace not recorded (docs/mame-oracle.md)") return path @pytest.mark.parametrize("windows", [False, True], ids=["windows-off", "windows-on"]) @pytest.mark.parametrize("run", sorted(EXPECTED)) def test_replay(run, windows): import mame_replay r = mame_replay.replay(_need(run), windows=windows) assert r.vram_differ == 0 assert r.data_differ == [] assert (len(r.status_differ), r.frame_pixels_differ) == EXPECTED[run] assert r.lost_accesses == (LOST.get(run, 0) if windows else 0) if run == "sg1000-DokiDoki": assert [(y, x) for y, x, *_ in r.frame_differ_at] == [(189, 174), (189, 175)]