From ed0f2fed88a7ab36c3b323d64f0c45a4aaa09a9b Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 5 Jun 2025 21:58:13 +0200 Subject: [PATCH] Fixes --- config/SOUE01/splits.txt | 12 +++++-- config/SOUE01/symbols.txt | 20 +++++------ configure.py | 2 ++ include/d/snd/d_snd_player_mgr.h | 32 +++++++++++++++++ include/d/snd/d_snd_source.h | 1 + include/nw4r/snd/snd_SoundPlayer.h | 1 + include/toBeSorted/music_mgrs.h | 3 ++ src/d/snd/d_snd_player_mgr.cpp | 55 ++++++++++++++++++++++++++++-- 8 files changed, 110 insertions(+), 16 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 4ebbe039..13bb72e7 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2397,13 +2397,13 @@ d/snd/d_snd_unk_component_2.cpp: .text start:0x80366430 end:0x8036A3A4 align:16 d/snd/d_snd_area_sound_effect_mgr.cpp: - .text start:0x8036A3B0 end:0x8036B8D0 + .text start:0x8036A3B0 end:0x8036B8D0 align:16 .data start:0x80548B38 end:0x80548B48 .sbss start:0x80575D78 end:0x80575D80 .sdata2 start:0x8057D8B0 end:0x8057D8E8 d/snd/d_snd_area_sound.cpp: - .text start:0x8036B8D0 end:0x8036C090 + .text start:0x8036B8D0 end:0x8036C090 align:16 .data start:0x80548B48 end:0x80548B78 .sdata2 start:0x8057D8E8 end:0x8057D920 @@ -2417,8 +2417,14 @@ d/snd/d_snd_control_player.cpp: .data start:0x80548C38 end:0x80548CC8 .sdata2 start:0x8057D938 end:0x8057D940 +d/snd/d_snd_bgm_mgr.cpp: + .text start:0x8036C6B0 end:0x803739CC align:16 + +d/snd/d_snd_bgm_sound.cpp: + .text start:0x803739D0 end:0x8037BA68 align:16 + d/snd/d_snd_unk_15.cpp: - .text start:0x8036C6B0 end:0x8037D800 align:16 + .text start:0x8037BA70 end:0x8037D800 align:16 d/snd/d_snd_small_effect_mgr.cpp: .text start:0x8037D800 end:0x8037F8B4 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 28dc2197..9c98f249 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19944,13 +19944,13 @@ fn_8035E220 = .text:0x8035E220; // type:function size:0x2C fn_8035E250 = .text:0x8035E250; // type:function size:0x8C fn_8035E2E0 = .text:0x8035E2E0; // type:function size:0x2C fn_8035E310 = .text:0x8035E310; // type:function size:0x50 -fn_8035E360 = .text:0x8035E360; // type:function size:0x70 -fn_8035E3D0 = .text:0x8035E3D0; // type:function size:0x70 -fn_8035E440 = .text:0x8035E440; // type:function size:0x2C -fn_8035E470 = .text:0x8035E470; // type:function size:0x2C -fn_8035E4A0 = .text:0x8035E4A0; // type:function size:0x44 -fn_8035E4F0 = .text:0x8035E4F0; // type:function size:0x44 -fn_8035E540 = .text:0x8035E540; // type:function size:0x18 +enterPauseState__15dSndPlayerMgr_cFv = .text:0x8035E360; // type:function size:0x70 +leavePauseState__15dSndPlayerMgr_cFv = .text:0x8035E3D0; // type:function size:0x70 +enterMenu__15dSndPlayerMgr_cFv = .text:0x8035E440; // type:function size:0x2C +leaveMenu__15dSndPlayerMgr_cFv = .text:0x8035E470; // type:function size:0x2C +enterMap__15dSndPlayerMgr_cFv = .text:0x8035E4A0; // type:function size:0x44 +leaveMap__15dSndPlayerMgr_cFv = .text:0x8035E4F0; // type:function size:0x44 +enterHelp__15dSndPlayerMgr_cFv = .text:0x8035E540; // type:function size:0x18 fn_8035E560 = .text:0x8035E560; // type:function size:0x18 fn_8035E580 = .text:0x8035E580; // type:function size:0x50 fn_8035E5D0 = .text:0x8035E5D0; // type:function size:0x44 @@ -37694,7 +37694,7 @@ lbl_80548AFC = .data:0x80548AFC; // type:object size:0xC lbl_80548B08 = .data:0x80548B08; // type:object size:0x14 lbl_80548B1C = .data:0x80548B1C; // type:object size:0x10 lbl_80548B2C = .data:0x80548B2C; // type:object size:0xC -lbl_80548B38 = .data:0x80548B38; // type:object size:0x10 +__vt__42SndMgrDisposer<24dSndAreaSoundEffectMgr_c> = .data:0x80548B38; // type:object size:0x10 lbl_80548B48 = .data:0x80548B48; // type:object size:0x30 __vt__33dSndControlSoundStrmTrackVolume_c = .data:0x80548B78; // type:object size:0x20 __vt__32dSndControlSoundSeqTrackVolume_c = .data:0x80548B98; // type:object size:0x20 @@ -41902,8 +41902,8 @@ lbl_80575D64 = .sbss:0x80575D64; // type:object size:0x4 data:4byte lbl_80575D68 = .sbss:0x80575D68; // type:object size:0x4 data:4byte ENEMY_SOUND_MGR = .sbss:0x80575D6C; // type:object size:0x4 data:4byte ENEMY_SOUND_MGR_source = .sbss:0x80575D70; // type:object size:0x8 data:4byte -lbl_80575D78 = .sbss:0x80575D78; // type:object size:0x4 data:4byte -lbl_80575D7C = .sbss:0x80575D7C; // type:object size:0x4 data:4byte +sInstance__24dSndAreaSoundEffectMgr_c = .sbss:0x80575D78; // type:object size:0x4 data:4byte +sDisposer__24dSndAreaSoundEffectMgr_c = .sbss:0x80575D7C; // type:object size:0x4 data:4byte FANFARE_SOUND_MGR = .sbss:0x80575D80; // type:object size:0x4 data:4byte FANFARE_SOUND_MGR_source = .sbss:0x80575D84; // type:object size:0x4 data:4byte lbl_80575D88 = .sbss:0x80575D88; // type:object size:0x8 data:4byte diff --git a/configure.py b/configure.py index 214d5ba8..b1193287 100644 --- a/configure.py +++ b/configure.py @@ -711,6 +711,8 @@ config.libs = [ Object(NonMatching, "d/snd/d_snd_control_player_mgr.cpp"), Object(Matching, "d/snd/d_snd_3d_manager.cpp"), Object(NonMatching, "d/snd/d_snd_stage_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_mgr.cpp"), + Object(NonMatching, "d/snd/d_snd_bgm_sound.cpp"), Object(NonMatching, "d/snd/d_snd_unk_component_2.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_area_sound.cpp"), diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index d5c877eb..d803ab70 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -13,6 +13,8 @@ SND_DISPOSER_FORWARD_DECL(dSndPlayerMgr_c); /** * The main interface for managing sound stuff. Will delegate to dSndMgr_c for * most things, but handles demo (cutscene) sound effects (SE_DEMO*) by itself. + * + * Previous Ghidra name: BgmMgr */ class dSndPlayerMgr_c { public: @@ -24,6 +26,16 @@ public: void shutdown(); void calc(); + void enterMenu(); + void leaveMenu(); + void enterMap(); + void leaveMap(); + void enterHelp(); + void leaveHelp(); + + void enterHbm(); + void leaveHbm(); + u32 getFreeSize(); bool loadDemoArchive(const char *demoArchiveName); const char *getSoundArchivePath(); @@ -32,10 +44,26 @@ public: nw4r::snd::SoundArchivePlayer &getSoundArchivePlayerForType(u8 type); bool canUseThisPlayer(u8 type) const; + enum PlayerMgrFlag_e { + MGR_HBM = 0x1, + MGR_UNK_0x2 = 0x2, + MGR_PAUSE = 0x4, + MGR_MAP = 0x8, + MGR_HELP = 0x10, + }; + bool checkFlag(u32 mask) const { return mFlags & mask; } + void onFlag(u32 mask) { + mFlags |= mask; + } + + void offFlag(u32 mask) { + mFlags &= ~mask; + } + u32 getEventMuteMask(u32 id) { nw4r::snd::SoundArchive *archive; if (mSoundArchivePlayer.IsAvailable()) { @@ -124,6 +152,10 @@ private: /* 0x01C */ s32 field_0x01C; /* 0x020 */ u32 mFlags; + // system menu, inventory, map + void enterPauseState(); + void leavePauseState(); + virtual nw4r::snd::SoundStartable::StartResult startSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo); virtual nw4r::snd::SoundStartable::StartResult startSound( diff --git a/include/d/snd/d_snd_source.h b/include/d/snd/d_snd_source.h index d732e924..1b2ca525 100644 --- a/include/d/snd/d_snd_source.h +++ b/include/d/snd/d_snd_source.h @@ -99,6 +99,7 @@ private: /* 0x154 */ UNKWORD field_0x154; /* 0x158 */ s16 field_0x158; /* 0x15A */ s16 field_0x15A; + /* 0x15C */ nw4r::ut::Node mNode2; }; #endif diff --git a/include/nw4r/snd/snd_SoundPlayer.h b/include/nw4r/snd/snd_SoundPlayer.h index 90b56ed0..52382946 100644 --- a/include/nw4r/snd/snd_SoundPlayer.h +++ b/include/nw4r/snd/snd_SoundPlayer.h @@ -10,6 +10,7 @@ #include "nw4r/snd/snd_BasicSound.h" #include "nw4r/snd/snd_global.h" // AUX_BUS_NUM #include "nw4r/snd/snd_PlayerHeap.h" +#include "nw4r/snd/snd_SoundHandle.h" /******************************************************************************* * classes diff --git a/include/toBeSorted/music_mgrs.h b/include/toBeSorted/music_mgrs.h index 1efa7fe0..8d255eb8 100644 --- a/include/toBeSorted/music_mgrs.h +++ b/include/toBeSorted/music_mgrs.h @@ -33,6 +33,9 @@ extern "C" void *ENEMY_BGM_RELATED_MGR; extern "C" void fn_80384570(void *, bool); extern "C" void fn_803858D0(void *); + +// This one has a SoundActor that actually plays the BGM_ music tracks, +// including the battle BGM track. extern "C" void *FANFARE_SOUND_MGR; extern "C" void AnotherSoundMgr__playSound(void *, s32); extern "C" bool fn_803721F0(void *, u32); diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index b89ecdd5..6a25a564 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -2,7 +2,10 @@ #include "d/snd/d_snd_player_mgr.h" #include "common.h" +#include "d/snd/d_snd_control_player_mgr.h" #include "d/snd/d_snd_mgr.h" +#include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_wzsound.h" #include "egg/core/eggDvdRipper.h" #include "nw4r/snd/snd_SoundHandle.h" #include "nw4r/snd/snd_SoundStartable.h" @@ -17,14 +20,61 @@ SND_DISPOSER_DEFINE(dSndPlayerMgr_c); dSndPlayerMgr_c::dSndPlayerMgr_c() : field_0x010(0), field_0x011(0), field_0x014(-1), field_0x018(-1), field_0x01C(-1), mFlags(0) {} +void dSndPlayerMgr_c::enterPauseState() { + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_FAN, 0.3f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA, 0.3f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA_IN_WATER_LV, 0.3f, 5); + // has other effects, such as reducing BGM volume + onFlag(MGR_PAUSE); +} + u32 dSndPlayerMgr_c::getFreeSize() { return dSndMgr_c::GetInstance()->getSoundHeap()->GetFreeSize(); } +void dSndPlayerMgr_c::leavePauseState() { + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_FAN, 1.0f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA, 1.0f, 5); + dSndControlPlayerMgr_c::GetInstance()->setVolume(PLAYER_AREA_IN_WATER_LV, 1.0f, 5); + offFlag(MGR_PAUSE); +} + +void dSndPlayerMgr_c::enterMenu() { + enterPauseState(); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MENU_IN); +} + +void dSndPlayerMgr_c::leaveMenu() { + leavePauseState(); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MENU_OUT); +} + +void dSndPlayerMgr_c::enterMap() { + enterPauseState(); + onFlag(MGR_MAP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_OPEN); +} + +void dSndPlayerMgr_c::leaveMap() { + leavePauseState(); + offFlag(MGR_MAP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_CLOSE); +} + +void dSndPlayerMgr_c::enterHelp() { + onFlag(MGR_HELP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HELP_IN); +} + +void dSndPlayerMgr_c::leaveHelp() { + offFlag(MGR_HELP); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HELP_OUT); +} + nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound( nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo ) { - if (mFlags & 0x2) { + if (checkFlag(MGR_UNK_0x2)) { return nw4r::snd::SoundStartable::START_ERR_USER; } @@ -65,7 +115,7 @@ bool dSndPlayerMgr_c::canUseThisPlayer(u8 type) const { } int ty = type; - + if ((ty >= 0 && ty <= 1) || ty == 58) { return true; } @@ -110,7 +160,6 @@ void dSndPlayerMgr_c::shutdown() { mSoundArchive.Shutdown(); } - void dSndPlayerMgr_c::calc() { if (mSoundArchivePlayer.IsAvailable()) { mSoundArchivePlayer.Update();