# Validation: every oracle, its tier, its pin, how to read its answer Tiers, as for every repository in the family: **hardware-captured** (a result recorded from a real console) > **hardware-corrected** (documentation fixed against hardware) > **emulator-derived**. A low-tier oracle is a **detector** (it points at a difference), never a **judge** (it decides one). Pins are in `scripts/pinned_repos.json` and `scripts/pinned_files.json`; `python scripts/fetch_references.py` fetches them all (23 repositories and 7 files: about 410 MB, of which the Arm toolchain's tarball is 150 MB and unpacks to 500 MB more). There is **no die-level model** of the GBA: no netlist, no decap-derived simulator like dmg-sim or Visual 6502, and no die photographs in a public repository were found (GitHub searches "gba decap", "agb die", "gba netlist", 2026-10-21). The MiSTer core is hand-written RTL, an emulator in another language. So the judges are test ROMs with hardware results. ## Tier 1: hardware-captured | Oracle | Pin | What it covers | Result protocol | Hardware evidence | | --- | --- | --- | --- | --- | | **NBA hw-test** | `reference/src/hw-test` @ `fbc9914` (Codeberg; GitHub copy abandoned) | bus 128 KiB, DMA (start delay, latch, forced N, burst), HALTCNT, IRQ delay, PPU (BG latch, DISPCNT latch, green swap, OBJ mosaic, RAM access timing, DISPSTAT/IRQ/DMA, VRAM mirror), timers | text screen ("PASS/FAIL ... congratulations!"); PPU ones are pictures | PPU `expected.png`: `bgpd` and `greenswap` are **photographs of a GBA screen** (4000×3000); `bgx` and `dispcnt-latch` are captures of unstated source, `sprite-hmosaic` a NanoBoyAdvance 1.8.2 screenshot (C13); READMEs state GBA/GBA SP results; written by NBA's authors to settle NBA | | **alyosha-tas gba-tests** | `reference/src/gba-tests-alyosha` @ `66f5f1d` | jsmolka's suites plus Bus, DMA, Interactions, LDM, Serial, fifo_dma, irq, prefetcher, psr, timer, timing, ppu; 143 ROMs with the r12 protocol | r12 = 0 or the first failing test | READMEs: "tested on GBP" (Game Boy Player): GBA silicon, but **booted by the GBP's BIOS** (C4) | | **AGS Aging Cartridge** | not pinned: Nintendo's, BYOR. Local: v7.0, v7.1, v9.0, v10.0 and the older AGB Aging Cartridge, No-Intro "(Test Program)" | Nintendo's factory test: memory, CPU, DMA, timers, sound, LCD, key, serial, cartridge | its own PASS/FAIL screens | a manufacturer test program that passes on working hardware: the strongest judge for what it covers | | **mGBA test suite** | `reference/src/suite` @ `e694203`; prebuilt `tests/test_roms/mgba-suite/suite.gba` (2026-07-08 build) | 14 groups: memory 1,552, I/O read 130, timing 2,020, timer count-up 936, timer IRQ 90, shifter 140, carry 93, multiply long 72, BIOS math 615, DMA 1,244, SIO R/W 90, SIO timing 8, misc edge 12, video (interactive) | "END: passes/total" through mGBA's debug port (mGBA and NBA both implement it); also text in SRAM (`savprintf`), which hardware keeps | expectations recorded on hardware by its author (not stated in the repository); consistent with an independent emulator: NBA reaches 2020/2020, 936/936, 90/90, 72/72 | | **jsmolka gba-tests** | `reference/src/gba-tests` @ `a7113b6` | arm, thumb, memory, bios, nes, unsafe, save (sram, flash64, flash128, none), ppu (pictures) | r12 = 0 or the first failing test; screen "All tests passed" | the repository does not say; widely run on hardware; treat as Tier 1 for documented behaviour only, and `unsafe` as unverified | | **destoer gba_tests** | `reference/src/gba_tests-destoer` @ `d714cda` | dma_priority, if_ack, isr, line_timing, lyc_midline, window_midframe, cond_invalid, experimental (irq_delay, joypad, pcmxx, timer_change) | raw values on screen | values to compare with hardware photos that the repository does not include: **detector until a hardware value is found** | | **Hades-Tests** | `reference/src/Hades-Tests` @ `206d550` | bios-openbus, dma-latch, dma-start-delay, timer-basic (and cheat-device tests) | "Total: n/m" screen | hardware-derived per Hades' author; not stated | | **ARMWrestler (fixed)** | `reference/src/armwrestler` @ `802e55a` (destoer's `armwrestler-gba-fixed`) | ARM ALU, multiply, SWP, PSR, LDR/STR addressing, LDM/STM writeback; Thumb ALU, LDR/STR, LDM/STM: 79 rows on 8 pages | mode 4 text, OK or BAD per row (suite `armwrestler`) | the original's LDM-writeback tests (base in the list) fail on real hardware (forums.mgba.io tid 18); the fix takes Test4 from Arisotura's arm7wrestler. Both binaries in the pinned tree carry the fixed Test4 (the same check code byte for byte), so no unfixed build is pinned; the suite runs `armwrestler-gba-fixed.gba`. Hardware-checked by report, not by a recorded run | | **krom's BIOS tests** (Peter Lemon) | `reference/src/PeterLemon-GBA` @ `efdb535`, prebuilt | 25 BIOS calls (Div, Sqrt, ArcTan, the decompressors, BitUnPack, CpuSet, CpuFastSet, Checksum, RegisterRamReset, the affine sets, the sound driver calls): results **and Timer 0 cycle counts** | text screen, PASS or FAIL per line (suite `krom`) | the expected values are in the source; the author states he "only tests with a real GBA". The PNGs beside each ROM are emulator captures, not used. The cycle counts are the retail BIOS's: with Cult-of-GBA's every count fails | | **Nintendo's "Backup LIB sample"** | not pinned: No-Intro "(Program)" v1.04, BYOR | Nintendo's backup libraries (SRAM_V113, FLASH512_V13, FLASH1M_V102, EEPROM_V122) writing and verifying a chip | its own "WRITE COMPLETE." / "VERIFY ERROR." (suite `backuplib`) | manufacturer code: the libraries games link, verifying through their own reads. Covers SRAM and the Flash command protocol; its EEPROM run is spoilt by the program's own DACS probe on the board (C24) | ## Tier 2: hardware-corrected documentation GBATEK (`reference/docs/gbatek.{htm,txt}`, 2025-04-16; the base text of every document here), gbadoc (`reference/docs/gbadoc` @ `35a281a`, a community rewrite of GBATEK), CowBite (`reference/docs/CowBiteSpec.htm`, Wayback copy; older), Tonc (`reference/docs/tonc` @ `36b7def`, programming semantics and examples). None of them is a judge on cycle timing: where a hardware test disagrees, the test wins (C1 in [undocumented-behavior.md](undocumented-behavior.md) is one such place). ## Tier 3: emulator-derived, and the detectors | Detector | Pin | Built here | Use | | --- | --- | --- | --- | | **NanoBoyAdvance 1.8.3** | `reference/src/NanoBoyAdvance` @ `8c3b159` (release tag, Codeberg) | `scripts/nba_driver/` against its core library | the closest detector: passes the most hardware tests measured here. **Not HEAD**: the 2.0 rewrite at `9894c66` crashed (SIGSEGV in `PPU::DrawMergeImpl`, in 40 % to 85 % of runs depending on the ROM; its audio thread also overruns a buffer under ASan) | | **mGBA** | `reference/src/mgba` @ `fd9dc5c` (2026-10-18) | `libmgba.a` + `scripts/mgba_driver.c`; `mgba-headless` with Lua | a second, independent lineage; its suite's home | | **MAME 0.285** `gba` | the installed binary; sources at `reference/src/mame` @ `1ee501d` (sparse) | — | gross faults only ([mame-oracle.md](mame-oracle.md), C10) | | SkyEmu, Hades, ares, GBA_MiSTer | pinned sources, not built | — | read when NBA and mGBA disagree; Hades' `accuracy/suite.py` has key sequences and frame counts for the AGS cartridge and others | | Hades' expected screenshots | `reference/src/Hades/accuracy/expected/` | — | emulator-derived pictures of passing AGS/AGBEEG screens; a detector for the AGS procedure | | AGBEEG | `tests/test_roms/agbeeg/` v0.0.2 | — | a free re-implementation of AGS tests; detector-strength until its results are checked against the real AGS on hardware | | FuzzARM | `reference/src/FuzzARM` @ `a675329` | prebuilt (5 ROMs) | 10,000 random ARM/Thumb data-processing, multiply and load/store tests per ROM, expected values computed by its Python generator (a model, so a **detector**); a failure dumps its state to EWRAM (suite `fuzzarm`). It masks C after multiplies and generates no RRX | | GBA-Test-Collection | `reference/src/GBA-Test-Collection` @ `61527ec` | prebuilt | `exception/retAddr`: LR_irq after an IRQ in ARM and in Thumb state, against the data sheet's rule (next instruction + 4); judged by that document (suite `retaddr`). `misc/helloWorld` and `helloAudio` have no verdict | | mGBA gbatests `keyirq` | `reference/src/gbatests-mgba` @ `c24b8e2` | `scripts/build_test_roms.py`: its `main.c` unchanged, against `scripts/libgba_shim` with the pinned Arm toolchain (no devkitARM here) | KEYCNT IRQ edges: 14 steps, keys held as each prompt asks (suite `keyirq`, a key per step). mGBA's author's expectations, no hardware run recorded: a detector, except where GBATEK states the rule (C23) | | DUST (Daft-Freak) | `reference/src/DUST` @ `70738f1` | not built: needs gba-toolchain's `librom`/`gba-hpp`, not installed; no prebuilt | about 170 display (layers, objects, windows, mosaic, blend) and DMA pictures with no expected images: would be a frame-diff detector only | ## What was run here (2026-10-21) All with `python scripts/referee_run.py` (both detectors) and `python scripts/mame_run.py`; raw results land in `tests/referee_runs/` and `tests/mame_runs/` (ignored). "Retail" = Aubrey's BIOS dump read in place, "Cult" = Cult-of-GBA's free BIOS, "HLE" = mGBA's built-in BIOS emulation. ### mGBA suite | Group (cases) | NBA retail | NBA Cult | mGBA retail | mGBA Cult | mGBA HLE | | --- | --- | --- | --- | --- | --- | | Memory (1,552) | 1,514 | 1,468 | **1,552** | 1,506 | 1,552 | | I/O read (130) | 130 | 130 | 130 | 130 | 130 | | Timing (2,020) | **2,020** | 1,900 | 1,768 | 1,648 | 1,768 | | Timer count-up (936) | **936** | 847 | 744 | 692 | 639 | | Timer IRQ (90) | **90** | 90 | 70 | 70 | 70 | | Shifter (140) | 140 | 140 | 140 | 140 | 140 | | Carry (93) | 93 | 93 | 93 | 93 | 93 | | Multiply long (72) | **72** | 72 | 52 | 52 | 52 | | BIOS math (615) | 615 | 603 | 615 | 603 | 615 | | DMA (1,244) | 1,244 | 1,244 | 1,244 | 1,244 | 1,244 | | SIO R/W (90) | 18 | 18 | 61 | 61 | 61 | | SIO timing (8) | 0 | 0 | 0 | 0 | 0 | | Misc. edge (12) | 6 | 5 | 6 | 3 | 5 | | Video | interactive | | | | | NBA's misses with the retail BIOS: 38 "ROM out-of-bounds" memory cases (C5), the SIO groups, six "H-blank bit start" (C1). mGBA's: 252 timing (Thumb loads from ROM with prefetch), 192 count-up, 20 timer IRQ, 20 multiply long, the SIO groups, "DMA Prefetch Break" and five "H-blank bit start". ### r12-protocol ROMs (jsmolka + alyosha-tas, 143 ROMs, 600 frames) | | NBA | mGBA | | --- | --- | --- | | retail BIOS | **95** pass | 49 | | Cult-of-GBA BIOS | 79 | 59 | | GBP ("GameCube") BIOS | 0 (does not boot standalone) | — | Per folder, failures with the retail BIOS (NBA / mGBA): Bus 3/5 of 6, DMA 2/8 of 9, Interactions 9/14 of 16, LDM 0/0 of 8, Serial 8/7 of 9, fifo_dma 6/6 of 9, irq 2/14 of 16, ppu 3/4 of 12, prefetcher 8/16 of 18, timer 2/3 of 3, timing 2/4 of 5; jsmolka: NBA fails only `unsafe` (test 2), mGBA also `arm` (522), `flash64` and `flash128` (10). ### Screens (both detectors, retail BIOS, 400 frames) | ROM | NBA | mGBA | | --- | --- | --- | | hw-test timer reload / start-stop / tick-before-reload | pass / pass / pass | 4 of 7 / 1 of 2 / 0 of 2 | | hw-test dma start-delay / force-nseq-access / latch / burst-into-tears | pass / pass / pass / 0 of 3 | fail / 0 of 2 / pass / 1 of 3 | | hw-test irq-delay / haltcnt | 3 of 3 / 5 of 6 | 1 of 3 / 2 of 6 | | hw-test vram-mirror | pass | pass | | Hades-Tests bios-openbus / dma-latch / dma-start-delay / timer-basic | 10/12, 4/4, 4/8, 10/10 | 10/12, 2/4, 0/8, 2/10 | | AGBEEG | CARTRIDGE, CPU, DMA all PASS | all three FAIL | | AGS v7.0, v7.1, v9.0, v10.0 | "CHECK SUM ERROR! DEFAULT IS SAVED" (fresh EEPROM: the tests run on the next power-on, rung 3) | same | ### MAME 0.285 With the retail BIOS: jsmolka `nes` and `save/none` pass; `arm` 225, `thumb` 221, `memory` 50, `bios` 1, `unsafe` 1, `sram` 1, `flash64` 2, `flash128` black screen; Hades `bios-openbus` 0/12; `hw-test/timer/reload` 0/7; AGBEEG fails all three. With Cult-of-GBA's BIOS it never leaves the BIOS's splash screen. ## Local romsets (read in place, never copied into the repository) - BIOS: `.../No-Intro/Nintendo - Game Boy Advance/[BIOS] Nintendo Game Boy Advance Boot ROM (World).zip` (retail, SHA-1 `300c20df…`), `(GameCube)` (`3d4b5d09…`, Game Boy Player), `(Beta)` (`aa98a2ad…`), and the GBC-mode boot ROMs. - AGS/AGB aging cartridges, same directory. - 3,487 licensed ROMs for the save census ([cartridge.md](cartridge.md)) and later game coverage. The directory is `/data/emu/source/myrient.erista.me/files/No-Intro/` (`GBA_NOINTRO_DIR`). ## The plan: rungs in tier order Each rung names its acceptance; a rung that needs the core waits for arm7tdmi-python's rung 3. 0. **Bus without a picture.** Memory map, wait states, open bus, BIOS latch, WAITCNT, the I/O table, IRQ controller, timers, DMA (no PPU beyond a line counter that raises VBlank/HBlank/VCount at NBA's cycles). Accept: jsmolka `arm`, `thumb`, `memory`, `bios`, `nes`; mGBA suite memory, I/O read, shifter, carry, multiply long, BIOS math, DMA groups at NBA's retail-BIOS score or better. 1. **Cycle timing of the bus.** The prefetch buffer and the N/S rules. Accept: mGBA suite timing 2,020/2,020, timer count-up 936/936, timer IRQ 90/90; `hw-test` timer, dma, irq, haltcnt, bus; Hades-Tests; alyosha-tas `timer`, `irq`, `DMA`, `Interactions`, `prefetcher`, `timing` (the boot-phase-sensitive ones flagged under C4 as known). 2. **Saves and the RTC.** SRAM, Flash 64K/128K, EEPROM 512 B/8 KiB, the GPIO RTC. Accept: jsmolka `save/*`; AGS cartridge's backup test; a Pokémon game's clock. 3. **The PPU, line-exact.** All modes, OBJs, windows, blending, mosaic. Accept: jsmolka/alyosha-tas `ppu` pictures; `hw-test/ppu` photographs (by eye, then by a captured reference frame once one matches); AGS LCD tests. 4. **The PPU, dot-exact.** VRAM/OAM/palette access timing, DISPCNT and affine latches, mid-line effects. Accept: `hw-test/ppu/ram-access-timing`, `dispcnt-latch`, `bgx`, `bgpd`, alyosha-tas `ppu/Sprite_*`, destoer `window_midframe`, `lyc_midline`, `line_timing`. 5. **Sound.** The extracted Game Boy channels with the GBA's differences, the FIFOs, the mixer, SOUNDBIAS. Accept: alyosha-tas `fifo_dma`, AGS sound tests, a recorded comparison with NBA's output on commercial music. 6. **AGS aging cartridge to its final PASS screen**, every group, with the retail BIOS. 7. **Games.** A boot-to-gameplay list drawn from the census, then a playable front end (keypad, audio out). Speed is not a goal: a `-fast` fork is. Each rung also runs a **seeded-fault check** (as in the other boards): a deliberate bug in each rule must turn its judge red. ## The board's results All runs: `scripts/run_test_roms.py` (PyPy 7.3.20) with the retail BIOS read in place (user decision 1), arm7tdmi-python pinned at `34c18fd`. A ROM on the r12 protocol passes only when it reaches its closing branch to itself with r12 = 0, which is stricter than the referee drivers (finding below). ### Rung 0: the bus without a picture (2026-10-22) — passes | Judge (tier) | Board | NBA 1.8.3 | mGBA | | --- | --- | --- | --- | | jsmolka `arm`, `thumb`, `memory`, `bios`, `nes` (hardware-checked) | 5/5 | 5/5 | 4/5 | | jsmolka `unsafe`, `save/*` | 5/5 | 4/5 | 4/5 | | mGBA suite memory (1,552) | **1,552** | 1,514 | 1,552 | | I/O read (130), shifter (140), carry (93), multiply long (72), BIOS math (615), DMA (1,244) | all | all | multiply long 52 | ### Rung 1: cycle timing of the bus (2026-10-22) — in progress | Judge (tier) | Board | NBA 1.8.3 | | --- | --- | --- | | mGBA suite timing (2,020), timer count-up (936), timer IRQ (90) | **all** | all | | `hw-test` timer (3), dma (4), irq (1), bus (1) (hardware) | **9/9** | 7/9 (128kb-boundary, burst-into-tears fail) | | `hw-test` haltcnt (hardware) | 5/6 ("CPUSET DMA" 4,153, expected 4,154) | 5/6 (4,151) | | `hw-test/ppu/status-irq-dma`, its four text tests (hardware) | **4/4** | 4/4 | | Hades-Tests timer-basic, dma-latch / bios-openbus / dma-start-delay | 2/4: 10/12, 4/8 | same | | alyosha-tas r12 ROMs, `ppu` excluded (121) | 85 | 77 by the referee's count, which includes one hung ROM | | ... of which `prefetcher` (18) | **12** | 10 | `tests/alyosha_gbp_calibrated.txt` lists the 32 alyosha-tas ROMs whose verdict on NBA changes with the BIOS (C4); per user decision 6 they are GBP-calibrated and the board is not fitted to them. Of the board's 40 alyosha-tas failures, 13 are on that list; the others are `Serial` (9) and `fifo_dma` (5) (no link partner; rung 5), `Bus` (3: open bus after DMA, see below), `prefetcher` (6), `irq/halt_pc` and `irq/IRQ_sub_2_slow`, and `unsafe/prefetcher_branch_thumb_arm_2`. **What changed against NanoBoyAdvance's model, each by a hardware test:** 1. **A DMA's 128 KiB boundary follows its previous access, not its address.** NBA forces N wherever the address is a multiple of 128 KiB. hw-test `bus/128kb-boundary` (hardware) needs, for a decrementing DMA, N on the access *after* one that ended at the boundary and S on a read *of* the boundary address; alyosha-tas `DMA/readme.txt` says the same in words ("the NEXT access will use non-sequential timing, even if in decrement or fixed mode"). The CPU keeps NBA's address rule (its S accesses are contiguous, and the mGBA suite's LDM from OAM into ROM needs it): 18/18. 2. **A Game Pak write moves the cartridge's address counter.** hw-test `dma/burst-into-tears`: a DMA that writes 8000000 and then reads "8000000" S gets 8000002's halfword, and the read is S. NBA's counter does not move on writes: 0/3, this board 3/3. 3. **A full prefetch buffer pauses.** NBA's buffer keeps counting past its capacity, handing out opcodes it never fetched. alyosha-tas `prefetcher/readme.txt` ("the prefetch unit pauses until the buffer is empty and then starts up again with non-sequential timing"): the board pauses it, and the opcode fetch that finds it emptied is N. `prefetcher_full_arm` and `_full_arm_2` pass (NBA fails both). Tried and rejected (more prefetcher ROMs fail): restarting the buffer itself with N timing, a CPU N fetch for a branch onto the in-flight opcode, and stopping the buffer at a 128 KiB boundary. 4. **A DMA that writes HALTCNT stops the CPU where it waits**, in the middle of its instruction, rather than at the next instruction boundary (hw-test `haltcnt` "CPUSET DMA": NBA 4,151, the board 4,153, hardware 4,154; one cycle open). The case starts the DMA from inside the BIOS's CpuSet, so its start delay is C12's question; it waits for the C12 hardware ROM's result rather than a fitted cycle. **The referee drivers count a hung ROM as passing.** `scripts/referee_run.py r12` reads r12 after a fixed number of frames; alyosha-tas `irq/IRQ_sub_2_slow` clears r12 at its start and then loops forever on NBA (and here), so the referee scores it a pass. This board's runner needs the closing branch to itself. **Lockstep against NBA** (`scripts/nba_lockstep.py`, with `nba_trace` built from `scripts/nba_driver/trace.cc`): every instruction's start cycle and R15 from reset. On `irq/IRQ_sub_2_slow` the two agree on all of the first 10,000,000 instructions, through the retail BIOS's boot and into the test's hang: the board's cycle model is NBA's wherever no hardware test said otherwise. The script streams both sides (any length of run), and has switches for looking past a known difference: `--regs` compares R0-R14 too (`nba_trace --regs`); `--adopt` lists each read site where only registers differ, takes NBA's values and carries on; `--trace-from N` prints the board's bus accesses from instruction N; `--nba-trace` runs another `nba_trace` build (one patched for an experiment); `--nba-model PARTS|all` swaps the board's deliberate differences for NBA's, each with the evidence the board follows: | Part | The board | NBA 1.8.3 | Evidence for the board | | --- | --- | --- | --- | | `irq` | the CPU looks at its IRQ input at the start of an access, one synchronizer cycle after `IE & IF & IME`; the synchronizer waits with the CPU for a DMA | looks at the instruction boundary, two cycles, never waits | alyosha-tas `irq/halt_pc` 1-4, `Interactions/*` (quirks 10, 23) | | `data-bus` | open bus after a CPU data cycle on IWRAM, OAM or the Game Pak is that data | always the prefetched opcode | alyosha-tas `Bus/*` (quirk 24) | | `prefetch` | halfwords; pauses when full or at a 128 KiB boundary, restarts N; flushes on a branch past what it holds; a branch onto a fetch just started by a buffer never ahead is N | counts opcodes, never pauses, waits for any fetch in flight | alyosha-tas `prefetcher/*` and its readme (quirk 9) | | `rom-mirror` | reads past the ROM's end return the address pattern | mirrors the ROM | mGBA suite "ROM out-of-bounds" (quirk 7) | | `flash-id` | Panasonic `1B32` / Sanyo `1362` | SST `D4BF` / Macronix `09C2` | none: real carts carry all four (C7) | | `sio`, `joy` | SIO data and JOY bus registers as GBATEK | open bus (no read cases) | GBATEK; mGBA suite "SIO register R/W" (C9) | | `obj-free` | the OBJ engine's HBlank-free window: 960 cycles | 964 | alyosha-tas `ppu/Sprite_Last_VRAM_Access_Free` (C17) | Until rung 4 one NBA difference was not switchable: NBA stalls CPU accesses to VRAM, palette and OAM while its PPU fetches (quirk 18), which the line-exact board did not do. On Advance Wars, with every part switched and against an `nba_trace` built with NBA's four `DidAccess*` checks returning false, the two agreed on all of the first 40,000,000 instructions (to about frame 800): start cycle, R15 and R0-R14, through the boot, the intro and the title. Since rung 4 the board waits too, and the same run against the stock `nba_trace` agrees on all 40,000,000 (see rung 4). **The core's rung 5 through the board** (arm7tdmi-python docs/validation.md): mGBA suite `carry`, `multiply-long`, `shifter`, `timing` pass; alyosha-tas `psr`, `LDM/*` (8/8), `arm/Coprocessor_14`, `thumb/Push_no_regs` and `Pop_no_regs` pass. ARMWrestler (interactive) and FuzzARM are not run yet. **The gates can fail** (`scripts/seeded_faults.py`, each fault in a copy of `src/`): 15 of 15 faults fail their judge (23 of 23 since rung 4). | Fault | Judge | | --- | --- | | EWRAM 16-bit access 2 cycles | mGBA timing (1,943/2,020) | | open bus reads 0 | mGBA memory (1,532) | | the BIOS answers reads from outside it | jsmolka `bios` (1) | | IRQ line 1 cycle after IE & IF, not 2 | mGBA timer IRQ (62/90); hw-test `irq-delay` does *not* see it | | DMA starts 1 cycle after its enable | hw-test `dma/start-delay` | | a timer reload write lands at once | hw-test `timer/reload` (4/7) | | no prefetch buffer | mGBA timing (1,392) | | a DMA's boundary by its own address (NBA's rule) | hw-test `128kb-boundary` | | a Game Pak write leaves the counter | hw-test `burst-into-tears` (1/3) | | HBlank flag at 1,006 | hw-test `status-irq-dma` DISPSTAT (1/5) | | a full buffer keeps counting (NBA) | alyosha-tas `prefetcher_full_arm_2` | | an unreadable half of a readable I/O word reads open bus | mGBA I/O read (112/130) | | SRAM reads not replicated | jsmolka `save/sram` (4) | | 8-bit palette writes store one byte | alyosha-tas `memory/PAL_8_bit_writes` | | the IRQ synchronizer runs during HALT (NBA) | alyosha-tas `irq/halt_pc` | ### Rung 2: saves and the RTC (2026-10-22) — partly - **Save chips** (SRAM, Flash 64K/128K with ID table, EEPROM 512 B/8 KiB sized by the first DMA): jsmolka `save/sram`, `flash64`, `flash128`, `none` and alyosha-tas `save/*` pass (8/8); mGBA fails jsmolka `flash*` test 10 with the free BIOS only. - **RTC** (`cartridge/gpio.py`, Seiko S-3511 on the GPIO port when the ROM names `SIIRTC_V`): the protocol follows GBATEK (commands either bit order, as NBA accepts); date and time are writable and run on emulated time from a start date. `tests/test_board.py` reads the date back over the port. **Pokémon Emerald** (No-Intro, read in place), 900 frames from the retail BIOS: it reads the control register twice, the date and time once and the time once, and never force-resets the clock, which is its "battery has run dry" path (`scripts/pokemon_clock.py`: "clock accepted"). This is a behavioural check, not a picture: the clock screen is rung 3. - **AGS EEPROM** (2026-11-05): the aging cartridges keep their settings page in a 512-byte EEPROM under their own checksum; the `aging` suite changes the page, switches off and on and reads it back (rung 3, "AGS settings and the aging loop"). There is no other backup test on them. **Not done:** the 512 B/8 KiB census by DMA length. **Speed** (mGBA suite Timing group, CPU busy, 60 s after 320 frames, 32-core machine idle): CPython 3.14 0.104x real time (1.74 M system clocks/s), PyPy 7.3.20 0.086x (1.45 M/s). While halted (the BIOS logo, VBlankIntrWait) the board skips to the next event: the retail BIOS's 270-frame boot takes about 6 s on PyPy. ### HALT wake and the IRQ synchronizer (2026-10-23; superseded 2026-11-12, below) Rule (quirk 23): the last two cycles of the IRQ latency are the CPU's synchronizer and count CPU clock cycles, which HALT stops. alyosha-tas `irq/halt_pc` (hardware, GBP) wanted the IRQ after the BIOS's `bx lr` (lr 174h, timer D7h); the board, like NBA, took it before (1B8h, D4h). One rule passes all four `halt_pc` phases (timer reloads FFA0, FFDC, FFDD, FFDE: two wake from HALT, two have the IRQ already in flight when HALT starts) plus `Interactions/Halt_IRQ` and `Halt_DMA_IRQ_Read_OAM`. Full rerun, retail BIOS: alyosha-tas 81 -> 85 of 121, nothing regressed in any suite (jsmolka 10/10, hw-test 13/14, Hades 2/4, mGBA suite scores unchanged); seeded faults 15/15. NBA lockstep was not needed: the test's lr pins the instruction boundary. `hw-test/haltcnt` "CPUSET DMA" stays at 4,153 (hardware 4,154) and Hades `dma-start-delay` test 2 stays failing (C12): no hardware rule found for either. ### When the CPU looks at its IRQ input, and DMA (2026-11-12): replaces the rule above Nine alyosha-tas ROMs that put a timer or VBlank IRQ inside a DMA failed (`Interactions/*DMA_IRQ*`, `DMA_pause_timing_end_4`). Traced on `Internal_Cycle_DMA_IRQ`: the HBlank DMA starts on an `ldr`'s internal cycle, the timer IRQ is raised six cycles into it, and hardware runs two more instructions after the DMA before taking the IRQ (return address ..0Ah); the board took it at once (..06h). Four rules, each judged below, replace the HALT rule of 2026-10-23: 1. **The synchronizer waits with the CPU for a DMA** (quirk 10): one cycle of the CPU's clock, which stops from the moment the CPU wants the bus until the DMA ends. Internal cycles a DMA overlaps still count, and so does HALT. 2. **The CPU looks at its IRQ input when it begins a bus cycle** (quirk 23), so the look at the start of an instruction's last cycle decides the next instruction. The board copies the input to `cpu.irq` at the start of every CPU access; the core is unchanged. 3. **A CPU that a HALT's wake-up reaches while a DMA has the bus** goes on as the DMA's last write ends: no cycle for the wake-up and none for the DMA's closing idle cycle, which hands the bus back to an access that is waiting, and a halted CPU has none. 4. **A channel that becomes ready as another's closing cycle ends runs next**, before the CPU's waiting access (C29). The HALT freeze of 2026-10-23 is gone: with rule 2 the four `halt_pc` ROMs and `Halt_IRQ` pass with the synchronizer running through HALT, as the tests' author describes it ("Halt counts as an internal cycle"). GBAHawk's source was read for the idea of rule 2 (it latches the input at the first cycle of each access); nothing was copied. | Judge | Before | Now | | --- | --- | --- | | alyosha-tas, all | 95/127 | 104/127 | | `Interactions/*` | 9/16 | 16/16 | | `Internal_Cycle_DMA_IRQ`, `_7`, `_ST`, `_ST_p3`, `_br`, `_ldr_IWRAM` | fail | pass | | `Halt_DMA_IRQ_Read_OAM` (C18) | 223 | 221 = hardware | | `Halt_DMA_IRQ` | 137 | 135 = hardware | | `DMA/DMA_pause_timing_end_4` (C29) | 0Eh | 0Ah = hardware | | `irq/IRQ_sub_2_slow` (C22) | hangs | return address and handler timer = hardware; fails later on a prefetch count | | `hw-test/irq/irq-delay`, `haltcnt` 5/6, mGBA timer IRQ 90/90, `irq/*` | | unchanged | | every other suite (jsmolka, hw-test, Hades, mGBA, frames, AGS, aging, ARMWrestler, FuzzARM, krom, retAddr, keyirq, Backup LIB) | | unchanged | With boundary sampling and a two-cycle synchronizer the wait alone passes two of the six (`_7`, `_ldr_IWRAM`); boundary sampling with rule 1 and a one-cycle synchronizer was not a candidate (`irq-delay` pins the three cycles where there are no wait states). Seeded faults: 51 of 51, seven of them these rules (no synchronizer cycle; the input seen at once; no wait; a wait through overlapped internal cycles; the wake-up's cycle after the DMA; the closing cycle; the CPU's access before the second DMA). Unit tests in `tests/test_board.py` hold the four cycle counts. **Games.** With `nba_lockstep.py --nba-model all` (the new `irq` part restores NBA's line) the board and NBA still agree instruction for instruction (Mystery Dungeon, 60,000,000). In the smoke set no picture changed but one: *James Pond - Codename Robocod*, the entry kept for its IRQ-timing race, shows its snowman screen one frame after NBA does (frame 795 for 794; mGBA draws half of it at 793), so the old script's last A fell on a different screen. The game runs as before; its script presses A for two more seconds and the checkpoint moved to frame 1,140. In the 57-game list every game still runs to the same place; two pictures moved (Super Mario Advance by a few pixels of a moving scene, Need for Speed Underground 2 in its race), and 124 of 154 checkpoint pictures equal NBA's (125 before), 44 of the 57 last ones (121 and 43 after the prefetch buffer of 2026-11-13). **Nothing in this family still fails.** ### Data stays on the bus (2026-11-12) The three `Bus` ROMs the board failed (C21) were not about what a DMA reads but about what is on the bus when it reads: each starts a DMA from an unused address right after a CPU load, and hardware copies the load's data. Rule (quirk 24): until the next opcode fetch, open bus is the last data cycle's bus: IWRAM's own 32-bit bus lane by lane, OAM's whole word, the Game Pak's 16 bits twice. alyosha-tas 104 -> 107 of 127 (`Bus` 6/6); jsmolka, Hades (`dma-latch` 4/4), hw-test and the mGBA suite (memory 1,552/1,552) unchanged; three seeded faults and a unit test. `nba_lockstep.py` has the part `data-bus` for NBA's rule. ### The prefetch buffer (2026-11-13) Traced cycle by cycle against the ROMs' expected timer values (each ROM measures several short stretches; `bounday_test_1` ships without source and was read from its disassembly), five rules, each one of the ROMs' cases (docs/timing.md marks them **(h)**): 1. **A branch onto a fetch the buffer has only now started, by a buffer that has never got ahead of the CPU, is the CPU's own N access** (readme: "the instruction fetch is done with non-sequential timing"). The earlier rejected try made every branch onto the fetch in flight N (alyosha-tas 63/127); "never got ahead" is what separates `prefetcher_branch_thumb_2` (needs N) from `_4` (an internal cycle first: waits). 2. **A branch past halfwords still in the buffer flushes it**, the fetch in flight too (`_thumb_3`: the stop penalty and an N fetch, 4 cycles, where the board had waited 1). 3. **The buffer holds halfwords in both states** (`_thumb_arm`: Thumb code after a `BX` from ARM reads the halves of the words ARM code buffered, five fetches at one cycle). NBA's ARM stop-penalty rule falls out of it. 4. **It pauses at a 128 KiB boundary** as when full (readme), tried and rejected before when the buffer counted opcodes. 5. **A buffer stopped at the boundary keeps its rhythm**: the CPU's fetch past it pays the stop penalty when it comes one cycle before a fetch would have landed. Four ROMs pin it: `prefetcher_boundary_1`-`4` push 1-4 registers before the fetch and read 52h, 52h, 54h, 54h. alyosha-tas 107 -> 114 of 127: `prefetcher/*` 17 of 18 (was 12; NBA 10), and with them `timing/prefetch_enable` and `irq/IRQ_sub_2_slow` (C22: its last nine cycles were the buffer). mGBA timing 2,020/2,020 and every other suite unchanged; six seeded faults. The lockstep part `prefetch` now swaps in NBA's whole buffer, and with it two games agree with NBA for 30,000,000 instructions each. `prefetcher_branch_thumb_arm_3` is listed as failing now although it scored a pass before: that pass was the ROM's own bug (C30). Games: the smoke set's pictures are unchanged (state and sound moved); in the 57-game list every game reaches the same place, and 121 of 154 checkpoint pictures equal NBA's (124 before), 43 of the 57 last ones (44): moving scenes a frame apart, now that the buffer differs from NBA's on purpose. Of alyosha-tas's 13 failures left, 8 are the serial port (no link partner), 2 `timer` and `dma_long` the prescaler's phase from the GBP's boot (C4), and 2 the prefetch buffer's `BX` from ARM to Thumb (C30). `timing/dma_long` was traced and is not a DMA fault: the 65,536-word transfer costs 458,754 cycles here as GBATEK counts it, and the verdict is a 1,024-prescaled timer read 36 cycles past a tick boundary (1C1h for hardware's 1C0h). The prescaler is a free-running divider whose phase comes from reset (docs/timing.md), the timer started at phase 1,002 of 1,024 after the retail BIOS's boot, and the test passes for any phase up to 233: it measures the boot it was calibrated on (the Game Boy Player's, C4), like `timer/timer` and `timer_reset`. ### Rung 3: the PPU, line-exact (2026-10-23; AGS 2026-10-25) The renderer (`src/gba_python/ppu/`): text, affine and bitmap BGs (modes 0-5, page flip), the OBJ engine a line ahead with its per-line budget (regular, affine, double size, 1D/2D mapping, semi-transparent, OBJ window; NanoBoyAdvance's pipeline, emulator-derived), WIN0/WIN1/OBJ window/outside, alpha blend, brighten, darken, BG and OBJ mosaic, forced blank, green swap. Each line is drawn whole at cycle 46 from the registers as they are then; affine reference points step or reload at cycle 0; DISPCNT's three-deep latch shifts and the OBJ engine evaluates the next line at cycle 40. The finished frame swaps in at line 227 -> 0, so a capture never mixes in the next frame's top line (found on Advance Wars' row 0). **Photograph and reference-image judges** (board frame after 400 frames, compared by eye, and pixel for pixel where the reference is a clean capture; tiers per C13): | ROM | Reference | What was compared | Result | | --- | --- | --- | --- | | hw-test `bgpd` | photograph | two dark-to-light gradient bands, black gap mid-screen, black strip at the bottom | matches | | hw-test `bgx` | capture, source unstated | white dot at (0, 0); white column at x = 130 from row 1 down; green field | matches | | hw-test `dispcnt-latch` | capture, source unstated | 13 text rows, BG0 hidden for its lines, white forced-blank band, the WIN0 rows, OBJ squares (a red/green checker, brown in the capture) back two lines after re-enable | matches | | hw-test `sprite-hmosaic` | NBA 1.8.2 screenshot | every pixel at 8x scale | equal except column 0 (the window's shading) | | hw-test `greenswap` | photograph | swap on about the left 88 dots, then normal stripes | **differs**: the board swaps the whole line (C16, rung 4) | **NanoBoyAdvance 1.8.3 as a detector** (`scripts/frame_diff.py --judges`, retail BIOS): 19 of 21 frames equal pixel for pixel and are the pass list `tests/frames_pass.txt` (run by `run_test_roms.py frames` and the slow tests): - jsmolka `ppu/hello`, `shades`, `stripes`; alyosha-tas `ppu/hello`, `shades`, `stripes`; hw-test `bgpd`, `bgx`, `dispcnt-latch`, `sprite-hmosaic`. - Game boots: Advance Wars @600 and @900, F-Zero Maximum Velocity @600 (title) and @1200, Golden Sun @1200, Castlevania Aria of Sorrow @900, Kirby Nightmare in Dream Land @900, The Minish Cap @900 (title), Mario Kart Super Circuit @900 (title art). - Differ, both mid-line writes (C16, rung 4): hw-test `greenswap`, alyosha-tas `ppu/stripes_x_offset` (rows 45 and 90). **Found while diffing, and settled (2026-10-23): the "one frame behind" was the referee's frame count, not the board.** In long game runs the board's frame f + 1 equalled NBA's frame f (Advance Wars from 680, Golden Sun before 780, F-Zero before 900). The lockstep (above) showed the CPUs keep identical time and state across the slip, so the picture was not late; the frame count was. `nba_driver` ran `Core::RunForOneFrame`, which is `Run(280896)` from wherever the previous call overran its limit (the last instruction, or a HALT stepping on to its next event), so its frame boundary drifted later every frame; the first 227 -> 0 wrap comes about 2,690 cycles after reset, and once the drift passed that, a run of N frames held N + 1 pictures (a counting build: 681 Draw calls after `--frames 680`, 801 after 800, on both games). The board's `run_frame` and mGBA's `runFrame` stop at the PPU's own wrap. `nba_driver` now does the same: a line at a time until its Nth Draw. With it, Advance Wars equals NBA at 680, 700, 900 and 1,200, F-Zero at 900, 1,000 and 1,200, Golden Sun at 600, 780, 900 and 1,200, and the pass list gains Advance Wars @900, F-Zero @1200 and Golden Sun @1200 (21 frames). No board change was needed for it; NBA's other differences (the table above) did not move a frame. The lockstep also found one board bug on the way: JOYCNT kept the flags the BIOS writes to acknowledge (C9), so the BIOS's JOY bus check saw three pending events. Fixed per GBATEK; the mGBA suite's "SIO register R/W" went from 25 to 31 of 90. **Regressions: none.** Full rerun with the renderer (retail BIOS, PyPy): jsmolka 10/10, alyosha-tas 85/121, hw-test 13/14, Hades 2/4, every mGBA suite group score unchanged. **Seeded faults: 19/19.** Four new for the picture: DISPCNT acting one line after a write (`dispcnt-latch`), forced blank still drawing (`dispcnt-latch`), affine reference points reloading every line (`bgpd`), an OBJ pixel in front waiting for the mosaic block (`sprite-hmosaic`). One rule has no judge here and is not seeded: the internal reference point does not step while its BG is disabled (NBA, "confirmed on real hardware"); no agreed frame depends on it. 20/20 since the JOYCNT fix (2026-10-23): JOYCNT keeping its acknowledged flags lowers the mGBA suite's "SIO register R/W" below its recorded 31/90 (a partly passing group is judged against its score in `tests/mgba_scores.txt`). **Speed** (Mario Kart Super Circuit's title art, 60 frames after 400; the machine was shared, load average 69-73 on 32 cores, so treat these as rough): CPython 3.14 0.136-0.159x real time with drawing switched off, 0.087-0.100x with it, so drawing costs about a third. PyPy 7.3.20 0.097x with drawing; its runs without drawing were slower (0.054-0.075x) under that load, so PyPy's cost of drawing is not measured. **AGS aging cartridges (2026-10-25): all five pass their automatic tests, LCD included**, with the retail BIOS (`run_test_roms.py ags`, `tests/ags_pass.txt`, slow tests). There was no menu procedure to script: a fresh AGS cartridge (v7.0, v7.1, v9.0, v10.0) finds its EEPROM blank, writes its defaults ("CHECK SUM ERROR! DEFAULT IS SAVED") and waits, and on the next power-on it runs the tests. `testrom.run_ags` does exactly that: power-on, keep what it saved, power on again. The older AGB Aging Cartridge opens on a SELECT TARGET menu instead (DOWN, DOWN, A for AGING CARTRIDGE) and leaves KEY INPUT blank with no keys pressed. | Cartridge | MEMORY | LCD | TIMER | DMA | KEY INPUT | INTERRUPT | | --- | --- | --- | --- | --- | --- | --- | | AGS v7.0, v7.1, v9.0, v10.0 | PASS | PASS | PASS | PASS | PASS | PASS | | AGB Aging Cartridge | PASS | PASS | PASS | PASS | (blank) | PASS | COM needs a link cable and stays blank on every one. Each run takes about 2 minutes (PyPy). This is a manufacturer test that passes on working hardware, but a coarse one: with v9.0 as the judge for all 24 seeded faults it catches 2, the EWRAM wait and the missing prefetch buffer (one is seeded against it, `seeded_faults.py`). Hades' result screenshot for v9.0 matches ours, except that Hades' title reads AGB where ours reads AGS. Not judged here: what follows PUSH START and the settings kept in the EEPROM; both are now judged by the `aging` suite (below, 2026-11-05). Hades' `ags_ppu_*` frames (the LCD UNIT CHECKER pages) are emulator-derived. The destoer PPU ROMs ran under rung 4. **AGS settings and the aging loop (2026-11-05): all five pass** (`run_test_roms.py aging`, `testrom.run_ags_aging`, `tests/aging_pass.txt`, slow tests), retail BIOS. How it is reached (found by running the cartridges, starting from Hades' `accuracy/suite.py`, whose AGS PPU test opens the same menu with L and R held at power-on): 1. Power on with L and R held: the AGS cartridges open AGS TEST PROGRAM, a MENU of CONFIGURATION, TEST PROGRAM (LCD UNIT CHECKER, FLICKER ADJUSTER, AGING CARTRIDGE, SELF TEST CARTRIDGE) and OPTION PROGRAM (KEY INPUT TEST). 2. CONFIGURATION is the page the cartridge keeps in its 512-byte EEPROM under a checksum (TARGET, TYPE, AGING TIME, and from v9.0 on AGING LOG). The run moves AGING TIME back one step (v7.x 03:00:00 to 02:30:00, v9.0 and v10.0 01:00:00 to 00:30:00), sets AGING LOG to YES where there is one, leaves the page (which writes it), switches the console off and on holding L and R, and reads the page again: it must come back as left. A page the cartridge cannot read back fails its own checksum and comes back as the defaults. 3. TEST PROGRAM, AGING CARTRIDGE: the automatic tests (as in the `ags` suite) end on PUSH START TO AGING. START begins the aging loop: test patterns and sound, and about every 2,600 frames a result screen that reruns MEMORY, LCD, DMA and INTERRUPT (TIMER and KEY INPUT show `---` and `--`). The judge is two rounds, each all PASS, with no "ERROR OCCURED!!". With AGING LOG on, each round writes a 16-byte record to EEPROM 100h on (seen: two records after two rounds; the record's layout is not read, so it is not judged). The older AGB cartridge has no settings page: its loop starts from SELECT TARGET (DOWN, DOWN, A), and two rounds pass. Each run takes 5-12 minutes (PyPy) depending on load. As a judge for the 28 seeded faults (v10.0) it catches the same two rules the automatic tests do, the EWRAM wait and the missing prefetch buffer (both stop it before PUSH START TO AGING): the aging rounds rerun the same tests. What it adds is the EEPROM rewrite, seeded as its own fault (`seeded_faults.py`, 29 in all): an EEPROM that ORs a rewritten block into the old one instead of replacing it passes the `ags` suite (its defaults land on a blank chip) and fails here (the changed page fails its checksum and comes back as the defaults). | Cartridge | Settings kept across power-off | Aging loop, 2 rounds | | --- | --- | --- | | AGB Aging Cartridge | (no settings page) | PASS | | AGS v7.0, v7.1 | AGING TIME 02:30:00 | PASS | | AGS v9.0, v10.0 | AGING TIME 00:30:00, AGING LOG YES | PASS | There is no separate backup test on these cartridges: the strings in the ROMs name the EEPROM only in "EEPROM IS NOT AVAILABLE!" and the checksum message, and the settings page and the aging log are what the EEPROM holds. SELF TEST CARTRIDGE runs the LCD UNIT CHECKER pages (operator-judged, one key per page), then the automatic tests, then asks for a link cable and a second console (AGB-005) for COM: not run. **Can the end of the aging loop be judged?** Not in a useful time. AGING TIME moves in 30-minute steps; the shortest non-zero setting is 00:30:00 of emulated time (108,000 frames, about 40 rounds). 00:00:00 is accepted too, and what it means was not established (a run with it showed rounds as usual). A run with 00:30:00 was stopped after 7,650 frames (three rounds, all PASS, no error) at about 3 frames a second on the loaded machine: reaching the end would take about ten hours here, and what the end screen shows is not known. The rounds are the judge. ### Rung 4: the PPU, dot-exact (2026-10-23) — in progress The engines (`src/gba_python/ppu/`), each run lazily up to the present: - `dot.DotLine`: the BG and merge engines cycle by cycle on NanoBoyAdvance's schedule (emulator-derived): text map and tile fetches placed by the fine scroll, affine and bitmap fetches per dot, the merge choosing each dot's layers and reading the palette at 46 + 4x, blending at 48 + 4x, green swap per pair. Everything is read when used. - `objects.Engine`: the OBJ engine a step (two cycles) at a time across its window, as a resumable machine (state saves pickle it); a step while OBJs are disabled stands still. - The window engine: a dot every four cycles from cycle 0 to dot 255, reading WINxH as it goes. - Waits (quirk 18): a palette, VRAM or OAM access by the CPU or a DMA repeats any cycle in which the merge (palette), the BG engine (BG VRAM) or the OBJ engine (OAM, OBJ VRAM) read the same memory (NBA `Bus::ReadVRAM` and friends). A visible line moves to the dot engine when a display register, palette or BG VRAM write lands while the line is drawn, or a CPU/DMA access needs the engine's fetch schedule for its wait; every other line keeps the line renderer (rung 3), drawn at HBlank. In game boots that is about one line in 160 (0.8-1.8 per frame on Advance Wars, Golden Sun, F-Zero, Kirby, 600 frames each; nearly all for a CPU VRAM access's wait). **The two renderers agree.** `GBA_PPU_EXACT=1` runs every visible line on the dot engine: the 10 test-ROM frames of the pass list and four game boots (Advance Wars @600, Castlevania @900, Kirby @900, Mario Kart @900) give the same frame hashes as the line renderer. **Judges:** | ROM | Tier | Result | | --- | --- | --- | | hw-test `ppu/greenswap` | photograph | the swap on the left part of the line, normal stripes after it: equals NBA's frame, which matches the photograph (C16 settled); in the pass list | | alyosha-tas `ppu/stripes_x_offset` | alyosha-tas picture (BG0HOFS written in lines 45 and 90) | equals NBA's frame; in the pass list | | alyosha-tas `ppu/Sprite_Last_VRAM_Access` | hardware-calibrated r12 (OBJ VRAM wait, normal mode) | pass (was 141, the timer one tick short) | | alyosha-tas `ppu/Sprite_Last_VRAM_Access_Free` | hardware-calibrated r12 (OBJ VRAM wait, HBlank free) | pass (was 119): needs the OBJ window cut at 960 cycles, not NBA's 964 (C17; NBA gives 121) | | alyosha-tas `ppu/start_up`, `start_up_vbl`, `start_up_vbl_irq`, `start_up_vbl_irq_halt` | hardware-calibrated r12 | pass (they passed before; now in the alyosha suite) | | destoer `lyc_midline` | photograph (a 3DS in GBA mode) | every value equals the photograph's: start 7, end 3F, vcount 24; rapid toggle start DC0B, end E0AA, lyc count 6 | | destoer `window_midframe` | expected screenshot (Powerlated's; source unstated) | equal pixel for pixel; also equal to NBA's | | destoer `line_timing` | none (raw values) | every row 3EC, as NBA's | | alyosha-tas `ppu/Sprite_Disable_Midline`, `Sprite_Disable_on_VRAM_Access` | visual, no reference | equal to NBA's frames (a detector only) | | hw-test `ppu/ram-access-timing` | none | an interactive probe that draws its measurements; ships no reference, so not run as a judge | The alyosha-tas suite now takes the `ppu` ROMs whose own source ends in `m_test_eval`, less the two `Sprite_Disable_*` that never finish: 127 ROMs (121 + 6). **NanoBoyAdvance as a detector.** Lockstep against the stock `nba_trace` (its waits on), every NBA part switched (`--nba-model all`, which now includes `obj-free`) and R0-R14 compared: Advance Wars and F-Zero Maximum Velocity agree on all of their first 40,000,000 instructions. The check reaches the waits: with the board's waits switched off, Advance Wars parts from NBA at instruction 28,471,963 (frame 566, line 50: five cycles early). **Regression: one, recorded, not fitted.** alyosha-tas `Interactions/Halt_DMA_IRQ_Read_OAM` (GBP-calibrated, C4) passed with no OAM waits and gives 223 with NBA's OAM schedule (hardware 221); its verdict also moves with the BIOS (C18). Everything else as before (retail BIOS, PyPy): jsmolka 10/10; alyosha-tas 90/127 (85/121 before, plus the six `ppu` ROMs, less that one); hw-test 13/14; Hades 2/4; every mGBA suite group score unchanged; frames 21/21 (the 19 of rung 3 plus `greenswap` and `stripes_x_offset`); NBA's r12 and suite referee runs are unchanged by the frame-count fix in `nba_driver`. **Seeded faults: 23/23.** Three new: register writes during a line reaching the whole line (no dot engine; `greenswap`), CPU accesses to OBJ VRAM never waiting (`Sprite_Last_VRAM_Access`, r12 141), the HBlank-free OBJ window at NBA's 964 cycles (`Sprite_Last_VRAM_Access_Free`, r12 121). Not seeded: the BG VRAM and palette waits, which no hardware judge here measures. **Speed** (Mario Kart Super Circuit's title, 60 frames after 400, old and new run at the same time; load average 40-55 on 32 cores, so rough): no measurable cost on a screen without mid-line changes (CPython 0.065-0.066x real time before, 0.066-0.075x after; PyPy 0.061-0.079x before, 0.054-0.082x after). Every line on the dot engine (`GBA_PPU_EXACT=1`) costs about 30 % (CPython 0.036x -> 0.025x, PyPy 0.049x -> 0.038x), which is what keeping the line renderer for unchanged lines buys. **Not settled here:** the BG and palette waits have no hardware judge (NBA's lockstep only); the OBJ engine's attribute-fetch schedule is NBA's model (C18 shows it off by a cycle or two in one case); whether the attribute fetcher also stops at 960 cycles in HBlank-free mode (C17). ### Rung 5: sound (2026-11-11) — in progress **Built.** `apu.py` hosts the `gb-apu-python` core's AGB row (pinned `b8cab61`): the register map, the clock, the frame sequencer's edges, the two FIFOs, the mixer, SOUNDBIAS; `python -m gba_python ROM --wav out.wav` writes a run's sound. The GBA's differences in the channels are the core's (two wave banks as a shift register, the 64-digit ring, the forced 75 %): 9 seeded faults there, its 94 DMG and CGB streams unchanged. **alyosha-tas `fifo_dma`: 7 of 9** (was 4; mGBA and NanoBoyAdvance 6 of 9 each when measured for Phase 0), and both `unsafe/fifo_dma_disable_jam` ROMs still pass. `fifo_2`, `fifo_3` and `fifo_4` needed a FIFO's DMA request to take three cycles, not the two of every other start condition. `fifo` (test 2) and `fifo_6` (test 122) still fail: C28. **Against NanoBoyAdvance 1.8.3, on commercial music** (`scripts/sound_diff.py --games`; a detector). Both machines mix a sample every 512 cycles from power-on, so the WAVs compare index for index. From the cartridge's entry (`skip_bios`), 20 to 25 seconds each: | Game | Game Boy channels heard | level | envelope | equal | near | |---|---|---|---|---|---| | Pokemon Emerald | pulses 1, 2 | 0.994 | 0.9950 | 35.6 % | 54.2 % | | Mario Kart: Super Circuit | pulse 2, wave | 0.998 | 0.9998 | 45.2 % | 63.1 % | | F-Zero: Maximum Velocity | pulses 1, 2 | 0.997 | 0.9993 | 59.2 % | 78.7 % | | The Minish Cap | pulses 1, 2, noise | 0.989 | 0.9993 | 74.1 % | 84.7 % | | Metroid: Zero Mission | noise | 0.997 | 0.9993 | 38.4 % | 79.3 % | | Golden Sun | pulse 1 | 0.997 | 0.9999 | 39.0 % | 76.2 % | | Kirby: Nightmare in Dream Land | none (FIFOs) | 0.995 | 0.9999 | 58.5 % | 86.0 % | | Advance Wars | none (FIFOs) | 0.994 | 0.9958 (one point over) | 14.0 % | 14.0 % | - **level** is the board's RMS over NanoBoyAdvance's across the seconds that sound: within about 1 % on every game. The mixer's scales (PSG 25/50/100 %, NR50, FIFO 50/100 %, the bias) are therefore NanoBoyAdvance's. - **envelope** is the correlation of the two loudness curves in 1/64 s steps: the same music at the same moments. Advance Wars starts its music a frame later on one machine (a known kind of difference: docs/validation.md rung 3), so its curve fits one step over. - **equal** and **near** count identical samples, and samples within one 10-bit step at the best lag of +-16. They fall as the two machines' cycle counts drift (a FIFO sample lasts about 2.5 mixer samples, so a shift of a few hundred cycles moves many boundaries). They are printed to be watched, not met: the board differs from NanoBoyAdvance on purpose in places (rungs 1 and 4). - All eight games set SOUNDBIAS to 65,536 Hz, so the averaging to 32,768 Hz is in every row. What this does not judge: the phase of the frame sequencer, the wave channel's shift register and 64-digit order, the DC level of the Game Boy channels (C25, C26). There is no hardware recording here to compare with. **Regressions: none.** Full rerun (retail BIOS, PyPy): jsmolka 10/10, alyosha-tas 93/127 (90 plus the three `fifo_dma` ROMs), hw-test 13/14, Hades 2/4, mGBA suite scores unchanged, frames 21/21, AGS 5/5, aging 5/5, ARMWrestler, FuzzARM, krom 25/25 (its seven sound-driver BIOS calls among them), retAddr, keyirq 13/14, Backup LIB 9/12. Smoke set, 39 ROMs: no picture changed. The state digest moved in 19 ROMs, which the FIFO request's extra cycle explains (every refill DMA holds the bus a cycle later), and every sound digest is new; the baseline was re-recorded. **Rules without a hardware judge are held by unit tests** (`tests/test_apu.py`, 13) with a seeded fault each: `scripts/seeded_faults.py` has 13 sound faults (the FIFO request delay against `fifo_2`, the rest against their unit test), all caught. **Cost.** The channels are caught up lazily; with all four playing the core takes about 1.2 s of CPython per second of sound, beside the board's ten. **The last two `fifo_dma` ROMs (2026-11-11, later): 9 of 9.** `fifo.gba` needed a request that arrives during a refill to make the channel read a fifth word and leave three for the next one; `fifo_6` needed a DMA's IRQ a cycle after its last write (C28, where the first is marked as a fit to that ROM's five hardware numbers). Full rerun: alyosha-tas 95/127, every other suite as above. Seeded faults for both rules are caught. **The first rule narrowed (2026-11-12).** A lockstep of *Pokémon Mystery Dungeon* with NanoBoyAdvance found the fifth word read where no refill was under way: the game's 32,768-cycle DMA0 holds the bus while two timer overflows ask for the same FIFO's DMA, and the board counted the second request as one "during a refill" although the first was still waiting. The fifth word is now read only when the refill is moving words (C28); `fifo.gba` still passes, a unit test and a seeded fault hold the difference, and every suite scores as before. In the smoke set and the games list no picture changed; the sound of five entries did (both WarioWare games, Tactics Ogre, Final Fantasy Tactics Advance, Mystery Dungeon). **Not done:** a hardware recording as a judge. ### Rung 7: games and the window (2026-11-11) **The games list.** `tests/games_set.txt` holds 57 commercial games that are not in the smoke set, chosen across the save census (21 EEPROM, 19 SRAM, 14 Flash, 3 without a save; one with the cartridge clock) and across the picture modes (text, affine, the mode 4 3D engines). Each starts at the cartridge (`skip_bios`) and runs 3,600 or 5,400 frames with START and A pressed in turn; `scripts/smoke.py --set tests/games_set.txt --nba --dump DIR` runs them and NanoBoyAdvance 1.8.3 with the same keys and keeps both pictures. Every last picture was looked at beside NanoBoyAdvance's, and the list says what it shows: - **56 of 57 are in the game**: in a level, field, match or story scene past the title and setup screens. The first pass used one two-button script for all and left 10 at a setup screen; nine of those now have a script of their own (a direction at a menu or a Yes/No prompt for six, a longer run for three), worked out on NanoBoyAdvance and then run here. The one left is *Rhythm Tengoku*: a new save begins with a timing test, the script's A on the beat passes its first part, and the second part (A at each zero of a countdown) starts the test over when the presses are late. Nothing looks wrong on it. - **No crash, no hang, no blank or broken picture** in any of the 57, and all 57 make sound. - **Against NanoBoyAdvance (a detector):** 121 of the 154 checkpoint pictures are identical pixel for pixel, 43 of the 57 last ones. Of the rest: - *Sonic Advance, Sonic Advance 2, Stuntman, V-Rally 3*: NanoBoyAdvance stops at a blank panel, a red screen or a black one, and the board plays the game. NanoBoyAdvance does it only with its own BIOS skip: booted through the retail BIOS it runs Sonic Advance and Stuntman to their language menus (tried here). So the difference is the state its skip leaves, not the board; what the games test was not looked for. - *Pokémon Ruby*: NanoBoyAdvance's driver has no cartridge clock, so the two part ways. - *Need for Speed Underground 2* and *Pokémon Mystery Dungeon* play on both but take different turns once the scripts reach their menus: the board is in a drift event and NanoBoyAdvance in a circuit race; the personality quiz gives the board Bulbasaur and NanoBoyAdvance Squirtle. A few cycles of difference move the frame a key is read in, and that is enough. - The others differ by a few percent of pixels in moving scenes (Super Mario Advance, Astro Boy, Tetris Worlds, Top Gear Rally, Max Payne, Densetsu no Stafy): a frame or so apart after a minute of play. - **Where those eight start (2026-11-12):** `scripts/first_frame.py` finds the first picture that differs and `scripts/nba_lockstep.py` the first instruction. With the board's known differences from NanoBoyAdvance switched to NanoBoyAdvance's side (`--nba-model all`: the HALT wake-up, the prefetch buffer, the ROM mirror, the FIFO request's third cycle and the rest), all eight agree with it instruction for instruction, cycle for cycle, over 400,000,000 instructions each. So the drift is those documented differences and nothing new; the one new thing the lockstep found was the FIFO rule above, in Mystery Dungeon. - The two Castlevania dumps from the Castlevania Advance Collection stay blank on both emulators; the list uses the cartridge dumps. `tests/games_baseline.txt` records each checkpoint's picture, state and sound digests (and NanoBoyAdvance's picture), so the list is also a second regression set: a run of all of it took 92 minutes at `-j 24` on a loaded machine. **The window.** `python -m gba_python play ROM` (`frontend.py`, the `frontend` extra: pygame-ce) is gameboy-python's window on this board: the picture scaled by SDL, the mixer's 32,768 Hz stereo to the sound card, keyboard and game controller (L and R on A/S and the shoulders), pause, fast forward, screenshots, the save chip in `NAME.sav` (raw, as mGBA and NanoBoyAdvance write it), the whole console in `NAME.state`, the cartridge clock from the PC's. `tests/test_frontend.py` (6) holds the conversions, the save and state round trips, and a window driven headless through SDL's dummy drivers. Driven that way on Advance Wars from the retail BIOS it drew the game and queued its sound. **Not done:** nobody has played it at a screen with speakers yet (this machine has neither), so the window's feel and the sound to the ear are unjudged. Speed is not a goal here: PyPy runs the board at about 10 frames a second on an idle core, a sixth of real time, so sound plays in short bursts; playing at speed is the `-fast` fork's job. ## Smoke set (2026-10-24): a fast regression detector over commercial ROMs `tests/smoke_set.txt` lists 39 commercial ROMs, read in place from the local No-Intro tree and never copied, in three groups: - **Known problematic (16):** an emulator author recorded a fix or a failure for each, with the source given on its line. The sources are mGBA's `overrides.c`, `CHANGES` and issues; NBA's `game_db.cpp` and `rtc.cpp`; SkyEmu's README and `gba.h`; ares's `ppu.cpp`; and the mgba.io posts on the Classic NES Series and the DMA latch. - **Must-have classics (17).** - **Interesting hardware (6):** rumble, gyro, tilt, the solar sensor, mode 4 page flipping, and a 32 MB GBA Video cart streaming into mode 3. Together they cover every save type the board detects (SRAM, Flash 64K/128K, EEPROM, none) and the RTC. Titles suggested for the set but dropped, because no source names a problem with them: - Pinball of the Dead, Starsky & Hutch, V-Rally 3 and Need for Speed: no source found. - Kirby & the Amazing Mirror: the only record is a multiplayer bug (mgba.io/i/3295). `scripts/smoke.py` runs each entry in its own PyPy process. At each checkpoint it records three digests: - **picture:** `screen_hash`, the same hash `tests/frames_pass.txt` records; - **state:** the CPU's registers and CPSR, EWRAM and IWRAM. These move on a timing change frames before the picture does; - **sound:** every sample the mixer has put out so far (the Game Boy channels and both FIFOs through SOUNDCNT and SOUNDBIAS; until rung 5 it was the FIFOs' samples only, so every sound digest was re-recorded then). It compares them with `tests/smoke_baseline.txt`, the board's own output at a recorded commit. A change therefore means "look", never "wrong": the set is a **detector**. A deliberate change is accepted with `--record`. Run conditions: - Entries start at 8000000 from `skip_bios`, unless their line says `bios`. The boot animation is 273 frames, the same for every cartridge. Two entries boot through the retail BIOS: Robocod, which is in the quick tier, and Advance Wars. - The RTC starts at a fixed date. - Keys are scripted where a title screen or a health warning would stall the run. Wall clock on this machine (32 cores, other load average about 40, PyPy, `-j 16`): | Run | Entries | Time | | --- | --- | --- | | `--quick` (the `q` checkpoints) | 11 | **3.3 min** | | the whole set | 39 | **13-19 min**, including NBA | A second whole-set run against the recorded baselines passed 39/39, so the digests repeat from run to run. **Against NanoBoyAdvance 1.8.3 (`--nba`, a detector):** at baselines from `024d865`, 55 of 59 checkpoint pictures equal NBA's. The four that differ: - **Boktai @720, Sennen Kazoku @360 and @720:** RTC games. `nba_driver` attaches no GPIO, so NBA runs them without a clock. These are expected. - **Fire Emblem @720:** 5 pixels differ, all in column 12 on alternate lines 133-141. The board's blue there equals NBA's from two lines higher. **Explained (2026-10-25): the board's HALT-wake rule, quirk 23.** The game's HBlank handler writes BLDALPHA on odd lines at line cycle 96, the cycle the merge blends dot 12; on the board the write lands just after that blend, on NBA just before. With `nba_lockstep.py --skip-bios --nba-model all` the two agree on all of the first 90,000,000 instructions (frame 720 is about instruction 44,300,000), and the board's frame 720 equals NBA's with only `halt-wake` (now part of `irq`) switched to NBA's behaviour (`prefetch` alone does not move it). Quirk 23 is judged by hardware-calibrated alyosha-tas `irq/halt_pc*` tests (quirk 23), which NBA's rule fails, so the board's picture stands: this is NBA's error, not the board's. No change. `nba_driver` gained `--skip-bios` (NBA's SkipBootScreen) for these runs. **Found by building the set:** - **`skip_bios` leaves BG2/BG3 PA and PD at 0.** The retail BIOS leaves them at 100h, and NBA sets 100h at power-on (`ppu.cpp` Reset). As a result Doom and Pinball Tycoon drew one colour where they should show a picture. - Fixed in the board (C19): `skip_bios` now leaves every register the retail BIOS leaves, judged by booting the BIOS on the board to the cartridge (`test_skip_bios_leaves_what_the_bios_leaves`). `smoke.py`'s own 100h writes are gone. The forced-blank DISPCNT the BIOS leaves (no PPU waits until the game first writes DISPCNT) moved the state digest, never the picture, of three entries: the Classic NES Series, Famicom Mini 22 and Star Wars Episode II. Each was checked to come back with DISPCNT alone left out, then re-recorded. - No entry crashed or hung, and Hello Kitty (DMA latch), the Classic NES Series (anti-emulation) and Sennen Kazoku (24-hour RTC) all boot. ## More suites (2026-11-04): ARMWrestler, FuzzARM, krom, retAddr, keyirq, Backup LIB Six suites were added to `scripts/run_test_roms.py`, each with a pass list the slow tests replay. They start at 8000000 (`skip_bios`) and use the retail BIOS: none of their verdicts depends on the boot, and krom's measure the BIOS's own timing. Three spot checks booted through the BIOS (krom DIV, CpuSet, LZ77) gave the same counts. | Suite | Tier | Result | Wall clock (PyPy, loaded) | | --- | --- | --- | --- | | `armwrestler` (8 pages, 79 rows) | 1 (by report) | **79/79 OK**, 8/8 pages | about 50 s a page | | `fuzzarm` (5 ROMs × 10,000 tests) | 3 (generator's model) | **5/5**, no failure dumps | 100-155 s a ROM | | `krom` (25 BIOS calls, 106 checked lines) | 1 (author's hardware) | **25/25**, every result and Timer 0 count | under 30 s a ROM | | `retaddr` | 2 (the data sheet's rule) | **pass**: LR_irq offset 0 in ARM and Thumb | seconds | | `keyirq` (14 steps) | 3, steps 2 and 12 by GBATEK | **13/14** after the KEYCNT fix below (was 12/14) | seconds a step | | `backuplib` (4 chips × 3 patterns) | 1 (manufacturer code) | **12/12** (9/12 until 2026-11-13: EEPROM failed all three, C24, fixed by ending an unfinished command with its transfer) | 10-60 s a run | How each verdict is read: - **ARMWrestler** draws its text into the mode 4 frame with its own font. `testrom.bitmap_text` matches every 8×8 cell against `data/font8x8.pat`'s glyphs (lit pixels, any colour), so no picture comparison is involved. Keys are held six frames: its loop polls once per pass, and a pass takes longer than a frame. - **FuzzARM** writes `AAAA`/`TTTT` and the failing test's registers to EWRAM and waits for a key. The runner records the dump, presses A and runs to the final branch to itself. - **keyirq**'s console is a text buffer at 2000000h (the shim's `puts`/`iprintf`). The runner holds what each prompt asks, changing keys only when the prompt changes. - **Backup LIB**: the menu entry for the chip, the pattern keys (UP twice for 00FF, DOWN twice for INC, checked on screen), then A. The ROM carries all four libraries' ID strings, so the chip is chosen with `save_type`. Its DACS entry (a development flash chip) is not run. **Judges can fail** (one-off seeded faults, not in `seeded_faults.py` because they live in the core, which the harness does not copy): - RRX shifting in 0 instead of C: ARMWrestler `ARM ALU 1` shows `ORR BAD Rd`. FuzzARM generates no RRX and passes it. - Thumb ADC ignoring C: FuzzARM `THUMB_DataProcessing` reports 379 failures. ARMWrestler's Thumb ALU page passes it. Board faults added to `seeded_faults.py` (28 now): - BIOS reads at 2 cycles: krom DIV 6/8. - Flash byte program doing nothing: Backup LIB `flash128#INC`. - KEYCNT AND needing exactly the selected keys: keyirq step 2. A Flash 128K bank switch that does nothing is *not* caught by Backup LIB, because it verifies each sector right after writing it; jsmolka `save/flash128` covers banks. **Fixed:** KEYCNT's AND condition now asks that every selected key be down, not exactly the selected ones (GBATEK "Keypad Input"; keyirq steps 2 and 12). NanoBoyAdvance, which the board followed, has the exact match. **Read and not added:** | Program | What it is | Why not | | --- | --- | --- | | DUST | about 170 display and DMA pictures | needs gba-toolchain's `librom`/`gba-hpp` to build; no expected images | | PeterLemon `Sound/` (3) | BRR and PCM playback demos | no verdict; sound is rung 5 | | GBA-Test-Collection `helloWorld`, `helloAudio` | demos | no verdict | | "Backup Mem. Quick-Copy" (No-Intro, v1.04) | a save copier by NOE (Michael Buchholz, 2003) for a flash board with a sub-cartridge | needs that hardware | | "SN Systems (Test Program) (Unl)" | a 32 MB ROM showing mode 4 pictures (a development kit demo) | no verdict; boots on the board | | "Farbe (Proto) (Test Program)" | backdrop colour cycler: black, white, red, green, blue with A/B (an LCD test) | no verdict | | "AGB-Parallel Interface Cartridge" | Intelligent Systems' IS-AGB-CHARACTER interface | needs the development hardware | The pinned Arm toolchain includes `arm-none-eabi-objdump`, used here to read the Backup LIB and Farbe code. Full rerun after the KEYCNT change (retail BIOS, PyPy): jsmolka 10/10, alyosha-tas 90/127, hw-test 13/14, Hades 2/4, every mGBA group at its recorded score, frames 21/21, aging cartridges 5/5, seeded faults 28/28, smoke set 39/39 (21 min wall under load).