Metadata-Version: 2.5 Name: gba-python Version: 0.1.0.dev0 Summary: Readable, pure-Python Game Boy Advance board built on arm7tdmi-python 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: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: System :: Emulators Requires-Python: >=3.11 Requires-Dist: arm7tdmi-python @ git+file:///data/emu/arm7tdmi-python@69aceb2ac52507fafd7b4ad505b6bd55c9dcfa9e Provides-Extra: dev Requires-Dist: pytest>=8; extra == 'dev' Requires-Dist: ruff==0.16.8; extra == 'dev' Description-Content-Type: text/markdown # gba-python A readable, pure-Python emulator of **Nintendo's Game Boy Advance**, to be built as a board on [arm7tdmi-python](../arm7tdmi-python): the core owns the ARM7TDMI's instruction sets and its cycle-by-cycle bus; this repository will own everything around it: the memory map and its wait states, the Game Pak prefetch buffer, four DMA channels, four timers, the interrupt controller, HALT and STOP, the keypad and serial port, the BIOS's read protection and open bus, the picture processor, the sound unit, and the cartridge's save chips and clock. **Status (2026-10-23): rung 0 passes; rungs 1, 3 and 4 in progress.** The board runs the retail BIOS (read in place) and every CPU, memory, I/O, timer, IRQ and DMA judge of rung 0; of rung 1 it passes the mGBA suite's timing groups, all of NanoBoyAdvance's non-PPU `hw-test` but one case, and 12 of alyosha-tas's 18 prefetcher ROMs (NBA: 10). It draws the picture dot-exact where a line changes while it is drawn (rung 4) and a line at a time elsewhere, with the same result: every BG mode, OBJs, windows, blending and mosaic; mid-line register writes; CPU and DMA accesses to VRAM, palette and OAM waiting for the PPU's fetches. 21 judge and game frames (games to 1,200 frames) match NanoBoyAdvance pixel for pixel, including the green swap photograph; alyosha-tas's OBJ VRAM timing tests pass (one needed a hardware correction to NanoBoyAdvance); a 40,000,000-instruction lockstep with NanoBoyAdvance agrees on two games. Nintendo's five local aging cartridges (AGS v7.0-v10.0 and the older AGB) pass their automatic tests, LCD included, keep their settings in their EEPROM across a power cycle, and pass rounds of their aging loop. ARMWrestler (79/79 rows), FuzzARM (5 × 10,000), krom's 25 BIOS-call tests (results and Timer 0 cycle counts) and Nintendo's backup library sample on SRAM and Flash pass too. Results, the places hardware tests overruled NanoBoyAdvance's model, and the seeded faults are in [docs/validation.md](docs/validation.md) "The board's results". ```sh python -m venv .venv && .venv/bin/pip install -e '.[dev]' # PyPy: the same with pypy3 python -m gba_python ROM.gba [--bios PATH] [--frames N] [--png out.png] [--trace bus.jsonl] python scripts/run_test_roms.py jsmolka alyosha hwtest hades mgba frames ags aging --jobs 16 python scripts/build_test_roms.py # keyirq, against scripts/libgba_shim python scripts/run_test_roms.py armwrestler fuzzarm krom retaddr keyirq backuplib python scripts/frame_diff.py --judges # pictures vs NanoBoyAdvance python scripts/smoke.py --quick # 11 commercial ROMs, ~3 min: a regression detector pytest -m "not slow" # quick; -m slow: the ROM judges ``` ## Scope | Machine | Phase | | --- | --- | | AGB-001 (GBA), the reference; AGS (SP) and the Game Boy Player share the chip | 1 | | Game Boy / Game Boy Color cartridges in the GBA (SM83 mode) | later: embeds gameboy-python and sm83-python | | Link-cable partners | later | The Game Boy's four sound channels live in `gameboy-python` today. This board is their second consumer, so they are **extracted with their history into their own core** (`gb-apu-python`, user decision 4) before this board uses them, never copied. ## What is fetched Nothing third-party is committed. `scripts/fetch_references.py` rebuilds `reference/` and `tests/test_roms/` from `scripts/pinned_files.json` (GBATEK, CowBite, the prebuilt mGBA suite, AGBEEG, the Arm GNU toolchain 14.3, Lua 5.4.7; by SHA-256) and `scripts/pinned_repos.json` (23 repositories at full commit SHAs: gbadoc, Tonc, the test suites of jsmolka, alyosha-tas, NanoBoyAdvance, mGBA, destoer and Hades, ARMWrestler, the free BIOSes, NanoBoyAdvance 1.8.3, mGBA, SkyEmu, Hades, ares, the MiSTer core, MAME's driver): ```sh python scripts/fetch_references.py # everything missing python scripts/fetch_references.py --verify # check what is present python scripts/build_referees.py --nba # mGBA and NanoBoyAdvance drivers ``` It needs `git` and `curl`; the build needs `cmake`, `ninja`, a C/C++ compiler, libpng and zlib. **The BIOS is bring-your-own**: Nintendo's is never fetched or committed; the scripts read your dump in place (`--bios`, a `.bin` or a No-Intro `.zip`). Cult-of-GBA's free BIOS (MIT) is pinned for runs without one; judge runs need the retail BIOS ([docs/start-here.md](docs/start-here.md) "The BIOS"). ## Scripts | Script | What | | --- | --- | | `scripts/fetch_references.py` | the pinned references, tools and test ROMs | | `scripts/build_referees.py` | Lua, mGBA's core + `mgba_driver`, NanoBoyAdvance 1.8.3's core + `nba_driver` | | `scripts/mgba_driver.c`, `scripts/nba_driver/` | one command line for both detectors: run N frames with held keys, print the debug-port log, registers, I/O words, save the frame as PNG | | `scripts/referee_run.py` | scores jsmolka/alyosha-tas ROMs (r12), the mGBA suite (END lines) and screenshots on either detector ([docs/validation.md](docs/validation.md)) | | `scripts/mame_run.py` | MAME 0.285's `gba` driver with your BIOS: a frame and the registers ([docs/mame-oracle.md](docs/mame-oracle.md)) | | `scripts/count_saves.py` | save-chip and RTC census over the local No-Intro set, read in place ([docs/cartridge.md](docs/cartridge.md)) | | `scripts/run_test_roms.py` | the board's judges: jsmolka, alyosha-tas, hw-test, Hades-Tests, the mGBA suite, Nintendo's aging cartridges (`ags`, and `aging`: settings across a power cycle and the aging loop), ARMWrestler, FuzzARM, krom's BIOS tests, GBA-Test-Collection's `retAddr`, mGBA's `keyirq`, Nintendo's Backup LIB sample; `--write` updates the pass lists | | `scripts/build_test_roms.py` | builds pinned test programs written for devkitARM's libgba (mGBA's `keyirq`) with the pinned Arm toolchain, against `scripts/libgba_shim/` | | `scripts/seeded_faults.py` | one fault per rule in a copy of `src/`, each run against its judge | | `scripts/smoke.py` | the smoke set (`tests/smoke_set.txt`, 39 commercial ROMs read in place): picture, state and sound digests against `tests/smoke_baseline.txt`, in parallel; `--quick`, `--record`, `--nba`, `--dump` ([docs/validation.md](docs/validation.md) "Smoke set") | | `scripts/nba_lockstep.py` | instruction-by-instruction comparison with NanoBoyAdvance (`nba_trace`): cycles, R15 and optionally R0-R14, streaming any length of run, with switches to look past the board's known differences (docs/validation.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.