diff --git a/include/functions.h b/include/functions.h index 10037d5a4f..907c35b5f8 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1256,6 +1256,14 @@ void AudioScript_InitSequencePlayers(void); void func_8019AE40(s32 param_1, s32 param_2, u32 param_3, s32 param_4); void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); +void Audio_Init(void); +void Audio_InitSound(void); +void Audio_Update(void); +void Audio_ResetForAudioHeapStep3(void); +void Audio_ResetForAudioHeapStep2(void); +void Audio_ResetForAudioHeapStep1(s32 specId); +void Audio_PreNMI(void); + void AudioOcarina_SetSongStartingPos(void); void AudioOcarina_StartAtSongStartingPos(u32 ocarinaFlags); void AudioOcarina_StartForSongCheck(u32 ocarinaFlags, u8 ocarinaStaffPlayingPosStart); @@ -1273,68 +1281,59 @@ OcarinaStaff* AudioOcarina_GetPlaybackStaff(void); void AudioOcarina_TerminaWallGenerateNotes(void); void AudioOcarina_PlayLongScarecrowSong(void); -void Audio_Update(void); void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex); void AudioSfx_LowerSfxSettingsReverb(Vec3f* pos, s8 isReverbLowered); -void Audio_SetBgmVolumeOff(void); -void Audio_SetBgmVolumeOn(void); -void func_801A0204(s8 seqId); -void Audio_SetMainBgmVolume(u8 targetVolume, u8 volumeFadeTimer); void AudioSfx_SetChannelIO(Vec3f* pos, u16 sfxId, u8 ioData); + void Audio_PlayObjSoundBgm(Vec3f* pos, s8 seqId); void Audio_PlayObjSoundFanfare(Vec3f* pos, s8 seqId); void Audio_PlaySubBgmAtPos(Vec3f* pos, u8 seqId, f32 maxDist); -void Audio_PlaySubBgmAtPosWithFilter(Vec3f* pos, u8 seqId, f32 arg2); +void Audio_PlaySubBgmAtPosWithFilter(Vec3f* pos, u8 seqId, f32 maxDist); void Audio_PlaySequenceAtDefaultPos(u8 seqPlayerIndex, u16 seqId); -void Audio_StopSequenceAtDefaultPos(void); void Audio_PlaySequenceAtPos(u8 seqPlayerIndex, Vec3f* pos, u16 seqId, f32 maxDist); -void func_801A246C(u8 param_1, u8 param_2); void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne); void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne); -void Audio_SetSeqTempoAndFreq(u8 seqPlayerIndex, f32 freqTempoScale, u8 duration); void Audio_PlaySubBgm(u16 seqId); -void Audio_StopSubBgm(void); void Audio_PlaySequenceInCutscene(u16 seqId); -void Audio_StopSequenceInCutscene(u16 seqId); -s32 Audio_IsSequencePlaying(u8 seqId); void Audio_PlayBgm_StorePrevBgm(u16 seqId); -void Audio_RestorePrevBgm(void); -void func_801A3000(u16 seqId, u8 ioData); -// void func_801A3038(void); +void Audio_PlayFanfareWithPlayerIOPort7(u16 seqId, u8 ioData); void Audio_PlayFanfare(u16 seqId); -// void func_801A312C(void); -void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); +void Audio_PlayFanfareWithPlayerIOCustomPort(u16 seqId, s8 ioPort, u8 ioData); void Audio_PlaySequenceWithSeqPlayerIO(s8 seqPlayerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData); -void Audio_SetSequenceMode(u8 seqMode); -void Audio_UpdateEnemyBgmVolume(f32 dist); -u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); -u8 func_801A39F8(void); -void func_801A3A7C(s32 arg0); -// void func_801A3AC0(void); -void func_801A3B48(UNK_TYPE arg0); -// void func_801A3B90(void); -void func_801A3CD8(s8 param_1); -void func_801A3CF4(s8 arg0); -void func_801A3D98(s8 audioSetting); -void func_801A3E38(u8 arg0); -void func_801A3EC0(u8 arg0); -void Audio_SetCutsceneFlag(s8 flag); -void Audio_SetSpec(u32 specId); -void func_801A4058(UNK_TYPE arg0); -void func_801A41C8(s32 arg0); -void func_801A41F8(UNK_TYPE arg0); -// void func_801A42C8(void); -// void func_801A4324(void); -// void func_801A4348(void); -void Audio_PreNMI(void); -s32 func_801A46F8(void); -void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData); void Audio_PlayAmbience(u8 ambienceId); -void Audio_Init(void); -void Audio_InitSound(void); -void Audio_ResetForAudioHeapStep3(void); -void Audio_ResetForAudioHeapStep2(void); -void Audio_ResetForAudioHeapStep1(s32 specId); + +void Audio_StopSequenceAtDefaultPos(void); +void Audio_StopSubBgm(void); +void Audio_StopSequenceInCutscene(u16 seqId); +void Audio_StopFanfare(u16 duration); + +void Audio_SetBgmVolumeOff(void); +void Audio_SetBgmVolumeOn(void); +void Audio_SetMainBgmVolume(u8 targetVolume, u8 volumeFadeTimer); +void Audio_SetSequenceMode(u8 seqMode); +void Audio_SetPauseState(u8 isPauseMenuOpen); +void Audio_SetEnvReverb(s8 reverb); +void Audio_SetCodeReverb(s8 reverb); +void Audio_SetFileSelectSettings(s8 audioSetting); +void Audio_SetBaseFilter(u8 filter); +void Audio_SetExtraFilter(u8 filter); +void Audio_SetCutsceneFlag(s8 flag); +void Audio_SetSpec(u8 specId); +void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData); +void Audio_SetSeqTempoAndFreq(u8 seqPlayerIndex, f32 freqTempoScale, u8 duration); + +void Audio_MuteSeqPlayerBgmSub(u8 isMuted); +void Audio_MuteAllSeqExceptSystemAndOcarina(u16 duration); +void Audio_MuteSfxAndAmbienceSeqExceptSysAndOca(u16 duration); + +void func_801A0204(s8 seqId); +void func_801A246C(u8 seqPlayerIndex, u8 type); +s32 Audio_IsSequencePlaying(u8 seqId); +void Audio_RestorePrevBgm(void); +void Audio_UpdateEnemyBgmVolume(f32 dist); +u8 func_801A3950(u8 seqPlayerIndex, u8 resetChannelIO); +u8 func_801A39F8(void); +s32 func_801A46F8(void); void func_801A4EB0(void); // void func_801A4EB8(void); diff --git a/include/variables.h b/include/variables.h index 41c8f3966f..9c0df58f4e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1805,8 +1805,8 @@ extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD29C; // extern UNK_TYPE1 D_801FD2A0; // extern UNK_TYPE1 D_801FD2A8; -// extern UNK_TYPE1 D_801FD3A8; -// extern UNK_TYPE1 D_801FD3A9; +// extern UNK_TYPE1 sRomaniSingingTimer; +// extern UNK_TYPE1 sRomaniSingingDisabled; // extern UNK_TYPE1 D_801FD3AA; // extern UNK_TYPE1 D_801FD3AB; // extern UNK_TYPE1 D_801FD3AC; diff --git a/src/audio/code_8019AF00.c b/src/audio/code_8019AF00.c index 5fb24860f4..3f684cbf9c 100644 --- a/src/audio/code_8019AF00.c +++ b/src/audio/code_8019AF00.c @@ -39,7 +39,7 @@ typedef enum { /* 0xD */ SFX_CHANNEL_OCARINA, // SfxOcarinaBank /* 0xE */ SFX_CHANNEL_VOICE0, // SfxVoiceBank /* 0xF */ SFX_CHANNEL_VOICE1 -} SfxChannelIndex; // playerIndex = 2 +} SfxChannelIndex; // seqPlayerIndex = 2 // Global IO ports for sequences, 8 global ports per seqPlayer typedef enum { @@ -72,7 +72,7 @@ void Audio_StartMorningSceneSequence(u16 seqId); void Audio_StartSceneSequence(u16 seqId); void Audio_PlaySequenceWithSeqPlayerIO(s8 seqPlayerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData); void Audio_SetSfxReverbIndexExceptOcarinaBank(u8 reverbIndex); -void func_801A3038(void); +void Audio_MuteBgmPlayersForFanfare(void); void Audio_PlayAmbience(u8 ambienceId); void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 volume); @@ -82,8 +82,8 @@ void Audio_UpdateObjSoundFanfare(void); void Audio_UpdateSubBgmAtPos(void); void Audio_UpdateSequenceAtPos(void); void Audio_UpdateSceneSequenceResumePoint(void); -void func_801A312C(void); -void func_801A3AC0(void); +void Audio_UpdateFanfare(void); +void Audio_UpdatePauseState(void); void Audio_ResetRequestedSceneSeqId(void); // Sfx bss @@ -107,11 +107,11 @@ f32* sSfxVolumeCur; f32 sSfxVolumeTarget; f32 sSfxVolumeRate; u16 sRequestedSceneSeqId; -SfxChannelState sSfxChannelState[16]; +SfxChannelState sSfxChannelState[SEQ_NUM_CHANNELS]; // Sequence bss -u8 D_801FD3A8; -u8 D_801FD3A9; +u8 sRomaniSingingTimer; +u8 sRomaniSingingDisabled; u8 sRiverSoundBgmTimer; u8 sFanfareState; u16 sFanfareSeqId; @@ -3648,12 +3648,12 @@ void Audio_Update(void) { Audio_StepFreqLerp(&sWaterfallFreqScaleLerp); Audio_UpdateRiverSoundVolumes(); Audio_UpdateSceneSequenceResumePoint(); - func_801A312C(); + Audio_UpdateFanfare(); Audio_UpdateSfxVolumeTransition(); Audio_UpdateSubBgmAtPos(); Audio_UpdateObjSoundFanfare(); Audio_UpdateSequenceAtPos(); - func_801A3AC0(); + Audio_UpdatePauseState(); Audio_UpdateObjSoundProperties(); Audio_ResetRequestedSceneSeqId(); AudioSfx_ProcessRequests(); @@ -5123,7 +5123,7 @@ void Audio_UpdateObjSoundFanfare(void) { Audio_StartObjSoundFanfare(SEQ_PLAYER_FANFARE, &sObjSoundFanfarePos, sObjSoundFanfareSeqId, 0); if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) { - func_801A3038(); + Audio_MuteBgmPlayersForFanfare(); } if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && @@ -5384,7 +5384,42 @@ void Audio_ClearSariaBgm2(void) { sRiverSoundBgmPos = NULL; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A246C.s") +void func_801A246C(u8 seqPlayerIndex, u8 type) { + u16 seqId; + u8 targetVolume; + s32 channelMask = 0; + + targetVolume = 0; + + switch (type) { + case 0: + targetVolume = 0x7F; + break; + + case 1: + channelMask = 0xFFFF; + break; + + case 2: + targetVolume = 0xFF; + break; + + default: + break; + } + + if (targetVolume != 0xFF) { + SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, channelMask); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, targetVolume, 1); + } else { + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 0); + seqId = AudioSeq_GetActiveSeqId(seqPlayerIndex); + + if (seqId != NA_BGM_DISABLED) { + SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, 0, seqId); + } + } +} void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne) { Audio_StartMorningSceneSequence(seqId); @@ -5612,15 +5647,64 @@ void Audio_ForceRestorePreviousBgm(void) { sPrevMainBgmSeqId = NA_BGM_DISABLED; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3000.s") +void Audio_PlayFanfareWithPlayerIOPort7(u16 seqId, u8 ioData) { + Audio_PlayFanfare(seqId); + SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_FANFARE, 7, ioData); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3038.s") +void Audio_MuteBgmPlayersForFanfare(void) { + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0, 5); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0, 5); + SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, 1, 10); + SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_SUB, 1, 10); + SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PlayFanfare.s") +/** + * Sets up seqId to play on seqPlayerIndex 1 + */ +void Audio_PlayFanfare(u16 seqId) { + u16 prevSeqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE); + u32 outNumFonts; + u8* prevFontId = AudioThread_GetFontsForSequence(prevSeqId & 0xFF, &outNumFonts); + u8* fontId = AudioThread_GetFontsForSequence(seqId & 0xFF, &outNumFonts); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A312C.s") + if ((prevSeqId == NA_BGM_DISABLED) || (*prevFontId == *fontId)) { + sFanfareState = 1; + } else { + sFanfareState = 5; + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A31EC.s") + sFanfareSeqId = seqId; +} + +void Audio_UpdateFanfare(void) { + if (sFanfareState != 0) { + if ((sFanfareState != 5) && + !AudioSeq_IsSeqCmdNotQueued((SEQCMD_OP_STOP_SEQUENCE << 28) | (SEQ_PLAYER_FANFARE << 24), + SEQCMD_OP_MASK | SEQCMD_ASYNC_ACTIVE | SEQCMD_SEQPLAYER_MASK)) { + sFanfareState = 0; + } else { + sFanfareState--; + if (sFanfareState == 0) { + AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(SEQUENCE_TABLE); + AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(FONT_TABLE); + AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); + if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) { + Audio_MuteBgmPlayersForFanfare(); + } + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_FANFARE, 0, sFanfareSeqId); + SEQCMD_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_MAIN, 0xFFFF); + } + } + } +} + +void Audio_PlayFanfareWithPlayerIOCustomPort(u16 seqId, s8 ioPort, u8 ioData) { + SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_FANFARE, ioPort, ioData); + Audio_PlayFanfare(seqId); +} void Audio_PlaySequenceWithSeqPlayerIO(s8 seqPlayerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData) { u16 flaggedSeqId; @@ -5743,15 +5827,114 @@ void Audio_UpdateEnemyBgmVolume(f32 dist) { sBgmEnemyDist = dist; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A36F0.s") +void Audio_UpdateRomaniSinging(f32 dist, u16 seqId) { + s8 pad; + s8 melodyVolume; + s16 curSeqId; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3950.s") + if (sRomaniSingingDisabled) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A39F8.s") + curSeqId = (s8)(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3A7C.s") + if (curSeqId == (seqId & 0xFF)) { + if ((seqId & 0xFF) == NA_BGM_ROMANI_RANCH) { + // Romani is singing along with the Romani Ranch Sequence -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3AC0.s") + if (dist > 2000.0f) { + melodyVolume = 127; + } else if (dist < 200.0f) { + melodyVolume = 0; + } else { + melodyVolume = (s8)(((dist - 200.0f) * 127.0f) / 1800.0f); + } + + // Update volume for channels 0 & 1, which contains Romani's singing + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 0, 3, 127 - melodyVolume); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 1, 3, 127 - melodyVolume); + + // Update volume for channel 13, which contains the melody line for Romani's Ranch Sequence + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 13, 3, melodyVolume); + if (sRomaniSingingTimer == 0) { + sRomaniSingingTimer++; + } + } + } else if ((curSeqId == NA_BGM_AMBIENCE) && ((seqId & 0xFF) == NA_BGM_ROMANI_RANCH)) { + // Romani is singing along with ambience + curSeqId = (s8)(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) & 0xFF); + + if ((curSeqId != (seqId & 0xFF)) && (sRomaniSingingTimer < 10)) { + // Disable all channels between 2-15. + // Only allow the two channels with Romani's singing to play, and surpress the full Romani Ranch sequence. + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_SUB, NA_BGM_ROMANI_RANCH, 0, 0, 0); + SEQCMD_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_SUB, 0xFFFC); + sRomaniSingingTimer = 10; + } + + if (dist > 2000.0f) { + melodyVolume = 127; + } else if (dist < 200.0f) { + melodyVolume = 0; + } else { + melodyVolume = (s8)(((dist - 200.0f) * 127.0f) / 1800.0f); + } + + // Update volume for channels 0 & 1, which contains Romani's singing + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_SUB, 0, 3, 127 - melodyVolume); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_SUB, 1, 3, 127 - melodyVolume); + } + + if (sRomaniSingingTimer < 10) { + sRomaniSingingTimer++; + } +} + +u8 func_801A3950(u8 seqPlayerIndex, u8 resetChannelIO) { + u8 ret = SEQ_IO_VAL_NONE; + SequenceChannel* channel = gAudioCtx.seqPlayers[seqPlayerIndex].channels[15]; + + if (gAudioCtx.seqPlayers[seqPlayerIndex].enabled && channel->enabled) { + if (channel->seqScriptIO[0] != SEQ_IO_VAL_NONE) { + ret = channel->seqScriptIO[0]; + if (resetChannelIO == true) { + SEQCMD_SET_CHANNEL_IO(seqPlayerIndex, 15, 0, (u8)SEQ_IO_VAL_NONE); + } + } + } + return ret; +} + +// Used only by minifrog +u8 func_801A39F8(void) { + u8 frogIndex = 0xFF; + s32 pad; + SequenceChannel* channel = gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_SUB].channels[15]; + + if (gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_SUB].enabled) { + if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == NA_BGM_FROG_SONG) && channel->enabled) { + if (channel->seqScriptIO[0] != -1) { + frogIndex = channel->seqScriptIO[0]; + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_BGM_SUB, 15, 0, SEQ_IO_VAL_NONE); + } + } + } + return frogIndex; +} + +void Audio_SetPauseState(u8 isPauseMenuOpen) { + if ((isPauseMenuOpen == false) && (sAudioPauseState != AUDIO_PAUSE_STATE_CLOSED)) { + sAudioPauseState = AUDIO_PAUSE_STATE_CLOSING; + } else { + sAudioPauseState = isPauseMenuOpen << 1; // Set to AUDIO_PAUSE_STATE_OPEN + } +} + +void Audio_UpdatePauseState(void) { + if ((sAudioPauseState != AUDIO_PAUSE_STATE_CLOSED) && (sAudioPauseState != AUDIO_PAUSE_STATE_OPEN)) { + sAudioPauseState--; // Set to AUDIO_PAUSE_STATE_CLOSED + } +} void Audio_PlaySfx_PauseMenuOpenOrClose(u8 pauseMenuOpenOrClose) { sAudioPauseMenuOpenOrClose = pauseMenuOpenOrClose; @@ -5764,13 +5947,81 @@ void Audio_PlaySfx_PauseMenuOpenOrClose(u8 pauseMenuOpenOrClose) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3B48.s") +// Only used by guru guru +void Audio_MuteSeqPlayerBgmSub(u8 isMuted) { + if (isMuted == true) { + AUDIOCMD_GLOBAL_MUTE(SEQ_PLAYER_BGM_SUB); + } else { + AUDIOCMD_GLOBAL_UNMUTE(SEQ_PLAYER_BGM_SUB, false); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3B90.s") +/** + * Enable or disable Romani's singing + * + * @param romaniSingingDisabled true to disable, false to enable + */ +void Audio_ToggleRomaniSinging(u8 romaniSingingDisabled) { + u8 seqPlayerIndex; + u16 channelMaskDisable; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3CD8.s") + sRomaniSingingDisabled = romaniSingingDisabled; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3CF4.s") + if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF) == NA_BGM_ROMANI_RANCH) { + // Romani is singing along with the Romani Ranch Sequence + seqPlayerIndex = SEQ_PLAYER_BGM_MAIN; + // Do not disable any channel. + // Allow the full Romani Ranch sequence to play in addition to Romani's singing. + channelMaskDisable = 0; + } else if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) & 0xFF) == NA_BGM_ROMANI_RANCH) { + seqPlayerIndex = SEQ_PLAYER_BGM_SUB; + // Disable all channels between 2-15. + // Only allow the two channels with Romani's singing to play, and surpress the full Romani sequence. + channelMaskDisable = 0xFFFC; + } else { + return; + } + + if (romaniSingingDisabled) { + // Turn volume off for channels 0 & 1, which contains Romani's singing + SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 0, 1, 0); + SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 1, 1, 0); + if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { + // When singing along with ambience, disable all 16 channels + SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, channelMaskDisable | 3); + } + } else { + if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { + // When singing along with ambience, start the sequence + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_SUB, NA_BGM_ROMANI_RANCH, 0, 0, 0); + } + + // Turn volume on for only channels 0 & 1, which contains Romani's singing + SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 0, 1, 0x7F); + SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 1, 1, 0x7F); + + if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { + // When singing along with ambience, disable channels 2-15 + SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, channelMaskDisable); + } + } +} + +void Audio_SetEnvReverb(s8 reverb) { + sAudioEnvReverb = reverb & 0x7F; +} + +void Audio_SetCodeReverb(s8 reverb) { + u8 reverbIndex; + + if (reverb != 0) { + if ((reverb & 0x40) != (sAudioCodeReverb & 0x40)) { + reverbIndex = (reverb >> 6) + 1; + Audio_SetSfxReverbIndexExceptOcarinaBank(reverbIndex); + } + sAudioCodeReverb = reverb & 0x7F; + } +} /** * Possibly a test for surround sound @@ -5786,11 +6037,62 @@ void Audio_PlaySfx_SurroundSoundTest(void) { Audio_PlaySfx_AtPosWithAllChannelsIO(&gSfxDefaultPos, NA_SE_SY_SOUT_DEMO, val); } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3D98.s") +void Audio_SetFileSelectSettings(s8 audioSetting) { + s8 soundMode; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3E38.s") + switch (audioSetting) { + case SAVE_AUDIO_STEREO: + soundMode = SOUNDMODE_STEREO; + sSoundMode = SOUNDMODE_STEREO; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3EC0.s") + case SAVE_AUDIO_MONO: + soundMode = SOUNDMODE_MONO; + sSoundMode = SOUNDMODE_MONO; + break; + + case SAVE_AUDIO_HEADSET: + soundMode = SOUNDMODE_HEADSET; + sSoundMode = SOUNDMODE_HEADSET; + break; + + case SAVE_AUDIO_SURROUND: + soundMode = SOUNDMODE_SURROUND; + sSoundMode = SOUNDMODE_SURROUND_EXTERNAL; + break; + + default: + break; + } + + SEQCMD_SET_SOUND_MODE(soundMode); +} + +void Audio_SetBaseFilter(u8 filter) { + if (sAudioBaseFilter != filter) { + if (filter == 0) { + AudioSfx_StopById(NA_SE_PL_IN_BUBBLE); + } else if (sAudioBaseFilter == 0) { + AudioSfx_PlaySfx(NA_SE_PL_IN_BUBBLE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + } + sAudioBaseFilter = filter; + sAudioBaseFilter2 = filter; +} + +void Audio_SetExtraFilter(u8 filter) { + u8 channelIndex; + + sAudioExtraFilter2 = filter; + sAudioExtraFilter = filter; + if (gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId == NA_BGM_AMBIENCE) { + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + // seq player 4, all channels, slot 6 + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_AMBIENCE, channelIndex, 6, filter); + } + } +} void Audio_SetCutsceneFlag(s8 flag) { sAudioCutsceneFlag = flag; @@ -5808,17 +6110,67 @@ void Audio_PlaySfx_IfNotInCutscene(u16 sfxId) { } // Unused -void Audio_MuteSfxAndAmbienceSeqExceptOcarinaAndSystem(u8 muteOnlySfxAndAmbienceSeq) { +void Audio_MuteSfxAndAmbienceSeqExceptSystemAndOcarina(u8 muteOnlySfxAndAmbienceSeq) { sMuteOnlySfxAndAmbienceSeq = muteOnlySfxAndAmbienceSeq; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetSpec.s") +void Audio_SetSpec(u8 specId) { + if (!sMuteOnlySfxAndAmbienceSeq) { + SEQCMD_RESET_AUDIO_HEAP(0, 0, specId); + } else { + SEQCMD_RESET_AUDIO_HEAP(2, 0, specId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4058.s") +void Audio_MuteAllSeqExceptSystemAndOcarina(u16 duration) { + s32 skip; + u8 channelIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A41C8.s") + if (!sMuteOnlySfxAndAmbienceSeq) { + sAllPlayersMutedExceptSystemAndOcarina = true; + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, (duration * 3) / 2); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, (duration * 3) / 2); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, (duration * 3) / 2); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A41F8.s") + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, (duration * 3) / 2); + + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + skip = false; + switch (channelIndex) { + case SFX_CHANNEL_SYSTEM0: + case SFX_CHANNEL_SYSTEM1: + if (gAudioSpecId == 10) {} // Remnant of OoT + if (gAudioSpecId == 11) {} + skip = true; + break; + + case SFX_CHANNEL_OCARINA: + skip = true; + break; + } + + if (!skip) { + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_SFX, channelIndex, (u8)(duration >> 1), 0); + } + } +} + +void Audio_MuteSfxAndAmbienceSeqExceptSysAndOca(u16 duration) { + sMuteOnlySfxAndAmbienceSeq = true; + Audio_MuteAllSeqExceptSystemAndOcarina(duration); +} + +void Audio_StopFanfare(u16 duration) { + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, duration); + if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE) != NA_BGM_DISABLED) { + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, duration); + } + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, duration); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, duration); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 0); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0x7F, 0); +} /** * The flag 0xFF makes the sequence process SkipTicks and SkipForwardSequence @@ -5828,11 +6180,31 @@ void Audio_StartSfxPlayer(void) { AudioSeq_StartSequence(SEQ_PLAYER_SFX, NA_BGM_GENERAL_SFX, 0xFF, 5); } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A42C8.s") +void Audio_DisableAllSeq(void) { + AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_BGM_MAIN, 0); + AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_FANFARE, 0); + AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_SFX, 0); + AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_BGM_SUB, 0); + AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_AMBIENCE, 0); + AudioThread_ScheduleProcessCmds(); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4324.s") +s8 Audio_GetEnabledNotesCount(void) { + return AudioThread_GetEnabledNotesCount(); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4348.s") +// Unused +void func_801A4348(void) { + Audio_DisableAllSeq(); + AudioThread_ScheduleProcessCmds(); + + // Wait for all notes to be finished + while (true) { + if (Audio_GetEnabledNotesCount() == 0) { + break; + } + } +} void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 volume) { u8 channelIndex; @@ -5863,16 +6235,85 @@ void Audio_SetSfxReverbIndexExceptOcarinaBank(u8 reverbIndex) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s") +void Audio_PreNMI(void) { + AudioThread_PreNMIInternal(); +} void Audio_ResetRequestedSceneSeqId(void) { sRequestedSceneSeqId = NA_BGM_DISABLED; } -void Audio_ResetData(void); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_ResetData.s") +void Audio_ResetData(void) { + u8 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A46F8.s") + for (i = 0; i < ARRAY_COUNT(sSfxSettings); i++) { + sSfxSettings[i].pos = NULL; + sSfxSettings[i].freqScale = 1.0; + sSfxSettings[i].reverbAdd = 0; + } + sSfxSettingsFlags = 0; + sTwoSemitonesLoweredFreq = 0.9f; + sSfxIncreasedReverb = 20; + sSfxVolumeDuration = 0; + sPrevSeqMode = 0; + sSfxSyncedVolume = 1.0f; + sSfxSyncedFreq = 1.0f; + sAudioBaseFilter = 0; + sAudioExtraFilter = 0; + sAudioBaseFilter2 = 0; + sAudioExtraFilter2 = 0; + AudioOcarina_ResetInstrument(); + sRiverFreqScaleLerp.remainingFrames = 0; + sWaterfallFreqScaleLerp.remainingFrames = 0; + sRiverFreqScaleLerp.value = 1; + sWaterfallFreqScaleLerp.value = 1; + sSfxAdjustedFreq = 1; + sRiverSoundMainBgmVol = 0x7F; + sRiverSoundMainBgmCurrentVol = 0x7F; + sRiverSoundMainBgmLower = false; + sRiverSoundMainBgmRestore = false; + sGanonsTowerVol = 0xFF; + sRomaniSingingTimer = 0; + sObjSoundFanfareRequested = false; + sSpecReverb = sSpecReverbs[gAudioSpecId]; + sAudioPauseMenuOpenOrClose = SFX_PAUSE_MENU_CLOSE; + sPrevMainBgmSeqId = NA_BGM_DISABLED; + AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_BGM_MAIN, 0, SEQ_IO_VAL_NONE); + sRiverSoundBgmPos = NULL; + sFanfareState = 0; + sRiverSoundBgmTimer = 1; + sRomaniSingingDisabled = false; + sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX; + sPrevAmbienceSeqId = NA_BGM_DISABLED; + sSpatialSeqFlags = 0; + D_801FD432 = 0; + sSpatialSeqSeqId = NA_BGM_GENERAL_SFX; + sSpatialSubBgmFadeTimer = 0; + D_801FD434 = 0; + sSpatialSeqFadeTimer = 0; + sAllPlayersMutedExceptSystemAndOcarina = false; + sAudioPauseState = AUDIO_PAUSE_STATE_CLOSED; + sObjSoundPlayerIndex = SEQ_PLAYER_INVALID; + sIsFinalHoursOrSoaring = false; + + for (i = SEQ_PLAYER_BGM_MAIN; i <= SEQ_PLAYER_BGM_SUB; i++) { + sSpatialSeqIsActive[i] = false; + } +} + +s32 func_801A46F8(void) { + switch (func_801A3950(SEQ_PLAYER_FANFARE, true)) { + case 0: + case 0x8: + case 0x10: + case 0x18: + case 0x20: + return true; + + default: + return false; + } +} // used for z_obj_sound and z_en_gk void Audio_PlaySfx_AtFixedPos(Vec3f* pos, u16 sfxId) { @@ -5908,7 +6349,7 @@ void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData) { // channelIndexRange = 01 on ioPort 1 if ((((channelIndexRange << 8) + (u32)ioPort) == ((1 << 8) | (u32)1)) && (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { - D_801FD3A8 = 0; + sRomaniSingingTimer = 0; } firstChannelIndex = channelIndexRange >> 4; diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 1b3aa49d78..277fc53609 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -106,7 +106,7 @@ void KaleidoSetup_Update(PlayState* play) { func_800F4A10(play); // Set next page mode to scroll left pauseCtx->nextPageMode = pauseCtx->pageIndex * 2 + 1; - func_801A3A7C(1); + Audio_SetPauseState(true); } if (pauseCtx->state == PAUSE_STATE_OPENING_0) { diff --git a/src/code/z_message.c b/src/code/z_message.c index 4d717d8df1..4bc104fec4 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -4556,8 +4556,8 @@ void Message_DrawMain(PlayState* play, Gfx** gfxP) { AudioOcarina_SetInstrument(sPlayerFormOcarinaInstruments[CUR_FORM]); AudioOcarina_SetPlaybackSong((u8)msgCtx->songPlayed + 1, 1); if (msgCtx->songPlayed != OCARINA_SONG_SCARECROW_SPAWN) { - func_801A3000((u16)sOcarinaSongFanfares[msgCtx->songPlayed], - (u8)sOcarinaSongFanfareIoData[CUR_FORM]); + Audio_PlayFanfareWithPlayerIOPort7((u16)sOcarinaSongFanfares[msgCtx->songPlayed], + (u8)sOcarinaSongFanfareIoData[CUR_FORM]); AudioSfx_MuteBanks(0x20); } } diff --git a/src/code/z_play.c b/src/code/z_play.c index 17449e0422..6d3dac1fe6 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -525,7 +525,7 @@ void Play_UpdateWaterCamera(PlayState* this, Camera* camera) { Distortion_SetDuration(80); } - func_801A3EC0(0x20); + Audio_SetExtraFilter(0x20); Environment_EnableUnderwaterLights(this, lightIndex); if ((sQuakeIndex == -1) || (Quake_GetTimeLeft(sQuakeIndex) == 10)) { @@ -556,7 +556,7 @@ void Play_UpdateWaterCamera(PlayState* this, Camera* camera) { Quake_RemoveRequest(sQuakeIndex); } Environment_DisableUnderwaterLights(this); - func_801A3EC0(0); + Audio_SetExtraFilter(0); } } @@ -589,20 +589,20 @@ void Play_UpdateTransition(PlayState* this) { !CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE))) && (!Environment_IsFinalHours(this) || (Entrance_GetSceneId(this->nextEntrance + sceneLayer) < 0) || (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_FINAL_HOURS))) { - func_801A4058(20); + Audio_MuteAllSeqExceptSystemAndOcarina(20); gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } if (Environment_IsForcedSequenceDisabled()) { - func_801A4058(20); + Audio_MuteAllSeqExceptSystemAndOcarina(20); gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } if (Environment_IsFinalHours(this) && (Entrance_GetSceneId(this->nextEntrance + sceneLayer) >= 0) && (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS)) { - func_801A41C8(20); + Audio_MuteSfxAndAmbienceSeqExceptSysAndOca(20); } } @@ -2175,7 +2175,7 @@ void Play_Init(GameState* thisx) { KaleidoManager_Init(this); ShrinkWindow_Init(); View_Init(&this->view, gfxCtx); - func_801A3EC0(0); + Audio_SetExtraFilter(0); Quake_Init(); Distortion_Init(this); diff --git a/src/code/z_room.c b/src/code/z_room.c index 428dd5c132..ff94768255 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -620,5 +620,5 @@ void func_8012EBF8(PlayState* play, RoomContext* roomCtx) { Map_InitRoomData(play, roomCtx->curRoom.num); Minimap_SavePlayerRoomInitInfo(play); } - func_801A3CD8(play->roomCtx.curRoom.echo); + Audio_SetEnvReverb(play->roomCtx.curRoom.echo); } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 01a493cc00..83e271edce 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1663,7 +1663,7 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { gSaveContext.options.zTargetSetting = 0; } } - func_801A3D98(gSaveContext.options.audioSetting); + Audio_SetFileSelectSettings(gSaveContext.options.audioSetting); } } @@ -1861,7 +1861,7 @@ void Sram_WriteSaveOptionsToBuffer(SramContext* sramCtx) { void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { if (gSaveContext.save.entrance) {} // Required to match - func_801A3D98(gSaveContext.options.audioSetting); + Audio_SetFileSelectSettings(gSaveContext.options.audioSetting); } void Sram_Alloc(GameState* gameState, SramContext* sramCtx) { diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index b3ae6bbeb3..abe1fbc47f 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -250,7 +250,7 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) { } if (this->textIdIndex == 12) { SET_WEEKEVENTREG(WEEKEVENTREG_38_40); - func_801A3B48(0); + Audio_MuteSeqPlayerBgmSub(false); Message_BombersNotebookQueueEvent(play, BOMBERS_NOTEBOOK_EVENT_RECEIVED_BREMEN_MASK); Message_BombersNotebookQueueEvent(play, BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU); func_80BC6E10(this); @@ -275,15 +275,15 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) { if ((this->unk268 != 0) && (this->textIdIndex >= 7)) { this->skelAnime.playSpeed = 2.0f; Audio_SetSeqTempoAndFreq(3, 1.18921f, 2); - func_801A3B48(0); + Audio_MuteSeqPlayerBgmSub(false); } else { if (this->skelAnime.playSpeed == 2.0f) { Audio_SetSeqTempoAndFreq(3, 1.0f, 2); } if (this->unk268 == 0) { - func_801A3B48(1); + Audio_MuteSeqPlayerBgmSub(true); } else { - func_801A3B48(0); + Audio_MuteSeqPlayerBgmSub(false); } this->skelAnime.playSpeed = 1.0f; } @@ -291,14 +291,14 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) { Message_ContinueTextbox(play, textIDs[this->textIdIndex]); return; } - func_801A3B48(0); + Audio_MuteSeqPlayerBgmSub(false); Message_BombersNotebookQueueEvent(play, BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU); func_80BC6E10(this); } } void func_80BC73F4(EnGuruguru* this) { - func_801A3B48(0); + Audio_MuteSeqPlayerBgmSub(false); this->unk268 = 1; this->headZRotTarget = 0; this->unk272 = 2; @@ -311,7 +311,7 @@ void func_80BC7440(EnGuruguru* this, PlayState* play) { this->actor.parent = NULL; this->textIdIndex++; this->actor.textId = textIDs[this->textIdIndex]; - func_801A3B48(1); + Audio_MuteSeqPlayerBgmSub(true); Actor_OfferTalkExchange(&this->actor, play, 400.0f, 400.0f, PLAYER_IA_MINUS1); this->unk268 = 0; SET_WEEKEVENTREG(WEEKEVENTREG_38_40); diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index c62a460066..75d880cd8e 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -604,7 +604,7 @@ s32 func_80BA47E0(EnToto* this, PlayState* play) { s32 func_80BA49A4(EnToto* this, PlayState* play) { func_800B7298(play, NULL, PLAYER_CSACTION_68); - func_801A31EC(NA_BGM_BALLAD_OF_THE_WIND_FISH, 4, this->unk2B3 ^ 0xF); + Audio_PlayFanfareWithPlayerIOCustomPort(NA_BGM_BALLAD_OF_THE_WIND_FISH, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index 0bce7ae707..14469f556f 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -247,7 +247,7 @@ void EnWarpTag_GrottoReturn(EnWarptag* this, PlayState* play) { Scene_SetExitFade(play); play->transitionTrigger = TRANS_TRIGGER_START; Audio_PlaySfx_2(NA_SE_OC_SECRET_HOLE_OUT); - func_801A4058(5); + Audio_MuteAllSeqExceptSystemAndOcarina(5); gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 0fc16b8240..07a18db577 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -4504,7 +4504,7 @@ void func_80831F34(PlayState* play, Player* this, PlayerAnimationHeader* anim) { this->actionVar1 = 1; } else { play->gameOverCtx.state = GAMEOVER_DEATH_START; - func_801A41F8(0); + Audio_StopFanfare(0); Audio_PlayFanfare(NA_BGM_GAME_OVER); gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; @@ -6128,7 +6128,7 @@ s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* pol if ((this->stateFlags1 & PLAYER_STATE1_8000000) && (this->floorProperty == FLOOR_PROPERTY_5)) { Audio_PlaySfx_2(NA_SE_OC_TUNAMI); - func_801A4058(5); + Audio_MuteAllSeqExceptSystemAndOcarina(5); gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && @@ -6150,7 +6150,7 @@ s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* pol ((sp34 < 100) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { if (floorType == FLOOR_TYPE_11) { Audio_PlaySfx_2(NA_SE_OC_SECRET_HOLE_OUT); - func_801A4058(5); + Audio_MuteAllSeqExceptSystemAndOcarina(5); gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } else { @@ -8565,9 +8565,9 @@ void func_8083BB4C(PlayState* play, Player* this) { if ((this->transformation == PLAYER_FORM_ZORA) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->currentBoots = PLAYER_BOOTS_ZORA_LAND; } - func_801A3E38(0); + Audio_SetBaseFilter(0); } else { - func_801A3E38(0x20); + Audio_SetBaseFilter(0x20); if ((this->transformation == PLAYER_FORM_ZORA) || (sp1C < 10.0f)) { this->underwaterTimer = 0; } else if (this->underwaterTimer < 300) { @@ -11241,7 +11241,7 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { this->floorProperty = SurfaceType_GetFloorProperty(&play->colCtx, floorPoly, this->actor.floorBgId); if (this == GET_PLAYER(play)) { - func_801A3CF4(SurfaceType_GetEcho(&play->colCtx, floorPoly, this->actor.floorBgId)); + Audio_SetCodeReverb(SurfaceType_GetEcho(&play->colCtx, floorPoly, this->actor.floorBgId)); if (this->actor.floorBgId == BGCHECK_SCENE) { Environment_ChangeLightSetting( diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index 1136632fbc..3957466b11 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -2050,7 +2050,7 @@ void FileSelect_ConfirmFile(GameState* thisx) { Rumble_Request(300.0f, 180, 20, 100); Audio_PlaySfx(NA_SE_SY_FSEL_DECIDE_L); this->selectMode = SM_FADE_OUT; - func_801A4058(0xF); + Audio_MuteAllSeqExceptSystemAndOcarina(15); } else { // FS_BTN_CONFIRM_QUIT Audio_PlaySfx(NA_SE_SY_FSEL_CLOSE); this->selectMode++; // SM_FADE_OUT_FILE_INFO diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c index f8f228eaa7..e615126958 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c @@ -766,7 +766,7 @@ void FileSelect_UpdateOptionsMenu(GameState* thisx) { Sram_StartWriteToFlashDefault(sramCtx); this->configMode = CM_OPTIONS_WAIT_FOR_FLASH_SAVE; } - func_801A3D98(gSaveContext.options.audioSetting); + Audio_SetFileSelectSettings(gSaveContext.options.audioSetting); return; } diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index fee889b6b9..7b8f3d1b06 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -3167,7 +3167,7 @@ void KaleidoScope_Update(PlayState* play) { BgCheck_InitCollisionHeaders(&play->colCtx, play); STOP_GAMESTATE(&play->state); SET_NEXT_GAMESTATE(&play->state, TitleSetup_Init, sizeof(TitleSetupState)); - func_801A4058(0x14); + Audio_MuteAllSeqExceptSystemAndOcarina(20); gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } @@ -3610,7 +3610,10 @@ void KaleidoScope_Update(PlayState* play) { } gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; Interface_SetHudVisibility(sUnpausedHudVisibility); - func_801A3A7C(0); + Audio_SetPauseState(false); + break; + + default: break; } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 3c1265e15d..8690c35c85 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3956,39 +3956,39 @@ 0x801A2ED8:("Audio_RestorePrevBgm",), 0x801A2F88:("Audio_PlayAmbience_StorePrevBgm",), 0x801A2FC4:("Audio_ForceRestorePreviousBgm",), - 0x801A3000:("func_801A3000",), - 0x801A3038:("func_801A3038",), + 0x801A3000:("Audio_PlayFanfareWithPlayerIOPort7",), + 0x801A3038:("Audio_MuteBgmPlayersForFanfare",), 0x801A3098:("Audio_PlayFanfare",), - 0x801A312C:("func_801A312C",), - 0x801A31EC:("func_801A31EC",), + 0x801A312C:("Audio_UpdateFanfare",), + 0x801A31EC:("Audio_PlayFanfareWithPlayerIOCustomPort",), 0x801A3238:("Audio_PlaySequenceWithSeqPlayerIO",), 0x801A32CC:("Audio_SetSequenceMode",), 0x801A3590:("Audio_UpdateEnemyBgmVolume",), - 0x801A36F0:("func_801A36F0",), + 0x801A36F0:("Audio_UpdateRomaniSinging",), 0x801A3950:("func_801A3950",), 0x801A39F8:("func_801A39F8",), - 0x801A3A7C:("func_801A3A7C",), - 0x801A3AC0:("func_801A3AC0",), + 0x801A3A7C:("Audio_SetPauseState",), + 0x801A3AC0:("Audio_UpdatePauseState",), 0x801A3AEC:("Audio_PlaySfx_PauseMenuOpenOrClose",), - 0x801A3B48:("func_801A3B48",), - 0x801A3B90:("func_801A3B90",), - 0x801A3CD8:("func_801A3CD8",), - 0x801A3CF4:("func_801A3CF4",), + 0x801A3B48:("Audio_MuteSeqPlayerBgmSub",), + 0x801A3B90:("Audio_ToggleRomaniSinging",), + 0x801A3CD8:("Audio_SetEnvReverb",), + 0x801A3CF4:("Audio_SetCodeReverb",), 0x801A3D54:("Audio_PlaySfx_SurroundSoundTest",), - 0x801A3D98:("func_801A3D98",), - 0x801A3E38:("func_801A3E38",), - 0x801A3EC0:("func_801A3EC0",), + 0x801A3D98:("Audio_SetFileSelectSettings",), + 0x801A3E38:("Audio_SetBaseFilter",), + 0x801A3EC0:("Audio_SetExtraFilter",), 0x801A3F54:("Audio_SetCutsceneFlag",), 0x801A3F6C:("Audio_PlaySfx_IfNotInCutsceneImpl",), 0x801A3FB4:("Audio_PlaySfx_IfNotInCutscene",), - 0x801A3FFC:("Audio_MuteSfxAndAmbienceSeqExceptOcarinaAndSystem",), + 0x801A3FFC:("Audio_MuteSfxAndAmbienceSeqExceptSystemAndOcarina",), 0x801A400C:("Audio_SetSpec",), - 0x801A4058:("func_801A4058",), - 0x801A41C8:("func_801A41C8",), - 0x801A41F8:("func_801A41F8",), + 0x801A4058:("Audio_MuteAllSeqExceptSystemAndOcarina",), + 0x801A41C8:("Audio_MuteSfxAndAmbienceSeqExceptSysAndOca",), + 0x801A41F8:("Audio_StopFanfare",), 0x801A429C:("Audio_StartSfxPlayer",), - 0x801A42C8:("func_801A42C8",), - 0x801A4324:("func_801A4324",), + 0x801A42C8:("Audio_DisableAllSeq",), + 0x801A4324:("Audio_GetEnabledNotesCount",), 0x801A4348:("func_801A4348",), 0x801A4380:("Audio_SetSfxVolumeExceptSystemAndOcarinaBanks",), 0x801A4428:("Audio_SetSfxReverbIndexExceptOcarinaBank",), @@ -8570,7 +8570,7 @@ 0x8099A920:("ObjSound_Init",), 0x8099A96C:("ObjSound_Destroy",), 0x8099A9A4:("ObjSound_Update",), - 0x8099AA84:("func_8099AA84",), + 0x8099AA84:("ObjSound_Draw",), 0x8099AB30:("EnCrow_Init",), 0x8099AC2C:("EnCrow_Destroy",), 0x8099AC58:("EnCrow_SetupFlyIdle",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index f1ab300c72..57ed5c173a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4175,8 +4175,8 @@ 0x801FD29C:("sSfxVolumeRate","UNK_TYPE1","",0x1), 0x801FD2A0:("sRequestedSceneSeqId","UNK_TYPE1","",0x1), 0x801FD2A8:("sSfxChannelState","UNK_TYPE1","",0x1), - 0x801FD3A8:("D_801FD3A8","UNK_TYPE1","",0x1), - 0x801FD3A9:("D_801FD3A9","UNK_TYPE1","",0x1), + 0x801FD3A8:("sRomaniSingingTimer","UNK_TYPE1","",0x1), + 0x801FD3A9:("sRomaniSingingDisabled","UNK_TYPE1","",0x1), 0x801FD3AA:("sRiverSoundBgmTimer","UNK_TYPE1","",0x1), 0x801FD3AB:("sFanfareState","UNK_TYPE1","",0x1), 0x801FD3AC:("sFanfareSeqId","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 702ebf7481..3a4de09cee 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3473,39 +3473,39 @@ asm/non_matchings/code/code_8019AF00/Audio_PlayBgm_StorePrevBgm.s,Audio_PlayBgm_ asm/non_matchings/code/code_8019AF00/Audio_RestorePrevBgm.s,Audio_RestorePrevBgm,0x801A2ED8,0x2C asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience_StorePrevBgm.s,Audio_PlayAmbience_StorePrevBgm,0x801A2F88,0xF asm/non_matchings/code/code_8019AF00/Audio_ForceRestorePreviousBgm.s,Audio_ForceRestorePreviousBgm,0x801A2FC4,0xF -asm/non_matchings/code/code_8019AF00/func_801A3000.s,func_801A3000,0x801A3000,0xE -asm/non_matchings/code/code_8019AF00/func_801A3038.s,func_801A3038,0x801A3038,0x18 +asm/non_matchings/code/code_8019AF00/Audio_PlayFanfareWithPlayerIOPort7.s,Audio_PlayFanfareWithPlayerIOPort7,0x801A3000,0xE +asm/non_matchings/code/code_8019AF00/Audio_MuteBgmPlayersForFanfare.s,Audio_MuteBgmPlayersForFanfare,0x801A3038,0x18 asm/non_matchings/code/code_8019AF00/Audio_PlayFanfare.s,Audio_PlayFanfare,0x801A3098,0x25 -asm/non_matchings/code/code_8019AF00/func_801A312C.s,func_801A312C,0x801A312C,0x30 -asm/non_matchings/code/code_8019AF00/func_801A31EC.s,func_801A31EC,0x801A31EC,0x13 +asm/non_matchings/code/code_8019AF00/Audio_UpdateFanfare.s,Audio_UpdateFanfare,0x801A312C,0x30 +asm/non_matchings/code/code_8019AF00/Audio_PlayFanfareWithPlayerIOCustomPort.s,Audio_PlayFanfareWithPlayerIOCustomPort,0x801A31EC,0x13 asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceWithSeqPlayerIO.s,Audio_PlaySequenceWithSeqPlayerIO,0x801A3238,0x25 asm/non_matchings/code/code_8019AF00/Audio_SetSequenceMode.s,Audio_SetSequenceMode,0x801A32CC,0xB1 asm/non_matchings/code/code_8019AF00/Audio_UpdateEnemyBgmVolume.s,Audio_UpdateEnemyBgmVolume,0x801A3590,0x58 -asm/non_matchings/code/code_8019AF00/func_801A36F0.s,func_801A36F0,0x801A36F0,0x98 +asm/non_matchings/code/code_8019AF00/Audio_UpdateRomaniSinging.s,Audio_UpdateRomaniSinging,0x801A36F0,0x98 asm/non_matchings/code/code_8019AF00/func_801A3950.s,func_801A3950,0x801A3950,0x2A asm/non_matchings/code/code_8019AF00/func_801A39F8.s,func_801A39F8,0x801A39F8,0x21 -asm/non_matchings/code/code_8019AF00/func_801A3A7C.s,func_801A3A7C,0x801A3A7C,0x11 -asm/non_matchings/code/code_8019AF00/func_801A3AC0.s,func_801A3AC0,0x801A3AC0,0xB +asm/non_matchings/code/code_8019AF00/Audio_SetPauseState.s,Audio_SetPauseState,0x801A3A7C,0x11 +asm/non_matchings/code/code_8019AF00/Audio_UpdatePauseState.s,Audio_UpdatePauseState,0x801A3AC0,0xB asm/non_matchings/code/code_8019AF00/Audio_PlaySfx_PauseMenuOpenOrClose.s,Audio_PlaySfx_PauseMenuOpenOrClose,0x801A3AEC,0x17 -asm/non_matchings/code/code_8019AF00/func_801A3B48.s,func_801A3B48,0x801A3B48,0x12 -asm/non_matchings/code/code_8019AF00/func_801A3B90.s,func_801A3B90,0x801A3B90,0x52 -asm/non_matchings/code/code_8019AF00/func_801A3CD8.s,func_801A3CD8,0x801A3CD8,0x7 -asm/non_matchings/code/code_8019AF00/func_801A3CF4.s,func_801A3CF4,0x801A3CF4,0x18 +asm/non_matchings/code/code_8019AF00/Audio_MuteSeqPlayerBgmSub.s,Audio_MuteSeqPlayerBgmSub,0x801A3B48,0x12 +asm/non_matchings/code/code_8019AF00/Audio_ToggleRomaniSinging.s,Audio_ToggleRomaniSinging,0x801A3B90,0x52 +asm/non_matchings/code/code_8019AF00/Audio_SetEnvReverb.s,Audio_SetEnvReverb,0x801A3CD8,0x7 +asm/non_matchings/code/code_8019AF00/Audio_SetCodeReverb.s,Audio_SetCodeReverb,0x801A3CF4,0x18 asm/non_matchings/code/code_8019AF00/Audio_PlaySfx_SurroundSoundTest.s,Audio_PlaySfx_SurroundSoundTest,0x801A3D54,0x11 -asm/non_matchings/code/code_8019AF00/func_801A3D98.s,func_801A3D98,0x801A3D98,0x28 -asm/non_matchings/code/code_8019AF00/func_801A3E38.s,func_801A3E38,0x801A3E38,0x22 -asm/non_matchings/code/code_8019AF00/func_801A3EC0.s,func_801A3EC0,0x801A3EC0,0x25 +asm/non_matchings/code/code_8019AF00/Audio_SetFileSelectSettings.s,Audio_SetFileSelectSettings,0x801A3D98,0x28 +asm/non_matchings/code/code_8019AF00/Audio_SetBaseFilter.s,Audio_SetBaseFilter,0x801A3E38,0x22 +asm/non_matchings/code/code_8019AF00/Audio_SetExtraFilter.s,Audio_SetExtraFilter,0x801A3EC0,0x25 asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s,Audio_SetCutsceneFlag,0x801A3F54,0x6 asm/non_matchings/code/code_8019AF00/Audio_PlaySfx_IfNotInCutsceneImpl.s,Audio_PlaySfx_IfNotInCutsceneImpl,0x801A3F6C,0x12 asm/non_matchings/code/code_8019AF00/Audio_PlaySfx_IfNotInCutscene.s,Audio_PlaySfx_IfNotInCutscene,0x801A3FB4,0x12 -asm/non_matchings/code/code_8019AF00/Audio_MuteSfxAndAmbienceSeqExceptOcarinaAndSystem.s,Audio_MuteSfxAndAmbienceSeqExceptOcarinaAndSystem,0x801A3FFC,0x4 +asm/non_matchings/code/code_8019AF00/Audio_MuteSfxAndAmbienceSeqExceptSystemAndOcarina.s,Audio_MuteSfxAndAmbienceSeqExceptSystemAndOcarina,0x801A3FFC,0x4 asm/non_matchings/code/code_8019AF00/Audio_SetSpec.s,Audio_SetSpec,0x801A400C,0x13 -asm/non_matchings/code/code_8019AF00/func_801A4058.s,func_801A4058,0x801A4058,0x5C -asm/non_matchings/code/code_8019AF00/func_801A41C8.s,func_801A41C8,0x801A41C8,0xC -asm/non_matchings/code/code_8019AF00/func_801A41F8.s,func_801A41F8,0x801A41F8,0x29 +asm/non_matchings/code/code_8019AF00/Audio_MuteAllSeqExceptSystemAndOcarina.s,Audio_MuteAllSeqExceptSystemAndOcarina,0x801A4058,0x5C +asm/non_matchings/code/code_8019AF00/Audio_MuteSfxAndAmbienceSeqExceptSysAndOca.s,Audio_MuteSfxAndAmbienceSeqExceptSysAndOca,0x801A41C8,0xC +asm/non_matchings/code/code_8019AF00/Audio_StopFanfare.s,Audio_StopFanfare,0x801A41F8,0x29 asm/non_matchings/code/code_8019AF00/Audio_StartSfxPlayer.s,Audio_StartSfxPlayer,0x801A429C,0xB -asm/non_matchings/code/code_8019AF00/func_801A42C8.s,func_801A42C8,0x801A42C8,0x17 -asm/non_matchings/code/code_8019AF00/func_801A4324.s,func_801A4324,0x801A4324,0x9 +asm/non_matchings/code/code_8019AF00/Audio_DisableAllSeq.s,Audio_DisableAllSeq,0x801A42C8,0x17 +asm/non_matchings/code/code_8019AF00/Audio_GetEnabledNotesCount.s,Audio_GetEnabledNotesCount,0x801A4324,0x9 asm/non_matchings/code/code_8019AF00/func_801A4348.s,func_801A4348,0x801A4348,0xE asm/non_matchings/code/code_8019AF00/Audio_SetSfxVolumeExceptSystemAndOcarinaBanks.s,Audio_SetSfxVolumeExceptSystemAndOcarinaBanks,0x801A4380,0x2A asm/non_matchings/code/code_8019AF00/Audio_SetSfxReverbIndexExceptOcarinaBank.s,Audio_SetSfxReverbIndexExceptOcarinaBank,0x801A4428,0x1F