From b4a79946bf374e341f65f373cc430c73bad5f441 Mon Sep 17 00:00:00 2001 From: robojumper Date: Mon, 26 May 2025 23:50:15 +0200 Subject: [PATCH] snd_SoundArchivePlayer not OK (instruction scheduling) --- config/SOUE01/splits.txt | 2 ++ config/SOUE01/symbols.txt | 4 +-- include/nw4r/snd/snd_SoundArchivePlayer.h | 8 ++++-- src/nw4r/snd/snd_SoundArchivePlayer.cpp | 34 +++++++++++++++++++++-- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 2cdd573e..89dbf801 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -3060,6 +3060,8 @@ nw4r/snd/snd_SoundArchiveLoader.cpp: nw4r/snd/snd_SoundArchivePlayer.cpp: .text start:0x80478560 end:0x8047B018 align:16 + .data start:0x8056E1B0 end:0x8056E200 + .sdata2 start:0x8057F138 end:0x8057F148 nw4r/snd/snd_SoundHandle.cpp: .text start:0x8047B020 end:0x8047B110 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 9e1323e9..7dc53880 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -21804,8 +21804,8 @@ fn_803A18B0 = .text:0x803A18B0; // type:function size:0xF0 fn_803A19A0 = .text:0x803A19A0; // type:function size:0x2B0 fn_803A1C50 = .text:0x803A1C50; // type:function size:0xC fn_803A1C60 = .text:0x803A1C60; // type:function size:0xC -fn_803A1C70 = .text:0x803A1C70; // type:function size:0xC -fn_803A1C80 = .text:0x803A1C80; // type:function size:0x14 +AXFXSetHooks = .text:0x803A1C70; // type:function size:0xC +AXFXGetHooks = .text:0x803A1C80; // type:function size:0x14 PPCMfmsr = .text:0x803A1CA0; // type:function size:0x8 scope:global PPCMtmsr = .text:0x803A1CB0; // type:function size:0x8 scope:global PPCMfhid0 = .text:0x803A1CC0; // type:function size:0x8 scope:global diff --git a/include/nw4r/snd/snd_SoundArchivePlayer.h b/include/nw4r/snd/snd_SoundArchivePlayer.h index 34231be7..f8126d73 100644 --- a/include/nw4r/snd/snd_SoundArchivePlayer.h +++ b/include/nw4r/snd/snd_SoundArchivePlayer.h @@ -55,8 +55,8 @@ namespace nw4r { namespace snd public: // virtual function ordering // vtable SoundArchivePlayer_FileManager - virtual void const *at_0x08(int) = 0; - virtual void const *at_0x0c(int) = 0; + virtual void const *GetFileAddress(u32) = 0; + virtual void const *GetFileWaveDataAddress(u32) = 0; // members private: @@ -98,6 +98,8 @@ namespace nw4r { namespace snd { } + virtual ~SeqNoteOnCallback() {} + // virtual function ordering // vtable NoteOnCallback virtual detail::Channel *NoteOn( @@ -176,6 +178,8 @@ namespace nw4r { namespace snd return LoadGroup(static_cast(id), pAllocatable, blockSize); } + bool IsLoadedGroup(u32 groupId) const; + SoundArchive const &GetSoundArchive() const; u32 GetSoundPlayerCount() const { return mSoundPlayerCount; } SoundPlayer &GetSoundPlayer(u32 playerId); diff --git a/src/nw4r/snd/snd_SoundArchivePlayer.cpp b/src/nw4r/snd/snd_SoundArchivePlayer.cpp index 8e9019d6..93996870 100644 --- a/src/nw4r/snd/snd_SoundArchivePlayer.cpp +++ b/src/nw4r/snd/snd_SoundArchivePlayer.cpp @@ -517,16 +517,18 @@ SoundPlayer &SoundArchivePlayer::GetSoundPlayer(u32 playerId) return mSoundPlayers[playerId]; } +#if 0 /* SoundArchivePlayer::GetSoundPlayer(char const *) * ([R89JEL]:/bin/RVL/Debug/mainD.MAP:14216) */ DECOMP_FORCE(NW4RAssertPointerNonnull_String(mSoundArchive)); +#endif void const *SoundArchivePlayer::detail_GetFileAddress(u32 fileId) const { if (mFileManager) { - if (void const *addr = mFileManager->at_0x08(fileId)) + if (void const *addr = mFileManager->GetFileAddress(fileId)) return addr; } @@ -567,7 +569,7 @@ void const *SoundArchivePlayer::detail_GetFileWaveDataAddress(u32 fileId) const { if (mFileManager) { - if (void const *addr = mFileManager->at_0x0c(fileId)) + if (void const *addr = mFileManager->GetFileWaveDataAddress(fileId)) return addr; } @@ -621,9 +623,19 @@ void const *SoundArchivePlayer::GetGroupAddress(u32 groupId) const return mGroupTable->item[groupId].address; } +#if 0 // SoundArchivePlayer::SetGroupAddress ([R89JEL]:/bin/RVL/Debug/mainD.MAP:14220) DECOMP_FORCE("Failed to SoundArchivePlayer::SetGroupAddress because group " "table is not allocated.\n"); +#endif + +void SoundArchivePlayer::SetGroupAddress(u32 id, const void* pAddr) +{ + if (mGroupTable == NULL) + return; + + mGroupTable->item[id].address = pAddr; +} void const *SoundArchivePlayer::GetGroupWaveDataAddress(u32 groupId) const { @@ -643,6 +655,15 @@ void const *SoundArchivePlayer::GetGroupWaveDataAddress(u32 groupId) const return mGroupTable->item[groupId].waveDataAddress; } +void SoundArchivePlayer::SetGroupWaveDataAddress(u32 id, const void* pAddr) +{ + if (mGroupTable == NULL) + return; + + mGroupTable->item[id].waveDataAddress = pAddr; +} + +#if 0 /* SoundArchivePlayer::SetGroupWaveDataAddress * ([R89JEL]:/bin/RVL/Debug/mainD.MAP:14222) */ @@ -660,6 +681,7 @@ DECOMP_FORCE("Failed to SoundArchivePlayer::SetFileAddress because file table " DECOMP_FORCE(NW4RAssertHeaderClampedLValue_String(fileId)); DECOMP_FORCE("Failed to SoundArchivePlayer::SetFileWaveDataAddress because " "file table is not allocated.\n"); +#endif void const *SoundArchivePlayer::GetFileAddress(u32 fileId) const { @@ -1323,10 +1345,12 @@ void SoundArchivePlayer::UpdateCommonSoundParam( sound->SetPanCurve(commonInfo->panCurve); } +#if 0 /* SoundArchivePlayer::LoadGroup(u32, SoundMemoryAllocatable *, u32) * ([R89JEL]:/bin/RVL/Debug/mainD.MAP:14234) */ DECOMP_FORCE(NW4RAssertAligned_String(loadBlockSize, 32)); +#endif bool SoundArchivePlayer::LoadGroup(u32 id, SoundMemoryAllocatable* pAllocatable, u32 blockSize) { @@ -1373,6 +1397,12 @@ bool SoundArchivePlayer::LoadGroup(const char* pLabel, return LoadGroup(id, pAllocatable, blockSize); } +bool SoundArchivePlayer::IsLoadedGroup(u32 groupId) const +{ + void const *groupAddress = GetGroupAddress(groupId); + return groupAddress != NULL; +} + void SoundArchivePlayer::InvalidateData(void const *start, void const *end) { if (mFileTable)