# Sharing the graphics hardware with CPS-2 **The question** (open decision 1, shared with `cps2-python`): CPS-2 uses the same two graphics chips as CPS-1. How do the two boards share them without copying code? This page lays out what is shared, the three options, and a recommendation written so that the two Phase 0 briefs can be reconciled. When this was written (2026-11-12) `cps2-python` had only its status page (`docs/phase0-status.md`, read-only for this repository) and no recommendation of its own. ## What is actually shared | Part | CPS-1 | CPS-2 | Source | | --- | --- | --- | --- | | CPS-A-01 (DL-0311): scroll layers, SRAM, row scroll, stars, palette copy, bus requests | yes | yes, same die, **sprite ports unplugged**; `ROMA22-20` ignored, the address remapped by the DL-1927 | `[die: vram.md, graphics-rom-layout.md]` | | CPS-B: layer mixing, priority masks, palette paging, sync counters | DL-0411 variants or DL-0921 (keyed) | DL-0921 in **default mode** only (no battery) | `[die: security-scheme.md]` | | CPS-B-21 raster counters | Ganbare and Puchi Monster only | every game that uses raster effects (IPL2) | `[die]`, `[mame]` | | Objects (sprites) | CPS-A + frame buffer on the A-board ([cps-a.md](cps-a.md)) | a different engine (object RAM, DL-1525/DL-1827 side) injected into the mix | `[die: layer-assembly.md]`: "On the CPS2, the sprites are NOT handled by the B-21 at all"; how they enter the mix is "still unclear" | | Graphics ROM mapping | per-game B-board PAL ([gfx-mapping.md](gfx-mapping.md)) | fixed layout plus address mangling | `[die]` | | Palette word, brightness, palette RAM | same | same | `[die: wstlut.md]` | | QSound sound section (Z80 map, shared RAM, DSP device) | five games | every game | `[mame: qsound_sub_map "used by cps2.c too"]` | | Kabuki Z80 | the QSound games | **no** (CPS-2's Z80 is plain) | `[mame]` | | 93C46 EEPROM | QSound games (8-bit mode), Pang! 3 (16-bit) | every game | `[mame]` | So the shareable pieces are: **the CPS-A model, the CPS-B model (one model, data rows, of which CPS-2 uses one), the palette/brightness, the QSound device, the EEPROM**. Not shared: CPS-1's object engine and B-board mapper, CPS-2's object engine, decryption and mangling, both boards' memory maps and schedulers. ## The interface the shared video must have (whatever the option) For both boards to use one CPS-A/CPS-B model it must not assume either board: 1. **Bus master callbacks**: `read_word(address)` into the host's graphics RAM, and a way to tell the host "I hold the bus from clock *t* to *t'*" (the board turns that into 68000 stall time; on CPS-2 the host also arbitrates the Z80 RAM, [die: bus-requests.md]). 2. **A ROM fetch callback** `fetch(roma) -> 64-bit word or None` (None = no bank enabled = pen 15): CPS-1 implements it with the mapper PAL, CPS-2 with its mangling. 3. **An object pixel source**: on CPS-1 the frame buffer fed by the CPS-A's own object job; on CPS-2 the B-board engine. The mixer takes "the sprite pixel at (x, y)" from whichever source the board plugs in. 4. **A CPS-B configuration row** (offsets, enable selects, ID, key data) as plain data; CPS-2 passes the default row. 5. **Clocking**: stepped per line (or per pixel group) in master clocks by the host; raster and vblank outputs as lines the host wires to its IPL inputs. 6. No imports from either board's package. ## The options **A. `cps2-python` pins `cps1-python` and imports its video subpackage.** One implementation and no new repository; the family's add-on boards already pin their base board (sega32x-python pins megadrive-python). But CPS-2 is not an add-on to a CPS-1: it would pull a whole board (its 68000 and Z80 wiring, mapper, CPS-1 objects) as a dependency to use two chips, every CPS-1 change would move CPS-2's pin, and CPS-2's certification would hang on a board it does not contain. It is the lowest-effort start and the wrong long-term shape. **B. One `cps-python` repository with two machines.** One place for shared tests; the repository already exists for neither (both Phase 0 repos would merge). It breaks the family's "one board per repository" pattern for two machines that share chips but not boards (different CPU arrangements: CPS-2's 68000 runs encrypted code and sits on the B-board inside DL-1525, per the cps2 status page; different sprite engines, memory maps, security), and it makes every CPS-2 milestone a release of a CPS-1 board. **C. A shared chip package both boards pin** (`cps-video-python`, package `cpsvideo`: `CPSA`, `CPSB`, `CPSBConfig`, the palette): this is the chip rule as written. CPS-A and CPS-B are non-CPU chips with a second user in the family from day one. Its risk is designing the interface before either board runs a frame. ## Recommendation **C, staged.** Build the two chips inside `cps1-python` first, as a subpackage `cps1/video/` that obeys the interface above and imports nothing else from `cps1` (enforced by a test that imports it alone). CPS-1 exercises more of the chips than CPS-2 does (variants, keys, its own object path, stars), so it is the better place to get them right. **Trigger for extraction**: the day `cps2-python` starts its first video milestone, the subpackage moves to `cps-video-python` (history kept), `cps1-python` pins it, `cps2-python` pins it. Until then `cps2-python` does not import `cps1-python` at all (its early milestones, 68000 decryption, memory map, inputs, sound, do not need video). Reject B. Keep A only as the fallback if Aubrey prefers fewer repositories; if chosen, the import boundary above is the same, so moving to C later is mechanical. The same reasoning, already at its trigger, gives: - **QSound device** (DSP16A wiring, sample ROM, Z80 port): two consumers from day one, on top of `dsp16-python`: a small `qsound-python` (open decision 4, with the dsp16 Phase 0 which holds the question of where the device lives). - **93C46**: used by both boards (and by many other arcade boards): small; put it with the QSound device or in its own tiny package; not inside either board (open decision 3). - **Kabuki**: CPS-1 only here; second consumer = Mitchell. Stays in `cps1` (open decision 5). For reconciliation, the cps2 brief needs to say only: which option; that it expects a `CPSB` row in default mode, an object-pixel source of its own, a `fetch(roma)` callback with its mangling, and that it drives raster IPL2. If the cps2 agent recommends A, the difference from this page is only where the code sits until the trigger; the interface list stays the same.