# colecovision-python A readable, pure-Python emulator of the **ColecoVision** (Coleco, 1982): a board on the family's cores, [z80-python](../z80-python) for the Z80A (with its M1-cycle hook), [tms9918-python](../tms9918-python) for the TMS9928A/TMS9929A, and [sn76489-python](../sn76489-python) for the SN76489A (its `SN76489AN` row). The board owns everything around them: memory and I/O decode with mirrors, the 8K BIOS and 1K RAM, the one-clock wait on every M1 cycle, the sound chip's READY wait, the VDP's interrupt as an NMI edge, the controller ports with keypad and spinner circuit, the cartridge slot and its boards, and sockets for the expansion port. **Status (2026-11-12): M1-M7 met (M5 less the Super Controller Tester); M8 not started.** Every number is in [docs/results.md](docs/results.md); provisional behaviours and their switches in [docs/claims.md](docs/claims.md); the story in [docs/worklog.md](docs/worklog.md); core gaps in [docs/core-issues/](docs/core-issues/). | Milestone | Result | | --- | --- | | M1 CPU, bus, BIOS | MAME's 2 s BIOS trace in lockstep: 945,993 instructions, 17,821 port writes, 1 read, 0 differences | | M2 VDP background | BIOS, Zaxxon and Final Test screens equal to MAME and Gearcoleco by colour index (0 pixels); Final Test prints ROM CHECKSUM D483, ROM GOOD, RAM GOOD | | M3 sprites and status | 12-title smoke list at gameplay: 44 of 48 pictures equal to MAME (MAME's switches); all port-access replays end at a sprite-status read (core issue 0003) | | M4 sound | SN76489AN wired at `$FF` with the READY wait, mixer, WAV; 6 games' sound streams equal to MAME's for 12.8-17.1 s of game sound each; Final Test sound rendered and compared with MAME's recording (envelope correlation 0.997); periods 0/1 audible in 8 titles | | M5 controllers | BIOS DECODER and UPDATE_SPINNER, Final Test controller screen, Turbo and Slither respond; Super Controller Tester not done | | M6 cartridge boards | MegaCart, Activision + 24C02/24C256 on synthetic images (clean-room rewrite 2026-11-26; X-in-1 removed) | | M7 sweep, PAL, long replays | 584 of 600 sweep pictures equal to MAME, all 16 others triaged; PAL BIOS lockstep 0 differences, 23 of 24 Europe-only pictures equal; 6 games' port replays 0 differences over 20.1-26.2 M CPU steps | | M8 Super Game Module | not started: an add-on, no image in the library | ```sh python -m venv .venv && .venv/bin/pip install ../z80-python-m1-hook ../tms9918-python && .venv/bin/pip install -e '.[dev]' pypy3.11 -m venv .venv-pypy && .venv-pypy/bin/pip install -U pip ../z80-python-m1-hook ../tms9918-python && .venv-pypy/bin/pip install -e '.[dev]' .venv/bin/python -m colecovision_python "Zaxxon (USA, Europe).zip" --frames 300 --png out.png .venv/bin/pytest # unit tests, and the M1 lockstep if the MAME trace is present .venv/bin/pytest -m slow # the detector picture comparisons ``` The package imports as `colecovision_python`. Two cores come from sibling checkouts (no remote holds their commits; install them first, as above): z80-python `f97c0f5` (branch `m1-fetch-hook-rebased`), tms9918-python `df9d8ae`, sn76489-python `c0d88a6` (`main`, the restart written from documents). Add `--wav out.wav` to the command line for the sound. Speed (reference board, correct first): about 0.3-0.5 x real time on CPython and 0.6-2.9 x on PyPy (`PYPY_GC_NURSERY=1M`), by title. BIOS and cartridges are bring-your-own, read in place: the BIOS by SHA-1 from the local MAME sets (or `$COLECO_BIOS`), cartridges from raw, zip or 7z files. Nothing third-party is committed. | Machine | State | | --- | --- | | ColecoVision NTSC (TMS9928A, 262 lines): the reference | M1-M6 | | ColecoVision PAL (TMS9929A, 313 lines, its own BIOS): a machine-table row | BIOS lockstep and 8 Europe-only images (M7) | | Super Game Module (AY-3-8910 + RAM): expansion socket, a later add-on | sockets and fakes only | | Expansion Module 1, the ADAM, clones | out of scope | ## Scripts | Script | What | | --- | --- | | `scripts/fetch_references.py` | the pinned references (Phase 0) | | `scripts/count_carts.py` | the library census (Phase 0) | | `scripts/mame_trace.py` | MAME per-instruction trace and I/O log ([docs/mame-oracle.md](docs/mame-oracle.md)) | | `scripts/lockstep_mame.py` | replay a MAME instruction trace against the board | | `scripts/mame_io.py`, `scripts/replay_io.py` | MAME port-access log with scripted inputs; its replay against the board | | `scripts/mame_frames.py`, `scripts/libretro_run.py` | detector pictures at chosen frames with scripted inputs (MAME, Gearcoleco) | | `scripts/smoke_pictures.py` | a smoke list against both detectors by colour index (`--io` adds the port replay) | | `scripts/compare_pictures.py` | one run against detector pictures | | `scripts/sound_streams.py`, `scripts/psg_sweep.py`, `scripts/psg_streams.py` | sound-write streams; the library's periods 0 and 1 | | `scripts/final_test.py`, `scripts/spinner_games.py` | Coleco's Final Test Cartridge; Turbo and Slither under spinner input | The Python floor is 3.11 (the newest PyPy supports); PyPy must work. Licence: MIT.