From 8da7d7cf25f225b7c8d22b299e2c9fac23fd2f3a Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Wed, 23 Jun 2021 00:34:02 +0200 Subject: ksys/snd: Add SoundResource --- src/KingSystem/Sound/CMakeLists.txt | 1 + src/KingSystem/Sound/sndResource.cpp | 26 ++++++++++++++++++++++++++ src/KingSystem/Sound/sndResource.h | 8 ++++---- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/KingSystem/Sound/sndResource.cpp (limited to 'src') diff --git a/src/KingSystem/Sound/CMakeLists.txt b/src/KingSystem/Sound/CMakeLists.txt index 7fdd69c1..b10f005e 100644 --- a/src/KingSystem/Sound/CMakeLists.txt +++ b/src/KingSystem/Sound/CMakeLists.txt @@ -1,5 +1,6 @@ target_sources(uking PRIVATE sndInfoData.cpp sndInfoData.h + sndResource.cpp sndResource.h ) diff --git a/src/KingSystem/Sound/sndResource.cpp b/src/KingSystem/Sound/sndResource.cpp new file mode 100644 index 00000000..df3f6b7d --- /dev/null +++ b/src/KingSystem/Sound/sndResource.cpp @@ -0,0 +1,26 @@ +#include "KingSystem/Sound/sndResource.h" +#include +#include +#include + +namespace ksys::snd { + +SEAD_SINGLETON_DISPOSER_IMPL(SoundResource) + +SoundResource::~SoundResource() { + mSoundResourceHeap->destroy(); + _30->destroy(); + if (mSoundDebugHeap) + mSoundDebugHeap->destroy(); +} + +void SoundResource::init(sead::Heap* heap, sead::Heap* debug_heap, bool extra_large) { + mSoundResourceHeap = + sead::FrameHeap::create(extra_large ? 0x9583000 : 0x6383000, "SoundResource", heap, 0x1000, + sead::FrameHeap::cHeapDirection_Forward, false); + if (debug_heap) + mSoundDebugHeap = sead::ExpHeap::create(0x1E00000u, "SoundDebug", debug_heap, 0x1000, + sead::ExpHeap::cHeapDirection_Forward, false); +} + +} // namespace ksys::snd \ No newline at end of file diff --git a/src/KingSystem/Sound/sndResource.h b/src/KingSystem/Sound/sndResource.h index 31a502fa..62d00efd 100644 --- a/src/KingSystem/Sound/sndResource.h +++ b/src/KingSystem/Sound/sndResource.h @@ -5,19 +5,19 @@ namespace ksys::snd { -// FIXME: incomplete class SoundResource { SEAD_SINGLETON_DISPOSER(SoundResource) SoundResource() = default; virtual ~SoundResource(); public: + void init(sead::Heap* heap, sead::Heap* debug_heap, bool extra_large); sead::Heap* getSoundDebugHeap() const { return mSoundDebugHeap; } private: - sead::Heap* mSoundResourceHeap; - void* _30; - sead::Heap* mSoundDebugHeap; + sead::Heap* mSoundResourceHeap = nullptr; + sead::Heap* _30 = nullptr; // TODO find out what this does + sead::Heap* mSoundDebugHeap = nullptr; }; KSYS_CHECK_SIZE_NX150(SoundResource, 0x40); -- cgit v1.2.3