Skip to content

Rachael's sound through the ports and her SPC700 - #105

Merged
skerkewitz-agent[bot] merged 1 commit into
developfrom
rachael-ports
Nov 30, 2026
Merged

skerkewitz-agent[bot] merged 1 commit into
developfrom
rachael-ports

Conversation

@skerkewitz-agent

Copy link
Copy Markdown
Contributor

What

This is step 2 of "Krautrecker's songs on the desktop and the web". The library on Rachael now talks to her sound CPU through the four ports, as on the SNES. A driver runs on her SPC700 (from #104) and writes her DSP; before, the library wrote the DSP itself.

One change from the roadmap: the driver is the kit's forwarding driver in every game, including games with Krautrecker songs. In dampf's emulator, Sprite Run's driver sets ADSR envelopes (ADSR1 $CF), echo (EDL 3) and looped samples, none of which Rachael's DSP plays yet. Running Krautrecker's driver on her now would fail the desktop check of both music projects on unheard. So it moves after the DSP step and becomes step 4. The roadmap says so.

How

  • Timing (lib/rachael/apu.c): the SPC700 and the DSP run together, 32 SPC700 cycles per sample (sdevkit__sound_render), so a driver's write lands on the sample it would on the SNES. The desktop frontend takes each tick's samples there instead of from sdevkit__dsp_render.
  • Waits: while the library waits for the driver's answer (sdevkit__apu_wait), the APU runs on, and the samples it makes are played first in the next frame. Beyond 2,048 samples they're skipped, as during a song's load: the desktop doesn't stand still for it the way the SNES does.
  • Failures: a driver that doesn't answer within ten seconds of its time, or that reads the boot ROM, fails the desktop check, with a line saying so.
  • The backend (lib/rachael/sfx.c):
    • Uploads still go straight into the audio RAM (Rachael has no boot ROM). Then the SPC700 jumps to $0200 and the backend waits for $5D.
    • sfx_dsp is now an exchange through the ports, as on the SNES.
    • In a game with songs, the forwarding driver goes to $0200 in place of Krautrecker's, after the aram hash took what the SNES uploads. The writes Rachael makes for the effects in that case (unmute, DIR at PLAY) also go through it; they aren't logged, since the SNES doesn't send them.
  • lib/sound/sfx_voices.h: the music driver state is set before the jump, so the backend knows what it starts. On the SNES this moves two stores; no worst case changed.
  • Power-on: ppu.c resets the APU with the sound. The C tests that link Rachael's files now list apu.c and spc700.c.

Verified

  • ./gradlew build: 1300 tests, 0 failed. ExamplesTest checks that sound.txt is still the same on the emulator and the desktop for every example. backend-output.txt is re-recorded: hashes only, cost-baseline.txt unchanged.

  • Desktop checks: steinschlag, schach, music and hello all pass, with unheard 0 and no hangs.

  • The effects sound as before. I compared each example's --wav output with the same run on develop:

    • music: identical, shifted by 5 samples (mean difference 0.00);
    • steinschlag: best shift 5 samples, mean difference 34 against a mean level of 1286;
    • schach: best shift 10 samples, mean difference 47 against 856.

    The shift is the driver's exchanges: an effect starts after them, as on the SNES, where it used to start at once.

  • dampf's output and the SNES are unchanged apart from the two stores, so I didn't run the benchmark.

What follows

  • The game: nothing changes until it builds for the desktop with this kit; its effects then start a few samples later. No entry in docs/game-findings.md.
  • Documents: docs/sound.md (On Rachael), docs/roadmap.md (step 2 built, Krautrecker's driver as step 4, the gallery as step 5).
  • Book pages stale at the release: guide/the-desktop and guide/graphics-and-sound, if they describe how Rachael plays effects.

Open

Step 3, the rest of Rachael's DSP (ADSR, GAIN's modes, loops, noise, pitch modulation, echo), then step 4, Krautrecker's driver on her.

🤖 Generated with Claude Code

The library's DSP writes go through the ports to the kit's forwarding
driver on Rachael's SPC700, which writes her DSP, as on the SNES. The
SPC700 and the DSP run together, 32 cycles a sample; what they make
while the library waits for the driver is played by the next frame, and
of a long wait more than 2,048 samples are skipped. A driver that hangs
or reads the boot ROM fails the desktop's check.

In a game with songs she runs the forwarding driver too, since her DSP
does not play yet what Krautrecker's driver writes; the roadmap moves
Krautrecker's driver on Rachael after the DSP's step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skerkewitz-agent
skerkewitz-agent Bot merged commit 28dcbd7 into develop Nov 30, 2026
1 check passed
@skerkewitz-agent
skerkewitz-agent Bot deleted the rachael-ports branch November 30, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant