#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Write the synthetic case of a5200-python's tests/test_state.py (cf82d44) as files the two tracers load: the busy BIOS (``_busy_bios()``: display list DMA, a VBI NMI, POKEY timer and keyboard interrupts, two tones, pot scans with pot power toggled every other frame, the keypad, a trigger, a WSYNC every 32 passes), the 32K cartridge of zeros, and the display list and screen bytes ``_busy_console()`` writes into RAM ($1000, $2000). The bytes are taken from the reference's own test module (imported from the clone at ``external/a5200-python``), so the gate's synthetic case is exactly the reference test's. Run on the reference's interpreter (it holds pytest), from ``/``: PYPY_GC_NURSERY=1M /data/emu/a5200-python/.venv-pypy/bin/python scripts/busy_case.py Writes ``external/busy/{bios,cart,dlist,screen}.bin``; ``scripts/cases-midframe.tsv`` uses them (``$BUSY``, scripts/lockstep.py). """ from __future__ import annotations import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] REFERENCE = ROOT / "external" / "a5200-python" def main() -> int: sys.path[:0] = [str(REFERENCE / "src"), str(REFERENCE / "tests")] import test_state # noqa: E402 (the reference's tests/test_state.py) if not test_state.__file__.startswith(str(REFERENCE)): raise SystemExit(f"test_state came from {test_state.__file__}") out = ROOT / "external" / "busy" out.mkdir(parents=True, exist_ok=True) (out / "bios.bin").write_bytes(test_state._busy_bios()) (out / "cart.bin").write_bytes(bytes(0x8000)) ram = test_state._busy_console().board.ram (out / "dlist.bin").write_bytes(bytes(ram[0x1000 : 0x1000 + len(test_state._DLIST)])) (out / "screen.bin").write_bytes(bytes(ram[0x2000:0x2140])) print(f"wrote {out}") return 0 if __name__ == "__main__": raise SystemExit(main())