# Handoff: build `vectrex-python`, the GCE / Milton Bradley Vectrex board ## Context you are inheriting The family's shape is **chips are cores, boards compose cores; never copy a chip file between repositories; extract on the second consumer**. Each core is certified on its own and pinned by commit; each board is validated against the highest-tier sources that exist, with MAME and other emulators as detectors only. Boards to model this one on: `a2600-python` (a board whose picture is made by the program cycle by cycle, with a chip held in-board), `pcengine-python` (sockets, Phase 0 shape), `sms-python` and `famicom-python` (pinning a CPU core and a sound core). The Vectrex is unusual in two ways that shape everything: 1. **One VIA drives the whole machine.** A 6522 is the only I/O device on the bus; its timer 1 times every vector (PB7 = RAMP), its shift register draws every dashed line and character (CB2 = BLANK), its port A is both the DAC and the PSG's bus. The board is only as correct as its VIA at cycle resolution, and the CPU must show the VIA every bus access on its true cycle. 2. **The picture is not pixels.** A DAC, a multiplexer, three sample-and-holds and two analog integrators steer a vector CRT. The board's video output is **timed beam segments**; the analog stage is a **model with named parameters**, because no source in hand measures it ([analog.md](analog.md)). Read, in order: 1. [README.md](../README.md), then [start-here.md](start-here.md): the machine in one page, who drives what, the proposed module shape. 2. [memory-map.md](memory-map.md): decode, vectors, RAM, the cartridge header and boot check. 3. [via.md](via.md): how the Vectrex programs the 6522, what it depends on to the cycle, in-board versus own repository, its oracles. 4. [analog.md](analog.md): the circuit, five emulators' delay sets, the model, **the output contract and the comparison layers L0-L5**. 5. [executive.md](executive.md), [sound.md](sound.md), [controllers.md](controllers.md), [cartridge.md](cartridge.md). 6. [validation.md](validation.md): every oracle with tier, licence, pin; the ladder V0-V8. 7. [mame-oracle.md](mame-oracle.md): the verified MAME recipe and its traps. Then `python3 -I scripts/fetch_references.py --verify` (45 files by SHA-256, 11 repositories by commit; about 90 MB in the git-ignored `reference/`). ## Decided - **`m6809-python` is approved and is a prerequisite** (Aubrey, 2026-11-11, via the coordinator). It does not exist yet beyond its Phase 0 documents (`/data/emu/m6809-python`, HEAD `ee74b14`); this board starts when it reaches the rungs below. - `ay8910-python` (built, `5abe2df`) is the PSG: `PSG(AY8912)`. - Python floor 3.11 (PyPy must work), ruff `py311`; modern forms; reference boards are correct, not fast; keep every hot object under 80 attributes (PyPy). - Bring-your-own ROMs: no system ROM, cartridge or homebrew image is committed or fetched. - No hardware: anything only a console could settle is recorded as undecidable and modelled with a named parameter. ## Scope In: the 68A09 (via `m6809-python`), the 6522 VIA, 1K RAM and decode, the 8K system ROM (B796 default, 7931 supported, 7ADB if supplied), the DAC / multiplexer / sample-and-holds / integrators as a parameterised model emitting beam segments, the AY-3-8912 (via `ay8910-python`) plus the DAC voice, two controller ports with analog joysticks and buttons, the light pen, the 3D Imager, the cartridge port (plain ROM, AnimAction RAM, PB6 banking, /NMI, /IRQ, /HALT lines). Optional and outside the board's imports: a rasteriser, a host-side audio mixer. Out (open decisions 7-8): modern cartridge hardware (VecFever, Vectrex32, flash and EEPROM carts, VecVoice), the RA+A Spectrum I+ arcade variant (`raaspec`), the monitor board beyond the segment contract, overlays (artwork, a rasteriser concern). ## Proposed names | Thing | Name | | --- | --- | | repository | `vectrex-python` | | package | `vectrex_python` (the family's `_python` pattern; open decision 1) | | board | `Vectrex` in `machine.py`; a machine table row per ROM revision | | VIA | `VIA6522` in `via.py` (no Vectrex names inside; open decision 2) | | analog model | `AnalogStage` in `analog.py`, `AnalogParameters` (frozen dataclass) with presets `MAME`, `VIDE`, `VECTREXY`, `IDEAL`, `SCHEMATIC` | | video output | `Segment` in `beam.py` ([analog.md](analog.md) §5) | | cartridge | `CartridgeSocket` protocol; `RomCartridge`, `RamCartridge` (AnimAction), `BankedCartridge` (PB6) in `cartridge.py` | | controllers | `ControllerPort` protocol; `Joystick`, `LightPen`, `Imager` in `controllers.py` | | rasteriser | `raster.py`, imported by hosts and tests only | ## The import boundary | Owned by | What | | --- | --- | | `m6809-python` (pinned) | the instruction set, cycle counts, every bus cycle in order (including dummy cycles), interrupt entry, CWAI/SYNC | | `ay8910-python` (pinned) | the PSG's registers, tone/noise/envelope, port A, its DAC levels | | this board | the E clock and the order of stepping; decode, RAM, ROM, open bus; the VIA; the analog model; the DAC voice; ports and sockets; segment and audio output | | the host | the frame (where to cut the segment stream), pictures, audio mixing to a sample rate, input devices | The board owns the clock. Per E cycle, in this order: the CPU's bus cycle (an access, or a dummy or internal cycle) is presented to decode; the VIA advances one cycle (timers, shift register, pins); the PSG `tick()`s; the analog stage advances one cycle from the VIA's pins of that cycle. ## Sockets | Socket | Lines | Notes | | --- | --- | --- | | cartridge | read/write `$0000-$BFFF` with the cycle, PB6 out, /NMI, /IRQ (wired-OR with the VIA's IRQB), /HALT in | [cartridge.md](cartridge.md). /HALT can be accepted and ignored until something uses it | | controller port 1 (right) | SW0-SW3 (SW3 is also /FIRQ), POT0, POT1 | [controllers.md](controllers.md) | | controller port 2 (left) | SW4-SW7 (SW7 is also CA1), POT2, POT3 | the light pen and 3D Imager plug in here | | video out | `Segment` list | drained by the host | | audio out | per E cycle: PSG `levels()`, DAC-voice code or `None` | mixed by the host | The gate for any socket device added later: with nothing plugged in, the V1 lockstep and every recorded stream are byte-identical to the tagged base. ## What the board needs from m6809-python The core's brief (`/data/emu/m6809-python/docs/handoff-brief.md`, read 2026-11-12) defines seven rungs. The Vectrex needs: - **Rung 1** (the documented set, cycle counts, interrupt entries 19/10/19 with their stacked frames) and **rung 2** (the `neetandev/m6809` vectors including **bus order**: every cycle's address and data, dummy reads at `$FFFF` and of the instruction stream) **before board milestone M2.** Rung 2 is what proves that `CLR