Metadata-Version: 2.5 Name: sm83-python Version: 0.1.0.dev0 Summary: Readable, pure-Python Sharp SM83 (Game Boy CPU) instruction-core reference implementation 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 # sm83-python A readable, pure-Python **Sharp SM83** CPU core: the processor inside the Game Boy, Game Boy Pocket, Super Game Boy, Game Boy Color and the Game Boy Advance's backward-compatible mode. "LR35902" is the name of the original Game Boy's whole system-on-a-chip; the CPU inside it is the SM83, and this repository is only the CPU. The board, [gameboy-python](../gameboy-python), owns everything else. **Status (2026-10-05): groundwork only, no core code.** The documents in [`docs/`](docs/README.md) gather what the build needs, every fact with its source and tier: the instruction set, every M-cycle with its address, interrupts, HALT and STOP, the quirks and contradictions, the oracles with measured results, a verified MAME recipe, and the brief for the session that builds the core ([docs/handoff-brief.md](docs/handoff-brief.md)). The core will follow [z80-python](https://github.com/alewman/z80-python)'s shape: host-owned memory passed in as callables, `step()` returning M-cycles, no dependencies, CPython and PyPy (Python 3.11+). Unlike z80-python it will make **one bus callback per M-cycle, internal cycles included**, because the Game Boy's hardware reacts to the address the CPU drives even when it neither reads nor writes (the DMG's OAM corruption bug). ## What is fetched Nothing third-party is committed. `scripts/fetch_references.py` rebuilds `reference/` from `scripts/pinned_files.json` (5 files pinned by SHA-256: the built Mooneye ROMs, GBCTR's PDF, the SonoSooS CPU-internals notes, and two tool bundles) and `scripts/pinned_repos.json` (16 repositories at full commit SHAs, sparse where large), including SingleStepTests sm83, blargg's and Mooneye's test ROMs, Gambatte's hardware-captured tests, SameBoy, Pan Docs, GBCTR, and two die-traced SM83 models. ```sh python scripts/fetch_references.py # everything missing (~1 GB) python scripts/fetch_references.py --no-tools # without the 750 MB simulator bundle python scripts/fetch_references.py --verify # check what is present python scripts/build_referees.py # SameBoy tester, GHDL venv, dmg-sim python scripts/gbctr_timing.py # tests/gbctr_timing.json ``` They need `git`, `curl`, `make`, a C compiler, and `uv` for the GHDL venv. No sudo. ## Scripts | Script | What | | --- | --- | | `scripts/fetch_references.py` | the pinned references, test ROMs and tool bundles | | `scripts/build_referees.py` | builds SameBoy's headless tester and free boot ROMs, a venv for Gekkio's die-traced VHDL SM83, and msinger's dmg-sim | | `scripts/gbctr_timing.py` | GBCTR's per-M-cycle tables (address, data, IDU, ALU, access kind) as JSON | | `scripts/mame_trace.py` | MAME 0.285 per-instruction trace and serial output of a Game Boy ROM, with a free boot ROM ([docs/mame-oracle.md](docs/mame-oracle.md)) | ## Licence MIT (see `LICENSE`), for what is in this repository. The fetched material keeps its own terms, recorded per entry in the pin lists.