diff options
| author | hatal175 <hatal175@users.noreply.github.com> | 2023-08-01 10:17:21 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-01 00:17:21 -0700 |
| commit | 2275eb710b4b0794f198059a7fd61db7499941ff (patch) | |
| tree | e4bb01dce37d78a88657b0240a247febbfa14c24 /include | |
| parent | 396449b597bef772b4a79ef173671100e32ad5c1 (diff) | |
Work on J2DMaterialFactory (#394)
* Work on J2DMaterialFactory
* J3DUClipper OK
* Work on JAISoundStarter
* JAISoundHandles OK
* JAISoundInfo OK
* Fix JAISound::isStopping
* Work on J2DTextBoxEx
* dspproc OK
* osdsp OK
* osdsp_task OK
* Work on dsptask
* Import some JASCalc code
* JASCallback OK
* JASOscillator OK
* JASLfo OK
Diffstat (limited to 'include')
| -rw-r--r-- | include/JSystem/J2DGraph/J2DMatBlock.h | 86 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DMaterialFactory.h | 135 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DTevs.h | 73 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DMatBlock.h | 24 | ||||
| -rw-r--r-- | include/JSystem/J3DU/J3DUClipper.h | 18 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISeMgr.h | 6 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISound.h | 37 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISoundHandles.h | 2 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JAISoundStarter.h | 2 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JASCalc.h | 24 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JASCallback.h | 29 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JASLfo.h | 17 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/JASOscillator.h | 41 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/dspproc.h | 3 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/osdsp.h | 6 | ||||
| -rw-r--r-- | include/JSystem/JAudio2/osdsp_task.h | 15 | ||||
| -rw-r--r-- | include/JSystem/JMath/JMATrigonometric.h | 11 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/limits | 70 | ||||
| -rw-r--r-- | include/dolphin/dsp/dsp.h | 2 | ||||
| -rw-r--r-- | include/dolphin/dsp/dsp_task.h | 14 |
20 files changed, 526 insertions, 89 deletions
diff --git a/include/JSystem/J2DGraph/J2DMatBlock.h b/include/JSystem/J2DGraph/J2DMatBlock.h index 5473a3a0c1..b495a44792 100644 --- a/include/JSystem/J2DGraph/J2DMatBlock.h +++ b/include/JSystem/J2DGraph/J2DMatBlock.h @@ -15,17 +15,27 @@ struct ResTIMG; struct ResTLUT; struct J2DGXColorS10 : public GXColorS10 { - /* 802F1B90 */ J2DGXColorS10(); - - /* - J2DGXColorS10& operator=(const GXColorS10& other) { + /* 802F1B90 */ J2DGXColorS10() {} + J2DGXColorS10(const J2DGXColorS10& other) { r = other.r; g = other.g; b = other.b; a = other.a; - return *this; } - */ + J2DGXColorS10(const GXColorS10& other) { + r = other.r; + g = other.g; + b = other.b; + a = other.a; + } + + // J2DGXColorS10& operator=(const GXColorS10& other) { + // r = other.r; + // g = other.g; + // b = other.b; + // a = other.a; + // return *this; + // } }; struct J2DTevSwapModeInfo; @@ -36,11 +46,11 @@ public: /* 802EB1D0 */ virtual void setGX(); /* 802F2A44 */ virtual void loadTexture(_GXTexMapID, u32); virtual u32 getType() = 0; - virtual s32 getMaxStage() = 0; + virtual u8 getMaxStage() = 0; /* 802EB1DC */ virtual void setTexNo(u32, u16); /* 802EA170 */ virtual u32 getTexNo(u32) const; /* 802F2A48 */ virtual void setFontNo(u16); - /* 802EA164 */ virtual u32 getFontNo() const; + /* 802EA164 */ virtual u16 getFontNo() const; /* 802F2A4C */ virtual void setTevOrder(u32, J2DTevOrder); /* 802EA144 */ virtual J2DTevOrder* getTevOrder(u32); /* 802EB1D8 */ virtual void setTevColor(u32, J2DGXColorS10); @@ -87,11 +97,11 @@ public: /* 802EC328 */ virtual void setGX(); /* 802EC570 */ virtual void loadTexture(_GXTexMapID, u32); /* 802F27A0 */ virtual u32 getType(); - /* 802F27AC */ virtual s32 getMaxStage(); + /* 802F27AC */ virtual u8 getMaxStage(); /* 802F27B4 */ virtual void setTexNo(u32, u16); /* 802F27C4 */ virtual u32 getTexNo(u32) const; /* 802F27D4 */ virtual void setFontNo(u16); - /* 802F27DC */ virtual u32 getFontNo() const; + /* 802F27DC */ virtual u16 getFontNo() const; /* 802F27E4 */ virtual void setTevOrder(u32, J2DTevOrder); /* 802F2808 */ virtual J2DTevOrder* getTevOrder(u32); /* 802F281C */ virtual void setTevColor(u32, J2DGXColorS10); @@ -154,11 +164,11 @@ public: /* 802ED584 */ virtual void setGX(); /* 802ED874 */ virtual void loadTexture(_GXTexMapID, u32); /* 802F24FC */ virtual u32 getType(); - /* 802F2508 */ virtual s32 getMaxStage(); + /* 802F2508 */ virtual u8 getMaxStage(); /* 802F2510 */ virtual void setTexNo(u32, u16); /* 802F2520 */ virtual u32 getTexNo(u32) const; /* 802F2530 */ virtual void setFontNo(u16); - /* 802F2538 */ virtual u32 getFontNo() const; + /* 802F2538 */ virtual u16 getFontNo() const; /* 802F2540 */ virtual void setTevOrder(u32, J2DTevOrder); /* 802F2564 */ virtual J2DTevOrder* getTevOrder(u32); /* 802F2578 */ virtual void setTevColor(u32, J2DGXColorS10); @@ -223,11 +233,11 @@ public: /* 802EEA2C */ virtual void setGX(); /* 802EED1C */ virtual void loadTexture(_GXTexMapID, u32); /* 802F2258 */ virtual u32 getType(); - /* 802F2264 */ virtual s32 getMaxStage(); + /* 802F2264 */ virtual u8 getMaxStage(); /* 802F226C */ virtual void setTexNo(u32, u16); /* 802F227C */ virtual u32 getTexNo(u32) const; /* 802F228C */ virtual void setFontNo(u16); - /* 802F2294 */ virtual u32 getFontNo() const; + /* 802F2294 */ virtual u16 getFontNo() const; /* 802F229C */ virtual void setTevOrder(u32, J2DTevOrder); /* 802F22C0 */ virtual J2DTevOrder* getTevOrder(u32); /* 802F22D4 */ virtual void setTevColor(u32, J2DGXColorS10); @@ -292,11 +302,11 @@ public: /* 802EFEAC */ virtual void setGX(); /* 802F019C */ virtual void loadTexture(_GXTexMapID, u32); /* 802F1FB8 */ virtual u32 getType(); - /* 802F1FC4 */ virtual s32 getMaxStage(); + /* 802F1FC4 */ virtual u8 getMaxStage(); /* 802F1FCC */ virtual void setTexNo(u32, u16); /* 802F1FDC */ virtual u32 getTexNo(u32) const; /* 802F1FEC */ virtual void setFontNo(u16); - /* 802F1FF4 */ virtual u32 getFontNo() const; + /* 802F1FF4 */ virtual u16 getFontNo() const; /* 802F1FFC */ virtual void setTevOrder(u32, J2DTevOrder); /* 802F2020 */ virtual J2DTevOrder* getTevOrder(u32); /* 802F2034 */ virtual void setTevColor(u32, J2DGXColorS10); @@ -362,11 +372,11 @@ public: /* 802F132C */ virtual void setGX(); /* 802F161C */ virtual void loadTexture(_GXTexMapID, u32); /* 802F1D18 */ virtual u32 getType(); - /* 802F1D24 */ virtual s32 getMaxStage(); + /* 802F1D24 */ virtual u8 getMaxStage(); /* 802F1D2C */ virtual void setTexNo(u32, u16); /* 802F1D3C */ virtual u32 getTexNo(u32) const; /* 802F1D4C */ virtual void setFontNo(u16); - /* 802F1D54 */ virtual u32 getFontNo() const; + /* 802F1D54 */ virtual u16 getFontNo() const; /* 802F1D5C */ virtual void setTevOrder(u32, J2DTevOrder); /* 802F1D80 */ virtual J2DTevOrder* getTevOrder(u32); /* 802F1D94 */ virtual void setTevColor(u32, J2DGXColorS10); @@ -424,14 +434,34 @@ public: /* 0x1B1 */ bool mFontUndeleteFlag; }; // Size: 0x1B4 +struct J2DAlphaCompInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 mRef0; + /* 0x3 */ u8 mRef1; + /* 0x4 */ u8 field_0x4; + /* 0x5 */ u8 field_0x5; + /* 0x6 */ u8 field_0x6; + /* 0x7 */ u8 field_0x7; +}; + extern u16 j2dDefaultAlphaCmp; +inline u16 J2DCalcAlphaCmp(s32 param_1, u32 param_2, u32 param_3) { + return ((param_1) << 5) | ((param_2 & 0xff) << 3) | (param_3 & 0xff); +} + struct J2DAlphaComp { J2DAlphaComp() { mAlphaCmp = j2dDefaultAlphaCmp; mRef0 = 0; mRef1 = 0; } + J2DAlphaComp(const J2DAlphaCompInfo& info) { + mAlphaCmp = J2DCalcAlphaCmp(info.field_0x0, info.mRef0, info.mRef1); + mRef0 = info.field_0x1; + mRef1 = info.field_0x4; + } u8 getComp0() { return mAlphaCmp >> 5 & 7; } u8 getRef0() { return mRef0; } u8 getOp() { return mAlphaCmp >> 3 & 3; } @@ -461,6 +491,7 @@ extern J2DBlendInfo j2dDefaultBlendInfo; struct J2DBlend { J2DBlend() { mBlendInfo = j2dDefaultBlendInfo; } + J2DBlend(const J2DBlendInfo& info) { mBlendInfo = info; } void setBlendInfo(const J2DBlendInfo& info) { mBlendInfo = info; } u8 getType() { return mBlendInfo.mType; } u8 getSrcFactor() { return mBlendInfo.mSrcFactor; } @@ -476,6 +507,9 @@ public: /* 802F17FC */ void initialize(); /* 802F1840 */ void setGX(); + void setAlphaComp(J2DAlphaComp comp) { mAlphaComp = comp; } + void setBlend(J2DBlend blend) { mBlend = blend; } + void setDither(u8 dither) { mDither = dither; } private: /* 0x0 */ J2DAlphaComp mAlphaComp; @@ -547,6 +581,9 @@ public: /* 802EB7E0 */ void getTexMtx(u32, J2DTexMtx&); u32 getTexGenNum() const { return mTexGenNum; } + void setTexGenNum(u32 num) { mTexGenNum = num; } + void setTexCoord(u32 i, J2DTexCoord coord) { mTexGenCoord[i] = coord; } + void setTexMtx(u32 i, J2DTexMtx* mtx) { mTexMtx[i] = mtx; } /* 802EB620 */ virtual ~J2DTexGenBlock(); }; // Size: 0x48 @@ -554,13 +591,21 @@ public: struct J2DColorChanInfo { /* 0x0 */ u8 field_0x0; /* 0x0 */ u8 field_0x1; + /* 0x0 */ u8 field_0x2; + /* 0x0 */ u8 field_0x3; }; inline u8 J2DCalcColorChanID(u8 param_1) { return param_1; } +extern J2DColorChanInfo j2dDefaultColorChanInfo; class J2DColorChan { public: - /* 802EB280 */ J2DColorChan(); + /* 802EB280 */ J2DColorChan() { + setColorChanInfo(j2dDefaultColorChanInfo); + } + J2DColorChan(const J2DColorChanInfo& info) { + mColorChan = J2DCalcColorChanID(info.field_0x1); + } void setColorChanInfo(const J2DColorChanInfo& info) { mColorChan = J2DCalcColorChanID(info.field_0x1); @@ -589,6 +634,9 @@ public: JUtility::TColor* getMatColor(u32 i) { return &mMatColor[i]; } J2DColorChan* getColorChan(u32 i) { return &mColorChan[i]; } void setCullMode(u8 mode) { mCullMode = mode; } + void setColorChanNum(u8 num) { mColorChanNum = num; } + void setMatColor(u32 i, JUtility::TColor color) { mMatColor[i] = color; } + void setColorChan(u32 i, const J2DColorChan& color) { mColorChan[i] = color; } }; #endif /* J2DMATBLOCK_H */ diff --git a/include/JSystem/J2DGraph/J2DMaterialFactory.h b/include/JSystem/J2DGraph/J2DMaterialFactory.h index 719333b51c..48b68363f8 100644 --- a/include/JSystem/J2DGraph/J2DMaterialFactory.h +++ b/include/JSystem/J2DGraph/J2DMaterialFactory.h @@ -2,19 +2,85 @@ #define J2DMATERIALFACTORY_H #include "JSystem/J2DGraph/J2DManage.h" +#include "JSystem/J2DGraph/J2DMatBlock.h" #include "dolphin/gx/GXEnum.h" #include "dolphin/types.h" -struct J2DMaterialBlock {}; +struct J2DMaterialBlock { + u32 field_0x0; + u32 field_0x4; + u16 field_0x8; + u16 field_0xa; + u32 field_0xc; + u32 field_0x10; + u32 field_0x14; + u32 field_0x18; + u32 field_0x1c; + u32 field_0x20; + u32 field_0x24; + u32 field_0x28; + u32 field_0x2c; + u32 field_0x30; + u32 field_0x34; + u32 field_0x38; + u32 field_0x3c; + u32 field_0x40; + u32 field_0x44; + u32 field_0x48; + u32 field_0x4c; + u32 field_0x50; + u32 field_0x54; + u32 field_0x58; + u32 field_0x5c; + u32 field_0x60; + u32 field_0x64; +}; typedef struct _GXColor GXColor; typedef struct _GXColorS10 GXColorS10; struct J2DAlphaCompInfo; struct J2DBlendInfo; struct J2DColorChanInfo; -struct J2DIndInitData; class J2DMaterial; -struct J2DMaterialInitData; + +struct J2DIndInitData { + u8 field_0x0; + u8 field_0x1; + u8 field_0x2[2]; + J2DIndTexOrderInfo field_0x4[4]; + J2DIndTexMtxInfo field_0xc[3]; + J2DIndTexCoordScaleInfo field_0x60[4]; + J2DIndTevStageInfo field_0x68[4]; + u8 field_0xac[0x90]; +}; + +struct J2DMaterialInitData { + u8 field_0x0; + u8 field_0x1; + u8 field_0x2; + u8 field_0x3; + u8 field_0x4; + u8 field_0x5; + u8 field_0x6; + u8 field_0x7; + u16 field_0x8[2]; + u16 field_0xc[4]; + u16 field_0x14[8]; + u16 field_0x24[0xa]; + u16 field_0x38[8]; + u16 field_0x48; + u16 field_0x4a[4]; + u8 field_0x52[0x10]; + u8 field_0x62[0x10]; + u16 field_0x72[0x10]; + u16 field_0x92[0x4]; + u16 field_0x9a[0x10]; + u16 field_0xba[0x10]; + u16 field_0xda[0x4]; + u16 field_0xe2; + u16 field_0xe4; + u16 field_0xe6; +}; struct J2DTevStageInfo; struct J2DTevSwapModeTableInfo; struct J2DTevSwapModeInfo; @@ -26,35 +92,44 @@ class JKRArchive; class J2DMaterialFactory { public: /* 802F2AD0 */ J2DMaterialFactory(J2DMaterialBlock const&); - /* 802F2C94 */ void countStages(int) const; - /* 802F2D1C */ void create(J2DMaterial*, int, u32, J2DResReference*, J2DResReference*, + /* 802F2C94 */ u32 countStages(int) const; + /* 802F2D1C */ J2DMaterial* create(J2DMaterial*, int, u32, J2DResReference*, J2DResReference*, JKRArchive*) const; - /* 802F362C */ void newMatColor(int, int) const; - /* 802F36CC */ void newColorChanNum(int) const; - /* 802F3704 */ void newColorChan(int, int) const; - /* 802F3758 */ void newTexGenNum(int) const; - /* 802F3790 */ void newTexCoord(int, int) const; - /* 802F3804 */ void newTexMtx(int, int) const; - /* 802F38E0 */ void newCullMode(int) const; - /* 802F3920 */ void newTexNo(int, int) const; - /* 802F3968 */ void newFontNo(int) const; - /* 802F39A8 */ void newTevOrder(int, int) const; - /* 802F3A1C */ void newTevColor(int, int) const; - /* 802F3AB4 */ void newTevKColor(int, int) const; - /* 802F3B54 */ void newTevStageNum(int) const; - /* 802F3B8C */ void newTevStage(int, int) const; - /* 802F3BEC */ void newTevSwapModeTable(int, int) const; - /* 802F3C88 */ void newIndTexStageNum(int) const; - /* 802F3CB8 */ void newIndTexOrder(int, int) const; - /* 802F3D20 */ void newIndTexMtx(int, int) const; - /* 802F3E24 */ void newIndTevStage(int, int) const; - /* 802F3F78 */ void newIndTexCoordScale(int, int) const; - /* 802F3FE0 */ void newAlphaComp(int) const; - /* 802F405C */ void newBlend(int) const; - /* 802F40D8 */ void newDither(int) const; + /* 802F362C */ JUtility::TColor newMatColor(int, int) const; + /* 802F36CC */ u8 newColorChanNum(int) const; + /* 802F3704 */ J2DColorChan newColorChan(int, int) const; + /* 802F3758 */ u32 newTexGenNum(int) const; + /* 802F3790 */ J2DTexCoord newTexCoord(int, int) const; + /* 802F3804 */ J2DTexMtx* newTexMtx(int, int) const; + /* 802F38E0 */ u8 newCullMode(int) const; + /* 802F3920 */ u16 newTexNo(int, int) const; + /* 802F3968 */ u16 newFontNo(int) const; + /* 802F39A8 */ J2DTevOrder newTevOrder(int, int) const; + /* 802F3A1C */ J2DGXColorS10 newTevColor(int, int) const; + /* 802F3AB4 */ JUtility::TColor newTevKColor(int, int) const; + /* 802F3B54 */ u8 newTevStageNum(int) const; + /* 802F3B8C */ J2DTevStage newTevStage(int, int) const; + /* 802F3BEC */ J2DTevSwapModeTable newTevSwapModeTable(int, int) const; + /* 802F3C88 */ u8 newIndTexStageNum(int) const; + /* 802F3CB8 */ J2DIndTexOrder newIndTexOrder(int, int) const; + /* 802F3D20 */ J2DIndTexMtx newIndTexMtx(int, int) const; + /* 802F3E24 */ J2DIndTevStage newIndTevStage(int, int) const; + /* 802F3F78 */ J2DIndTexCoordScale newIndTexCoordScale(int, int) const; + /* 802F3FE0 */ J2DAlphaComp newAlphaComp(int) const; + /* 802F405C */ J2DBlend newBlend(int) const; + /* 802F40D8 */ u8 newDither(int) const; + + u32 getMaterialMode(int idx) const { + return field_0x4[field_0x8[idx]].field_0x0; + } + + u8 getMaterialAlphaCalc(int idx) const { + return field_0x4[field_0x8[idx]].field_0x6; + } private: - /* 0x00 */ int field_0x0; + /* 0x00 */ u16 field_0x0; + /* 0x02 */ u16 field_0x2; /* 0x04 */ J2DMaterialInitData* field_0x4; /* 0x08 */ u16* field_0x8; /* 0x0C */ J2DIndInitData* field_0xc; @@ -68,7 +143,7 @@ private: /* 0x2C */ u16* field_0x2c; /* 0x30 */ _GXCullMode* field_0x30; /* 0x34 */ J2DTevOrderInfo* field_0x34; - /* 0x38 */ GXColorS10* field_0x38; + /* 0x38 */ J2DGXColorS10* field_0x38; /* 0x3C */ GXColor* field_0x3c; /* 0x40 */ u8* field_0x40; /* 0x44 */ J2DTevStageInfo* field_0x44; diff --git a/include/JSystem/J2DGraph/J2DTevs.h b/include/JSystem/J2DGraph/J2DTevs.h index 1fdcc0c0f9..9bf56f924e 100644 --- a/include/JSystem/J2DGraph/J2DTevs.h +++ b/include/JSystem/J2DGraph/J2DTevs.h @@ -65,9 +65,16 @@ struct J2DIndTexOrderInfo { GXTexMapID getTexMapID() const { return (GXTexMapID)mTexMapID; } }; +extern const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull; + class J2DIndTexOrder { public: - /* 802EB378 */ J2DIndTexOrder(); + /* 802EB378 */ J2DIndTexOrder() { + mInfo = j2dDefaultIndTexOrderNull; + } + J2DIndTexOrder(const J2DIndTexOrderInfo& info) { + mInfo = info; + } /* 802EA0FC */ void load(u8); private: @@ -89,10 +96,17 @@ struct J2DIndTexMtxInfo { } }; +extern J2DIndTexMtxInfo const j2dDefaultIndTexMtxInfo; + class J2DIndTexMtx { public: - /* 802EB2E4 */ ~J2DIndTexMtx(); - /* 802EB320 */ J2DIndTexMtx(); + /* 802EB2E4 */ ~J2DIndTexMtx() {} + /* 802EB320 */ J2DIndTexMtx() { + mIndTexMtxInfo = j2dDefaultIndTexMtxInfo; + } + J2DIndTexMtx(const J2DIndTexMtxInfo& info) { + mIndTexMtxInfo = info; + } /* 802EA098 */ void load(u8); /* 802E9C90 */ void load(u32); /* 802E9CC4 */ void calc(); @@ -114,10 +128,17 @@ struct J2DIndTexCoordScaleInfo { GXIndTexScale getScaleT() const { return (GXIndTexScale)mScaleT; } }; +extern const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo; + class J2DIndTexCoordScale { public: - /* 802EB290 */ ~J2DIndTexCoordScale(); - /* 802EB2CC */ J2DIndTexCoordScale(); + /* 802EB290 */ ~J2DIndTexCoordScale() {} + /* 802EB2CC */ J2DIndTexCoordScale() { + mInfo = j2dDefaultIndTexCoordScaleInfo; + } + J2DIndTexCoordScale(const J2DIndTexCoordScaleInfo& info) { + mInfo = info; + } /* 802EA0CC */ void load(u8); private: @@ -133,19 +154,29 @@ struct J2DIndTevStageInfo { /* 0x5 */ u8 field_0x5; /* 0x6 */ u8 field_0x6; /* 0x7 */ u8 field_0x7; - /* 0x8 */ int field_0x8; + /* 0x8 */ u8 field_0x8; + /* 0x9 */ u8 field_0x9; + /* 0xa */ u8 field_0xa; + /* 0xb */ u8 field_0xb; }; 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; + (info.field_0x2 << 4) | (info.field_0x1 << 2) | (info.field_0x0); } +extern const J2DIndTevStageInfo j2dDefaultIndTevStageInfo; + class J2DIndTevStage { public: /* 802EA044 */ void load(u8); - /* 802F18A0 */ J2DIndTevStage(); + /* 802F18A0 */ J2DIndTevStage() { + mFlags = J2DCalcIndTevStage(j2dDefaultIndTevStageInfo); + } + J2DIndTevStage(const J2DIndTevStageInfo& info) { + mFlags = J2DCalcIndTevStage(info); + } void setIndTevStageInfo(const J2DIndTevStageInfo& info) { mFlags = J2DCalcIndTevStage(info); } @@ -177,9 +208,17 @@ struct J2DTexCoordInfo { } }; +extern J2DTexCoordInfo const j2dDefaultTexCoordInfo[8]; + class J2DTexCoord { public: - /* 802EB260 */ J2DTexCoord(); + /* 802EB260 */ inline J2DTexCoord() { + *(J2DTexCoordInfo*)this = j2dDefaultTexCoordInfo[0]; + } + + J2DTexCoord(const J2DTexCoordInfo& info) { + *(J2DTexCoordInfo*)this = info; + } void setTexCoordInfo(const J2DTexCoordInfo& info) { mTexCoordInfo = info; } s32 getTexGenType() { return mTexCoordInfo.mTexGenType; } s32 getTexGenSrc() { return mTexCoordInfo.mTexGenSrc; } @@ -203,9 +242,17 @@ struct J2DTevOrderInfo { } }; +extern J2DTevOrderInfo j2dDefaultTevOrderInfoNull; + class J2DTevOrder { public: - /* 802F1B70 */ J2DTevOrder(); + /* 802F1B70 */ J2DTevOrder() { + mTevOrderInfo = j2dDefaultTevOrderInfoNull; + } + + J2DTevOrder(const J2DTevOrderInfo& info) { + *(J2DTevOrderInfo*)this = info; + } void setTevOrderInfo(const J2DTevOrderInfo& info) {mTevOrderInfo = info; } GXChannelID getColor() const { return (GXChannelID)mTevOrderInfo.mColor; } @@ -235,6 +282,7 @@ struct J2DTevStageInfo { /* 0x10 */ u8 field_0x10; /* 0x11 */ u8 field_0x11; /* 0x12 */ u8 field_0x12; + /* 0x13 */ u8 field_0x13; }; struct J2DTevSwapModeInfo { @@ -384,9 +432,14 @@ 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; } +extern const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable; + class J2DTevSwapModeTable { public: /* 802F1934 */ J2DTevSwapModeTable(); + J2DTevSwapModeTable(const J2DTevSwapModeTableInfo& info) { + field_0x0 = J2DCalcTevSwapTable(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); + } void setTevSwapModeTableInfo(const J2DTevSwapModeTableInfo& info) { field_0x0 = J2DCalcTevSwapTable(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index ed9ffd645c..377746bb9d 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -598,23 +598,31 @@ struct J3DAlphaCompInfo { /* 0x1 */ u8 field_0x1; /* 0x2 */ u8 mRef0; /* 0x3 */ u8 mRef1; + /* 0x4 */ u8 field_0x4; + /* 0x5 */ u8 field_0x5; + /* 0x6 */ u8 field_0x6; + /* 0x7 */ u8 field_0x7; }; -extern const J3DAlphaCompInfo j3dDefaultAlphaCmpID; +extern const u16 j3dDefaultAlphaCmpID; -struct J3DAlphaComp: public J3DAlphaCompInfo { +struct J3DAlphaComp { J3DAlphaComp() { - *(u16*)&field_0x0 = *(u16*)&j3dDefaultAlphaCmpID.field_0x0; + field_0x0 = j3dDefaultAlphaCmpID; mRef0 = 0; mRef1 = 0; } - void setAlphaCompInfo(J3DAlphaCompInfo *param_1) { - mRef0 = param_1[0].field_0x1; - mRef1 = param_1[1].field_0x0; - u32 p1_mref1 = param_1[0].mRef1; - *(u16*)&field_0x0 = calcAlphaCmpID(param_1[0].field_0x0, param_1[0].mRef0, p1_mref1); + void setAlphaCompInfo(const J3DAlphaCompInfo& param_1) { + mRef0 = param_1.field_0x1; + mRef1 = param_1.field_0x4; + u32 p1_mref1 = param_1.mRef1; + field_0x0 = calcAlphaCmpID(param_1.field_0x0, param_1.mRef0, p1_mref1); } + + /* 0x00 */ u16 field_0x0; + /* 0x02 */ u8 mRef0; + /* 0x03 */ u8 mRef1; }; // Size: 0x4 class J3DPEBlock { diff --git a/include/JSystem/J3DU/J3DUClipper.h b/include/JSystem/J3DU/J3DUClipper.h index 3f8645a23b..6d3a5113ef 100644 --- a/include/JSystem/J3DU/J3DUClipper.h +++ b/include/JSystem/J3DU/J3DUClipper.h @@ -22,15 +22,15 @@ public: f32 getFar() { return mFar; } private: - Vec _04; - Vec _10; - Vec _1C; - Vec _28; - u8 _34[0x4C - 0x34]; - f32 mFovY; - f32 mAspect; - f32 mNear; - f32 mFar; + /* 0x04 */ Vec _04; + /* 0x10 */ Vec _10; + /* 0x1C */ Vec _1C; + /* 0x28 */ Vec _28; + /* 0x34 */ u8 _34[0x4C - 0x34]; + /* 0x4C */ f32 mFovY; + /* 0x50 */ f32 mAspect; + /* 0x54 */ f32 mNear; + /* 0x58 */ f32 mFar; }; #endif /* J3DUCLIPPER_H */ diff --git a/include/JSystem/JAudio2/JAISeMgr.h b/include/JSystem/JAudio2/JAISeMgr.h index c34adf04b5..87b31b0529 100644 --- a/include/JSystem/JAudio2/JAISeMgr.h +++ b/include/JSystem/JAudio2/JAISeMgr.h @@ -47,11 +47,7 @@ public: JAISoundParamsMove* getParams() { return &mParams; } int getMaxSe() const { - if (mMaxActiveSe == 0) { - return 0; - } - - return mMaxActiveSe + mMaxInactiveSe; + return (mMaxActiveSe == 0) ? 0 : mMaxActiveSe + mMaxInactiveSe; } int getMaxActiveSe() const { return mMaxActiveSe; } void setMaxActiveSe(int se) { mMaxActiveSe = se; } diff --git a/include/JSystem/JAudio2/JAISound.h b/include/JSystem/JAudio2/JAISound.h index 8752faca66..2ed7f20471 100644 --- a/include/JSystem/JAudio2/JAISound.h +++ b/include/JSystem/JAudio2/JAISound.h @@ -2,6 +2,7 @@ #define JAISOUND_H #include "JSystem/JAudio2/JAISoundParams.h" +#include "JSystem/JAudio2/JAIAudible.h" #include "JSystem/JGeometry.h" #include "dolphin/types.h" #include "global.h" @@ -55,6 +56,9 @@ struct JAISoundStatus_ { inline bool isMute() { return field_0x0.flags.mute; } inline bool isPaused() { return field_0x0.flags.paused; } + void pauseWhenOut() { + field_0x1.flags.flag6 = 1; + } /* 0x0 */ union { u8 value; @@ -115,10 +119,7 @@ struct JAISoundFader { } } bool isOut() { - if (mTransition.mCount != 0 || mIntensity < 0.01f) { - return true; - } - return false; + return (mTransition.mCount == 0 && mIntensity < 0.01f); } inline void calc() { mIntensity = mTransition.apply(mIntensity); } f32 getIntensity() { return mIntensity; } @@ -227,7 +228,7 @@ public: bool isStopping() { bool isStopping = false; if (status_.state.flags.flag1) { - isStopping = status_.state.flags.flag5 ? fader.isOut() : true; + isStopping = !status_.state.flags.flag5 || fader.isOut(); } return isStopping; } @@ -236,6 +237,32 @@ public: status_.field_0x0.flags.paused = param_0; } + void updateLifeTime(u32 param_0) { + if (lifeTime < param_0) { + lifeTime = param_0; + } + } + + void setLifeTime(u32 param_0, bool param_1) { + lifeTime = param_0; + setComesBack(param_1); + status_.field_0x1.flags.flag2 = 1; + } + + void setComesBack(bool param_0) { + status_.field_0x1.flags.flag1 = 1; + if (param_0) { + status_.pauseWhenOut(); + } + } + + bool setPos(const JGeometry::TVec3<f32>& param_1) { + if (audible_ != NULL) { + audible_->setPos(param_1); + } + return audible_ != NULL; + } + /* 0x04 */ JAISoundHandle* handle_; /* 0x08 */ JAIAudible* audible_; /* 0x0C */ JAIAudience* audience_; diff --git a/include/JSystem/JAudio2/JAISoundHandles.h b/include/JSystem/JAudio2/JAISoundHandles.h index 4800a94ee9..0292495742 100644 --- a/include/JSystem/JAudio2/JAISoundHandles.h +++ b/include/JSystem/JAudio2/JAISoundHandles.h @@ -36,7 +36,7 @@ public: numHandles_ = param_1; }; - void getHandleSoundID(JAISoundID); + JAISoundHandle* getHandleSoundID(JAISoundID); JAISoundHandle* getFreeHandle(); private: diff --git a/include/JSystem/JAudio2/JAISoundStarter.h b/include/JSystem/JAudio2/JAISoundStarter.h index 180efd2307..beb8e92b7f 100644 --- a/include/JSystem/JAudio2/JAISoundStarter.h +++ b/include/JSystem/JAudio2/JAISoundStarter.h @@ -6,9 +6,9 @@ struct JAISoundStarter : public JASGlobalInstance<JAISoundStarter> { /* 802A2F6C */ JAISoundStarter(bool); - /* 802A2FEC */ void startLevelSound(JAISoundID, JAISoundHandle*, JGeometry::TVec3<f32> const*); virtual ~JAISoundStarter(); + /* 802A2FEC */ bool startLevelSound(JAISoundID, JAISoundHandle*, JGeometry::TVec3<f32> const*); }; #endif /* JAISOUNDSTARTER_H */ diff --git a/include/JSystem/JAudio2/JASCalc.h b/include/JSystem/JAudio2/JASCalc.h index c9fc87dceb..5e55417350 100644 --- a/include/JSystem/JAudio2/JASCalc.h +++ b/include/JSystem/JAudio2/JASCalc.h @@ -2,5 +2,29 @@ #define JASCALC_H #include "dolphin/types.h" +#include "MSL_C/MSL_Common/Src/limits" + +struct JASCalc { + /* 8028F2E8 */ static void imixcopy(s16 const*, s16 const*, s16*, u32); + /* 8028F318 */ static void bcopyfast(void const*, void*, u32); + /* 8028F354 */ static void bcopy(void const*, void*, u32); + /* 8028F454 */ static void bzerofast(void*, u32); + /* 8028F480 */ static void bzero(void*, u32); + /* 8028F578 */ static f32 pow2(f32); + template <typename A, typename B> + static A clamp(B x); /* { + if (std::numeric_limits<A>::min() >= x) + return std::numeric_limits<A>::min(); + if (x >= std::numeric_limits<A>::max()) + return std::numeric_limits<A>::max(); + return x; + } */ + + f32 fake1(); + f32 fake2(long x); + f32 fake3(); + + static u8 const CUTOFF_TO_IIR_TABLE[1024]; +}; #endif /* JASCALC_H */ diff --git a/include/JSystem/JAudio2/JASCallback.h b/include/JSystem/JAudio2/JASCallback.h index 52061420d5..0b345f61f7 100644 --- a/include/JSystem/JAudio2/JASCallback.h +++ b/include/JSystem/JAudio2/JASCallback.h @@ -3,4 +3,33 @@ #include "dolphin/types.h" +typedef long JASCallback(void*); + +struct JASCallbackMgr { + struct TCallback { + TCallback() + : mFunction(NULL) + , mArgument(NULL) { + } + + /** @fabricated */ + bool isMatch(JASCallback* function, void* argument) { return (mFunction == function && mArgument == argument); } + + /** @fabricated */ + void clear() { + mFunction = NULL; + mArgument = NULL; + } + + /* 0x00 */ JASCallback* mFunction; + /* 0x04 */ void* mArgument; + }; + + bool regist(JASCallback*, void*); + int reject(JASCallback*, void*); + void callback(); + + /* 0x00 */ TCallback mCallbacks[0x20]; +}; + #endif /* JASCALLBACK_H */ diff --git a/include/JSystem/JAudio2/JASLfo.h b/include/JSystem/JAudio2/JASLfo.h index 0b9c738db3..35291bd5b0 100644 --- a/include/JSystem/JAudio2/JASLfo.h +++ b/include/JSystem/JAudio2/JASLfo.h @@ -3,4 +3,21 @@ #include "dolphin/types.h" +struct JASLfo { + /* 8029BD14 */ JASLfo(); + /* 8029BD44 */ f32 getValue() const; + /* 8029BDD8 */ void incCounter(f32); + /* 8029BE2C */ void resetCounter(); + + static JASLfo sFreeRunLfo; + + /* 0x00 */ u32 field_0x0; + /* 0x04 */ u32 field_0x4; + /* 0x08 */ f32 field_0x8; + /* 0x0C */ f32 field_0xC; + /* 0x10 */ f32 field_0x10; + /* 0x14 */ u16 field_0x14; + /* 0x16 */ u16 field_0x16; +}; + #endif /* JASLFO_H */ diff --git a/include/JSystem/JAudio2/JASOscillator.h b/include/JSystem/JAudio2/JASOscillator.h index 8b8adb8f92..07a4259c67 100644 --- a/include/JSystem/JAudio2/JASOscillator.h +++ b/include/JSystem/JAudio2/JASOscillator.h @@ -3,4 +3,45 @@ #include "dolphin/types.h" + +struct JASOscillator { + struct Data { + /* 0x00 */ u32 _00; + /* 0x04 */ f32 _04; + /* 0x08 */ short* _08; + /* 0x0C */ short* _0C; + /* 0x10 */ f32 _10; + /* 0x14 */ f32 _14; + }; + + JASOscillator(); + + void initStart(const Data*); + void incCounter(f32 param_0); + f32 getValue() const; + void release(); + void update(); + void updateCurrentValue(f32 param_0); + + void stop() { + _1C = 0; + } + + /* 0x00 */ const Data* mData; + /* 0x04 */ f32 _04; + /* 0x08 */ f32 _08; + /* 0x0C */ f32 _0C; + /* 0x10 */ f32 _10; + /* 0x14 */ u16 _14; + /* 0x16 */ u16 _16; + /* 0x18 */ u8 _18; + /* 0x1A */ u16 _1A; + /* 0x1C */ int _1C; + + static const f32 sCurveTableLinear[17]; + static const f32 sCurveTableSampleCell[17]; + static const f32 sCurveTableSqRoot[17]; + static const f32 sCurveTableSquare[17]; +}; + #endif /* JASOSCILLATOR_H */ diff --git a/include/JSystem/JAudio2/dspproc.h b/include/JSystem/JAudio2/dspproc.h index 5f1c530495..50c563c143 100644 --- a/include/JSystem/JAudio2/dspproc.h +++ b/include/JSystem/JAudio2/dspproc.h @@ -4,4 +4,7 @@ #include "dolphin/types.h" #include "dolphin/dsp/dsp.h" +void DsyncFrame2ch(u32 param_0, u32 param_1, u32 param_2); +void DsyncFrame4ch(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4); + #endif /* DSPPROC_H */ diff --git a/include/JSystem/JAudio2/osdsp.h b/include/JSystem/JAudio2/osdsp.h index 9336345e99..9cf2c7c610 100644 --- a/include/JSystem/JAudio2/osdsp.h +++ b/include/JSystem/JAudio2/osdsp.h @@ -3,4 +3,10 @@ #include "dolphin/types.h" +struct DSPTaskInfo; +struct STRUCT_DSP_TASK; + +extern "C" DSPTaskInfo* DSPAddTask(DSPTaskInfo*); +void DSPAddPriorTask(STRUCT_DSP_TASK*); + #endif /* OSDSP_H */ diff --git a/include/JSystem/JAudio2/osdsp_task.h b/include/JSystem/JAudio2/osdsp_task.h index f403ece1f2..ccce3c1e0f 100644 --- a/include/JSystem/JAudio2/osdsp_task.h +++ b/include/JSystem/JAudio2/osdsp_task.h @@ -2,5 +2,20 @@ #define OSDSP_TASK_H #include "dolphin/types.h" +#include "dolphin/os/OSInterrupt.h" + +struct DSPTaskInfo; + +extern DSPTaskInfo* DSP_prior_task; + +#ifdef __cplusplus +extern "C" { +#endif + +void __DSPHandler(OSInterrupt interrupt, OSContext* context); + +#ifdef __cplusplus +} +#endif #endif /* OSDSP_TASK_H */ diff --git a/include/JSystem/JMath/JMATrigonometric.h b/include/JSystem/JMath/JMATrigonometric.h index 8fd009944b..2b09c3939d 100644 --- a/include/JSystem/JMath/JMATrigonometric.h +++ b/include/JSystem/JMath/JMATrigonometric.h @@ -9,6 +9,13 @@ struct TSinCosTable { f32 sinShort(s16 v) const { return table[static_cast<u16>(v) >> 3].first; } f32 cosShort(s16 v) const { return table[static_cast<u16>(v) >> 3].second; } + + inline f32 sinLap(f32 v) { + if (v < 0.0f) { + return -table[(u16)(-8192.0f * v) & 0x1fff].first; + } + return table[(u16)(8192.0f * v) & 0x1fff].first; + } }; struct TAtanTable { @@ -41,4 +48,8 @@ inline f32 JMASSin(s16 v) { return JMASinShort(v); } +inline f32 JMASinLap(f32 v) { + return JMath::sincosTable_.sinLap(v); +} + #endif /* JMATRIGONOMETRIC_H */ diff --git a/include/MSL_C/MSL_Common/Src/limits b/include/MSL_C/MSL_Common/Src/limits new file mode 100644 index 0000000000..579f600dd4 --- /dev/null +++ b/include/MSL_C/MSL_Common/Src/limits @@ -0,0 +1,70 @@ +#ifndef _STD_LIMITS_H +#define _STD_LIMITS_H + +namespace std { +template <typename T> +class numeric_limits { +public: + inline static T min(); + inline static T max(); +}; + +template <> +class numeric_limits<char> { +public: + inline static char min() { return -0x80; } + inline static char max() { return 0x7F; } +}; + +template <> +class numeric_limits<short> { +public: + inline static short min() { return -0x8000; } + inline static short max() { return 0x7FFF; } +}; + +template <> +class numeric_limits<int> { +public: + inline static int min() { return -0x80000000; } + inline static int max() { return 0x7FFFFFFF; } +}; + +template <> +class numeric_limits<long> { +public: + inline static long min() { return -0x80000000; } + inline static long max() { return 0x7FFFFFFF; } +}; + +template <> +class numeric_limits<unsigned char> { +public: + inline static unsigned char min() { return 0x0; } + inline static unsigned char max() { return 0xFF; } +}; + +template <> +class numeric_limits<unsigned short> { +public: + inline static unsigned short min() { return 0x0; } + inline static unsigned short max() { return 0xFFFF; } +}; + +template <> +class numeric_limits<unsigned int> { +public: + inline static unsigned int min() { return 0x0; } + inline static unsigned int max() { return 0xFFFFFFFF; } +}; + +template <> +class numeric_limits<unsigned long> { +public: + inline static unsigned long min() { return 0x0; } + inline static unsigned long max() { return 0xFFFFFFFF; } +}; + +} // namespace std + +#endif
\ No newline at end of file diff --git a/include/dolphin/dsp/dsp.h b/include/dolphin/dsp/dsp.h index 3b9db17a2b..c6bf34943b 100644 --- a/include/dolphin/dsp/dsp.h +++ b/include/dolphin/dsp/dsp.h @@ -63,7 +63,7 @@ void DSPInit(void); void DSPReleaseHalt2(u32 msg); u16 DSP_CreateMap2(u32 msg); -void DSPSendCommands2(u32* msgs, u32 param_1, void (*param_2)(u16)); +int DSPSendCommands2(u32* msgs, u32 param_1, void (*param_2)(u16)); void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4); void DsetMixerLevel(f32 level); diff --git a/include/dolphin/dsp/dsp_task.h b/include/dolphin/dsp/dsp_task.h index 8b2e88ff7b..0e7ff14ed6 100644 --- a/include/dolphin/dsp/dsp_task.h +++ b/include/dolphin/dsp/dsp_task.h @@ -8,4 +8,18 @@ extern DSPTaskInfo* __DSP_last_task; extern DSPTaskInfo* __DSP_first_task; extern DSPTaskInfo* __DSP_curr_task; +#ifdef __cplusplus +extern "C" { +#endif + +void __DSP_boot_task(DSPTaskInfo* task); +void __DSP_insert_task(DSPTaskInfo* task); +void __DSP_exec_task(DSPTaskInfo* curr, DSPTaskInfo* next); +void __DSP_remove_task(DSPTaskInfo* task); + +#ifdef __cplusplus +} + +#endif + #endif /* DSP_TASK_H */ |
