# Validation: every oracle, its tier, what ran ## Oracle tiers Rank an oracle by where its expected values came from; the highest tier that covers a claim decides it, a lower tier only detects. | Tier | Here | | --- | --- | | **hardware-captured** | values recorded from a console's DSP output or ARAM: **none in reach** | | **hardware-verified** | blargg's `spc_dsp6.sfc`: a self-checking test ROM whose author ran it on consoles. Its test names (from the ROM's strings) say what each test checks; its source is not read | | **die-derived** | none exists (no published S-DSP netlist was found) | | **research** | anomie (r1160, r1212-jwdonal), fullsnes, the SNESdev wiki | | **closed box (OBSERVED)** | blargg's snes_spc 0.9.0 run through its documented API (`spc_dump`); MAME 0.285 run as a program. Detectors and measuring instruments: a value from them is overruled by any document or hardware number | ## The oracles ### blargg's `spc_dsp6.sfc` (hardware-verified): the judge, at the board milestone - Pin: `gitlab.com/higan/snes-test-roms` @ `26e8aa91e0d3b90b901e7e693bc4a8244b391d7b` (2024-09-23), `blargg-spc-6/spc_dsp6.sfc`, SHA-256 `b12038f865536a33003c9887e6f86fcbcb526b7f1766526ab30cb74b7380aa9a`. Licence not stated; never committed; run only. - 111 named tests: Echo 8, Envelope 7, KON 18, Misc 10, Order 19, Random 8, Timing 41 (list at the end). - It needs the whole SNES (the S-CPU uploads the test code through the ports), so it runs when the board runs ROMs. Not run yet. - Run on MAME 0.285 (2026-10-21, closed box): prints `Echo/basics`, `Echo/esa_changes`, `Echo/edl_changes` and **"Failed 02"**, then stops. (That run's IPL ROM was produced from a non-commercial emulator's source file; that method is not used again. The IPL ROM is bring-your-own: `$SNES_IPL`.) ### snes_spc 0.9.0 (closed box): the referee - Pin: `snes_spc-0.9.0.zip`, SHA-256 `dbad8273973a26f1b0c2a07b61b68855b2d96526fbc2cdd237f9d4fb91083aed` (Wayback copy of `blargg.parodius.com/libs/`, 2011-08-12). LGPL-2.1. - Built (since 2026-11-24) by the GPL tool snes-spc 0.1.0, `$EMU_TOOLS_GPL/tools/snes-spc/build.sh`, which fetches the pinned archive into emu-tools-gpl (this repository no longer fetches or keeps it); run from `$EMU_TOOLS_GPL/tools/snes-spc/build/spc_dump` (`scripts/emu_tools.py` `SPC_DUMP`; `scripts/dsp_build_referees.py` checks it). The same bytes as the build below (SHA-1 `6d1aba42`), and the same outputs on all 1,028 `.spc` files (../validation.md, "The S-DSP referee from snes-spc"). Until then built by `scripts/dsp_build_referees.py` from `reference/dsp/archives/`: all of `snes_spc/*.cpp` as its readme says, unmodified, `-O2 -DNDEBUG`, g++ 15.2.0 x86_64, diagnostics suppressed (they quote the source), linked with `spc_dump.cpp` (kept outside this repository since 2026-11-22 as a GPL tool, found at `$EMU_TOOLS_GPL/tools/snes-python/spc_dump.cpp`, through `SNES_GPL_TOOLS` until 2026-11-24), which calls only the C functions `snes_spc.txt` documents (`spc_new`, `spc_load_spc`, `spc_clear_echo`, `spc_play`, `spc_save_spc`, `spc_delete`). The DSP registers are read from the `.spc` image `spc_save_spc` writes, at the format's offset `$10100`. The built program is an LGPL-2.1 combined work, never shipped. - What the library's documentation says of itself (snes_spc.txt "Accurate S-DSP Limitations"): "Power-up and soft reset behavior might have slight inaccuracies"; FLG.6 toggled rapidly is not emulated properly. - Two properties measured on it (OBSERVED): - its audio stream trails its own register snapshots by **4 samples** (`--lag 4`); - its snapshot of sample *i* is the register file after DSP step 31 of sample *i*, except that it sometimes lands up to ~10 steps earlier or includes an S-SMP write from the instruction crossing the boundary. `dsp_compare.py` accepts a match anywhere from step 20 of sample *i* to step 8 of *i* + 1 and counts those as **jitter** (Mega Man X "03 Sigma Intro 1": all 10 of 10 off-step snapshots in 1,500 samples equal the board's file after steps 21-24). - Hashes of its output, 64,000 samples, by `scripts/dsp_run_referee.py --regs` (2026-11-19): | Case | audio SHA-256 (first 16) | non-zero | peak | regs SHA-256 (first 16) | | --- | --- | --- | --- | --- | | brr | `347ee663ed68b0a1` | 63,972 | 32,512 | `81f0b770251434b8` | | echo-wrap | `8feafc50511c7029` | 63,980 | 32,188 | `09c77ddf7107d78d` | | echo | `39272124c4ad8de5` | 63,973 | 32,768 | `77de80aa40b77112` | | edges | `671db68c1de034ad` | 63,974 | 17,328 | `5949568fc0eb70d9` | | edl-zero | `7299213978a02cfb` | 63,946 | 32,768 | `49a20c450a46ffe5` | | endx-override | `5f88b1a112d344bb` | 63,976 | 32,512 | `3288160e80d1449b` | | env-quirks | `fd320e2ca04f80d7` | 5,483 | 29,568 | `0296bfe3b797cd94` | | envelopes | `b99296137ba6db9d` | 63,966 | 29,317 | `6dcaa3cc9164cd4d` | | flg | `6694813656e393c3` | 60,917 | 32,768 | `8aef9b984d01ceee` | | kon-ring | `e38f3df7bae2c8b8` | 63,975 | 32,511 | `d6ed5a4a6c1d6663` | | kon-timing | `b4c4e24f1d4ffab4` | 63,973 | 25,776 | `b5da370f3d185860` | | latch-sweep | `4a9dbb0fff4a0906` | 53,230 | 32,768 | `971b162cd1c8bcfa` | | noise-pmod | `44bd6ac8ec2bb12a` | 63,968 | 32,512 | `b1099a3a3e2df5d1` | | saturation | `c3b564cf4cef9f92` | 63,988 | 32,768 | `5909c6d0acc58666` | The six audio hashes recorded in Phase 0 (brr, envelopes, echo, noise-pmod, kon-timing, flg), from a build that patched the library and defined an accuracy macro, are reproduced exactly by the unpatched build. ### MAME 0.285 (closed box): a coarse detector `mamedev/mame` tag `mame0285`; its `s_dsp` is LGPL-2.1+ (OpenSPC lineage, per sample) and is not read. It fails spc_dsp6 (above). Useful only for "does a track sound at all". ### Documents (research) | Document | Pin | Notes | | --- | --- | --- | | Anomie's S-DSP Doc r1160 (2008-12-21) | Wayback 2012-09-27, SHA-256 `0ab1702a...358536` | | | Same, r1212 with jwdonal's updates (2015-09-28) | Wayback 2017-07-31, SHA-256 `21b793b1...61bc` | the one cited; its Mednafen counter fragment is not used (C7) | | fullsnes | `problemkaputt.de/fullsnes.htm`, SHA-256 `3853b65a...79f6c6` | facts only | | SNESdev wiki "S-DSP registers" r1428, "BRR samples" r902, "DSP envelopes" r1447 | `action=raw&oldid=` | CC BY-SA, facts only | | SPC File Format v0.30 | `snesmusic.org/files/spc_file_format.txt`, SHA-256 `21e706f1...ea646` (fetched 2026-11-19) | the `.spc` loader's source | Full hashes in `scripts/dsp_pinned_files.json`. ### Hardware recordings None. An SPC-playing cartridge or an APU board on a rig would make the top tier possible. ## What ran (2026-11-19) PyPy 3.11 (7.3.20), `PYPY_GC_NURSERY=1M`, `nice`, on a shared machine (load ~90). ### Rungs 0-1: tables and units (`tests/dsp/test_tables_and_units.py`) 21 tests from document statements, all pass: the Gaussian hash and equality with anomie's printed table; tap sums 7FFh-801h; rates "1,3,5 SHL n"; each rate fires once per period; shifts 13-15; filter fractions; the clamp-then-clip glitches; history carried; fullsnes's interpolation overflow example (+3FF8h); release, direct gain, attack 31, decay to the sustain level, sustain level from GAIN in GAIN mode; the noise period 32,767; mirrors and ENDX clearing; FLG acting as `$E0`; one sample per 32 steps; KON's five empty samples (#6 is the first heard). ### Rung 2: synthetic cases against the referee (`scripts/dsp_compare.py`) spc700-python + `smp.py` + `dsp/`, 64,000 samples (2 s) each: | Case | audio different | registers different | jitter | | --- | --- | --- | --- | | brr | 0 | 0 | 2 | | echo-wrap | 0 | 0 | 0 | | echo | 0 | 0 | 1 | | edges | 0 | 0 | 2 | | edl-zero | 0 | 0 | 0 | | endx-override | 0 | 0 | 7 | | env-quirks | 0 | 0 | 5 | | envelopes | 0 | 0 | 3 | | flg | 0 | 0 | 2 | | kon-ring | 0 | 0 | 7 | | kon-timing | 0 | 0 | 6 | | latch-sweep | 0 | 0 | 35 | | noise-pmod | 0 | 0 | 4 | | saturation | 63,992 | 0 | 0 | 13 of 14 cases value-exact in audio and in the register file after every sample. The readings chosen by measurement (each tagged OBSERVED in the code): C14 (DSP step, then the S-SMP access; the opposite order gives 612 and 108 different samples on latch-sweep and kon-timing in 4,000), C15 (fullsnes's clipped saved envelope; anomie's pre-clamp gives 45 differences on env-quirks), C16 (one shared ENVX and OUTX latch; per-voice latches give 55 mismatching register files on endx-override), step 30's order (ares's). **D1, saturation.** The referee turns the eighth FIR product into a 16-bit value before the clamped add: with an echo sample of -`$4000` and FFC7 = -128 the product +`$8000` becomes -`$8000` (OBSERVED: casting that product reproduces all 64,000 samples). anomie (`FIR = clamp16(FIR + S(x-0) * FFC7 >> 6)`) and fullsnes ("with overflow handling ... saturate") both say the sum is clamped, so the module keeps the documents' reading and the difference is recorded. fullsnes also says FFCx = -128 "should not be used ... to avoid multiply overflows"; a console run (spc_dsp6 `Echo/echo calc` or a probe) would settle it. *Settled 2026-11-23 (TEST ROM):* spc_dsp6 `Random/echo data` fails through the board with the plain clamp and passes with the cast, so the module now casts as the referee does; the saturation case is value-exact (5c5bb32). ### Rung 3: game `.spc` files against the referee Fetched by `scripts/dsp_fetch_games.py` into `reference/dsp/spc/games/` (19 games, 1,012 tracks; never committed). The board's loader follows two player conventions that agree with the referee (C18): the file's KON byte is a pending KON, and the timers and DSP step start at a fixed phase. Sweep of 2 tracks per game, 320,000 samples each: **38 of 38 tracks value-exact** in audio and in the register file after every sample (12,160,000 samples; table in [status.md](status.md)). ## spc_dsp6's tests Echo: basics, esa_changes, edl_changes, wrap_around, zero_length, echo calc, edl 0 quirk, edl lengths. Envelope: attack->decay during gain, decay->sustain during gain, envelope rates, gain $E0 threshold, hidden env 0 at kon, hidden env after adsr, hidden env after gain. KON: BRR header.03 read times, envx during kon, gain used on last kon sample, hidden env flag during kon, kon as prev sample ends, kon clears independent, kon decoding when another kon, kon every other sample, kon stops endx of prev sample, kon then another kon, kon then change pitch, kon then flg.80, kon then flg.80 then kon, kon then koff, kon then set sample's end flg, kon unaffected by pitch, kon when prev sample at end, pitch at kon. Misc: $F0-$FF are not ram, brr addr wrap-around, brr early end at many pitches, brr not always decoding, counter rate synchronizations, dsp addr above $7F, endx write clears immediately, interp pos clamped at $7FFF, noise rates, voice sums clamped each time. Order: brr end uses curr header, brr interp pos clamp time, edl before inc offset, endx after final brr decode, env run after being used, envx uses env before koff, envx uses prev env, esa applied after echo write, flg.80 after env used, flg.80 clears next envx, koff before env runs, kon env after used, loop addr read in prev sample, noise rate flg.1F, pitch added before interp, pitch after brr, pitch mod uses prev sample, voice 0 noise, vol applied on final sample. Random: brr before playing, brr while playing, echo data, echo fir, envelope, kon pitch, pitch mod, voice volumes. Timing/Echo: 22-23 echo read, 22-25 fir, 26 efb, 28-29 flg.20, 29 edl, 29 esa, 29-30 echo write. Timing/Misc: 27 pmon, 28 dir, 28 eon, 28 non, 29 kon cleared, 30 flg.1F, 30 koff, 30 kon. Timing/Voice: V1 srcn.loop, V1 srcn.start, V2 adsr0.0F, V2 adsr0.70, V2 adsr0.80, V2 dir.loop.lsb, V2 dir.loop.msb, V2 dir.start.lsb, V2 dir.start.msb, V2 pitchl, V3 adsr1.1F, V3 adsr1.E0, V3 BRR.header.03, V3 BRR.sample.lsb, V3 BRR.sample.msb, V3 flg.80, V3 gain.1F, V3 gain.60, V3 gain.7F, V3 gain.80, V3 pitchh, V4-5 vvol, V7 endx cleared, V7 endx set, V8 outx, V9 envx.