From 1be399e999307d9bd3fdffaf03618edefd5fdc84 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 20 Jul 2025 22:10:38 +0200 Subject: [PATCH] d_snd_small_effect_mgr OK --- config/SOUE01/symbols.txt | 60 +++++++------- configure.py | 2 +- include/d/snd/d_snd_player_mgr.h | 6 ++ include/d/snd/d_snd_small_effect_mgr.h | 3 + include/d/snd/d_snd_state_mgr.h | 15 +++- src/d/snd/d_snd_small_effect_mgr.cpp | 108 ++++++++++++++++++++++--- src/d/snd/d_snd_state_mgr.cpp | 32 ++++---- 7 files changed, 169 insertions(+), 57 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 3a5b3926..fa59aed5 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -19964,7 +19964,7 @@ setup__15dSndPlayerMgr_cFl = .text:0x8035E8A0; // type:function size:0xC shutdown__15dSndPlayerMgr_cFl = .text:0x8035E8B0; // type:function size:0xC startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E8C0; // type:function size:0x90 startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandlePCcPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E950; // type:function size:0x6C -fn_8035E9C0 = .text:0x8035E9C0; // type:function size:0x80 +startDemoSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E9C0; // type:function size:0x80 loadGroup__15dSndPlayerMgr_cFUl = .text:0x8035EA40; // type:function size:0x64 loadFileForSound__15dSndPlayerMgr_cFUl = .text:0x8035EAB0; // type:function size:0x28 isLoadedFileForSound__15dSndPlayerMgr_cFUl = .text:0x8035EAE0; // type:function size:0xC @@ -20828,11 +20828,11 @@ NoteOnCommandProc__28dSndBgmMmlParserTagBgmBoss_cCFUliiil = .text:0x8037D640; // __ct__29dSndBgmMmlParserTagCompNote_cFv = .text:0x8037D6B0; // type:function size:0x5C parseData__29dSndBgmMmlParserTagCompNote_cFPP11dSndTagData = .text:0x8037D710; // type:function size:0x94 NoteOnCommandProc__29dSndBgmMmlParserTagCompNote_cCFUliiil = .text:0x8037D7B0; // type:function size:0x50 -__dt__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D800; // type:function size:0x78 -create__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D880; // type:function size:0x48 -remove__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D8D0; // type:function size:0x10 +__dt__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D800; // type:function size:0x78 scope:weak +create__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D880; // type:function size:0x48 scope:weak +remove__38SndMgrDisposer<20dSndSmallEffectMgr_c>Fv = .text:0x8037D8D0; // type:function size:0x10 scope:weak __ct__20dSndSmallEffectMgr_cFv = .text:0x8037D8E0; // type:function size:0x9C -__ct__Q34nw4r3snd11SoundHandleFv = .text:0x8037D980; // type:function size:0xC +__ct__Q34nw4r3snd11SoundHandleFv = .text:0x8037D980; // type:function size:0xC scope:weak initialize__20dSndSmallEffectMgr_cFv = .text:0x8037D990; // type:function size:0x4 calc__20dSndSmallEffectMgr_cFv = .text:0x8037D9A0; // type:function size:0xA0 calcTimer__20dSndSmallEffectMgr_cFv = .text:0x8037DA40; // type:function size:0x18 @@ -20844,7 +20844,7 @@ playSoundInternalChecked__20dSndSmallEffectMgr_cFUlPQ34nw4r3snd11SoundHandle = . playSoundInternal__20dSndSmallEffectMgr_cFUlPQ34nw4r3snd11SoundHandle = .text:0x8037DD10; // type:function size:0x1BC playSound__20dSndSmallEffectMgr_cFUl = .text:0x8037DED0; // type:function size:0x2D0 playSoundWithPan__20dSndSmallEffectMgr_cFUlf = .text:0x8037E1A0; // type:function size:0x90 -fn_8037E230 = .text:0x8037E230; // type:function size:0xEC +doSideEffects__20dSndSmallEffectMgr_cFUl = .text:0x8037E230; // type:function size:0xEC playSoundInternal__20dSndSmallEffectMgr_cFUl = .text:0x8037E320; // type:function size:0x78 getHoldSoundHandle__20dSndSmallEffectMgr_cFUl = .text:0x8037E3A0; // type:function size:0x158 holdSound__20dSndSmallEffectMgr_cFUl = .text:0x8037E500; // type:function size:0x58 @@ -20866,9 +20866,9 @@ playMinigameScoreUpSound__20dSndSmallEffectMgr_cFl = .text:0x8037EB10; // type:f playMinigameScoreDownSound__20dSndSmallEffectMgr_cFv = .text:0x8037EC30; // type:function size:0x8 playMinigameMusasabiSound__20dSndSmallEffectMgr_cFl = .text:0x8037EC40; // type:function size:0x3C playSkbSound__20dSndSmallEffectMgr_cFUl = .text:0x8037EC80; // type:function size:0xB0 -fn_8037ED30 = .text:0x8037ED30; // type:function size:0x68 +playDemoSound__20dSndSmallEffectMgr_cFUlPQ34nw4r3snd11SoundHandle = .text:0x8037ED30; // type:function size:0x68 stopSounds__20dSndSmallEffectMgr_cFUlUll = .text:0x8037EDA0; // type:function size:0xA0 -__cl__12SoundStopperFRQ34nw4r3snd11SoundHandle = .text:0x8037EE40; // type:function size:0x3C +__cl__12SoundStopperFRQ34nw4r3snd11SoundHandle = .text:0x8037EE40; // type:function size:0x3C scope:weak stopSounds__20dSndSmallEffectMgr_cFUll = .text:0x8037EE80; // type:function size:0x64 isPlayingSound__20dSndSmallEffectMgr_cFUlUl = .text:0x8037EEF0; // type:function size:0xAC isPlayingSound__20dSndSmallEffectMgr_cFUl = .text:0x8037EFA0; // type:function size:0x80 @@ -20876,8 +20876,8 @@ playButtonPressSoundWhenAdvancingTextBoxes__20dSndSmallEffectMgr_cFf = .text:0x8 resetButtonPressSound__20dSndSmallEffectMgr_cFv = .text:0x8037F0E0; // type:function size:0xC setButtonPressSound__20dSndSmallEffectMgr_cFP14dSoundSource_c = .text:0x8037F0F0; // type:function size:0x60 playBattleHitSound__20dSndSmallEffectMgr_cFQ220dSndSmallEffectMgr_c16BattleHitSound_eP14dSoundSource_c = .text:0x8037F150; // type:function size:0x6D0 -getName__14dSoundSource_cCFv = .text:0x8037F820; // type:function size:0x8 -getSourceType__14dSoundSource_cCFv = .text:0x8037F830; // type:function size:0x8 +getName__14dSoundSource_cCFv = .text:0x8037F820; // type:function size:0x8 scope:weak +getSourceType__14dSoundSource_cCFv = .text:0x8037F830; // type:function size:0x8 scope:weak setBitsIfAdjacent__20dSndSmallEffectMgr_cFP27dSndBgmDataHarpVarSetBase_cllPUl = .text:0x8037F840; // type:function size:0x74 __dt__35SndMgrDisposer<17dSndHarpSongMgr_c>Fv = .text:0x8037F8C0; // type:function size:0x78 create__35SndMgrDisposer<17dSndHarpSongMgr_c>Fv = .text:0x8037F940; // type:function size:0x48 @@ -38048,8 +38048,8 @@ __vt__28dSndBgmMmlParserTagBgmBoss_c = .data:0x80549178; // type:object size:0x1 __vt__27dSndBgmMmlParserTagBattle_c = .data:0x80549188; // type:object size:0x10 __vt__26dSndBgmMmlParserHarpSong_c = .data:0x80549198; // type:object size:0x10 __vt__22dSndBgmMmlParserHarp_c = .data:0x805491A8; // type:object size:0x10 -__vt__12SoundStopper = .data:0x805491B8; // type:object size:0xC -__vt__38SndMgrDisposer<20dSndSmallEffectMgr_c> = .data:0x805491C4; // type:object size:0xC +__vt__12SoundStopper = .data:0x805491B8; // type:object size:0xC scope:weak +__vt__38SndMgrDisposer<20dSndSmallEffectMgr_c> = .data:0x805491C4; // type:object size:0xC scope:weak __vt__35SndMgrDisposer<17dSndHarpSongMgr_c> = .data:0x805491D0; // type:object size:0x10 jumptable_805491E0 = .data:0x805491E0; // type:object size:0x20 scope:local lbl_80549200 = .data:0x80549200; // type:object size:0x14 data:4byte @@ -41098,7 +41098,7 @@ lbl_805742E0 = .sdata:0x805742E0; // type:object size:0x8 lbl_805742E8 = .sdata:0x805742E8; // type:object size:0x8 @7580 = .sdata:0x805742F0; // type:object size:0x6 scope:local data:string @7402 = .sdata:0x805742F8; // type:object size:0x5 scope:local data:string -lbl_80574300 = .sdata:0x80574300; // type:object size:0x8 data:string +@12944 = .sdata:0x80574300; // type:object size:0x8 scope:local data:string lbl_80574308 = .sdata:0x80574308; // type:object size:0x8 lbl_80574310 = .sdata:0x80574310; // type:object size:0x4 lbl_80574314 = .sdata:0x80574314; // type:object size:0x8 @@ -49069,23 +49069,23 @@ lbl_8057DA6C = .sdata2:0x8057DA6C; // type:object size:0x4 align:4 data:float lbl_8057DA70 = .sdata2:0x8057DA70; // type:object size:0x4 align:4 data:float lbl_8057DA74 = .sdata2:0x8057DA74; // type:object size:0x4 align:4 data:float lbl_8057DA78 = .sdata2:0x8057DA78; // type:object size:0x4 align:4 data:float -lbl_8057DA80 = .sdata2:0x8057DA80; // type:object size:0x4 align:4 data:float -lbl_8057DA84 = .sdata2:0x8057DA84; // type:object size:0x4 align:4 data:float -lbl_8057DA88 = .sdata2:0x8057DA88; // type:object size:0x4 align:4 data:float -lbl_8057DA8C = .sdata2:0x8057DA8C; // type:object size:0x4 align:4 data:float -lbl_8057DA90 = .sdata2:0x8057DA90; // type:object size:0x4 align:4 data:float -lbl_8057DA94 = .sdata2:0x8057DA94; // type:object size:0x4 align:4 data:float -lbl_8057DA98 = .sdata2:0x8057DA98; // type:object size:0x4 align:4 data:float -lbl_8057DA9C = .sdata2:0x8057DA9C; // type:object size:0x4 align:4 data:float -lbl_8057DAA0 = .sdata2:0x8057DAA0; // type:object size:0x4 align:4 data:float -lbl_8057DAA4 = .sdata2:0x8057DAA4; // type:object size:0x4 align:4 data:float -lbl_8057DAA8 = .sdata2:0x8057DAA8; // type:object size:0x4 align:4 data:float -lbl_8057DAAC = .sdata2:0x8057DAAC; // type:object size:0x4 align:4 data:float -lbl_8057DAB0 = .sdata2:0x8057DAB0; // type:object size:0x4 align:4 data:float -lbl_8057DAB4 = .sdata2:0x8057DAB4; // type:object size:0x4 align:4 data:float -lbl_8057DAB8 = .sdata2:0x8057DAB8; // type:object size:0x4 align:4 data:float -lbl_8057DAC0 = .sdata2:0x8057DAC0; // type:object size:0x8 align:8 data:double -lbl_8057DAC8 = .sdata2:0x8057DAC8; // type:object size:0x4 align:4 data:float +@12034 = .sdata2:0x8057DA80; // type:object size:0x4 scope:local align:4 data:float +@12035 = .sdata2:0x8057DA84; // type:object size:0x4 scope:local align:4 data:float +@12125 = .sdata2:0x8057DA88; // type:object size:0x4 scope:local align:4 data:float +@12177 = .sdata2:0x8057DA8C; // type:object size:0x4 scope:local align:4 data:float +@12178 = .sdata2:0x8057DA90; // type:object size:0x4 scope:local align:4 data:float +@12179 = .sdata2:0x8057DA94; // type:object size:0x4 scope:local align:4 data:float +@12217 = .sdata2:0x8057DA98; // type:object size:0x4 scope:local align:4 data:float +@12218 = .sdata2:0x8057DA9C; // type:object size:0x4 scope:local align:4 data:float +@12219 = .sdata2:0x8057DAA0; // type:object size:0x4 scope:local align:4 data:float +@12220 = .sdata2:0x8057DAA4; // type:object size:0x4 scope:local align:4 data:float +@12221 = .sdata2:0x8057DAA8; // type:object size:0x4 scope:local align:4 data:float +@12222 = .sdata2:0x8057DAAC; // type:object size:0x4 scope:local align:4 data:float +@12223 = .sdata2:0x8057DAB0; // type:object size:0x4 scope:local align:4 data:float +@12224 = .sdata2:0x8057DAB4; // type:object size:0x4 scope:local align:4 data:float +@12235 = .sdata2:0x8057DAB8; // type:object size:0x4 scope:local align:4 data:float +@12238 = .sdata2:0x8057DAC0; // type:object size:0x8 scope:local align:8 data:double +@12706 = .sdata2:0x8057DAC8; // type:object size:0x4 scope:local align:4 data:float lbl_8057DAD0 = .sdata2:0x8057DAD0; // type:object size:0x4 align:4 data:float lbl_8057DAD4 = .sdata2:0x8057DAD4; // type:object size:0x4 align:4 data:float lbl_8057DAD8 = .sdata2:0x8057DAD8; // type:object size:0x4 align:4 data:float diff --git a/configure.py b/configure.py index 4193fda8..9a240a9c 100644 --- a/configure.py +++ b/configure.py @@ -765,7 +765,7 @@ config.libs = [ Object(Matching, "d/snd/d_snd_bgm_harp_data.cpp"), Object(Matching, "d/snd/d_snd_bgm_mml_parser_base.cpp"), Object(Matching, "d/snd/d_snd_bgm_mml_parsers.cpp"), - Object(NonMatching, "d/snd/d_snd_small_effect_mgr.cpp"), + Object(Matching, "d/snd/d_snd_small_effect_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_harp_song_mgr.cpp"), Object(NonMatching, "d/snd/d_snd_harp_song_data.cpp"), Object(Matching, "d/snd/d_snd_anim_sound.cpp"), diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index da94dfd1..9b90a233 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -219,12 +219,18 @@ private: void initialize(); void createFileManager(); +public: virtual nw4r::snd::SoundStartable::StartResult startSound(nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo); virtual nw4r::snd::SoundStartable::StartResult startSound( nw4r::snd::SoundHandle *pHandle, const char *soundLabel, const nw4r::snd::SoundStartable::StartInfo *pStartInfo ); + nw4r::snd::SoundStartable::StartResult startDemoSound( + nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo + ); + +private: /* 0x028 */ nw4r::snd::MemorySoundArchive mDemoSoundArchive; /* 0x178 */ nw4r::snd::SoundArchivePlayer mDemoSoundArchivePlayer; }; diff --git a/include/d/snd/d_snd_small_effect_mgr.h b/include/d/snd/d_snd_small_effect_mgr.h index 3e55b06a..a47fc559 100644 --- a/include/d/snd/d_snd_small_effect_mgr.h +++ b/include/d/snd/d_snd_small_effect_mgr.h @@ -66,6 +66,7 @@ public: bool playMinigameMusasabiSound(s32 count); bool playSkbSound(u32 soundId); + bool playDemoSound(u32 soundId, nw4r::snd::SoundHandle *pHandle); bool playButtonPressSoundWhenAdvancingTextBoxes(f32); void resetButtonPressSound(); @@ -82,6 +83,8 @@ private: bool isPlayingSound(u32 playerIdx, u32 soundId); bool isPlayingSound(u32 soundId); + bool doSideEffects(u32 soundId); + void setBitsIfAdjacent(dSndBgmDataHarpVarSetBase_c *set, s32 count, s32 target, u32 *pMask); /** diff --git a/include/d/snd/d_snd_state_mgr.h b/include/d/snd/d_snd_state_mgr.h index cc8109d2..37f0ad57 100644 --- a/include/d/snd/d_snd_state_mgr.h +++ b/include/d/snd/d_snd_state_mgr.h @@ -34,6 +34,15 @@ public: STAGE_SILENT_GROUNDS = 0x200, }; + enum Flag0x10_e { + FLAG0x10_0x01 = 0x01, + FLAG0x10_0x02 = 0x02, + FLAG0x10_0x04 = 0x04, + FLAG0x10_0x08 = 0x08, + FLAG0x10_0x10 = 0x10, + }; + + // 0x94 enum EventFlags_e { EVENT_IN_EVENT = 0x1, EVENT_DEMO = 0x2, @@ -58,6 +67,10 @@ public: static bool isInStage(const char *stageName); + bool getField_0x064() const { + return field_0x064; + } + s32 getField_0x14() const { return field_0x014; } @@ -307,7 +320,7 @@ private: /* 0x058 */ s32 mLayer; /* 0x05C */ s32 mRoomId; /* 0x060 */ UNKWORD field_0x060; - /* 0x064 */ u8 field_0x064; + /* 0x064 */ bool field_0x064; /* 0x065 */ bool field_0x065; /* 0x066 */ bool mHasChangedTgSndAreaFlags; /* 0x067 */ bool mHasChangedTgSndAreaMgFlags; diff --git a/src/d/snd/d_snd_small_effect_mgr.cpp b/src/d/snd/d_snd_small_effect_mgr.cpp index 46a9ffc5..b970a325 100644 --- a/src/d/snd/d_snd_small_effect_mgr.cpp +++ b/src/d/snd/d_snd_small_effect_mgr.cpp @@ -1,6 +1,7 @@ #include "d/snd/d_snd_small_effect_mgr.h" #include "common.h" +#include "d/snd/d_snd_area_sound_effect_mgr.h" #include "d/snd/d_snd_bgm_harp_data.h" #include "d/snd/d_snd_bgm_mgr.h" #include "d/snd/d_snd_bgm_sound.h" @@ -109,13 +110,64 @@ void dSndSmallEffectMgr_c::stopAllSoundExceptEffectOrLink(s32 fadeFrames) { } bool dSndSmallEffectMgr_c::playSoundInternalChecked(u32 soundId, nw4r::snd::SoundHandle *pHandle) { - // TODO - return false; + if (dSndStateMgr_c::GetInstance()->getField_0x064()) { + return false; + } + + if (field_0x10 > 0) { + return false; + } + + if (dSndStateMgr_c::GetInstance()->checkFlag0x10(dSndStateMgr_c::FLAG0x10_0x08)) { + return false; + } + return playSoundInternal(soundId, pHandle); } bool dSndSmallEffectMgr_c::playSoundInternal(u32 soundId, nw4r::snd::SoundHandle *pHandle) { - // TODO - return false; + u32 userParam = dSndPlayerMgr_c::GetInstance()->getSomeUserParam(soundId); + if (userParam & 2) { + for (u32 i = dSndPlayerMgr_c::PLAYER_SMALL_IMPORTANT; i <= dSndPlayerMgr_c::PLAYER_EVENT; i++) { + if (isPlayingSound(i, soundId)) { + return false; + } + } + } else if (userParam & 1) { + stopSounds(soundId, 2); + } + + if (userParam & 0x80000000) { + return false; + } + + nw4r::snd::SoundHandle tmpHandle; + if (pHandle == nullptr) { + pHandle = &tmpHandle; + } + + nw4r::snd::SoundStartable::StartResult res = dSndPlayerMgr_c::GetInstance()->startSound(pHandle, soundId, nullptr); + if (res == nw4r::snd::SoundStartable::START_SUCCESS) { + if (userParam & 8) { + if (EGG::AudioRmtSpeakerMgr::getWpadVolume() != 0) { + pHandle->SetOutputLineFlag(nw4r::snd::OUTPUT_LINE_REMOTE_1); + } + } else if (userParam & 4) { + pHandle->SetOutputLineFlag(nw4r::snd::OUTPUT_LINE_MAIN | nw4r::snd::OUTPUT_LINE_REMOTE_1); + } + + if (userParam & 0x10 && EGG::AudioRmtSpeakerMgr::getWpadVolume() != 0) { + u32 rcVariant = dSndPlayerMgr_c::GetInstance()->getRemoConSoundVariant(soundId); + if (rcVariant != -1) { + nw4r::snd::SoundHandle rcHandle; + dSndMgr_c::GetInstance()->getPlayer().StartSound(&rcHandle, rcVariant); + if (EGG::AudioRmtSpeakerMgr::getWpadVolume() != 0) { + rcHandle.SetOutputLineFlag(nw4r::snd::OUTPUT_LINE_REMOTE_1); + } + } + } + } + + return res == nw4r::snd::SoundStartable::START_SUCCESS; } bool dSndSmallEffectMgr_c::playSound(u32 soundId) { @@ -228,8 +280,41 @@ bool dSndSmallEffectMgr_c::playSoundWithPan(u32 soundId, f32 pan) { return ok; } +bool dSndSmallEffectMgr_c::doSideEffects(u32 soundId) { + if (soundId == SE_S_FS2_SELECT_START || soundId == SE_S_NE_SELECT_OK) { + dSndBgmMgr_c::GetInstance()->stopAllBgm(15); + dSndAreaSoundEffectMgr_c::GetInstance()->stopSounds(15); + } + + u32 userParam = dSndPlayerMgr_c::GetInstance()->getSomeUserParam(soundId); + if ((userParam & 0x80) && dSndStateMgr_c::GetInstance()->isInEvent()) { + return false; + } + + if (userParam & 2) { + for (u32 i = dSndPlayerMgr_c::PLAYER_SMALL_IMPORTANT; i <= dSndPlayerMgr_c::PLAYER_SMALL_NORMAL; i++) { + if (isPlayingSound(i, soundId)) { + return false; + } + } + } else if (userParam & 1) { + stopSounds(soundId, 2); + } + return true; +} + bool dSndSmallEffectMgr_c::playSoundInternal(u32 soundId) { - // TODO + u32 userParam = dSndPlayerMgr_c::GetInstance()->getSomeUserParam(soundId); + + // Why is this flag weird + if ((userParam >> 31) != 0) { + return false; + } + + // Bunch of code duplication between doSideEffects and playSoundInternal + if (doSideEffects(soundId)) { + return playSoundInternal(soundId, &mNormalSound); + } return false; } @@ -491,6 +576,14 @@ bool dSndSmallEffectMgr_c::playSkbSound(u32 soundId) { return playSound(soundId); } +bool dSndSmallEffectMgr_c::playDemoSound(u32 soundId, nw4r::snd::SoundHandle *pHandle) { + nw4r::snd::SoundHandle tmpHandle; + + return dSndPlayerMgr_c::GetInstance()->startDemoSound( + pHandle == nullptr ? &tmpHandle : pHandle, soundId, nullptr + ) == nw4r::snd::SoundStartable::START_SUCCESS; +} + void dSndSmallEffectMgr_c::stopSounds(u32 playerIdx, u32 soundId, s32 fadeFrames) { SoundStopper stopper(soundId, fadeFrames); dSndControlPlayerMgr_c::GetInstance()->getPlayer1(playerIdx)->ForEachSound(stopper, false); @@ -661,7 +754,6 @@ bool dSndSmallEffectMgr_c::playBattleHitSound(BattleHitSound_e type, dSoundSourc // One bit set, get the value (using a slightly convoluted method // due to inline complexity) without rejecting it when it equals // the previously picked value - // TODO - unnecessary reload of count here. varIdx = set->getRandomIdxWithBitSet(); field_0x40 = set->getVal(varIdx); } else { @@ -733,9 +825,7 @@ bool dSndSmallEffectMgr_c::playBattleHitSound(BattleHitSound_e type, dSoundSourc return ok; } -void dSndSmallEffectMgr_c::setBitsIfAdjacent( - dSndBgmDataHarpVarSetBase_c *set, s32 count, s32 target, u32 *pMask -) { +void dSndSmallEffectMgr_c::setBitsIfAdjacent(dSndBgmDataHarpVarSetBase_c *set, s32 count, s32 target, u32 *pMask) { for (int i = 0; i < count; i++) { s32 val = set->getVal(i); if (val == target + 1 || val == target - 1) { diff --git a/src/d/snd/d_snd_state_mgr.cpp b/src/d/snd/d_snd_state_mgr.cpp index 6342cab2..90eaaa6e 100644 --- a/src/d/snd/d_snd_state_mgr.cpp +++ b/src/d/snd/d_snd_state_mgr.cpp @@ -42,7 +42,7 @@ dSndStateMgr_c::dSndStateMgr_c() mLayer(0), mRoomId(-1), field_0x060(0), - field_0x064(0), + field_0x064(false), field_0x065(false), mHasChangedTgSndAreaFlags(false), mHasChangedTgSndAreaMgFlags(false), @@ -110,8 +110,8 @@ void dSndStateMgr_c::onStageOrLayerUpdate() { bool unk_0x065 = field_0x065; - onFlag0x10(0x2); - field_0x064 = 0; + onFlag0x10(FLAG0x10_0x02); + field_0x064 = false; if (!streq(mStageName, dScGame_c::currentSpawnInfo.getStageName())) { mNeedsGroupsReload = true; @@ -248,7 +248,7 @@ void dSndStateMgr_c::onRestartScene(s32 fadeFrames) { dSndAreaSoundEffectMgr_c::GetInstance()->stopSounds(fadeFrames); } else { onGotoStage(fadeFrames); - onFlag0x10(0x01); + onFlag0x10(FLAG0x10_0x01); return; } } @@ -256,10 +256,10 @@ void dSndStateMgr_c::onRestartScene(s32 fadeFrames) { dSndSmallEffectMgr_c::GetInstance()->stopAllSoundExceptEvent(fadeFrames); dSndBgmMgr_c::GetInstance()->prepareBgm(); dSndHarpSongMgr_c::GetInstance()->deactivate(); - onFlag0x10(0x01); + onFlag0x10(FLAG0x10_0x01); dSndBgmMgr_c::GetInstance()->setField_0x306(1); - offFlag0x10(0x4); - offFlag0x10(0x10); + offFlag0x10(FLAG0x10_0x04); + offFlag0x10(FLAG0x10_0x10); } void dSndStateMgr_c::loadStageSound() { @@ -488,14 +488,14 @@ void dSndStateMgr_c::setEvent(const char *eventName) { dSndPlayerMgr_c::GetInstance()->leaveCaution(); } - if (field_0x064 == 0) { + if (!field_0x064) { if (streq(mEventName, "DefaultSkip")) { onSkipEvent(); mPrevEventName = mEventName; return; } - if (!checkFlag0x18(0x20) || !checkFlag0x10(0x04)) { + if (!checkFlag0x18(0x20) || !checkFlag0x10(FLAG0x10_0x04)) { SizedString<64> prevEvent = mEventName; if (isInEvent()) { field_0x23C = 1; @@ -523,7 +523,7 @@ void dSndStateMgr_c::setEvent(const char *eventName) { mpStbEventName = nullptr; } - if (!checkFlag0x10(0x04)) { + if (!checkFlag0x10(FLAG0x10_0x04)) { if (mpUnkCallback != nullptr) { mpUnkCallback(); } @@ -531,11 +531,11 @@ void dSndStateMgr_c::setEvent(const char *eventName) { dSndBgmMgr_c::GetInstance()->setField_0x306(1); dSndBgmMgr_c::GetInstance()->prepareBgm(); onEventFlag(EVENT_0x04); - onFlag0x10(0x04); + onFlag0x10(FLAG0x10_0x04); dSndControlPlayerMgr_c::GetInstance()->unmuteScenePlayers(30); } bool b2 = checkEventFlag(EVENT_0x800) && dSndBgmMgr_c::GetInstance()->isPlayingBgmSound(); - if (checkEventFlag(EVENT_0x800) && field_0x064 == 0) { + if (checkEventFlag(EVENT_0x800) && !field_0x064) { // TODO - constness or direct access offEventFlag(0x800); } @@ -846,8 +846,8 @@ void dSndStateMgr_c::onMsgWaitEnd() { } void dSndStateMgr_c::onLinkDie() { - if (!checkFlag0x10(0x8)) { - onFlag0x10(0x8); + if (!checkFlag0x10(FLAG0x10_0x08)) { + onFlag0x10(FLAG0x10_0x08); dSndBgmMgr_c::GetInstance()->stopAllBgm(15); dSndSmallEffectMgr_c::GetInstance()->stopAllSoundExceptEffectOrLink(15); if (field_0x065 == 0) { @@ -861,7 +861,7 @@ void dSndStateMgr_c::setStbEventName(const char *eventName) { } void dSndStateMgr_c::calcRoomId() { - if (checkFlag0x10(4)) { + if (checkFlag0x10(FLAG0x10_0x04)) { if (field_0x060 > 0) { field_0x060--; } else { @@ -871,7 +871,7 @@ void dSndStateMgr_c::calcRoomId() { s32 newRoom = dSndSourceMgr_c::GetInstance()->getPlayerSourceRoomId(); if (mRoomId != newRoom) { setRoomId(newRoom); - } else if (newRoom != -1 && !checkFlag0x10(0x10)) { + } else if (newRoom != -1 && !checkFlag0x10(FLAG0x10_0x10)) { setRoomId(newRoom); } }