# Validation: every oracle, its tier, and the plan ## Oracle tiers The family's rule: rank an oracle by **where its expected values came from**; a lower tier detects, the highest tier that covers a claim decides it. Order of authority for a disputed point: **a console result > fullsnes/anomie > two emulators agreeing > MAME**. For this chip "two emulators agreeing" needs care: byuu's model is read in its ISC form, ares (bsnes, the same core, is GPL-3 and a closed box); Mesen2 is a closed box whose behaviour is OBSERVED by running it; the MiSTer Cx4 has no licence and is not used; MAME and snes9x are high-level emulation that never executes an HG51B instruction, used as closed boxes. | Tier | Meaning here | What exists | | --- | --- | --- | | **hardware-captured** | values recorded from a real HG51B169 | **none** (searched 2026-11-06: no per-instruction capture, no logic-analyser trace, no published timing; fullsnes "100% unknown") | | **hardware-designed self-test** | a check written by the chip's programmers to pass on production hardware | the games' **built-in Cx4 test**: hold controller 2 B at power-on (Mega Man X2/X3, Rockman X2/X3, all versions surveyed); 8 items, each "OK." (below) | | **manufacturer** | Hitachi's documents | **none found** (no HG51B data sheet or manual is known) | | **program** | what the shipped program needs to make sense | the 4,096-word program at 02:8000-9FFF (one version for X2/X3 retail, two words apart; an earlier one in the Rockman X2 betas): survey in timing.md | | **research** | community documents from hardware study and the program | fullsnes "SNES Cart Capcom CX4" (Nocash; it cites decapping for the part number); the HLE authors' findings where published in prose (zsKnight, anomie, Nach, Overload; their code, snes9x `c4*.cpp`, is a closed box); the data ROM formulas (U21) | | **die** | a netlist or die model | **none** (decapped for identification only) | | **emulator** | values an emulator produced | **Mesen2 2.1.1 LLE** (closed box, runs here: screens, per-instruction traces, host stream, probe cartridges), **ares LLE** (ISC, read, not built), **MAME 0.285 HLE** (closed box, runs here: screens and host stream at command level), snes9x HLE (closed box) | ### What does not exist (searched 2026-11-06) - **No SingleStepTests-style corpus** for the HG51B. - **No hardware test ROM with recorded console results.** Overload's `cx4test` (SNES Central article 1116, updated 2017, source included) tests emulation; SNES Central shows it passing in higan and says it needs the Cx4 ROM appended; nothing says it was run on a console or records a console's output. It is a probe, not a judge; not fetched (BYOR: it is a ROM image; open decision 9). - **No timing measurement**, no Hitachi document, no die trace. - **No console route here**: Aubrey's Super EverDrive X5 cannot host a Cx4 (the chip is on the cartridge), and FXPak's Cx4 is an FPGA model (emulator tier). A real Mega Man X2/X3 cartridge runs only its own code, but it *does* run the built-in test on a console (the test's purpose); Aubrey owns a Super Famicom, so **Rockman X2/X3 on that console with controller 2 B held would show the test's screen on hardware**: a console run of the self-test, if Aubrey has (or gets) the cartridge (open decision 10). So: the instruction set has research and emulator tiers only; whole computations have the game's self-test, and the data ROM has a real dump reproduced by formula. ## The oracles ### The game's built-in Cx4 test: hardware-designed self-test - **Entry**: controller 2 B held while the console powers on (snes-python `docs/cartridge.md` row 4; TASVideos "SNES accuracy tests"). Measured 2026-11-06: MAME 0.285 (`--press "0:P2 B:170"`) and Mesen2 2.1.1 (the debugger input override on port 2) both reach it by frame 200 on Mega Man X2 (USA); Mesen2 also on Mega Man X3 (USA) and Rockman X2 (Japan). - **Screen**: title "Cx4 TEST", items INTERFACE REGISTER, REGISTER FILE, DATA RAM, LDMAC, DOWN LOAD, MALU, IMMEDIATE REGISTER, IMMEDIATE ROM, each "OK."; "PRESS BUTTON TO EXIT". Both emulators show eight "OK." (the strings are ASCII at ROM 0x315C2 in X2 USA; the "OK."/failure glyphs are tile codes, not ASCII: the failure text is to be read from the test code). - **What each item exercises** (MAME host log of the test, 200 frames): - INTERFACE REGISTER: S-CPU writes and reads back $7F49-$7F4B, $7F50-$7F52, $7F6A/$7F6B, $7F6E/$7F6F. - REGISTER FILE: every byte of $7F80-$7FAF written and read (and the sixteen 4-word programs 0E:00-0E:3C that set R0 to 0-15). - DATA RAM, LDMAC: 768 DMAs of 2 KiB (the whole ROM, 008000h-2FF800h) into data RAM, each followed by 0E:40 (sum of the first 2 KiB of data RAM). - DOWN LOAD: 802 cache preloads alternating cache pages 0 and 1. - MALU: sixteen 0E:54 (R1:R2 = R0 x R0). - IMMEDIATE REGISTER: 0E:5C (the 16 constants written to data RAM). - IMMEDIATE ROM: 0E:89 (R0 = byte sum of the data ROM = 054336h, R1 = FFFFFFh, the game's own check). - **What it can and cannot see**: results, not mechanism. MAME's HLE, which runs no instruction and ignores cache loads, passes all eight, so a pass does not prove the cache, the timing, the stack, C1, C2 or C6. A failure, however, is a real error. The judge is coarse and one-sided. ### The data ROM: a real dump, and formulas that reproduce it MAME's software list names the image `cx4.bin` (3,072 bytes, CRC b6e76a6a, SHA-1 a002f4efba42775a31185d443f3ed1790b0e949a; also `cx4.u2`, `cx4.u3`, `cx4.ic2` in other entries of `hash/snes.xml`, CC0), a dump of a real chip. `data_rom.py` computes it from fullsnes' formulas with truncation, and the result's SHA-1 **is the dump's** (U21; `tests/test_data_rom.py`). `scripts/check_data_rom.py` compares a player's own copy byte for byte (`HG51B_DATA_ROM`, or found through `MAME_ROMPATH`: the software-list game sets that carry it). None is on this machine. (The earlier survey script parsed emulator copies of the table out of GPL and unlicensed files; it was withdrawn in Wave 2.) ### fullsnes: research - Pin: `problemkaputt.de/fullsnes.txt` as served 2026-10-21, SHA-256 `d79dbec9...` (snes-python's copy, satisfied in place). - Lines 8468-8766: memory map, the data ROM formulas, PCBs, header, I/O ports (many marked unknown), the opcode table (several "-" and "??"), the program's function table with the test entry points; 22773 the crystal; 24115 the pinout. - Use: the data ROM (U21), the I/O map, the program's entry points, the contradictions it raises itself (C4: 8 vs 16 stack levels; C6: the nop rule). ### Mesen2 2.1.1 LLE: emulator, closed box, the lockstep detector - a `MesenCore.so` built from the pinned `b9fa69dd` (mesen2-runner's `build.sh`, or `MESEN_CORE`), its source never opened, driven through ctypes by the GPL tool mesen2-runner 0.2.0, `$EMU_TOOLS_GPL/tools/mesen2/run.py --machine snes-cx4` (emu-tools-gpl; run as a separate program, [mame-oracle.md](mame-oracle.md) "Mesen2"; until 2026-11-24 through the old harness command line `tools/hg51b-python/mesen_cx4_trace.py`, a shim over it). Every value from it is OBSERVED (Mesen2 b9fa69d via mesen2-runner 0.2.0). Runs the test (all "OK."), traces the Cx4 per instruction (the trace logger API; Lua exec callbacks do not fire for the Cx4), and its Lua write callbacks see every S-CPU write to the Cx4 window (802 program starts in 200 frames of the test, as on MAME): **a host stream plus an instruction trace from one emulator**, enough for a replay. - `scripts/cx4_probe.py` (Wave 2) builds homebrew Cx4 cartridges, a few words of HG51B program each, and records Mesen2's trace and host stream for them; `tests/ test_mesen_probes.py` replays the 20 recordings. Differences OBSERVED from ares: C1, C2, C3, C4, C7, C8, C9, C10, C11, C13, C17, C18 (undocumented-behavior.md quotes each). A trace divergence is classified by C entry; Mesen2 is not a judge. - **Moved to mesen2-runner 0.2.0 (2026-11-24).** `cx4_probe.py` and `record_mesen_windows.py` run `run.py --machine snes-cx4 --trace cx4-text,host --trace-window START:END` (with `--hold-test` and `--input` where the windows need them) in place of the old harness command line. The gate: before (HEAD `5826506`, the shim, `MESEN_CORE` naming the runner's own build) and after (`run.py`, the same library, SHA-1 `b24ea01b`), all 20 probe recordings and all five windows: every `cx4.trace.gz` identical, every `host.txt.gz` identical up to the last requested frame (the shim's ran 1 to 28 rows past it on 7 of 25 recordings; `run.py`'s now end there), and `cx4_probe.py`'s replay summaries identical line for line. The before side also matched the November recordings it replaced, file for file up to the last requested frame. X2's test screen at frame 300 (`--hold-test --frames-out`) is the same picture; X2's title press is the same trace, stream and picture with an input record at the old press frame (mame-oracle.md "Mesen2"). Quick loop 155 passed, 1 skipped; `-m slow` on PyPy (the Mesen2 replays of the new recordings) 8 passed. OBSERVED (Mesen2 b9fa69d via mesen2-runner 0.2.0); it shows the new command line reproduces the old recordings, nothing more about the hardware. ### ares LLE: emulator, read (ISC) byuu's model; the default for most C entries because it is the only readable one with the S-CPU side (U16). Its "verified" comment (`registers.cpp` l.62) is a program comment, not a published measurement: U5 is provisional. Not built here; building ares headless would give a second lockstep detector (open decision 8). bsnes, the same core under GPL-3, is a closed box. ### MiSTer FPGA: not used No licence in its sources, and not runnable here: no closed-box route, so nothing rests on it (Wave 2 removed the switch positions earlier versions took from reading it). ### MAME 0.285: emulator, HLE, command-level detector No HG51B CPU device exists in MAME 0.285 (none listed by the binary, measured). Its Cx4 (`snescx4.cpp`, GPL-2.0+, a closed box) computes command results. Useful for: the host stream of the S-CPU (what the game asks, in what order), the test screen, and command-result comparisons where it implements the command. Not an instruction oracle. ### snes9x HLE: research-derived, command level, closed box The game's commands as high-level functions, written against the real chip's outputs by their authors (snes9x licence: non-commercial terms, a closed box). Detectors for whole-command results (wireframes, scaling, trig) where the LLE models share one model. ## Rung plan | Rung | What | Judge (tier) | Runs where | | --- | --- | --- | --- | | 0 | **Decode**: every encoding of the 65,536 classified as byuu's table does (ares; start-here.md "Instruction encoding"); `disasm` of every word of both programs; the executed words' disassembly checked against Mesen2's trace text | ares table (emulator, one model); Mesen2 disassembly (detector, closed box) | here, seconds | | 1 | **Directed tests** per family: ALU and flags (U9, C2), shifts (C1), MUL (U8, C6), RDRAM/WRRAM fold (U3), RDROM (U4), constants (U6), operand mirror and undefined codes (U5), jumps/skips/stack (U1, C4, C5), cache paging and fall-through (U2), bus port and WAIT (U10, C7), DMA and locks (U15, C3), suspend (U14), the SNES-side register map (U11-U13, U16) | fullsnes (research), the U-entries' consensus; each test names its entry | here | | 2 | **The data ROM**: the generator equals `cx4.bin` (SHA-1) when a BYOR image is given, and its byte sum is 054336h always | a real chip's dump (via MAME's list) + the self-test's checksum | here | | 3 | **The game's test functions in a board-free harness**: load page 0Eh from a BYOR cartridge, run 0E:00-0E:3C, 0E:40 after DMAs of the cartridge ROM, 0E:54 for R0 in a sweep, 0E:5C, 0E:89; compare with the values the S-CPU's test code checks (read from the 65816 code) and with the HLE formulas | the test's own expectations (self-test) ; HLE (detector) | here, BYOR cartridge | | 4 | **Mesen2 replay**: record the S-CPU's Cx4-window writes and reads and the Cx4 trace from power-on (Lua write callbacks + the trace logger), feed the writes to the core at their stamps, compare every traced instruction's registers and every S-CPU read; windows: the boot (pages 0 and 0Eh), the test loop, then gameplay windows that reach the wireframe, scaling and trig commands (pages 2-0Ch). Divergences classified by C-entry | Mesen2 (detector) | here | | 5 | **(Follow-up) HLE command comparison**: build_oam, transforms, wireframe, trig commands through the harness against an HLE's results run as a closed box | HLE (detector) | needs a headless build of an HLE | | 6 | **Through snes-python milestone 7**: the test screen on the board (all eight "OK."); Mega Man X2/X3 frames vs Mesen2 (title, intro, the X-Hunter and Sigma wireframe scenes) | the self-test (tier 1 by construction); Mesen2 (detector) | the board | ### What no judge decides (do not pretend) C1 beyond the counts the program reaches; C4's overflow; C5's uncached case; C6, C7, C8 and C14 (timing: no hardware number exists); C9's two-ROM meaning; C10's unused encodings; C15 (reset). The build session records the default and keeps the switch. ## Results (2026-11-07) | Rung | Result | Judge | | --- | --- | --- | | 0 | All 65,536 words match exactly one of byuu's patterns (ares) and classify as it; both shipped programs (retail, Rockman X2 Beta 1) disassemble; the 247 distinct words the five Mesen2 windows executed disassemble to the same operation as Mesen2's text (`tests/test_decode.py`, `test_disasm_vs_mesen.py`) | ares table; Mesen2 (detector) | | 1 | Directed tests per family, 140+ cases, each naming its U/C entry; every switch tested both ways (`tests/test_switches.py`: defaults against ares, other positions against the probe rows); 20 probe recordings replayed (`tests/test_mesen_probes.py`) | fullsnes + ares; Mesen2 OBSERVED | | 2 | Generator SHA-1 = a002f4ef... (the dump's), byte sum 054336h, 65 ms on CPython; float64 would get word 340h wrong | a real chip's dump; the test's checksum | | 3 | **All eight items "OK."** on Mega Man X2 (USA, Europe, Japan) and X3 (USA, Europe, Japan); X2: 18,901,640 instructions, X3: 25,194,888 (LDMAC dominates; Mesen2 measured 18.9 M for X2's test). Rockman X3 Beta 1 fails LDMAC by its own rule (header checksum 0000h). No C switch changes any item (11 alternatives after Wave 2, measured 2026-11-19 on X2 USA). 63 s CPython, 4 s PyPy | the games' built-in test (expectations read from their 65816 code) | | 4 | Five windows from power-on: **814,898 traced instructions compared, 0 divergences; 2,205,927 S-CPU reads compared**, which differ only in status bit 1 (7,752 polls, all C18; 0 with `IRQ_DISABLE_SETS_FLAG = True`) | Mesen2 2.1.1 (detector) | Rung 4 per window (`scripts/record_mesen_windows.py`; core defaults / with C18 flipped): | Window | Pages | Runs | Instructions compared | S-CPU reads | Read mismatches | | --- | --- | --- | --- | --- | --- | | x2-boot (frames 0-120) | 0Eh | 2 | 21,704 | 94,605 | 6 / 0 | | x2-test (120-122, test held) | 0Eh | 802 (15 traced) | 368,745 | 90,365 | 3,942 / 0 | | x2-title (Start at 900; 1000-1002) | 3, 0 | 123 (4) | 360,860 | 514,667 | 420 / 0 | | x2-play (intro stage; 1800-1804) | 0 | 905 (4) | 21,413 | 1,066,245 | 3,314 / 0 | | x3-title (860-864) | 2, 4 | 33 (4) | 42,176 | 440,045 | 70 / 0 | What the windows say about the C entries (undocumented-behavior.md "measure first"): register shift counts seen 2, 4, 6 (C1 never reached); 516 shifted CMP and 516 CMPR A<<8 at page 4 and 3,000+ shifted ADDs, **none with A<