# cps1-python A readable, pure-Python emulator of the **Capcom CP System (CPS-1)** arcade board, to be built as a board on the family's cores: [m68000-python](../m68000-python) (68000 at 10 or 12 MHz), [z80-python](../z80-python) (sound CPU), and three sibling cores whose Phase 0 runs in parallel with this one: `ym2151-python` (FM), `msm6295-python` (ADPCM) and `dsp16-python` (the QSound DSP). This repository will own everything around them: the A-board (bus decode, the CPS-A-01 graphics chip, object frame buffer, palette), the B-board as **data** (program and graphics ROM layout, the PAL that maps tile codes to ROM banks), the C-board's CPS-B-xx chip in all its variants, the sound boards (standard and QSound, with the Kabuki-encrypted Z80), inputs and the EEPROM. **Status (2026-11-12): Phase 0 complete, groundwork only, no emulator code.** The documents in [`docs/`](docs/README.md) hold what the build needs, every fact with its source and tier; [docs/handoff-brief.md](docs/handoff-brief.md) is the plan. What Phase 0 found, in short: - **A hardware-tier source exists for the two custom chips.** Loïc Petit traced the CPS-A-01 (DL-0311) and CPS-B-21 (DL-0921) gate by gate from die photographs and published the schematics and prose documentation (CC-BY 4.0). It settles questions MAME's source marks as unknown: the three "unknown" CPS-B-21 registers, what bit 0 of the palette base does, the 256-tiles-per-frame object limit, the bus requests the graphics chip makes on every scanline. It is a hand trace and a set of documents, **not a runnable simulation**; nobody has simulated it here. - **The B-board PALs are in the ROM sets, and they run.** 166 of 168 Capcom sets carry the fuse map of their graphics-mapper PAL. Decoded here, the A-board PALs give exactly MAME's quoted equations, and ten B-board mapper PALs, wired as Capcom's 89624B-3 schematic shows, reproduce MAME's tile ranges boundary for boundary ([docs/gfx-mapping.md](docs/gfx-mapping.md)). - **Capcom's own schematics** for the A-board (two revisions) and a B-board are public as scans. - **MAME runs the 68000 faster than the board does**: the A-board's PRG1 PAL inserts a wait state on ROM and RAM cycles and the CPS-A-01 takes the bus on every scanline; MAME models neither. - **No homebrew conformance suite exists.** The closest things are a diagnostic ROM (MAD) and the games' own service-mode tests. ## Scope One board, every game's configuration as a row of data. The CPS-1 family as MAME 0.285 lists it: **37 Capcom parent sets (164 sets with clones) and the CPS Changer's 2 parents (4 sets)**; 5 of the parents are the "CPS-1.5" QSound games. Bootlegs (102 sets) and the Mitchell boards are out of scope. The CPS Changer is a machine row. CPS-2 is a separate repository that reuses this one's graphics chips: see [docs/cps2-sharing.md](docs/cps2-sharing.md). ## What is fetched Nothing third-party is committed; ROM sets are bring-your-own and read in place. `scripts/fetch_references.py` rebuilds `reference/` from `scripts/pinned_repos.json` (11 repositories at full commit hashes, sparse where large): ```sh python -I scripts/fetch_references.py # everything missing (~180 MB) python -I scripts/fetch_references.py --verify # check what is present ``` It needs `git` and `curl`. ## Scripts | Script | What | | --- | --- | | `scripts/fetch_references.py` | the pinned references | | `scripts/census.py` | every CPS-1 set from `mame -listxml` against the local ROM trees (no emulator runs a game) | | `scripts/mame_trace.py` | MAME 0.285 headless: per-instruction 68000 or Z80 trace plus register and latch accesses ([docs/mame-oracle.md](docs/mame-oracle.md)) | | `scripts/decode_cpsb21_keys.py` | decodes the CPS-B-21 battery keys with the die's bit layout and compares them with MAME's table | | `scripts/mapper_table.py` | prints MAME's graphics-mapper tables and per-set extra ports from the pinned source | | `scripts/decode_gal16v8.py` | prints the equations of a GAL16V8 fuse map from a ROM set | | `scripts/check_pal_mapper.py` | evaluates a B-board mapper PAL with a board's pin wiring and prints its tile ranges | Scripts need Python >= 3.11 and the system's `mame`. Run any Python that reads `reference/` with `python -I`. ## Floors and rules Python **>= 3.11** (the newest PyPy supports); PyPy must work. Modern over compatibility. Reference boards are correct, not fast. Never copy code between repositories. ROMs are never committed. Local git only until a milestone says otherwise.