# SPDX-License-Identifier: MIT """Milestone 7: the PAL and SECAM rows, and the TIA revision fields from ale-79's #699 tables. The judge is scripts/serial_consoles.py (every cell of every console's tables, one console per run, minutes per ROM): the slow tests here run one ROM per field; the quick ones check the rows themselves. """ from __future__ import annotations from pathlib import Path import pytest from a2600_python.gates import compare_table, serial_tables from a2600_python.machine import ( CONSOLE_ROWS, HOSTED_MACHINES, MACHINES, REFERENCE_TIA, TIA_REVISIONS, VCS_NTSC, VCS_PAL, VCS_SECAM, ) from a2600_python.tia import TIA ROOT = Path(__file__).resolve().parents[1] def test_the_reference_rows_use_the_die_s_chip(): for machine in (VCS_NTSC, VCS_PAL, VCS_SECAM): assert machine.tia_revision is REFERENCE_TIA assert REFERENCE_TIA.merge_steps == 0x1F and REFERENCE_TIA.strobe_drops == 0 assert TIA().revision is REFERENCE_TIA def test_pal_and_secam_run_on_their_own_clocks(): assert VCS_PAL.timing.colour_clock_hz == 3_546_894.0 assert round(VCS_PAL.timing.cpu_hz) == 1_182_298 # nocash assert VCS_SECAM.timing is not VCS_PAL.timing assert round(VCS_NTSC.timing.cpu_hz) == 1_193_182 def test_a_secam_console_has_no_colour_switch(): assert not VCS_SECAM.switches & 0x08 assert VCS_PAL.switches & 0x08 and VCS_NTSC.switches & 0x08 def test_seven_eight_hundred_rows_stay_out_of_the_2600_listing(): assert not set(HOSTED_MACHINES) & set(MACHINES) assert all("7800" not in name for name in MACHINES) assert all(not m.tia_clocks_cpu for m in HOSTED_MACHINES.values()) assert all(m.tia_clocks_cpu for m in MACHINES.values()) def test_every_console_row_names_a_revision_from_the_tables(): assert set(CONSOLE_ROWS) == { "PAL_7800", "PAL_JR_84", "PAL_JR_91", "PAL_L6", "PAL_VADER", "SECAM_WOODY", } # fmt: skip for row in CONSOLE_ROWS.values(): assert row.tia_revision in TIA_REVISIONS.values() assert row.tia_revision.source.startswith(("TEST ROM", "DIE")) def test_the_serial_judge_counts_every_cell_and_finds_a_wrong_one(): table = " HMP0 values\n01 8 7\n02 8 6\n" assert compare_table(table, table)[:2] == (8, 8) matched, total, misses = compare_table(table.replace("8 6", "8 5"), table) assert (matched, total) == (7, 8) and misses == [(2, 2, "5", "6")] def needs_references(): if not (ROOT / "reference/hardware/stella-issues/699-results.zip").exists(): pytest.skip("references not fetched: python scripts/fetch_references.py") @pytest.mark.slow @pytest.mark.parametrize( ("console", "rom"), [ ("PAL_7800", "early_HMOVE"), # merge_steps ("PAL_L6", "HMOVE_RESPx_P0"), # strobe_drops, players ("PAL_VADER", "HMOVE_RESPx_M1"), # strobe_drops, missiles ("SECAM_WOODY", "HMOVE_RESPx_M1"), # the reference ], ) def test_a_console_row_matches_every_cell_of_its_table(console, rom): needs_references() matched, total, misses = serial_tables(ROOT, CONSOLE_ROWS[console], console, roms=(rom,))[rom] assert not misses and matched == total, misses[:5]