diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 89dbf801..587515b8 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2909,6 +2909,7 @@ nw4r/snd/snd_AxVoiceManager.cpp: nw4r/snd/snd_AxfxImpl.cpp: .text start:0x80467DD0 end:0x80467FC8 align:16 + .sbss start:0x80576670 end:0x80576678 nw4r/snd/snd_Bank.cpp: .text start:0x80467FD0 end:0x80468248 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 7dc53880..b0c1735c 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -42421,8 +42421,8 @@ sBiquadFilterBpf2048__Q44nw4r3snd6detail9AxManager = .sbss:0x80576660; // type:o @GUARD@GetInstance__Q44nw4r3snd6detail9AxManagerFv@instance = .sbss:0x80576664; // type:object size:0x1 scope:weak data:byte @LOCAL@AiDmaCallbackFunc__Q44nw4r3snd6detail9AxManagerFv@finishedFlag = .sbss:0x80576665; // type:object size:0x1 scope:weak data:byte @GUARD@GetInstance__Q44nw4r3snd6detail14AxVoiceManagerFv@instance = .sbss:0x80576668; // type:object size:0x1 scope:weak data:byte -lbl_80576670 = .sbss:0x80576670; // type:object size:0x4 data:4byte -lbl_80576674 = .sbss:0x80576674; // type:object size:0x4 data:4byte +mCurrentFx__Q44nw4r3snd6detail8AxfxImpl = .sbss:0x80576670; // type:object size:0x4 data:4byte +mAllocatedSize__Q44nw4r3snd6detail8AxfxImpl = .sbss:0x80576674; // type:object size:0x4 data:4byte typeInfo__Q44nw4r3snd6detail10BasicSound = .sbss:0x80576678; // type:object size:0x8 data:4byte @GUARD@GetInstance__Q44nw4r3snd6detail14ChannelManagerFv@instance = .sbss:0x80576680; // type:object size:0x1 scope:weak data:byte @GUARD@GetInstance__Q44nw4r3snd6detail22DisposeCallbackManagerFv@instance = .sbss:0x80576688; // type:object size:0x1 scope:weak data:byte diff --git a/configure.py b/configure.py index a41a2431..cadd2c42 100644 --- a/configure.py +++ b/configure.py @@ -1016,7 +1016,7 @@ config.libs = [ Object(Matching, "nw4r/snd/snd_AxManager.cpp"), Object(NonMatching, "nw4r/snd/snd_AxVoice.cpp"), Object(Matching, "nw4r/snd/snd_AxVoiceManager.cpp"), - Object(NonMatching, "nw4r/snd/snd_AxfxImpl.cpp"), + Object(Matching, "nw4r/snd/snd_AxfxImpl.cpp"), Object(Matching, "nw4r/snd/snd_Bank.cpp"), Object(Matching, "nw4r/snd/snd_BankFile.cpp"), Object(Matching, "nw4r/snd/snd_BasicPlayer.cpp"), diff --git a/include/nw4r/snd/snd_AxfxImpl.h b/include/nw4r/snd/snd_AxfxImpl.h index 4721ddaf..06334ff7 100644 --- a/include/nw4r/snd/snd_AxfxImpl.h +++ b/include/nw4r/snd/snd_AxfxImpl.h @@ -9,13 +9,12 @@ namespace snd { namespace detail { struct AxfxImpl { - bool mIsActive; // at 0x0 MEMiHeapHead *mHeap; // at 0x4 u32 mAllocCount; // at 0x8 static const u32 HEAP_SIZE_MIN = MEM_FRM_HEAP_MIN_SIZE + 32; - AxfxImpl() : mIsActive(false), mHeap(NULL), mAllocCount(0) {} + AxfxImpl() : mHeap(NULL), mAllocCount(0) {} bool CreateHeap(void *pBuffer, u32 size); void DestroyHeap(); @@ -29,7 +28,7 @@ struct AxfxImpl { } void HookAlloc(AXFXAllocHook *pAllocHook, AXFXFreeHook *pFreeHook); - void RestoreAlloc(AXFXAllocHook allocHook, AXFXFreeHook freeHook); + u32 RestoreAlloc(AXFXAllocHook allocHook, AXFXFreeHook freeHook); static void *Alloc(u32 size); static void Free(void *pBlock); diff --git a/src/nw4r/snd/snd_AxfxImpl.cpp b/src/nw4r/snd/snd_AxfxImpl.cpp index ba4a6394..4e757cfb 100644 --- a/src/nw4r/snd/snd_AxfxImpl.cpp +++ b/src/nw4r/snd/snd_AxfxImpl.cpp @@ -10,6 +10,11 @@ AxfxImpl* AxfxImpl::mCurrentFx = NULL; u32 AxfxImpl::mAllocatedSize = 0; bool AxfxImpl::CreateHeap(void* pBuffer, u32 size) { + if (pBuffer == NULL || size == 0) + { + mHeap = NULL; + return false; + } mHeap = MEMCreateFrmHeap(pBuffer, size); return mHeap != NULL; } @@ -17,6 +22,7 @@ bool AxfxImpl::CreateHeap(void* pBuffer, u32 size) { void AxfxImpl::DestroyHeap() { if (mHeap != NULL) { MEMDestroyFrmHeap(mHeap); + mHeap = NULL; } } @@ -24,11 +30,13 @@ void AxfxImpl::HookAlloc(AXFXAllocHook* pAllocHook, AXFXFreeHook* pFreeHook) { AXFXGetHooks(pAllocHook, pFreeHook); AXFXSetHooks(Alloc, Free); mCurrentFx = this; + mAllocatedSize = 0; } -void AxfxImpl::RestoreAlloc(AXFXAllocHook allocHook, AXFXFreeHook freeHook) { +u32 AxfxImpl::RestoreAlloc(AXFXAllocHook allocHook, AXFXFreeHook freeHook) { AXFXSetHooks(allocHook, freeHook); mCurrentFx = NULL; + return mAllocatedSize; } void* AxfxImpl::Alloc(u32 size) {