# Validation: the oracles found, ranked, and pinned ## The tier rule Same rule as every core in this family: **hardware-captured > hardware-corrected > emulator-derived**. A lower-tier oracle is a *detector* (it finds where to look); it is never the *judge*. When a detector and a judge disagree, the judge wins, and the disagreement goes in [undocumented-behavior.md](undocumented-behavior.md). For a board, "hardware-captured" means one of: - output recorded from a real console (a white-noise capture, a CRC printed on real hardware, a photograph of a test screen); - a test program whose expected values its author established on real hardware ("hardware-corrected" when the program was written against an emulator and then fixed on hardware). The **specification** tier (manufacturer manuals) sits beside these: it defines the intent, and hardware overrides it where they differ. ## The oracles ### Hardware-captured | Oracle | What it judges | Where | Pin | | --- | --- | --- | --- | | ZEXALL-SMS CRCs | Z80 + board plumbing. Maxim's original port: "Then I ran it on a real SMS and noted the results." From v0.20 the CRCs ignore the undocumented flags after `SCF`/`CCF`, because they differ between Sega consoles' Z80s (below); a pre-test counts them instead | `reference/src/zexall-sms` (GPL-2.0); binaries in `tests/test_roms/smspower/ZEXALL-SMS-0.*.zip` | repo `8bfcd2c` (tag v0.21) | | FluBBa's hardware results for SMS VDP Test v1.31 | VDP ports, counters, interrupts, sprite flags, latch timing | `VDPTest-ReadMe.txt` inside `SMSVDPTest-SMS-1.31.zip`; forum thread 10695 (hardware runs on PAL SMS1 at 50/60 Hz, PAL SMS2, PAL MD1+PBC, plus user reports) | zip pinned; thread snapshot 2026-09-18 | | TecToy VDP test photographs | the Brazilian VDP variant's differences | `reference/smspower-attach/TectoyVDPVDPTest0[0-4].jpg` | pinned | | YM2413 measurements (openMSX RE project) | FM unit, optional milestone | `reference/src/ym2413/results`, `testprog` | `4893d1c` | | (none for PSG noise: see "What is *not* available") | | | | | 315-5124 die photograph (66 MB) | nothing yet: no netlist has been extracted | `reference/smspower-attach/3155124-die.jpg` | pinned | ### Game Gear timing (hardware-measured, 2019) Forum thread 10695 (`reference/smspower-forum/10695-start50.txt`): "enik2" ran FluBBa's test on a 1-ASIC and a 2-ASIC Game Gear, found the GG timings differ from the SMS *and between the two models*, contributed them to MAME 0.200 (`line_315_5377` in `315_5124.cpp`), and published `VDPTEST_GG.sms` with GG expected values per model (`tests/test_roms/smspower-forum/VDPTEST_GG.zip` and the source patch beside it, pinned). It runs in the GG's SMS-compatibility mode. He also notes the H-counter table on a 1-ASIC unit is sometimes wrong until the unit is power-cycled, and that his measured VINT/HINT HCounts did not follow the SMS pattern, so those two tests carry no GG expected values. A later post in the same thread (a VA5 Game Gear with a logic analyser) documents the VDP's VRAM refresh fetch pattern while the display is disabled. ### Hardware-corrected (self-checking or hardware-verified programs) | Program | Checks | Self-checking? | Pin | | --- | --- | --- | --- | | **SMS VDP Test v1.31** (FluBBa, 2009) | 56 named tests (plus two latch-timing columns): data/control port semantics, V/H counter values and timing, frame and line IRQ timing, sprite collision and overflow flags, scroll and name-table latch timing | Yes: prints pass/fail per test | `SMSVDPTest-SMS-1.31.zip`; also in the mirror's Master System aftermarket folder as "SMS VDP Test (World) (v1.31)" | | **SG-1000 M2 Check Program** (Sega, 1984) | Factory diagnostic. Seen on MAME 0.285: "SCRATCH RAM OK", a sound test stepping through the channels, an I/O test of both joypads and the hold switch, then "EXTENSION PORT BAD" (MAME has no loopback plug; expect BAD without one) | Yes: prints OK/BAD | `Sega - SG-1000 - SC-3000/SG-1000 M2 Test Cartridge (Japan).zip` in the mirror, CRC 207e7e99 = MAME `sg1000:m2cp` | | **Color & Switch Test** (Sega) | Factory diagnostic: colour bars, both joypads, light phaser, reset and hold | No: interactive, compared by eye or by frame image | `Sega - Master System - Mark III/Color & Switch Test (Brazil) (En) (Rev A).zip` in the mirror and the Japan proto | | VCounter Test, Scroll Test, 64 Color Palette Test, Fullscreen Palette Test, MD 6-button test (Charles MacDonald, 2001) | V counter, scroll, palette, controller | Partly (they display values) | `tests/test_roms/smspower/*` | | PauseTest, SMS Cycle Counter (FluBBa, 2006) | NMI behaviour; CPU cycles per frame | Display values | pinned | | SN76489 TestRom SG/SMS/GG, YM2413 TestRom (JoppyFurr, 2024) | PSG and FM behaviour, to compare side by side with a real console | No (interactive) | pinned | | SMS Sound Test (Heliophobe/Maxim) | PSG | No | pinned | | SMS Test Suite v0.36 (sverx, 2025) | 240p-suite video patterns; reports VDP type, Z80 NMOS/CMOS, region, BIOS | Reports what it detects | zip pinned; source `reference/src/SMSTestSuite` at `985bc04` (no licence stated) | | Leftmost-pixels test `test01` (sverx, 2015) | what the VDP shows in the 1-7 pixels a fine horizontal scroll uncovers when column blanking is off | No: interactive, and its thread reached no rule (undocumented-behavior open item 15) | `tests/test_roms/smspower-forum/test01.rar`; thread `reference/smspower-forum/topic-15653.txt` | | PFR Detect, Mark III BG/Port tests, Checkstate, Color Check, FadeTest-GG, GG Button Test, SMS Padtest, 48KB test, Simple BIOS | peripheral and region detection, paging, BIOS behaviour | Display values | pinned | ### Specification | Document | Covers | Where | | --- | --- | --- | | TI *TMS9918A/TMS9928A/TMS9929A Video Display Processors Data Manual* (Nov 1982, 105 pp., text layer present) | modes 0–3, sprites, timing, VRAM access windows | `reference/manuals/TMS9918A_TMS9928A_TMS9929A_VDP_Data_Manual_Nov82.pdf` | | TI SN76489AN data manual | PSG registers, READY timing | `reference/manuals/TI_SN76489_datasheet_console5.pdf` (text) and `TI_SN76489AN_application_manual.pdf` (image-only) | | NEC uPD765 data sheet (Dec 1978, 20 pp., text layer present) | the SF-7000's disk controller: phases, commands, status registers, timers. The unit's chip is the later uPD765A | `reference/manuals/NEC_uPD765_Data_Sheet_Dec78.pdf` | | Sega *Software Reference Manual for the Sega Mark III Console* | Mark III/SMS VDP, memory, I/O, PSG as Sega told developers | `reference/smspower-attach/sms-officialdocs-{pdf,txt-bmp}.zip`, `reference/smspower-wiki/SMSOfficialDocs.pmwiki` | | Sega Game Gear hardware manual (translated) | GG VDP, ports, precautions | `reference/smspower-wiki/GGOfficialDocs.pmwiki`, scans in `gg-officialdocs-png.zip` | | TMS9918 Arizona Technical Symposium draft (1980) | TMS9918 design notes | `reference/smspower-attach/1980_Arizona_Technical_Symposium_Draft.pdf` | | Yamaha YM2413 application manual | FM unit | `reference/smspower/ym2413am.zip`, `ym2413pdf.zip`, `chipsym2413am.pdf` | ### Research documents (high-quality secondary sources) Charles MacDonald's `msvdp-20021112.txt` (VDP; vertical timing checked on an NTSC SMS2) and `smstech-20021112.txt`; Maxim's SN76489 page; Sean Young's `tms9918a.txt` (undocumented TMS9918A behaviour); the SMS Power wiki (60 pages in `reference/smspower-wiki/`, snapshot 2026-09-18); the forum threads in `reference/smspower-forum/` (each saved as HTML and converted to text). ### Emulator-derived (detectors) | Emulator | Covers | Licence | Pin | | --- | --- | --- | --- | | **MAME 0.285** (the installed binary) | trace and I/O-log lockstep on `sg1000`, `sms`, `sms1`, `smsj`, `gamegear` | BSD-3-Clause (these drivers) | source `reference/src/mame` at tag `mame0285` (`f379cd0`), sparse | | Genesis Plus GX | SMS/GG VDP, PSG, mappers, cartridge database | **non-commercial**: closed box only. Read before the 2026-11-14 rule: every "Genesis Plus GX agrees" in these documents is HYPOTHESIS (source-read), for review | https://github.com/ekeeke/Genesis-Plus-GX @ `27426f0`, not fetched since 2026-11-24 (Aubrey) | | Gearsystem | SMS/GG/SG-1000 | GPL-3.0: closed box only | https://github.com/drhelius/Gearsystem @ `0e35ec6`, not fetched since 2026-11-24 | | openMSX (video and sound) | TMS9918A behaviour as used by MSX1. Its VRAM access-slot tables were read to say they were measured on a real V9938, the MSX2 chip (HYPOTHESIS: source-read), so check which chip a table covers before citing it for the TMS9918A | GPL-2.0: closed box only | https://github.com/openMSX/openMSX @ `621950b`, not fetched since 2026-11-24 | | vrEmuTms9918 | TMS9918A | MIT | `dc40960` | | F18A (VHDL) | a TMS9918A re-implementation in FPGA, built to run real TI-99 software | BSD-3-Clause | `4318963` | | Nuked-OPLL | YM2413, transistor-level from the die. Since the restart (2026-11-13) only a closed-box detector, run by ym2413-python's own `validation/closed_box.py` and never read; not this board's judge | GPL-2.0 | https://github.com/nukeykt/Nuked-OPLL @ `1269cf5`, not fetched here since 2026-11-24 | All repository pins are in `scripts/pinned_repos.json`; `scripts/fetch_references.py` clones each at its pinned revision. ## What is *not* available - **No transistor-level VDP or PSG.** The 315-5124 die photograph exists; no netlist does. So the VDP's judge is the test programs above, not silicon. - **No hardware capture of SG-1000 VDP timing.** FluBBa's test needs Mode 4. The SG-1000's judges are the M2 Check Program (functional) and the TI manual (timing); openMSX and MAME are detectors. - **No usable hardware capture of PSG noise.** The wiki's two "white noise" downloads (`SN76489WhiteNoise.zip`, `SegaVDPWhiteNoise.zip`, 32,767 bytes of 0/1 each) are the bit patterns illustrating its LFSR description, not raw recordings. Checked 2026-09-18: `SN76489 white noise.dat` is the 15-bit, taps-$0003 m-sequence (it matches the model inverted, at phase 32,752, over all 32,767 samples). But `Sega VDP white noise.dat` is *also* that 15-bit $0003 sequence (it matches from sample 0), while the page says the Sega PSG is 16-bit with taps $0009, whose period is 57,337, so it cannot fit in 32,767 samples. MAME and Genesis Plus GX use the 16-bit $0009 model. So the Sega file looks mislabelled or wrongly generated: it is *not* a judge for the Sega noise. See [undocumented-behavior.md](undocumented-behavior.md), open item 6. - **No hardware capture of the discrete PSG's tone-0 behaviour** (open item 3 in [undocumented-behavior.md](undocumented-behavior.md)). - **No Game Gear LCD-scaling capture** for SMS mode. The one description in `msvdp` section 14 says the method is unknown. ## Local romsets (not fetched, not committed) A local copy of No-Intro's sets, named by the environment variable `NO_INTRO_DIR` and read in place (`scripts/romsets.py`): SG-1000 - SC-3000 and its aftermarket folder (246 files on 2026-11-12, seven of them SF-7000 disks), Master System - Mark III and aftermarket (1,180), Game Gear and aftermarket (903). MAME BIOS sets (`sms.zip`, `sms1.zip`, `smsj.zip`, `smspal.zip`, `gamegear.zip`, `sf7000.zip` for the disk unit's IPL ROM, …) are in a MAME rompath named by `MAME_ROMPATH`. MAME's software lists (`/usr/share/games/mame/hash/{sg1000,sms,gamegear,sc3000_cart}.xml`) identify each cartridge's board type by CRC: that is the board-detection table. ## Certification record Recorded 2026-09-21 with z80-python 0.4.0 (PyPI), PyPy 7.3.20 (Python 3.11.13), MAME 0.285, ZEXALL-SMS v0.21 (`tests/test_roms/github/ZEXALL-SMS-0.21.zip`, SHA-256 in `scripts/pinned_files.json`). Milestones refer to [handoff-brief.md](handoff-brief.md). | Milestone | Gate | Tier | Result | | --- | --- | --- | --- | | 1 | `scripts/run_zex.py zexdoc` on the SMS2 board | hardware-captured CRCs | 79 of 79 tests OK, 0 errors; 2,026,344,677 instructions, 15,975,528,164 cycles, 377 s | | 1 | `scripts/run_zex.py zexall` on the SMS2 board | hardware-captured CRCs (undocumented flags version) | 79 of 79 OK, 0 errors; 2,398,521,988 instructions, 18,925,076,690 cycles, 412 s | | 1 | the `SCF`/`CCF` pre-test counts it prints | recorded for comparison with real consoles | `0000 0000 1fff 1fff 0000 0000` / `1fff` x6 / same again: z80-python's Zilog NMOS rule | | 2 | sn76489-python's own tests (the PSG is that core; restarted 2026-11-12, written from documents) | manufacturer and research documents; one hardware capture (John Kortink's, of a discrete chip on a BBC Micro) | the discrete chip's 15-bit white noise equals the capture over all 32,767 bits; everything else is checked against TI's data sheet, Sega's manuals and Maxim's page, with what is provisional marked so. Nothing is measured on a Sega console. Nuked-PSG is run as a closed box, a detector only: its differences are open items in that core's `docs/validation.md` | | 2 | ym2413-python's own tests (the FM unit is that core; restarted 2026-11-13, written from documents) | Yamaha's application manual; the openMSX project's measurements of one real YM2413; the NESdev wiki and SMS Power | 514 tests pass in that core (one expected failure, an open difference); 30 deliberate faults all caught. The YM2413's fifteen built-in voices are an emulator's hand-tuned table, not a dump. Nuked-OPLL is run there as a closed box, a detector only: its differences are open items in that core's `docs/validation.md`. On this board: `tests/test_fm_unit.py` and the FM state round trip pass; Phantasy Star (Japan) on `smsj` plays FM music (900 frames rendered) | | 3 | Sega's SG-1000 M2 Check Program on our SG-1000, 900 frames | hardware-corrected (factory diagnostic) | "SCRATCH RAM OK", the test patterns, then the I/O screen with "EXTENSION PORT BAD" (no loopback plug), as on MAME | | 3 | MAME `sg1000` lockstep, Flicky, 20 s | emulator-derived | 7,703,804 instructions identical (registers and cycle counts); 0 port reads differ; exit frame 49,152 of 49,152 pixels | | 4, 5 | SMS VDP Test v1.31 on our system (`scripts/run_vdptest.py`), SMS2 and SMS1 variants | hardware-corrected (FluBBa, real PAL SMS1/SMS2/MD) | **55 of 55 results Ok on both**: 19 data-port, 16 counter/IRQ, 20 sprite tests, including every HCount timing test. Timing constants fitted to these tests ([timing.md](timing.md)) | | 6 | enik2's `VDPTEST_GG` on our Game Gear in SMS-compatibility mode | hardware-corrected (enik2, real 2-ASIC and 1-ASIC units) | 2-ASIC: 55 of 55; 1-ASIC: 53 of 55 (Frame and Line IRQ HCount open, undocumented-behavior item 8). Game Gear timing constants fitted to these tests | | 4, 5 | the same ROM's Mega Drive entry (`scripts/run_vdptest.py --machine megadrive-pbc --menu 1`), NTSC and PAL, 2026-11-11 | hardware-corrected (FluBBa, real PAL Mega Drive with Power Base Converter) | **55 of 55 on both**. The 315-5313's port rules are msvdp section 13's; its timing constants are fitted to this entry ([timing.md](timing.md), Mega Drive specifics). On the SMS2 variant the same entry fails 14 of 55, and the SMS entry fails 13 of 55 on `megadrive-pbc`: the two machines are told apart by the tests. Cross-check on Nuked-MD (`-m3`, die-derived, 2026-11-11): 50 of 55 agree; the five H counter comparisons fail there on a sub-count Z80 phase FluBBa's source says real machines vary in ([undocumented-behavior.md](undocumented-behavior.md) item 17) | | 3 | BASIC Level III on `sc3000`, three lines typed on its keyboard (`pytest -m slow`, `test_sc3000_basic_runs_a_typed_program`), 2026-11-12 | the program's own output; MAME `sc3000` as detector | `PRINT 6*7` answers 42 and a FOR loop runs; free memory 12,284 (16 KB cartridge) and 26,620 (32 KB), the latter MAME's too; the frame after the same lines differs from MAME's in one character cell, the blinking cursor | | 3 | Disk BASIC on `sf7000`, booted through the IPL ROM, six lines typed (`pytest -m slow`, `test_sf7000_disk_basic_saves_and_loads_a_program`), 2026-11-12 | the IPL's and the program's own behaviour; MAME `sf7000` as detector | the IPL's drive-speed check passes and it boots; `SAVE`, `FILES`, `NEW`, `LOAD` and `RUN` work; the three sectors `SAVE` writes are byte for byte the ones MAME writes, and the last frame is MAME's exactly. All seven disks of the mirror match MAME at 5, 10, 20, 30 and 60 s (at 45 s four differ in the blinking cursor's cell) | | tooling | Save states (`state.py`): `tests/test_state.py` on a program of its own, six machines; `scripts/state_roundtrip.py` on real cartridges, 2026-11-12 | equivalence with the run that was never interrupted | a state saved in mid-frame and loaded into a fresh system continues with identical frames, sound samples, CPU, RAM and video memory for 30 frames: 28 of 28, one cartridge of every board in the sweep's records, an SF-7000 disk while the IPL loads, and Sonic or Phantasy Star on `megadrive-pbc`, `sms1pal`, `smsj` (the FM chip playing), `ggsms` and `sc3000` | | 4 | MAME `sms` lockstep through the export BIOS, Sonic, 20 s | emulator-derived | 7,904,561 identical; 0 reads differ; frame 49,152 of 49,152 | | 4 | MAME `sms` lockstep, SMS VDP Test v1.31, 12 s (menu and first tests) | emulator-derived | 3,556,264 identical; 0 reads differ; frame 49,152 of 49,152 | | 6 (early) | MAME `gamegear` lockstep, Sonic, 20 s | emulator-derived | 5,903,153 identical; 1 read differs (the first status read after power-on, open item 7, continued with MAME's value); frame 23,040 of 23,040 | | 7 | `scripts/compat_sweep.py`: every cartridge of the three romsets (`scripts/romsets.py`), 10 s on MAME and on ours, frames compared | emulator-derived (detector) | see the table below | Milestone 7, first run 2026-09-21 (918 of 928, 532 of 562 and 203 of 209, with 449 cartridges unread behind broken links); run again 2026-11-11 on every file of the local No-Intro folders. Cartridges the board and MAME both run, and whose frame after 10 s matches MAME's exit snapshot exactly (colours compared as levels): | Romset | Identical | Differ | Board not modelled | MAME on another board | Missing file | Not comparable | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | Master System (1,180) | **1,157** (98.9% of 1,170) | 13 | 0 | 10 | 0 | 0 | | Game Gear (903) | **823** (94.2% of 874) | 51 | 0 | 3 | 0 | 26 SMS-mode games (MAME's LCD scaling is its own guess) | | SG-1000 (246) | **237** (97.5% of 243) | 6 | 0 | 3 | 0 | 0 | The 66 cartridges on Korean, Taiwanese, Hi-Com, HES and EEPROM boards joined the table on 2026-11-12, when those boards were added (`cartridge.py`): 65 identical at once, and LinkWord once text mode was put where the TMS9918A's manual has it (it had been 2 pixels right). Several of those boards are known only from MAME's source and say so in their docstrings; for them an identical frame shows that we follow MAME, not that MAME is right. The seven SF-7000 disk images in the SG-1000 folder joined the same day, on the machine `sf7000`, compared after 30 s (a disk takes about 15 s to start): all seven identical. The SG-1000 row had been counting five aftermarket titles twice: the local copy holds No-Intro's old folder (`Sega - SG-1000`) beside the renamed one, and the sweep read the old one plus the new aftermarket folder. It now reads the renamed pair, 246 files. The two X-Terminator cheat cartridges, the last board not modelled, joined the Game Gear row as MAME describes the device, with no game plugged into them: identical, which again shows only that we follow MAME. Nothing is missing now that the folders are read in place. "MAME on another board": an unlisted image MAME's file loader guesses onto another board, whose frame then differs or which MAME fails to run ([mame-oracle.md](mame-oracle.md), trap 8). The per-cartridge CSVs are in `tests/compat/` (not committed). Every remaining difference was run in lockstep with MAME (`scripts/triage_diffs.py`), its port reads checked and its frame compared, and sorted: | Verdict | SMS | GG | SG-1000 | Whose | | --- | ---: | ---: | ---: | --- | | interrupts: identical in lockstep, no read differs | 8 | 1 | 6 | MAME's interrupt acceptance wanders (trap 7) | | power-on: identical once MAME's first status read is used | 0 | 35 | 0 | MAME's reset artefact (open item 7) | | reads: identical once MAME's status/counter reads are used | 1 | 6 | 0 | sprite-flag timing near the frame flag, open; three NFL '95 betas on the serial status (open item 16) | | render: CPU identical, frame differs | 4 | 8 | 0 | GG: MAME's 224-line frame 16 lines early (open item 10); SMS: mid-line CRAM writes (item 12), NTSC 240 lines (item 13) | | cpu | 0 | 1 | 0 | Ultimate Soccer: MAME raises a Gear-to-Gear NMI with no cable, and the game hangs on a black screen; ours reaches its menu | So no difference is left that points at the board, CPU or VDP without a known MAME-side cause or a documented open item. Found and fixed on the way: - a 24 KB cartridge was mirrored instead of read linearly (Mahjong, SG-1000); - the TMS9918A's fifth-sprite number was held while 5S was set (Hyper Sports); - mapper writes reached a disabled slot's mapper (Versus); - Codemasters boards missing from MAME's lists (header checksum; Pete Sampras Tennis) and Ernie Els Golf's cartridge RAM; - the vertical scroll latch (Streets of Rage), the GG LCD window in 224-line mode (Micro Machines), transparent TMS sprites (Ping Pong), zoomed sprite rows (Racer), the GG's TMS modes coloured through CRAM (Justin Harder Reel), the GG EXT port on $01/$DC/$DD; - the GG power-on phase, refitted from V counter reads; - the sweep itself: MAME's exit snapshot timing, its GG LCD persistence (in the sweep and in traces), MAME's board guess for files, snapshot alignment. Interrupt timing in the locksteps: interrupts are taken where MAME took them, because MAME's acceptance point wanders by about ten cycles between frames ([mame-oracle.md](mame-oracle.md), trap 7). Our INT rose no later than MAME's acceptance in every entry (Sonic SMS: 692 of 694 within one instruction, median 0 cycles; the rest held off by the program). Not yet run: FluBBa's MD and Game Gear modes of the VDP test, its visual latch-time screens (x-scroll, name table; judged by eye), the Game Gear's CMOS `OUT (C),0` (a z80-python option).