Metadata-Version: 2.5 Name: hg51b-python Version: 0.1.0.dev0 Summary: Readable, pure-Python Hitachi HG51B169 core (the SNES Cx4 of Mega Man X2/X3), instruction-exact 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 Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: System :: Emulators Requires-Python: >=3.11 Provides-Extra: dev Requires-Dist: pytest>=8; extra == 'dev' Requires-Dist: ruff==0.16.8; extra == 'dev' Description-Content-Type: text/markdown # hg51b-python A readable, pure-Python **Hitachi HG51B169** core, instruction-exact: the SNES **Capcom Cx4** in *Mega Man X2* and *Mega Man X3* (*Rockman X2/X3*). A 24-bit CPU with 16-bit instructions that fetches its program from the cartridge ROM into a two-page cache, with a 24 x 24 multiplier, sixteen 24-bit registers, 3 KiB of data RAM, a 3 KiB data ROM of math tables, a DMA engine and its own ROM bus. Its first user is the board `snes-python` (milestone 7: "Cx4 self-test PASS"). **Status (2026-11-06): Phase 0 only** (documents, oracles, survey and trace scripts, the handoff brief). No core code yet. Local git only. **There is no manufacturer document, hardware capture, test ROM with console results or die model for this chip.** The judges are the games' own built-in Cx4 test (hold controller 2 B at power-on), a real chip's data ROM dump (reproduced exactly by formula), research (fullsnes) and emulator-tier detectors (Mesen2 runs here and traces the Cx4; bsnes/ares and MiSTer are read; MAME is HLE only). [docs/validation.md](docs/validation.md) ranks them. ## What is fetched Nothing third-party is committed. `scripts/fetch_references.py` fills `reference/` from `scripts/pinned_files.json` (fullsnes) and `scripts/pinned_repos.json` (bsnes, ares, MAME 0.285, Mesen2, snes9x, MiSTer at full commit SHAs, sparse). Every pin is satisfied in place from snes-python's `reference/` (same revision, every sparse path present): nothing is cloned or copied. The cartridges are **bring your own**, read in place from the No-Intro set (`SNES_NO_INTRO`). The data ROM needs no file: it is computed (open decision 3); a BYOR `cx4.bin` can be passed to the survey to compare. ## Scripts | Script | What | | --- | --- | | `fetch_references.py` | fetch, verify, or find in place the pinned documents and source trees | | `survey_data_rom.py` | compute the data ROM from fullsnes' formulas exactly; compare with BYOR images and the emulators' copies; SHA-1, checksum, float64 margins | | `survey_program.py` | the program at 02:8000-9FFF in every Cx4 cartridge: versions, instruction mix, the contested encodings it uses | | `mesen_cx4_trace.py` | Mesen2 2.1.1 headless: the built-in test (controller 2 B), a per-instruction Cx4 trace, the screen | | `mame_cx4_host.py` | MAME 0.285: the S-CPU's accesses to $6000-$7FFF, input presses, screens (HLE: command level only) | They need `7z`, MAME 0.285 at `/usr/games/mame`, famicom-python's `MesenCore.so` (Mesen2 `b9fa69dd`), and Pillow for `--png`. Run anything that reads `reference/` or a ROM with `python -I`, heavy runs under `nice -n 19`. ## Documents [docs/README.md](docs/README.md) is the index; [docs/handoff-brief.md](docs/handoff-brief.md) is the build session's task and the open decisions. MIT licensed ([LICENSE](LICENSE)).