#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Generate an active-H40 FIFO probe cartridge. python scripts/run_fifo_release.py probe.bin --target vsram The probe keeps display enabled, autoincrement zero and the destination fixed, and writes the data port back to back, so the FIFO fills and each write's /AS length (a pin) shows when the VDP let the CPU reuse an entry. This script once also replayed a referee run's write arrivals on the board, from a line origin and an empty FIFO read off the model's internal H counter and FIFO pointers; those taps were removed from the harness in provenance wave 2 (2026-11-19), and the checker with them. A pin-only replay (the line origin from the /HSYNC pin, ``nuked_md.SIG_HSYNC``; the FIFO known empty from the program) is owed: until then ``vdp.FIFO_CPU_RELEASE_MCLK`` and ``FIFO_CPU_RELEASE_SLOW_MCLK`` rest on that withdrawn measurement and are provisional. """ from __future__ import annotations import argparse from pathlib import Path from run_vscroll_latch import _w, nuked_md_cartridge TARGETS = {"vram": (1, 0x4000, 0), "cram": (3, 0xC000, 0), "vsram": (5, 0x4000, 0x10)} def cartridge(target: str) -> bytes: if target not in TARGETS: raise ValueError(f"unknown FIFO destination: {target}") code = bytearray(_w(0x46FC, 0x2700)) code += bytes.fromhex("23fc5345474100a14000") code += _w(0x41F9, 0x00C0, 0, 0x43F9, 0x00C0, 4, 0x45F9, 0x00C0, 8) for word in (0x8004, 0x8144, 0x8C81, 0x8F00): code += _w(0x32BC, word) code += _w(0x22BC, *TARGETS[target][1:], 0x323C, 0x1234) loop = _w(0x3081, 0x3412) * 32 code += loop + _w(0x6000, (-len(loop) - 2) & 0xFFFF) return nuked_md_cartridge(bytes(code)) def main() -> None: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("path", type=Path) parser.add_argument("--target", choices=TARGETS, required=True) args = parser.parse_args() args.path.write_bytes(cartridge(args.target)) if __name__ == "__main__": main()