Skip to content

SWI 0x22 — SoundWhatever2 (MusicPlayerStop / MPlayStop)

  • Entry: 0x000014C0 (THUMB; SWI table stores 0x000014C1)
  • Status: verified (hardware-checked 2026-07-08: cycle counts and return registers measured on real GBA; struct layouts remain from static analysis)

Summary

Behaviorally the sequencer MPlayStop: halts playback on a MusicPlayerInfo, stopping every track and marking the player stopped, so its voices go silent on the next mixer pass.

Parameters

Reg In Meaning
r0 ptr MusicPlayerInfo (identity 0x68736d53 at +0x34)

Returns

No return value.

Clobbered registers

r0–r7.

Hardware audit (2026-07-08, canary r4–r12 + CPSR snapshot): caller-visible clobbers: r0 = 0x14E7 leftover, r1 = 0, r3 = 0x170 leftover. r2, r4–r12, r13, and CPSR (flags and mode) came back bit-identical on every tested path. r11/r12 are explained by the SWI dispatcher (it pushes {r11, r12, lr} — see 10_irq_boot_and_iwram.md) and CPSR by the SPSR restore on return; r2 and r4–r10 must be preserved or restored by the routine itself — where a static note above claims r2 is destroyed, the hardware disagrees at the caller level. Raw data: results/clobber_audit_pass2.csv.

Algorithm

  1. Verify MusicPlayerInfo identity (+0x34); no-op if not open. Bump it as a busy lock.
  2. Set the "stopped" flag (bit 0 / value 1) in the player flags word (+0x04).
  3. For each opened track (count at +0x08, array at +0x2C, stride 0x50): call the per-track stop/silence helper (0x23E6) so the track releases its voice.
  4. Restore the identity word and return.

Edge cases & known bugs

  • No-op if the MusicPlayerInfo is not a valid opened player.
  • Only flags the player and tracks as stopped; the actual silencing happens when the mixer/updater next runs.

Cycle count

Hardware-measured net CPU cycles (worker-ROM harness, TM0/TM1 cascade at F/1, 13-cycle baseline subtracted; identical across 3 runs — see 02_hardware_verification_checklist.md § Measurement setup).

285 cycles (4-track player, stable across states).

Open questions (need hardware verification)

  • Exact contract of the track helper (0x23E6) — immediate cut vs. release.
  • Flag-bit semantics in the player flags word.

GBATEK cross-reference

Identifies GBATEK's reserved SWI 0x22 as the sequencer MPlayStop.