#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Milestone 7's judge: each #699 console's tables against the board running that console's row. ale-79's seven serial ROMs (Stella #699) printed object positions from six PAL and SECAM consoles (docs/validation.md). The board runs each ROM on the machine row of one console, with the TIA revision fields derived from these tables (machine.py), decodes the serial stream from its own SWCHA writes and compares every cell of that console's table: no cell is skipped where consoles disagree, so a row is right only if all of its console's cells are. One console per run; the runs are slow (about two minutes a ROM on PyPy), so run them niced, one at a time: nice -n 19 python scripts/serial_consoles.py PAL_L6 [--roms early_HMOVE,...] """ from __future__ import annotations import argparse import sys import time from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "src")) from a2600_python.gates import CONSOLES, SERIAL_ROMS, serial_tables # noqa: E402 from a2600_python.machine import CONSOLE_ROWS # noqa: E402 def main() -> int: parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) parser.add_argument("console", choices=CONSOLES) parser.add_argument("--roms", default=",".join(SERIAL_ROMS)) parser.add_argument("--root", type=Path, default=ROOT, help="where the references are") parser.add_argument("--misses", type=int, default=6, help="misses to list per ROM") args = parser.parse_args() machine = CONSOLE_ROWS[args.console] print(f"{args.console}: machine row {machine.name!r}, TIA {machine.tia_revision.name!r}") bad = 0 for rom in args.roms.split(","): began = time.monotonic() matched, total, misses = serial_tables(args.root, machine, args.console, roms=(rom,))[rom] bad += len(misses) print( f" {rom}: {matched:,} of {total:,} cells ({time.monotonic() - began:.0f} s)", flush=True, ) for r, c, mine, theirs in misses[: args.misses]: print(f" row {r} cell {c}: board {mine!r}, console {theirs!r}") return 1 if bad else 0 if __name__ == "__main__": sys.exit(main())