Metadata-Version: 2.5 Name: pcengine-python Version: 0.1.0.dev0 Summary: Readable, pure-Python PC Engine / TurboGrafx-16 board with documented sockets for add-ons Author: alewman License: MIT License Copyright (c) 2026 alewman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License-File: LICENSE Requires-Python: >=3.11 Requires-Dist: huc6280-python @ git+https://github.com/alewman/huc6280-python@9c47c98d4310d55935906607abef0f69607d0e7a Provides-Extra: dev Requires-Dist: numpy; extra == 'dev' Requires-Dist: pillow; extra == 'dev' Requires-Dist: pytest>=8; extra == 'dev' Requires-Dist: ruff==0.16.8; extra == 'dev' Description-Content-Type: text/markdown # pcengine-python Public at https://github.com/alewman/pcengine-python since 2026-11-05 (published by Claude Sonnet 5.5 for alewman; no ROMs, System Card or other BIOS are included, bring your own). A readable, pure-Python emulator of the **PC Engine / TurboGrafx-16**, to be built as a board on the family's cores: [huc6280-python](https://github.com/alewman/huc6280-python) for the HuC6280's instruction set (built in parallel; not read by this phase). The core owns the CPU; this repository will own everything around it: the 21-bit physical decode and the hardware page, the master clock and the VDC/VCE wait states, the timer, interrupt controller and I/O port, the **HuC6270 VDC**, the **HuC6260 VCE**, the six-channel wavetable **PSG**, the HuCard slot and its mappers, the pads, and **documented sockets** for add-on boards. **Status (2026-10-24): Phase 0 documents (2026-10-23) and the first half of Milestone 1.** The sockets, page table, timer, interrupt controller, I/O port and pads, VCE, a VDC skeleton (VRAM port, status/IRQ, frame layout, raster compare), the ROM card and the board's one-timeline clocking are built and tested (CPython and PyPy) and pinned to huc6280-python 143eb29; the Covell and MAME judges were run and **M1's exit does not hold yet**. See [docs/m1-record.md](docs/m1-record.md). 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 (8 milestones, 25 unknowns, 11 conflicts, 14 open decisions, all decided). **Milestone 2 (the background) holds**: the first ten titles are pixel-identical to Mesen2 and Beetle PCE at the 9-bit palette value wherever there are no sprites ([docs/m2-record.md](docs/m2-record.md)). **Milestone 3 (sprites) holds** too: ten plus eight titles are identical to Mesen2 and Beetle with sprites on ([docs/m3-record.md](docs/m3-record.md)). **Milestone 4 (the PSG)**: the model reproduces MAME and Mednafen step for step with each referee's switches on five games ([docs/m4-record.md](docs/m4-record.md)); tier 5 only. Measured while gathering: MAME 0.285, Mesen2 (famicom-python's headless build, after setting the config the DLL lacks), Beetle PCE (Mednafen's core, built from the pinned tree) and Geargrafx all run here headless; 35 library cards start on all three of the first; the CD boots the Super System Card screen on three of them; the only tier-1 (hardware-photographed) judge found is Chris Covell's CPU timing test. ## Shape: base board plus add-ons (the Sega console pattern) `pcengine-python` is the base board; **CD-ROM² / Super CD-ROM² / Arcade Card** (`pcenginecd-python`) and probably the **SuperGrafx** (`supergrafx-python`) are separate boards that pin it through sockets ([docs/sockets.md](docs/sockets.md)). `supergrafx-python` exists since 2026-11-05 (local; pins this board at 5d9dc86; see [docs/m6-status.md](docs/m6-status.md)); `pcenginecd-python` does not exist yet. | Machine | Phase | | --- | --- | | PC Engine, NTSC-J, HuCard: the reference | 1 (milestones M1-M5) | | TurboGrafx-16 (US): a machine-table row, region bit | 1 | | SuperGrafx: add-on (or a mode, open decision 6) | M6 | | CD-ROM², Super CD-ROM², Arcade Card: add-on | M7-M8 | | PC-FX (shares the VDC family; beyond the 1990 cutoff) | recorded as a possible later consumer only | ## What is fetched Nothing third-party is committed; ROMs, CD images and the System Card are bring-your-own. `scripts/fetch_references.py` rebuilds `reference/` and `tests/test_roms/` from `scripts/pinned_files.json` (12 files by SHA-256: MacDonald's `pcetech.txt` and `sgxtech.txt`, Covell's CPU test, eight PCEdev wiki pages) and `scripts/pinned_repos.json` (17 repositories at full commit SHAs, sparse where large: MAME 0.285's PC Engine sources, Mednafen via pce-devel, Beetle PCE, Geargrafx, ares, Mesen2, the TurboGrafx16 MiSTer core **with its `docs/`** (Hudson's manuals), pce-devel's research repos, HuC, the 240p Test Suite source, ...): ```sh python -I scripts/fetch_references.py # everything missing (~100 MB before building the cores) python -I scripts/fetch_references.py --verify # check what is present ``` It needs `git` and `curl`. The wiki pages are live: a changed page is reported and kept. ## Scripts | Script | What | | --- | --- | | `scripts/fetch_references.py` | the pinned references | | `scripts/count_carts.py` | the census: HuCards by MAME software list (CRC), CDs by hash then title | | `scripts/mame_trace.py` | MAME 0.285 per-instruction HuC6280 trace for `pce`, `tg16`, `sgx` ([docs/mame-oracle.md](docs/mame-oracle.md)) | | `scripts/mesen_run.py` | a card on Mesen2's `MesenCore.so` headless, frame to PNG (sets the PC Engine config the DLL lacks) | | `scripts/libretro_run.py` | a card or CD on a libretro core (Beetle PCE, Geargrafx) through a ctypes host | | `scripts/detectors_compare.py` | MAME, Mesen2 and Beetle PCE against each other on a card list | Scripts need Python >= 3.11, Pillow for pictures, and the system's `mame`, `7z` and (for CDs) `chdman`. Run any Python that reads `reference/` with `python -I`. ## Floors and rules Python **>= 3.11** (the newest PyPy supports); ruff `py311`. Modern over compatibility. Reference boards are correct, not fast. Never copy a chip file between repositories. ROMs, CHDs, BIOS: never committed. Local git only until a rung says otherwise.