diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index a89049eb..1d2fd9e6 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3893,6 +3893,12 @@ function seq_player_unlower_volume(player, fadeDuration) -- ... end +--- @param fadeOutTime integer +--- @return nil +function set_audio_fadeout(fadeOutTime) + -- ... +end + --- @param player integer --- @param bankMask integer --- @return nil @@ -3913,6 +3919,12 @@ function stop_background_music(seqId) -- ... end +--- @param fadeTimer integer +--- @return nil +function stop_secondary_music(fadeTimer) + -- ... +end + --- @param soundBits integer --- @param pos Vec3f --- @return nil diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index e9cc9a5f..17274cfa 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -2910,6 +2910,26 @@
+## [set_audio_fadeout](#set_audio_fadeout) + +### Lua Example +`set_audio_fadeout(fadeOutTime)` + +### Parameters +| Field | Type | +| ----- | ---- | +| fadeOutTime | `integer` | + +### Returns +- None + +### C Prototype +`void set_audio_fadeout(u16 fadeOutTime);` + +[:arrow_up_small:](#) + +
+ ## [sound_banks_disable](#sound_banks_disable) ### Lua Example @@ -2972,6 +2992,26 @@
+## [stop_secondary_music](#stop_secondary_music) + +### Lua Example +`stop_secondary_music(fadeTimer)` + +### Parameters +| Field | Type | +| ----- | ---- | +| fadeTimer | `integer` | + +### Returns +- None + +### C Prototype +`void stop_secondary_music(u16 fadeTimer);` + +[:arrow_up_small:](#) + +
+ ## [stop_sound](#stop_sound) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index fe4e7c93..4e8c6d49 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -766,9 +766,11 @@ - [seq_player_fade_out](functions-3.md#seq_player_fade_out) - [seq_player_lower_volume](functions-3.md#seq_player_lower_volume) - [seq_player_unlower_volume](functions-3.md#seq_player_unlower_volume) + - [set_audio_fadeout](functions-3.md#set_audio_fadeout) - [sound_banks_disable](functions-3.md#sound_banks_disable) - [sound_banks_enable](functions-3.md#sound_banks_enable) - [stop_background_music](functions-3.md#stop_background_music) + - [stop_secondary_music](functions-3.md#stop_secondary_music) - [stop_sound](functions-3.md#stop_sound) - [stop_sounds_from_source](functions-3.md#stop_sounds_from_source) - [stop_sounds_in_continuous_banks](functions-3.md#stop_sounds_in_continuous_banks) diff --git a/src/audio/external.c b/src/audio/external.c index c66352bf..5769648f 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -5,6 +5,7 @@ #include "data.h" #include "seqplayer.h" #include "external.h" +#include "internal.h" #include "playback.h" #include "synthesis.h" #include "game/level_update.h" @@ -424,11 +425,11 @@ u16 sSoundBanksThatLowerBackgroundMusic = 0; u8 sUnused80332114 = 0; // never read, set to 0 u16 sUnused80332118 = 0; // never read, set to 0 u8 sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_UNSET; -u8 D_80332120 = 0; -u8 D_80332124 = 0; +u8 sCurrentSecondaryMusicSeqId = 0; +u8 sCurrentSecondaryMusicVolume = 0; #if defined(VERSION_EU) || defined(VERSION_SH) -u8 D_EU_80300558 = 0; +u8 sRemainingEnvFadeInSkips = 0; #endif u8 sBackgroundMusicQueueSize = 0; @@ -453,7 +454,7 @@ s8 D_SH_80343E48_pad[0x8]; #endif struct Sound sSoundRequests[0x100] = { 0 }; -struct ChannelVolumeScaleFade D_80360928[SEQUENCE_PLAYERS][CHANNELS_MAX] = { 0 }; +struct ChannelVolumeScaleFade sVolumeScaleFades[SEQUENCE_PLAYERS][CHANNELS_MAX] = { 0 }; u8 sUsedChannelsForSoundBank[SOUND_BANK_COUNT] = { 0 }; u8 sCurrentSound[SOUND_BANK_COUNT][MAX_CHANNELS_PER_SOUND_BANK] = { 0 }; // index into sSoundBanks @@ -510,7 +511,7 @@ static void update_game_sound(void); static void fade_channel_volume_scale(u8 player, u8 channelId, u8 targetScale, u16 fadeTimer); void process_level_music_dynamics(void); static u8 begin_background_music_fade(u16 fadeDuration); -void func_80320ED8(void); +void fade_in_env_music(void); static s16 get_level_dynamics(s16 levelNum, s16 index) { if (levelNum < 0 || levelNum >= LEVEL_COUNT) { @@ -820,7 +821,7 @@ void maybe_tick_game_sound(void) { void func_eu_802e9bec(s32 player, s32 channel, s32 arg2) { // EU verson of unused_803209D8 // chan->stopSomething2 = arg2? - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x08, player, channel, 0), (s8)arg2); + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_GENERAL_STOP, player, channel, 0), (s8)arg2); } #else @@ -1430,7 +1431,7 @@ static void update_game_sound(void) { if (sSoundMovingSpeed[bank] > 8) { #if defined(VERSION_EU) || defined(VERSION_SH) queue_audio_cmd_f32( - AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), + AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1)); #else value = get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1); @@ -1439,7 +1440,7 @@ static void update_game_sound(void) { #endif } else { #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1) * ((sSoundMovingSpeed[bank] + 8.0f) / 16)); #else @@ -1449,7 +1450,7 @@ static void update_game_sound(void) { #endif } #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_pan(*sSoundBanks[bank][soundIndex].x, *sSoundBanks[bank][soundIndex].z)); #else @@ -1462,7 +1463,7 @@ static void update_game_sound(void) { == (SOUND_MOVING_FLYING & SOUNDARGS_MASK_SOUNDID)) { #if defined(VERSION_EU) || defined(VERSION_SH) queue_audio_cmd_f32( - AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex) + ((f32) sSoundMovingSpeed[bank] / US_FLOAT(80.0))); #else @@ -1473,7 +1474,7 @@ static void update_game_sound(void) { } else { #if defined(VERSION_EU) || defined(VERSION_SH) queue_audio_cmd_f32( - AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex) + ((f32) sSoundMovingSpeed[bank] / US_FLOAT(400.0))); #else @@ -1483,7 +1484,7 @@ static void update_game_sound(void) { #endif } #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_reverb(bank, soundIndex, channelIndex)); #else gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb = @@ -1495,9 +1496,9 @@ static void update_game_sound(void) { // fallthrough case SOUND_BANK_MENU: #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), 1); - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), 64); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), 1); + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), 64); + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex)); #else gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume = 1.0f; @@ -1510,14 +1511,14 @@ static void update_game_sound(void) { case SOUND_BANK_LUIGI_VOICE: case SOUND_BANK_WARIO_VOICE: #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_reverb(bank, soundIndex, channelIndex)); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1)); - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_pan(*sSoundBanks[bank][soundIndex].x, *sSoundBanks[bank][soundIndex].z) * 127.0f + 0.5f); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex)); #else gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume = @@ -1538,14 +1539,14 @@ static void update_game_sound(void) { case SOUND_BANK_GENERAL2: case SOUND_BANK_OBJ2: #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_reverb(bank, soundIndex, channelIndex)); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK2)); - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_pan(*sSoundBanks[bank][soundIndex].x, *sSoundBanks[bank][soundIndex].z) * 127.0f + 0.5f); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex)); #else gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb = @@ -1603,7 +1604,7 @@ static void update_game_sound(void) { if (sSoundMovingSpeed[bank] > 8) { #if defined(VERSION_EU) || defined(VERSION_SH) queue_audio_cmd_f32( - AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), + AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1)); #else value = get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1); @@ -1612,7 +1613,7 @@ static void update_game_sound(void) { #endif } else { #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1) * ((sSoundMovingSpeed[bank] + 8.0f) / 16)); #else @@ -1622,7 +1623,7 @@ static void update_game_sound(void) { #endif } #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_pan(*sSoundBanks[bank][soundIndex].x, *sSoundBanks[bank][soundIndex].z)); #else @@ -1635,7 +1636,7 @@ static void update_game_sound(void) { == (SOUND_MOVING_FLYING & SOUNDARGS_MASK_SOUNDID)) { #if defined(VERSION_EU) || defined(VERSION_SH) queue_audio_cmd_f32( - AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex) + ((f32) sSoundMovingSpeed[bank] / US_FLOAT(80.0))); #else @@ -1646,7 +1647,7 @@ static void update_game_sound(void) { } else { #if defined(VERSION_EU) || defined(VERSION_SH) queue_audio_cmd_f32( - AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex) + ((f32) sSoundMovingSpeed[bank] / US_FLOAT(400.0))); #else @@ -1656,7 +1657,7 @@ static void update_game_sound(void) { #endif } #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_reverb(bank, soundIndex, channelIndex)); #else gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb = @@ -1668,9 +1669,9 @@ static void update_game_sound(void) { // fallthrough case SOUND_BANK_MENU: #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), 1); - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), 64); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), 1); + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), 64); + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex)); #else gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume = 1.0f; @@ -1681,14 +1682,14 @@ static void update_game_sound(void) { case SOUND_BANK_ACTION: case SOUND_BANK_MARIO_VOICE: #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_reverb(bank, soundIndex, channelIndex)); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1)); - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_pan(*sSoundBanks[bank][soundIndex].x, *sSoundBanks[bank][soundIndex].z) * 127.0f + 0.5f); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex)); #else gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume = @@ -1709,14 +1710,14 @@ static void update_game_sound(void) { case SOUND_BANK_GENERAL2: case SOUND_BANK_OBJ2: #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_reverb(bank, soundIndex, channelIndex)); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK2)); - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_pan(*sSoundBanks[bank][soundIndex].x, *sSoundBanks[bank][soundIndex].z) * 127.0f + 0.5f); - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_freq_scale(bank, soundIndex)); #else gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb = @@ -1737,7 +1738,7 @@ static void update_game_sound(void) { // add custom pitch bend if (soundIndex < SOUND_INDEX_COUNT && sSoundBanks[bank][soundIndex].customFreqScale != 0) { #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0), + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0), gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->freqScale * sSoundBanks[bank][soundIndex].customFreqScale); #else @@ -1772,12 +1773,12 @@ static void seq_player_play_sequence(u8 player, u8 seqId, u16 arg2) { } for (i = 0; i < CHANNELS_MAX; i++) { - D_80360928[player][i].remainingFrames = 0; + sVolumeScaleFades[player][i].remainingFrames = 0; } #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x46, player, 0, 0), seqId & SEQ_VARIATION); - queue_audio_cmd_u32(AUDIO_CMD_ARGS(0x82, player, seqId & SEQ_BASE_ID, 0), arg2); + queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_SEQUENCE_VARIATION, player, 0, 0), seqId & SEQ_VARIATION); + queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_LOAD_SEQUENCE, player, seqId & SEQ_BASE_ID, 0), arg2); if (player == SEQ_PLAYER_LEVEL) { targetVolume = begin_background_music_fade(0); @@ -1815,7 +1816,7 @@ void seq_player_fade_out(u8 player, u16 fadeDuration) { if (!player) { sCurrentBackgroundMusicSeqId = SEQUENCE_NONE; } - queue_audio_cmd_u32(AUDIO_CMD_ARGS(0x83, player, 0, 0), fd); + queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_FADE_TO_ZERO_VOLUME, player, 0, 0), fd); #else if (player == SEQ_PLAYER_LEVEL) { sCurrentBackgroundMusicSeqId = SEQUENCE_NONE; @@ -1841,7 +1842,7 @@ static void fade_channel_volume_scale(u8 player, u8 channelIndex, u8 targetScale struct ChannelVolumeScaleFade *temp; if (gSequencePlayers[player].channels[channelIndex] != &gSequenceChannelNone) { - temp = &D_80360928[player][channelIndex]; + temp = &sVolumeScaleFades[player][channelIndex]; temp->remainingFrames = fadeDuration; temp->velocity = ((f32)(targetScale / US_FLOAT(127.0)) - gSequencePlayers[player].channels[channelIndex]->volumeScale) @@ -1854,31 +1855,29 @@ static void fade_channel_volume_scale(u8 player, u8 channelIndex, u8 targetScale /** * Called from threads: thread4_sound, thread5_game_loop (EU only) */ -static void func_8031F96C(u8 player) { - u8 i; - +static void fade_seqplayer_channels(u8 player) { // Loop over channels - for (i = 0; i < CHANNELS_MAX; i++) { + for (u8 i = 0; i < CHANNELS_MAX; i++) { if (gSequencePlayers[player].channels[i] != &gSequenceChannelNone - && D_80360928[player][i].remainingFrames != 0) { - D_80360928[player][i].current += D_80360928[player][i].velocity; + && sVolumeScaleFades[player][i].remainingFrames != 0) { + sVolumeScaleFades[player][i].current += sVolumeScaleFades[player][i].velocity; #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x01, player, i, 0), - D_80360928[player][i].current); + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME_SCALE, player, i, 0), + sVolumeScaleFades[player][i].current); #else - gSequencePlayers[player].channels[i]->volumeScale = D_80360928[player][i].current; + gSequencePlayers[player].channels[i]->volumeScale = sVolumeScaleFades[player][i].current; #endif - D_80360928[player][i].remainingFrames--; - if (D_80360928[player][i].remainingFrames == 0) { + sVolumeScaleFades[player][i].remainingFrames--; + if (sVolumeScaleFades[player][i].remainingFrames == 0) { #if defined(VERSION_EU) - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x01, player, i, 0), - FLOAT_CAST(D_80360928[player][i].target) / 127.0); + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME_SCALE, player, i, 0), + FLOAT_CAST(sVolumeScaleFades[player][i].target) / 127.0); #elif defined(VERSION_SH) - queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x01, player, i, 0), - FLOAT_CAST(D_80360928[player][i].target) / 127.0f); + queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME_SCALE, player, i, 0), + FLOAT_CAST(sVolumeScaleFades[player][i].target) / 127.0f); #else gSequencePlayers[player].channels[i]->volumeScale = - D_80360928[player][i].target / 127.0f; + sVolumeScaleFades[player][i].target / 127.0f; #endif } } @@ -1902,9 +1901,9 @@ void process_level_music_dynamics(void) { s16 dur2; u16 bit; - func_8031F96C(0); - func_8031F96C(2); - func_80320ED8(); + fade_seqplayer_channels(0); + fade_seqplayer_channels(2); + fade_in_env_music(); if (sMusicDynamicDelay != 0) { sMusicDynamicDelay--; } else { @@ -2149,9 +2148,9 @@ void set_audio_muted(u8 muted) { for (i = 0; i < SEQUENCE_PLAYERS; i++) { #if defined(VERSION_EU) || defined(VERSION_SH) if (muted) - queue_audio_cmd_u32(AUDIO_CMD_ARGS(0xf1, 0, 0, 0), 0); + queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_MUTE_ALL_SEQUENCE_PLAYERS, 0, 0, 0), 0); else - queue_audio_cmd_u32(AUDIO_CMD_ARGS(0xf2, 0, 0, 0), 0); + queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_UNMUTE_ALL_SEQUENCE_PLAYERS, 0, 0, 0), 0); #else gSequencePlayers[i].muted = muted; #endif @@ -2187,7 +2186,7 @@ void sound_init(void) { sSoundBanks[i][0].next = 0xff; // Set free list to contain every sound slot - for (j = 1; j < 40 - 1; j++) { + for (j = 1; j < SOUND_INDEX_COUNT - 1; j++) { sSoundBanks[i][j].prev = j - 1; sSoundBanks[i][j].next = j + 1; } @@ -2197,7 +2196,7 @@ void sound_init(void) { for (j = 0; j < 3; j++) { for (i = 0; i < CHANNELS_MAX; i++) { - D_80360928[j][i].remainingFrames = 0; + sVolumeScaleFades[j][i].remainingFrames = 0; } } @@ -2216,8 +2215,8 @@ void sound_init(void) { gSoundMode = SOUND_MODE_STEREO; sBackgroundMusicQueueSize = 0; sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_UNSET; - D_80332120 = 0; - D_80332124 = 0; + sCurrentSecondaryMusicSeqId = 0; + sCurrentSecondaryMusicVolume = 0; sNumProcessedSoundRequests = 0; sSoundRequestCount = 0; } @@ -2595,14 +2594,14 @@ u8 is_current_background_music_volume_lowered(void) { /** * Called from threads: thread4_sound, thread5_game_loop (EU only) */ -void func_80320ED8(void) { +void fade_in_env_music(void) { #if defined(VERSION_EU) || defined(VERSION_SH) - if (D_EU_80300558 != 0) { - D_EU_80300558--; + if (sRemainingEnvFadeInSkips != 0) { + sRemainingEnvFadeInSkips--; } if (gSequencePlayers[SEQ_PLAYER_ENV].enabled - || sBackgroundMusicMaxTargetVolume == TARGET_VOLUME_UNSET || D_EU_80300558 != 0) { + || sBackgroundMusicMaxTargetVolume == TARGET_VOLUME_UNSET || sRemainingEnvFadeInSkips != 0) { #else if (gSequencePlayers[SEQ_PLAYER_ENV].enabled || sBackgroundMusicMaxTargetVolume == TARGET_VOLUME_UNSET) { @@ -2614,10 +2613,10 @@ void func_80320ED8(void) { begin_background_music_fade(50); if (sBackgroundMusicTargetVolume != TARGET_VOLUME_UNSET - && (D_80332120 == SEQ_EVENT_MERRY_GO_ROUND || D_80332120 == SEQ_EVENT_PIRANHA_PLANT)) { - seq_player_play_sequence(SEQ_PLAYER_ENV, D_80332120, 1); - if (D_80332124 != 0xff) { - seq_player_fade_to_target_volume(SEQ_PLAYER_ENV, 1, D_80332124); + && (sCurrentSecondaryMusicSeqId == SEQ_EVENT_MERRY_GO_ROUND || sCurrentSecondaryMusicSeqId == SEQ_EVENT_PIRANHA_PLANT)) { + seq_player_play_sequence(SEQ_PLAYER_ENV, sCurrentSecondaryMusicSeqId, 1); + if (sCurrentSecondaryMusicVolume != 0xff) { + seq_player_fade_to_target_volume(SEQ_PLAYER_ENV, 1, sCurrentSecondaryMusicVolume); } } } @@ -2640,24 +2639,24 @@ void play_secondary_music(u8 seqId, u8 bgMusicVolume, u8 volume, u16 fadeTimer) if (volume < 0x80) { seq_player_fade_to_target_volume(SEQ_PLAYER_ENV, fadeTimer, volume); } - D_80332124 = volume; - D_80332120 = seqId; + sCurrentSecondaryMusicVolume = volume; + sCurrentSecondaryMusicSeqId = seqId; } else if (volume != 0xff) { sBackgroundMusicTargetVolume = bgMusicVolume + TARGET_VOLUME_IS_PRESENT_FLAG; begin_background_music_fade(fadeTimer); seq_player_fade_to_target_volume(SEQ_PLAYER_ENV, fadeTimer, volume); - D_80332124 = volume; + sCurrentSecondaryMusicVolume = volume; } } /** * Called from threads: thread5_game_loop */ -void func_80321080(u16 fadeTimer) { +void stop_secondary_music(u16 fadeTimer) { if (sBackgroundMusicTargetVolume != TARGET_VOLUME_UNSET) { sBackgroundMusicTargetVolume = TARGET_VOLUME_UNSET; - D_80332120 = 0; - D_80332124 = 0; + sCurrentSecondaryMusicSeqId = 0; + sCurrentSecondaryMusicVolume = 0; begin_background_music_fade(fadeTimer); seq_player_fade_out(SEQ_PLAYER_ENV, fadeTimer); } @@ -2666,16 +2665,14 @@ void func_80321080(u16 fadeTimer) { /** * Called from threads: thread3_main, thread5_game_loop */ -void func_803210D4(u16 fadeDuration) { - u8 i; - +void set_audio_fadeout(u16 fadeDuration) { if (sHasStartedFadeOut) { return; } if (gSequencePlayers[SEQ_PLAYER_LEVEL].enabled == TRUE) { #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_u32(AUDIO_CMD_ARGS(0x83, 0, 0, 0), fadeDuration); + queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_FADE_TO_ZERO_VOLUME, 0, 0, 0), fadeDuration); #else seq_player_fade_to_zero_volume(SEQ_PLAYER_LEVEL, fadeDuration); #endif @@ -2683,13 +2680,13 @@ void func_803210D4(u16 fadeDuration) { if (gSequencePlayers[SEQ_PLAYER_ENV].enabled == TRUE) { #if defined(VERSION_EU) || defined(VERSION_SH) - queue_audio_cmd_u32(AUDIO_CMD_ARGS(0x83, SEQ_PLAYER_ENV, 0, 0), fadeDuration); + queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_FADE_TO_ZERO_VOLUME, SEQ_PLAYER_ENV, 0, 0), fadeDuration); #else seq_player_fade_to_zero_volume(SEQ_PLAYER_ENV, fadeDuration); #endif } - for (i = 0; i < SOUND_BANK_COUNT; i++) { + for (s32 i = 0; i < SOUND_BANK_COUNT; i++) { if (i != SOUND_BANK_MENU) { fade_channel_volume_scale(SEQ_PLAYER_SFX, i, 0, fadeDuration / 16); } @@ -2705,7 +2702,7 @@ void play_course_clear(void) { seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_CUTSCENE_COLLECT_STAR, 0); sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 0; #if defined(VERSION_EU) || defined(VERSION_SH) - D_EU_80300558 = 2; + sRemainingEnvFadeInSkips = 2; #endif begin_background_music_fade(50); } @@ -2717,7 +2714,7 @@ void play_peachs_jingle(void) { seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_PEACH_MESSAGE, 0); sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 0; #if defined(VERSION_EU) || defined(VERSION_SH) - D_EU_80300558 = 2; + sRemainingEnvFadeInSkips = 2; #endif begin_background_music_fade(50); } @@ -2733,7 +2730,7 @@ void play_puzzle_jingle(void) { seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_SOLVE_PUZZLE, 0); sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20; #if defined(VERSION_EU) || defined(VERSION_SH) - D_EU_80300558 = 2; + sRemainingEnvFadeInSkips = 2; #endif begin_background_music_fade(50); } @@ -2745,7 +2742,7 @@ void play_star_fanfare(void) { seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_HIGH_SCORE, 0); sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20; #if defined(VERSION_EU) || defined(VERSION_SH) - D_EU_80300558 = 2; + sRemainingEnvFadeInSkips = 2; #endif begin_background_music_fade(50); } @@ -2760,7 +2757,7 @@ void play_power_star_jingle(u8 arg0) { seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_CUTSCENE_STAR_SPAWN, 0); sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20; #if defined(VERSION_EU) || defined(VERSION_SH) - D_EU_80300558 = 2; + sRemainingEnvFadeInSkips = 2; #endif begin_background_music_fade(50); } @@ -2772,7 +2769,7 @@ void play_race_fanfare(void) { seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_RACE, 0); sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20; #if defined(VERSION_EU) || defined(VERSION_SH) - D_EU_80300558 = 2; + sRemainingEnvFadeInSkips = 2; #endif begin_background_music_fade(50); } @@ -2784,7 +2781,7 @@ void play_toads_jingle(void) { seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_TOAD_MESSAGE, 0); sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20; #if defined(VERSION_EU) || defined(VERSION_SH) - D_EU_80300558 = 2; + sRemainingEnvFadeInSkips = 2; #endif begin_background_music_fade(50); } @@ -2803,7 +2800,7 @@ void sound_reset(u8 presetId) { disable_all_sequence_players(); sound_init(); #ifdef VERSION_SH - queue_audio_cmd_u32(AUDIO_CMD_ARGS(0xF2, 0, 0, 0), 0); + queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_UNMUTE_ALL_SEQUENCE_PLAYERS, 0, 0, 0), 0); #endif #if defined(VERSION_JP) || defined(VERSION_US) audio_reset_session(&gAudioSessionPresets[presetId]); diff --git a/src/audio/external.h b/src/audio/external.h index 3330e5f7..9e5005c3 100644 --- a/src/audio/external.h +++ b/src/audio/external.h @@ -10,10 +10,6 @@ // bit which may be read by the sequence script. #define SEQUENCE_ARGS(priority, seqId) ((priority << 8) | seqId) -#if defined(VERSION_EU) || defined(VERSION_SH) -#define AUDIO_CMD_ARGS(cmd, arg1, arg2, arg3) (((cmd & 0xff) << 24) | ((arg1 & 0xff) << 16) | ((arg2 & 0xff) << 8) | (arg3 & 0xff)) -#endif - #define SOUND_MODE_STEREO 0 #define SOUND_MODE_MONO 3 #define SOUND_MODE_HEADSET 1 @@ -65,8 +61,8 @@ u8 get_current_background_music_target_volume(void); u8 get_current_background_music_max_target_volume(void); u8 is_current_background_music_volume_lowered(void); void play_secondary_music(u8 seqId, u8 bgMusicVolume, u8 volume, u16 fadeTimer); -void func_80321080(u16 fadeTimer); -void func_803210D4(u16 fadeOutTime); +void stop_secondary_music(u16 fadeTimer); +void set_audio_fadeout(u16 fadeOutTime); void play_course_clear(void); void play_peachs_jingle(void); void play_puzzle_jingle(void); diff --git a/src/audio/internal.h b/src/audio/internal.h index b5bb13d1..e2c80648 100644 --- a/src/audio/internal.h +++ b/src/audio/internal.h @@ -86,6 +86,37 @@ #define eu_stubbed_printf_3(msg, a, b, c) #endif +#if defined(VERSION_EU) || defined(VERSION_SH) +#define AUDIO_CMD_ARGS(cmd, arg1, arg2, arg3) (((cmd & 0xff) << 24) | ((arg1 & 0xff) << 16) | ((arg2 & 0xff) << 8) | (arg3 & 0xff)) + +// Channel audio commands +#define AUDIO_CMD_VOLUME_SCALE 1 +#define AUDIO_CMD_VOLUME 2 +#define AUDIO_CMD_NEW_PAN 3 +#define AUDIO_CMD_FREQ_SCALE 4 +#define AUDIO_CMD_REVERB 5 +#define AUDIO_CMD_SOUND_SCRIPT 6 // Unused, There is spots it could be added, But it isn't in practice. +#define AUDIO_CMD_GENERAL_STOP 8 + +// Sequence player audio commands +#define AUDIO_CMD_FADE_VOLUME_SCALE 0x41 +#define AUDIO_CMD_SEQUENCE_VARIATION 0x46 +#define AUDIO_CMD_TEMPO 0x47 +#define AUDIO_CMD_TRANSPOSITION 0x48 + +// Sequence audio commands +#define AUDIO_CMD_PRELOAD_SEQUENCE 0x81 +#define AUDIO_CMD_LOAD_SEQUENCE 0x82 +#define AUDIO_CMD_FADE_TO_ZERO_VOLUME 0x83 +#define AUDIO_CMD_LOAD_SEQUENCE2 0x88 + +// Other audio commands +#define AUDIO_CMD_SOUND_MODE 0xf0 +#define AUDIO_CMD_MUTE_ALL_SEQUENCE_PLAYERS 0xf1 +#define AUDIO_CMD_UNMUTE_ALL_SEQUENCE_PLAYERS 0xf2 + +#endif + struct NotePool; struct AudioListItem diff --git a/src/audio/port_eu.c b/src/audio/port_eu.c index 05572f08..a95e129e 100644 --- a/src/audio/port_eu.c +++ b/src/audio/port_eu.c @@ -65,18 +65,18 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) { s32 i; switch (cmd->u.s.op) { - case 0x81: - preload_sequence(cmd->u.s.arg2, 3); + case AUDIO_CMD_PRELOAD_SEQUENCE: + preload_sequence(cmd->u.s.arg2, PRELOAD_BANKS | PRELOAD_SEQUENCE); break; - case 0x82: - case 0x88: + case AUDIO_CMD_LOAD_SEQUENCE: + case AUDIO_CMD_LOAD_SEQUENCE2: load_sequence(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3); seq_player_fade_from_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32); //LOG_DEBUG("Playing sequence with arguments: %d, 0x%X, %d", cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3); break; - case 0x83: + case AUDIO_CMD_FADE_TO_ZERO_VOLUME: if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) { if (cmd->u2.as_s32 == 0) { sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]); @@ -87,18 +87,18 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) { } break; - case 0xf0: + case AUDIO_CMD_SOUND_MODE: gSoundMode = cmd->u2.as_s32; break; - case 0xf1: + case AUDIO_CMD_MUTE_ALL_SEQUENCE_PLAYERS: for (i = 0; i < 4; i++) { gSequencePlayers[i].muted = TRUE; gSequencePlayers[i].recalculateVolume = TRUE; } break; - case 0xf2: + case AUDIO_CMD_UNMUTE_ALL_SEQUENCE_PLAYERS: for (i = 0; i < 4; i++) { gSequencePlayers[i].muted = FALSE; gSequencePlayers[i].recalculateVolume = TRUE; @@ -191,20 +191,20 @@ void process_queued_audio_cmds(u32 arg0) { } else if ((cmd->u.s.op & 0x40) != 0) { switch (cmd->u.s.op) { - case 0x41: + case AUDIO_CMD_FADE_VOLUME_SCALE: seqPlayer->fadeVolumeScale = cmd->u2.as_f32; seqPlayer->recalculateVolume = TRUE; break; - case 0x47: + case AUDIO_CMD_TEMPO: seqPlayer->tempo = cmd->u2.as_s32 * TATUMS_PER_BEAT; break; - case 0x48: + case AUDIO_CMD_TRANSPOSITION: seqPlayer->transposition = cmd->u2.as_s8; break; - case 0x46: + case AUDIO_CMD_SEQUENCE_VARIATION: seqPlayer->seqVariationEu[cmd->u.s.arg3] = cmd->u2.as_s8; break; } @@ -214,31 +214,31 @@ void process_queued_audio_cmds(u32 arg0) { if (IS_SEQUENCE_CHANNEL_VALID(chan)) { switch (cmd->u.s.op) { - case 1: + case AUDIO_CMD_VOLUME_SCALE: chan->volumeScale = cmd->u2.as_f32; chan->changes.as_bitfields.volume = TRUE; break; - case 2: + case AUDIO_CMD_VOLUME: chan->volume = cmd->u2.as_f32; chan->changes.as_bitfields.volume = TRUE; break; - case 3: + case AUDIO_CMD_NEW_PAN: chan->newPan = cmd->u2.as_s8; chan->changes.as_bitfields.pan = TRUE; break; - case 4: + case AUDIO_CMD_FREQ_SCALE: chan->freqScale = cmd->u2.as_f32; chan->changes.as_bitfields.freqScale = TRUE; break; - case 5: + case AUDIO_CMD_REVERB: chan->reverb = cmd->u2.as_s8; break; - case 6: + case AUDIO_CMD_SOUND_SCRIPT: if (cmd->u.s.arg3 < 8) { chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8; } break; - case 8: + case AUDIO_CMD_GENERAL_STOP: chan->stopSomething2 = cmd->u2.as_s8; } } diff --git a/src/game/behaviors/bbh_merry_go_round.inc.c b/src/game/behaviors/bbh_merry_go_round.inc.c index 5cf3f0f6..628b6a3d 100644 --- a/src/game/behaviors/bbh_merry_go_round.inc.c +++ b/src/game/behaviors/bbh_merry_go_round.inc.c @@ -52,7 +52,7 @@ static void handle_merry_go_round_music(void) { // The merry-go-round is a dynamic surface. gMarioCurrentRoom != BBH_DYNAMIC_SURFACE_ROOM && gMarioCurrentRoom != BBH_NEAR_MERRY_GO_ROUND_ROOM) { - func_80321080(300); // Switch to BBH music? FIXME: Audio needs labelling + stop_secondary_music(300); // Switch to BBH music? FIXME: Audio needs labelling o->oMerryGoRoundMusicShouldPlay = FALSE; } else { cur_obj_play_sound_1(SOUND_ENV_MERRY_GO_ROUND_CREAKING); @@ -93,6 +93,6 @@ void bhv_merry_go_round_loop(void) { handle_merry_go_round_music(); } else { o->oAngleVelYaw = 0; - func_80321080(300); // Switch to BBH music? FIXME: Audio needs labelling + stop_secondary_music(300); // Switch to BBH music? FIXME: Audio needs labelling } } diff --git a/src/game/behaviors/piranha_plant.inc.c b/src/game/behaviors/piranha_plant.inc.c index 487c0647..3ed0a414 100644 --- a/src/game/behaviors/piranha_plant.inc.c +++ b/src/game/behaviors/piranha_plant.inc.c @@ -42,7 +42,7 @@ s32 piranha_plant_check_interactions(void) { s32 i; s32 interacted = 1; if (o->oInteractStatus & INT_STATUS_INTERACTED) { - func_80321080(50); + stop_secondary_music(50); if (o->oInteractStatus & INT_STATUS_WAS_ATTACKED) { cur_obj_play_sound_2(SOUND_OBJ2_PIRANHA_PLANT_DYING); @@ -104,7 +104,7 @@ void piranha_plant_act_sleeping(void) { o->oPiranhaPlantSleepMusicState = PIRANHA_PLANT_SLEEP_MUSIC_PLAYING; } else if (o->oPiranhaPlantSleepMusicState == PIRANHA_PLANT_SLEEP_MUSIC_PLAYING) { o->oPiranhaPlantSleepMusicState++; - func_80321080(50); + stop_secondary_music(50); } piranha_plant_check_interactions(); } @@ -123,7 +123,7 @@ void piranha_plant_act_woken_up(void) { o->oDamageOrCoinValue = 3; #endif if (o->oTimer == 0) - func_80321080(50); + stop_secondary_music(50); if (piranha_plant_check_interactions() == 0) { if (o->oTimer > 10) { diff --git a/src/game/sound_init.c b/src/game/sound_init.c index 704b6110..de09a93f 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -214,7 +214,7 @@ void play_infinite_stairs_music(void) { if (shouldPlay) { play_secondary_music(SEQ_EVENT_ENDLESS_STAIRS, 0, 255, 1000); } else { - func_80321080(500); + stop_secondary_music(500); } } } @@ -241,7 +241,7 @@ void set_background_music(u16 a, u16 seqArgs, s16 fadeTimer) { * Called from threads: thread3_main, thread5_game_loop */ void fadeout_music(s16 fadeOutTime) { - func_803210D4(fadeOutTime); + set_audio_fadeout(fadeOutTime); sCurrentMusic = MUSIC_NONE; sCurrentShellMusic = MUSIC_NONE; sCurrentCapMusic = MUSIC_NONE; diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index b7a14bdf..d76c6179 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -10,6 +10,7 @@ char gSmluaConstants[] = "" " return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil\n" " end\n" "}\n" +"\n" "_CPointer = {\n" " __index = function (t,k)\n" " return nil\n" @@ -23,6 +24,7 @@ char gSmluaConstants[] = "" " return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil\n" " end\n" "}\n" +"\n" "_SyncTable = {\n" " __index = function (t,k)\n" " local _table = rawget(t, '_table')\n" @@ -34,6 +36,7 @@ char gSmluaConstants[] = "" " _set_sync_table_field(t, k, v)\n" " end\n" "}\n" +"\n" "_ReadOnlyTable = {\n" " __index = function (t,k)\n" " local _table = rawget(t, '_table')\n" @@ -42,6 +45,7 @@ char gSmluaConstants[] = "" " __newindex = function (t,k,v)\n" " end\n" "}\n" +"\n" "--- @param dest Vec3f\n" "--- @param src Vec3f\n" "--- @return Vec3f\n" @@ -51,6 +55,7 @@ char gSmluaConstants[] = "" " dest.z = src.z\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3f\n" "--- @param x number\n" "--- @param y number\n" @@ -62,6 +67,7 @@ char gSmluaConstants[] = "" " dest.z = z\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3f\n" "--- @param a Vec3f\n" "--- @return Vec3f\n" @@ -71,6 +77,7 @@ char gSmluaConstants[] = "" " dest.z = dest.z + a.z\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3f\n" "--- @param a Vec3f\n" "--- @param b Vec3f\n" @@ -81,6 +88,7 @@ char gSmluaConstants[] = "" " dest.z = a.z + b.z\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3f\n" "--- @param a number\n" "--- @return Vec3f\n" @@ -90,6 +98,7 @@ char gSmluaConstants[] = "" " dest.z = dest.z * a\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3f\n" "--- @return Vec3f\n" "function vec3f_normalize(dest)\n" @@ -97,23 +106,28 @@ char gSmluaConstants[] = "" " if divisor == 0 then\n" " return dest\n" " end\n" +"\n" " local invsqrt = 1.0 / divisor\n" " dest.x = dest.x * invsqrt\n" " dest.y = dest.y * invsqrt\n" " dest.z = dest.z * invsqrt\n" +"\n" " return dest\n" "end\n" +"\n" "--- @param a Vec3f\n" "--- @return number\n" "function vec3f_length(a)\n" " return math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z)\n" "end\n" +"\n" "--- @param a Vec3f\n" "--- @param b Vec3f\n" "--- @return number\n" "function vec3f_dot(a, b)\n" " return a.x * b.x + a.y * b.y + a.z * b.z\n" "end\n" +"\n" "--- @param vec Vec3f\n" "--- @param onto Vec3f\n" "--- @return Vec3f\n" @@ -125,6 +139,7 @@ char gSmluaConstants[] = "" " vec3f_mul(out, numerator / denominator)\n" " return out\n" "end\n" +"\n" "--- @param v1 Vec3f\n" "--- @param v2 Vec3f\n" "--- @return number\n" @@ -134,6 +149,7 @@ char gSmluaConstants[] = "" " dz = v1.z - v2.z\n" " return math.sqrt(dx * dx + dy * dy + dz * dz)\n" "end\n" +"\n" "--- @param dest Vec3s\n" "--- @param src Vec3s\n" "--- @return Vec3s\n" @@ -143,6 +159,7 @@ char gSmluaConstants[] = "" " dest.z = src.z\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3s\n" "--- @param x number\n" "--- @param y number\n" @@ -154,6 +171,7 @@ char gSmluaConstants[] = "" " dest.z = z\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3s\n" "--- @param a Vec3s\n" "--- @return Vec3s\n" @@ -163,6 +181,7 @@ char gSmluaConstants[] = "" " dest.z = dest.z + a.z\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3s\n" "--- @param a Vec3s\n" "--- @param b Vec3s\n" @@ -173,6 +192,7 @@ char gSmluaConstants[] = "" " dest.z = a.z + b.z\n" " return dest\n" "end\n" +"\n" "--- @param dest Vec3s\n" "--- @param a number\n" "--- @return Vec3s\n" @@ -182,6 +202,7 @@ char gSmluaConstants[] = "" " dest.z = dest.z * a\n" " return dest\n" "end\n" +"\n" "--- @param v1 Vec3s\n" "--- @param v2 Vec3s\n" "--- @return number\n" @@ -191,6 +212,7 @@ char gSmluaConstants[] = "" " dz = v1.z - v2.z\n" " return math.sqrt(dx * dx + dy * dy + dz * dz)\n" "end\n" +"\n" "--- @param current number\n" "--- @param target number\n" "--- @param inc number\n" @@ -210,6 +232,7 @@ char gSmluaConstants[] = "" " end\n" " return current;\n" "end\n" +"\n" "--- @param current number\n" "--- @param target number\n" "--- @param inc number\n" @@ -227,6 +250,7 @@ char gSmluaConstants[] = "" " current = target\n" " end\n" " end\n" +"\n" " -- keep within 32 bits\n" " if current > 2147483647 then\n" " current = -2147483648 + (current - 2147483647)\n" @@ -235,6 +259,7 @@ char gSmluaConstants[] = "" " end\n" " return current;\n" "end\n" +"\n" "--- @param bank number\n" "--- @param soundID number\n" "--- @param priority number\n" @@ -244,9 +269,11 @@ char gSmluaConstants[] = "" " if flags == nil then flags = 0 end\n" " return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING\n" "end\n" +"\n" "-------------\n" "-- courses --\n" "-------------\n" +"\n" "--- @type integer\n" "COURSE_NONE = 0\n" "--- @type integer\n" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 2d008675..4d707c52 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -12299,6 +12299,23 @@ int smlua_func_seq_player_unlower_volume(lua_State* L) { return 1; } +int smlua_func_set_audio_fadeout(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_audio_fadeout", 1, top); + return 0; + } + + u16 fadeOutTime = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_audio_fadeout"); return 0; } + + set_audio_fadeout(fadeOutTime); + + return 1; +} + int smlua_func_sound_banks_disable(lua_State* L) { if (L == NULL) { return 0; } @@ -12354,6 +12371,23 @@ int smlua_func_stop_background_music(lua_State* L) { return 1; } +int smlua_func_stop_secondary_music(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "stop_secondary_music", 1, top); + return 0; + } + + u16 fadeTimer = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "stop_secondary_music"); return 0; } + + stop_secondary_music(fadeTimer); + + return 1; +} + int smlua_func_stop_sound(lua_State* L) { if (L == NULL) { return 0; } @@ -30174,9 +30208,11 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "seq_player_fade_out", smlua_func_seq_player_fade_out); smlua_bind_function(L, "seq_player_lower_volume", smlua_func_seq_player_lower_volume); smlua_bind_function(L, "seq_player_unlower_volume", smlua_func_seq_player_unlower_volume); + smlua_bind_function(L, "set_audio_fadeout", smlua_func_set_audio_fadeout); smlua_bind_function(L, "sound_banks_disable", smlua_func_sound_banks_disable); smlua_bind_function(L, "sound_banks_enable", smlua_func_sound_banks_enable); smlua_bind_function(L, "stop_background_music", smlua_func_stop_background_music); + smlua_bind_function(L, "stop_secondary_music", smlua_func_stop_secondary_music); smlua_bind_function(L, "stop_sound", smlua_func_stop_sound); smlua_bind_function(L, "stop_sounds_from_source", smlua_func_stop_sounds_from_source); smlua_bind_function(L, "stop_sounds_in_continuous_banks", smlua_func_stop_sounds_in_continuous_banks);