diff options
| author | hatal175 <hatal175@users.noreply.github.com> | 2023-07-21 14:08:32 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-21 14:08:32 +0300 |
| commit | 912a14e57dc4fdeb192a23864fc2abc37166c0b1 (patch) | |
| tree | 14e7bac8c51bf2b72692ffb5afc3b7f2c3f68a01 /include/JSystem | |
| parent | 2e177620128983214229a2b897c4952e28854526 (diff) | |
| parent | d331fd53e3713cc6d3c4a59b9771ec10454ffad7 (diff) | |
Merge pull request #379 from Jcw87/JAISeq
JAISeq, JAISe, and others
Diffstat (limited to 'include/JSystem')
| -rw-r--r-- | include/JSystem/J2DGraph/J2DMatBlock.h | 10 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DTevs.h | 67 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAIAudible.h | 9 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISe.h | 52 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISeMgr.h | 24 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISeq.h | 51 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISeqDataMgr.h | 13 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISeqMgr.h | 8 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISound.h | 72 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISoundChild.h | 2 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAIStream.h | 3 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JASHeapCtrl.h | 115 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JASTrack.h | 63 |
13 files changed, 419 insertions, 70 deletions
diff --git a/include/JSystem/J2DGraph/J2DMatBlock.h b/include/JSystem/J2DGraph/J2DMatBlock.h index 1a036dc072..5473a3a0c1 100644 --- a/include/JSystem/J2DGraph/J2DMatBlock.h +++ b/include/JSystem/J2DGraph/J2DMatBlock.h @@ -16,6 +16,16 @@ struct ResTLUT; struct J2DGXColorS10 : public GXColorS10 { /* 802F1B90 */ J2DGXColorS10(); + + /* + J2DGXColorS10& operator=(const GXColorS10& other) { + r = other.r; + g = other.g; + b = other.b; + a = other.a; + return *this; + } + */ }; struct J2DTevSwapModeInfo; diff --git a/include/JSystem/J2DGraph/J2DTevs.h b/include/JSystem/J2DGraph/J2DTevs.h index 6a561e9557..1fdcc0c0f9 100644 --- a/include/JSystem/J2DGraph/J2DTevs.h +++ b/include/JSystem/J2DGraph/J2DTevs.h @@ -124,11 +124,31 @@ private: /* 0x0 */ J2DIndTexCoordScaleInfo mInfo; }; // Size: 0x2 +struct J2DIndTevStageInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; + /* 0x4 */ u8 field_0x4; + /* 0x5 */ u8 field_0x5; + /* 0x6 */ u8 field_0x6; + /* 0x7 */ u8 field_0x7; + /* 0x8 */ int field_0x8; +}; + +inline u32 J2DCalcIndTevStage(J2DIndTevStageInfo info) { + return (info.field_0x8 << 22) | (info.field_0x7 << 21) | (info.field_0x6 << 20) | + (info.field_0x3 << 16) | (info.field_0x5 << 11) | (info.field_0x4 << 8) | + (info.field_0x2 << 4) | (info.field_0x1 << 2) | info.field_0x0; +} + class J2DIndTevStage { public: /* 802EA044 */ void load(u8); /* 802F18A0 */ J2DIndTevStage(); + void setIndTevStageInfo(const J2DIndTevStageInfo& info) { mFlags = J2DCalcIndTevStage(info); } + private: /* 0x0 */ u32 mFlags; @@ -143,24 +163,6 @@ private: GXIndTexAlphaSel getAlphaSel() const { return (GXIndTexAlphaSel)((mFlags >> 22) & 0x03); } }; -struct J2DIndTevStageInfo { - /* 0x0 */ u8 field_0x0; - /* 0x1 */ u8 field_0x1; - /* 0x2 */ u8 field_0x2; - /* 0x3 */ u8 field_0x3; - /* 0x4 */ u8 field_0x4; - /* 0x5 */ u8 field_0x5; - /* 0x6 */ u8 field_0x6; - /* 0x7 */ u8 field_0x7; - /* 0x8 */ int field_0x8; -}; - -inline u32 J2DCalcIndTevStage(J2DIndTevStageInfo info) { - return (info.field_0x8 << 22) | (info.field_0x7 << 21) | (info.field_0x6 << 20) | - (info.field_0x3 << 16) | (info.field_0x5 << 11) | (info.field_0x4 << 8) | - (info.field_0x2 << 4) | (info.field_0x1 << 2) | info.field_0x0; -} - struct J2DTexCoordInfo { /* 0x0 */ u8 mTexGenType; /* 0x1 */ u8 mTexGenSrc; @@ -191,18 +193,26 @@ struct J2DTevOrderInfo { /* 0x0 */ u8 mTexCoord; /* 0x1 */ u8 mTexMap; /* 0x2 */ u8 mColor; + /* 0x3 */ u8 field_0x3; + + J2DTevOrderInfo& operator=(const J2DTevOrderInfo& other) { + mTexCoord = other.mTexCoord; + mTexMap = other.mTexMap; + mColor = other.mColor; + return *this; + } }; class J2DTevOrder { public: /* 802F1B70 */ J2DTevOrder(); + void setTevOrderInfo(const J2DTevOrderInfo& info) {mTevOrderInfo = info; } GXChannelID getColor() const { return (GXChannelID)mTevOrderInfo.mColor; } GXTexMapID getTexMap() const { return (GXTexMapID)mTevOrderInfo.mTexMap; } GXTexCoordID getTexCoord() const { return (GXTexCoordID)mTevOrderInfo.mTexCoord; } /* 0x0 */ J2DTevOrderInfo mTevOrderInfo; - /* 0x4 */ u8 field_0x4; }; struct J2DTevStageInfo { @@ -240,6 +250,11 @@ public: /* 802F1940 */ J2DTevStage(); /* 802F19A8 */ void setTevStageInfo(J2DTevStageInfo const&); + void setStageNo(u32 param_0) { + field_0x0 = (param_0 << 1) - 0x40; + field_0x4 = (param_0 << 1) - 0x3f; + } + void setTevSwapModeInfo(const J2DTevSwapModeInfo& swapInfo) { setTexSel(swapInfo.field_0x1); setRasSel(swapInfo.field_0x0); @@ -358,10 +373,24 @@ private: /* 0x7 */ u8 field_0x7; }; +struct J2DTevSwapModeTableInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; +}; + +inline u8 J2DCalcTevSwapTable(u8 param_0, u8 param_1, u8 param_2, u8 param_3) { + return (param_0 << 6) + (param_1 << 4) + (param_2 << 2) + param_3; +} + class J2DTevSwapModeTable { public: /* 802F1934 */ J2DTevSwapModeTable(); + void setTevSwapModeTableInfo(const J2DTevSwapModeTableInfo& info) { + field_0x0 = J2DCalcTevSwapTable(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); + } u8 getR() { return field_0x0 >> 6 & 3; } u8 getG() { return field_0x0 >> 4 & 3; } u8 getB() { return field_0x0 >> 2 & 3; } diff --git a/include/JSystem/JAudio2/JAIAudible.h b/include/JSystem/JAudio2/JAIAudible.h index 1f89a60d73..a7db5ee39c 100644 --- a/include/JSystem/JAudio2/JAIAudible.h +++ b/include/JSystem/JAudio2/JAIAudible.h @@ -1,14 +1,21 @@ #ifndef JAIAUDIBLE_H #define JAIAUDIBLE_H +#include "JSystem/JGeometry.h" #include "dolphin/types.h" struct JASSoundParams; -struct JAIAudible { +class JAIAudible { +public: virtual ~JAIAudible(); virtual JASSoundParams* getOuterParams(int) = 0; virtual void calc() = 0; + + JGeometry::TVec3<float>& getPos() { return mPos; } + void setPos(const JGeometry::TVec3<float>& other) { mPos.set(other); } + + /* 0x04 */ JGeometry::TVec3<float> mPos; }; #endif /* JAIAUDIBLE_H */ diff --git a/include/JSystem/JAudio2/JAISe.h b/include/JSystem/JAudio2/JAISe.h index cd398bd72a..3c28fa464a 100644 --- a/include/JSystem/JAudio2/JAISe.h +++ b/include/JSystem/JAudio2/JAISe.h @@ -1,6 +1,56 @@ #ifndef JAISE_H #define JAISE_H -#include "dolphin/types.h" +#include "JSystem/JAudio2/JAISeqDataMgr.h" +#include "JSystem/JAudio2/JAISound.h" +#include "JSystem/JAudio2/JASTrack.h" +#include "JSystem/JSupport/JSUList.h" + +class JAISeMgr; + +class JAISe : public JSULink<JAISe>, public JAISound { +public: + class TInner { + public: + TInner() : mSeqData(NULL, 0) {} + + /* 0x000 */ u32 mProperPriority; + /* 0x004 */ u32 mPriority; + /* 0x008 */ JASSoundParams mSoundParams; + /* 0x01c */ JASTrack track; + /* 0x264 */ JAISeqData mSeqData; + /* 0x26c */ u8 field_0x26c; + /* 0x270 */ JAISeMgr* seMgr; + /* 0x274 */ JAISoundStrategyMgr<JAISe>* mSoundStrategyMgr; + /* 0x278 */ JAISoundStrategyMgr__unknown<JAISe>* field_0x278; + /* 0x27c */ JAITempoMgr mTempoMgr; + }; + + /* 8029F6D8 */ virtual bool getNumChild() const; + /* 8029F6E0 */ virtual bool getChild(int); + /* 8029F6E8 */ virtual void releaseChild(int); + /* 8029F84C */ virtual JASTrack* getTrack(); + /* 8029F854 */ virtual JASTrack* getChildTrack(int); + /* 8029F864 */ virtual JAISe* asSe(); + /* 8029F868 */ virtual JAITempoMgr* getTempoMgr(); + /* 8029F5C8 */ virtual bool JAISound_tryDie_(); + + /* 8029F03C */ JAISe(JAISeMgr*, JAISoundStrategyMgr<JAISe>*, u32); + /* 8029F0F8 */ void mixOut_(JASSoundParams const&); + /* 8029F214 */ void stopTrack_(); + /* 8029F250 */ void startTrack_(JASSoundParams const&); + /* 8029F304 */ void JAISeCategoryMgr_mixOut_(bool, JASSoundParams const&, JAISoundActivity); + /* 8029F4CC */ void JAISeCategoryMgr_calc_(); + /* 8029F650 */ void JAISeMgr_startID_(JAISoundID, JGeometry::TVec3<f32> const*, JAIAudience*); + /* 8029F6EC */ bool prepare_getSeqData_(); + /* 8029F78C */ void prepare_(); + + JAISeqData* getSeqData() { return &inner_.mSeqData; } + u32 JAISeCategoryMgr_getProperPriority_() const { return inner_.mProperPriority; } + u32 JAISeCategoryMgr_getPriority_() const { return inner_.mPriority; } + bool isFarAway() const { return mPriority == -1; } + + /* 0x0ac */ TInner inner_; +}; #endif /* JAISE_H */ diff --git a/include/JSystem/JAudio2/JAISeMgr.h b/include/JSystem/JAudio2/JAISeMgr.h index 67b79c362d..c34adf04b5 100644 --- a/include/JSystem/JAudio2/JAISeMgr.h +++ b/include/JSystem/JAudio2/JAISeMgr.h @@ -1,6 +1,7 @@ #ifndef JAISEMGR_H #define JAISEMGR_H +#include "JSystem/JAudio2/JAISe.h" #include "JSystem/JAudio2/JAISeqDataMgr.h" #include "JSystem/JAudio2/JAISound.h" #include "JSystem/JAudio2/JAISoundParams.h" @@ -27,28 +28,6 @@ struct JAISeCategoryArrangement { class JAISeMgr; -struct JAISePlaceHolder { - u8 field_0x0[0x10]; -}; - -struct JAISe : public JAISePlaceHolder, public JAISound { - /* 8029F03C */ JAISe(JAISeMgr*, JAISoundStrategyMgr<JAISe>*, u32); - /* 8029F304 */ void JAISeCategoryMgr_mixOut_(bool, JASSoundParams const&, JAISoundActivity); - /* 8029F4CC */ void JAISeCategoryMgr_calc_(); - /* 8029F650 */ void JAISeMgr_startID_(JAISoundID, JGeometry::TVec3<f32> const*, JAIAudience*); - - JAISeqData* getSeqData() { return &mSeqData; } - u32 JAISeCategoryMgr_getProperPriority_() const { return mProperPriority; } - u32 JAISeCategoryMgr_getPriority_() const { return mPriority;} - bool isFarAway() const { return mPriority == -1; } - - /* 0x0aa */ u8 field_0x0[2]; - /* 0x0ac */ u32 mProperPriority; - /* 0x0b0 */ u32 mPriority; - /* 0x0b4 */ u8 field_0xb4[0x25c]; - /* 0x310 */ JAISeqData mSeqData; -}; - class JAISeCategoryMgr : public JAISeqDataUser { public: /* 8029F9C4 */ void JAISeMgr_calc_(); @@ -117,6 +96,7 @@ public: } return mAudience; } + JAISeqDataMgr* getSeqDataMgr() { return mSeqDataMgr; } private: /* 0x008 */ JAIAudience* mAudience; diff --git a/include/JSystem/JAudio2/JAISeq.h b/include/JSystem/JAudio2/JAISeq.h index ed6c6dee9f..14e3d1ee80 100644 --- a/include/JSystem/JAudio2/JAISeq.h +++ b/include/JSystem/JAudio2/JAISeq.h @@ -1,6 +1,55 @@ #ifndef JAISEQ_H #define JAISEQ_H -#include "dolphin/types.h" +#include "JSystem/JAudio2/JAISeqDataMgr.h" +#include "JSystem/JAudio2/JAISound.h" +#include "JSystem/JAudio2/JASHeapCtrl.h" +#include "JSystem/JAudio2/JASTrack.h" +#include "JSystem/JSupport/JSUList.h" + +class JAISeqMgr; +class JAISoundChild; + +class JAISeq : public JAISound, JSULink<JAISeq> { +public: + class TInner { + public: + TInner() : mSeqData(NULL, 0) {} + + /* 0x000 */ JASTrack outputTrack; + /* 0x248 */ JASPoolAllocObject<JAISoundChild>* mSoundChild[32]; + /* 0x2C8 */ JAITempoMgr mTempoMgr; + /* 0x2D8 */ JASSoundParams mSoundParams; + /* 0x2EC */ JAISeqData mSeqData; + /* 0x2F4 */ s32 field_0x39c; + /* 0x2F8 */ JAISeqMgr* seqMgr; + /* 0x2FC */ JAISoundStrategyMgr<JAISeq>* strategyMgr; + }; + + /* 802A1570 */ virtual s32 getNumChild() const; + /* 802A1578 */ virtual JAISoundChild* getChild(int); + /* 802A165C */ virtual void releaseChild(int); + /* 802A1768 */ virtual JAISeq* asSeq(); + /* 802A1728 */ virtual JASTrack* getTrack(); + /* 802A1730 */ virtual JASTrack* getChildTrack(int); + /* 802A176C */ virtual JAITempoMgr* getTempoMgr(); + /* 802A12BC */ virtual bool JAISound_tryDie_(); + + /* 802A0A8C */ JAISeq(JAISeqMgr*, JAISoundStrategyMgr<JAISeq>*); + /* 802A0B64 */ void JAISeqMgr_startID_(JAISoundID, JGeometry::TVec3<f32> const*, JAIAudience*, + int, int); + /* 802A0C04 */ void playSeqData_(JASSoundParams const&, JAISoundActivity); + /* 802A0CA4 */ void reserveChildTracks_(int); + /* 802A0E48 */ void releaseChildTracks_(); + /* 802A0EDC */ bool prepare_getSeqData_(); + /* 802A0F90 */ bool prepare_(JASSoundParams const&, JAISoundActivity); + /* 802A108C */ void JAISeqMgr_calc_(); + /* 802A1180 */ void die_(); + /* 802A1348 */ void mixOut_(JASSoundParams const&, JAISoundActivity); + /* 802A14FC */ void JAISeqMgr_mixOut_(JASSoundParams const&, JAISoundActivity); + + /* 0x0a8 */ TInner inner_; + /* 0x3A8 */ JAISoundStrategyMgr__unknown<JAISeq>* field_0x3a8; +}; #endif /* JAISEQ_H */ diff --git a/include/JSystem/JAudio2/JAISeqDataMgr.h b/include/JSystem/JAudio2/JAISeqDataMgr.h index f97e502ce1..afa630f0e3 100644 --- a/include/JSystem/JAudio2/JAISeqDataMgr.h +++ b/include/JSystem/JAudio2/JAISeqDataMgr.h @@ -5,16 +5,21 @@ #include "dolphin/types.h" struct JAISeqData { - /* 0x00 */ u32 field_0x0; + JAISeqData(void* param_0, u32 param_1) { + field_0x0 = param_0; + field_0x4 = param_1; + } + + /* 0x00 */ void* field_0x0; /* 0x04 */ u32 field_0x4; }; struct JAISeqDataRegion { bool intersects(JAISeqData& seqData) const { - if (field_0x0 + field_0x4 < seqData.field_0x0) { + if (field_0x0 + field_0x4 < (u32)seqData.field_0x0) { return false; } - if (seqData.field_0x0 + seqData.field_0x4 < field_0x0) { + if ((u32)seqData.field_0x0 + seqData.field_0x4 < field_0x0) { return false; } return true; @@ -33,7 +38,7 @@ struct JAISeqDataUser { struct JAISeqDataMgr { virtual ~JAISeqDataMgr(); - virtual void getSeqData(JAISoundID, JAISeqData*) = 0; + virtual int getSeqData(JAISoundID, JAISeqData*) = 0; virtual int releaseSeqData() = 0; virtual void setSeqDataUser(JAISeqDataUser*) = 0; }; diff --git a/include/JSystem/JAudio2/JAISeqMgr.h b/include/JSystem/JAudio2/JAISeqMgr.h index 4d87772f52..db7ef07904 100644 --- a/include/JSystem/JAudio2/JAISeqMgr.h +++ b/include/JSystem/JAudio2/JAISeqMgr.h @@ -27,11 +27,13 @@ public: /* 802A1804 */ virtual bool isUsingSeqData(JAISeqDataRegion const&); /* 802A1870 */ virtual int releaseSeqData(JAISeqDataRegion const&); + JAISeqDataMgr* getSeqDataMgr() { return seqDataMgr_; } + private: /* 0x04 */ JAISoundActivity mActivity; - /* 0x08 */ void* field_0x8; - /* 0x0C */ JAIAudience* mAudience; - /* 0x10 */ JAISeqDataMgr* seqDataMgr_; + /* 0x08 */ JAIAudience* mAudience; + /* 0x0C */ JAISeqDataMgr* seqDataMgr_; + /* 0x10 */ void* field_0x10; /* 0x14 */ JAISoundParamsMove mMove; /* 0x64 */ JSUList<JAISeq> mSeqList; /* 0x70 */ int field_0x70; diff --git a/include/JSystem/JAudio2/JAISound.h b/include/JSystem/JAudio2/JAISound.h index 2896ec2357..8752faca66 100644 --- a/include/JSystem/JAudio2/JAISound.h +++ b/include/JSystem/JAudio2/JAISound.h @@ -53,12 +53,13 @@ struct JAISoundStatus_ { inline bool isPlaying() { return state.unk == 5; } + inline bool isMute() { return field_0x0.flags.mute; } inline bool isPaused() { return field_0x0.flags.paused; } /* 0x0 */ union { u8 value; struct { - u8 flag1 : 1; + u8 mute : 1; u8 paused : 1; u8 flag3 : 1; u8 flag4 : 1; @@ -120,13 +121,24 @@ struct JAISoundFader { return false; } inline void calc() { mIntensity = mTransition.apply(mIntensity); } + f32 getIntensity() { return mIntensity; } /* 0x00 */ f32 mIntensity; /* 0x04 */ JAISoundParamsTransition::TTransition mTransition; }; // Size: 0x10 +template <typename A0> +struct JAISoundStrategyMgr__unknown { + virtual void virtual2(); + virtual void virtual3(A0*); + virtual void virtual4(A0*, const JASSoundParams&); +}; template <typename A0> -struct JAISoundStrategyMgr {}; +struct JAISoundStrategyMgr { + virtual void virtual2(); + virtual JAISoundStrategyMgr__unknown<A0>* virtual3(JAISoundID); + virtual void virtual4(JAISoundStrategyMgr__unknown<A0>*); +}; /* JAISoundStrategyMgr<JAISe> */ struct JAISoundStrategyMgr__template0 {}; /* JAISoundStrategyMgr<JAISeq> */ @@ -136,14 +148,46 @@ struct JAISoundStrategyMgr__template2 {}; class JAISoundActivity { public: - void init() { field_0x0 = 0; } + void init() { field_0x0.value = 0; } - /* 0x0 */ u8 field_0x0; + /* 0x0 */ union { + u8 value; + struct { + u8 flag1 : 1; + u8 flag2 : 1; + u8 flag3 : 1; + u8 flag4 : 1; + u8 flag5 : 1; + u8 flag6 : 1; + u8 flag7 : 1; + u8 flag8 : 1; + } flags; + } field_0x0; +}; + +class JAITempoMgr { +public: + /* 0x00 */ f32 mTempo; + /* 0x04 */ JAISoundParamsTransition::TTransition field_0x4; + + JAITempoMgr() { init(); } + void init() { setTempo(1.0f); } + void setTempo(f32 param_0) { + mTempo = param_0; + field_0x4.zero(); + } + f32 getTempo() { return mTempo; } + void calc() { mTempo = field_0x4.apply(mTempo); } }; class JAISoundHandle; class JAIAudible; class JAIAudience; +class JAISe; +class JAISeq; +class JAISoundChild; +class JAIStream; +class JAITempoMgr; class JAISound { public: /* 802A21A0 */ void releaseHandle(); @@ -160,15 +204,15 @@ public: /* 802A26B8 */ bool calc_JAISound_(); /* 802A29DC */ void initTrack_JAISound_(JASTrack*); - virtual void getNumChild() = 0; - virtual void getChild() = 0; - virtual void releaseChild() = 0; - /* 802A25D8 */ virtual bool asSe(); - /* 802A25E0 */ virtual bool asSeq(); - /* 802A25E8 */ virtual bool asStream(); - virtual void getTrack() = 0; - virtual void getChildTrack() = 0; - virtual void getTempoMgr() = 0; + virtual s32 getNumChild() const = 0; + virtual JAISoundChild* getChild(int) = 0; + virtual void releaseChild(int) = 0; + /* 802A25D8 */ virtual JAISe* asSe(); + /* 802A25E0 */ virtual JAISeq* asSeq(); + /* 802A25E8 */ virtual JAIStream* asStream(); + virtual JASTrack* getTrack() = 0; + virtual JASTrack* getChildTrack(int) = 0; + virtual JAITempoMgr* getTempoMgr() = 0; virtual bool JAISound_tryDie_() = 0; JAISoundID getID() const; @@ -200,7 +244,7 @@ public: /* 0x18 */ JAISoundID soundID; /* 0x1C */ JAISoundStatus_ status_; /* 0x24 */ JAISoundFader fader; - /* 0x34 */ s32 mPriority; + /* 0x34 */ u32 mPriority; /* 0x38 */ s32 mCount; /* 0x3C */ JAISoundParams params; }; // Size: 0x98 diff --git a/include/JSystem/JAudio2/JAISoundChild.h b/include/JSystem/JAudio2/JAISoundChild.h index b3ac7d6942..df8ad96224 100644 --- a/include/JSystem/JAudio2/JAISoundChild.h +++ b/include/JSystem/JAudio2/JAISoundChild.h @@ -11,6 +11,8 @@ struct JAISoundChild { /* 802A2B28 */ void mixOut(JASTrack*); /* 802A2B7C */ void calc(); + JAISoundChild() { init(); } + /* 0x00 */ JAISoundParamsMove mMove; /* 0x50 */ JASSoundParams mParams; }; // Size: 0x64 diff --git a/include/JSystem/JAudio2/JAIStream.h b/include/JSystem/JAudio2/JAIStream.h index 8fd4ea9e32..ec9f25ec94 100644 --- a/include/JSystem/JAudio2/JAIStream.h +++ b/include/JSystem/JAudio2/JAIStream.h @@ -1,6 +1,7 @@ #ifndef JAISTREAM_H #define JAISTREAM_H -#include "dolphin/types.h" +#include "JSystem/JAudio2/JAISound.h" +#include "JSystem/JSupport/JSUList.h" #endif /* JAISTREAM_H */ diff --git a/include/JSystem/JAudio2/JASHeapCtrl.h b/include/JSystem/JAudio2/JASHeapCtrl.h index 139fcbb4f6..78e9cbb69e 100644 --- a/include/JSystem/JAudio2/JASHeapCtrl.h +++ b/include/JSystem/JAudio2/JASHeapCtrl.h @@ -1,14 +1,125 @@ #ifndef JASHEAPCTRL_H #define JASHEAPCTRL_H -#include "dolphin/types.h" +#include "JSystem/JSupport/JSUList.h" +#include "dolphin/os/OSInterrupt.h" +#include "dolphin/os/OSMutex.h" + +class JASDisposer; + +class JASHeap { + /* 80290140 */ JASHeap(JASDisposer*); + /* 802901AC */ void initRootHeap(void*, u32); + /* 8029021C */ void alloc(JASHeap*, u32); + /* 802903F4 */ void allocTail(JASHeap*, u32); + /* 802904E4 */ void free(); + /* 80290608 */ void insertChild(JASHeap*, JASHeap*, void*, u32, bool); + /* 802906F0 */ void getTailHeap(); + /* 8029077C */ void getTailOffset(); + /* 802907E0 */ void getCurOffset(); + /* 80290B54 */ ~JASHeap(); + + /* 0x00 */ JSUTree<JASHeap> mTree; + /* 0x1C */ OSMutex mMutex; + /* 0x34 */ JASDisposer* mDisposer; + /* 0x38 */ int field_0x38; + /* 0x3c */ int field_0x3c; + /* 0x40 */ void* field_0x40; +}; struct JASGenericMemPool { /* 80290848 */ JASGenericMemPool(); /* 80290860 */ ~JASGenericMemPool(); /* 802908C8 */ void newMemPool(u32, int); - /* 80290948 */ void alloc(u32); + /* 80290948 */ void* alloc(u32); /* 80290994 */ void free(void*, u32); + + /* 0x00 */ void* field_0x0; + /* 0x04 */ int freeMemCount; + /* 0x08 */ int totalMemCount; + /* 0x0C */ int field_0xc; + +}; + +namespace JASThreadingModel { + template <typename A0> + struct InterruptsDisable { + struct Lock { + Lock(const A0& param_0) { field_0x0 = OSDisableInterrupts(); } + ~Lock() { OSRestoreInterrupts(field_0x0); } + + BOOL field_0x0; + }; + }; +}; + +template <typename T> +class JASMemPool : public JASGenericMemPool { +public: + void newMemPool(int param_0) { JASGenericMemPool::newMemPool(sizeof(T), param_0); } + void* alloc(u32 n) { return JASGenericMemPool::alloc(n); } + void free(void* ptr, u32 n) { JASGenericMemPool::free(ptr, n); } +}; + +template <typename T> +class JASPoolAllocObject : public T { +public: + static void* operator new(size_t n) { + JASMemPool<T>* memPool = getMemPool(); + return memPool->alloc(n); + } + static void operator delete(void* ptr, size_t n) { + JASMemPool<T>* memPool_ = getMemPool(); + memPool_->free(ptr, n); + } + static void newMemPool(int param_0) { + JASMemPool<T>* memPool_ = getMemPool(); + memPool_->newMemPool(param_0); + } + +private: + static JASMemPool<T>* getMemPool() { + static JASMemPool<T> memPool_; + return &memPool_; + } +}; + +template <typename T> +class JASMemPool_MultiThreaded : public JASGenericMemPool { +public: + void newMemPool(int param_0) { + JASThreadingModel::InterruptsDisable<JASMemPool_MultiThreaded<T> >::Lock lock(*this); + JASGenericMemPool::newMemPool(sizeof(T), param_0); + } + + void* alloc(size_t count) { + JASThreadingModel::InterruptsDisable<JASMemPool_MultiThreaded<T> >::Lock lock(*this); + return JASGenericMemPool::alloc(count); + } + + void free(void* ptr, u32 param_1) { + JASThreadingModel::InterruptsDisable<JASMemPool_MultiThreaded<T> >::Lock lock(*this); + JASGenericMemPool::free(ptr, param_1); + } +}; + +template <typename T> +class JASPoolAllocObject_MultiThreaded : public T { +public: + static void* operator new(size_t n) { + JASMemPool_MultiThreaded<T>* memPool_ = getMemPool(); + return memPool_->alloc(n); + } + static void operator delete(void* ptr, size_t n) { + JASMemPool_MultiThreaded<T>* memPool_ = getMemPool(); + memPool_->free(ptr, n); + } + +private: + static JASMemPool_MultiThreaded<T>* getMemPool() { + static JASMemPool_MultiThreaded<T> memPool_; + return &memPool_; + } }; #endif /* JASHEAPCTRL_H */ diff --git a/include/JSystem/JAudio2/JASTrack.h b/include/JSystem/JAudio2/JASTrack.h index 396a32ae15..bc5879bdf9 100644 --- a/include/JSystem/JAudio2/JASTrack.h +++ b/include/JSystem/JAudio2/JASTrack.h @@ -30,12 +30,23 @@ struct JASChannel { }; struct JASTrack { + enum Status { + STATUS_FREE, + STATUS_RUN, + }; + struct TChannelMgr { /* 802930DC */ TChannelMgr(JASTrack*); /* 80293148 */ void init(); /* 802931B0 */ void releaseAll(); /* 80293220 */ void noteOff(u32, u16); /* 802932A0 */ void setPauseFlag(bool); + + /* 0x00 */ JASChannel* field_0x0[8]; + /* 0x20 */ u8 field_0x20[0x18]; // JASChannelParams + /* 0x38 */ short field_0x38[8]; + /* 0x48 */ JASSoundParams* field_0x48; + /* 0x4c */ JASTrack* field_0x4c; }; struct TList { @@ -47,6 +58,10 @@ struct JASTrack { struct MoveParam_ { /* 802932C8 */ MoveParam_(); + + /* 0x00 */ f32 field_0x0; + /* 0x04 */ f32 field_0x4; + /* 0x08 */ int field_0x8; }; /* 80291228 */ JASTrack(); @@ -109,9 +124,53 @@ struct JASTrack { static u8 sTrackList[16]; int getChannelMgrCount() { return channelMgrCount; } - - /* 0x000 */ u8 field_0x0[0x1d0]; + u8 getStatus() const { return mStatus; } + JASTrack* getChild(u32 index) { return field_0x130[index]; } + void setAutoDelete(bool param_0) { + field_0x216 = (param_0 << 4) | field_0x216 & ~0x10; + } + + /* 0x000 */ u8 field_0x0[0x5c]; // JASSeqCtrl + /* 0x05C */ u8 field_0x5c[0x24]; // JASTrackPort + /* 0x080 */ u8 field_0x80[0x1c]; // JASRegisterParam + /* 0x09C */ MoveParam_ field_0x9c[6]; + /* 0x0e4 */ u8 mOscParam[0x30]; // JASOscillator::Data[2] + /* 0x114 */ u8 field_0x114[0x18]; // JASOscillator::Point[4] + /* 0x12C */ JASTrack* mParent; + /* 0x130 */ JASTrack* field_0x130[16]; + /* 0x170 */ TChannelMgr* field_0x170[4]; + /* 0x180 */ TChannelMgr field_0x180; /* 0x1D0 */ int channelMgrCount; + /* 0x1D4 */ void* field_0x1d4; + /* 0x1D8 */ f32 field_0x1d8; + /* 0x1DC */ f32 field_0x1dc; + /* 0x1E0 */ f32 field_0x1e0; + /* 0x1E4 */ f32 field_0x1e4; + /* 0x1E8 */ f32 field_0x1e8; + /* 0x1EC */ f32 field_0x1ec; + /* 0x1F0 */ u16 field_0x1f0; + /* 0x1F2 */ u16 field_0x1f2; + /* 0x1F4 */ short field_0x1f4[8]; + /* 0x204 */ short field_0x204[8]; + /* 0x214 */ char field_0x214; + /* 0x215 */ u8 mStatus; + /* 0x216 */ u8 field_0x216; + /* 0x218 */ f32 field_0x218; + /* 0x21C */ f32 field_0x21c; + /* 0x220 */ u32 field_0x220; + /* 0x224 */ short field_0x224; + /* 0x226 */ u16 field_0x226; + /* 0x228 */ u16 field_0x228; + /* 0x22A */ s8 field_0x22a; + /* 0x22B */ char field_0x22b; + /* 0x22C */ short field_0x22c; + /* 0x22E */ short field_0x22e; + /* 0x230 */ char field_0x230; + /* 0x231 */ char field_0x231; + /* 0x232 */ char field_0x232; + /* 0x233 */ char field_0x233; + /* 0x234 */ u16 field_0x234[6]; + /* 0x240 */ u8 field_0x240[0x08]; // TLinkListNode }; struct JASDefaultBankTable : public JASGlobalInstance<JASDefaultBankTable> { |
