# Handoff brief What the restarted gba-python is to become, and how it is judged. The rules of the restart come first: [restart.md](restart.md). ## The machine and the goal A readable, pure-Python Game Boy Advance (AGB-001) board on the arm7tdmi-python core: the memory map and wait states, the Game Pak prefetch buffer, four DMA channels, four timers, the interrupt controller, HALT and STOP, keypad and serial registers, the BIOS's read protection and open bus, the picture processor (dot-exact where a line changes mid-draw), the sound unit (the Game Boy channels from gb-apu-python's AGB row, two DMA FIFOs, the mixer, SOUNDBIAS), cartridge saves (SRAM, Flash, EEPROM) and the cartridge clock (GPIO and the S-3511 RTC). A reference board: correct, not fast; sub-real-time on PyPy is expected. It must run on PyPy (Python floor: the newest PyPy supports, 3.11). ## Owner's standing decisions (from Phase 0, still in force) - The retail BIOS is the player's own dump, read in place (`--bios`, a `.bin` or a No-Intro `.zip`), never committed or fetched; Cult-of-GBA's free BIOS (MIT) is pinned for runs without one. Commercial ROMs are read in place from the No-Intro folder named by the environment variable `NO_INTRO_DIR`; never copied, never committed. - A catch-up scheduler (devices advanced to the CPU's time when touched or at events). - The sound channels come from gb-apu-python, pinned by revision (it was extracted for exactly this board). - The repository stays private until the owner says otherwise. No GBA hardware is available: hardware-calibrated test ROMs are the strongest judges. ## The rungs and their judges Each rung passes before the next starts. A judge is hardware-calibrated unless marked detector. Seeded one-line faults prove each rule's judge can fail (charter, proof obligations). | Rung | What | Judges | | --- | --- | --- | | 0 | the bus without a picture: memory map, I/O registers, BIOS calls, timers, IRQs, DMA | jsmolka `gba-tests` (arm, thumb, memory, bios, nes, save), mGBA suite (memory, I/O read, DMA, BIOS math, shifter, carry, multiply), krom's BIOS tests (run only), ARMWrestler (run only) | | 1 | cycle timing of the bus: wait states, N/S, the prefetch buffer, DMA and IRQ timing, HALT | alyosha-tas `gba-tests` (Bus, DMA, Interactions, irq, prefetcher, timer, timing), `hw-test` (bus, dma, haltcnt, irq, timer), mGBA suite (timing, timer count-up, timer IRQ), Hades-Tests (run only), GBA-Test-Collection `retAddr` | | 2 | saves and the clock | jsmolka `save/`, Nintendo's Backup LIB sample (SRAM, Flash 64K/128K, EEPROM), Pokémon Emerald accepting the RTC | | 3 | the picture, a line at a time: modes 0-5, OBJs, windows, blending, mosaic | `hw-test` ppu photos, destoer tests, pictures against NanoBoyAdvance (detector, closed box) | | 4 | the picture, dot by dot where a line changes mid-draw; CPU/DMA waits on VRAM/OAM/palette | alyosha-tas `ppu/*`, destoer `lyc_midline`/`window_midframe`, `hw-test/ppu` | | 5 | sound | alyosha-tas `fifo_dma/*`, the AGS aging cartridges' sound tests, level and envelope against NanoBoyAdvance (detector) | | 6 | Nintendo's aging cartridges (AGS v7.0-v10.0, AGB) pass their automatic tests and keep settings in EEPROM across a power cycle | the cartridges themselves | | 7 | games, and a window to play them in | `tests/smoke_set.txt` (39) and `tests/games_set.txt` (57): no crash, no broken picture, the game reached; pictures against NanoBoyAdvance (detector) | ## Targets: what the archived board reached Targets only (restart.md, "Carried over"): the archived board's scores, with the retail BIOS, at its last commit. A score below a target is reported with what was found, not fitted. | Judge | Archived board | | --- | --- | | jsmolka | 10/10 | | alyosha-tas (127 ROMs) | 114/127 read from r12, which overstates it: the test library restores r12 after printing, so r12 is the verdict only for the ROMs that evaluate r12 itself (116 of alyosha-tas's; not the 9 that evaluate r0, the 3 that evaluate r7, or a ROM that hangs). Judge by the screen (`scripts/judge_text.py`, docs/validation.md); its archived failures were 8 serial ROMs (no link partner), timer, timer_reset and dma_long (Game Boy Player boot), two prefetcher ROMs | | hw-test | 13/14 (the archive's layout; the restarted board's runner judges 11 text ROMs at rungs 0-1, the menus and picture ROMs being later rungs) | | Hades-Tests | 2/4 | | mGBA suite | memory 1,552/1,552, I/O read 130/130, timing 2,020/2,020, timer count-up 936/936, timer IRQ 90/90, shifter 140/140, carry 93/93, multiply long 72/72, BIOS math 615/615, DMA 1,244/1,244; SIO R/W 31/90, SIO timing 0/8, misc. edge 6/12 | | krom BIOS tests | 25/25 | | ARMWrestler / FuzzARM / retAddr | 8/8 / 5/5 / 1/1 | | mGBA `keyirq` | 13/14 | | Backup LIB sample | 12/12 | | AGS aging (auto tests; settings across power cycle) | 5/5; 5/5 | | games list | 56 of 57 reach the game (one stops at a timing test its script cannot pass) | Known detector facts (measured by running the detectors, not by reading them): NanoBoyAdvance 1.8.3 fails 8 of alyosha-tas's 18 `prefetcher/*` ROMs; its own BIOS skip leaves state that breaks some games (Sonic Advance, Stuntman, V-Rally 3) which run from its BIOS boot; its driver has no cartridge clock. ## Practical facts - `python scripts/fetch_references.py` rebuilds `reference/` and the test ROMs (already present on this machine); `python scripts/build_referees.py --nba` builds the drivers. - PyPy: `PYPY_GC_NURSERY=1M` for parallel runs (about five times the throughput here); `nice` long runs. A PyPy object with 80 or more attributes falls back to a dict: keep hot objects under that. - The core's GBA access rule (`arm7tdmi_python.gba_access`) is the core's: call it, never copy it. - House rules: no `rm -rf`, `sed -i` or `ln -sfn` one-liners; commit locally at good points; pushes are the owner's call.