Repository navigation
DSP replay
Checks a DSP model against the console microcode. A port records what the CPU hands the audio
DSP and what its model returns; dsp-replay feeds the same input to Dolphin's DSP LLE
interpreter running the game's own uploaded microcode, and compares.
starlet::dsp::Recorder (include/starlet/dsp/recording.hpp) takes, in order:
- CPU writes to the DSP mailbox and control register,
- ARAM written by the CPU's ARAM DMA,
- main memory the model reads or writes, through
main_accessbefore it does, - the model's mails and interrupts.
The record holds only what changed: a byte of main memory is written again only when it differs
from what the replay already holds. Each step (the model's work between two CPU events) ends with
the ranges the model touched and the bytes it changed. Recordings hold game data: keep them in
.agents/, never in git.
gc-recomp records with GCRT_DSP_RECORD=FILE; while recording, its JAudio model renders on the CPU
thread so each step's work falls between the CPU events that bound it.
tools/dsp_replay/fetch_dolphin.sh .agents/dolphin
cmake -S . -B build/dsp-replay -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTARLET_TESTS=OFF \
-DSTARLET_DSP_REPLAY=ON -DDOLPHIN_DIR=$PWD/.agents/dolphin
ninja -C build/dsp-replay dsp-replay
build/dsp-replay/tools/dsp_replay/dsp-replay FILE .agents/dolphin/Data/Sys/GC --verbose 1The ROM is Dolphin's free DSP ROM (Data/Sys/GC, source in docs/DSP/free_dsp_rom). The
replayer builds Dolphin's interpreter (GPL-2.0-or-later) with tools/dsp_replay/shim, which
stands in for Dolphin's logging, memory and timing services.
Per step the replayer loads the recorded main memory, gives the DSP the CPU's input, runs it until the step's mails and interrupts are out and the DSP polls an empty mailbox, then compares:
- mails, in order, and the interrupt count,
- every byte in the ranges the model touched, against the model's result,
- DSP writes outside those ranges, and DSP reads of memory the record never held.
The step then continues from the recorded result, so a difference shows where it starts and does
not spread. MATCH means bit-exact on all of these; --dump-steps FILE writes one line per step.
- The free ROM's coefficient table (
dsp_coef.bin) is a reproduction; microcode that reads it (the accelerator's polyphase resampling does not, JAudio's interpolation tables may) can differ from a console. - The replay checks what the model touched. Main memory the DSP writes but the model does not is reported as "writes outside the recorded ranges".
- The replay is open loop: the CPU input is what the game sent in answer to the recorded model. Where the model's protocol differs from the microcode's (other mail values, interrupts at other points), the game would have sent the console other input, and memory differences after that step are not meaningful until the model's protocol matches.
gc-recomp can run the game against the LLE instead of its model (GCRT_DSP_LLE=ROM_DIR, built
with GC_DSP_LLE=ON), so the CPU answers the microcode itself. GCRT_DSP_COMPARE=FILE also runs
the model on the same CPU input and writes one line per render command: mails, interrupts and
output words that differ. This avoids the open-loop limit above.
Luigi's Mansion (GLME01, microcode 64d75375):
- The LLE loads the same microcode (same hash) through the free ROM's boot handshake.
- Protocol: the microcode greets with 0x88881111 and acks each command with 0x80000000 | its
handler's address (0x62 + 2 * command), the 0x82 render command with its sub-frame count
(0x80000007). Inside a render command each mail starts one 80-sample sub-frame, which raises
the interrupt after its voices and before its output DMA. Dolphin's Zelda HLE
(
LIGHT_PROTOCOL) documents the same acks. - The replayer must run Dolphin's analyzer on each microcode upload (as Dolphin's own host does):
without it every
bloopruns once and the microcode renders one sub-frame per command. - Closed loop, 45 s from boot to the title:
starlet::dsp's model matches the LLE in all 2570 mails, all 17969 interrupts, 2,875,040 output words and 15,104,896 words of voice write-back and other DMA.