#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """The 2-cell column vertical-scroll cartridges, for the pin-level fit. A cartridge built here: plane A (or B) red over its top 128 rows, green below; 2-cell column scroll; all 40 VSRAM words 0; on each line the 68000 waits (V & 63) ``dbra`` loops, sweeping across the line, then writes the plane's word for one column k as ``(V & 1) << 7``. Only that word ever changes, so the column's colour in the picture says which value each line used. The measurement is ``scripts/run_vscroll_pins.py`` (its column cases): the referee (Nuked-MD @ 594ca2a, a closed box, its RGB pins only) against the board, fitted on the picture alone (``VSCROLL_COLUMN_H``, OBSERVED, bounded). This script once also read the model's internal column latch, a VSRAM word and its V counter; those taps were removed from the harness in provenance wave 2 (2026-11-19), and that part with them. python scripts/run_vscroll_columns.py (runs run_vscroll_pins.py) """ from __future__ import annotations import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "src")) sys.path.insert(0, str(ROOT / "scripts")) from run_vscroll_latch import _w, nuked_md_cartridge # noqa: E402 CASES = [("A", True, 0), ("A", True, 10), ("A", True, 19), ("B", True, 0), ("B", True, 10), ("A", False, 0), ("A", False, 8), ("A", False, 15), ("B", False, 8)] # fmt: skip def cartridge(k: int, plane: str, h40: bool) -> bytes: code = bytearray() code += _w(0x46FC, 0x2700) code += bytes.fromhex("23fc5345474100a14000") code += _w(0x41F9, 0x00C0, 0x0000, 0x43F9, 0x00C0, 0x0004, 0x45F9, 0x00C0, 0x0008) for reg, value in ((0x00, 0x04), (0x01, 0x04), (0x02, 0x30 if plane == "A" else 0x38), (0x04, 0x07 if plane == "A" else 0x06), (0x05, 0x78), (0x07, 0x00), (0x0A, 0xFF), (0x0B, 0x04), (0x0C, 0x81 if h40 else 0x00), (0x0D, 0x3F), (0x0F, 0x02), (0x10, 0x01), (0x11, 0x00), (0x12, 0x00)): # fmt: skip code += _w(0x32BC, 0x8000 | reg << 8 | value) code += _w(0x22BC, 0xC000, 0x0000) code += _w(0x30BC, 0x0000, 0x30BC, 0x000E, 0x30BC, 0x00E0) code += _w(0x22BC, 0x4000, 0x0000, 0x303C, 0x7FFF) # clear VRAM code += _w(0x30BC, 0x0000, 0x51C8, 0xFFFA) code += _w(0x22BC, 0x4020, 0x0000) code += _w(0x303C, 0x000F, 0x30BC, 0x1111, 0x51C8, 0xFFFA) code += _w(0x303C, 0x000F, 0x30BC, 0x2222, 0x51C8, 0xFFFA) code += _w(0x22BC, 0x4000, 0x0003) code += _w(0x303C, 0x03FF, 0x30BC, 0x0001, 0x51C8, 0xFFFA) code += _w(0x303C, 0x03FF, 0x30BC, 0x0002, 0x51C8, 0xFFFA) code += _w(0x22BC, 0x4000, 0x0010, 0x303C, 0x0027) # VSRAM 0, 40 words code += _w(0x30BC, 0x0000, 0x51C8, 0xFFFA) code += _w(0x32BC, 0x8144) code += _w(0x7800, 0x7200) address = 4 * k + (0 if plane == "A" else 2) # the plane's word for column k loop = bytearray() loop += _w(0x1012, 0xB001, 0x67FA, 0x1200, 0x3400, 0x0242, 0x003F, 0x51CA, 0xFFFE) loop += _w(0x22BC, 0x4000 | address, 0x0010) loop += _w(0x1801, 0x0244, 0x0001, 0xEF4C, 0x3084) assert len(loop) == 34 loop += _w(0x60DC) return nuked_md_cartridge(bytes(code + loop)) def main() -> int: import run_vscroll_pins return run_vscroll_pins.main() if __name__ == "__main__": sys.exit(main())