diff options
| author | Caroline Madsen <69010899+randomsalience@users.noreply.github.com> | 2025-04-09 16:45:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-09 13:45:30 -0700 |
| commit | c6f76e7240dde8bbcf40a88d6d88cf87cab616b4 (patch) | |
| tree | bf9afbb1c32e66f45bdba30f61a9e4f0d92f804a /include/JSystem/JAudio2 | |
| parent | 6672817e41064e04951ec28d51070b66fc8377ac (diff) | |
Various JSystem work (#2383)
* JKernel and JStudio cleanup
* JMessage cleanup
* JAudio cleanup
* JASBNKParser work
* functionvalue work
* fvb work
* J2D and J3D cleanup
* steal from tww
* J2DPictureEx mostly done
* fix build
Diffstat (limited to 'include/JSystem/JAudio2')
| -rw-r--r-- | include/JSystem/JAudio2/JASBNKParser.h | 82 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JASHeapCtrl.h | 21 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JASTrack.h | 1 |
3 files changed, 82 insertions, 22 deletions
diff --git a/include/JSystem/JAudio2/JASBNKParser.h b/include/JSystem/JAudio2/JASBNKParser.h index 9c2d23e955..29a2d9140e 100644 --- a/include/JSystem/JAudio2/JASBNKParser.h +++ b/include/JSystem/JAudio2/JASBNKParser.h @@ -2,6 +2,7 @@ #define JASBNKPARSER_H #include "JSystem/JAudio2/JASOscillator.h" +#include "JSystem/JSupport/JSupport.h" class JASBank; class JASBasicBank; @@ -53,24 +54,85 @@ namespace JASBNKParser { /* 0xC */ u32 mOffsets[0]; }; - /* 80299600 */ static TChunk* findChunk(void const*, u32); - /* 8029963C */ static JASBasicBank* createBasicBank(void const*, JKRHeap*); + /* 80299600 */ TChunk* findChunk(void const*, u32); + /* 8029963C */ JASBasicBank* createBasicBank(void const*, JKRHeap*); }; namespace Ver0 { - struct THeader {}; + template<typename T> + struct TOffset { + /* 0x0 */ u32 offset; + T* ptr(void const* stream) const { return JSUConvertOffsetToPtr<T>(stream, offset); } + }; + + struct TOsc { + /* 0x00 */ u8 mTarget; + /* 0x04 */ f32 field_0x4; + /* 0x08 */ TOffset<JASOscillator::Point> mPointOffset; + /* 0x0C */ TOffset<JASOscillator::Point> field_0xc; + /* 0x10 */ f32 mScale; + /* 0x14 */ f32 field_0x14; + }; + + struct TVmap { + /* 0x00 */ u8 field_0x0[4]; + /* 0x04 */ u32 field_0x4; + /* 0x08 */ f32 field_0x8; + /* 0x0C */ f32 field_0xc; + }; + + struct TKeymap { + /* 0x00 */ u8 mHighKey; + /* 0x01 */ u8 field_0x1[7]; + /* 0x08 */ TOffset<TVmap> mVmapOffset; + }; + + struct TInst { + /* 0x00 */ u8 field_0x0[8]; + /* 0x08 */ f32 mVolume; + /* 0x0C */ f32 mPitch; + /* 0x10 */ TOffset<TOsc> mOscOffset[2]; + /* 0x18 */ u8 field_0x18[0x10]; + /* 0x28 */ u32 mKeyRegionCount; + /* 0x2C */ TOffset<TKeymap> mKeymapOffset[0]; + }; - struct TOsc {}; + struct TPmap { + /* 0x00 */ f32 mVolume; + /* 0x04 */ f32 mPitch; + /* 0x08 */ u8 field_0x8[0xc]; + /* 0x14 */ TOffset<TVmap> mVmapOffset; + }; + + struct TPerc { + /* 0x000 */ u32 mMagic; + /* 0x000 */ u8 field_0x0[0x84]; + /* 0x088 */ TOffset<TPmap> mPmapOffset[0x80]; + /* 0x288 */ s8 mPan[0x80]; + /* 0x308 */ u16 mRelease[0x80]; + }; + + struct TOffsetData { + /* 0x000 */ u8 field_0x20[4]; + /* 0x004 */ TOffset<TInst> mInstOffset[0x80]; + /* 0x204 */ u8 field_0x204[0x190]; + /* 0x394 */ TOffset<TPerc> mPercOffset[12]; + }; + + struct THeader { + /* 0x00 */ u8 field_0x0[0x20]; + /* 0x20 */ TOffsetData mOffsets; + }; - /* 80299A3C */ static JASBasicBank* createBasicBank(void const*, JKRHeap*); - /* 80299E68 */ static void findOscPtr(JASBasicBank*, THeader const*, TOsc const*); - /* 80299F8C */ static void getOscTableEndPtr(JASOscillator::Point const*); + /* 80299A3C */ JASBasicBank* createBasicBank(void const*, JKRHeap*); + /* 80299E68 */ JASOscillator::Data* findOscPtr(JASBasicBank*, THeader const*, TOsc const*); + /* 80299F8C */ JASOscillator::Point const* getOscTableEndPtr(JASOscillator::Point const*); }; - /* 80299538 */ static JASBank* createBank(void const*, JKRHeap*); - /* 80299558 */ static JASBasicBank* createBasicBank(void const*, JKRHeap*); + /* 80299538 */ JASBank* createBank(void const*, JKRHeap*); + /* 80299558 */ JASBasicBank* createBasicBank(void const*, JKRHeap*); - inline static u32 getBankNumber(const void* param_0) { return ((u32*)param_0)[2]; } + inline u32 getBankNumber(const void* param_0) { return ((u32*)param_0)[2]; } extern u32 sUsedHeapSize; }; diff --git a/include/JSystem/JAudio2/JASHeapCtrl.h b/include/JSystem/JAudio2/JASHeapCtrl.h index 18a5a627d8..e0f4be1822 100644 --- a/include/JSystem/JAudio2/JASHeapCtrl.h +++ b/include/JSystem/JAudio2/JASHeapCtrl.h @@ -68,13 +68,11 @@ namespace JASThreadingModel { }; }; - + template <typename A0> struct ObjectLevelLockable { - // Should be templated on the chunk memory but couldn't initialize it inside the class itself - //template <typename A0> struct Lock { - Lock(OSMutex* mutex) { - mMutex = mutex; + Lock(A0 const& mutex) { + mMutex = (A0*)&mutex; OSLockMutex(mMutex); } @@ -82,7 +80,7 @@ namespace JASThreadingModel { OSUnlockMutex(mMutex); } - OSMutex* mMutex; + A0* mMutex; }; }; }; @@ -105,8 +103,8 @@ namespace JASKernel { JKRHeap* getSystemHeap(); }; * @ingroup jsystem-jaudio * */ -template<u32 ChunkSize, typename T> -class JASMemChunkPool { +template<u32 ChunkSize, template<typename> class T> +class JASMemChunkPool : public OSMutex { struct MemoryChunk { MemoryChunk(MemoryChunk* nextChunk) { mNextChunk = nextChunk; @@ -156,7 +154,7 @@ class JASMemChunkPool { }; public: JASMemChunkPool() { - OSInitMutex(&mMutex); + OSInitMutex(this); field_0x18 = NULL; createNewChunk(); } @@ -185,7 +183,7 @@ public: } void* alloc(u32 size) { - typename T::Lock lock(&mMutex); + typename T<JASMemChunkPool<ChunkSize, T> >::Lock lock(*this); if (field_0x18->getFreeSize() < size) { if (ChunkSize < size) { return NULL; @@ -198,7 +196,7 @@ public: } void free(void* ptr) { - typename T::Lock lock(&mMutex); + typename T<JASMemChunkPool<ChunkSize, T> >::Lock lock(*this); MemoryChunk* chunk = field_0x18; MemoryChunk* prevChunk = NULL; while (chunk != NULL) { @@ -216,7 +214,6 @@ public: } } - /* 0x00 */ OSMutex mMutex; /* 0x18 */ MemoryChunk* field_0x18; }; diff --git a/include/JSystem/JAudio2/JASTrack.h b/include/JSystem/JAudio2/JASTrack.h index d6b8df2660..85e729cb72 100644 --- a/include/JSystem/JAudio2/JASTrack.h +++ b/include/JSystem/JAudio2/JASTrack.h @@ -7,6 +7,7 @@ #include "JSystem/JAudio2/JASSeqCtrl.h" #include "JSystem/JAudio2/JASTrackPort.h" #include "JSystem/JGadget/linklist.h" +#include "global.h" struct JASSoundParams; |
