# snes-spc blargg's snes_spc 0.9.0 run as a closed-box S-DSP referee: `spc_dump` plays an .spc file and writes every 32 kHz output sample, and optionally the DSP's registers after every sample and the final state. Version 0.1.0 (`CHANGELOG.md`). Regrouped on 2026-11-24 from the two identical copies of `spc_dump.cpp` that snes-python and s-dsp-python parked here on 2026-11-22, with a build script of its own, so no MIT repository needs to keep the snes_spc archive. ## Where it is Set **`EMU_TOOLS_GPL`** to a checkout of this repository (emu-tools `docs/contract.md`, section 5). Then: | Path | What | | --- | --- | | `$EMU_TOOLS_GPL/tools/snes-spc/build.sh` | fetches the archive, checks it, builds `build/spc_dump` | | `$EMU_TOOLS_GPL/tools/snes-spc/build/spc_dump` | the referee, built (git-ignored) | | `$EMU_TOOLS_GPL/tools/snes-spc/build/build-info.json` | the archive's SHA-256, compiler, flags and build time | | `$EMU_TOOLS_GPL/tools/snes-spc/spc_dump.cpp` | the driver's source, for a consumer that still compiles it itself | | `$EMU_TOOLS_GPL/tools/snes-spc/tests/smoke.py` | the smoke test | The old paths `tools/snes-python/spc_dump.cpp` and `tools/s-dsp-python/spc_dump.cpp` are relative links to `spc_dump.cpp` here, so a consumer that compiles the driver from its old path gets the same file. ## Upstream, licence and pin - **snes_spc 0.9.0** by Shay Green (blargg), the archive `snes_spc-0.9.0.zip` of 2007-04-17, pinned by **SHA-256 `dbad8273973a26f1b0c2a07b61b68855b2d96526fbc2cdd237f9d4fb91083aed`**. blargg's site is gone; `build.sh` fetches the Internet Archive's copy of the file it served (`https://web.archive.org/web/20110812132836id_/http://blargg.parodius.com/libs/snes_spc-0.9.0.zip`) and refuses any other bytes. Licence: **LGPL-2.1-or-later** (the archive's `license.txt` is the LGPL-2.1 text, the readme says "GNU Lesser General Public License (LGPL)", and the eight `.cpp` files of `snes_spc/` grant "version 2.1 of the License, or (at your option) any later version"; the nine headers carry no notice and take the archive's terms). Checked against `emulator-lineage/docs/sources.md` (snes_spc 0.9.0: LGPL-2.1+, closed box only) and `../../docs/upstreams.md`. - **This tool: GPL-3.0-or-later** (`../../LICENSE`). `spc_dump.cpp` is our code (alewman), first published under MIT in snes-python and s-dsp-python; it keeps its MIT line (`../../notices/MIT-emulator-family.txt`). The program built from it and the library is an LGPL-2.1-or-later combined work. - No patches. The archive is never committed here; if the tool is shared, its complete source (this folder and the pinned archive) goes with it. ## Build `./build.sh` (needs `curl`, `unzip`, `sha256sum` and a C++ compiler): fetches the archive into `upstream/` (git-ignored) unless it is there, checks its SHA-256, unpacks it, checks the unpacked tree against the archive file by file, and compiles `spc_dump.cpp` with every `.cpp` file of the archive's `snes_spc/` folder, unmodified, as the library's readme says: `g++ -O2 -DNDEBUG -w` (the consumers' flags; `CXX` and `CXXFLAGS` override them). A copy of the archive you already have can be given with `SNES_SPC_ZIP=FILE` (it is checked by SHA-256 and copied in). `./build.sh --version` prints `snes-spc 0.1.0 (snes_spc 0.9.0, LGPL-2.1-or-later, archive SHA-256 dbad8273973a)`. Exit status as the contract says: 0 built, 2 a usage error, 3 the archive could not be fetched or is not the pinned one, anything else a failed build. It never deletes anything: a tree that differs from the archive stops it until moved aside. Built here in a few seconds. ## Command line $EMU_TOOLS_GPL/tools/snes-spc/build/spc_dump FILE.spc SAMPLES OUT.raw [--regs OUT.regs] [--final OUT.spc] [--clear-echo] - `FILE.spc`: the .spc file to play (a path the player gives). - `SAMPLES`: how many 32 kHz output samples to write. - `OUT.raw`: every output sample, unfiltered, as little-endian signed 16-bit left and right pairs (4 bytes a sample). - `--regs OUT.regs`: after every output sample, the 128 DSP registers as the library saves them in an .spc snapshot (so ENVX, OUTX and ENDX included): SAMPLES records of 128 bytes. - `--final OUT.spc`: the state at the end, as the library saves it: an .spc image of 66,048 bytes (RAM at offset $100, the DSP registers at $10100). The library does not write the file's signature or tag (the first bytes are zero, OBSERVED 2026-11-24). - `--clear-echo`: the library's optional echo-buffer clear after loading. The driver calls only the C interface snes_spc's documentation (`snes_spc.txt`) describes. It is not yet on the contract's `run.py` (no manifest): quote the pin from `build/build-info.json`. ## Outputs and evidence Every value it gives is a closed-box measurement: tag it **OBSERVED (snes_spc 0.9.0, archive SHA-256 `dbad8273...`, via snes-spc 0.1.0)**, never a hardware fact; any document or hardware measurement that disagrees overrules it (`emu-tools/docs/wall.md`). Checked 2026-11-24: the binary this script builds and snes-python's own build (the same archive and flags) gave byte-identical `OUT.raw`, `--regs` and `--final` outputs for 32,000 samples on each of the 1,028 .spc files in snes-python's DSP set (16 synthetic, 1,012 from games). ## Smoke test `python3 -I tests/smoke.py`: `--version` and the usage exit code without a build; with `build/spc_dump`, an .spc file written by the test (an endless loop, every DSP register zero) played for 1000 samples: silence, the three outputs' sizes, and the same bytes in two runs. ## For consumers (snes-python, s-dsp-python) Run `"$EMU_TOOLS_GPL/tools/snes-spc/build.sh"` once and run `$EMU_TOOLS_GPL/tools/snes-spc/build/spc_dump` instead of building `reference/dsp/build/spc_dump` from a fetched archive; then the consumer no longer fetches or keeps `snes_spc-0.9.0.zip` (drop it from its pinned-files list and its build script). A consumer that wants to keep compiling the driver itself finds it at `$EMU_TOOLS_GPL/tools/snes-spc/spc_dump.cpp` (the old paths are links to it). The command line and outputs are unchanged. A missing `build/spc_dump` is a missing input: stop with exit status 3, naming `EMU_TOOLS_GPL` and the path.