Skip to content

Krautrecker's driver on Rachael's SPC700 (step 4) - #107

Open
skerkewitz-agent[bot] wants to merge 1 commit into
developfrom
rachael-driver
Open

skerkewitz-agent[bot] wants to merge 1 commit into
developfrom
rachael-driver

Conversation

@skerkewitz-agent

Copy link
Copy Markdown
Contributor

What

Step 4 of "the desktop plays Krautrecker's songs by running its driver" (ADR-6G3QXFJ0): in a game with songs, Rachael now runs Krautrecker's driver on her SPC700, as the SNES does. Until now she ran the kit's forwarding driver there. The songs now play on the desktop and the web, and the effects pass through Krautrecker's driver as on the SNES.

How

  • lib/rachael/sfx.c: the driver uploaded by the game stays at $0200 (no more swap for the forwarding driver). Commands go through the ports with their argument on ports 2-3, and a LOAD's bytes go three per exchange, as lib/snes/sfx.c sends them. The sound.txt lines are still taken on the CPU side, so the checks compare the same thing as before.
  • lib/sound/sfx_voices.h, lib/snes/sfx.c: snd_driver_started and snd_played are gone. They existed only so that Rachael could imitate the driver, and on the SNES they were empty.
  • lib/rachael/apu.c: an optional hook on her SPC700's DSP writes (dsp_written, null unless a test sets it).
  • The test: RachaelDriverTest compiles rachael/driver_run.c with the library's own sfx.c and starts the song of examples/music the way a game does: sdevkit_music_init, then sdevkit_music_play, which uploads, LOADs and PLAYs through the ports. It logs every DSP write from the PLAY on, together with the driver's tick, and compares the log with a recording of Mesen (rachael/sprite_run-mesen.txt).
  • The recording: Mesen does not call a Lua script on the SPC700's writes when it runs a ROM; I tried exec, read and write callbacks, and none fired. It does when it plays a .spc, which is how Krautrecker's own Mesen check works. So dev/record_mesen_dsp.sh takes the song's full export (with song.spc), plays it in Mesen with dev/mesen_dsp.lua to 40 ticks past the end, and writes "tick reg value" lines. The recording is checked in (163 KB), so the test runs in every build, in CI too, without Mesen.

Verified

  • RachaelDriverTest: 15,189 DSP writes in 3,112 ticks of the driver, the loop back included, the same as Mesen's, each in the same tick. A write changed by hand in the recording fails the test, which names it ("write 4997 of 15189: 1152 32 a7 here, 1152 32 ff in Mesen").
  • Before writing the test, I also played the same .spc directly on Rachael's APU: identical to Mesen too.
  • ./gradlew build: 1,302 tests, 0 failed, 5 skipped. BackendOutputTest was re-recorded (hashes, and the two removed functions in the cost baseline).
  • dev/compare_example.sh music: Mesen and the desktop give the same pictures, 300 ticks of the same checksums, and the same 33 lines of sound.txt.
  • The desktop check's WAV of examples/music has the song: it is silent from the stop at tick 139 to the next start at 200, as check.txt presses.
  • Not checked: listening in the window or the browser.

What follows

  • Generated code: the SNES library loses two empty functions and their calls (snd_driver_started, snd_played, 42 cycles each in the cost baseline); nothing else changes.
  • C guide and its StyleGuideTest rules: unchanged.
  • The game: nothing changes for it. No entry in docs/game-findings.md.
  • Documents: docs/sound.md (On Rachael, The checks, Music, Not built), docs/testing.md, docs/roadmap.md (step 4 built), lib/README.md, lib/SNES_HARDWARE.md, examples/music/README.md, and the comments in snes.h, main.c, rachael.h, music.c.
  • Stale book pages at the release: reference/console-api.md (from snes.h), and the music part of guide/graphics-and-sound.md, which was already out of date since the zips came in.

Open

  • The recording can only be redone from the song's full export, because the stripped zip in the repository has no .spc. Krautrecker writes the full export ("Export for SNES").
  • Step 5, examples/music in the site's gallery, comes next.

🤖 Generated with Claude Code

In a game with songs Rachael now runs Krautrecker's driver, as the SNES does, in place of the
kit's forwarding driver: the song plays on the desktop and the web, the effects pass through
the driver, and the commands and the LOAD go through the ports, three bytes an exchange. The
two hooks only Rachael needed (snd_driver_started, snd_played) are gone from sfx_voices.h.

RachaelDriverTest starts the song of examples/music through lib/rachael/sfx.c and compares
every DSP write of her SPC700, with the driver's tick, against a recording of Mesen
(rachael/sprite_run-mesen.txt, dev/record_mesen_dsp.sh from the song's .spc): 15,189 writes
in 3,112 ticks, the loop back included, all the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skerkewitz-agent
skerkewitz-agent Bot requested a review from skerkewitz December 1, 2026 11:09

This branch has not been deployed

No deployments
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.

0 participants