diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-09-04 07:56:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-04 17:56:59 +0300 |
| commit | b45a089e15d79821b07be020db628e01a49b1fd2 (patch) | |
| tree | 948057548cc19b19d644bd4f300ca6434e6bff11 /include | |
| parent | ee8b843996f4d888903f8c125b95ec1af376877e (diff) | |
some J3D/misc cleanup (#2628)
* some j3d cleanup
* begin using uintptr_t
* j3dgraphbase cleanup
* j3dgraphanimator cleanup
Diffstat (limited to 'include')
43 files changed, 913 insertions, 668 deletions
diff --git a/include/JSystem/J2DGraph/J2DAnimation.h b/include/JSystem/J2DGraph/J2DAnimation.h index eb393c3fad..8820f36b05 100644 --- a/include/JSystem/J2DGraph/J2DAnimation.h +++ b/include/JSystem/J2DGraph/J2DAnimation.h @@ -56,10 +56,10 @@ class J2DAnmVtxColor : public J2DAnmBase { public: J2DAnmVtxColor() { mKind = KIND_VTX_COLOR; - for (s32 i = 0; i < ARRAY_SIZE(mAnmTableNum); i++) { + for (s32 i = 0; i < ARRAY_SIZEU(mAnmTableNum); i++) { mAnmTableNum[i] = NULL; } - for (s32 i = 0; i < ARRAY_SIZE(mVtxColorIndexData); i++) { + for (s32 i = 0; i < ARRAY_SIZEU(mVtxColorIndexData); i++) { mVtxColorIndexData[i] = NULL; } } @@ -88,7 +88,7 @@ struct J3DTextureSRTInfo; class J2DAnmVtxColorKey : public J2DAnmVtxColor { public: J2DAnmVtxColorKey() { - for (s32 i = 0; i < ARRAY_SIZE(mInfoTable); i++) { + for (s32 i = 0; i < ARRAY_SIZEU(mInfoTable); i++) { mInfoTable[i] = NULL; } } @@ -109,7 +109,7 @@ public: class J2DAnmVtxColorFull : public J2DAnmVtxColor { public: J2DAnmVtxColorFull() { - for (s32 i = 0; i < ARRAY_SIZE(mInfoTable); i++) { + for (s32 i = 0; i < ARRAY_SIZEU(mInfoTable); i++) { mInfoTable[i] = NULL; } } diff --git a/include/JSystem/J3DAssert.h b/include/JSystem/J3DAssert.h new file mode 100644 index 0000000000..24fe88274e --- /dev/null +++ b/include/JSystem/J3DAssert.h @@ -0,0 +1,11 @@ +#ifndef J3DASSERT_H +#define J3DASSERT_H + +#include "JSystem/JUtility/JUTAssert.h" + +#define J3D_ASSERT_NULLPTR(LINE, COND) JUT_ASSERT_MSG(LINE, (COND) != 0, "Error : null pointer.") +#define J3D_ASSERT_RANGE(LINE, COND) JUT_ASSERT_MSG(LINE, (COND) != 0, "Error : range over.") +#define J3D_ASSERT_NONZEROARG(LINE, COND) JUT_ASSERT_MSG(LINE, (COND) != 0, "Error : non-zero argument is specified 0.") +#define J3D_ASSERT_ALLOCMEM(LINE, COND) JUT_ASSERT_MSG(LINE, (COND) != 0, "Error : allocate memory.") + +#endif /* J3DASSERT_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DAnimation.h b/include/JSystem/J3DGraphAnimator/J3DAnimation.h index 58a0f1912b..1003219d24 100644 --- a/include/JSystem/J3DGraphAnimator/J3DAnimation.h +++ b/include/JSystem/J3DGraphAnimator/J3DAnimation.h @@ -476,10 +476,10 @@ public: mFrame = 0.0f; } - J3DAnmBase(s16 i_frameMax) { + J3DAnmBase(s16 frameMax) { mAttribute = 0; field_0x5 = 0; - mFrameMax = i_frameMax; + mFrameMax = frameMax; mFrame = 0.0f; } @@ -515,7 +515,7 @@ public: /* 0x18 */ s16 field_0x18; /* 0x1A */ s16 field_0x1a; /* 0x1C */ u16 field_0x1c; - /* 0x1E */ s16 field_0x1e; + /* 0x1E */ u16 field_0x1e; }; // Size: 0x20 /** @@ -533,8 +533,8 @@ public: /* 8003B8D0 */ virtual ~J3DAnmTransformKey() {} /* 8003C800 */ virtual s32 getKind() const { return 8; } - /* 8003C808 */ virtual void getTransform(u16 param_0, J3DTransformInfo* param_1) const { - calcTransform(mFrame, param_0, param_1); + /* 8003C808 */ virtual void getTransform(u16 jointNo, J3DTransformInfo* pTransform) const { + calcTransform(mFrame, jointNo, pTransform); } /* 0x20 */ int mDecShift; @@ -585,25 +585,25 @@ public: /* 8032C198 */ virtual ~J3DAnmTextureSRTKey() {} /* 8032C220 */ virtual s32 getKind() const { return 4; } - void getTransform(u16 param_0, J3DTextureSRTInfo* pSRTInfo) const { - calcTransform(getFrame(), param_0, pSRTInfo); + void getTransform(u16 jointNo, J3DTextureSRTInfo* pSRTInfo) const { + calcTransform(getFrame(), jointNo, pSRTInfo); } u16 getUpdateMaterialID(u16 idx) const { - J3D_ASSERT(1029, idx < mTrackNum / 3, "Error : range over."); + J3D_ASSERT_RANGE(1029, idx < mTrackNum / 3); return mUpdateMaterialID[idx]; } u16 getUpdateMaterialNum() const { return mTrackNum / 3; } u16 getPostUpdateMaterialNum() const { return field_0x4a / 3; } int getUpdateTexMtxID(u16 idx) const { - J3D_ASSERT(1017, idx < mTrackNum / 3, "Error : range over."); + J3D_ASSERT_RANGE(1017, idx < mTrackNum / 3); return mUpdateTexMtxID[idx]; } bool isValidUpdateMaterialID(u16 idx) const { return mUpdateMaterialID[idx] != 0xffff; } u32 getTexMtxCalcType() { return mTexMtxCalcType; } Vec* getSRTCenter(u16 idx) { - J3D_ASSERT(1047, idx < mTrackNum / 3, "Error : range over."); + J3D_ASSERT_RANGE(1047, idx < mTrackNum / 3); return &mSRTCenter[idx]; } @@ -650,7 +650,7 @@ public: /* 8032BD94 */ virtual s32 getKind() const { return 2; } u16 getUpdateMaterialID(u16 idx) const { - J3D_ASSERT(2288, idx < mUpdateMaterialNum, "Error : range over."); + J3D_ASSERT_RANGE(2288, idx < mUpdateMaterialNum); return mUpdateMaterialID[idx]; } u16 getUpdateMaterialNum() const { return mUpdateMaterialNum; } @@ -684,19 +684,19 @@ public: u16 getKRegUpdateMaterialNum() const { return mKRegUpdateMaterialNum; } u16 getCRegUpdateMaterialID(u16 idx) const { - J3D_ASSERT(2100, idx < mCRegUpdateMaterialNum, "Error : range over."); + J3D_ASSERT_RANGE(2100, idx < mCRegUpdateMaterialNum); return mCRegUpdateMaterialID[idx]; } u16 getKRegUpdateMaterialID(u16 idx) const { - J3D_ASSERT(2140, idx < mKRegUpdateMaterialNum, "Error : range over."); + J3D_ASSERT_RANGE(2140, idx < mKRegUpdateMaterialNum); return mKRegUpdateMaterialID[idx]; } - const J3DAnmCRegKeyTable* getAnmCRegKeyTable() const { return mAnmCRegKeyTable; } - const J3DAnmKRegKeyTable* getAnmKRegKeyTable() const { return mAnmKRegKeyTable; } + const J3DAnmCRegKeyTable* getAnmCRegKeyTable() { return mAnmCRegKeyTable; } + const J3DAnmKRegKeyTable* getAnmKRegKeyTable() { return mAnmKRegKeyTable; } - bool isValidCRegUpdateMaterialID(u16 idx) { return mCRegUpdateMaterialID[idx] != 0xffff; } - bool isValidKRegUpdateMaterialID(u16 idx) { return mKRegUpdateMaterialID[idx] != 0xffff; } + bool isValidCRegUpdateMaterialID(u16 idx) const { return mCRegUpdateMaterialID[idx] != 0xffff; } + bool isValidKRegUpdateMaterialID(u16 idx) const { return mKRegUpdateMaterialID[idx] != 0xffff; } /* 0x0C */ u16 mCRegUpdateMaterialNum; /* 0x0E */ u16 mKRegUpdateMaterialNum; @@ -740,7 +740,7 @@ public: u16 getUpdateMaterialNum() const { return mUpdateMaterialNum; } bool isValidUpdateMaterialID(u16 id) const { return mUpdateMaterialID[id] != 0xFFFF; } u16 getUpdateMaterialID(u16 idx) const { - J3D_ASSERT(1578, idx < mUpdateMaterialNum, "Error : range over."); + J3D_ASSERT_RANGE(1578, idx < mUpdateMaterialNum); return mUpdateMaterialID[idx]; } @@ -851,7 +851,7 @@ public: */ class J3DAnmCluster : public J3DAnmBase { public: - J3DAnmCluster(s16 param_1, f32* param_2) : J3DAnmBase(param_1) { mWeight = param_2; } + J3DAnmCluster(s16 frameMax, f32* pWeight) : J3DAnmBase(frameMax) { mWeight = pWeight; } /* 8032BCAC */ virtual ~J3DAnmCluster() {} /* 8032BF44 */ virtual s32 getKind() const { return 3; } @@ -866,7 +866,7 @@ public: */ class J3DAnmClusterFull : public J3DAnmCluster { public: - J3DAnmClusterFull() : J3DAnmCluster(0, 0) { mAnmTable = NULL; } + J3DAnmClusterFull() : J3DAnmCluster(0, NULL) { mAnmTable = NULL; } /* 8032BCAC */ virtual ~J3DAnmClusterFull() {} /* 8032BF44 */ virtual s32 getKind() const { return 12; } @@ -965,10 +965,10 @@ public: }; // Size: 0x14 struct J3DMtxCalcAnmBase: public J3DMtxCalc { - J3DMtxCalcAnmBase(J3DAnmTransform* param_0) { mAnmTransform = param_0; } + J3DMtxCalcAnmBase(J3DAnmTransform* pAnmTransform) { mAnmTransform = pAnmTransform; } /* 8000D8EC */ ~J3DMtxCalcAnmBase() {} /* 80014FB8 */ J3DAnmTransform* getAnmTransform() { return mAnmTransform; } - /* 80014FC0 */ void setAnmTransform(J3DAnmTransform* param_0) { mAnmTransform = param_0; } + /* 80014FC0 */ void setAnmTransform(J3DAnmTransform* pAnmTransform) { mAnmTransform = pAnmTransform; } J3DAnmTransform* mAnmTransform; }; @@ -980,29 +980,33 @@ struct J3DMtxCalcAnimationAdaptorBase { template <typename A0> struct J3DMtxCalcAnimationAdaptorDefault : public J3DMtxCalcAnimationAdaptorBase { - J3DMtxCalcAnimationAdaptorDefault(J3DAnmTransform* param_0) {} - void calc(J3DMtxCalcAnmBase* param_0) { + J3DMtxCalcAnimationAdaptorDefault(J3DAnmTransform* pAnmTransform) {} + + void calc(J3DMtxCalcAnmBase* pMtxCalc) { J3DTransformInfo transform; J3DTransformInfo* transform_p; - if (param_0->getAnmTransform() != NULL) { + if (pMtxCalc->getAnmTransform() != NULL) { u16 jnt_no = J3DMtxCalc::getJoint()->getJntNo(); - param_0->getAnmTransform()->getTransform(jnt_no, &transform); + pMtxCalc->getAnmTransform()->getTransform(jnt_no, &transform); transform_p = &transform; } else { transform_p = &J3DMtxCalc::getJoint()->getTransformInfo(); } + A0::calcTransform(*transform_p); } }; template <typename A0, typename B0> struct J3DMtxCalcAnimation : public J3DMtxCalcAnmBase { - J3DMtxCalcAnimation(J3DAnmTransform* param_0) : J3DMtxCalcAnmBase(param_0), field_0x8(param_0) {} + J3DMtxCalcAnimation(J3DAnmTransform* pAnmTransform) : J3DMtxCalcAnmBase(pAnmTransform), field_0x8(pAnmTransform) {} ~J3DMtxCalcAnimation() {} - void setAnmTransform(J3DAnmTransform* param_0) { - mAnmTransform = param_0; - field_0x8.change(param_0); + + void setAnmTransform(J3DAnmTransform* pAnmTransform) { + mAnmTransform = pAnmTransform; + field_0x8.change(pAnmTransform); } + void init(const Vec& param_0, const Mtx& param_1) { B0::init(param_0, param_1); } void calc() { field_0x8.calc(this); } diff --git a/include/JSystem/J3DGraphAnimator/J3DCluster.h b/include/JSystem/J3DGraphAnimator/J3DCluster.h index ded3d1a2ca..0ef5185db8 100644 --- a/include/JSystem/J3DGraphAnimator/J3DCluster.h +++ b/include/JSystem/J3DGraphAnimator/J3DCluster.h @@ -1,8 +1,7 @@ #ifndef J3DCLUSTER_H #define J3DCLUSTER_H -#include "JSystem/JUtility/JUTAssert.h" -#include "dolphin/types.h" +#include "JSystem/J3DAssert.h" class J3DDeformer; class J3DClusterKey; @@ -81,13 +80,13 @@ public: /* 8032E364 */ void setAnm(J3DAnmCluster*); J3DCluster* getClusterPointer(u16 index) { - J3D_ASSERT(186, (index < mClusterNum), "Error : range over."); + J3D_ASSERT_RANGE(186, (index < mClusterNum)); return &mClusterPointer[index]; } u16 getClusterNum() const { return mClusterNum; } u16 getClusterKeyNum() const { return mClusterKeyNum; } J3DClusterKey* getClusterKeyPointer(u16 i) { - J3D_ASSERT(199, (i < mClusterKeyNum), "Error : range over."); + J3D_ASSERT_RANGE(199, (i < mClusterKeyNum)); return &mClusterKeyPointer[i]; } f32* getVtxPos() { return mVtxPos; } diff --git a/include/JSystem/J3DGraphAnimator/J3DJoint.h b/include/JSystem/J3DGraphAnimator/J3DJoint.h index ccd676967a..b20b48d792 100644 --- a/include/JSystem/J3DGraphAnimator/J3DJoint.h +++ b/include/JSystem/J3DGraphAnimator/J3DJoint.h @@ -3,6 +3,7 @@ #include "JSystem/J3DGraphBase/J3DTransform.h" #include "JSystem/J3DGraphBase/J3DSys.h" +#include "JSystem/J3DGraphBase/J3DMaterial.h" class J3DAnmTransform; class J3DJoint; @@ -29,7 +30,7 @@ public: static J3DMtxBuffer* getMtxBuffer() { return mMtxBuffer; } static J3DJoint* getJoint() { - J3D_ASSERT(185, mJoint != NULL, "Error : null pointer.") + J3D_ASSERT_NULLPTR(185, mJoint != NULL) return mJoint; } static void setJoint(J3DJoint* joint) { mJoint = joint; } @@ -51,7 +52,17 @@ public: /* 8032F254 */ void entryIn(); /* 8032F3F8 */ void recursiveCalc(); + u32 getType() const { return 'NJNT'; } + J3DMaterial* getMesh() { return mMesh; } + void addMesh(J3DMaterial* pMesh) { + if (mMesh != NULL) { + pMesh->setNext(mMesh); + } + + mMesh = pMesh; + } + u16 getJntNo() const { return mJntNo; } u8 getScaleCompensate() const { return mScaleCompensate; } J3DJoint* getYounger() { return mYounger; } @@ -67,13 +78,13 @@ public: J3DMtxCalc* getMtxCalc() { return mMtxCalc; } J3DMtxCalc* getCurrentMtxCalc() { return mCurrentMtxCalc; }; J3DJoint* getChild() { return mChild; } - u8 getMtxType() { return (mKind & 0xf0) >> 4; } + u8 getMtxType() const { return (mKind & 0xf0) >> 4; } void setMtxType(u8 type) { mKind = (mKind & ~0xf0) | (type << 4); } f32 getRadius() const { return mBoundingSphereRadius; } static J3DMtxCalc* mCurrentMtxCalc; - inline u8 getKind() { return mKind & 15; } + u8 getKind() { return mKind & 15; } private: friend struct J3DJointFactory; diff --git a/include/JSystem/J3DGraphAnimator/J3DJointTree.h b/include/JSystem/J3DGraphAnimator/J3DJointTree.h index 01c55620bd..1b959ecbb8 100644 --- a/include/JSystem/J3DGraphAnimator/J3DJointTree.h +++ b/include/JSystem/J3DGraphAnimator/J3DJointTree.h @@ -64,14 +64,14 @@ public: JUTNameTab* getJointName() const { return mJointName; } J3DJoint* getRootNode() { return mRootNode; } J3DJoint* getJointNodePointer(u16 idx) const { - J3D_ASSERT(139, idx < mJointNum, "Error : range over."); + J3D_ASSERT_RANGE(139, idx < mJointNum); return mJointNodePointer[idx]; } - J3DMtxCalc* getBasicMtxCalc() const { return mBasicMtxCalc; } + J3DMtxCalc* getBasicMtxCalc() { return mBasicMtxCalc; } Mtx& getInvJointMtx(int idx) { return mInvJointMtx[idx]; } u32 getModelDataType() const { return mModelDataType; } void setModelDataType(u32 type) { mModelDataType = type; } - bool checkFlag(u32 flag) { return mFlags & flag; } + bool checkFlag(u32 flag) const { return mFlags & flag ? true : false; } void setFlag(u32 flag) { mFlags = flag; } private: diff --git a/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h b/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h index e77a550462..43f6a577da 100644 --- a/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h +++ b/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h @@ -3,9 +3,6 @@ #include "JSystem/J3DGraphAnimator/J3DAnimation.h" -typedef struct _GXColor GXColor; -typedef struct _GXColorS10 GXColorS10; - /** * @ingroup jsystem-j3d * @@ -13,11 +10,14 @@ typedef struct _GXColorS10 GXColorS10; class J3DMatColorAnm { public: /* 8003B2B8 */ ~J3DMatColorAnm() {} + /* 8003B2F4 */ J3DMatColorAnm() : field_0x0(0), mAnmFlag(1), mAnmColor(NULL) {} - J3DMatColorAnm(u16 param_1, J3DAnmColor* param_2) { + + J3DMatColorAnm(u16 param_1, J3DAnmColor* pAnmColor) { field_0x0 = param_1; mAnmFlag = 1; - mAnmColor = param_2; + mAnmColor = pAnmColor; + J3D_ASSERT_NULLPTR(56, pAnmColor != NULL); } void operator=(J3DMatColorAnm const& other) { @@ -28,7 +28,11 @@ public: void setAnmFlag(bool flag) { mAnmFlag = flag; } bool getAnmFlag() const { return mAnmFlag; } - void calc(_GXColor* pColor) const { mAnmColor->getColor(field_0x0, pColor); } + + void calc(GXColor* pColor) const { + J3D_ASSERT_NULLPTR(507, pColor != NULL); + mAnmColor->getColor(field_0x0, pColor); + } private: /* 0x0 */ u16 field_0x0; @@ -40,15 +44,55 @@ private: * @ingroup jsystem-j3d * */ +class J3DTexMtxAnm { +public: + /* 8003B264 */ ~J3DTexMtxAnm() {} + /* 8003B2A0 */ J3DTexMtxAnm() : field_0x0(0), mAnmFlag(1), mAnmTransform(NULL) {} + + J3DTexMtxAnm(u16 param_1, J3DAnmTextureSRTKey* pSRTKey) { + field_0x0 = param_1; + mAnmFlag = 1; + mAnmTransform = pSRTKey; + J3D_ASSERT_NULLPTR(134, pSRTKey != NULL); + } + + void operator=(J3DTexMtxAnm const& other) { + mAnmTransform = other.mAnmTransform; + field_0x0 = other.field_0x0; + mAnmFlag = other.mAnmFlag; + } + + void setAnmFlag(bool flag) { mAnmFlag = flag; } + + void calc(J3DTextureSRTInfo* pSRTInfo) const { + J3D_ASSERT_NULLPTR(519, pSRTInfo != NULL); + mAnmTransform->getTransform(field_0x0, pSRTInfo); + } + + bool getAnmFlag() const { return mAnmFlag; } + +private: + /* 0x0 */ u16 field_0x0; + /* 0x2 */ u16 mAnmFlag; + /* 0x4 */ J3DAnmTextureSRTKey* mAnmTransform; +}; // Size: 0x8 + +/** + * @ingroup jsystem-j3d + * + */ class J3DTexNoAnm { public: /* 8003B1F8 */ ~J3DTexNoAnm() {} /* 8003B240 */ J3DTexNoAnm() : field_0x4(0), mAnmFlag(1), mAnmTexPattern(NULL) {} - J3DTexNoAnm(u16 param_1, J3DAnmTexPattern* param_2) { + + J3DTexNoAnm(u16 param_1, J3DAnmTexPattern* pAnmTexPattern) { field_0x4 = param_1; mAnmFlag = 1; - mAnmTexPattern = param_2; + mAnmTexPattern = pAnmTexPattern; + J3D_ASSERT_NULLPTR(214, pAnmTexPattern != NULL); } + /* 8003C82C */ virtual void calc(u16* param_0) const { mAnmTexPattern->getTexNo(field_0x4, param_0); } void operator=(J3DTexNoAnm const& other) { @@ -71,32 +115,36 @@ private: * @ingroup jsystem-j3d * */ -class J3DTexMtxAnm { +class J3DTevColorAnm { public: - /* 8003B264 */ ~J3DTexMtxAnm() {} - /* 8003B2A0 */ J3DTexMtxAnm() : field_0x0(0), mAnmFlag(1), mAnmTransform(NULL) {} - J3DTexMtxAnm(u16 param_1, J3DAnmTextureSRTKey* param_2) { + /* 8003B1A4 */ ~J3DTevColorAnm() {} + /* 8003B1E0 */ J3DTevColorAnm() : field_0x0(0), mAnmFlag(1), mAnmTevReg(NULL) {} + + J3DTevColorAnm(u16 param_1, J3DAnmTevRegKey* pTevRegKey) { field_0x0 = param_1; mAnmFlag = 1; - mAnmTransform = param_2; + mAnmTevReg = pTevRegKey; + J3D_ASSERT_NULLPTR(293, pTevRegKey != NULL); } - void operator=(J3DTexMtxAnm const& other) { - mAnmTransform = other.mAnmTransform; + void operator=(J3DTevColorAnm const& other) { + mAnmTevReg = other.mAnmTevReg; field_0x0 = other.field_0x0; mAnmFlag = other.mAnmFlag; } void setAnmFlag(bool flag) { mAnmFlag = flag; } - void calc(J3DTextureSRTInfo* pSRTInfo) const { - mAnmTransform->getTransform(field_0x0, pSRTInfo); - } bool getAnmFlag() const { return mAnmFlag; } + void calc(GXColorS10* pColor) const { + J3D_ASSERT_NULLPTR(545, pColor != NULL); + mAnmTevReg->getTevColorReg(field_0x0, pColor); + } + private: /* 0x0 */ u16 field_0x0; /* 0x2 */ u16 mAnmFlag; - /* 0x4 */ J3DAnmTextureSRTKey* mAnmTransform; + /* 0x4 */ J3DAnmTevRegKey* mAnmTevReg; }; // Size: 0x8 /** @@ -107,10 +155,12 @@ class J3DTevKColorAnm { public: /* 8003B150 */ ~J3DTevKColorAnm() {} /* 8003B18C */ J3DTevKColorAnm() : field_0x0(0), mAnmFlag(1), mAnmTevReg(NULL) {} - J3DTevKColorAnm(u16 param_1, J3DAnmTevRegKey* param_2) { + + J3DTevKColorAnm(u16 param_1, J3DAnmTevRegKey* pTevRegKey) { field_0x0 = param_1; mAnmFlag = 1; - mAnmTevReg = param_2; + mAnmTevReg = pTevRegKey; + J3D_ASSERT_NULLPTR(371, pTevRegKey != NULL); } void operator=(J3DTevKColorAnm const& other) { @@ -121,38 +171,12 @@ public: void setAnmFlag(bool flag) { mAnmFlag = flag; } bool getAnmFlag() const { return mAnmFlag; } - void calc(_GXColor* pColor) const { mAnmTevReg->getTevKonstReg(field_0x0, pColor); } - -private: - /* 0x0 */ u16 field_0x0; - /* 0x2 */ u16 mAnmFlag; - /* 0x4 */ J3DAnmTevRegKey* mAnmTevReg; -}; // Size: 0x8 -/** - * @ingroup jsystem-j3d - * - */ -class J3DTevColorAnm { -public: - /* 8003B1A4 */ ~J3DTevColorAnm() {} - /* 8003B1E0 */ J3DTevColorAnm() : field_0x0(0), mAnmFlag(1), mAnmTevReg(NULL) {} - J3DTevColorAnm(u16 param_1, J3DAnmTevRegKey* param_2) { - field_0x0 = param_1; - mAnmFlag = 1; - mAnmTevReg = param_2; - } - - void operator=(J3DTevColorAnm const& other) { - mAnmTevReg = other.mAnmTevReg; - field_0x0 = other.field_0x0; - mAnmFlag = other.mAnmFlag; + void calc(GXColor* pColor) const { + J3D_ASSERT_NULLPTR(558, pColor != NULL); + mAnmTevReg->getTevKonstReg(field_0x0, pColor); } - void setAnmFlag(bool flag) { mAnmFlag = flag; } - bool getAnmFlag() const { return mAnmFlag; } - void calc(_GXColorS10* pColor) const { mAnmTevReg->getTevColorReg(field_0x0, pColor); } - private: /* 0x0 */ u16 field_0x0; /* 0x2 */ u16 mAnmFlag; diff --git a/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h b/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h index eb53887ea4..028c81b87c 100644 --- a/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h +++ b/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h @@ -1,8 +1,7 @@ #ifndef J3DMATERIALATTACH_H #define J3DMATERIALATTACH_H -#include "JSystem/JUtility/JUTAssert.h" -#include "dolphin/types.h" +#include "JSystem/J3DAssert.h" class J3DMaterial; class J3DTexture; @@ -33,7 +32,7 @@ public: /* 8032F604 */ virtual ~J3DMaterialTable(); J3DMaterial* getMaterialNodePointer(u16 idx) const { - J3D_ASSERT(92, idx < mMaterialNum, "Error : range over."); + J3D_ASSERT_RANGE(92, idx < mMaterialNum); return mMaterialNodePointer[idx]; } diff --git a/include/JSystem/J3DGraphAnimator/J3DModel.h b/include/JSystem/J3DGraphAnimator/J3DModel.h index 9e412af352..b21abd212f 100644 --- a/include/JSystem/J3DGraphAnimator/J3DModel.h +++ b/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -6,15 +6,15 @@ #include "dolphin/types.h" enum J3DMdlFlag { - J3DMdlFlag_None = 0x0, - /* 0x00001 */ J3DMdlFlag_Unk00001 = 0x1, - /* 0x00002 */ J3DMdlFlag_Unk00002 = 0x2, - /* 0x00004 */ J3DMdlFlag_SkinPosCpu = 0x4, - /* 0x00008 */ J3DMdlFlag_SkinNrmCpu = 0x8, - /* 0x00010 */ J3DMdlFlag_Unk00010 = 0x10, - /* 0x20000 */ J3DMdlFlag_Unk20000 = 0x20000, - /* 0x40000 */ J3DMdlFlag_Unk40000 = 0x40000, - /* 0x80000 */ J3DMdlFlag_Unk80000 = 0x80000, + J3DMdlFlag_None = 0x0, + /* 0x00001 */ J3DMdlFlag_Unk1 = 0x1, + /* 0x00002 */ J3DMdlFlag_UseDefaultJ3D = 0x2, + /* 0x00004 */ J3DMdlFlag_SkinPosCpu = 0x4, + /* 0x00008 */ J3DMdlFlag_SkinNrmCpu = 0x8, + /* 0x00010 */ J3DMdlFlag_EnableLOD = 0x10, + /* 0x20000 */ J3DMdlFlag_UseSharedDL = 0x20000, + /* 0x40000 */ J3DMdlFlag_UseSingleDL = 0x40000, + /* 0x80000 */ J3DMdlFlag_DifferedDLBuffer = 0x80000, }; /** @@ -45,9 +45,10 @@ public: J3DModel() { initialize(); } - J3DModel(J3DModelData* param_0, u32 param_1, u32 param_2) { + + J3DModel(J3DModelData* pModelData, u32 mdlFlags, u32 mtxBufferFlag) { initialize(); - entryModelData(param_0, param_1, param_2); + entryModelData(pModelData, mdlFlags, mtxBufferFlag); } /* 80327100 */ void initialize(); @@ -66,6 +67,8 @@ public: /* 803281B4 */ void calcBumpMtx(); /* 803282B8 */ void calcBBoardMtx(); /* 803282EC */ void prepareShapePackets(); + void ptrToIndex(); + void makeDL(); /* 80327CA4 */ virtual void update(); /* 80327E4C */ virtual void entry(); @@ -85,21 +88,22 @@ public: Mtx& getBaseTRMtx() { return mBaseTransformMtx; } void setBaseTRMtx(Mtx m) { MTXCopy(m, mBaseTransformMtx); } - u32 getMtxCalcMode() const { return mFlags & 0x03; } + u32 getMtxCalcMode() { return mFlags & (J3DMdlFlag_Unk1 | J3DMdlFlag_UseDefaultJ3D); } J3DVertexBuffer* getVertexBuffer() { return (J3DVertexBuffer*)&mVertexBuffer; } J3DMatPacket* getMatPacket(u16 idx) const { return &mMatPacket[idx]; } J3DShapePacket* getShapePacket(u16 idx) const { return &mShapePacket[idx]; } - J3DMtxBuffer* getMtxBuffer() const { return mMtxBuffer; } + J3DMtxBuffer* getMtxBuffer() { return mMtxBuffer; } void setScaleFlag(int idx, u8 flag) { mMtxBuffer->setScaleFlag(idx, flag); } - Mtx33* getBumpMtxPtr(int idx) const { return mMtxBuffer->getBumpMtxPtr(idx); } - Mtx33* getNrmMtxPtr() const { return mMtxBuffer->getNrmMtxPtr(); } - Mtx* getDrawMtxPtr() const { return mMtxBuffer->getDrawMtxPtr(); } + Mtx33* getBumpMtxPtr(int idx) { return mMtxBuffer->getBumpMtxPtr(idx); } + Mtx33* getNrmMtxPtr() { return mMtxBuffer->getNrmMtxPtr(); } + Mtx* getDrawMtxPtr() { return mMtxBuffer->getDrawMtxPtr(); } void setBaseScale(const Vec& scale) { mBaseScale = scale; } void setUserArea(u32 area) { mUserArea = area; } u32 getUserArea() const { return mUserArea; } Vec* getBaseScale() { return &mBaseScale; } void setAnmMtx(int jointNo, Mtx m) { mMtxBuffer->setAnmMtx(jointNo, m); } MtxP getAnmMtx(int jointNo) { return mMtxBuffer->getAnmMtx(jointNo); } + MtxP getWeightAnmMtx(int i) { return mMtxBuffer->getWeightAnmMtx(i); } J3DSkinDeform* getSkinDeform() { return mSkinDeform; } /* 0x04 */ J3DModelData* mModelData; diff --git a/include/JSystem/J3DGraphAnimator/J3DModelData.h b/include/JSystem/J3DGraphAnimator/J3DModelData.h index f6a57b7030..643d1f7849 100644 --- a/include/JSystem/J3DGraphAnimator/J3DModelData.h +++ b/include/JSystem/J3DGraphAnimator/J3DModelData.h @@ -8,7 +8,6 @@ #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DVertex.h" -typedef struct _GXColor GXColor; class JUTNameTab; /** @@ -68,7 +67,7 @@ public: bool checkFlag(u32 flag) const { return (mFlags & flag) ? true : false; } u32 getFlag() const { return mFlags; } void const* getRawData() const { return mpRawData; } - u16 checkBumpFlag() const { return mbHasBumpArray; } + bool checkBumpFlag() const { return mbHasBumpArray == 1; } void setBumpFlag(u32 flag) { mbHasBumpArray = flag; } bool checkBBoardFlag() const { return mbHasBillboard == 1; } bool isLocked() { return mMaterialTable.isLocked(); } diff --git a/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h b/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h index 5f9d4da047..00f401d673 100644 --- a/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h +++ b/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h @@ -25,28 +25,28 @@ public: /* 80326D3C */ void calcNrmMtx(); /* 80326EF0 */ void calcBBoardMtx(); - MtxP getAnmMtx(int idx) const { return mpAnmMtx[idx]; } + MtxP getAnmMtx(int idx) { return mpAnmMtx[idx]; } void setAnmMtx(int i, Mtx m) { MTXCopy(m, (MtxP)mpAnmMtx[i]); } - MtxP getWeightAnmMtx(int idx) const { return mpWeightEvlpMtx[idx]; } - MtxP getUserAnmMtx(int idx) const { return mpUserAnmMtx[idx]; } + MtxP getWeightAnmMtx(int idx) { return mpWeightEvlpMtx[idx]; } + MtxP getUserAnmMtx(int idx) { return mpUserAnmMtx[idx]; } void setScaleFlag(int idx, u8 flag) { mpScaleFlagArr[idx] = flag; } u32* getCurrentViewNoPtr() { return &mCurrentViewNo; } u8* getScaleFlagArray() const { return mpScaleFlagArr; } u8 getScaleFlag(int idx) const { return mpScaleFlagArr[idx]; } u8 getEnvScaleFlag(int idx) const { return mpEvlpScaleFlagArr[idx]; } - Mtx** getDrawMtxPtrPtr() const { return mpDrawMtxArr[1]; } - Mtx* getDrawMtxPtr() const { return mpDrawMtxArr[1][mCurrentViewNo]; } - Mtx* getDrawMtx(int idx) const { return &mpDrawMtxArr[1][mCurrentViewNo][idx]; } - Mtx33** getNrmMtxPtrPtr() const { return mpNrmMtxArr[1]; } - Mtx33* getNrmMtxPtr() const { return mpNrmMtxArr[1][mCurrentViewNo]; } - Mtx33* getNrmMtx(u16 idx) const { return &mpNrmMtxArr[1][mCurrentViewNo][idx]; } + Mtx** getDrawMtxPtrPtr() { return mpDrawMtxArr[1]; } + Mtx* getDrawMtxPtr() { return mpDrawMtxArr[1][mCurrentViewNo]; } + Mtx* getDrawMtx(int idx) { return &mpDrawMtxArr[1][mCurrentViewNo][idx]; } + Mtx33** getNrmMtxPtrPtr() { return mpNrmMtxArr[1]; } + Mtx33* getNrmMtxPtr() { return mpNrmMtxArr[1][mCurrentViewNo]; } + Mtx33* getNrmMtx(int idx) { return &mpNrmMtxArr[1][mCurrentViewNo][idx]; } Mtx33*** getBumpMtxPtrPtr() const { return mpBumpMtxArr[1]; } - Mtx33* getBumpMtxPtr(int idx) const { return mpBumpMtxArr[1][idx][mCurrentViewNo]; } + Mtx33* getBumpMtxPtr(int idx) { return mpBumpMtxArr[1][idx][mCurrentViewNo]; } J3DJointTree* getJointTree() const { return mJointTree; } - void setNrmMtx(int idx, Mtx* mtx) { - J3DPSMtx33CopyFrom34(*mtx, mpNrmMtxArr[1][mCurrentViewNo][idx]); + void setNrmMtx(int idx, Mtx mtx) { + J3DPSMtx33CopyFrom34(mtx, mpNrmMtxArr[1][mCurrentViewNo][idx]); } void swapDrawMtx() { @@ -66,7 +66,6 @@ public: static Mtx* sNoUseDrawMtxPtr; static Mtx33* sNoUseNrmMtxPtr; -private: /* 0x00 */ J3DJointTree* mJointTree; /* 0x04 */ u8* mpScaleFlagArr; /* 0x08 */ u8* mpEvlpScaleFlagArr; @@ -75,7 +74,7 @@ private: /* 0x14 */ Mtx** mpDrawMtxArr[2]; /* 0x1C */ Mtx33** mpNrmMtxArr[2]; /* 0x24 */ Mtx33*** mpBumpMtxArr[2]; - /* 0x2C */ u32 mFlags; + /* 0x2C */ u32 mMtxNum; /* 0x30 */ u32 mCurrentViewNo; /* 0x34 */ Mtx* mpUserAnmMtx; diff --git a/include/JSystem/J3DGraphAnimator/J3DShapeTable.h b/include/JSystem/J3DGraphAnimator/J3DShapeTable.h index 6754b6f83a..6446979e32 100644 --- a/include/JSystem/J3DGraphAnimator/J3DShapeTable.h +++ b/include/JSystem/J3DGraphAnimator/J3DShapeTable.h @@ -27,7 +27,7 @@ public: u16 getShapeNum() const { return mShapeNum; } J3DShape* getShapeNodePointer(u16 idx) const { - J3D_ASSERT(85, idx < mShapeNum, "Error : range over."); + J3D_ASSERT_RANGE(85, idx < mShapeNum); return mShapeNodePointer[idx]; } diff --git a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h index 5e03122ce3..d9b743a96c 100644 --- a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h +++ b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h @@ -53,14 +53,14 @@ public: Mtx3P getNrmMtx(int i) { return mNrmMtx[i]; } void onFlag(u32 flag) { mFlags |= flag; } void offFlag(u32 flag) { mFlags &= ~flag; } - bool checkFlag(u32 flag) { return mFlags & flag; } + bool checkFlag(u32 flag) { return mFlags & flag ? true : false; } /* 8032E064 */ virtual void deform(J3DVertexBuffer*, J3DMtxBuffer*); /* 8032E1B0 */ virtual ~J3DSkinDeform(); static u16* sWorkArea_WEvlpMixMtx[1024]; static f32* sWorkArea_WEvlpMixWeight[1024]; - static u16 sWorkArea_MtxReg[1024 + 4 /* padding */]; + static u16 sWorkArea_MtxReg[1024]; private: /* 0x04 */ u16* mPosData; @@ -89,7 +89,7 @@ public: /* 8032EBCC */ void normalizeWeight(int, f32*); void offFlag(u32 i_flag) { mFlags &= ~i_flag; } - bool checkFlag(u32 i_flag) { return mFlags & i_flag; } + bool checkFlag(u32 i_flag) { return mFlags & i_flag ? true : false; } void setAnmCluster(J3DAnmCluster* anm) { mAnmCluster = anm; } void normalize(f32* i_vec) { VECNormalize((Vec*)i_vec, (Vec*)i_vec); } diff --git a/include/JSystem/J3DGraphBase/J3DDrawBuffer.h b/include/JSystem/J3DGraphBase/J3DDrawBuffer.h index e58be9e6a9..1cc88b4079 100644 --- a/include/JSystem/J3DGraphBase/J3DDrawBuffer.h +++ b/include/JSystem/J3DGraphBase/J3DDrawBuffer.h @@ -33,8 +33,23 @@ class J3DDrawPacket; class J3DMatPacket; class J3DShapePacket; -typedef int (J3DDrawBuffer::*sortFunc)(J3DMatPacket*); -typedef void (J3DDrawBuffer::*drawFunc)() const; +enum J3DDrawBufDrawMode { + J3DDrawBufDrawMode_Head, + J3DDrawBufDrawMode_Tail, + + J3DDrawBufDrawMode_MAX, +}; + +enum J3DDrawBufSortMode { + J3DDrawBufSortMode_Mat, + J3DDrawBufSortMode_MatAnm, + J3DDrawBufSortMode_Z, + J3DDrawBufSortMode_Model, + J3DDrawBufSortMode_Invalid, + J3DDrawBufSortMode_Non, + + J3DDrawBufSortMode_MAX, +}; /** * @ingroup jsystem-j3d @@ -42,24 +57,13 @@ typedef void (J3DDrawBuffer::*drawFunc)() const; */ class J3DDrawBuffer { public: - enum EDrawType { - DRAW_HEAD, - DRAW_TAIL, - }; - - enum ESortType { - SORT_MAT, - SORT_MAT_ANM, - SORT_Z, - SORT_MODEL, - SORT_INVALID, - SORT_NON, - }; + typedef int (J3DDrawBuffer::*sortFunc)(J3DMatPacket*); + typedef void (J3DDrawBuffer::*drawFunc)() const; J3DDrawBuffer() { initialize(); } ~J3DDrawBuffer(); void initialize(); - J3DError allocBuffer(u32); + int allocBuffer(u32); void frameInit(); int entryMatSort(J3DMatPacket*); int entryMatAnmSort(J3DMatPacket*); @@ -72,18 +76,19 @@ public: void drawHead() const; void drawTail() const; - u32 getEntryTableSize() { return mBufSize; } + u32 getEntryTableSize() { return mEntryTableSize; } + int getSortMode() { return mSortMode; } inline void calcZRatio(); - void setNonSort() { mSortType = 5; } - void setZSort() { mSortType = 2; } + void setNonSort() { mSortMode = J3DDrawBufSortMode_Non; } + void setZSort() { mSortMode = J3DDrawBufSortMode_Z; } void setZMtx(MtxP mtx) { mpZMtx = mtx; } public: - /* 0x00 */ J3DPacket** mpBuf; - /* 0x04 */ u32 mBufSize; - /* 0x08 */ u32 mDrawType; - /* 0x0C */ u32 mSortType; + /* 0x00 */ J3DPacket** mpBuffer; + /* 0x04 */ u32 mEntryTableSize; + /* 0x08 */ u32 mDrawMode; + /* 0x0C */ u32 mSortMode; /* 0x10 */ f32 mZNear; /* 0x14 */ f32 mZFar; /* 0x18 */ f32 mZRatio; diff --git a/include/JSystem/J3DGraphBase/J3DFifo.h b/include/JSystem/J3DGraphBase/J3DFifo.h new file mode 100644 index 0000000000..c93943864c --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DFifo.h @@ -0,0 +1,67 @@ +#ifndef J3DFIFO_H +#define J3DFIFO_H + +#include <dolphin/gx.h> +#include <dolphin/gd.h> + +inline void J3DFifoLoadBPCmd(u32 regval) { + GXCmd1u8(GX_LOAD_BP_REG); + GXCmd1u32(regval); +} + +inline void J3DFifoWriteXFCmdHdr(u16 addr, u8 len) { + GXCmd1u8(GX_LOAD_XF_REG); + GXCmd1u16(len - 1); + GXCmd1u16(addr); +} + +inline void J3DFifoLoadIndx(u8 cmd, u16 indx, u16 addr) { + GXWGFifo.u8 = cmd; + GXWGFifo.u16 = indx; + GXWGFifo.u16 = addr; +} + +inline void J3DFifoWriteCPCmd(u8 cmd, u32 param) { + GXWGFifo.u8 = GX_LOAD_CP_REG; + GXWGFifo.u8 = cmd; + GXWGFifo.u32 = param; +} + +inline void J3DFifoLoadCPCmd(u8 reg, u32 value) { + GXCmd1u8(GX_LOAD_CP_REG); + GXCmd1u8(reg); + GXCmd1u32(value); +} + +inline void J3DFifoWriteXFCmd(u16 cmd, u16 len) { + GXWGFifo.u8 = GX_LOAD_XF_REG; + GXWGFifo.u16 = (len - 1); + GXWGFifo.u16 = cmd; +} + +inline void J3DFifoLoadXFCmdHdr(u16 addr, u8 len) { + GXCmd1u8(GX_LOAD_XF_REG); + GXCmd1u16(len - 1); + GXCmd1u16(addr); +} + +inline void J3DFifoLoadPosMtxIndx(u16 index, u32 addr) { + GXCmd1u8(GX_LOAD_INDX_A); + GXCmd1u16(index); + GXCmd1u16(((sizeof(Vec) - 1) << 12) | (u16)(addr * 4)); +} + +inline void J3DFifoLoadNrmMtxIndx3x3(u16 index, u32 addr) { + GXCmd1u8(GX_LOAD_INDX_B); + GXCmd1u16(index); + GXCmd1u16(((9 - 1) << 12) | (u16)((addr * 3) + 0x400)); +} + +void J3DFifoLoadPosMtxImm(f32 (*)[4], u32); +void J3DFifoLoadNrmMtxImm(f32 (*)[4], u32); +void J3DFifoLoadNrmMtxImm3x3(f32 (*)[3], u32); +void J3DFifoLoadNrmMtxToTexMtx(f32 (*)[4], u32); +void J3DFifoLoadNrmMtxToTexMtx3x3(f32 (*)[3], u32); +void J3DFifoLoadTexCached(GXTexMapID, u32, GXTexCacheSize, u32, GXTexCacheSize); + +#endif /* J3DFIFO_H */ diff --git a/include/JSystem/J3DGraphBase/J3DGD.h b/include/JSystem/J3DGraphBase/J3DGD.h index 854cecef65..b01dc7187f 100644 --- a/include/JSystem/J3DGraphBase/J3DGD.h +++ b/include/JSystem/J3DGraphBase/J3DGD.h @@ -2,64 +2,62 @@ #define J3DGD_H #include <dolphin/gx.h> -#include "dolphin/gd/GDBase.h" +#include <dolphin/gd.h> -inline void J3DGDWrite_u8(u8 param) { - __GDWrite(param); +inline void J3DGDWrite_u8(u8 data) { + __GDWrite(data); } -inline void J3DGDWrite_u16(u16 param) { - __GDWrite((param & 0xffff) >> 8); - __GDWrite(param & 0xff); +inline void J3DGDWrite_u16(u16 data) { + __GDWrite((u8)((data >> 8))); + __GDWrite((u8)((data >> 0) & 0xFF)); } -inline void J3DGDWrite_u32(u32 param) { - __GDWrite((param >> 24) & 0xff); - __GDWrite((param >> 16) & 0xff); - __GDWrite((param >> 8) & 0xff); - __GDWrite(param & 0xff); +inline void J3DGDWrite_u32(u32 data) { + __GDWrite((u8)((data >> 24) & 0xFF)); + __GDWrite((u8)((data >> 16) & 0xFF)); + __GDWrite((u8)((data >> 8) & 0xFF)); + __GDWrite((u8)((data >> 0) & 0xFF)); } -inline void J3DGDWrite_f32(f32 param) { - u32 tmp = *(u32*)¶m; - J3DGDWrite_u32(tmp); +inline void J3DGDWrite_f32(f32 data) { + union { + f32 f; + u32 u; + } fid; + fid.f = data; + J3DGDWrite_u32(fid.u); } -inline void J3DGDWriteBPCmd(u32 cmd) { - J3DGDWrite_u8(0x61); - J3DGDWrite_u32(cmd); +inline void J3DGDWriteBPCmd(u32 regval) { + J3DGDWrite_u8(GX_LOAD_BP_REG); + J3DGDWrite_u32(regval); } -inline void J3DFifoLoadBPCmd(u32 cmd) { - GXWGFifo.u8 = 0x61; - GXWGFifo.u32 = cmd; -} - -inline void J3DGDWriteXFCmd(u16 addr, u32 cmd) { - J3DGDWrite_u8(0x10); +inline void J3DGDWriteXFCmd(u16 addr, u32 val) { + J3DGDWrite_u8(GX_LOAD_XF_REG); J3DGDWrite_u16(0); J3DGDWrite_u16(addr); - J3DGDWrite_u32(cmd); + J3DGDWrite_u32(val); } inline void J3DGDWriteXFCmdHdr(u16 addr, u8 len) { - J3DGDWrite_u8(0x10); + J3DGDWrite_u8(GX_LOAD_XF_REG); J3DGDWrite_u16(len - 1); J3DGDWrite_u16(addr); } -inline void J3DFifoWriteXFCmdHdr(u16 addr, u8 len) { - GXWGFifo.u8 = 0x10; - GXWGFifo.u16 = len - 1; - GXWGFifo.u16 = addr; +inline void J3DGXCmd1f32ptr(f32* data) { + GXCmd1u32(*(u32*)data); } -inline void J3DGXCmd1f32ptr(f32* value) { - GXWGFifo.u32 = *(u32*)value; -} - -inline void J3DGXCmd1f32(f32 value) { - GXWGFifo.u32 = *(u32*)&value; +inline void J3DGXCmd1f32(f32 data) { + union { + f32 f; + u32 u; + } fid; + fid.f = data; + GXCmd1u32(fid.u); } inline void J3DGDWriteCPCmd(u8 reg, u32 value) { @@ -96,18 +94,6 @@ void J3DGDSetTevKColor(GXTevKColorID, GXColor); void J3DGDSetTevColorS10(GXTevRegID, GXColorS10); void J3DGDSetFog(GXFogType, f32, f32, f32, f32, GXColor); void J3DGDSetFogRangeAdj(u8, u16, _GXFogAdjTable*); -void J3DFifoLoadPosMtxImm(f32 (*)[4], u32); -void J3DFifoLoadNrmMtxImm(f32 (*)[4], u32); -void J3DFifoLoadNrmMtxImm3x3(f32 (*)[3], u32); -void J3DFifoLoadNrmMtxToTexMtx(f32 (*)[4], u32); -void J3DFifoLoadNrmMtxToTexMtx3x3(f32 (*)[3], u32); -void J3DFifoLoadTexCached(GXTexMapID, u32, GXTexCacheSize, u32, GXTexCacheSize); - -static inline void J3DFifoLoadIndx(u8 cmd, u16 indx, u16 addr) { - GXWGFifo.u8 = cmd; - GXWGFifo.u16 = indx; - GXWGFifo.u16 = addr; -} inline void J3DGDSetNumChans(u8 numChans) { J3DGDWriteXFCmd(0x1009, numChans); diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index cf3e76d9d3..6d019321c5 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -4,8 +4,7 @@ #include "JSystem/J3DGraphBase/J3DGD.h" #include "JSystem/J3DGraphBase/J3DTevs.h" #include "JSystem/J3DGraphBase/J3DTexture.h" -#include "JSystem/JUtility/JUTAssert.h" -#include "dolphin/types.h" +#include "JSystem/J3DAssert.h" #include "global.h" /** @@ -46,21 +45,28 @@ struct J3DGXColor : public GXColor { } }; +extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; + /** * @ingroup jsystem-j3d * */ struct J3DNBTScale : public J3DNBTScaleInfo { - J3DNBTScale() {} + J3DNBTScale() { + mbHasScale = j3dDefaultNBTScaleInfo.mbHasScale; + mScale.x = j3dDefaultNBTScaleInfo.mScale.x; + mScale.y = j3dDefaultNBTScaleInfo.mScale.y; + mScale.z = j3dDefaultNBTScaleInfo.mScale.z; + } + J3DNBTScale(J3DNBTScaleInfo const& info) { mbHasScale = info.mbHasScale; mScale = info.mScale; } + Vec* getScale() { return &mScale; } }; -extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; - /** * @ingroup jsystem-j3d * @@ -222,39 +228,39 @@ public: /* 80319D30 */ virtual void diffColorChan(); /* 80323560 */ virtual u32 getType() { return 'CLOF'; } /* 80323184 */ virtual void setMatColor(u32 idx, J3DGXColor const* color) { - J3D_ASSERT(0x121, idx >= 0 && idx < ARRAY_SIZE(mMatColor), "Error : range over."); - J3D_ASSERT(0x122, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x121, idx >= 0 && idx < ARRAY_SIZEU(mMatColor)); + J3D_ASSERT_NULLPTR(0x122, color != 0); mMatColor[idx] = *color; } /* 80323158 */ virtual void setMatColor(u32 idx, J3DGXColor color) { - J3D_ASSERT(0x128, idx >= 0 && idx < ARRAY_SIZE(mMatColor), "Error : range over."); + J3D_ASSERT_RANGE(0x128, idx >= 0 && idx < ARRAY_SIZEU(mMatColor)); mMatColor[idx] = color; } /* 803231B0 */ virtual J3DGXColor* getMatColor(u32 idx) { - J3D_ASSERT(0x12d, idx >= 0 && idx < ARRAY_SIZE(mMatColor), "Error : range over."); + J3D_ASSERT_RANGE(0x12d, idx >= 0 && idx < ARRAY_SIZEU(mMatColor)); return &mMatColor[idx]; } /* 803231D0 */ virtual void setColorChanNum(u8 num) { mColorChanNum = num; } /* 803231C4 */ virtual void setColorChanNum(u8 const* num) { - J3D_ASSERT(0x137, num != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x137, num != 0); mColorChanNum = *num; } /* 803231D8 */ virtual u8 getColorChanNum() const { return mColorChanNum; } /* 803231F4 */ virtual void setColorChan(u32 idx, J3DColorChan const& chan) { - J3D_ASSERT(0x142, idx >= 0 && idx < ARRAY_SIZE(mColorChan), "Error : range over."); + J3D_ASSERT_RANGE(0x142, idx >= 0 && idx < ARRAY_SIZEU(mColorChan)); mColorChan[idx] = chan; } /* 803231E0 */ virtual void setColorChan(u32 idx, J3DColorChan const* chan) { - J3D_ASSERT(0x148, idx >= 0 && idx < ARRAY_SIZE(mColorChan), "Error : range over."); - J3D_ASSERT(0x149, chan != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x148, idx >= 0 && idx < ARRAY_SIZEU(mColorChan)); + J3D_ASSERT_NULLPTR(0x149, chan != 0); mColorChan[idx] = *chan; } /* 80323208 */ virtual J3DColorChan* getColorChan(u32 idx) { - J3D_ASSERT(0x14e, idx >= 0 && idx < ARRAY_SIZE(mColorChan), "Error : range over."); + J3D_ASSERT_RANGE(0x14e, idx >= 0 && idx < ARRAY_SIZEU(mColorChan)); return &mColorChan[idx]; } /* 80323224 */ virtual void setCullMode(u8 const* mode) { - J3D_ASSERT(0x154, mode != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x154, mode != 0); mCullMode = *mode; } /* 8032321C */ virtual void setCullMode(u8 mode) { mCullMode = mode; } @@ -289,16 +295,16 @@ public: /* 80317B8C */ virtual s32 countDLSize(); /* 80323074 */ virtual u32 getType() { return 'CLAB'; } /* 803230AC */ virtual void setAmbColor(u32 idx, J3DGXColor const* color) { - J3D_ASSERT(0x1a3, idx >= 0 && idx < ARRAY_SIZE(mAmbColor), "Error : range over."); - J3D_ASSERT(0x1a4, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x1a3, idx >= 0 && idx < ARRAY_SIZEU(mAmbColor)); + J3D_ASSERT_NULLPTR(0x1a4, color != 0); mAmbColor[idx] = *color; } /* 80323080 */ virtual void setAmbColor(u32 idx, J3DGXColor color) { - J3D_ASSERT(0x1aa, idx >= 0 && idx < ARRAY_SIZE(mAmbColor), "Error : range over."); + J3D_ASSERT_RANGE(0x1aa, idx >= 0 && idx < ARRAY_SIZEU(mAmbColor)); mAmbColor[idx] = color; } /* 803230D8 */ virtual J3DGXColor* getAmbColor(u32 idx) { - J3D_ASSERT(0x1af, idx >= 0 && idx < ARRAY_SIZE(mAmbColor), "Error : range over."); + J3D_ASSERT_RANGE(0x1af, idx >= 0 && idx < ARRAY_SIZEU(mAmbColor)); return &mAmbColor[idx]; } /* 803230EC */ virtual ~J3DColorBlockAmbientOn() {} @@ -330,60 +336,60 @@ public: /* 80317B94 */ virtual s32 countDLSize(); /* 80322E80 */ virtual u32 getType() { return 'CLON'; } /* 80322EB8 */ virtual void setMatColor(u32 idx, J3DGXColor const* color) { - J3D_ASSERT(0x1e9, idx >= 0 && idx < ARRAY_SIZE(mMatColor), "Error : range over."); - J3D_ASSERT(0x1ea, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x1e9, idx >= 0 && idx < ARRAY_SIZEU(mMatColor)); + J3D_ASSERT_NULLPTR(0x1ea, color != 0); mMatColor[idx] = *color; } /* 80322E8C */ virtual void setMatColor(u32 idx, J3DGXColor color) { - J3D_ASSERT(0x1f0, idx >= 0 && idx < ARRAY_SIZE(mMatColor), "Error : range over."); + J3D_ASSERT_RANGE(0x1f0, idx >= 0 && idx < ARRAY_SIZEU(mMatColor)); mMatColor[idx] = color; } /* 80322EE4 */ virtual J3DGXColor* getMatColor(u32 idx) { - J3D_ASSERT(0x1f5, idx >= 0 && idx < ARRAY_SIZE(mMatColor), "Error : range over."); + J3D_ASSERT_RANGE(0x1f5, idx >= 0 && idx < ARRAY_SIZEU(mMatColor)); return &mMatColor[idx]; } /* 80322F24 */ virtual void setAmbColor(u32 idx, J3DGXColor const* color) { - J3D_ASSERT(0x1fc, idx >= 0 && idx < ARRAY_SIZE(mAmbColor), "Error : range over."); - J3D_ASSERT(0x1fd, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x1fc, idx >= 0 && idx < ARRAY_SIZEU(mAmbColor)); + J3D_ASSERT_NULLPTR(0x1fd, color != 0); mAmbColor[idx] = *color; } /* 80322EF8 */ virtual void setAmbColor(u32 idx, J3DGXColor color) { - J3D_ASSERT(0x203, idx >= 0 && idx < ARRAY_SIZE(mAmbColor), "Error : range over."); + J3D_ASSERT_RANGE(0x203, idx >= 0 && idx < ARRAY_SIZEU(mAmbColor)); mAmbColor[idx] = color; } /* 80322F50 */ virtual J3DGXColor* getAmbColor(u32 idx) { - J3D_ASSERT(0x208, idx >= 0 && idx < ARRAY_SIZE(mAmbColor), "Error : range over."); + J3D_ASSERT_RANGE(0x208, idx >= 0 && idx < ARRAY_SIZEU(mAmbColor)); return &mAmbColor[idx]; } /* 80322F70 */ virtual void setColorChanNum(u8 num) { mColorChanNum = num; } /* 80322F64 */ virtual void setColorChanNum(u8 const* num) { - J3D_ASSERT(0x212, num != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x212, num != 0); mColorChanNum = *num; } /* 80322F78 */ virtual u8 getColorChanNum() const { return mColorChanNum; } /* 80322F94 */ virtual void setColorChan(u32 idx, J3DColorChan const& chan) { - J3D_ASSERT(0x21d, idx >= 0 && idx < ARRAY_SIZE(mColorChan), "Error : range over."); + J3D_ASSERT_RANGE(0x21d, idx >= 0 && idx < ARRAY_SIZEU(mColorChan)); mColorChan[idx] = chan; } /* 80322F80 */ virtual void setColorChan(u32 idx, J3DColorChan const* chan) { - J3D_ASSERT(0x223, idx >= 0 && idx < ARRAY_SIZE(mColorChan), "Error : range over."); - J3D_ASSERT(0x224, chan != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x223, idx >= 0 && idx < ARRAY_SIZEU(mColorChan)); + J3D_ASSERT_NULLPTR(0x224, chan != 0); mColorChan[idx] = *chan; } /* 80322FA8 */ virtual J3DColorChan* getColorChan(u32 idx) { - J3D_ASSERT(0x229, idx >= 0 && idx < ARRAY_SIZE(mColorChan), "Error : range over."); + J3D_ASSERT_RANGE(0x229, idx >= 0 && idx < ARRAY_SIZEU(mColorChan)); return &mColorChan[idx]; } /* 80322FBC */ virtual void setLight(u32 idx, J3DLightObj* light) { - J3D_ASSERT(0x230, idx >= 0 && idx < ARRAY_SIZE(mLight), "Error : range over."); + J3D_ASSERT_RANGE(0x230, idx >= 0 && idx < ARRAY_SIZEU(mLight)); mLight[idx] = light; } /* 80322FCC */ virtual J3DLightObj* getLight(u32 idx) { - J3D_ASSERT(0x235, idx >= 0 && idx < ARRAY_SIZE(mLight), "Error : range over."); + J3D_ASSERT_RANGE(0x235, idx >= 0 && idx < ARRAY_SIZEU(mLight)); return mLight[idx]; } /* 80322FE4 */ virtual void setCullMode(u8 const* mode) { - J3D_ASSERT(0x23b, mode != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x23b, mode != 0); mCullMode = *mode; } /* 80322FDC */ virtual void setCullMode(u8 mode) { @@ -479,26 +485,26 @@ public: /* 80317B9C */ virtual s32 countDLSize(); /* 80322E74 */ virtual u32 getType() { return 'TGPT'; } /* 80322D3C */ virtual void setTexGenNum(u32 const* num) { - J3D_ASSERT(0x335, num != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x335, num != 0); mTexGenNum = *num; } /* 80322D34 */ virtual void setTexGenNum(u32 num) { mTexGenNum = num; } /* 80322D48 */ virtual u32 getTexGenNum() const { return mTexGenNum; } /* 80322D50 */ virtual void setTexCoord(u32 idx, J3DTexCoord const* coord) { - J3D_ASSERT(0x344, idx >= 0 && idx < ARRAY_SIZE(mTexCoord), "Error : range over."); - J3D_ASSERT(0x345, coord != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x344, idx >= 0 && idx < ARRAY_SIZEU(mTexCoord)); + J3D_ASSERT_NULLPTR(0x345, coord != 0); mTexCoord[idx] = *coord; } /* 80322D64 */ virtual J3DTexCoord* getTexCoord(u32 idx) { - J3D_ASSERT(0x34a, idx >= 0 && idx < ARRAY_SIZE(mTexCoord), "Error : range over."); + J3D_ASSERT_RANGE(0x34a, idx >= 0 && idx < ARRAY_SIZEU(mTexCoord)); return &mTexCoord[idx]; } /* 80322D78 */ virtual void setTexMtx(u32 idx, J3DTexMtx* mtx) { - J3D_ASSERT(0x351, idx >= 0 && idx < ARRAY_SIZE(mTexMtx), "Error : range over."); + J3D_ASSERT_RANGE(0x351, idx >= 0 && idx < ARRAY_SIZEU(mTexMtx)); mTexMtx[idx] = mtx; } /* 80322D88 */ virtual J3DTexMtx* getTexMtx(u32 idx) { - J3D_ASSERT(0x356, idx >= 0 && idx < ARRAY_SIZE(mTexMtx), "Error : range over."); + J3D_ASSERT_RANGE(0x356, idx >= 0 && idx < ARRAY_SIZEU(mTexMtx)); return mTexMtx[idx]; } /* 80322D98 */ virtual u32 getTexMtxOffset() const { return mTexMtxOffset; } @@ -517,7 +523,7 @@ public: */ class J3DTexGenBlock4 : public J3DTexGenBlockPatched { public: - J3DTexGenBlock4() : mNBTScale(j3dDefaultNBTScaleInfo) { + J3DTexGenBlock4() : mNBTScale() { initialize(); } /* 80317674 */ void initialize(); @@ -528,7 +534,7 @@ public: /* 80317BA4 */ virtual s32 countDLSize(); /* 80322DA8 */ virtual u32 getType() { return 'TGB4'; } /* 80322DD8 */ virtual void setNBTScale(J3DNBTScale const* scale) { - J3D_ASSERT(0x393, scale != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x393, scale != 0); mNBTScale = *scale; } /* 80322DB4 */ virtual void setNBTScale(J3DNBTScale scale) { mNBTScale = scale; } @@ -544,7 +550,7 @@ public: */ class J3DTexGenBlockBasic : public J3DTexGenBlockPatched { public: - J3DTexGenBlockBasic() : mNBTScale(j3dDefaultNBTScaleInfo) { + J3DTexGenBlockBasic() : mNBTScale() { initialize(); } /* 803176A4 */ void initialize(); @@ -555,7 +561,7 @@ public: /* 80317BAC */ virtual s32 countDLSize(); /* 80322C6C */ virtual u32 getType() { return 'TGBC'; } /* 80322C9C */ virtual void setNBTScale(J3DNBTScale const* scale) { - J3D_ASSERT(0x3ca, scale != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x3ca, scale != 0); mNBTScale = *scale; } /* 80322C78 */ virtual void setNBTScale(J3DNBTScale scale) { mNBTScale = scale; } @@ -672,107 +678,107 @@ public: /* 80322974 */ virtual void indexToPtr() { indexToPtr_private(mTexNoOffset); } /* 80322998 */ virtual u32 getType() { return 'TVPT'; } /* 803229AC */ virtual void setTevStageNum(u8 const* num) { - J3D_ASSERT(0x52c, num != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x52c, num != 0); mTevStageNum = *num; } /* 803229A4 */ virtual void setTevStageNum(u8 num) { mTevStageNum = num; } /* 803229B8 */ virtual u8 getTevStageNum() const { return mTevStageNum; } /* 80317BB4 */ virtual s32 countDLSize(); /* 803229D0 */ virtual void setTexNo(u32 idx, u16 const* texNo) { - J3D_ASSERT(0x53b, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); - J3D_ASSERT(0x53c, texNo != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x53b, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); + J3D_ASSERT_NULLPTR(0x53c, texNo != 0); mTexNo[idx] = *texNo; } /* 803229C0 */ virtual void setTexNo(u32 idx, u16 texNo) { - J3D_ASSERT(0x542, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); + J3D_ASSERT_RANGE(0x542, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); mTexNo[idx] = texNo; } /* 803229E4 */ virtual u16 getTexNo(u32 idx) const { - J3D_ASSERT(1353, idx >= 0 && idx < 8, "Error : range over."); + J3D_ASSERT_RANGE(1353, idx >= 0 && idx < 8); return mTexNo[idx]; } /* 80322A08 */ virtual void setTevOrder(u32 idx, J3DTevOrder const* order) { - J3D_ASSERT(0x550, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); - J3D_ASSERT(0x551, order != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x550, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); + J3D_ASSERT_NULLPTR(0x551, order != 0); mTevOrder[idx] = *order; } /* 803229F4 */ virtual void setTevOrder(u32 idx, J3DTevOrder order) { - J3D_ASSERT(0x557, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x557, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); mTevOrder[idx] = order; } /* 80322A1C */ virtual J3DTevOrder* getTevOrder(u32 idx) { - J3D_ASSERT(0x55c, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x55c, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); return &mTevOrder[idx]; } /* 80322A6C */ virtual void setTevStage(u32 idx, J3DTevStage const* stage) { - J3D_ASSERT(0x563, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); - J3D_ASSERT(0x564, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x563, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); + J3D_ASSERT_NULLPTR(0x564, stage != 0); mTevStage[idx] = *stage; } /* 80322A30 */ virtual void setTevStage(u32 idx, J3DTevStage stage) { - J3D_ASSERT(0x56a, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x56a, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); mTevStage[idx] = stage; } /* 80322AA8 */ virtual J3DTevStage* getTevStage(u32 idx) { - J3D_ASSERT(0x56f, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x56f, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); return &mTevStage[idx]; } /* 80322AD0 */ virtual void setIndTevStage(u32 idx, J3DIndTevStage const* stage) { - J3D_ASSERT(0x576, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); - J3D_ASSERT(0x577, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x576, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); + J3D_ASSERT_NULLPTR(0x577, stage != 0); mIndTevStage[idx] = *stage; } /* 80322ABC */ virtual void setIndTevStage(u32 idx, J3DIndTevStage stage) { - J3D_ASSERT(0x57d, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x57d, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); mIndTevStage[idx] = stage; } /* 80322AE4 */ virtual J3DIndTevStage* getIndTevStage(u32 idx) { - J3D_ASSERT(0x582, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x582, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); return &mIndTevStage[idx]; } /* 80322B24 */ virtual void setTevColor(u32 idx, J3DGXColorS10 const* color) { - J3D_ASSERT(0x589, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); - J3D_ASSERT(0x58a, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x589, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); + J3D_ASSERT_NULLPTR(0x58a, color != 0); mTevColor[idx] = *color; } /* 80322AF8 */ virtual void setTevColor(u32 idx, J3DGXColorS10 color) { - J3D_ASSERT(0x590, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); + J3D_ASSERT_RANGE(0x590, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); mTevColor[idx] = color; } /* 80322B50 */ virtual J3DGXColorS10* getTevColor(u32 idx) { - J3D_ASSERT(0x595, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); + J3D_ASSERT_RANGE(0x595, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); return &mTevColor[idx]; } /* 80322B90 */ virtual void setTevKColor(u32 idx, J3DGXColor const* color) { - J3D_ASSERT(0x59c, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); - J3D_ASSERT(0x59d, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x59c, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); + J3D_ASSERT_NULLPTR(0x59d, color != 0); mTevKColor[idx] = *color; } /* 80322B64 */ virtual void setTevKColor(u32 idx, J3DGXColor color) { - J3D_ASSERT(0x5a3, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); + J3D_ASSERT_RANGE(0x5a3, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); mTevKColor[idx] = color; } /* 80322BBC */ virtual J3DGXColor* getTevKColor(u32 idx) { - J3D_ASSERT(0x5a8, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); + J3D_ASSERT_RANGE(0x5a8, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); return &mTevKColor[idx]; } /* 80322BDC */ virtual void setTevKColorSel(u32 idx, u8 const* sel) { - J3D_ASSERT(0x5af, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); - J3D_ASSERT(0x5b0, sel != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x5af, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); + J3D_ASSERT_NULLPTR(0x5b0, sel != 0); mTevKColorSel[idx] = *sel; } /* 80322BD0 */ virtual void setTevKColorSel(u32 idx, u8 sel) { - J3D_ASSERT(0x5b6, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); + J3D_ASSERT_RANGE(0x5b6, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); mTevKColorSel[idx] = sel; } /* 80322BEC */ virtual u8 getTevKColorSel(u32 idx) { - J3D_ASSERT(0x5bb, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); + J3D_ASSERT_RANGE(0x5bb, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); return mTevKColorSel[idx]; } /* 80322BF8 */ virtual u32 getTexNoOffset() const { return mTexNoOffset; } /* 80322C00 */ virtual u32 getTevRegOffset() const { return mTevRegOffset; } /* 80322C08 */ virtual void setTevRegOffset(u32 offset) { - J3D_ASSERT(0x53b, offset >= 0, "Error : range over."); + J3D_ASSERT_RANGE(0x53b, offset >= 0); mTevRegOffset = offset; } /* 80322C10 */ virtual ~J3DTevBlockPatched() {} @@ -815,58 +821,58 @@ public: /* 80322798 */ virtual u32 getType() { return 'TVB1'; } /* 80317BBC */ virtual s32 countDLSize(); /* 803227B4 */ virtual void setTexNo(u32 idx, u16 const* no) { - J3D_ASSERT(0x618, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); - J3D_ASSERT(0x619, no != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x618, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); + J3D_ASSERT_NULLPTR(0x619, no != 0); mTexNo[idx] = *no; } /* 803227A4 */ virtual void setTexNo(u32 idx, u16 no) { - J3D_ASSERT(0x61f, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); + J3D_ASSERT_RANGE(0x61f, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); mTexNo[idx] = no; } /* 803227C8 */ virtual u16 getTexNo(u32 idx) const { - J3D_ASSERT(1574, idx >= 0 && idx < 1, "Error : range over."); + J3D_ASSERT_RANGE(1574, idx >= 0 && idx < 1); return mTexNo[idx]; } /* 803227EC */ virtual void setTevOrder(u32 idx, J3DTevOrder const* order) { - J3D_ASSERT(0x62d, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); - J3D_ASSERT(0x62e, order != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x62d, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); + J3D_ASSERT_NULLPTR(0x62e, order != 0); mTevOrder[idx] = *order; } /* 803227D8 */ virtual void setTevOrder(u32 idx, J3DTevOrder order) { - J3D_ASSERT(0x634, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x634, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); mTevOrder[idx] = order; } /* 80322800 */ virtual J3DTevOrder* getTevOrder(u32 idx) { - J3D_ASSERT(0x639, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x639, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); return &mTevOrder[idx]; } /* 80322818 */ virtual void setTevStageNum(u8 const* num) {} /* 80322814 */ virtual void setTevStageNum(u8 num) {} /* 8032281C */ virtual u8 getTevStageNum() const { return 1; } /* 80322860 */ virtual void setTevStage(u32 idx, J3DTevStage const* stage) { - J3D_ASSERT(0x64b, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); - J3D_ASSERT(0x64c, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x64b, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); + J3D_ASSERT_NULLPTR(0x64c, stage != 0); mTevStage[idx] = *stage; } /* 80322824 */ virtual void setTevStage(u32 idx, J3DTevStage stage) { - J3D_ASSERT(0x652, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x652, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); mTevStage[idx] = stage; } /* 8032289C */ virtual J3DTevStage* getTevStage(u32 idx) { - J3D_ASSERT(0x657, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x657, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); return &mTevStage[idx]; } /* 803228C4 */ virtual void setIndTevStage(u32 idx, J3DIndTevStage const* stage) { - J3D_ASSERT(0x65e, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); - J3D_ASSERT(0x65f, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x65e, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); + J3D_ASSERT_NULLPTR(0x65f, stage != 0); mIndTevStage[idx] = *stage; } /* 803228B0 */ virtual void setIndTevStage(u32 idx, J3DIndTevStage stage) { - J3D_ASSERT(0x665, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x665, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); mIndTevStage[idx] = stage; } /* 803228D8 */ virtual J3DIndTevStage* getIndTevStage(u32 idx) { - J3D_ASSERT(0x66a, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x66a, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); return &mIndTevStage[idx]; } /* 803228EC */ virtual u32 getTexNoOffset() const { return mTexNoOffset; } @@ -905,135 +911,135 @@ public: /* 803223D4 */ virtual u32 getType() { return 'TVB2'; } /* 80317BC4 */ virtual s32 countDLSize(); /* 803223F0 */ virtual void setTexNo(u32 idx, u16 const* texNo) { - J3D_ASSERT(0x6b4, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); - J3D_ASSERT(0x6b5, texNo != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x6b4, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); + J3D_ASSERT_NULLPTR(0x6b5, texNo != 0); mTexNo[idx] = *texNo; } /* 803223E0 */ virtual void setTexNo(u32 idx, u16 texNo) { - J3D_ASSERT(0x6bb, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); + J3D_ASSERT_RANGE(0x6bb, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); mTexNo[idx] = texNo; } /* 80322404 */ virtual u16 getTexNo(u32 idx) const { - J3D_ASSERT(0x6c2, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); + J3D_ASSERT_RANGE(0x6c2, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); return mTexNo[idx]; } /* 80322428 */ virtual void setTevOrder(u32 idx, J3DTevOrder const* order) { - J3D_ASSERT(0x6c9, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); - J3D_ASSERT(0x6ca, order != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x6c9, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); + J3D_ASSERT_NULLPTR(0x6ca, order != 0); mTevOrder[idx] = *order; } /* 80322414 */ virtual void setTevOrder(u32 idx, J3DTevOrder order) { - J3D_ASSERT(0x6d0, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x6d0, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); mTevOrder[idx] = order; } /* 8032243C */ virtual J3DTevOrder* getTevOrder(u32 idx) { - J3D_ASSERT(0x6d5, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x6d5, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); return &mTevOrder[idx]; } /* 8032247C */ virtual void setTevColor(u32 idx, J3DGXColorS10 const* color) { - J3D_ASSERT(0x6dc, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); - J3D_ASSERT(0x6dd, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x6dc, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); + J3D_ASSERT_NULLPTR(0x6dd, color != 0); mTevColor[idx] = *color; } /* 80322450 */ virtual void setTevColor(u32 idx, J3DGXColorS10 color) { - J3D_ASSERT(0x6e3, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); + J3D_ASSERT_RANGE(0x6e3, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); mTevColor[idx] = color; } /* 803224A8 */ virtual J3DGXColorS10* getTevColor(u32 idx) { - J3D_ASSERT(0x6e8, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); + J3D_ASSERT_RANGE(0x6e8, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); return &mTevColor[idx]; } /* 803224E8 */ virtual void setTevKColor(u32 idx, J3DGXColor const* color) { - J3D_ASSERT(0x6ef, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); - J3D_ASSERT(0x6f0, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x6ef, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); + J3D_ASSERT_NULLPTR(0x6f0, color != 0); mTevKColor[idx] = *color; } /* 803224BC */ virtual void setTevKColor(u32 idx, J3DGXColor color) { - J3D_ASSERT(0x6f6, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); + J3D_ASSERT_RANGE(0x6f6, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); mTevKColor[idx] = color; } /* 80322514 */ virtual J3DGXColor* getTevKColor(u32 idx) { - J3D_ASSERT(0x6fb, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); + J3D_ASSERT_RANGE(0x6fb, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); return &mTevKColor[idx]; } /* 80322534 */ virtual void setTevKColorSel(u32 idx, u8 const* sel) { - J3D_ASSERT(0x702, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); - J3D_ASSERT(0x703, sel != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x702, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); + J3D_ASSERT_NULLPTR(0x703, sel != 0); mTevKColorSel[idx] = *sel; } /* 80322528 */ virtual void setTevKColorSel(u32 idx, u8 sel) { - J3D_ASSERT(0x709, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); + J3D_ASSERT_RANGE(0x709, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); mTevKColorSel[idx] = sel; } /* 80322544 */ virtual u8 getTevKColorSel(u32 idx) { - J3D_ASSERT(0x70e, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); + J3D_ASSERT_RANGE(0x70e, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); return mTevKColorSel[idx]; } /* 8032255C */ virtual void setTevKAlphaSel(u32 idx, u8 const* sel) { - J3D_ASSERT(0x715, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); - J3D_ASSERT(0x716, sel != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x715, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); + J3D_ASSERT_NULLPTR(0x716, sel != 0); mTevKAlphaSel[idx] = *sel; } /* 80322550 */ virtual void setTevKAlphaSel(u32 idx, u8 sel) { - J3D_ASSERT(0x71c, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); + J3D_ASSERT_RANGE(0x71c, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); mTevKAlphaSel[idx] = sel; } /* 8032256C */ virtual u8 getTevKAlphaSel(u32 idx) { - J3D_ASSERT(0x721, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); + J3D_ASSERT_RANGE(0x721, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); return mTevKAlphaSel[idx]; } /* 80322580 */ virtual void setTevStageNum(u8 const* num) { - J3D_ASSERT(0x727, num != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x727, num != 0); mTevStageNum = *num; } /* 80322578 */ virtual void setTevStageNum(u8 num) { mTevStageNum = num; } /* 8032258C */ virtual u8 getTevStageNum() const { return mTevStageNum; } /* 803225D0 */ virtual void setTevStage(u32 idx, J3DTevStage const* stage) { - J3D_ASSERT(0x736, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); - J3D_ASSERT(0x737, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x736, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); + J3D_ASSERT_NULLPTR(0x737, stage != 0); mTevStage[idx] = *stage; } /* 80322594 */ virtual void setTevStage(u32 idx, J3DTevStage stage) { - J3D_ASSERT(0x73d, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x73d, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); mTevStage[idx] = stage; } /* 8032260C */ virtual J3DTevStage* getTevStage(u32 idx) { - J3D_ASSERT(0x742, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x742, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); return &mTevStage[idx]; } /* 80322658 */ virtual void setTevSwapModeInfo(u32 idx, J3DTevSwapModeInfo const* info) { - J3D_ASSERT(0x749, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); - J3D_ASSERT(0x74a, info != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x749, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); + J3D_ASSERT_NULLPTR(0x74a, info != 0); mTevStage[idx].setTevSwapModeInfo(*info); } /* 80322620 */ virtual void setTevSwapModeInfo(u32 idx, J3DTevSwapModeInfo info) { - J3D_ASSERT(0x750, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x750, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); mTevStage[idx].setTevSwapModeInfo(info); } /* 803226A0 */ virtual void setTevSwapModeTable(u32 idx, J3DTevSwapModeTable const* table) { - J3D_ASSERT(0x757, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); - J3D_ASSERT(0x758, table != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x757, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); + J3D_ASSERT_NULLPTR(0x758, table != 0); mTevSwapModeTable[idx] = *table; } /* 80322690 */ virtual void setTevSwapModeTable(u32 idx, J3DTevSwapModeTable table) { - J3D_ASSERT(0x75e, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); + J3D_ASSERT_RANGE(0x75e, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); mTevSwapModeTable[idx] = table; } /* 803226B0 */ virtual J3DTevSwapModeTable* getTevSwapModeTable(u32 idx) { - J3D_ASSERT(0x763, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); + J3D_ASSERT_RANGE(0x763, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); return &mTevSwapModeTable[idx]; } /* 803226D4 */ virtual void setIndTevStage(u32 idx, J3DIndTevStage const* stage) { - J3D_ASSERT(0x76a, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); - J3D_ASSERT(0x76b, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x76a, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); + J3D_ASSERT_NULLPTR(0x76b, stage != 0); mIndTevStage[idx] = *stage; } /* 803226C0 */ virtual void setIndTevStage(u32 idx, J3DIndTevStage stage) { - J3D_ASSERT(0x771, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x771, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); mIndTevStage[idx] = stage; } /* 803226E8 */ virtual J3DIndTevStage* getIndTevStage(u32 idx) { - J3D_ASSERT(0x776, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x776, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); return &mIndTevStage[idx]; } /* 803226FC */ virtual u32 getTexNoOffset() const { return mTexNoOffset; } @@ -1081,135 +1087,135 @@ public: /* 80322010 */ virtual u32 getType() { return 'TVB4'; } /* 80317BCC */ virtual s32 countDLSize(); /* 8032202C */ virtual void setTexNo(u32 idx, u16 const* texNo) { - J3D_ASSERT(0x7d5, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); - J3D_ASSERT(0x7d6, texNo != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x7d5, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); + J3D_ASSERT_NULLPTR(0x7d6, texNo != 0); mTexNo[idx] = *texNo; } /* 8032201C */ virtual void setTexNo(u32 idx, u16 texNo) { - J3D_ASSERT(0x7dc, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); + J3D_ASSERT_RANGE(0x7dc, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); mTexNo[idx] = texNo; } /* 80322040 */ virtual u16 getTexNo(u32 idx) const { - J3D_ASSERT(2019, idx >= 0 && idx < 4, "Error : range over."); + J3D_ASSERT_RANGE(2019, idx >= 0 && idx < 4); return mTexNo[idx]; } /* 80322064 */ virtual void setTevOrder(u32 idx, J3DTevOrder const* order) { - J3D_ASSERT(0x7ea, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); - J3D_ASSERT(0x7eb, order != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x7ea, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); + J3D_ASSERT_NULLPTR(0x7eb, order != 0); mTevOrder[idx] = *order; } /* 80322050 */ virtual void setTevOrder(u32 idx, J3DTevOrder order) { - J3D_ASSERT(0x7f1, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x7f1, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); mTevOrder[idx] = order; } /* 80322078 */ virtual J3DTevOrder* getTevOrder(u32 idx) { - J3D_ASSERT(0x7f6, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x7f6, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); return &mTevOrder[idx]; } /* 803220B8 */ virtual void setTevColor(u32 idx, J3DGXColorS10 const* color) { - J3D_ASSERT(0x7fd, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); - J3D_ASSERT(0x7fe, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x7fd, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); + J3D_ASSERT_NULLPTR(0x7fe, color != 0); mTevColor[idx] = *color; } /* 8032208C */ virtual void setTevColor(u32 idx, J3DGXColorS10 color) { - J3D_ASSERT(0x804, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); + J3D_ASSERT_RANGE(0x804, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); mTevColor[idx] = color; } /* 803220E4 */ virtual J3DGXColorS10* getTevColor(u32 idx) { - J3D_ASSERT(0x809, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); + J3D_ASSERT_RANGE(0x809, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); return &mTevColor[idx]; } /* 80322124 */ virtual void setTevKColor(u32 idx, J3DGXColor const* color) { - J3D_ASSERT(0x810, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); - J3D_ASSERT(0x811, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x810, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); + J3D_ASSERT_NULLPTR(0x811, color != 0); mTevKColor[idx] = *color; } /* 803220F8 */ virtual void setTevKColor(u32 idx, J3DGXColor color) { - J3D_ASSERT(0x817, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); + J3D_ASSERT_RANGE(0x817, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); mTevKColor[idx] = color; } /* 80322150 */ virtual J3DGXColor* getTevKColor(u32 idx) { - J3D_ASSERT(0x81c, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); + J3D_ASSERT_RANGE(0x81c, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); return &mTevKColor[idx]; } /* 80322170 */ virtual void setTevKColorSel(u32 idx, u8 const* sel) { - J3D_ASSERT(0x823, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); - J3D_ASSERT(0x824, sel != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x823, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); + J3D_ASSERT_NULLPTR(0x824, sel != 0); mTevKColorSel[idx] = *sel; } /* 80322164 */ virtual void setTevKColorSel(u32 idx, u8 sel) { - J3D_ASSERT(0x82a, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); + J3D_ASSERT_RANGE(0x82a, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); mTevKColorSel[idx] = sel; } /* 80322180 */ virtual u8 getTevKColorSel(u32 idx) { - J3D_ASSERT(0x82f, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); + J3D_ASSERT_RANGE(0x82f, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); return mTevKColorSel[idx]; } /* 80322198 */ virtual void setTevKAlphaSel(u32 idx, u8 const* sel) { - J3D_ASSERT(0x836, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); - J3D_ASSERT(0x837, sel != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x836, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); + J3D_ASSERT_NULLPTR(0x837, sel != 0); mTevKAlphaSel[idx] = *sel; } /* 8032218C */ virtual void setTevKAlphaSel(u32 idx, u8 sel) { - J3D_ASSERT(0x83d, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); + J3D_ASSERT_RANGE(0x83d, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); mTevKAlphaSel[idx] = sel; } /* 803221A8 */ virtual u8 getTevKAlphaSel(u32 idx) { - J3D_ASSERT(0x842, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); + J3D_ASSERT_RANGE(0x842, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); return mTevKAlphaSel[idx]; } /* 803221BC */ virtual void setTevStageNum(u8 const* num) { - J3D_ASSERT(0x848, num != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x848, num != 0); mTevStageNum = *num; } /* 803221B4 */ virtual void setTevStageNum(u8 num) { mTevStageNum = num; } /* 803221C8 */ virtual u8 getTevStageNum() const { return mTevStageNum; } /* 8032220C */ virtual void setTevStage(u32 idx, J3DTevStage const* stage) { - J3D_ASSERT(0x857, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); - J3D_ASSERT(0x858, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x857, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); + J3D_ASSERT_NULLPTR(0x858, stage != 0); mTevStage[idx] = *stage; } /* 803221D0 */ virtual void setTevStage(u32 idx, J3DTevStage stage) { - J3D_ASSERT(0x85e, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x85e, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); mTevStage[idx] = stage; } /* 80322248 */ virtual J3DTevStage* getTevStage(u32 idx) { - J3D_ASSERT(0x863, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x863, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); return &mTevStage[idx]; } /* 80322294 */ virtual void setTevSwapModeInfo(u32 idx, J3DTevSwapModeInfo const* info) { - J3D_ASSERT(0x86a, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); - J3D_ASSERT(0x86b, info != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x86a, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); + J3D_ASSERT_NULLPTR(0x86b, info != 0); mTevStage[idx].setTevSwapModeInfo(*info); } /* 8032225C */ virtual void setTevSwapModeInfo(u32 idx, J3DTevSwapModeInfo info) { - J3D_ASSERT(0x871, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x871, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); mTevStage[idx].setTevSwapModeInfo(info); } /* 803222DC */ virtual void setTevSwapModeTable(u32 idx, J3DTevSwapModeTable const* table) { - J3D_ASSERT(0x878, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); - J3D_ASSERT(0x879, table != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x878, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); + J3D_ASSERT_NULLPTR(0x879, table != 0); mTevSwapModeTable[idx] = *table; } /* 803222CC */ virtual void setTevSwapModeTable(u32 idx, J3DTevSwapModeTable table) { - J3D_ASSERT(0x87f, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); + J3D_ASSERT_RANGE(0x87f, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); mTevSwapModeTable[idx] = table; } /* 803222EC */ virtual J3DTevSwapModeTable* getTevSwapModeTable(u32 idx) { - J3D_ASSERT(0x884, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); + J3D_ASSERT_RANGE(0x884, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); return &mTevSwapModeTable[idx]; } /* 80322310 */ virtual void setIndTevStage(u32 idx, J3DIndTevStage const* stage) { - J3D_ASSERT(0x88b, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); - J3D_ASSERT(0x88c, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x88b, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); + J3D_ASSERT_NULLPTR(0x88c, stage != 0); mIndTevStage[idx] = *stage; } /* 803222FC */ virtual void setIndTevStage(u32 idx, J3DIndTevStage stage) { - J3D_ASSERT(0x892, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x892, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); mIndTevStage[idx] = stage; } /* 80322324 */ virtual J3DIndTevStage* getIndTevStage(u32 idx) { - J3D_ASSERT(0x897, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x897, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); return &mIndTevStage[idx]; } /* 80322338 */ virtual u32 getTexNoOffset() const { return mTexNoOffset; } @@ -1257,135 +1263,135 @@ public: /* 80321C44 */ virtual u32 getType() { return 'TV16'; } /* 80317BD4 */ virtual s32 countDLSize(); /* 80321C60 */ virtual void setTexNo(u32 idx, u16 const* texNo) { - J3D_ASSERT(0x8f6, idx >= 0 && idx < ARRAY_SIZE(mTexNo), "Error : range over."); - J3D_ASSERT(0x8f7, texNo != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x8f6, idx >= 0 && idx < ARRAY_SIZEU(mTexNo)); + J3D_ASSERT_NULLPTR(0x8f7, texNo != 0); mTexNo[idx] = *texNo; } /* 80321C50 */ virtual void setTexNo(u32 idx, u16 texNo) { - J3D_ASSERT(0x8fd, idx >= 0 && idx < 8, "Error : range over."); + J3D_ASSERT_RANGE(0x8fd, idx >= 0 && idx < 8); mTexNo[idx] = texNo; } /* 80321C74 */ virtual u16 getTexNo(u32 idx) const { - J3D_ASSERT(2308, idx >= 0 && idx < 8, "Error : range over."); + J3D_ASSERT_RANGE(2308, idx >= 0 && idx < 8); return mTexNo[idx]; } /* 80321C98 */ virtual void setTevOrder(u32 idx, J3DTevOrder const* order) { - J3D_ASSERT(0x90b, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); - J3D_ASSERT(0x90c, order != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x90b, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); + J3D_ASSERT_NULLPTR(0x90c, order != 0); mTevOrder[idx] = *order; } /* 80321C84 */ virtual void setTevOrder(u32 idx, J3DTevOrder order) { - J3D_ASSERT(0x912, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x912, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); mTevOrder[idx] = order; } /* 80321CAC */ virtual J3DTevOrder* getTevOrder(u32 idx) { - J3D_ASSERT(0x917, idx >= 0 && idx < ARRAY_SIZE(mTevOrder), "Error : range over."); + J3D_ASSERT_RANGE(0x917, idx >= 0 && idx < ARRAY_SIZEU(mTevOrder)); return &mTevOrder[idx]; } /* 80321CEC */ virtual void setTevColor(u32 idx, J3DGXColorS10 const* color) { - J3D_ASSERT(0x91e, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); - J3D_ASSERT(0x91f, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x91e, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); + J3D_ASSERT_NULLPTR(0x91f, color != 0); mTevColor[idx] = *color; } /* 80321CC0 */ virtual void setTevColor(u32 idx, J3DGXColorS10 color) { - J3D_ASSERT(0x925, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); + J3D_ASSERT_RANGE(0x925, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); mTevColor[idx] = color; } /* 80321D18 */ virtual J3DGXColorS10* getTevColor(u32 idx) { - J3D_ASSERT(0x92a, idx >= 0 && idx < ARRAY_SIZE(mTevColor), "Error : range over."); + J3D_ASSERT_RANGE(0x92a, idx >= 0 && idx < ARRAY_SIZEU(mTevColor)); return &mTevColor[idx]; } /* 80321D58 */ virtual void setTevKColor(u32 idx, J3DGXColor const* color) { - J3D_ASSERT(0x931, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); - J3D_ASSERT(0x932, color != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x931, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); + J3D_ASSERT_NULLPTR(0x932, color != 0); mTevKColor[idx] = *color; } /* 80321D2C */ virtual void setTevKColor(u32 idx, J3DGXColor color) { - J3D_ASSERT(0x938, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); + J3D_ASSERT_RANGE(0x938, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); mTevKColor[idx] = color; } /* 80321D84 */ virtual J3DGXColor* getTevKColor(u32 idx) { - J3D_ASSERT(0x93d, idx >= 0 && idx < ARRAY_SIZE(mTevKColor), "Error : range over."); + J3D_ASSERT_RANGE(0x93d, idx >= 0 && idx < ARRAY_SIZEU(mTevKColor)); return &mTevKColor[idx]; } /* 80321DA4 */ virtual void setTevKColorSel(u32 idx, u8 const* sel) { - J3D_ASSERT(0x944, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); - J3D_ASSERT(0x945, sel != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x944, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); + J3D_ASSERT_NULLPTR(0x945, sel != 0); mTevKColorSel[idx] = *sel; } /* 80321D98 */ virtual void setTevKColorSel(u32 idx, u8 sel) { - J3D_ASSERT(0x94b, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); + J3D_ASSERT_RANGE(0x94b, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); mTevKColorSel[idx] = sel; } /* 80321DB4 */ virtual u8 getTevKColorSel(u32 idx) { - J3D_ASSERT(0x950, idx >= 0 && idx < ARRAY_SIZE(mTevKColorSel), "Error : range over."); + J3D_ASSERT_RANGE(0x950, idx >= 0 && idx < ARRAY_SIZEU(mTevKColorSel)); return mTevKColorSel[idx]; } /* 80321DCC */ virtual void setTevKAlphaSel(u32 idx, u8 const* sel) { - J3D_ASSERT(0x957, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); - J3D_ASSERT(0x958, sel != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x957, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); + J3D_ASSERT_NULLPTR(0x958, sel != 0); mTevKAlphaSel[idx] = *sel; } /* 80321DC0 */ virtual void setTevKAlphaSel(u32 idx, u8 sel) { - J3D_ASSERT(0x95e, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); + J3D_ASSERT_RANGE(0x95e, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); mTevKAlphaSel[idx] = sel; } /* 80321DDC */ virtual u8 getTevKAlphaSel(u32 idx) { - J3D_ASSERT(0x963, idx >= 0 && idx < ARRAY_SIZE(mTevKAlphaSel), "Error : range over."); + J3D_ASSERT_RANGE(0x963, idx >= 0 && idx < ARRAY_SIZEU(mTevKAlphaSel)); return mTevKAlphaSel[idx]; } /* 80321DF0 */ virtual void setTevStageNum(u8 const* num) { - J3D_ASSERT(0x969, num != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0x969, num != 0); mTevStageNum = *num; } /* 80321DE8 */ virtual void setTevStageNum(u8 num) { mTevStageNum = num; } /* 80321DFC */ virtual u8 getTevStageNum() const { return mTevStageNum; } /* 80321E40 */ virtual void setTevStage(u32 idx, J3DTevStage const* stage) { - J3D_ASSERT(0x978, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); - J3D_ASSERT(0x979, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x978, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); + J3D_ASSERT_NULLPTR(0x979, stage != 0); mTevStage[idx] = *stage; } /* 80321E04 */ virtual void setTevStage(u32 idx, J3DTevStage stage) { - J3D_ASSERT(0x97f, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x97f, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); mTevStage[idx] = stage; } /* 80321E7C */ virtual J3DTevStage* getTevStage(u32 idx) { - J3D_ASSERT(0x984, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x984, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); return &mTevStage[idx]; } /* 80321EC8 */ virtual void setTevSwapModeInfo(u32 idx, J3DTevSwapModeInfo const* info) { - J3D_ASSERT(0x98b, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); - J3D_ASSERT(0x98c, info != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x98b, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); + J3D_ASSERT_NULLPTR(0x98c, info != 0); mTevStage[idx].setTevSwapModeInfo(*info); } /* 80321E90 */ virtual void setTevSwapModeInfo(u32 idx, J3DTevSwapModeInfo info) { - J3D_ASSERT(0x992, idx >= 0 && idx < ARRAY_SIZE(mTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x992, idx >= 0 && idx < ARRAY_SIZEU(mTevStage)); mTevStage[idx].setTevSwapModeInfo(info); } /* 80321F10 */ virtual void setTevSwapModeTable(u32 idx, J3DTevSwapModeTable const* table) { - J3D_ASSERT(0x999, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); - J3D_ASSERT(0x99a, table != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x999, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); + J3D_ASSERT_NULLPTR(0x99a, table != 0); mTevSwapModeTable[idx] = *table; } /* 80321F00 */ virtual void setTevSwapModeTable(u32 idx, J3DTevSwapModeTable table) { - J3D_ASSERT(0x9a0, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); + J3D_ASSERT_RANGE(0x9a0, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); mTevSwapModeTable[idx] = table; } /* 80321F20 */ virtual J3DTevSwapModeTable* getTevSwapModeTable(u32 idx) { - J3D_ASSERT(0x9a5, idx >= 0 && idx < ARRAY_SIZE(mTevSwapModeTable), "Error : range over."); + J3D_ASSERT_RANGE(0x9a5, idx >= 0 && idx < ARRAY_SIZEU(mTevSwapModeTable)); return &mTevSwapModeTable[idx]; } /* 80321F44 */ virtual void setIndTevStage(u32 idx, J3DIndTevStage const* stage) { - J3D_ASSERT(0x9ac, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); - J3D_ASSERT(0x9ad, stage != 0, "Error : null pointer."); + J3D_ASSERT_RANGE(0x9ac, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); + J3D_ASSERT_NULLPTR(0x9ad, stage != 0); mIndTevStage[idx] = *stage; } /* 80321F30 */ virtual void setIndTevStage(u32 idx, J3DIndTevStage stage) { - J3D_ASSERT(0x9b3, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x9b3, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); mIndTevStage[idx] = stage; } /* 80321F58 */ virtual J3DIndTevStage* getIndTevStage(u32 idx) { - J3D_ASSERT(0x9b8, idx >= 0 && idx < ARRAY_SIZE(mIndTevStage), "Error : range over."); + J3D_ASSERT_RANGE(0x9b8, idx >= 0 && idx < ARRAY_SIZEU(mIndTevStage)); return &mIndTevStage[idx]; } /* 80321F6C */ virtual u32 getTexNoOffset() const { return mTexNoOffset; } @@ -1568,20 +1574,27 @@ struct J3DAlphaComp { return *this; } + J3DAlphaComp& operator=(J3DAlphaComp& rhs) { + mID = rhs.mID; + mRef0 = rhs.mRef0; + mRef1 = rhs.mRef1; + return *this; + } + void setAlphaCompInfo(const J3DAlphaCompInfo& info) { mRef0 = info.mRef0; mRef1 = info.mRef1; mID = calcAlphaCmpID(info.mComp0, info.mOp, info.mComp1); } - GXCompare getComp0() const { return GXCompare(*(&j3dAlphaCmpTable[mID * 3] + 0)); } - GXAlphaOp getOp() const { return GXAlphaOp(*(&j3dAlphaCmpTable[mID * 3] + 1)); } - GXCompare getComp1() const { return GXCompare(*(&j3dAlphaCmpTable[mID * 3] + 2)); } + u8 getComp0() const { return *(&j3dAlphaCmpTable[mID * 3] + 0); } + u8 getOp() const { return *(&j3dAlphaCmpTable[mID * 3] + 1); } + u8 getComp1() const { return *(&j3dAlphaCmpTable[mID * 3] + 2); } u8 getRef0() const { return mRef0; } u8 getRef1() const { return mRef1; } void load() const { - J3DGDSetAlphaCompare(getComp0(), mRef0, getOp(), getComp1(), mRef1); + J3DGDSetAlphaCompare((GXCompare)getComp0(), mRef0, (GXAlphaOp)getOp(), (GXCompare)getComp1(), mRef1); } /* 0x00 */ u16 mID; @@ -1720,42 +1733,42 @@ public: /* 8032339C */ virtual void setIndTexStageNum(u8 num) { mIndTexStageNum = num; } /* 803233A4 */ virtual u8 getIndTexStageNum() const { return mIndTexStageNum; } /* 803233C0 */ virtual void setIndTexOrder(u32 idx, J3DIndTexOrder const* order) { - J3D_ASSERT(0xa94, order != 0, "Error : null pointer."); - J3D_ASSERT(0xa95, idx >= 0 && idx < ARRAY_SIZE(mIndTexOrder), "Error : range over."); + J3D_ASSERT_NULLPTR(0xa94, order != 0); + J3D_ASSERT_RANGE(0xa95, idx >= 0 && idx < ARRAY_SIZEU(mIndTexOrder)); mIndTexOrder[idx] = *order; } /* 803233AC */ virtual void setIndTexOrder(u32 idx, J3DIndTexOrder order) { - J3D_ASSERT(0xa9b, idx >= 0 && idx < ARRAY_SIZE(mIndTexOrder), "Error : range over."); + J3D_ASSERT_RANGE(0xa9b, idx >= 0 && idx < ARRAY_SIZEU(mIndTexOrder)); mIndTexOrder[idx] = order; } /* 803233D4 */ virtual J3DIndTexOrder* getIndTexOrder(u32 idx) { - J3D_ASSERT(0xaa0, idx >= 0 && idx < ARRAY_SIZE(mIndTexOrder), "Error : range over."); + J3D_ASSERT_RANGE(0xaa0, idx >= 0 && idx < ARRAY_SIZEU(mIndTexOrder)); return &mIndTexOrder[idx]; } /* 8032341C */ virtual void setIndTexMtx(u32 idx, J3DIndTexMtx const* mtx) { - J3D_ASSERT(0xaa7, mtx != 0, "Error : null pointer."); - J3D_ASSERT(0xaa8, idx >= 0 && idx < ARRAY_SIZE(mIndTexMtx), "Error : range over."); + J3D_ASSERT_NULLPTR(0xaa7, mtx != 0); + J3D_ASSERT_RANGE(0xaa8, idx >= 0 && idx < ARRAY_SIZEU(mIndTexMtx)); mIndTexMtx[idx] = *mtx; } /* 803233E8 */ virtual void setIndTexMtx(u32 idx, J3DIndTexMtx mtx) { - J3D_ASSERT(0xaae, idx >= 0 && idx < ARRAY_SIZE(mIndTexMtx), "Error : range over."); + J3D_ASSERT_RANGE(0xaae, idx >= 0 && idx < ARRAY_SIZEU(mIndTexMtx)); mIndTexMtx[idx] = mtx; } /* 80323450 */ virtual J3DIndTexMtx* getIndTexMtx(u32 idx) { - J3D_ASSERT(0xab3, idx >= 0 && idx < ARRAY_SIZE(mIndTexMtx), "Error : range over."); + J3D_ASSERT_RANGE(0xab3, idx >= 0 && idx < ARRAY_SIZEU(mIndTexMtx)); return &mIndTexMtx[idx]; } /* 80323478 */ virtual void setIndTexCoordScale(u32 idx, J3DIndTexCoordScale const* scale) { - J3D_ASSERT(0xaba, scale != 0, "Error : null pointer."); - J3D_ASSERT(0xabb, idx >= 0 && idx < ARRAY_SIZE(mIndTexCoordScale), "Error : range over."); + J3D_ASSERT_NULLPTR(0xaba, scale != 0); + J3D_ASSERT_RANGE(0xabb, idx >= 0 && idx < ARRAY_SIZEU(mIndTexCoordScale)); mIndTexCoordScale[idx] = *scale; } /* 80323464 */ virtual void setIndTexCoordScale(u32 idx, J3DIndTexCoordScale scale) { - J3D_ASSERT(0xac1, idx >= 0 && idx < ARRAY_SIZE(mIndTexCoordScale), "Error : range over."); + J3D_ASSERT_RANGE(0xac1, idx >= 0 && idx < ARRAY_SIZEU(mIndTexCoordScale)); mIndTexCoordScale[idx] = scale; } /* 8032348C */ virtual J3DIndTexCoordScale* getIndTexCoordScale(u32 idx) { - J3D_ASSERT(0xac6, idx >= 0 && idx < ARRAY_SIZE(mIndTexCoordScale), "Error : range over."); + J3D_ASSERT_RANGE(0xac6, idx >= 0 && idx < ARRAY_SIZEU(mIndTexCoordScale)); return &mIndTexCoordScale[idx]; } /* 803234A0 */ virtual ~J3DIndBlockFull() {} @@ -1867,31 +1880,31 @@ public: /* 80317BFC */ virtual s32 countDLSize(); /* 80321B00 */ virtual u32 getType() { return 'PEFG'; } /* 80321B28 */ virtual void setAlphaComp(J3DAlphaComp const* alphaComp) { - J3D_ASSERT(0xbf9, alphaComp != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xbf9, alphaComp != 0); mAlphaComp = *alphaComp; } /* 80321B0C */ virtual void setAlphaComp(J3DAlphaComp const& alphaComp) { mAlphaComp = alphaComp; } /* 80321B44 */ virtual J3DAlphaComp* getAlphaComp() { return &mAlphaComp; } /* 80321B58 */ virtual void setBlend(J3DBlend const* blend) { - J3D_ASSERT(0xc07, blend != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xc07, blend != 0); mBlend = *blend; } /* 80321B4C */ virtual void setBlend(J3DBlend const& blend) { mBlend = blend; } /* 80321B64 */ virtual J3DBlend* getBlend() { return &mBlend; } /* 80321B78 */ virtual void setZMode(J3DZMode const* zMode) { - J3D_ASSERT(0xc15, zMode != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xc15, zMode != 0); mZMode = *zMode; } /* 80321B6C */ virtual void setZMode(J3DZMode zMode) { mZMode = zMode; } /* 80321B84 */ virtual J3DZMode* getZMode() { return &mZMode; } /* 80321B94 */ virtual void setZCompLoc(u8 const* zCompLoc) { - J3D_ASSERT(0xc23, zCompLoc != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xc23, zCompLoc != 0); mZCompLoc = *zCompLoc; } /* 80321B8C */ virtual void setZCompLoc(u8 zCompLoc) { mZCompLoc = zCompLoc; } /* 80321BA0 */ virtual u8 getZCompLoc() const { return mZCompLoc; } /* 80321BB0 */ virtual void setDither(u8 const* dither) { - J3D_ASSERT(0xc31, dither != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xc31, dither != 0); mDither = *dither; } /* 80321BA8 */ virtual void setDither(u8 dither) { mDither = dither; } @@ -1928,31 +1941,31 @@ public: /* 80321958 */ virtual void setFog(J3DFog* pFog) { mFog.setFogInfo(pFog->getFogInfo()); } /* 803219A0 */ virtual J3DFog* getFog() { return &mFog; } /* 803219C4 */ virtual void setAlphaComp(J3DAlphaComp const* alphaComp) { - J3D_ASSERT(0xc7d, alphaComp != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xc7d, alphaComp != 0); mAlphaComp = *alphaComp; } /* 803219A8 */ virtual void setAlphaComp(J3DAlphaComp const& alphaComp) { mAlphaComp = alphaComp; } /* 803219E0 */ virtual J3DAlphaComp* getAlphaComp() { return &mAlphaComp; } /* 803219F4 */ virtual void setBlend(J3DBlend const* blend) { - J3D_ASSERT(0xc8b, blend != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xc8b, blend != 0); mBlend = *blend; } /* 803219E8 */ virtual void setBlend(J3DBlend const& blend) { mBlend = blend; } /* 80321A00 */ virtual J3DBlend* getBlend() { return &mBlend; } /* 80321A14 */ virtual void setZMode(J3DZMode const* zMode) { - J3D_ASSERT(0xc99, zMode != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xc99, zMode != 0); mZMode = *zMode; } /* 80321A08 */ virtual void setZMode(J3DZMode zMode) { mZMode = zMode; } /* 80321A20 */ virtual J3DZMode* getZMode() { return &mZMode; } /* 80321A30 */ virtual void setZCompLoc(u8 const* zCompLoc) { - J3D_ASSERT(0xca7, zCompLoc != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xca7, zCompLoc != 0); mZCompLoc = *zCompLoc; } /* 80321A28 */ virtual void setZCompLoc(u8 zCompLoc) { mZCompLoc = zCompLoc; } /* 80321A3C */ virtual u8 getZCompLoc() const { return mZCompLoc; } /* 80321A4C */ virtual void setDither(u8 const* dither) { - J3D_ASSERT(0xcb5, dither != 0, "Error : null pointer."); + J3D_ASSERT_NULLPTR(0xcb5, dither != 0); mDither = *dither; } /* 80321A44 */ virtual void setDither(u8 dither) { mDither = dither; } diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h index b32bac6ff1..e3f7e7dab8 100644 --- a/include/JSystem/J3DGraphBase/J3DMaterial.h +++ b/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -4,7 +4,7 @@ #include "JSystem/J3DGraphBase/J3DMatBlock.h" #include "JSystem/J3DGraphBase/J3DPacket.h" #include "JSystem/J3DGraphBase/J3DShape.h" -#include "dolphin/types.h" +#include <stdint.h> class J3DJoint; class J3DMaterialAnm; @@ -56,7 +56,7 @@ public: J3DIndBlock* getIndBlock() { return mIndBlock; } J3DJoint* getJoint() { return mJoint; } J3DMaterialAnm* getMaterialAnm() { - if ((u32)mMaterialAnm < 0xC0000000) { + if ((uintptr_t)mMaterialAnm < 0xC0000000) { return mMaterialAnm; } else { return NULL; @@ -89,6 +89,21 @@ public: void setZCompLoc(u8 i_comploc) { mPEBlock->setZCompLoc(i_comploc); } void setMaterialMode(u32 i_mode) { mMaterialMode = i_mode; } + void addShape(J3DShape* pShape) { + J3D_ASSERT_NULLPTR(618, pShape != NULL); + mShape = pShape; + } + + void setNext(J3DMaterial* pMaterial) { + J3D_ASSERT_NULLPTR(623, pMaterial != NULL); + mNext = pMaterial; + } + + void setJoint(J3DJoint* pJoint) { + J3D_ASSERT_NULLPTR(628, pJoint != NULL); + mJoint = pJoint; + } + public: /* 0x04 */ J3DMaterial* mNext; /* 0x08 */ J3DShape* mShape; diff --git a/include/JSystem/J3DGraphBase/J3DPacket.h b/include/JSystem/J3DGraphBase/J3DPacket.h index ce01c85b1e..177c8de837 100644 --- a/include/JSystem/J3DGraphBase/J3DPacket.h +++ b/include/JSystem/J3DGraphBase/J3DPacket.h @@ -3,6 +3,7 @@ #include "JSystem/J3DGraphBase/J3DSys.h" #include "dolphin/gd/GDBase.h" +#include <stdint.h> class J3DMatPacket; @@ -16,27 +17,42 @@ class J3DTexMtx; class J3DTexMtxObj; class J3DTexture; -inline u32 getDiffFlag_LightObjNum(u32 param_1) { - return (param_1 & 0xf0) >> 4; +enum J3DDiffFlag { + J3DDiffFlag_MatColor = 0x1, + J3DDiffFlag_ColorChan = 0x2, + J3DDiffFlag_AmbColor = 0x4, + J3DDiffFlag_TexGen = 0x1000, + J3DDiffFlag_TevReg = 0x1000000, + J3DDiffFlag_KonstColor = 0x2000000, // is this right? + J3DDiffFlag_TexCoordScale = 0x4000000, + J3DDiffFlag_TevStageIndirect = 0x8000000, + J3DDiffFlag_Fog = 0x10000000, + J3DDiffFlag_Blend = 0x20000000, + J3DDiffFlag_Unk40000000 = 0x40000000, + J3DDiffFlag_Changed = 0x80000000, +}; + +inline u32 getDiffFlag_LightObjNum(u32 diffFlags) { + return (diffFlags & 0xf0) >> 4; } -inline u32 getDiffFlag_TexGenNum(u32 param_1) { - return (param_1 & 0xf00) >> 8; +inline u32 getDiffFlag_TexGenNum(u32 diffFlags) { + return (diffFlags & 0xf00) >> 8; } -inline int calcDifferedBufferSize_TexMtxSize(int param_1) { +inline int calcDifferedBufferSize_TexMtxSize(u32 param_1) { return param_1 * 0x35; } -inline int calcDifferedBufferSize_TexGenSize(int param_1) { +inline int calcDifferedBufferSize_TexGenSize(u32 param_1) { return param_1 * 0x3d + 10; } -inline u32 getDiffFlag_TexNoNum(u32 param_1) { - return (param_1 & 0xf0000) >> 0x10; +inline u32 getDiffFlag_TexNoNum(u32 diffFlags) { + return (diffFlags & 0xf0000) >> 0x10; } -inline int calcDifferedBufferSize_TexNoSize(int param_1) { +inline int calcDifferedBufferSize_TexNoSize(u32 param_1) { return param_1 * 0x37; } @@ -46,15 +62,15 @@ inline u32 calcDifferedBufferSize_TexNoAndTexCoordScaleSize(u32 param_1) { return res; } -inline u32 getDiffFlag_TevStageNum(u32 param_1) { - return (param_1 & 0xf00000) >> 0x14; +inline u32 getDiffFlag_TevStageNum(u32 diffFlags) { + return (diffFlags & 0xf00000) >> 0x14; } -inline int calcDifferedBufferSize_TevStageSize(int param_1) { +inline int calcDifferedBufferSize_TevStageSize(u32 param_1) { return param_1 * 10; } -inline int calcDifferedBufferSize_TevStageDirectSize(int param_1) { +inline int calcDifferedBufferSize_TevStageDirectSize(u32 param_1) { return param_1 * 5; } @@ -65,15 +81,15 @@ inline int calcDifferedBufferSize_TevStageDirectSize(int param_1) { class J3DDisplayListObj { public: J3DDisplayListObj() { - mpData[0] = NULL; - mpData[1] = NULL; + mpDisplayList[0] = NULL; + mpDisplayList[1] = NULL; mSize = 0; - mCapacity = 0; + mMaxSize = 0; } J3DError newDisplayList(u32); J3DError newSingleDisplayList(u32); - J3DError single_To_Double(); + int single_To_Double(); void setSingleDisplayList(void*, u32); void swapBuffer(); void callDL() const; @@ -82,15 +98,15 @@ public: void beginPatch(); u32 endPatch(); - u8* getDisplayList(int idx) const { return (u8*)mpData[idx]; } - u32 getDisplayListSize() const { return mSize; } + u8* getDisplayList(int idx) { return (u8*)mpDisplayList[idx]; } + u32 getDisplayListSize() { return mSize; } static GDLObj sGDLObj; static s32 sInterruptFlag; - /* 0x0 */ void* mpData[2]; + /* 0x0 */ void* mpDisplayList[2]; /* 0x8 */ u32 mSize; - /* 0xC */ u32 mCapacity; + /* 0xC */ u32 mMaxSize; }; // Size: 0x10 /** @@ -102,7 +118,7 @@ public: J3DPacket() { mpNextPacket = NULL; mpFirstChild = NULL; - mpUserData = NULL; + mpUserArea = NULL; } void addChildPacket(J3DPacket*); @@ -115,8 +131,8 @@ public: mpFirstChild = NULL; } - void* getUserArea() { return mpUserData; } - void setUserArea(u32 area) { mpUserData = (void*)area; } + void* getUserArea() const { return mpUserArea; } + void setUserArea(uintptr_t area) { mpUserArea = (void*)area; } virtual int entry(J3DDrawBuffer*); virtual void draw(); @@ -125,7 +141,7 @@ public: public: /* 0x04 */ J3DPacket* mpNextPacket; /* 0x08 */ J3DPacket* mpFirstChild; - /* 0x0C */ void* mpUserData; + /* 0x0C */ void* mpUserArea; }; // Size: 0x10 /** @@ -140,29 +156,34 @@ public: J3DError newSingleDisplayList(u32); virtual void draw(); - J3DDisplayListObj* getDisplayListObj() const { return mpDisplayListObj; } + J3DDisplayListObj* getDisplayListObj() { return mpDisplayListObj; } void setDisplayListObj(J3DDisplayListObj* pObj) { mpDisplayListObj = pObj; } void beginPatch() { mpDisplayListObj->beginPatch(); } void endPatch() { mpDisplayListObj->endPatch(); } - void callDL() const { getDisplayListObj()->callDL(); } + void callDL() const { mpDisplayListObj->callDL(); } + void beginDL() { mpDisplayListObj->beginDL(); } + void endDL() { mpDisplayListObj->endDL(); } + + void* getDisplayList(int i) { return mpDisplayListObj->mpDisplayList[i]; } + u32 getDisplayListSize() const { return mpDisplayListObj->mSize; } enum { LOCKED = 0x01, }; - bool checkFlag(u32 flag) const { return (mFlags & flag) != 0; } + bool checkFlag(u32 flag) const { return (mFlags & flag) ? true : false; } void onFlag(u32 flag) { mFlags |= flag; } void offFlag(u32 flag) { mFlags &= ~flag; } void lock() { onFlag(LOCKED); } void unlock() { offFlag(LOCKED); } - J3DTexMtxObj* getTexMtxObj() const { return mpTexMtxObj; } + J3DTexMtxObj* getTexMtxObj() { return mpTexMtxObj; } bool isLocked() const { return checkFlag(1); } public: /* 0x10 */ u32 mFlags; - /* 0x14 */ char mPad0[0x0C]; // unk + /* 0x14 */ char unk_0x14[0x20 - 0x14]; /* 0x20 */ J3DDisplayListObj* mpDisplayListObj; /* 0x24 */ J3DTexMtxObj* mpTexMtxObj; }; // Size: 0x28 @@ -175,15 +196,23 @@ class J3DShapePacket : public J3DDrawPacket { public: J3DShapePacket(); u32 calcDifferedBufferSize(u32); - J3DError newDifferedDisplayList(u32); + int newDifferedDisplayList(u32); void prepareDraw() const; void drawFast(); virtual ~J3DShapePacket(); virtual void draw(); - void setShape(J3DShape* pShape) { mpShape = pShape; } - void setModel(J3DModel* pModel) { mpModel = pModel; } + void setShape(J3DShape* pShape) { + J3D_ASSERT_NULLPTR(523, pShape != NULL); + mpShape = pShape; + } + + void setModel(J3DModel* pModel) { + J3D_ASSERT_NULLPTR(533, pModel != NULL); + mpModel = pModel; + } + void setMtxBuffer(J3DMtxBuffer* pMtxBuffer) { mpMtxBuffer = pMtxBuffer; } void setBaseMtxPtr(Mtx* pMtx) { mpBaseMtxPtr = pMtx; } @@ -214,13 +243,22 @@ public: J3DMaterial* getMaterial() const { return mpMaterial; } J3DShapePacket* getShapePacket() const { return mpShapePacket; } void setShapePacket(J3DShapePacket* packet) { mpShapePacket = packet; } - void setMaterial(J3DMaterial* pMaterial) { mpMaterial = pMaterial; } - void setTexture(J3DTexture* pTexture) { mpTexture = pTexture; } + + void setMaterial(J3DMaterial* pMaterial) { + J3D_ASSERT_NULLPTR(646, pMaterial != NULL); + mpMaterial = pMaterial; + } + + void setTexture(J3DTexture* pTexture) { + J3D_ASSERT_NULLPTR(651, pTexture != NULL); + mpTexture = pTexture; + } + void setInitShapePacket(J3DShapePacket* packet) { mpInitShapePacket = packet; } void setMaterialID(u32 id) { mDiffFlag = id; } void setMaterialAnmID(J3DMaterialAnm* materialAnm) { mpMaterialAnm = materialAnm; } - bool isChanged() const { return mDiffFlag & 0x80000000; } - bool isEnabled_Diff() const { return mpInitShapePacket->getDisplayListObj() != NULL; } + BOOL isChanged() { return mDiffFlag & J3DDiffFlag_Changed; } + bool isEnabled_Diff() { return mpInitShapePacket->getDisplayListObj() != NULL; } virtual ~J3DMatPacket(); virtual int entry(J3DDrawBuffer*); diff --git a/include/JSystem/J3DGraphBase/J3DShape.h b/include/JSystem/J3DGraphBase/J3DShape.h index 383afb3703..8524af4cf9 100644 --- a/include/JSystem/J3DGraphBase/J3DShape.h +++ b/include/JSystem/J3DGraphBase/J3DShape.h @@ -2,9 +2,9 @@ #define J3DSHAPE_H #include "JSystem/J3DGraphBase/J3DShapeDraw.h" -#include "JSystem/JUtility/JUTAssert.h" -#include "dolphin/gx.h" -#include "mtx.h" +#include "JSystem/J3DAssert.h" +#include "JSystem/J3DGraphBase/J3DFifo.h" +#include <dolphin/mtx.h> class J3DShapeMtx; @@ -18,18 +18,6 @@ public: u32 mMtxIdxRegB; }; -static inline void J3DFifoWriteCPCmd(u8 cmd, u32 param) { - GXWGFifo.u8 = GX_LOAD_CP_REG; - GXWGFifo.u8 = cmd; - GXWGFifo.u32 = param; -} - -static inline void J3DFifoWriteXFCmd(u16 cmd, u16 len) { - GXWGFifo.u8 = GX_LOAD_XF_REG; - GXWGFifo.u16 = (len - 1); - GXWGFifo.u16 = cmd; -} - /** * @ingroup jsystem-j3d * @@ -50,10 +38,10 @@ public: u32 getMtxIdxRegA() const { return mMtxIdxRegA; } u32 getMtxIdxRegB() const { return mMtxIdxRegB; } - inline void load() const { - J3DFifoWriteCPCmd(0x30, mMtxIdxRegA); // CP_MATINDEX_A - J3DFifoWriteCPCmd(0x40, mMtxIdxRegB); // CP_MATINDEX_B - J3DFifoWriteXFCmd(0x1018, 2); + void load() const { + J3DFifoLoadCPCmd(CP_REG_MTXIDXA_ID, mMtxIdxRegA); + J3DFifoLoadCPCmd(CP_REG_MTXIDXB_ID, mMtxIdxRegB); + J3DFifoLoadXFCmdHdr(GX_XF_REG_MATRIXINDEX0, 2); GXCmd1u32(mMtxIdxRegA); GXCmd1u32(mMtxIdxRegB); } @@ -65,17 +53,62 @@ public: } }; +typedef void (J3DShapeMtx::*J3DShapeMtx_LoadFunc)(int, u16) const; + +/** + * @ingroup jsystem-j3d + * + */ +class J3DShapeMtx { +public: + J3DShapeMtx(u16 useMtxIndex) + : mUseMtxIndex(useMtxIndex) + {} + + /* 803130E4 */ void loadMtxIndx_PNGP(int, u16) const; + /* 80313128 */ void loadMtxIndx_PCPU(int, u16) const; + /* 80313188 */ void loadMtxIndx_NCPU(int, u16) const; + /* 803131D4 */ void loadMtxIndx_PNCPU(int, u16) const; + + /* 80314798 */ virtual ~J3DShapeMtx() {} + /* 803147E0 */ virtual u32 getType() const { return 'SMTX'; } + /* 80273E08 */ virtual u16 getUseMtxNum() const { return 1; } + /* 8031459C */ virtual u16 getUseMtxIndex(u16) const { return mUseMtxIndex; } + /* 80313B94 */ virtual void load() const; + /* 80313BF0 */ virtual void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]); + + static J3DShapeMtx_LoadFunc sMtxLoadPipeline[4]; + static u16 sMtxLoadCache[10]; + static u32 sCurrentPipeline; + static u8* sCurrentScaleFlag; + static bool sNBTFlag; + static bool sLODFlag; + static u32 sTexMtxLoadType; + + static void setCurrentPipeline(u32 pipeline) { + J3D_ASSERT_RANGE(91, pipeline < 4); + sCurrentPipeline = pipeline; + } + + static void setLODFlag(bool flag) { sLODFlag = flag; } + static u32 getLODFlag() { return sLODFlag; } + static void resetMtxLoadCache(); + +protected: + /* 0x04 */ u16 mUseMtxIndex; +}; + class J3DMaterial; class J3DVertexData; class J3DDrawMtxData; enum J3DShpFlag { - J3DShpFlag_Visible = 0x0001, + J3DShpFlag_Visible = 0x0001, J3DShpFlag_SkinPosCpu = 0x0004, J3DShpFlag_SkinNrmCpu = 0x0008, - J3DShpFlag_Hidden = 0x0010, - J3DShpFlag_EnableLod = 0x0100, - J3DShpFlag_NoMtx = 0x0200, + J3DShpFlag_Hidden = 0x0010, + J3DShpFlag_EnableLod = 0x0100, + J3DShpFlag_NoMtx = 0x0200, }; /** @@ -88,9 +121,7 @@ public: initialize(); } - enum { - kVcdVatDLSize = 0xC0, - }; + static const int kVcdVatDLSize = 0xC0; /* 80314B48 */ void initialize(); /* 80314BB8 */ void addTexMtxIndexInDL(_GXAttr, u32); @@ -109,18 +140,44 @@ public: /* 80315628 */ virtual void simpleDraw() const; /* 803156AC */ virtual void simpleDrawCache() const; + void loadCurrentMtx() const; + void onFlag(u32 flag) { mFlags |= flag; } void offFlag(u32 flag) { mFlags &= ~flag; } - bool checkFlag(u32 flag) const { return !!(mFlags & flag); } - void setDrawMtxDataPointer(J3DDrawMtxData* pMtxData) { mDrawMtxData = pMtxData; } - void setVertexDataPointer(J3DVertexData* pVtxData) { mVertexData = pVtxData; } + bool checkFlag(u32 flag) const { return (mFlags & flag) != 0; } + + void setMaterial(J3DMaterial* pMaterial) { + J3D_ASSERT_NULLPTR(509, pMaterial != NULL); + mMaterial = pMaterial; + } + + void setDrawMtxDataPointer(J3DDrawMtxData* pMtxData) { + J3D_ASSERT_NULLPTR(554, pMtxData != NULL); + mDrawMtxData = pMtxData; + } + + void setVertexDataPointer(J3DVertexData* pVtxData) { + J3D_ASSERT_NULLPTR(657, pVtxData != NULL); + mVertexData = pVtxData; + } + void* getVcdVatCmd() { return mVcdVatCmd; } void setVcdVatCmd(void* pVatCmd) { mVcdVatCmd = (u8*)pVatCmd; } void show() { offFlag(J3DShpFlag_Visible); } void hide() { onFlag(J3DShpFlag_Visible); } - void setCurrentViewNoPtr(u32* pViewNoPtr) { mCurrentViewNo = pViewNoPtr; } + + void setCurrentViewNoPtr(u32* pViewNoPtr) { + J3D_ASSERT_NULLPTR(584, pViewNoPtr != NULL); + mCurrentViewNo = pViewNoPtr; + } + void setCurrentMtx(J3DCurrentMtx& mtx) { mCurrentMtx = mtx; } - void setScaleFlagArray(u8* pScaleFlagArray) { mScaleFlagArray = pScaleFlagArray; } + + void setScaleFlagArray(u8* pScaleFlagArray) { + J3D_ASSERT_NULLPTR(595, pScaleFlagArray != NULL); + mScaleFlagArray = pScaleFlagArray; + } + void setDrawMtx(Mtx** pDrawMtx) { mDrawMtx = pDrawMtx; } void setNrmMtx(Mtx33** pNrmMtx) { mNrmMtx = pNrmMtx; } void setTexMtxLoadType(u32 type) { mFlags = (mFlags & 0xFFFF0FFF) | type; } @@ -141,6 +198,7 @@ public: static void resetVcdVatCache() { sOldVcdVatCmd = NULL; } static void* sOldVcdVatCmd; + static bool sEnvelopeFlag; private: friend struct J3DShapeFactory; @@ -169,48 +227,4 @@ private: /* 0x64 */ u32 mBumpMtxOffset; }; -typedef void (J3DShapeMtx::*J3DShapeMtx_LoadFunc)(int, u16) const; - -/** - * @ingroup jsystem-j3d - * - */ -class J3DShapeMtx { -public: - J3DShapeMtx(u16 useMtxIndex) - : mUseMtxIndex(useMtxIndex) - {} - - /* 803130E4 */ void loadMtxIndx_PNGP(int, u16) const; - /* 80313128 */ void loadMtxIndx_PCPU(int, u16) const; - /* 80313188 */ void loadMtxIndx_NCPU(int, u16) const; - /* 803131D4 */ void loadMtxIndx_PNCPU(int, u16) const; - - /* 80314798 */ virtual ~J3DShapeMtx() {} - /* 803147E0 */ virtual u32 getType() const { return 'SMTX'; } - /* 80273E08 */ virtual u16 getUseMtxNum() const { return 1; } - /* 8031459C */ virtual u16 getUseMtxIndex(u16) const { return mUseMtxIndex; } - /* 80313B94 */ virtual void load() const; - /* 80313BF0 */ virtual void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]); - - static J3DShapeMtx_LoadFunc sMtxLoadPipeline[4]; - static u16 sMtxLoadCache[10]; - static u32 sCurrentPipeline; - static u8* sCurrentScaleFlag; - static u8 sNBTFlag; - static u8 sLODFlag; - static u32 sTexMtxLoadType; - - static void setCurrentPipeline(u32 pipeline) { - J3D_ASSERT(91, pipeline < 4, "Error : range over."); - sCurrentPipeline = pipeline; - } - static void setLODFlag(u8 flag) { sLODFlag = flag; } - static u32 getLODFlag() { return sLODFlag; } - static void resetMtxLoadCache(); - -protected: - /* 0x04 */ u16 mUseMtxIndex; -}; - #endif /* J3DSHAPE_H */ diff --git a/include/JSystem/J3DGraphBase/J3DShapeMtx.h b/include/JSystem/J3DGraphBase/J3DShapeMtx.h index bf15ff84e4..f269c0594b 100644 --- a/include/JSystem/J3DGraphBase/J3DShapeMtx.h +++ b/include/JSystem/J3DGraphBase/J3DShapeMtx.h @@ -2,6 +2,7 @@ #define J3DSHAPEMTX_H #include "JSystem/J3DGraphBase/J3DShape.h" +#include "JSystem/J3DAssert.h" #include "dolphin/mtx.h" class J3DTexMtx; @@ -14,15 +15,21 @@ class J3DTexGenBlock; class J3DTexMtxObj { public: Mtx& getMtx(u16 idx) { - J3D_ASSERT(0x113, idx <= mTexMtxNum, "Error : range over"); + J3D_ASSERT_RANGE(275, idx < mTexMtxNum); return mpTexMtx[idx]; } + + void setMtx(u16 idx, const Mtx mtx) { + J3D_ASSERT_RANGE(288, idx < mTexMtxNum); + MTXCopy(mtx, mpTexMtx[idx]); + } + Mtx44& getEffectMtx(u16 idx) { - J3D_ASSERT(0x125, idx <= mTexMtxNum, "Error : range over"); + J3D_ASSERT_RANGE(293, idx < mTexMtxNum); return mpEffectMtx[idx]; } + u16 getNumTexMtx() const { return mTexMtxNum; } - void setMtx(u16 idx, Mtx const* mtx) { MTXCopy(*mtx, mpTexMtx[idx]); } /* 0x00 */ Mtx* mpTexMtx; /* 0x04 */ Mtx44* mpEffectMtx; @@ -37,7 +44,7 @@ class J3DDifferedTexMtx { public: /* 8031322C */ static void loadExecute(f32 const (*)[4]); - static inline void load(Mtx m) { + static inline void load(const Mtx m) { if (sTexGenBlock != NULL) loadExecute(m); } diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h index 4e483ddb11..c8bff4d49f 100644 --- a/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/include/JSystem/J3DGraphBase/J3DStruct.h @@ -142,7 +142,7 @@ struct J3DFogInfo { struct J3DNBTScaleInfo { /* 8032587C */ J3DNBTScaleInfo& operator=(J3DNBTScaleInfo const&); - /* 0x0 */ bool mbHasScale; + /* 0x0 */ u8 mbHasScale; /* 0x4 */ Vec mScale; }; // Size: 0x10 diff --git a/include/JSystem/J3DGraphBase/J3DSys.h b/include/JSystem/J3DGraphBase/J3DSys.h index 61609050c5..141ec0296e 100644 --- a/include/JSystem/J3DGraphBase/J3DSys.h +++ b/include/JSystem/J3DGraphBase/J3DSys.h @@ -3,7 +3,7 @@ #include <dolphin/gx.h> #include <dolphin/mtx.h> -#include "JSystem/JUtility/JUTAssert.h" +#include "JSystem/J3DAssert.h" // Perhaps move to a new J3DEnum.h? enum J3DError { @@ -11,9 +11,11 @@ enum J3DError { kJ3DError_Alloc = 4, }; -enum J3DSysDrawBuffer { - /* 0x0 */ J3DSys_OPA_BUFFER_e, - /* 0x1 */ J3DSys_XLU_BUFFER_e +enum J3DSysDrawBuf { + /* 0x0 */ J3DSysDrawBuf_Opa, + /* 0x1 */ J3DSysDrawBuf_Xlu, + + /* 0x2 */ J3DSysDrawBuf_MAX }; class J3DMtxCalc; @@ -53,25 +55,25 @@ struct J3DSys { /* 0x03C */ J3DMatPacket* mMatPacket; /* 0x040 */ J3DShapePacket* mShapePacket; /* 0x044 */ J3DShape* mShape; - /* 0x048 */ J3DDrawBuffer* mDrawBuffer[2]; + /* 0x048 */ J3DDrawBuffer* mDrawBuffer[J3DSysDrawBuf_MAX]; /* 0x050 */ u32 mDrawMode; /* 0x054 */ u32 mMaterialMode; /* 0x058 */ J3DTexture* mTexture; - /* 0x05C */ u8 field_0x5c[0x04]; + /* 0x05C */ u8 unk_0x5c[0x60 - 0x5C]; /* 0x060 */ u32 mTexCacheRegionNum; /* 0x064 */ GXTexRegion mTexCacheRegion[8]; - /* 0x0E4 */ u8 field_0xe4[0x20]; + /* 0x0E4 */ u8 unk_0xe4[0x104 - 0xE4]; /* 0x104 */ Mtx* mModelDrawMtx; /* 0x108 */ Mtx33* mModelNrmMtx; /* 0x10C */ void* mVtxPos; /* 0x110 */ void* mVtxNrm; - /* 0x114 */ _GXColor* mVtxCol; + /* 0x114 */ GXColor* mVtxCol; /* 0x118 */ Vec* mNBTScale; /* 8030FDE8 */ J3DSys(); /* 8030FEC0 */ void loadPosMtxIndx(int, u16) const; /* 8030FEE4 */ void loadNrmMtxIndx(int, u16) const; - /* 8030FF0C */ void setTexCacheRegion(_GXTexCacheSize); + /* 8030FF0C */ void setTexCacheRegion(GXTexCacheSize); /* 803100BC */ void drawInit(); /* 8031073C */ void reinitGX(); /* 8031079C */ void reinitGenMode(); @@ -82,16 +84,15 @@ struct J3DSys { /* 80310D44 */ void reinitIndStages(); /* 80310E3C */ void reinitPixelProc(); - enum DrawMode { - /* 0x3 */ OPA_TEX_EDGE = 3, - /* 0x4 */ XLU, + enum J3DSysDrawMode { + J3DSysDrawMode_OpaTexEdge = 3, + J3DSysDrawMode_Xlu }; MtxP getViewMtx() { return mViewMtx; } - void setDrawModeOpaTexEdge() { mDrawMode = OPA_TEX_EDGE; } - - void setDrawModeXlu() { mDrawMode = XLU; } + void setDrawModeOpaTexEdge() { mDrawMode = J3DSysDrawMode_OpaTexEdge; } + void setDrawModeXlu() { mDrawMode = J3DSysDrawMode_Xlu; } void* getVtxPos() { return mVtxPos; } void setVtxPos(void* pVtxPos) { mVtxPos = pVtxPos; } @@ -99,15 +100,35 @@ struct J3DSys { void* getVtxNrm() { return mVtxNrm; } void setVtxNrm(void* pVtxNrm) { mVtxNrm = pVtxNrm; } - void* getVtxCol() const { return mVtxCol; } - void setVtxCol(_GXColor* pVtxCol) { mVtxCol = pVtxCol; } + void* getVtxCol() { return mVtxCol; } + void setVtxCol(GXColor* pVtxCol) { mVtxCol = pVtxCol; } + + void setDrawBuffer(J3DDrawBuffer* buffer, int type) { + J3D_ASSERT_RANGE(114, type >= 0 && type < J3DSysDrawBuf_MAX); + J3D_ASSERT_NULLPTR(115, buffer); + mDrawBuffer[type] = buffer; + } + + J3DDrawBuffer* getDrawBuffer(int type) { + J3D_ASSERT_RANGE(121, type >= 0 && type < J3DSysDrawBuf_MAX); + return mDrawBuffer[type]; + } + + void setMatPacket(J3DMatPacket* pPacket) { + J3D_ASSERT_NULLPTR(162, pPacket != NULL); + mMatPacket = pPacket; + } + + void setShapePacket(J3DShapePacket* pPacket) { + J3D_ASSERT_NULLPTR(172, pPacket != NULL); + mShapePacket = pPacket; + } void setModel(J3DModel* pModel) { - J3D_ASSERT(200, pModel, "Error : null pointer."); + J3D_ASSERT_NULLPTR(200, pModel != NULL); mModel = pModel; } - void setShapePacket(J3DShapePacket* pPacket) { mShapePacket = pPacket; } - void setMatPacket(J3DMatPacket* pPacket) { mMatPacket = pPacket; } + J3DMatPacket* getMatPacket() { return mMatPacket; } void setMaterialMode(u32 mode) { mMaterialMode = mode; } @@ -124,34 +145,20 @@ struct J3DSys { void offFlag(u32 flag) { mFlags &= ~flag; } - bool checkFlag(u32 flag) { return mFlags & flag; } + bool checkFlag(u32 flag) { return mFlags & flag ? true : false; } void setModelDrawMtx(Mtx* pMtxArr) { + J3D_ASSERT_NULLPTR(230, pMtxArr); mModelDrawMtx = pMtxArr; GXSetArray(GX_POS_MTX_ARRAY, mModelDrawMtx, sizeof(*mModelDrawMtx)); } void setModelNrmMtx(Mtx33* pMtxArr) { - JUT_ASSERT_MSG(241, pMtxArr, "Error : null pointer."); + J3D_ASSERT_NULLPTR(241, pMtxArr); mModelNrmMtx = pMtxArr; GXSetArray(GX_NRM_MTX_ARRAY, mModelNrmMtx, sizeof(*mModelNrmMtx)); } - // Type 0: Opa Buffer - // Type 1: Xlu Buffer - void setDrawBuffer(J3DDrawBuffer* buffer, int type) { - J3D_ASSERT(114, type >= 0 && type < 2, "Error : range over."); - J3D_ASSERT(115, buffer, "Error : null pointer."); - mDrawBuffer[type] = buffer; - } - - // Type 0: Opa Buffer - // Type 1: Xlu Buffer - J3DDrawBuffer* getDrawBuffer(int type) { - J3D_ASSERT(121, type >= 0 && type < 2, "Error : range over."); - return mDrawBuffer[type]; - } - Mtx& getModelDrawMtx(u16 no) { return mModelDrawMtx[no]; } J3DShapePacket* getShapePacket() { return mShapePacket; } diff --git a/include/JSystem/J3DGraphBase/J3DTevs.h b/include/JSystem/J3DGraphBase/J3DTevs.h index 23ddda86de..e5c06c97c7 100644 --- a/include/JSystem/J3DGraphBase/J3DTevs.h +++ b/include/JSystem/J3DGraphBase/J3DTevs.h @@ -153,6 +153,16 @@ struct J3DTevStage { return *this; } + J3DTevStage& operator=(J3DTevStage& other) { + mTevColorOp = other.mTevColorOp; + mTevColorAB = other.mTevColorAB; + mTevColorCD = other.mTevColorCD; + mTevAlphaOp = other.mTevAlphaOp; + mTevAlphaAB = other.mTevAlphaAB; + mTevSwapModeInfo = other.mTevSwapModeInfo; + return *this; + } + /* 0x0 */ u8 field_0x0; /* 0x1 */ u8 mTevColorOp; /* 0x2 */ u8 mTevColorAB; @@ -214,6 +224,16 @@ struct J3DIndTevStage { J3DGDWriteBPCmd(mInfo | (param_1 + 0x10) * 0x1000000); } + J3DIndTevStage& operator=(const J3DIndTevStage& other) { + mInfo = other.mInfo; + return *this; + } + + J3DIndTevStage& operator=(J3DIndTevStage& other) { + mInfo = other.mInfo; + return *this; + } + /* 0x0 */ u32 mInfo; }; @@ -264,6 +284,11 @@ struct J3DTevSwapModeTable { return *this; } + J3DTevSwapModeTable& operator=(J3DTevSwapModeTable& other) { + mIdx = other.mIdx; + return *this; + } + u8 calcTevSwapTableID(u8 param_0, u8 param_1, u8 param_2, u8 param_3) { return 0x40 * param_0 + 0x10 * param_1 + 4 * param_2 + param_3; } @@ -281,6 +306,7 @@ extern const GXColor j3dDefaultAmbInfo; extern const GXColorS10 j3dDefaultTevColor; extern const GXColor j3dDefaultTevKColor; extern u8 j3dAlphaCmpTable[768]; +extern const u8 j3dDefaultNumChans; struct J3DNBTScale; struct J3DTexCoord; @@ -290,5 +316,9 @@ void loadTexNo(u32 param_0, u16 const& param_1); void patchTexNo_PtrToIdx(u32 texID, u16 const& idx); bool isTexNoReg(void* param_0); u16 getTexNoReg(void* param_0); +void makeTexCoordTable(); +void makeAlphaCmpTable(); +void makeZModeTable(); +void makeTevSwapTable(); #endif /* J3DTEVS_H */ diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h index 98b1a92295..66b6df3a40 100644 --- a/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -2,9 +2,9 @@ #define J3DTEXTURE_H #include "JSystem/J3DGraphBase/J3DStruct.h" -#include "JSystem/JUtility/JUTAssert.h" +#include "JSystem/J3DAssert.h" #include "JSystem/JUtility/JUTTexture.h" -#include "dolphin/types.h" +#include <stdint.h> /** * @ingroup jsystem-j3d @@ -13,25 +13,28 @@ class J3DTexture { private: /* 0x0 */ u16 mNum; - /* 0x2 */ u16 field_0x2; + /* 0x2 */ u16 unk_0x2; /* 0x4 */ ResTIMG* mpRes; public: - J3DTexture(u16 num, ResTIMG* res) : mNum(num), field_0x2(0), mpRes(res) {} - /* 8031204C */ void loadGX(u16, _GXTexMapID) const; + J3DTexture(u16 num, ResTIMG* res) : mNum(num), unk_0x2(0), mpRes(res) {} + + /* 8031204C */ void loadGX(u16, GXTexMapID) const; /* 803121A4 */ void entryNum(u16); /* 8031221C */ void addResTIMG(u16, ResTIMG const*); /* 803366A4 */ virtual ~J3DTexture() {} u16 getNum() const { return mNum; } - ResTIMG* getResTIMG(u16 entry) const { - J3D_ASSERT(72, entry < mNum, "Error : range over."); - return &mpRes[entry]; + + ResTIMG* getResTIMG(u16 index) const { + J3D_ASSERT_RANGE(72, index < mNum); + return &mpRes[index]; } - void setResTIMG(u16 entry, const ResTIMG& timg) { - mpRes[entry] = timg; - mpRes[entry].imageOffset = ((mpRes[entry].imageOffset + (u32)&timg - (u32)(mpRes + entry))); - mpRes[entry].paletteOffset = ((mpRes[entry].paletteOffset + (u32)&timg - (u32)(mpRes + entry))); + + void setResTIMG(u16 index, const ResTIMG& timg) { + mpRes[index] = timg; + mpRes[index].imageOffset = ((mpRes[index].imageOffset + (uintptr_t)&timg - (uintptr_t)(mpRes + index))); + mpRes[index].paletteOffset = ((mpRes[index].paletteOffset + (uintptr_t)&timg - (uintptr_t)(mpRes + index))); } }; @@ -46,9 +49,11 @@ public: J3DTexMtx() { mTexMtxInfo = j3dDefaultTexMtxInfo; } + J3DTexMtx(const J3DTexMtxInfo& info) { mTexMtxInfo = info; } + /* 803238C4 */ void load(u32) const; /* 80323900 */ void calc(const Mtx); /* 80323920 */ void calcTexMtx(const Mtx); @@ -103,7 +108,7 @@ struct J3DTexCoord : public J3DTexCoordInfo { void setTexMtxReg(u16 reg) { mTexMtxReg = reg; } J3DTexCoord& operator=(const J3DTexCoord& other) { // Fake match (__memcpy or = doesn't match) - *(u32*)this = *(u32*)&other; + *(uintptr_t*)this = *(uintptr_t*)&other; return *this; } diff --git a/include/JSystem/J3DGraphBase/J3DTransform.h b/include/JSystem/J3DGraphBase/J3DTransform.h index 384e132385..45e79de06f 100644 --- a/include/JSystem/J3DGraphBase/J3DTransform.h +++ b/include/JSystem/J3DGraphBase/J3DTransform.h @@ -1,8 +1,7 @@ #ifndef J3DTRANSFORM_H #define J3DTRANSFORM_H -#include "JSystem/JGeometry.h" -#include "dolphin/mtx.h" +#include <dolphin/mtx.h> struct J3DTextureSRTInfo; diff --git a/include/JSystem/J3DGraphBase/J3DVertex.h b/include/JSystem/J3DGraphBase/J3DVertex.h index 7c46b38a61..38b969f730 100644 --- a/include/JSystem/J3DGraphBase/J3DVertex.h +++ b/include/JSystem/J3DGraphBase/J3DVertex.h @@ -29,6 +29,7 @@ struct J3DVtxColorCalc { class J3DVertexData { public: J3DVertexData(); + ~J3DVertexData() {} void* getVtxPosArray() const { return mVtxPosArray; } void* getVtxNrmArray() const { return mVtxNrmArray; } @@ -38,10 +39,10 @@ public: u32 getNrmNum() const { return mNrmNum; } u32 getVtxNum() const { return mVtxNum; } GXVtxAttrFmtList* getVtxAttrFmtList() const { return mVtxAttrFmtList; } - u8 getVtxPosFrac() { return mVtxPosFrac; } - u8 getVtxNrmFrac() { return mVtxNrmFrac; } - int getVtxPosType() { return mVtxPosType; } - int getVtxNrmType() { return mVtxNrmType; } + u8 getVtxPosFrac() const { return mVtxPosFrac; } + u8 getVtxNrmFrac() const { return mVtxNrmFrac; } + int getVtxPosType() const { return mVtxPosType; } + int getVtxNrmType() const { return mVtxNrmType; } void setVtxPosFrac(u8 frac) { mVtxPosFrac = frac; } void setVtxPosType(GXCompType type) { mVtxPosType = type; } @@ -148,8 +149,4 @@ private: /* 0x34 */ GXColor* mCurrentVtxCol; }; // Size: 0x38 -struct VertexNormal { - Vec data; -}; - #endif /* J3DVERTEX_H */ diff --git a/include/JSystem/JAudio2/JAISeqDataMgr.h b/include/JSystem/JAudio2/JAISeqDataMgr.h index bc6e1de468..d4118ffd94 100644 --- a/include/JSystem/JAudio2/JAISeqDataMgr.h +++ b/include/JSystem/JAudio2/JAISeqDataMgr.h @@ -2,6 +2,7 @@ #define JAISEQDATAMGR_H #include "JSystem/JAudio2/JAISound.h" +#include <stdint.h> /** * @ingroup jsystem-jaudio @@ -28,10 +29,10 @@ struct JAISeqData { */ struct JAISeqDataRegion { bool intersects(JAISeqData& seqData) const { - if ((u32)addr + size < (u32)seqData.field_0x0) { + if ((uintptr_t)addr + size < (uintptr_t)seqData.field_0x0) { return false; } - if ((u32)seqData.field_0x0 + seqData.field_0x4 < (u32)addr) { + if ((uintptr_t)seqData.field_0x0 + seqData.field_0x4 < (uintptr_t)addr) { return false; } return true; diff --git a/include/JSystem/JAudio2/JAUStreamAramMgr.h b/include/JSystem/JAudio2/JAUStreamAramMgr.h index 86324e7601..9ce6f094c1 100644 --- a/include/JSystem/JAudio2/JAUStreamAramMgr.h +++ b/include/JSystem/JAudio2/JAUStreamAramMgr.h @@ -64,7 +64,7 @@ public: if (!this->field_0x4.test(i)) { continue; } - if ((u32)this->mHeaps[i].getBase() != param_0) { + if ((uintptr_t)this->mHeaps[i].getBase() != param_0) { continue; } this->field_0x4.reset(i); diff --git a/include/JSystem/JGadget/std-vector.h b/include/JSystem/JGadget/std-vector.h index 95fb777644..7732a2861d 100644 --- a/include/JSystem/JGadget/std-vector.h +++ b/include/JSystem/JGadget/std-vector.h @@ -4,6 +4,7 @@ #include "JSystem/JGadget/std-memory.h" #include <algorithm.h> #include <msl_memory.h> +#include <stdint.h> namespace JGadget { namespace vector { @@ -105,7 +106,7 @@ struct TVector { } T* insert(T* pos, const T& val) { - u32 diff = (int)((u32)pos - (u32)begin()) / 4; + u32 diff = (int)((uintptr_t)pos - (uintptr_t)begin()) / 4; insert(pos, 1, val); return pBegin_ + diff; } @@ -118,7 +119,7 @@ struct TVector { if (pBegin_ == 0) { return 0; } - return (int)((u32)pEnd_ - (u32)pBegin_) / 4; + return (int)((uintptr_t)pEnd_ - (uintptr_t)pBegin_) / 4; } u32 capacity() { return mCapacity; } diff --git a/include/JSystem/JHostIO/JORMContext.h b/include/JSystem/JHostIO/JORMContext.h index 930e66b2d8..f7d68c9776 100644 --- a/include/JSystem/JHostIO/JORMContext.h +++ b/include/JSystem/JHostIO/JORMContext.h @@ -4,6 +4,7 @@ #include <dolphin.h> #include "JSystem/JSupport/JSUMemoryStream.h" #include "JSystem/JHostIO/JORReflexible.h" +#include <stdint.h> #define MCTX_MSG_RESET 0 #define MCTX_MSG_GET_ROOT_OBJ 2 @@ -29,7 +30,7 @@ #define DEFINE_GEN_CHECKBOX(T, kind) \ void genCheckBox(const char* label, T* pSrc, T mask, u32 style, JOREventListener* pListener, \ u16 posX, u16 posY, u16 width, u16 height) { \ - genCheckBoxSub(kind, label, (u32)pSrc, style, *pSrc, mask, pListener, posX, posY, width, \ + genCheckBoxSub(kind, label, (uintptr_t)pSrc, style, *pSrc, mask, pListener, posX, posY, width, \ height); \ } @@ -43,7 +44,7 @@ #define DEFINE_GEN_SLIDER(T, kind) \ void genSlider(const char* label, T* pSrc, T rangeMin, T rangeMax, u32 style, \ JOREventListener* pListener, u16 posX, u16 posY, u16 width, u16 height) { \ - genSliderSub(kind, label, (u32)pSrc, style, *pSrc, rangeMin, rangeMax, pListener, posX, \ + genSliderSub(kind, label, (uintptr_t)pSrc, style, *pSrc, rangeMin, rangeMax, pListener, posX, \ posY, width, height); \ } @@ -57,7 +58,7 @@ #define DEFINE_START_COMBO_BOX(T, kind) \ void startComboBox(const char* label, T* pSrc, u32 style, \ JOREventListener* pListener, u16 posX, u16 posY, u16 width, u16 height) { \ - startSelectorSub('CMBX', kind, label, (u32)pSrc, style, *pSrc, pListener, posX, \ + startSelectorSub('CMBX', kind, label, (uintptr_t)pSrc, style, *pSrc, pListener, posX, \ posY, width, height); \ } @@ -70,7 +71,7 @@ #define DEFINE_UPDATE_SLIDER(T) \ void updateSlider(u32 mode, T* pSrc, T rangeMin, T rangeMax, u32 param_5) { \ - updateSliderSub(mode, (u32) pSrc, *pSrc, rangeMin, rangeMax, param_5); \ + updateSliderSub(mode, (uintptr_t)pSrc, *pSrc, rangeMin, rangeMax, param_5); \ } #define DEFINE_UPDATE_SLIDER_ID(T) \ @@ -252,7 +253,7 @@ public: void updateEditBoxID(u32 mode, u32 id, const char* string, u32 param_3, u16 length); void updateCheckBox(u32 mode, u8* pSrc, u8 mask, u32 param_4) { - updateCheckBoxSub(mode, (u32) pSrc, *pSrc, mask, param_4); + updateCheckBoxSub(mode, (uintptr_t)pSrc, *pSrc, mask, param_4); } void updateCheckBoxID(u32 mode, u32 id, u8 value, u8 mask, u32 param_4) { diff --git a/include/JSystem/JKernel/JKRExpHeap.h b/include/JSystem/JKernel/JKRExpHeap.h index 5ef7b026f7..59b914dc2d 100644 --- a/include/JSystem/JKernel/JKRExpHeap.h +++ b/include/JSystem/JKernel/JKRExpHeap.h @@ -2,6 +2,7 @@ #define JKREXPHEAP_H #include "JSystem/JKernel/JKRHeap.h" +#include <stdint.h> /** * @ingroup jsystem-jkernel @@ -34,7 +35,7 @@ public: CMemBlock* getNextBlock() const { return mNext; } u32 getSize() const { return size; } u8 getGroupId() const { return mGroupId; } - static CMemBlock* getBlock(void* data) { return (CMemBlock*)((u32)data + -0x10); } + static CMemBlock* getBlock(void* data) { return (CMemBlock*)((uintptr_t)data + -0x10); } private: /* 0x0 */ u16 mMagic; diff --git a/include/JSystem/JMath/JMATrigonometric.h b/include/JSystem/JMath/JMATrigonometric.h index 1b88975794..25b79a72dc 100644 --- a/include/JSystem/JMath/JMATrigonometric.h +++ b/include/JSystem/JMath/JMATrigonometric.h @@ -2,8 +2,9 @@ #define JMATRIGONOMETRIC_H #include "dolphin/types.h" -#include "utility.h" +#include <utility.h> +namespace JMath { template<typename T> struct TAngleConstant_; @@ -19,7 +20,6 @@ struct TAngleConstant_<f32> { static f32 RADIAN_TO_DEGREE_FACTOR() { return 180.0f / RADIAN_DEG180(); } }; -namespace JMath { /** * @ingroup jsystem-jmath * @@ -73,30 +73,31 @@ struct TAtanTable { * @ingroup jsystem-jmath * */ +template<int N, typename T> struct TAsinAcosTable { - f32 table[1025]; + T table[1025]; u8 pad[0x1C]; - f32 acos_(f32 x) { + T acos_(T x) const { if (x >= 1.0f) { return 0.0f; } else if (x <= -1.0f) { - return TAngleConstant_<f32>::RADIAN_DEG180(); + return TAngleConstant_<T>::RADIAN_DEG180(); } else if (x < 0.0f) { - return table[(u32)(-x * 1023.5f)] + TAngleConstant_<f32>::RADIAN_DEG090(); + return table[(u32)(-x * 1023.5f)] + TAngleConstant_<T>::RADIAN_DEG090(); } else { - return TAngleConstant_<f32>::RADIAN_DEG090() - table[(u32)(x * 1023.5f)]; + return TAngleConstant_<T>::RADIAN_DEG090() - table[(u32)(x * 1023.5f)]; } } - f32 acosDegree(f32 x) { - return acos_(x) * TAngleConstant_<f32>::RADIAN_TO_DEGREE_FACTOR(); + T acosDegree(T x) const { + return acos_(x) * TAngleConstant_<T>::RADIAN_TO_DEGREE_FACTOR(); } }; extern TSinCosTable<13, f32> sincosTable_; extern TAtanTable atanTable_; -extern TAsinAcosTable asinAcosTable_; +extern TAsinAcosTable<1024, f32> asinAcosTable_; inline f32 acosDegree(f32 x) { return asinAcosTable_.acosDegree(x); diff --git a/include/JSystem/JMath/JMath.h b/include/JSystem/JMath/JMath.h index eb7932e848..4d9dd66608 100644 --- a/include/JSystem/JMath/JMath.h +++ b/include/JSystem/JMath/JMath.h @@ -80,6 +80,11 @@ inline f32 JMAHermiteInterpolation(register f32 p1, register f32 p2, register f3 namespace JMath { +template <typename T> +inline T fastSqrt(T value) { + return JMAFastSqrt(value); +} + inline f32 fastReciprocal(f32 value) { return JMAFastReciprocal(value); } diff --git a/include/JSystem/JParticle/JPAEmitter.h b/include/JSystem/JParticle/JPAEmitter.h index fec8d3128c..21a2f590ad 100644 --- a/include/JSystem/JParticle/JPAEmitter.h +++ b/include/JSystem/JParticle/JPAEmitter.h @@ -2,6 +2,7 @@ #define JPAEMITTER_H #include <dolphin/gx.h> +#include <stdint.h> #include "JSystem/JParticle/JPAResource.h" #include "JSystem/JParticle/JPAList.h" #include "JSystem/JParticle/JPARandom.h" @@ -197,8 +198,8 @@ public: void stopDrawParticle() { setStatus(JPAEmtrStts_StopDraw); } void playDrawParticle() { clearStatus(JPAEmtrStts_StopDraw); } - u32 getUserWork() { return mpUserWork; } - void setUserWork(u32 userWork) { mpUserWork = userWork; } + uintptr_t getUserWork() { return mpUserWork; } + void setUserWork(uintptr_t userWork) { mpUserWork = userWork; } u32 getParticleNumber() const { return mAlivePtclBase.getNum() + mAlivePtclChld.getNum(); } diff --git a/include/JSystem/JStudio/JStudio/jstudio-object.h b/include/JSystem/JStudio/JStudio/jstudio-object.h index c1f98384d6..a85b8dfb57 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-object.h +++ b/include/JSystem/JStudio/JStudio/jstudio-object.h @@ -225,7 +225,7 @@ struct TAdaptor_actor : public TAdaptor { }; TAdaptor_actor() - : TAdaptor(mValue, ARRAY_SIZE(mValue)) + : TAdaptor(mValue, ARRAY_SIZEU(mValue)) , mValue() { } diff --git a/include/JSystem/JSupport/JSupport.h b/include/JSystem/JSupport/JSupport.h index c4a47c61a9..b3bb337951 100644 --- a/include/JSystem/JSupport/JSupport.h +++ b/include/JSystem/JSupport/JSupport.h @@ -2,17 +2,18 @@ #define JSUPPORT_H #include <dolphin.h> +#include <stdint.h> /** * @ingroup jsystem-jsupport * */ template <typename T> -T* JSUConvertOffsetToPtr(const void* ptr, u32 offset) { +T* JSUConvertOffsetToPtr(const void* ptr, uintptr_t offset) { if (offset == 0) { return NULL; } else { - return (T*)((s32)ptr + (s32)offset); + return (T*)((intptr_t)ptr + (intptr_t)offset); } } @@ -25,7 +26,7 @@ T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) { if (offset == NULL) { return NULL; } else { - return (T*)((s32)ptr + (s32)offset); + return (T*)((intptr_t)ptr + (intptr_t)offset); } } diff --git a/include/JSystem/JUtility/JUTAssert.h b/include/JSystem/JUtility/JUTAssert.h index 2e7b126dc0..c33f590944 100644 --- a/include/JSystem/JUtility/JUTAssert.h +++ b/include/JSystem/JUtility/JUTAssert.h @@ -13,7 +13,6 @@ #define JUT_ASSERT_MSG_F(LINE, COND, MSG, ...) \ (COND) ? (void)0 : (JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), __FILE__, LINE, MSG, __VA_ARGS__), OSPanic(__FILE__, LINE, "Halt")); -#define J3D_ASSERT(LINE, COND, MSG) JUT_ASSERT_MSG(LINE, (COND) != 0, MSG) #define J3D_PANIC(LINE, COND, MSG) ((COND) != 0 || (OSPanic(__FILE__, LINE, MSG), 0)); #define JUT_PANIC(LINE, TEXT) \ @@ -36,7 +35,6 @@ #define JUT_ASSERT(...) (void)0; #define JUT_ASSERT_MSG(...) (void)0; #define JUT_ASSERT_MSG_F(...) (void)0; -#define J3D_ASSERT(...) (void)0; #define J3D_PANIC(...) (void)0; #define JUT_PANIC(...) #define JUT_WARN(...) diff --git a/include/JSystem/JUtility/JUTTexture.h b/include/JSystem/JUtility/JUTTexture.h index 606cd5811c..c42bc09b1f 100644 --- a/include/JSystem/JUtility/JUTTexture.h +++ b/include/JSystem/JUtility/JUTTexture.h @@ -2,6 +2,7 @@ #define JUTTEXTURE_H #include <dolphin/gx.h> +#include <stdint.h> class JUTPalette; @@ -24,7 +25,7 @@ struct ResTIMG { /* 0x08 */ u8 indexTexture; /* 0x09 */ u8 colorFormat; /* 0x0A */ u16 numColors; - /* 0x0C */ u32 paletteOffset; + /* 0x0C */ uintptr_t paletteOffset; /* 0x10 */ u8 mipmapEnabled; /* 0x11 */ u8 doEdgeLOD; /* 0x12 */ u8 biasClamp; @@ -36,7 +37,7 @@ struct ResTIMG { /* 0x18 */ u8 mipmapCount; /* 0x19 */ u8 unknown; /* 0x1A */ s16 LODBias; - /* 0x1C */ u32 imageOffset; + /* 0x1C */ uintptr_t imageOffset; }; // Size: 0x20 /** diff --git a/include/d/actor/d_a_alink.h b/include/d/actor/d_a_alink.h index b57d959b4c..91815f9d58 100644 --- a/include/d/actor/d_a_alink.h +++ b/include/d/actor/d_a_alink.h @@ -4332,7 +4332,7 @@ public: /* 0x032C0 */ s16 field_0x32c0[2]; /* 0x032C4 */ u16 field_0x32c4[2]; /* 0x032C8 */ u32 field_0x32c8; - /* 0x032CC */ u32 field_0x32cc; + /* 0x032CC */ uintptr_t field_0x32cc; /* 0x032D0 */ u32 field_0x32d0; /* 0x032D4 */ u32 field_0x32d4; /* 0x032D8 */ firePointEff_c field_0x32d8[4]; diff --git a/include/d/d_drawlist.h b/include/d/d_drawlist.h index 3daf9c5724..ed2ba1cb40 100644 --- a/include/d/d_drawlist.h +++ b/include/d/d_drawlist.h @@ -192,7 +192,7 @@ public: class dDlst_shadowRealPoly_c : public dDlst_shadowPoly_c { public: /* 800569A0 */ virtual dDlst_shadowTri_c* getTri() { return mShadowTri; } - /* 800569A8 */ virtual s32 getTriMax() { return ARRAY_SIZE(mShadowTri); } + /* 800569A8 */ virtual s32 getTriMax() { return ARRAY_SIZEU(mShadowTri); } /* 0x8 */ dDlst_shadowTri_c mShadowTri[256]; }; @@ -346,8 +346,8 @@ public: J3DDrawBuffer* getOpaListBG() { return mDrawBuffers[DB_OPA_LIST_BG]; } J3DDrawBuffer* getOpaListDark() { return mDrawBuffers[DB_OPA_LIST_DARK]; } J3DDrawBuffer* getXluListBG() { return mDrawBuffers[DB_XLU_LIST_BG]; } - void setXluDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, J3DSys_XLU_BUFFER_e); } - void setOpaDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, J3DSys_OPA_BUFFER_e); } + void setXluDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, J3DSysDrawBuf_Xlu); } + void setOpaDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, J3DSysDrawBuf_Opa); } void setXluListSky() { setXluDrawList(mDrawBuffers[DB_XLU_LIST_SKY]); } void setOpaListSky() { setOpaDrawList(mDrawBuffers[DB_OPA_LIST_SKY]); } void setXluListDark() { setXluDrawList(mDrawBuffers[DB_XLU_LIST_DARK]); } diff --git a/include/d/d_resorce.h b/include/d/d_resorce.h index 5ce6322755..9da681c3f0 100644 --- a/include/d/d_resorce.h +++ b/include/d/d_resorce.h @@ -81,50 +81,50 @@ public: static int syncAllRes(dRes_info_c* i_resInfo, int i_infoNum); int setObjectRes(const char* i_arcName, u8 i_mountDirection, JKRHeap* i_heap) { - return setRes(i_arcName, mObjectInfo, ARRAY_SIZE(mObjectInfo), "/res/Object/", i_mountDirection, + return setRes(i_arcName, mObjectInfo, ARRAY_SIZEU(mObjectInfo), "/res/Object/", i_mountDirection, i_heap); } void* getObjectRes(const char* i_arcName, const char* resName) { - return getRes(i_arcName, resName, mObjectInfo, ARRAY_SIZE(mObjectInfo)); + return getRes(i_arcName, resName, mObjectInfo, ARRAY_SIZEU(mObjectInfo)); } void* getObjectRes(const char* i_arcName, s32 i_index) { - return getRes(i_arcName, i_index, mObjectInfo, ARRAY_SIZE(mObjectInfo)); + return getRes(i_arcName, i_index, mObjectInfo, ARRAY_SIZEU(mObjectInfo)); } void* getObjectIDRes(const char* i_arcName, u16 i_resID) { - return getIDRes(i_arcName, i_resID, mObjectInfo, ARRAY_SIZE(mObjectInfo)); + return getIDRes(i_arcName, i_resID, mObjectInfo, ARRAY_SIZEU(mObjectInfo)); } int syncObjectRes(const char* i_arcName) { - return syncRes(i_arcName, mObjectInfo, ARRAY_SIZE(mObjectInfo)); + return syncRes(i_arcName, mObjectInfo, ARRAY_SIZEU(mObjectInfo)); } int syncStageRes(const char* i_arcName) { - return syncRes(i_arcName, mStageInfo, ARRAY_SIZE(mStageInfo)); + return syncRes(i_arcName, mStageInfo, ARRAY_SIZEU(mStageInfo)); } - int syncAllObjectRes() { return syncAllRes(mObjectInfo, ARRAY_SIZE(mObjectInfo)); } + int syncAllObjectRes() { return syncAllRes(mObjectInfo, ARRAY_SIZEU(mObjectInfo)); } int deleteObjectRes(const char* i_arcName) { - return deleteRes(i_arcName, mObjectInfo, ARRAY_SIZE(mObjectInfo)); + return deleteRes(i_arcName, mObjectInfo, ARRAY_SIZEU(mObjectInfo)); } int deleteStageRes(const char* i_arcName) { - return deleteRes(i_arcName, mStageInfo, ARRAY_SIZE(mStageInfo)); + return deleteRes(i_arcName, mStageInfo, ARRAY_SIZEU(mStageInfo)); } void* getStageRes(const char* i_arcName, const char* i_resName) { - return getRes(i_arcName, i_resName, mStageInfo, ARRAY_SIZE(mStageInfo)); + return getRes(i_arcName, i_resName, mStageInfo, ARRAY_SIZEU(mStageInfo)); } dRes_info_c* getObjectResInfo(const char* i_arcName) { - return getResInfo(i_arcName, mObjectInfo, ARRAY_SIZE(mObjectInfo)); + return getResInfo(i_arcName, mObjectInfo, ARRAY_SIZEU(mObjectInfo)); } dRes_info_c* getStageResInfo(const char* i_arcName) { - return getResInfo(i_arcName, mStageInfo, ARRAY_SIZE(mStageInfo)); + return getResInfo(i_arcName, mStageInfo, ARRAY_SIZEU(mStageInfo)); } /* 0x0000 */ dRes_info_c mObjectInfo[128]; diff --git a/include/global.h b/include/global.h index 81afcd5f47..7f725ba12c 100644 --- a/include/global.h +++ b/include/global.h @@ -23,7 +23,8 @@ #define ALIGN_DECL(ALIGNMENT) __attribute__((aligned(ALIGNMENT))) -#define ARRAY_SIZE(o) (sizeof((o)) / sizeof(*(o))) +#define ARRAY_SIZE(o) (s32)(sizeof((o)) / sizeof(*(o))) +#define ARRAY_SIZEU(o) (sizeof((o)) / sizeof(*(o))) // Align X to the previous N bytes (N must be power of two) #define ALIGN_PREV(X, N) ((X) & ~((N)-1)) |
