Hot-swapping APU programs at runtime — apuReset() in action.
The apu module's upload path (apuWaitBoot/apuUpload/apuExecute) runs once, at boot. This example adds the missing capability: replacing the running APU program at ANY time. The method is krom (Peter Lemon)'s PlayTwoSong protocol, productized: the 65816 writes APU_RESET_MAGIC to I/O port 0 (apuReset()); the SPC700 program polls for it in its wait loops (the APU_CHECK_RESET idiom), silences the DSP, and jumps back to the IPL boot ROM — ready for the next upload.
Press A for the play_noise drum kit, B for the pitch_mod vibrato cello. Both APU programs are this repo's own — no external assets beyond the cello sample already attributed.
ROM mode: LoROM (project default).
- SNES Concepts
- Cooperative APU reset: CPU→APU messaging over $2140 after boot
- The IPL ROM is re-entrant — jump to $FFC0 with the ROM re-enabled and the full boot handshake ($AA/$BB, $CC upload) works again
- Two independent APU programs in one ROM, uploaded on demand
- What to Observe
- Drums start immediately. Press B: the kit cuts, the cello blooms. Press A: back to the drums. The backdrop tracks the active program (red = drums, amber = cello). Swap latency is a few frames — the SPC polls for the reset request every millisecond.
- Modules Used
- console, apu, input
- See also
- https://github.com/PeterLemon/SNES — PlayTwoSong, the original protocol demo (its songs use samples ripped from commercial games, so this port swaps between two OpenSNES-native programs instead)
-
drums.spc700.asm, cello.spc700.asm — the two APU programs