diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 79f7fd9e..51606d7b 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -3063,6 +3063,8 @@ nw4r/snd/snd_SoundSystem.cpp: nw4r/snd/snd_SoundThread.cpp: .text start:0x8047C710 end:0x8047CD10 align:16 + .sbss start:0x805766C0 end:0x805766C8 + .bss start:0x8066F660 end:0x8066FA20 nw4r/snd/snd_StrmChannel.cpp: .text start:0x8047CD10 end:0x8047CF50 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index bfde946f..8265b693 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -25629,7 +25629,7 @@ IsInitializedSoundSystem__Q34nw4r3snd11SoundSystemFv = .text:0x8047C630; // type WaitForResetReady__Q34nw4r3snd11SoundSystemFv = .text:0x8047C640; // type:function size:0x74 __sinit_\snd_SoundSystem_cpp = .text:0x8047C6C0; // type:function size:0x48 scope:local GetInstance__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C710; // type:function size:0xB8 -__dt__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C7D0; // type:function size:0x70 +__dt__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C7D0; // type:function size:0x70 scope:weak Create__Q44nw4r3snd6detail11SoundThreadFlPvUl = .text:0x8047C840; // type:function size:0x12C AxCallbackFunc__Q44nw4r3snd6detail11SoundThreadFv = .text:0x8047C970; // type:function size:0x10C SoundThreadFunc__Q44nw4r3snd6detail11SoundThreadFPv = .text:0x8047CA80; // type:function size:0xB8 @@ -42435,7 +42435,7 @@ lbl_805766A8 = .sbss:0x805766A8; // type:object size:0x8 data:4byte lbl_805766B0 = .sbss:0x805766B0; // type:object size:0x8 data:byte isSoundSystemInit = .sbss:0x805766B8; // type:object size:0x1 data:byte lbl_805766BC = .sbss:0x805766BC; // type:object size:0x4 data:4byte -lbl_805766C0 = .sbss:0x805766C0; // type:object size:0x8 data:byte +@GUARD@GetInstance__Q44nw4r3snd6detail11SoundThreadFv@instance = .sbss:0x805766C0; // type:object size:0x1 scope:weak data:byte lbl_805766C8 = .sbss:0x805766C8; // type:object size:0x8 data:byte lbl_805766D0 = .sbss:0x805766D0; // type:object size:0x8 data:4byte @GUARD@GetInstance__Q44nw4r3snd6detail11TaskManagerFv@instance = .sbss:0x805766D8; // type:object size:0x1 scope:weak data:byte @@ -51947,9 +51947,9 @@ lbl_80659730 = .bss:0x80659730; // type:object size:0x610 data:4byte lbl_80659D40 = .bss:0x80659D40; // type:object size:0x10 lbl_80659D50 = .bss:0x80659D50; // type:object size:0x330 lbl_8065A080 = .bss:0x8065A080; // type:object size:0x155E0 -lbl_8066F660 = .bss:0x8066F660; // type:object size:0x10 -lbl_8066F670 = .bss:0x8066F670; // type:object size:0x3B0 -lbl_8066FA20 = .bss:0x8066FA20; // type:object size:0x4000 +@1941 = .bss:0x8066F660; // type:object size:0xC scope:local +@LOCAL@GetInstance__Q44nw4r3snd6detail11SoundThreadFv@instance = .bss:0x8066F670; // type:object size:0x398 scope:weak +lbl_8066FA20 = .bss:0x8066FA20; // type:object size:0x4000 align:32 lbl_80673A20 = .bss:0x80673A20; // type:object size:0x18 @886 = .bss:0x80673A38; // type:object size:0xC scope:local @LOCAL@GetInstance__Q44nw4r3snd6detail11TaskManagerFv@instance = .bss:0x80673A44; // type:object size:0x3C scope:weak diff --git a/configure.py b/configure.py index 445359da..aecb61a3 100644 --- a/configure.py +++ b/configure.py @@ -1067,7 +1067,7 @@ config.libs = [ Object(NonMatching, "nw4r/snd/snd_SoundPlayer.cpp"), Object(NonMatching, "nw4r/snd/snd_SoundStartable.cpp"), Object(NonMatching, "nw4r/snd/snd_SoundSystem.cpp"), - Object(NonMatching, "nw4r/snd/snd_SoundThread.cpp"), + Object(Matching, "nw4r/snd/snd_SoundThread.cpp"), Object(Matching, "nw4r/snd/snd_StrmChannel.cpp"), Object(Matching, "nw4r/snd/snd_StrmFile.cpp"), Object(NonMatching, "nw4r/snd/snd_StrmPlayer.cpp"), diff --git a/include/nw4r/snd/snd_SoundThread.h b/include/nw4r/snd/snd_SoundThread.h index 42d4a10f..7d250496 100644 --- a/include/nw4r/snd/snd_SoundThread.h +++ b/include/nw4r/snd/snd_SoundThread.h @@ -101,6 +101,7 @@ namespace nw4r { namespace snd { namespace detail static void *SoundThreadFunc(void *arg); void SoundThreadProc(); + void FrameProcess(); // static members private: @@ -121,6 +122,7 @@ namespace nw4r { namespace snd { namespace detail PlayerCallback::LinkList mPlayerCallbackList; // size 0x00c, offset 0x384 u32 mProcessTick; // size 0x004, offset 0x390 bool mCreateFlag; // size 0x001, offset 0x394 + bool field_0x395; // size 0x001, offset 0x395 /* 3 bytes padding */ }; // size 0x398 }}} // namespace nw4r::snd::detail diff --git a/src/nw4r/snd/snd_SoundThread.cpp b/src/nw4r/snd/snd_SoundThread.cpp index 2a8ca309..153d3492 100644 --- a/src/nw4r/snd/snd_SoundThread.cpp +++ b/src/nw4r/snd/snd_SoundThread.cpp @@ -35,7 +35,8 @@ namespace nw4r { namespace snd { namespace detail { SoundThread::SoundThread() : mStackEnd (nullptr), - mCreateFlag (false) + mCreateFlag (false), + field_0x395 (false) { OSInitMessageQueue(&mMsgQueue, mMsgBuffer, THREAD_MESSAGE_BUFSIZE); OSInitThreadQueue(&mThreadQueue); @@ -96,8 +97,10 @@ void SoundThread::AxCallbackFunc() void SoundThread::AxCallbackProc() { - BOOL result ATTR_UNUSED = - OSSendMessageAny(&mMsgQueue, MESSAGE_AX_CALLBACK, OS_MESSAGE_NO_FLAGS); + if (!field_0x395) { + BOOL result ATTR_UNUSED = + OSSendMessageAny(&mMsgQueue, MESSAGE_AX_CALLBACK, OS_MESSAGE_NO_FLAGS); + } NW4R_RANGE_FOR_NO_AUTO_INC(itr, mPlayerCallbackList) { @@ -123,6 +126,7 @@ void *SoundThread::SoundThreadFunc(void *arg) return nullptr; } +#ifdef DEBUG /* SoundThread::RegisterSoundFrameCallback * ([R89JEL]:/bin/RVL/Debug/mainD.MAP:14509) */ @@ -134,6 +138,7 @@ DECOMP_FORCE_CLASS_METHOD(SoundThread::SoundFrameCallback::LinkList, */ DECOMP_FORCE_CLASS_METHOD(SoundThread::SoundFrameCallback::LinkList, Erase(nullptr)); +#endif void SoundThread::RegisterPlayerCallback(PlayerCallback *callback) { @@ -159,42 +164,7 @@ void SoundThread::SoundThreadProc() if (reinterpret_cast(message) == MESSAGE_AX_CALLBACK) { - ut::detail::AutoLock lock(mMutex); - - NW4R_RANGE_FOR_NO_AUTO_INC(itr, mSoundFrameCallbackList) - { - decltype(itr) curItr = itr++; - - curItr->at_0x0c(); - } - - OSTick tick = OSGetTick(); - - { - // Sound frame - AxVoiceManager::GetInstance().FreeAllReservedAxVoice(); - AxManager::GetInstance().Update(); - - NW4R_RANGE_FOR_NO_AUTO_INC(itr, mPlayerCallbackList) - { - decltype(itr) curItr = itr++; - - curItr->OnUpdateFrameSoundThread(); - } - - ChannelManager::GetInstance().UpdateAllChannel(); - (void)Util::CalcRandom(); // ? - VoiceManager::GetInstance().UpdateAllVoices(); - } - - mProcessTick = OSGetTick() - tick; - - NW4R_RANGE_FOR_NO_AUTO_INC(itr, mSoundFrameCallbackList) - { - decltype(itr) curItr = itr++; - - curItr->at_0x10(); - } + FrameProcess(); } else if (reinterpret_cast(message) == MESSAGE_SHUTDOWN) { @@ -212,4 +182,44 @@ void SoundThread::SoundThreadProc() } } +void SoundThread::FrameProcess() +{ + ut::detail::AutoLock lock(mMutex); + + NW4R_RANGE_FOR_NO_AUTO_INC(itr, mSoundFrameCallbackList) + { + decltype(itr) curItr = itr++; + + curItr->at_0x0c(); + } + + OSTick tick = OSGetTick(); + + { + // Sound frame + AxVoiceManager::GetInstance().FreeAllReservedAxVoice(); + AxManager::GetInstance().Update(); + + NW4R_RANGE_FOR_NO_AUTO_INC(itr, mPlayerCallbackList) + { + decltype(itr) curItr = itr++; + + curItr->OnUpdateFrameSoundThread(); + } + + ChannelManager::GetInstance().UpdateAllChannel(); + (void)Util::CalcRandom(); // ? + VoiceManager::GetInstance().UpdateAllVoices(); + } + + mProcessTick = OSGetTick() - tick; + + NW4R_RANGE_FOR_NO_AUTO_INC(itr, mSoundFrameCallbackList) + { + decltype(itr) curItr = itr++; + + curItr->at_0x10(); + } +} + }}} // namespace nw4r::snd::detail