# SPDX-License-Identifier: MIT """Milestone 2's picture gate: krom's PPU demos against his pictures. Tier 3: krom's pictures are emulator screenshots shipped with ROMs he ran on a console (his README). Compared at 5 bits per channel after 60 frames (``scripts/ppu_pictures.py``, which also compares with Mesen2 frames). The ROMs that do not match carry the reason; they are xfail, not hidden. """ from __future__ import annotations import sys from pathlib import Path import pytest from roms import ROOT sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts")) from ppu_pictures import compare, reference_for # noqa: E402 from snes_python.board import SNES # noqa: E402 from snes_python.cartridge import Cartridge # noqa: E402 pytestmark = pytest.mark.slow ROMS = sorted(p for p in (ROOT / "krom" / "PPU").rglob("*.sfc") if reference_for(p)) U9 = "first hi-res half-dot of each line: ares (followed) draws it black, krom's picture bright (U9)" ANIMATED = "animated demo: krom's picture is another frame; Mesen2 at frame 60 agrees exactly" NOT_YET = { "HiColor64PerTileRowPseudoHiRes": U9, "lenna64PerTileRowHiRes": U9, "mandrill64PerTileRowHiRes": U9, "RGB_24bits_palette_color_test_chart64PerTileRowHiRes": U9, "InterlaceRPG": U9, "InterlaceSimpsonsHDMA": U9, "RedSpace9BitHDMA": "brightness curve below 15 (U10): the board follows fullsnes (N+1)/16", "WaveHDMA": "animated; neither krom's picture nor Mesen2's frame 60 matches", "InterlaceMoogle": "frame-dependent; Mesen2 differs only in the first column (U9)", "InterlaceScroll": "animated; Mesen2 differs only in the first column (U9)", "MosaicMode5": "animated; Mesen2 differs only in the first column (U9)", "InterlaceFont": ANIMATED, "HiColor1241DLair": ANIMATED, "RotZoom": ANIMATED, "StarWars": ANIMATED, "MosaicMode3": ANIMATED, "WindowMultiHDMA": ANIMATED, } @pytest.mark.parametrize("rom", ROMS, ids=lambda p: p.stem) def test_krom_picture(rom: Path) -> None: if rom.stem in NOT_YET: pytest.xfail(NOT_YET[rom.stem]) snes = SNES(Cartridge(rom.read_bytes())) snes.run_frames(60) assert compare(snes.ppu.picture(), reference_for(rom)) == "exact"