diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index dc814f19..bc2f3da0 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20473,7 +20473,7 @@ fn_80370420 = .text:0x80370420; // type:function size:0xCC fn_803704F0 = .text:0x803704F0; // type:function size:0xC playBattleBgm__12dSndBgmMgr_cFUlb = .text:0x80370500; // type:function size:0x120 fn_80370620 = .text:0x80370620; // type:function size:0xC0 -fn_803706E0 = .text:0x803706E0; // type:function size:0x24 +beginBgmBattleMainLoop__12dSndBgmMgr_cFv = .text:0x803706E0; // type:function size:0x24 fn_80370710 = .text:0x80370710; // type:function size:0x64 beginBgmBattleRoom__12dSndBgmMgr_cFv = .text:0x80370780; // type:function size:0x54 endBgmBattleRoom__12dSndBgmMgr_cFv = .text:0x803707E0; // type:function size:0x60 @@ -20532,7 +20532,7 @@ fn_803725E0 = .text:0x803725E0; // type:function size:0xB4 fn_803726A0 = .text:0x803726A0; // type:function size:0xE4 findIdleBgmSoundHandle__12dSndBgmMgr_cFv = .text:0x80372790; // type:function size:0x10C fn_803728A0 = .text:0x803728A0; // type:function size:0x74 -fn_80372920 = .text:0x80372920; // type:function size:0x3C +cullTooManyPreparingSounds__12dSndBgmMgr_cFv = .text:0x80372920; // type:function size:0x3C getBgmBattleSound__12dSndBgmMgr_cFv = .text:0x80372960; // type:function size:0x8 addToBgmSoundList__12dSndBgmMgr_cFQ212dSndBgmMgr_c14BgmSoundList_eP14dSndBgmSound_c = .text:0x80372970; // type:function size:0x6C appendToBgmSoundList__12dSndBgmMgr_cFQ212dSndBgmMgr_c14BgmSoundList_eP14dSndBgmSound_c = .text:0x803729E0; // type:function size:0x6C @@ -20550,7 +20550,7 @@ fn_80372E30 = .text:0x80372E30; // type:function size:0x40 fn_80372E70 = .text:0x80372E70; // type:function size:0xB0 fn_80372F20 = .text:0x80372F20; // type:function size:0x6C playFanSound__12dSndBgmMgr_cFUl = .text:0x80372F90; // type:function size:0x264 -setField0x101__14dSoundSource_cFUc = .text:0x80373200; // type:function size:0x8 +setField0x101__14dSoundSource_cFb = .text:0x80373200; // type:function size:0x8 prepareFanSound__12dSndBgmMgr_cFUl = .text:0x80373210; // type:function size:0xB4 getFreeFanSoundHandle__12dSndBgmMgr_cFv = .text:0x803732D0; // type:function size:0x44 getFanSoundHandleForFan__12dSndBgmMgr_cFUl = .text:0x80373320; // type:function size:0x8C @@ -20976,7 +20976,7 @@ fn_80384360 = .text:0x80384360; // type:function size:0x7C fn_803843E0 = .text:0x803843E0; // type:function size:0x34 fn_80384420 = .text:0x80384420; // type:function size:0x94 fn_803844C0 = .text:0x803844C0; // type:function size:0xB0 -fn_80384570 = .text:0x80384570; // type:function size:0xC0 +setMutedFromFader__15dSndSourceMgr_cFb = .text:0x80384570; // type:function size:0xC0 fn_80384630 = .text:0x80384630; // type:function size:0x94 fn_803846D0 = .text:0x803846D0; // type:function size:0xA0 getGroup__15dSndSourceMgr_cFlP9dAcBase_cPCcPCcUc = .text:0x80384770; // type:function size:0xAC diff --git a/include/d/snd/d_snd_bgm_mgr.h b/include/d/snd/d_snd_bgm_mgr.h index ff05db51..aa8654fa 100644 --- a/include/d/snd/d_snd_bgm_mgr.h +++ b/include/d/snd/d_snd_bgm_mgr.h @@ -73,7 +73,10 @@ public: /** Runs when the fight is over, no matter how you started it */ bool endBgmBattleRoom(); + bool beginBgmBattleMainLoop(); + bool isPlayingAnyBattleMusic(); + void cullTooManyPreparingSounds(); void removeFromAllBgmSoundLists(dSndBgmSound_c *sound); void addToBgmSoundList(BgmSoundList_e list, dSndBgmSound_c *sound); diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index 161322ab..f84105b5 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -183,7 +183,7 @@ public: return false; } /* 0x0F0 */ virtual void vt_0x0F0_noop() override {} - /* 0x0F4 */ virtual void setField0x101(u8 value) override { + /* 0x0F4 */ virtual void setField0x101(bool value) override { field_0x101 = value; } /* 0x0F8 */ virtual void setField0x102(u8 value) override { @@ -273,7 +273,7 @@ protected: /* 0x0FE */ u8 mSubtype; /* 0x0FF */ bool mIsSetup; /* 0x100 */ u8 field_0x100; - /* 0x101 */ u8 field_0x101; + /* 0x101 */ bool field_0x101; /* 0x102 */ u8 field_0x102; /* 0x104 */ u32 mFlagsPersistent; /* 0x108 */ u32 mFlagsHold; diff --git a/include/d/snd/d_snd_source_if.h b/include/d/snd/d_snd_source_if.h index 2ff36728..86a08c9f 100644 --- a/include/d/snd/d_snd_source_if.h +++ b/include/d/snd/d_snd_source_if.h @@ -93,7 +93,7 @@ public: /* 0x0E8 */ virtual bool isPlayingActionSound() const = 0; /* 0x0EC */ virtual bool isCurrentActionSound(u32 id) const = 0; /* 0x0F0 */ virtual void vt_0x0F0_noop() = 0; - /* 0x0F4 */ virtual void setField0x101(u8 value) = 0; + /* 0x0F4 */ virtual void setField0x101(bool value) = 0; /* 0x0F8 */ virtual void setField0x102(u8 value) = 0; /* 0x0FC */ virtual bool isInaudible() = 0; /* 0x100 */ virtual bool hasAnimSound() = 0; diff --git a/include/d/snd/d_snd_source_mgr.h b/include/d/snd/d_snd_source_mgr.h index 6bcbefad..e1eb6a28 100644 --- a/include/d/snd/d_snd_source_mgr.h +++ b/include/d/snd/d_snd_source_mgr.h @@ -62,6 +62,8 @@ public: field_0x3868--; } + void setMutedFromFader(bool muteFlag); + private: void calcEnemyObjVolume(); diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index b11174bc..17821527 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -2,9 +2,7 @@ #define MUSIC_MGRS_H #include "common.h" -#include "d/snd/d_snd_bgm_mgr.h" #include "d/snd/d_snd_player_mgr.h" -#include "d/snd/d_snd_source_mgr.h" #include "d/snd/d_snd_state_mgr.h" class dSndSound_c; @@ -16,6 +14,7 @@ extern "C" void fn_8035E000(); extern "C" void fn_8035E860(dSndPlayerMgr_c *); extern "C" void fn_8035E820(dSndPlayerMgr_c *); extern "C" void fn_8035E880(dSndPlayerMgr_c *); +extern "C" void fn_8035E310(dSndPlayerMgr_c *); #define ENEMY_SOUND_MGR (dSndStateMgr_c::GetInstance()) extern "C" void fn_80362150(dSndStateMgr_c *, u16); @@ -24,17 +23,8 @@ extern "C" void fn_803618F0(dSndStateMgr_c *); extern "C" void fn_80362730(dSndStateMgr_c *); extern "C" void fn_80365D20(dSndStateMgr_c *); extern "C" void fn_803624F0(dSndStateMgr_c *); -extern "C" void fn_80364FD0(dSndStateMgr_c *, s32); extern "C" bool fn_80364DA0(dSndStateMgr_c *); extern "C" void fn_80365020(dSndStateMgr_c *); extern "C" void fn_80364D00(dSndStateMgr_c *, s32); -#define ENEMY_BGM_RELATED_MGR (dSndSourceMgr_c::GetInstance()) -extern "C" void fn_80384570(dSndSourceMgr_c *, bool); - -// This one has a SoundActor that actually plays the BGM_ music tracks, -// including the battle BGM track. -#define FANFARE_SOUND_MGR (dSndBgmMgr_c::GetInstance()) -extern "C" void fn_80372920(dSndBgmMgr_c *); - #endif diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index 684824f7..7d2d2d38 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -13,6 +13,7 @@ #include "d/flag/dungeonflag_manager.h" #include "d/flag/sceneflag_manager.h" #include "d/flag/storyflag_manager.h" +#include "d/snd/d_snd_source_mgr.h" #include "f/f_base.h" #include "f/f_profile.h" #include "f/f_profile_name.h" @@ -27,7 +28,6 @@ #include "toBeSorted/arc_managers/layout_arc_manager.h" #include "toBeSorted/arc_managers/oarc_manager.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/music_mgrs.h" #include "toBeSorted/time_area_mgr.h" #include @@ -164,7 +164,7 @@ bool dStage_c::fadeIn(s32 fadeType, u16 frames) { mFader.setFadeInType(fadeType); mFader.setFadeInFrame(frames); mFader.fadeIn(); - fn_80384570(ENEMY_BGM_RELATED_MGR, false); + dSndSourceMgr_c::GetInstance()->setMutedFromFader(false); return true; } @@ -175,18 +175,18 @@ bool dStage_c::fadeOut(s32 fadeType, u16 frames) { mFader.setFadeOutType(fadeType); mFader.setFadeOutFrame(frames); mFader.fadeOut(); - fn_80384570(ENEMY_BGM_RELATED_MGR, true); + dSndSourceMgr_c::GetInstance()->setMutedFromFader(true); return true; } void dStage_c::forceFadeOut() { mFader.setStatus(mFaderBase_c::FADED_OUT); - fn_80384570(ENEMY_BGM_RELATED_MGR, true); + dSndSourceMgr_c::GetInstance()->setMutedFromFader(true); } void dStage_c::forceFadeIn() { mFader.setStatus(mFaderBase_c::FADED_IN); - fn_80384570(ENEMY_BGM_RELATED_MGR, false); + dSndSourceMgr_c::GetInstance()->setMutedFromFader(false); } void dStage_c::drawMap(mMtx_c *mtx, int param) { diff --git a/src/d/d_tag_processor.cpp b/src/d/d_tag_processor.cpp index bad5969e..17510bbe 100644 --- a/src/d/d_tag_processor.cpp +++ b/src/d/d_tag_processor.cpp @@ -23,7 +23,6 @@ #include "nw4r/ut/ut_TextWriterBase.h" #include "sized_string.h" #include "toBeSorted/file_manager.h" -#include "toBeSorted/music_mgrs.h" #include diff --git a/src/d/lyt/msg_window/d_lyt_msg_window.cpp b/src/d/lyt/msg_window/d_lyt_msg_window.cpp index 89e027a5..a7444bf5 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window.cpp @@ -28,6 +28,7 @@ // clang-format on #include "d/d_gfx.h" +#include "d/snd/d_snd_player_mgr.h" #include "d/snd/d_snd_small_effect_mgr.h" #include "f/f_base.h" #include "m/m_fader_base.h" @@ -37,7 +38,6 @@ #include "toBeSorted/d_d3d.h" #include "toBeSorted/event_manager.h" #include "toBeSorted/fi_context.h" -#include "toBeSorted/music_mgrs.h" #include "toBeSorted/other_sound_stuff.h" #include @@ -345,7 +345,7 @@ void dLytMsgWindow_c::initializeState_WaitKeyChangePage0() { if (field_0x811 != 0) { field_0x812 = 1; } else if (field_0x814 == 0) { - fn_8035E860(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->enterMsgWait(); } } void dLytMsgWindow_c::executeState_WaitKeyChangePage0() { @@ -360,7 +360,7 @@ void dLytMsgWindow_c::executeState_WaitKeyChangePage0() { allowChange = true; } } else if (dPad::getDownTrigA() || fn_8011A5D0()) { - fn_8035E880(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->leaveMsgWait(); allowChange = true; } @@ -403,7 +403,7 @@ void dLytMsgWindow_c::initializeState_WaitKeyMsgEnd0() { if (field_0x811 != 0) { field_0x812 = 1; } else if (mpTagProcessor->getField_0x90E() == 0 && field_0x814 == 0) { - fn_8035E860(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->enterMsgWait(); } } void dLytMsgWindow_c::executeState_WaitKeyMsgEnd0() { @@ -420,7 +420,7 @@ void dLytMsgWindow_c::executeState_WaitKeyMsgEnd0() { allowChange = true; } } else if (dPad::getDownTrigA() || fn_8011A5D0()) { - fn_8035E880(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->leaveMsgWait(); allowChange = true; } @@ -441,7 +441,7 @@ void dLytMsgWindow_c::executeState_WaitKeyMsgEnd0() { } field_0x810 = 0; } else { - fn_8035E820(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->unsetMsgActor(); if (mpTagProcessor->getField_0x90E() != 0) { mStateMgr.changeState(StateID_WaitKeySelectQuestion); } else { @@ -465,7 +465,7 @@ void dLytMsgWindow_c::executeState_WaitKeyMsgEnd1() { } field_0x810 = 0; } else { - fn_8035E820(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->unsetMsgActor(); if (mpTagProcessor->getField_0x90E() != 0) { mStateMgr.changeState(StateID_WaitKeySelectQuestion); } else if (field_0x817 == 0) { diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp index e4973458..23b4ce88 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp @@ -4,8 +4,8 @@ #include "d/d_pad.h" #include "d/d_pad_nav.h" #include "d/lyt/d2d.h" +#include "d/snd/d_snd_player_mgr.h" #include "d/snd/d_snd_small_effect_mgr.h" -#include "toBeSorted/music_mgrs.h" STATE_DEFINE(dLytMsgWindowSelectBtnParts_c, Wait); STATE_DEFINE(dLytMsgWindowSelectBtnParts_c, On); @@ -302,7 +302,7 @@ void dLytMsgWindowSelectBtn_c::finalizeState_In() { void dLytMsgWindowSelectBtn_c::initializeState_WaitSelect() { if (field_0x9D0 == 0) { field_0x9D0 = true; - fn_8035E860(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->enterMsgWait(); } mBtnHelper.fn_8011C970(); @@ -340,7 +340,7 @@ void dLytMsgWindowSelectBtn_c::executeState_WaitSelect() { } else { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TALK_CURSOR_OK); } - fn_8035E880(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->leaveMsgWait(); } else if (dPad::getDownTrigB()) { f32 f = mBtnHelper.fn_8011D690(field_0x9BC); // TODO @@ -353,7 +353,7 @@ void dLytMsgWindowSelectBtn_c::executeState_WaitSelect() { } else { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TALK_CURSOR_OK); } - fn_8035E880(BGM_MGR); + dSndPlayerMgr_c::GetInstance()->leaveMsgWait(); } } void dLytMsgWindowSelectBtn_c::finalizeState_WaitSelect() {} diff --git a/src/d/snd/d_snd_bgm_mgr.cpp b/src/d/snd/d_snd_bgm_mgr.cpp index a972531c..04e206b2 100644 --- a/src/d/snd/d_snd_bgm_mgr.cpp +++ b/src/d/snd/d_snd_bgm_mgr.cpp @@ -155,6 +155,10 @@ void dSndBgmMgr_c::checkForPrepareStoppedBgmSound(u32 stoppedSoundId) { } } +bool dSndBgmMgr_c::beginBgmBattleMainLoop() { + return getBgmBattleSound()->startMainBattleLoop(); +} + bool dSndBgmMgr_c::beginBgmBattleRoom() { if (isBgmHandleIdxPlayingSoundId(4, BGM_BATTLE_ROOM_MAIN)) { return false; @@ -355,6 +359,10 @@ dSndBgmSound_c *dSndBgmMgr_c::findIdleBgmSoundHandle() { return nullptr; } +dSndBgmBattleSound_c *dSndBgmMgr_c::getBgmBattleSound() { + return static_cast(mBgmSounds[4]); +} + void dSndBgmMgr_c::addToBgmSoundList(BgmSoundList_e list, dSndBgmSound_c *sound) { if (list < BGM_LIST_MAX && sound != nullptr) { removeFromAllBgmSoundLists(sound); diff --git a/src/d/snd/d_snd_bgm_sound.cpp b/src/d/snd/d_snd_bgm_sound.cpp index 60a717bc..138c0e40 100644 --- a/src/d/snd/d_snd_bgm_sound.cpp +++ b/src/d/snd/d_snd_bgm_sound.cpp @@ -263,7 +263,7 @@ nw4r::snd::SoundStartable::StartResult dSndBgmSound_c::prepareSound(u32 soundId, if (isPreparing()) { forceStop(); } else { - fn_80372920(FANFARE_SOUND_MGR); + dSndBgmMgr_c::GetInstance()->cullTooManyPreparingSounds(); } } diff --git a/src/d/snd/d_snd_sound.cpp b/src/d/snd/d_snd_sound.cpp index 7e51e683..41246acb 100644 --- a/src/d/snd/d_snd_sound.cpp +++ b/src/d/snd/d_snd_sound.cpp @@ -342,7 +342,7 @@ nw4r::snd::SoundStartable::StartResult dSndSound_c::prepareSound(u32 soundId, u3 if (isPreparing()) { forceStop(); } else { - fn_80372920(FANFARE_SOUND_MGR); + dSndBgmMgr_c::GetInstance()->cullTooManyPreparingSounds(); } } diff --git a/src/d/snd/d_snd_source_mgr.cpp b/src/d/snd/d_snd_source_mgr.cpp index 6b214a7b..9a391372 100644 --- a/src/d/snd/d_snd_source_mgr.cpp +++ b/src/d/snd/d_snd_source_mgr.cpp @@ -406,6 +406,25 @@ void dSndSourceMgr_c::calcEnemyObjVolume() { } } +void dSndSourceMgr_c::setMutedFromFader(bool muteFlag) { + for (dSoundSource_c *it = getAllSourcesFirst(); it != nullptr; it = getAllSourcesNext(it)) { + s32 sourceType = it->getSourceType(); + switch (sourceType) { + case SND_SOURCE_PLAYER: + case SND_SOURCE_PLAYER_HEAD: + break; + default: + it->setField0x101(muteFlag); + break; + } + } + if (muteFlag) { + dSndControlPlayerMgr_c::GetInstance()->muteScenePlayers(30); + } else { + dSndControlPlayerMgr_c::GetInstance()->unmuteScenePlayers(30); + } +} + dSndSourceGroup_c *dSndSourceMgr_c::getGroup(s32 sourceType, dAcBase_c *actor, const char *name, const char *origName, u8 subtype) { dSndSourceGroup_c *group = getActiveGroupForName(name); if (group != nullptr) {