Sound and music
This page is a guide to the games/tla/src/sound/ folder of the Alchemy
project, where the high-level music and sound effects code that scores Golden
Sun: The Lost Age is kept.
Every town theme, battle track, jingle, and spell sound runs through
sySoundPlay in sound.c, which also manages BGM volume ramps, the
debug sound test, and the heard-track bitfield for the Battle Arena. To hold the
sequel's larger soundtrack, The Lost Age extends BGM into the 700+ range and
layers five TLA-specific files into sdk/.
The notes below cover sound ID ranges, four-player SFX fallback, area and battle music rules, the IWRAM mixer, and MIDI and WAV naming, followed by the file map. Sound ID ranges, player fallback, and VBlank ducking concepts are explained in Graphics & Sound.
How it works, and sdk/ overrides
- ID dispatch and 4-player SFX fallback (
sound.c,include/sounds.h): IDs0–79loop as BGM,80–99play as jingles, and100–699play as SFX (with unused rows namedSE_UNUSED_*). IDs700+hold 31 additional TLA BGM tracks.sySoundFlagSetmarks every played ID for the Battle Arena sound test, whereL + R + Selectunlocks all tracks. Sounds assigned toMUSIC_PLAYER_SE_LASTsearch back through 3 prior SFX players (4 total) for an idle slot before cutting off their own channel. - Area and battle rules (
field/music_rules.s,field/field_engine_encounter.c):fdChooseMusicscans priority-ordered area, entrance, and flag rules (Daila has 2 rules, and the World Map has 6). Normal battle themes pick sea music while sailing before the ship gains wings, or choose a theme by front-row party lead (Felix, Isaac, or Jenna). Bosses override the theme throughEncounterBattleMusic(field/battle_music.c). - IWRAM mixer and
sdk/: Reconstructedm4aroutines are kept incommon/sdk/sound(SDK notes). Camelot's 528-sample-per-frame IWRAM mixer (31,536 Hz) placesresident_mixer.sinsystem/to share the-fcall-used-r4ABI.sdk/adds six TLA-specific files:mplay_main.s: TLA'sMPlayMain,ply_note, stereo volume calculation, channel unlink, and unreferencedm4aSoundInitWorkCopyROM copies.leftover_driver.s,leftover_modulation_helpers.c: Unreferenced older fragments ofMPlayMain,ply_note, the modulation commands' helpers, andMidiKeyToFreqpreserved in ROM.player_work_copy.c,dummy_func_work_copy.c, andbios_sound_driver_mode.s: TLA-specificm4awork copies and BIOS wrappers (BiosSoundDriverMode,BiosSwi23).
- MIDI and WAV naming (
sound/): Music samples take their names from General MIDI voices or drum key slots, such astimpani.pcm8.wavandside_stick.pcm8.wav. SFX samples are named for the sound itself, such asrumble.pcm8.wav.
File map
| Path | Role |
|---|---|
sound.c, sound_test.c, stubs.s | sySoundPlay, sySoundFlagSet, sySoundUpdateBGMRamps, debug sound test, and stubs |
sounds.h, sound_driver_symbols.h | All MUS_* and SE_* enums, player indices, 700+ range, and reverb definitions |
music_rules.s, battle_music.c, field_engine_encounter.c | Area music rules (fdChooseMusic), boss battle tracks (EncounterBattleMusic), and ship- and front-row-aware battle music (fdEncounterSelectBattleMusic) |
resident_mixer.s, system/channel_update_entry.s | Camelot's 528-sample-per-frame IWRAM mixer (-fcall-used-r4, 31,536 Hz) |
common/sdk/sound and sdk/ | Reconstructed m4a routines plus TLA overrides and leftover ROM fragments |
sound | MIDI songs (songs/*.mid), 8-bit PCM WAV samples (direct_sound_samples/*.pcm8.wav), voice groups, and song_table.s |
Source files
| File | Description |
|---|---|
sdk/dummy_func_work_copy.c | An older copy of the sound driver's empty callback, which the ROM keeps beside the driver with the player functions of player_work_copy.c. |
sdk/leftover_modulation_helpers.c | The older copies of the LFOS and MOD commands' helpers that the cartridge keeps with the leftover driver functions of leftover_driver.s, which alone call them: their bytes are those of clear_modM and ld_r3_tp_adr_i_unchecked (games/common/sdk/sound/modulation_helpers.c). |
sdk/player_work_copy.c | Two player functions of an older copy of the SDK's sound library that the ROM keeps beside the driver. |
sound.c | The game's own sound code over the sound driver, as The Broken Seal's: sySoundPlay, which takes every sound number, the music's volume and tempo ramps, and the music's return after a jingle. |
sound_test.c | The sound test, which nothing in the game calls; the heard-sound flags the link lobby offers its tunes by; and the fixed 31536 Hz output rate the game sets at start-up. |
| File | Description |
|---|---|
sound.h | The game's sound: sySoundPlay and the music's volume and tempo ramps (sound.c), the sound test and the heard-sound flags (sound_test.c), over the development kit's sound driver (sdk/sound_driver.h). |
sound_driver_symbols.h | What the game sets over the sound driver: the music's player, the sound numbers sySoundPlay takes and their ranges, the music players by row, the mixer's reverb codes, and the music's volume and tempo ramps. |
stubs.h | The stub calls into the sound module, as the other modules' code calls them. |