# SPDX-License-Identifier: MIT """The trace and beam watch on a synthetic BIOS.""" from __future__ import annotations import io import json from helpers import fake_board from a5200_python.debug import BeamWatch, trace_jsonl def test_trace_lines_carry_bus_events(): # STA $D40A (WSYNC) ; JMP $F800 board = fake_board(bytes((0x8D, 0x0A, 0xD4, 0x4C, 0x00, 0xF8))) out = io.StringIO() trace_jsonl(board, out, 4) lines = [json.loads(text) for text in out.getvalue().splitlines()] assert len(lines) == 4 kinds = {event[1] for line in lines for event in line["bus"]} assert {"R", "W"} <= kinds def test_beam_and_register_watch(): board = fake_board(bytes((0x8D, 0x18, 0xC0, 0x4C, 0x00, 0xF8))) # STA COLPF2 watch = BeamWatch(board) assert watch.run_to_beam(100, 50) assert board.antic.vcount == 100 watch.watch_register("gtia", 0x18) hit = watch.run_to_register_write() assert hit is not None and hit[:2] == ("gtia", 0x18)