diff --git a/configure.py b/configure.py index 4c4b88ad7..40d3586ae 100644 --- a/configure.py +++ b/configure.py @@ -325,7 +325,8 @@ def ActorRel(rel_name, status): NonMatching("DynamicLink.cpp"), ], }, - Rel("f_pc_profile_lst", "f_pc/f_pc_profile_lst.cpp", Matching),ActorRel("d_a_agbsw0", NonMatching), + Rel("f_pc_profile_lst", "f_pc/f_pc_profile_lst.cpp", Matching), + ActorRel("d_a_agbsw0", NonMatching), ActorRel("d_a_andsw0", NonMatching), ActorRel("d_a_andsw2", NonMatching), ActorRel("d_a_att", NonMatching), diff --git a/include/JSystem/J3DGraphAnimator/J3DAnimation.h b/include/JSystem/J3DGraphAnimator/J3DAnimation.h new file mode 100644 index 000000000..00bd2b865 --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DAnimation.h @@ -0,0 +1,634 @@ +#ifndef J3DANIMATION_H +#define J3DANIMATION_H + +#include "JSystem/J3DGraphAnimator/J3DModelData.h" +#include "JSystem/JUtility/JUTNameTab.h" +#include "global.h" + +typedef struct _GXColor GXColor; +typedef struct _GXColorS10 GXColorS10; + +struct J3DAnmKeyTableBase { + /* 0x00 */ u16 mMaxFrame; + /* 0x02 */ u16 mOffset; + /* 0x04 */ u16 mType; +}; // Size = 0x6 + +struct J3DAnmColorKeyTable { + J3DAnmKeyTableBase mRInfo; + J3DAnmKeyTableBase mGInfo; + J3DAnmKeyTableBase mBInfo; + J3DAnmKeyTableBase mAInfo; +}; // Size = 0x18 + +struct J3DAnmVtxColorIndexData; + +struct J3DAnmColorFullTable { + /* 0x00 */ u16 mRMaxFrame; + /* 0x02 */ u16 mROffset; + /* 0x04 */ u16 mGMaxFrame; + /* 0x06 */ u16 mGOffset; + /* 0x08 */ u16 mBMaxFrame; + /* 0x0A */ u16 mBOffset; + /* 0x0C */ u16 mAMaxFrame; + /* 0x0E */ u16 mAOffset; +}; // Size = 0x10 + +struct J3DAnmVisibilityFullTable { + u16 _0; + u16 _2; +}; // Size = 0x4 + +struct J3DAnmTransformKeyTable { + J3DAnmKeyTableBase mScaleInfo; + J3DAnmKeyTableBase mRotationInfo; + J3DAnmKeyTableBase mTranslateInfo; +}; // Size = 0x12 + +struct J3DAnmTransformFullTable { + /* 0x00 */ u16 mScaleMaxFrame; + /* 0x02 */ u16 mScaleOffset; + /* 0x04 */ u16 mRotationMaxFrame; + /* 0x06 */ u16 mRotationOffset; + /* 0x08 */ u16 mTranslateMaxFrame; + /* 0x0A */ u16 mTranslateOffset; +}; // Size = 0xC + +struct J3DAnmTexPatternFullTable { + /* 0x00 */ u16 mMaxFrame; + /* 0x02 */ u16 mOffset; + /* 0x04 */ u8 _4; + /* 0x06 */ u16 _6; +}; // Size = 0x8 + +struct J3DAnmCRegKeyTable { + /* 0x00 */ J3DAnmKeyTableBase mRTable; + /* 0x06 */ J3DAnmKeyTableBase mGTable; + /* 0x0C */ J3DAnmKeyTableBase mBTable; + /* 0x12 */ J3DAnmKeyTableBase mATable; + /* 0x18 */ u8 _18; + u8 padding[3]; +}; // Size = 0x1C + +struct J3DAnmKRegKeyTable { + /* 0x00 */ J3DAnmKeyTableBase mRTable; + /* 0x06 */ J3DAnmKeyTableBase mGTable; + /* 0x0C */ J3DAnmKeyTableBase mBTable; + /* 0x12 */ J3DAnmKeyTableBase mATable; + /* 0x18 */ u8 _18; + u8 padding[3]; +}; // Size = 0x1C + +struct J3DAnmDataBlockHeader { // actual name unknown + /* 0x0 */ u32 mType; + /* 0x4 */ u32 mNextOffset; +}; // Size = 0x8 + +struct J3DAnmDataHeader { // actual name unknown + /* 0x00 */ u32 mMagic; + /* 0x04 */ u32 mType; + /* 0x08 */ u8 _8[4]; + /* 0x0C */ u32 mCount; + /* 0x10 */ u8 _10[0x20 - 0x10]; + /* 0x20 */ J3DAnmDataBlockHeader mFirst; +}; + +struct J3DAnmVtxColorFullData { + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9; // padding? + /* 0x0A */ s16 mFrameMax; + /* 0x0C */ u16 mAnmTableNum[2]; + /* 0x10 */ u8 field_0x10[0x18 - 0x10]; + /* 0x18 */ s32 mTableOffsets[2]; + /* 0x20 */ s32 mVtxColorIndexDataOffsets[2]; + /* 0x28 */ s32 mVtxColorIndexPointerOffsets[2]; + /* 0x30 */ s32 mRValuesOffset; + /* 0x34 */ s32 mGValuesOffset; + /* 0x38 */ s32 mBValuesOffset; + /* 0x3C */ s32 mAValuesOffset; +}; // Size = 0x40 + +STATIC_ASSERT(sizeof(J3DAnmVtxColorFullData) == 0x40); + +struct J3DAnmVisibilityFullData { + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9; // padding? + /* 0x0A */ s16 mFrameMax; + /* 0x0C */ u16 field_0xc; + /* 0x0E */ u16 field_0xe; + /* 0x10 */ s32 mTableOffset; + /* 0x14 */ s32 mValuesOffset; +}; // Size = 0x18 + +STATIC_ASSERT(sizeof(J3DAnmVisibilityFullData) == 0x18); + +struct J3DAnmTransformFullData { + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9; + /* 0x0A */ s16 mFrameMax; + /* 0x0C */ u16 field_0xc; + /* 0x0E */ u8 field_0xe[0x14 - 0xe]; + /* 0x14 */ s32 mTableOffset; + /* 0x18 */ s32 mScaleValOffset; + /* 0x1C */ s32 mRotValOffset; + /* 0x20 */ s32 mTransValOffset; +}; // Size = 0x24 + +STATIC_ASSERT(sizeof(J3DAnmTransformFullData) == 0x24); + +struct J3DAnmColorKeyData { + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9[3]; + /* 0x0C */ s16 mFrameMax; + /* 0x0E */ u16 mUpdateMaterialNum; + /* 0x10 */ u16 field_0x10; + /* 0x12 */ u16 field_0x12; + /* 0x14 */ u16 field_0x14; + /* 0x16 */ u16 field_0x16; + /* 0x18 */ s32 mTableOffset; /* Created by retype action */ + /* 0x1C */ s32 mUpdateMaterialIDOffset; + /* 0x20 */ s32 mNameTabOffset; /* Created by retype action */ + /* 0x24 */ s32 mRValOffset; + /* 0x28 */ s32 mGValOffset; + /* 0x2C */ s32 mBValOffset; + /* 0x30 */ s32 mAValOffset; +}; // Size = 0x34 + +STATIC_ASSERT(sizeof(J3DAnmColorKeyData) == 0x34); + +struct J3DAnmTextureSRTKeyData { + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9; + /* 0x0A */ s16 field_0xa; + /* 0x0C */ u16 field_0xc; + /* 0x0E */ u16 field_0xe; + /* 0x10 */ u16 field_0x10; + /* 0x12 */ u16 field_0x12; + /* 0x14 */ s32 mTableOffset; + /* 0x18 */ s32 mUpdateMatIDOffset; + /* 0x1C */ s32 mNameTab1Offset; + /* 0x20 */ s32 mUpdateTexMtxIDOffset; + /* 0x24 */ s32 unkOffset; + /* 0x28 */ s32 mScaleValOffset; + /* 0x2C */ s32 mRotValOffset; + /* 0x30 */ s32 mTransValOffset; + /* 0x34 */ u16 field_0x34; + /* 0x36 */ u16 field_0x36; + /* 0x38 */ u16 field_0x38; + /* 0x3A */ u16 field_0x3a; + /* 0x3C */ s32 mInfoTable2Offset; + /* 0x40 */ s32 field_0x40; + /* 0x44 */ u32 mNameTab2Offset; + /* 0x48 */ s32 field_0x48; + /* 0x4C */ s32 field_0x4c; + /* 0x50 */ s32 field_0x50; + /* 0x54 */ s32 field_0x54; + /* 0x58 */ s32 field_0x58; + /* 0x5C */ s32 field_0x5c; +}; // Size = 0x60 + +STATIC_ASSERT(sizeof(J3DAnmTextureSRTKeyData) == 0x60); + +struct J3DAnmVtxColorKeyData { + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9; + /* 0x0A */ s16 mFrameMax; + /* 0x0C */ u16 mAnmTableNum[2]; + /* 0x10 */ u8 field_0x10[0x18 - 0x10]; + /* 0x18 */ s32 mTableOffsets[2]; + /* 0x20 */ s32 mVtxColoIndexDataOffset[2]; + /* 0x28 */ s32 mVtxColoIndexPointerOffset[2]; + /* 0x30 */ s32 mRValOffset; + /* 0x34 */ s32 mGValOffset; + /* 0x38 */ s32 mBValOffset; + /* 0x3C */ s32 mAValOffset; +}; // Size = 0x40 + +STATIC_ASSERT(sizeof(J3DAnmVtxColorKeyData) == 0x40); + +struct J3DAnmTexPatternFullData { + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9; + /* 0x0A */ s16 mFrameMax; + /* 0x0C */ u16 field_0xc; + /* 0x0E */ u16 field_0xe; + /* 0x10 */ s32 mTableOffset; + /* 0x14 */ s32 mValuesOffset; + /* 0x18 */ s32 mUpdateMaterialIDOffset; + /* 0x1C */ s32 mNameTabOffset; +}; // Size = 0x20 + +STATIC_ASSERT(sizeof(J3DAnmTexPatternFullData) == 0x20); + +struct J3DAnmTevRegKeyData { + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9; // maybe padding + /* 0x0A */ s16 mFrameMax; + /* 0x0C */ u16 mCRegUpdateMaterialNum; + /* 0x0E */ u16 mKRegUpdateMaterialNum; + /* 0x10 */ u16 field_0x10; + /* 0x12 */ u16 field_0x12; + /* 0x14 */ u16 field_0x14; + /* 0x16 */ u16 field_0x16; + /* 0x18 */ u16 field_0x18; + /* 0x1A */ u16 field_0x1a; + /* 0x1C */ u16 field_0x1c; + /* 0x1E */ u16 field_0x1e; + /* 0x20 */ s32 mCRegTableOffset; + /* 0x24 */ s32 mKRegTableOffset; + /* 0x28 */ s32 mCRegUpdateMaterialIDOffset; + /* 0x2C */ s32 mKRegUpdateMaterialIDOffset; + /* 0x30 */ s32 mCRegNameTabOffset; + /* 0x34 */ s32 mKRegNameTabOffset; + /* 0x38 */ s32 mCRValuesOffset; + /* 0x3C */ s32 mCGValuesOffset; + /* 0x40 */ s32 mCBValuesOffset; + /* 0x44 */ s32 mCAValuesOffset; + /* 0x48 */ s32 mKRValuesOffset; + /* 0x4C */ s32 mKGValuesOffset; + /* 0x50 */ s32 mKBValuesOffset; + /* 0x54 */ s32 mKAValuesOffset; +}; // Size = 0x58 + +STATIC_ASSERT(sizeof(J3DAnmTevRegKeyData) == 0x58); + +struct J3DAnmColorFullData { /* PlaceHolder Structure */ + /* 0x00 */ J3DAnmDataBlockHeader mHeader; + /* 0x08 */ u8 field_0x8; + /* 0x09 */ u8 field_0x9[3]; + /* 0x0C */ s16 mFrameMax; + /* 0x0E */ u16 mUpdateMaterialNum; + /* 0x10 */ u8 field_0x10[0x18 - 0x10]; + /* 0x18 */ s32 mTableOffset; + /* 0x1C */ s32 mUpdateMaterialIDOffset; + /* 0x20 */ s32 mNameTabOffset; + /* 0x24 */ s32 mRValuesOffset; + /* 0x28 */ s32 mGValuesOffset; + /* 0x2C */ s32 mBValuesOffset; + /* 0x30 */ s32 mAValuesOffset; +}; // Size = 0x34 + +STATIC_ASSERT(sizeof(J3DAnmColorFullData) == 0x34); + +class J3DAnmBase { +public: + J3DAnmBase(s16 i_frameMax) { + mAttribute = 0; + field_0x5 = 0; + mFrameMax = i_frameMax; + mFrame = 0.0f; + } + + virtual ~J3DAnmBase(); + + u8 getAttribute() const { return mAttribute; } + s16 getFrameMax() const { return mFrameMax; } + f32 getFrame() const { return mFrame; } + void setFrame(f32 frame) { mFrame = frame; } + +private: + /* 0x4 */ u8 mAttribute; + /* 0x5 */ u8 field_0x5; + /* 0x6 */ s16 mFrameMax; + /* 0x8 */ f32 mFrame; +}; // Size: 0xC + +class J3DAnmTransform : public J3DAnmBase { +public: + /* 80328E40 */ J3DAnmTransform(s16, f32*, s16*, f32*); + + /* 8003B93C */ virtual ~J3DAnmTransform(); + /* 8003C77C */ virtual s32 getKind() const; + virtual void getTransform(u16, J3DTransformInfo*) const = 0; + +private: + /* 0x0C */ f32* field_0xc; + /* 0x10 */ s16* field_0x10; + /* 0x14 */ f32* field_0x14; + /* 0x18 */ s16 field_0x18; + /* 0x1A */ s16 field_0x1a; + /* 0x1C */ s16 field_0x1c; + /* 0x1E */ s16 field_0x1e; +}; // Size: 0x20 + +class J3DAnmTransformKey : public J3DAnmTransform { +public: + J3DAnmTransformKey() : J3DAnmTransform(0, NULL, NULL, NULL) { + field_0x20 = 0; + field_0x24 = 0; + } + + /* 80329A34 */ void calcTransform(f32, u16, J3DTransformInfo*) const; + + /* 8003B8D0 */ virtual ~J3DAnmTransformKey(); + /* 8003C800 */ virtual s32 getKind() const; + /* 8003C808 */ virtual void getTransform(u16, J3DTransformInfo*) const; + +private: + /* 0x20 */ int field_0x20; + /* 0x24 */ int field_0x24; +}; // Size: 0x28 + +class J3DAnmTransformFull : public J3DAnmTransform { +public: + /* 8032C2AC */ virtual ~J3DAnmTransformFull(); + /* 8032C318 */ virtual s32 getKind() const; + /* 80328E90 */ virtual void getTransform(u16, J3DTransformInfo*) const; + +private: + /* 0x20 */ int field_0x20; +}; // Size: 0x24 + +class J3DAnmTransformFullWithLerp : public J3DAnmTransformFull { +public: + /* 8032C228 */ virtual ~J3DAnmTransformFullWithLerp(); + /* 8032C2A4 */ virtual s32 getKind() const; + /* 803291F0 */ virtual void getTransform(u16, J3DTransformInfo*) const; +}; // Size: 0x24 + +struct J3DTextureSRTInfo; +class J3DModelData; +class J3DMaterialTable; + +class J3DAnmTextureSRTKey : public J3DAnmBase { +public: + /* 80329E5C */ J3DAnmTextureSRTKey(); + /* 80329F14 */ void calcTransform(f32, u16, J3DTextureSRTInfo*) const; + /* 8032B0C0 */ void searchUpdateMaterialID(J3DMaterialTable*); + /* 8032B1D4 */ void searchUpdateMaterialID(J3DModelData*); + + /* 8032C198 */ virtual ~J3DAnmTextureSRTKey(); + /* 8032C220 */ virtual s32 getKind() const; + + void getTransform(u16 param_0, J3DTextureSRTInfo* pSRTInfo) const { + calcTransform(getFrame(), param_0, pSRTInfo); + } + + u16 getUpdateMaterialID(u16 idx) const { return mUpdateMaterialID[idx]; } + u16 getUpdateMaterialNum() const { return field_0x14 / 3; } + +private: + /* 0x0C */ int field_0xc; + /* 0x10 */ int field_0x10; + /* 0x14 */ u16 field_0x14; + /* 0x16 */ u16 field_0x16; + /* 0x18 */ u16 field_0x18; + /* 0x1A */ u16 field_0x1a; + /* 0x1C */ int field_0x1c; + /* 0x20 */ int field_0x20; + /* 0x24 */ int field_0x24; + /* 0x28 */ u8 mUpdateTexMtxID[4]; + /* 0x2C */ u16* mUpdateMaterialID; + /* 0x30 */ JUTNameTab field_0x30; + /* 0x40 */ int field_0x40; + /* 0x44 */ u16 field_0x44; + /* 0x46 */ u16 field_0x46; + /* 0x48 */ u16 field_0x48; + /* 0x4A */ u16 field_0x4a; + /* 0x4C */ int field_0x4c; + /* 0x50 */ int field_0x50; + /* 0x54 */ int field_0x54; + /* 0x58 */ int field_0x58; + /* 0x5C */ u8 field_0x5c[4]; + /* 0x60 */ u16* field_0x60; + /* 0x64 */ JUTNameTab field_0x64; + /* 0x74 */ u8 field_0x74[4]; + /* 0x78 */ u32 mTexMtxCalcType; +}; // Size: 0x7C + +class J3DAnmTexPattern : public J3DAnmBase { +public: + /* 8032AED8 */ J3DAnmTexPattern(); + /* 8032AF50 */ void getTexNo(u16, u16*) const; + /* 8032B004 */ void searchUpdateMaterialID(J3DMaterialTable*); + /* 8032B09C */ void searchUpdateMaterialID(J3DModelData*); + + /* 8032BD20 */ virtual ~J3DAnmTexPattern(); + /* 8032BD94 */ virtual s32 getKind() const; + +private: + /* 0x0C */ void* field_0xc; + /* 0x10 */ void* mAnmTable; + /* 0x14 */ u16 field_0x14; + /* 0x16 */ u16 mUpdateMaterialNum; + /* 0x18 */ u16* field_0x18; + /* 0x1C */ JUTNameTab field_0x1c; +}; // Size: 0x2C + +class J3DAnmTevRegKey : public J3DAnmBase { +public: + /* 8032AE18 */ J3DAnmTevRegKey(); + /* 8032B1F8 */ void getTevColorReg(u16, _GXColorS10*) const; + /* 8032B4BC */ void getTevKonstReg(u16, _GXColor*) const; + /* 8032B780 */ void searchUpdateMaterialID(J3DMaterialTable*); + /* 8032B87C */ void searchUpdateMaterialID(J3DModelData*); + + /* 8032BD9C */ virtual ~J3DAnmTevRegKey(); + /* 8032BE24 */ virtual s32 getKind() const; + + u16 getCRegUpdateMaterialNum() const { return mCRegUpdateMaterialNum; } + u16 getKRegUpdateMaterialNum() const { return mKRegUpdateMaterialNum; } + + u16 getCRegUpdateMaterialID(u16 idx) const { return mCRegUpdateMaterialID[idx]; } + u16 getKRegUpdateMaterialID(u16 idx) const { return mKRegUpdateMaterialID[idx]; } + +private: + /* 0x0C */ u16 mCRegUpdateMaterialNum; + /* 0x0E */ u16 mKRegUpdateMaterialNum; + /* 0x10 */ u16 field_0x10; + /* 0x12 */ u16 field_0x12; + /* 0x14 */ u16 field_0x14; + /* 0x16 */ u16 field_0x16; + /* 0x18 */ u16 field_0x18; + /* 0x1A */ u16 field_0x1a; + /* 0x1C */ u16 field_0x1c; + /* 0x1E */ u16 field_0x1e; + /* 0x20 */ u16* mCRegUpdateMaterialID; + /* 0x24 */ JUTNameTab field_0x24; + /* 0x34 */ u16* mKRegUpdateMaterialID; + /* 0x38 */ JUTNameTab field_0x38; + /* 0x48 */ void* field_0x48; + /* 0x4C */ void* field_0x4c; + /* 0x50 */ int field_0x50; + /* 0x54 */ int field_0x54; + /* 0x58 */ int field_0x58; + /* 0x5C */ int field_0x5c; + /* 0x60 */ int field_0x60; + /* 0x64 */ int field_0x64; + /* 0x68 */ int field_0x68; + /* 0x6C */ int field_0x6c; +}; // Size: 0x70 + +class J3DAnmColor : public J3DAnmBase { +public: + /* 8032A828 */ J3DAnmColor(); + /* 8032A8A4 */ void searchUpdateMaterialID(J3DMaterialTable*); + + /* 8032BCAC */ virtual ~J3DAnmColor(); + /* 8032BF44 */ virtual s32 getKind() const; + /* 8032BF4C */ virtual void getColor(u16, _GXColor*) const; + + u16 getUpdateMaterialNum() const { return mUpdateMaterialNum; } + bool isValidUpdateMaterialID(u16 id) const { return mUpdateMaterialID[id] != 0xFFFF; } + u16 getUpdateMaterialID(u16 idx) const { return mUpdateMaterialID[idx]; } + +private: + /* 0x0C */ u16 field_0xc; + /* 0x0E */ u16 field_0xe; + /* 0x10 */ u16 field_0x10; + /* 0x12 */ u16 field_0x12; + /* 0x14 */ u16 mUpdateMaterialNum; + /* 0x18 */ u16* mUpdateMaterialID; + /* 0x1C */ JUTNameTab field_0x1c; +}; // Size: 0x2C + +class J3DAnmColorKey : public J3DAnmColor { +public: + /* 8032AB00 */ J3DAnmColorKey(); + + /* 8032BE2C */ virtual ~J3DAnmColorKey(); + /* 8032BEB0 */ virtual s32 getKind() const; + /* 8032AB54 */ virtual void getColor(u16, _GXColor*) const; + +private: + /* 0x2C */ int field_0x2c; + /* 0x30 */ int field_0x30; + /* 0x34 */ int field_0x34; + /* 0x38 */ int field_0x38; + /* 0x3C */ int field_0x3c; +}; + +class J3DAnmColorFull : public J3DAnmColor { +public: + /* 8032AB00 */ J3DAnmColorFull(); + + /* 8032BE2C */ virtual ~J3DAnmColorFull(); + /* 8032BEB0 */ virtual s32 getKind() const; + /* 8032AB54 */ virtual void getColor(u16, _GXColor*) const; + +private: + /* 0x2C */ int field_0x2c; + /* 0x30 */ int field_0x30; + /* 0x34 */ int field_0x34; + /* 0x38 */ int field_0x38; + /* 0x3C */ int field_0x3c; +}; + +class J3DAnmVtxColor : public J3DAnmBase { +public: + J3DAnmVtxColor(); + + virtual ~J3DAnmVtxColor(); + virtual s32 getKind() const; + virtual void getColor(u8, u16, _GXColor*) const; + +private: + /* 0x0C */ s16 mAnmTableNum[2]; + /* 0x10 */ int mAnmVtxColorIndexData[2]; +}; // Size: 0x18 + +class J3DAnmVtxColorKey : public J3DAnmVtxColor { +public: + /* 8032A4E0 */ J3DAnmVtxColorKey(); + + /* 8032BF50 */ virtual ~J3DAnmVtxColorKey(); + /* 8032BFBC */ virtual s32 getKind() const; + /* 8032A53C */ virtual void getColor(u8, u16, _GXColor*) const; + +private: + /* 0x18 */ int field_0x18[2]; +}; + +class J3DAnmVtxColorFull : public J3DAnmVtxColor { + /* 8032A30C */ J3DAnmVtxColorFull(); + + /* 8032BFC4 */ virtual ~J3DAnmVtxColorFull(); + /* 8032C030 */ virtual s32 getKind() const; + /* 8032A368 */ virtual void getColor(u8, u16, _GXColor*) const; + +private: + /* 0x18 */ int field_0x18[2]; +}; + +class J3DAnmCluster : public J3DAnmBase { +public: + /* 8032BCAC */ virtual ~J3DAnmCluster(); + /* 8032BF44 */ virtual s32 getKind() const; + /* 8032BF4C */ virtual f32 getWeight(u16) const; + +private: + /* 0x0C */ f32* field_0xc; +}; // Size: 0x10 + +class J3DAnmClusterFull : public J3DAnmCluster { +public: + /* 8032BCAC */ virtual ~J3DAnmClusterFull(); + /* 8032BF44 */ virtual s32 getKind() const; + /* 8032BF4C */ virtual f32 getWeight(u16) const; + +private: + /* 0x10 */ int field_0x10; +}; + +class J3DAnmClusterKey : public J3DAnmCluster { +public: + /* 8032C044 */ virtual ~J3DAnmClusterKey(); + /* 8032C0B0 */ virtual s32 getKind() const; + /* 8032A218 */ virtual f32 getWeight(u16) const; + +private: + /* 0x10 */ int field_0x10; +}; + +class J3DFrameCtrl { +public: + enum Attribute_e { + LOOP_ONCE_e, + LOOP_ONCE_RESET_e, + LOOP_REPEAT_e, + LOOP_MIRROR_ONCE_e, + LOOP_MIRROR_REPEAT_e, + }; + + J3DFrameCtrl() { this->init(0); } + void init(s16); + BOOL checkPass(f32); + void update(); + virtual ~J3DFrameCtrl() {} + + f32 getRate() const { return mRate; } + f32 getFrame() const { return mFrame; } + s16 getEnd() const { return mEnd; } + s16 getStart() const { return mStart; } + u8 getAttribute() const { return mAttribute; } + u8 getState() const { return mState; } + void setAttribute(u8 attr) { mAttribute = attr; } + void setEnd(s16 end) { mEnd = end; } + void setRate(f32 rate) { mRate = rate; } + void setStart(s16 start) { + mStart = start; + mFrame = start; + } + void setFrame(f32 frame) { mFrame = frame; } + void setLoop(s16 loop) { mLoop = loop; } + bool checkState(u8 state) const { return mState & state; } + +private: + /* 0x04 */ u8 mAttribute; + /* 0x05 */ u8 mState; + /* 0x06 */ s16 mStart; + /* 0x08 */ s16 mEnd; + /* 0x0A */ s16 mLoop; + /* 0x0C */ f32 mRate; + /* 0x10 */ f32 mFrame; +}; // Size: 0x14 + +#endif /* J3DANIMATION_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DCluster.h b/include/JSystem/J3DGraphAnimator/J3DCluster.h new file mode 100644 index 000000000..511c17eed --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DCluster.h @@ -0,0 +1,24 @@ +#ifndef J3DCLUSTER_H +#define J3DCLUSTER_H + +#include "dolphin/types.h" + +class J3DDeformer; + +struct J3DCluster { + /* 0x00 */ f32 field_0x0; + /* 0x04 */ f32 field_0x4; + /* 0x08 */ int field_0x8; + /* 0x0C */ int field_0xc; + /* 0x10 */ u16 field_0x10; + /* 0x12 */ u16 field_0x12; + /* 0x14 */ u16 field_0x14; + /* 0x16 */ u16 field_0x16; + /* 0x18 */ u16 field_0x18[2]; + /* 0x1C */ int field_0x1c; + /* 0x20 */ J3DDeformer* mDeformer; +}; + +struct J3DClusterKey {}; + +#endif /* J3DCLUSTER_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DJoint.h b/include/JSystem/J3DGraphAnimator/J3DJoint.h new file mode 100644 index 000000000..6a67e0a94 --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DJoint.h @@ -0,0 +1,115 @@ +#ifndef J3DJOINT_H +#define J3DJOINT_H + +#include "JSystem/J3DGraphBase/J3DTransform.h" + +class J3DAnmTransform; +class J3DJoint; +class J3DMaterial; +class J3DMtxBuffer; + +class J3DMtxCalc { +public: + /* 80325D1C */ static void setMtxBuffer(J3DMtxBuffer*); + + /* 8000D948 */ virtual ~J3DMtxCalc(); + /* 80014E90 */ virtual void setAnmTransform(J3DAnmTransform*); + /* 80014E9C */ virtual bool getAnmTransform(); + /* 80014E8C */ virtual void setAnmTransform(u8, J3DAnmTransform*); + /* 80014E94 */ virtual bool getAnmTransform(u8); + /* 80014EA4 */ virtual void setWeight(u8, f32); + /* 80014EA8 */ virtual void getWeight(u8) const; + virtual void init(Vec const& param_0, Mtx*) = 0; + virtual void calc() = 0; + + static J3DMtxBuffer* getMtxBuffer() { return mMtxBuffer; } + static J3DJoint* getJoint() { return mJoint; } + static void setJoint(J3DJoint* joint) { mJoint = joint; } + + static J3DMtxBuffer* mMtxBuffer; + static J3DJoint* mJoint; +}; // Size: 0x4 + +class J3DMtxCalcNoAnmBase : public J3DMtxCalc { +public: + /* 8000FA8C */ virtual ~J3DMtxCalcNoAnmBase(); +}; + +template +class J3DMtxCalcNoAnm : public J3DMtxCalcNoAnmBase, public A, public B { +public: + J3DMtxCalcNoAnm() {} + virtual ~J3DMtxCalcNoAnm() {} + virtual void init(Vec const& param_0, f32 const (¶m_1)[3][4]); + virtual void calc(); +}; + +class J3DJoint; +typedef int (*J3DJointCallBack)(J3DJoint*, int); + +class J3DJoint { +public: + /* 8032F13C */ void appendChild(J3DJoint*); + /* 8032F170 */ J3DJoint(); + /* 8032F254 */ void entryIn(); + /* 8032F3F8 */ void recursiveCalc(); + + J3DMaterial* getMesh() { return mMesh; } + u16 getJntNo() const { return mJntNo; } + u8 getScaleCompensate() const { return mScaleCompensate; } + J3DJoint* getYounger() { return mYounger; } + void setYounger(J3DJoint* pYounger) { mYounger = pYounger; } + void setCurrentMtxCalc(J3DMtxCalc* pMtxCalc) { mCurrentMtxCalc = pMtxCalc; } + J3DTransformInfo& getTransformInfo() { return mTransformInfo; } + Vec* getMax() { return &mMax; } + Vec* getMin() { return &mMin; } + void setCallBack(J3DJointCallBack callback) { mCallBack = callback; } + J3DJointCallBack getCallBack() { return mCallBack; } + void setMtxCalc(J3DMtxCalc* i_mtxCalc) { mMtxCalc = i_mtxCalc; } + J3DMtxCalc* getMtxCalc() { return mMtxCalc; } + J3DMtxCalc* getCurrentMtxCalc() { return mCurrentMtxCalc; }; + J3DJoint* getChild() { return mChild; } + + static J3DMtxCalc* mCurrentMtxCalc; + +private: + friend struct J3DJointFactory; + friend class J3DJointTree; + + /* 0x00 */ void* mCallBackUserData; + /* 0x04 */ J3DJointCallBack mCallBack; + /* 0x08 */ void* field_0x8; + /* 0x0C */ J3DJoint* mChild; + /* 0x10 */ J3DJoint* mYounger; + /* 0x14 */ u16 mJntNo; + /* 0x16 */ u8 mKind; + /* 0x17 */ u8 mScaleCompensate; + /* 0x18 */ J3DTransformInfo mTransformInfo; + /* 0x38 */ f32 mBoundingSphereRadius; + /* 0x3C */ Vec mMin; + /* 0x48 */ Vec mMax; + /* 0x54 */ J3DMtxCalc* mMtxCalc; + /* 0x58 */ J3DMaterial* mMesh; +}; // Size: 0x5C + +struct J3DMtxCalcJ3DSysInitMaya { + /* 8032ECAC */ static void init(Vec const&, f32 const (&)[3][4]); +}; + +struct J3DMtxCalcJ3DSysInitBasic { + /* 8032EC28 */ static void init(Vec const&, f32 const (&)[3][4]); +}; + +struct J3DMtxCalcCalcTransformSoftimage { + /* 8032EE50 */ static void calcTransform(J3DTransformInfo const&); +}; + +struct J3DMtxCalcCalcTransformMaya { + /* 8032EFBC */ static void calcTransform(J3DTransformInfo const&); +}; + +struct J3DMtxCalcCalcTransformBasic { + /* 8032ED30 */ static void calcTransform(J3DTransformInfo const&); +}; + +#endif /* J3DJOINT_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DJointTree.h b/include/JSystem/J3DGraphAnimator/J3DJointTree.h new file mode 100644 index 000000000..2dd47be9f --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DJointTree.h @@ -0,0 +1,75 @@ +#ifndef J3DJOINTTREE_H +#define J3DJOINTTREE_H + +#include "JSystem/J3DGraphAnimator/J3DJoint.h" +#include "dolphin/types.h" + +class JUTNameTab; + +struct J3DModelHierarchy { + /* 0x0 */ u16 mType; + /* 0x2 */ u16 mValue; +}; + +class J3DMaterialTable; + +struct J3DDrawMtxData { + /* 803115E0 */ J3DDrawMtxData(); + /* 803115F4 */ ~J3DDrawMtxData(); + + /* 0x0 */ u16 mEntryNum; + /* 0x2 */ u16 mDrawFullWgtMtxNum; + /* 0x4 */ u8* mDrawMtxFlag; + /* 0x8 */ u16* mDrawMtxIndex; +}; // Size: 0xC + +class J3DShapeTable; + +class J3DJointTree { +public: + /* 80325A18 */ J3DJointTree(); + /* 80325A9C */ void makeHierarchy(J3DJoint*, J3DModelHierarchy const**, J3DMaterialTable*, + J3DShapeTable*); + /* 80325C00 */ void findImportantMtxIndex(); + + /* 80325CAC */ virtual void calc(J3DMtxBuffer*, Vec const&, f32 const (&)[3][4]); + /* 80325D24 */ virtual ~J3DJointTree(); + + u16 getWEvlpMtxNum() const { return mWEvlpMtxNum; } + u8 getWEvlpMixMtxNum(u16 idx) const { return mWEvlpMixMtxNum[idx]; } + u16 * getWEvlpMixIndex() const { return mWEvlpMixIndex; } + f32 * getWEvlpMixWeight() const { return mWEvlpMixWeight; } + u16 * getWEvlpImportantMtxIndex() const { return mWEvlpImportantMtxIdx; } + u16 getDrawFullWgtMtxNum() const { return mDrawMtxData.mDrawFullWgtMtxNum; } + u16 getJointNum() const { return mJointNum; } + u16 getDrawMtxNum() const { return mDrawMtxData.mEntryNum; } + u8 getDrawMtxFlag(u16 idx) const { return mDrawMtxData.mDrawMtxFlag[idx]; } + u16 getDrawMtxIndex(u16 idx) const { return mDrawMtxData.mDrawMtxIndex[idx]; } + JUTNameTab* getJointName() const { return mJointName; } + J3DJoint* getRootNode() { return mRootNode; } + J3DJoint* getJointNodePointer(u16 idx) const { return mJointNodePointer[idx]; } + J3DMtxCalc* getBasicMtxCalc() const { return mBasicMtxCalc; } + Mtx& getInvJointMtx(s32 idx) const { return mInvJointMtx[idx]; } + u32 getModelDataType() const { return mModelDataType; } + bool checkFlag(u32 flag) { return mFlags & flag; } + +private: + /* 0x04 */ J3DModelHierarchy* mHierarchy; + /* 0x08 */ u32 mFlags; + /* 0x0C */ u32 mModelDataType; + /* 0x10 */ J3DJoint* mRootNode; + /* 0x14 */ J3DMtxCalc* mBasicMtxCalc; + /* 0x18 */ J3DJoint** mJointNodePointer; + /* 0x1C */ u16 mJointNum; + /* 0x1E */ u16 mWEvlpMtxNum; + /* 0x20 */ u8* mWEvlpMixMtxNum; + /* 0x24 */ u16* mWEvlpMixIndex; + /* 0x28 */ f32* mWEvlpMixWeight; + /* 0x2C */ Mtx* mInvJointMtx; + /* 0x30 */ u16* mWEvlpImportantMtxIdx; + /* 0x34 */ J3DDrawMtxData mDrawMtxData; + /* 0x40 */ u32 field_0x40; + /* 0x44 */ JUTNameTab* mJointName; +}; // Size: 0x48 + +#endif /* J3DJOINTTREE_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h b/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h new file mode 100644 index 000000000..b2d5316af --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h @@ -0,0 +1,141 @@ +#ifndef J3DMATERIALANM_H +#define J3DMATERIALANM_H + +#include "JSystem/J3DGraphAnimator/J3DAnimation.h" + +typedef struct _GXColor GXColor; +typedef struct _GXColorS10 GXColorS10; + +class J3DMatColorAnm { +public: + /* 8003B2B8 */ ~J3DMatColorAnm() {}; + /* 8003B2F4 */ J3DMatColorAnm() {}; + + void operator=(J3DMatColorAnm const& other) { + mAnmColor = other.mAnmColor; + field_0x0 = other.field_0x0; + mAnmFlag = other.mAnmFlag; + } + + void setAnmFlag(bool flag) { mAnmFlag = flag; } + bool getAnmFlag() const { return mAnmFlag; } + void calc(_GXColor* pColor) const { mAnmColor->getColor(field_0x0, pColor); } + +private: + /* 0x0 */ u16 field_0x0; + /* 0x2 */ u16 mAnmFlag; + /* 0x4 */ J3DAnmColor* mAnmColor; +}; // Size: 0x8 + +class J3DTexNoAnm { +public: + /* 8003B1F8 */ ~J3DTexNoAnm() {}; + /* 8003B240 */ J3DTexNoAnm() {}; + /* 8003C82C */ virtual void calc(u16* param_0) const { mAnmTexPattern->getTexNo(field_0x4, param_0); } + + void operator=(J3DTexNoAnm const& other) { + mAnmTexPattern = other.mAnmTexPattern; + field_0x4 = other.field_0x4; + mAnmFlag = other.mAnmFlag; + } + + void setAnmFlag(bool flag) { mAnmFlag = flag; } + bool getAnmFlag() const { return mAnmFlag; } + J3DAnmTexPattern* getAnmTexPattern() { return mAnmTexPattern; } + +private: + /* 0x4 */ u16 field_0x4; + /* 0x6 */ u16 mAnmFlag; + /* 0x8 */ J3DAnmTexPattern* mAnmTexPattern; +}; // Size: 0xC + +class J3DTexMtxAnm { +public: + /* 8003B264 */ ~J3DTexMtxAnm() {}; + /* 8003B2A0 */ J3DTexMtxAnm() {}; + + 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 { + mAnmTransform->getTransform(field_0x0, pSRTInfo); + } + bool getAnmFlag() const { return mAnmFlag; } + +private: + /* 0x0 */ u16 field_0x0; + /* 0x2 */ u16 mAnmFlag; + /* 0x4 */ J3DAnmTextureSRTKey* mAnmTransform; +}; // Size: 0x8 + +class J3DTevKColorAnm { +public: + /* 8003B150 */ ~J3DTevKColorAnm() {}; + /* 8003B18C */ J3DTevKColorAnm() {}; + + void operator=(J3DTevKColorAnm const& other) { + mAnmTevReg = other.mAnmTevReg; + field_0x0 = other.field_0x0; + mAnmFlag = other.mAnmFlag; + } + + 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 + +class J3DTevColorAnm { +public: + /* 8003B1A4 */ ~J3DTevColorAnm() {}; + /* 8003B1E0 */ J3DTevColorAnm() {}; + + void operator=(J3DTevColorAnm const& other) { + mAnmTevReg = other.mAnmTevReg; + field_0x0 = other.field_0x0; + mAnmFlag = other.mAnmFlag; + } + + 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; + /* 0x4 */ J3DAnmTevRegKey* mAnmTevReg; +}; // Size: 0x8 + +class J3DMaterialAnm { +public: + J3DMaterialAnm() { initialize(); } + + /* 8032C320 */ void initialize(); + /* 8032C5A4 */ void setMatColorAnm(int, J3DMatColorAnm*); + /* 8032C5E4 */ void setTexMtxAnm(int, J3DTexMtxAnm*); + /* 8032C624 */ void setTexNoAnm(int, J3DTexNoAnm*); + /* 8032C664 */ void setTevColorAnm(int, J3DTevColorAnm*); + /* 8032C6A4 */ void setTevKColorAnm(int, J3DTevKColorAnm*); + + /* 800A4820 */ virtual ~J3DMaterialAnm() {}; + /* 8032C3C4 */ virtual void calc(J3DMaterial*) const; + + const J3DTexMtxAnm& getTexMtxAnm(int i) const { return mTexMtxAnm[i]; } + +private: + /* 0x04 */ J3DMatColorAnm mMatColorAnm[2]; + /* 0x14 */ J3DTexMtxAnm mTexMtxAnm[8]; + /* 0x54 */ J3DTexNoAnm mTexNoAnm[8]; + /* 0xB4 */ J3DTevColorAnm mTevColorAnm[4]; + /* 0xD4 */ J3DTevKColorAnm mTevKColorAnm[4]; +}; // Size: 0xF4 + +#endif /* J3DMATERIALANM_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h b/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h new file mode 100644 index 000000000..1891eedb9 --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h @@ -0,0 +1,51 @@ +#ifndef J3DMATERIALATTACH_H +#define J3DMATERIALATTACH_H + +#include "dolphin/types.h" + +class J3DMaterial; +class J3DTexture; +class J3DAnmColor; +class J3DAnmTexPattern; +class J3DAnmTextureSRTKey; +class J3DAnmTevRegKey; +class JUTNameTab; + +class J3DMaterialTable { +public: + /* 8032F5A8 */ void clear(); + /* 8032F5D0 */ J3DMaterialTable(); + /* 8032F64C */ int removeMatColorAnimator(J3DAnmColor*); + /* 8032F6F8 */ int removeTexNoAnimator(J3DAnmTexPattern*); + /* 8032F7B4 */ int removeTexMtxAnimator(J3DAnmTextureSRTKey*); + /* 8032F880 */ int removeTevRegAnimator(J3DAnmTevRegKey*); + /* 8032F9C0 */ void createTexMtxForAnimator(J3DAnmTextureSRTKey*); + /* 8032FAF4 */ void entryMatColorAnimator(J3DAnmColor*); + /* 8032FBC8 */ void entryTexNoAnimator(J3DAnmTexPattern*); + /* 8032FCC4 */ void entryTexMtxAnimator(J3DAnmTextureSRTKey*); + /* 8032FE70 */ void entryTevRegAnimator(J3DAnmTevRegKey*); + + /* 8032F604 */ virtual ~J3DMaterialTable(); + + J3DMaterial* getMaterialNodePointer(u16 idx) const { return mMaterialNodePointer[idx]; } + + J3DTexture* getTexture() const { return mTexture; } + JUTNameTab* getTextureName() const { return mTextureName; } + + JUTNameTab* getMaterialName() const { return mMaterialName; } + + u16 getMaterialNum() const { return mMaterialNum; } + bool isLocked() const { return field_0x1c == 1; } + +private: + /* 0x04 */ u16 mMaterialNum; + /* 0x06 */ u16 mUniqueMatNum; + /* 0x08 */ J3DMaterial** mMaterialNodePointer; + /* 0x0C */ JUTNameTab* mMaterialName; + /* 0x10 */ u32 field_0x10; + /* 0x14 */ J3DTexture* mTexture; + /* 0x18 */ JUTNameTab* mTextureName; + /* 0x1C */ u16 field_0x1c; +}; // Size: 0x20 + +#endif /* J3DMATERIALATTACH_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DModel.h b/include/JSystem/J3DGraphAnimator/J3DModel.h new file mode 100644 index 000000000..69ad60894 --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -0,0 +1,116 @@ +#ifndef J3DMODEL_H +#define J3DMODEL_H + +#include "JSystem/J3DGraphAnimator/J3DSkinDeform.h" +#include "JSystem/J3DGraphBase/J3DPacket.h" +#include "JSystem/J3DGraphBase/J3DVertex.h" +#include "dolphin/mtx/mtxvec.h" +#include "dolphin/types.h" + +enum J3DMdlFlag { + /* 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, +}; + +struct J3DUnkCalc1 { + virtual void calc(J3DModel* model); +}; + +struct J3DUnkCalc2 { + virtual void unk(); + virtual void calc(J3DModelData* mpModelData); +}; + +typedef void (*J3DCalcCallBack)(J3DModel*, u32 timing); + +class J3DModel { +public: + J3DModel() { + initialize(); + } + J3DModel(J3DModelData* param_0, u32 param_1, u32 param_2) { + initialize(); + entryModelData(param_0, param_1, param_2); + } + + /* 800CFFF4 */ void setBaseTRMtx(f32 (*)[4]); + /* 80327100 */ void initialize(); + /* 80327184 */ s32 entryModelData(J3DModelData*, u32, u32); + /* 80327300 */ s32 createShapePacket(J3DModelData*); + /* 803273CC */ s32 createMatPacket(J3DModelData*, u32); + /* 803275FC */ s32 newDifferedDisplayList(u32); + /* 8032767C */ void lock(); + /* 803276B4 */ void unlock(); + /* 803279A0 */ void diff(); + /* 80327A2C */ s32 setDeformData(J3DDeformData*, u32); + /* 80327AA0 */ s32 setSkinDeform(J3DSkinDeform*, u32); + /* 80327BD4 */ void calcAnmMtx(); + /* 80327C58 */ void calcWeightEnvelopeMtx(); + /* 80328190 */ void calcNrmMtx(); + /* 803281B4 */ void calcBumpMtx(); + /* 803282B8 */ void calcBBoardMtx(); + /* 803282EC */ void prepareShapePackets(); + MtxP getAnmMtx(int); + + /* 80327CA4 */ virtual void update(); + /* 80327E4C */ virtual void entry(); + /* 80327CF0 */ virtual void calc(); + /* 803276EC */ virtual void calcMaterial(); + /* 80327858 */ virtual void calcDiffTexMtx(); + /* 80327F40 */ virtual void viewCalc(); + /* 80328350 */ virtual ~J3DModel(); + + J3DModelData* getModelData() { return mModelData; } + + void onFlag(u32 flag) { mFlags |= flag; } + void offFlag(u32 flag) { mFlags &= ~flag; } + bool checkFlag(u32 flag) const { return (mFlags & flag) ? true : false; } + + bool isCpuSkinningOn() const { return (mFlags & J3DMdlFlag_SkinPosCpu) && (mFlags & J3DMdlFlag_SkinNrmCpu); } + + Mtx& getBaseTRMtx() { return mBaseTransformMtx; } + void i_setBaseTRMtx(Mtx m) { MTXCopy(m, mBaseTransformMtx); } + u32 getMtxCalcMode() const { return mFlags & 0x03; } + J3DVertexBuffer* getVertexBuffer() const { return (J3DVertexBuffer*)&mVertexBuffer; } + J3DMatPacket* getMatPacket(u16 idx) const { return &mMatPacket[idx]; } + J3DShapePacket* getShapePacket(u16 idx) const { return &mShapePacket[idx]; } + J3DMtxBuffer* getMtxBuffer() const { return mMtxBuffer; } + Mtx33* getBumpMtxPtr(int idx) const { return mMtxBuffer->getBumpMtxPtr(idx); } + Mtx33* getNrmMtxPtr() const { return mMtxBuffer->getNrmMtxPtr(); } + Mtx* getDrawMtxPtr() const { 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 i, Mtx m) { mMtxBuffer->setAnmMtx(i, m); } + + // is there a better way to handle inlines with same name as non-inlines? + MtxP i_getAnmMtx(int p1) { return mMtxBuffer->getAnmMtx(p1); } + void i_setAnmMtx(int p1, Mtx mtx) { mMtxBuffer->setAnmMtx(p1, mtx); } + + /* 0x04 */ J3DModelData* mModelData; + /* 0x08 */ u32 mFlags; + /* 0x0C */ u32 mDiffFlag; + /* 0x10 */ J3DCalcCallBack mCalcCallBack; + /* 0x14 */ u32 mUserArea; + /* 0x18 */ Vec mBaseScale; + /* 0x24 */ Mtx mBaseTransformMtx; + /* 0x54 */ Mtx mInternalView; + /* 0x84 */ J3DMtxBuffer* mMtxBuffer; + /* 0x88 */ J3DVertexBuffer mVertexBuffer; + /* 0xC0 */ J3DMatPacket* mMatPacket; + /* 0xC4 */ J3DShapePacket* mShapePacket; + /* 0xC8 */ J3DDeformData* mDeformData; + /* 0xCC */ J3DSkinDeform* mSkinDeform; + /* 0xD0 */ J3DVtxColorCalc* mVtxColorCalc; + /* 0xD4 */ J3DUnkCalc1* mUnkCalc1; + /* 0xD8 */ J3DUnkCalc2* mUnkCalc2; +}; + +#endif /* J3DMODEL_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DModelData.h b/include/JSystem/J3DGraphAnimator/J3DModelData.h new file mode 100644 index 000000000..3b113258f --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DModelData.h @@ -0,0 +1,93 @@ +#ifndef J3DMODELDATA_H +#define J3DMODELDATA_H + +#include "JSystem/J3DGraphAnimator/J3DJointTree.h" +#include "JSystem/J3DGraphAnimator/J3DMaterialAttach.h" +#include "JSystem/J3DGraphAnimator/J3DShapeTable.h" +#include "JSystem/J3DGraphBase/J3DSys.h" +#include "JSystem/J3DGraphBase/J3DVertex.h" + +typedef struct _GXColor GXColor; +class JUTNameTab; + +class J3DModelData { +public: + /* 80325D88 */ void clear(); + /* 80325DA0 */ J3DModelData(); + /* 80325E14 */ s32 newSharedDisplayList(u32); + /* 80325EC8 */ void indexToPtr(); + /* 80325F94 */ void makeSharedDL(); + /* 8032600C */ void simpleCalcMaterial(u16, f32 (*)[4]); + /* 803260CC */ void syncJ3DSysPointers() const; + /* 803260F8 */ void syncJ3DSysFlags() const; + + /* 8032617C */ virtual ~J3DModelData(); + + J3DMaterialTable& getMaterialTable() { return mMaterialTable; } + JUTNameTab* getMaterialName() const { return mMaterialTable.getMaterialName(); } + J3DVertexData& getVertexData() { return mVertexData; } + u16 getShapeNum() const { return mShapeTable.getShapeNum(); } + u16 getMaterialNum() const { return mMaterialTable.getMaterialNum(); } + u16 getJointNum() const { return mJointTree.getJointNum(); } + u16 getDrawMtxNum() const { return mJointTree.getDrawMtxNum(); } + J3DMaterial* getMaterialNodePointer(u16 idx) const { + return mMaterialTable.getMaterialNodePointer(idx); + } + u32 getVtxNum() const { return mVertexData.getVtxNum(); } + u32 getNrmNum() const { return mVertexData.getNrmNum(); } + u8 getDrawMtxFlag(u16 idx) const { return mJointTree.getDrawMtxFlag(idx); } + u16 getDrawMtxIndex(u16 idx) const { return mJointTree.getDrawMtxIndex(idx); } + J3DShape* getShapeNodePointer(u16 idx) const { return mShapeTable.getShapeNodePointer(idx); } + J3DJoint* getJointNodePointer(u16 idx) const { return mJointTree.getJointNodePointer(idx); } + J3DJointTree& getJointTree() { return mJointTree; } + JUTNameTab* getJointName() const { return mJointTree.getJointName(); } + Mtx& getInvJointMtx(s32 idx) const { return mJointTree.getInvJointMtx(idx); } + J3DTexture* getTexture() const { return mMaterialTable.getTexture(); } + JUTNameTab* getTextureName() const { return mMaterialTable.getTextureName(); } + u16 getWEvlpMtxNum() const { return mJointTree.getWEvlpMtxNum(); } + u16* getWEvlpMixMtxIndex() const { return mJointTree.getWEvlpMixIndex(); } + f32* getWEvlpMixWeight() const { return mJointTree.getWEvlpMixWeight(); } + u8 getWEvlpMixMtxNum(u16 idx) const { return mJointTree.getWEvlpMixMtxNum(idx); } + u32 getModelDataType() const { return mJointTree.getModelDataType(); } + void* getVtxPosArray() const { return mVertexData.getVtxPosArray(); } + void* getVtxNrmArray() const { return mVertexData.getVtxNrmArray(); } + GXColor* getVtxColorArray(u8 idx) const { return mVertexData.getVtxColorArray(idx); } + bool checkFlag(u32 flag) const { return (mFlags & flag) ? true : false; } + u32 getFlag() const { return mFlags; } + void* getRawData() const { return mpRawData; } + u16 checkBumpFlag() const { return mbHasBumpArray; } + void setBumpFlag(u32 flag) { mbHasBumpArray = flag; } + bool checkBBoardFlag() const { return mbHasBillboard == 1; } + bool isLocked() { return mMaterialTable.isLocked(); } + void entryTexMtxAnimator(J3DAnmTextureSRTKey* anm) { mMaterialTable.entryTexMtxAnimator(anm); } + void entryTevRegAnimator(J3DAnmTevRegKey* anm) { mMaterialTable.entryTevRegAnimator(anm); } + void entryTexNoAnimator(J3DAnmTexPattern* anm) { mMaterialTable.entryTexNoAnimator(anm); } + int removeTexNoAnimator(J3DAnmTexPattern* anm) { + return mMaterialTable.removeTexNoAnimator(anm); + } + int removeTexMtxAnimator(J3DAnmTextureSRTKey* anm) { + return mMaterialTable.removeTexMtxAnimator(anm); + } + int removeTevRegAnimator(J3DAnmTevRegKey* anm) { + return mMaterialTable.removeTevRegAnimator(anm); + } + int removeMatColorAnimator(J3DAnmColor* anm) { + return mMaterialTable.removeMatColorAnimator(anm); + } + void syncJ3DSys() { + syncJ3DSysFlags(); + syncJ3DSysPointers(); + } + +private: + /* 0x04 */ void* mpRawData; + /* 0x08 */ u32 mFlags; + /* 0x0C */ u16 mbHasBumpArray; + /* 0x0E */ u16 mbHasBillboard; + /* 0x10 */ J3DJointTree mJointTree; + /* 0x58 */ J3DMaterialTable mMaterialTable; + /* 0x78 */ J3DShapeTable mShapeTable; + /* 0x88 */ J3DVertexData mVertexData; +}; // Size: 0xE4 + +#endif /* J3DMODELDATA_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h b/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h new file mode 100644 index 000000000..904fa1d36 --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h @@ -0,0 +1,81 @@ +#ifndef J3DMTXBUFFER_H +#define J3DMTXBUFFER_H + +#include "JSystem/J3DGraphAnimator/J3DModelData.h" +#include "dolphin/types.h" + +class J3DModelData; + +class J3DMtxBuffer { +public: + J3DMtxBuffer() { initialize(); } + + /* 80326214 */ void initialize(); + /* 80326258 */ s32 create(J3DModelData*, u32); + /* 80326364 */ s32 createAnmMtx(J3DModelData*); + /* 803263F0 */ s32 createWeightEnvelopeMtx(J3DModelData*); + /* 8032648C */ s32 setNoUseDrawMtx(); + /* 803264B8 */ s32 createDoubleDrawMtx(J3DModelData*, u32); + /* 80326664 */ s32 createBumpMtxArray(J3DModelData*, u32); + /* 803268D4 */ void calcWeightEnvelopeMtx(); + /* 80326ACC */ void calcDrawMtx(u32, Vec const&, f32 const (&)[3][4]); + /* 80326D3C */ void calcNrmMtx(); + /* 80326EF0 */ void calcBBoardMtx(); + + MtxP getAnmMtx(int idx) const { return mpAnmMtx[idx]; } + void setAnmMtx(int i, Mtx m) { MTXCopy(m, (MtxP)mpAnmMtx[i]); } + MtxP getWeightAnmMtx(int idx) const { return mpWeightEvlpMtx[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(u16 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]; } + Mtx33*** getBumpMtxPtrPtr() const { return mpBumpMtxArr[1]; } + Mtx33* getBumpMtxPtr(int idx) const { return mpBumpMtxArr[1][idx][mCurrentViewNo]; } + J3DJointTree* getJointTree() const { return mJointTree; } + + void swapDrawMtx() { + Mtx* tmp = mpDrawMtxArr[0][mCurrentViewNo]; + mpDrawMtxArr[0][mCurrentViewNo] = mpDrawMtxArr[1][mCurrentViewNo]; + mpDrawMtxArr[1][mCurrentViewNo] = tmp; + } + + void swapNrmMtx() { + Mtx33* tmp = mpNrmMtxArr[0][mCurrentViewNo]; + mpNrmMtxArr[0][mCurrentViewNo] = mpNrmMtxArr[1][mCurrentViewNo]; + mpNrmMtxArr[1][mCurrentViewNo] = tmp; + } + + static Mtx sNoUseDrawMtx; + static Mtx33 sNoUseNrmMtx; + static Mtx* sNoUseDrawMtxPtr; + static Mtx33* sNoUseNrmMtxPtr; + +private: + /* 0x00 */ J3DJointTree* mJointTree; + /* 0x04 */ u8* mpScaleFlagArr; + /* 0x08 */ u8* mpEvlpScaleFlagArr; + /* 0x0C */ Mtx* mpAnmMtx; + /* 0x10 */ Mtx* mpWeightEvlpMtx; + /* 0x14 */ Mtx** mpDrawMtxArr[2]; + /* 0x1C */ Mtx33** mpNrmMtxArr[2]; + /* 0x28 */ Mtx33*** mpBumpMtxArr[2]; + /* 0x2C */ u32 mFlags; + /* 0x30 */ u32 mCurrentViewNo; + /* 0x34 */ Mtx* mpUserAnmMtx; + +public: + /* 803283B4 */ virtual ~J3DMtxBuffer(); +}; + +void J3DCalcViewBaseMtx(f32 (*param_0)[4], Vec const& param_1, f32 const (¶m_2)[3][4], + f32 (*param_3)[4]); + +#endif /* J3DMTXBUFFER_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DShapeTable.h b/include/JSystem/J3DGraphAnimator/J3DShapeTable.h new file mode 100644 index 000000000..4df0f6e0b --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DShapeTable.h @@ -0,0 +1,33 @@ +#ifndef J3DSHAPETABLE_H +#define J3DSHAPETABLE_H + +#include "JSystem/J3DGraphBase/J3DShape.h" +#include "dolphin/types.h" + +class JUTNameTab; + +class J3DShapeTable { +public: + J3DShapeTable() { + mShapeNum = 0; + mShapeNodePointer = NULL; + mShapeName = NULL; + } + + /* 803258A0 */ void hide(); + /* 803258D8 */ void show(); + /* 80325910 */ void initShapeNodes(J3DDrawMtxData*, J3DVertexData*); + /* 8032597C */ void sortVcdVatCmd(); + + virtual ~J3DShapeTable(); + + u16 getShapeNum() const { return mShapeNum; } + J3DShape* getShapeNodePointer(u16 idx) const { return mShapeNodePointer[idx]; } + +private: + /* 0x4 */ u16 mShapeNum; + /* 0x8 */ J3DShape** mShapeNodePointer; + /* 0xC */ JUTNameTab* mShapeName; +}; // Size: 0x10 + +#endif /* J3DSHAPETABLE_H */ diff --git a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h new file mode 100644 index 000000000..1844f2f15 --- /dev/null +++ b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h @@ -0,0 +1,120 @@ +#ifndef J3DSKINDEFORM_H +#define J3DSKINDEFORM_H + +#include "JSystem/J3DGraphAnimator/J3DCluster.h" +#include "JSystem/J3DGraphAnimator/J3DMtxBuffer.h" +#include "JSystem/J3DGraphBase/J3DTransform.h" +#include "dolphin/types.h" + +class J3DModel; +class J3DAnmCluster; + +class J3DDeformData { +public: + /* 8032E1F8 */ J3DDeformData(); + /* 8032E230 */ void offAllFlag(u32); + /* 8032E298 */ void deform(J3DVertexBuffer*); + /* 8032E274 */ void deform(J3DModel*); + /* 8032E364 */ void setAnm(J3DAnmCluster*); + +private: + /* 0x00 */ u16 mClusterNum; + /* 0x02 */ u16 mClusterKeyNum; + /* 0x04 */ u16 field_0x4; + /* 0x08 */ J3DCluster** mClusterPointer; + /* 0x0C */ J3DClusterKey** mClusterKeyPointer; + /* 0x10 */ int field_0x10; + /* 0x14 */ u16 field_0x14; + /* 0x16 */ u16 field_0x16; + /* 0x18 */ void* mVtxPos; + /* 0x1C */ void* mVtxNrm; + /* 0x20 */ int field_0x20; + /* 0x24 */ int field_0x24; +}; // Size: 0x28 + +struct J3DSkinNList { + /* 8032C6E4 */ J3DSkinNList(); + /* 8032C85C */ void calcSkin_VtxPosF32(f32 (*)[4], void*, void*); + /* 8032C8E4 */ void calcSkin_VtxNrmF32(f32 (*)[4], void*, void*); + + /* 0x00 */ u16* field_0x0; + /* 0x04 */ u16* field_0x4; + /* 0x08 */ f32* field_0x8; + /* 0x0C */ f32* field_0xc; + /* 0x10 */ u16 field_0x10; + /* 0x12 */ u16 field_0x12; +}; // Size: 0x14 + +class J3DSkinDeform { +public: + /* 8032C96C */ J3DSkinDeform(); + /* 8032C9B0 */ void initSkinInfo(J3DModelData*); + /* 8032CF44 */ int initMtxIndexArray(J3DModelData*); + /* 8032D378 */ void changeFastSkinDL(J3DModelData*); + /* 8032D5C4 */ void calcNrmMtx(J3DMtxBuffer*); + /* 8032D738 */ void transformVtxPosNrm(J3DModelData*); + /* 8032D87C */ void calcAnmInvJointMtx(J3DMtxBuffer*); + /* 8032D8F4 */ void deformFastVtxPos_F32(J3DVertexBuffer*, J3DMtxBuffer*) const; + /* 8032DA1C */ void deformFastVtxNrm_F32(J3DVertexBuffer*, J3DMtxBuffer*) const; + /* 8032DB50 */ void deformVtxPos_F32(J3DVertexBuffer*, J3DMtxBuffer*) const; + /* 8032DC74 */ void deformVtxPos_S16(J3DVertexBuffer*, J3DMtxBuffer*) const; + /* 8032DDB8 */ void deformVtxNrm_F32(J3DVertexBuffer*) const; + /* 8032DEBC */ void deformVtxNrm_S16(J3DVertexBuffer*) const; + /* 8032DFDC */ void deform(J3DModel*); + void setNrmMtx(int i, MtxP mtx) { + J3DPSMtx33CopyFrom34(mtx, (Mtx3P)mNrmMtx[i]); + } + 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; } + + /* 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 */]; + +private: + /* 0x04 */ u16* mPosData; + /* 0x08 */ u16* mNrmData; + /* 0x0C */ Mtx* mPosMtx; + /* 0x10 */ Mtx33* mNrmMtx; + /* 0x14 */ u32 mFlags; + /* 0x18 */ u8 field_0x18; + /* 0x19 */ u8 field_0x19; + /* 0x1C */ int field_0x1c; + /* 0x20 */ int field_0x20; + /* 0x24 */ J3DSkinNList* mSkinNList; +}; + +class J3DDeformer { +public: + /* 8032E39C */ J3DDeformer(J3DDeformData*); + /* 8032EAB4 */ void deform(J3DVertexBuffer*, u16, f32*); + /* 8032E3BC */ void deform(J3DVertexBuffer*, u16); + /* 8032E4A4 */ void deform_VtxPosF32(J3DVertexBuffer*, J3DCluster*, J3DClusterKey*, f32*); + /* 8032E60C */ void deform_VtxNrmF32(J3DVertexBuffer*, J3DCluster*, J3DClusterKey*, f32*); + /* 8032EBCC */ void normalizeWeight(int, f32*); + +private: + /* 0x00 */ J3DDeformData* mDeformData; + /* 0x04 */ J3DAnmCluster* mAnmCluster; + /* 0x08 */ int field_0x8; + /* 0x0C */ int field_0xc; + /* 0x10 */ u32 mFlags; +}; // Size: 0x14 + +inline void J3DFillZero32B(register void* param_0, register u32 param_1) { + asm { + srwi param_1, param_1, 5 + mtctr param_1 + lbl_8032D948: + dcbz 0, param_0 + addi param_0, param_0, 0x20 + bdnz lbl_8032D948 + } +} + +#endif /* J3DSKINDEFORM_H */ diff --git a/include/JSystem/J3DGraphBase/J3DDrawBuffer.h b/include/JSystem/J3DGraphBase/J3DDrawBuffer.h new file mode 100644 index 000000000..714de468d --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DDrawBuffer.h @@ -0,0 +1,95 @@ +#ifndef J3DDRAWBUFFER_H +#define J3DDRAWBUFFER_H + +#include "JSystem/J3DGraphBase/J3DSys.h" +#include "dolphin/types.h" + +// matches debug +inline f32 J3DCalcZValue(register MtxP m, register Vec v) { + register f32 temp_f4; + register f32 out; + register f32 temp_f0; + register f32 temp_f2; + register f32 temp_f1 = 1.0f; + + // clang-format off + asm { + psq_l temp_f0, 0(v), 0, 0 /* qr0 */ + lfs temp_f2, 8(v) + psq_l temp_f4, 32(m), 0, 0 /* qr0 */ + psq_l out, 40(m), 0, 0 /* qr0 */ + ps_merge00 temp_f2, temp_f2, temp_f1 + ps_mul temp_f4, temp_f0, temp_f4 + ps_madd out, temp_f2, out, temp_f4 + ps_sum0 out, out, out, out + } + // clang-format on + + return out; +} + +class J3DDrawBuffer; +class J3DPacket; +class J3DDrawPacket; +class J3DMatPacket; +class J3DShapePacket; + +typedef int (J3DDrawBuffer::*sortFunc)(J3DMatPacket*); +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, + }; + + J3DDrawBuffer() { initialize(); } + ~J3DDrawBuffer(); + void initialize(); + J3DError allocBuffer(u32); + void frameInit(); + int entryMatSort(J3DMatPacket*); + int entryMatAnmSort(J3DMatPacket*); + int entryZSort(J3DMatPacket*); + int entryModelSort(J3DMatPacket*); + int entryInvalidSort(J3DMatPacket*); + int entryNonSort(J3DMatPacket*); + int entryImm(J3DPacket* pPacket, u16 index); + void draw() const; + void drawHead() const; + void drawTail() const; + + u32 getEntryTableSize() { return mBufSize; } + + inline void calcZRatio(); + void setNonSort() { mSortType = 5; } + void setZSort() { mSortType = 2; } + void setZMtx(MtxP mtx) { mpZMtx = mtx; } + +public: + /* 0x00 */ J3DPacket** mpBuf; + /* 0x04 */ u32 mBufSize; + /* 0x08 */ u32 mDrawType; + /* 0x0C */ u32 mSortType; + /* 0x10 */ f32 mZNear; + /* 0x14 */ f32 mZFar; + /* 0x18 */ f32 mZRatio; + /* 0x1C */ MtxP mpZMtx; + /* 0x20 */ J3DPacket* mpCallBackPacket; + + static sortFunc sortFuncTable[6]; + static drawFunc drawFuncTable[2]; + static int entryNum; +}; + +#endif /* J3DDRAWBUFFER_H */ diff --git a/include/JSystem/J3DGraphBase/J3DGD.h b/include/JSystem/J3DGraphBase/J3DGD.h new file mode 100644 index 000000000..6047a4102 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DGD.h @@ -0,0 +1,47 @@ +#ifndef J3DGD_H +#define J3DGD_H + +#include "dolphin/gx/GX.h" +#include "dolphin/gd/GDBase.h" + +inline void J3DGDWrite_u8(u8 param) { + __GDWrite(param); +} + +inline void J3DGDWrite_u16(u16 param) { + __GDWrite((param & 0xffff) >> 8); + __GDWrite(param & 0xff); +} + +inline void J3DGDWrite_u32(u32 param) { + __GDWrite((param >> 24) & 0xff); + __GDWrite((param >> 16) & 0xff); + __GDWrite((param >> 8) & 0xff); + __GDWrite(param & 0xff); +} + +inline void J3DGDWriteXFCmd(u16 param_1, u32 param_2) { + J3DGDWrite_u8(0x10); + J3DGDWrite_u16(0); + J3DGDWrite_u16(param_1); + J3DGDWrite_u32(param_2); +} + +void J3DGDSetGenMode(u8 texGenNum, u8 colorChanNum, u8 tevStageNum, u8 IndTexStageNum, _GXCullMode cullMode); +void J3DGDSetGenMode_3Param(u8 texGenNum, u8 tevStageNum, u8 indTexStageNum); + +static inline void J3DFifoLoadIndx(u8 cmd, u16 indx, u16 addr) { + GFX_FIFO(u8) = cmd; + GFX_FIFO(u16) = indx; + GFX_FIFO(u16) = addr; +} + +inline void J3DGDSetNumChans(u8 numChans) { + J3DGDWriteXFCmd(0x1009, numChans); +} + +inline void J3DGDSetNumTexGens(u8 numTexGens) { + J3DGDWriteXFCmd(0x103f, numTexGens); +} + +#endif /* J3DGD_H */ diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h new file mode 100644 index 000000000..57fabded4 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -0,0 +1,1025 @@ +#ifndef J3DMATBLOCK_H +#define J3DMATBLOCK_H + +#include "JSystem/J3DGraphBase/J3DStruct.h" +#include "JSystem/J3DGraphBase/J3DTevs.h" +#include "JSystem/J3DGraphBase/J3DTexture.h" +#include "dolphin/types.h" +#include "m_Do/m_Do_lib.h" + +struct J3DGXColorS10 : public GXColorS10 { + /* 8000E460 */ J3DGXColorS10() {} +}; + +struct J3DGXColor : public GXColor { + /* 8000E538 */ J3DGXColor() {} +}; + +struct J3DNBTScale : public J3DNBTScaleInfo { + J3DNBTScale() {} + J3DNBTScale(J3DNBTScaleInfo const& info) { + mbHasScale = info.mbHasScale; + mScale = info.mScale; + } + Vec* getScale() { return &mScale; } +}; + +extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; + +class J3DTexGenBlock { +public: + /* 80317354 */ virtual void reset(J3DTexGenBlock*); + virtual void calc(f32 const (*)[4]) = 0; + virtual void calcWithoutViewMtx(f32 const (*)[4]) = 0; + virtual void calcPostTexMtx(f32 const (*)[4]) = 0; + virtual void calcPostTexMtxWithoutViewMtx(f32 const (*)[4]) = 0; + virtual void load() = 0; + virtual void patch() = 0; + virtual void diff(u32) = 0; + virtual void diffTexMtx() = 0; + virtual void diffTexGen() = 0; + /* 803172FC */ virtual s32 countDLSize(); + virtual u32 getType() = 0; + /* 8031741C */ virtual void setTexGenNum(u32 const*); + /* 8000E0D0 */ virtual void setTexGenNum(u32); + /* 8000DFE8 */ virtual u32 getTexGenNum() const; + /* 8000E0CC */ virtual void setTexCoord(u32, J3DTexCoord const*); + /* 8000DFE0 */ virtual J3DTexCoord* getTexCoord(u32); + /* 8003AB2C */ virtual void setTexMtx(u32, J3DTexMtx*); + /* 8000DFD8 */ virtual J3DTexMtx* getTexMtx(u32); + /* 80317424 */ virtual void setNBTScale(J3DNBTScale const*); + /* 80317420 */ virtual void setNBTScale(J3DNBTScale); + /* 80317334 */ virtual J3DNBTScale* getNBTScale(); + /* 80317428 */ virtual bool getTexMtxOffset() const; + /* 80317430 */ virtual void setTexMtxOffset(u32); + /* 803171DC */ virtual ~J3DTexGenBlock(); +}; + +class J3DTexGenBlockPatched : public J3DTexGenBlock { +public: + J3DTexGenBlockPatched() { + initialize(); + } + /* 80317644 */ void initialize(); + + /* 80320084 */ virtual void reset(J3DTexGenBlock*); + /* 803213C0 */ virtual void calc(f32 const (*)[4]); + /* 80321584 */ virtual void calcWithoutViewMtx(f32 const (*)[4]); + /* 803216D8 */ virtual void calcPostTexMtx(f32 const (*)[4]); + /* 8032181C */ virtual void calcPostTexMtxWithoutViewMtx(f32 const (*)[4]); + /* 80322E70 */ virtual void load(); + /* 8031AA88 */ virtual void patch(); + /* 8031AC68 */ virtual void diff(u32); + /* 8031ACD0 */ virtual void diffTexMtx(); + /* 8031AD30 */ virtual void diffTexGen(); + /* 80317B9C */ virtual s32 countDLSize(); + /* 80322E74 */ virtual u32 getType(); + /* 80322D3C */ virtual void setTexGenNum(u32 const*); + /* 80322D34 */ virtual void setTexGenNum(u32); + /* 80322D48 */ virtual u32 getTexGenNum() const; + /* 80322D50 */ virtual void setTexCoord(u32, J3DTexCoord const*); + /* 80322D64 */ virtual J3DTexCoord* getTexCoord(u32); + /* 80322D78 */ virtual void setTexMtx(u32, J3DTexMtx*); + /* 80322D88 */ virtual J3DTexMtx* getTexMtx(u32); + /* 80322D98 */ virtual bool getTexMtxOffset() const; + /* 80322DA0 */ virtual void setTexMtxOffset(u32); + /* 80317180 */ virtual ~J3DTexGenBlockPatched(); + +private: + /* 0x04 */ u32 mTexGenNum; + /* 0x08 */ J3DTexCoord mTexCoord[8]; + /* 0x38 */ J3DTexMtx* mTexMtx[8]; + /* 0x58 */ u32 mTexMtxOffset; +}; // Size: 0x5C + +class J3DTexGenBlockBasic : public J3DTexGenBlockPatched { +public: + J3DTexGenBlockBasic() : mNBTScale(j3dDefaultNBTScaleInfo) { + initialize(); + } + /* 803176A4 */ void initialize(); + + /* 803202DC */ virtual void reset(J3DTexGenBlock*); + /* 8031A9E8 */ virtual void load(); + /* 8031ABC0 */ virtual void patch(); + /* 80317BAC */ virtual s32 countDLSize(); + /* 80322C6C */ virtual u32 getType(); + /* 80322C9C */ virtual void setNBTScale(J3DNBTScale const*); + /* 80322C78 */ virtual void setNBTScale(J3DNBTScale); + /* 80322CC0 */ virtual J3DNBTScale* getNBTScale(); + /* 80322CC8 */ virtual ~J3DTexGenBlockBasic(); + +private: + /* 0x5C */ J3DNBTScale mNBTScale; +}; // Size: 0x6C + +class J3DTexGenBlock4 : public J3DTexGenBlockPatched { +public: + J3DTexGenBlock4() : mNBTScale(j3dDefaultNBTScaleInfo) { + initialize(); + } + /* 80317674 */ void initialize(); + + /* 803201A0 */ virtual void reset(J3DTexGenBlock*); + /* 8031A948 */ virtual void load(); + /* 8031AB18 */ virtual void patch(); + /* 80317BA4 */ virtual s32 countDLSize(); + /* 80322DA8 */ virtual u32 getType(); + /* 80322DD8 */ virtual void setNBTScale(J3DNBTScale const*); + /* 80322DB4 */ virtual void setNBTScale(J3DNBTScale); + /* 80322DFC */ virtual J3DNBTScale* getNBTScale(); + /* 80322E04 */ virtual ~J3DTexGenBlock4(); + +private: + /* 0x5C */ J3DNBTScale mNBTScale; +}; // Size: 0x6C + +class J3DTevBlock { +public: + /* 80317350 */ virtual void reset(J3DTevBlock*); + /* 80317330 */ virtual void load(); + /* 8031CD44 */ virtual void diff(u32); + /* 80321948 */ virtual void diffTexNo(); + /* 80321938 */ virtual void diffTevReg(); + /* 80321944 */ virtual void diffTexCoordScale(); + /* 80321940 */ virtual void diffTevStage(); + /* 8032193C */ virtual void diffTevStageIndirect(); + /* 8000DBD4 */ virtual void patch(); + /* 8032353C */ virtual void patchTexNo(); + /* 80323540 */ virtual void patchTevReg(); + /* 8000DBC8 */ virtual void patchTexNoAndTexCoordScale(); + virtual void ptrToIndex() = 0; + virtual void indexToPtr() = 0; + virtual u32 getType() = 0; + /* 8031730C */ virtual s32 countDLSize(); + /* 80323544 */ virtual void setTexNo(u32, u16 const*); + /* 8000E0AC */ virtual void setTexNo(u32, u16); + /* 8000DF94 */ virtual u16 getTexNo(u32) const; + /* 80323548 */ virtual void setTevOrder(u32, J3DTevOrder const*); + /* 8000E0BC */ virtual void setTevOrder(u32, J3DTevOrder); + /* 8000DFB8 */ virtual J3DTevOrder* getTevOrder(u32); + /* 80110E80 */ virtual void setTevColor(u32, J3DGXColorS10 const*); + /* 8000E0C4 */ virtual void setTevColor(u32, J3DGXColorS10); + /* 8000DFC8 */ virtual _GXColorS10* getTevColor(u32); + /* 800732AC */ virtual void setTevKColor(u32, J3DGXColor const*); + /* 8000E0C0 */ virtual void setTevKColor(u32, J3DGXColor); + /* 8000DFC0 */ virtual _GXColor* getTevKColor(u32); + /* 80322950 */ virtual void setTevKColorSel(u32, u8 const*); + /* 8000E0B8 */ virtual void setTevKColorSel(u32, u8); + /* 8000DFB0 */ virtual bool getTevKColorSel(u32); + /* 80322954 */ virtual void setTevKAlphaSel(u32, u8 const*); + /* 8000E0B4 */ virtual void setTevKAlphaSel(u32, u8); + /* 8000DFA8 */ virtual bool getTevKAlphaSel(u32); + /* 8032354C */ virtual void setTevStageNum(u8 const*); + /* 8000E0C8 */ virtual void setTevStageNum(u8); + /* 8000DFD0 */ virtual u8 getTevStageNum() const; + /* 80323550 */ virtual void setTevStage(u32, J3DTevStage const*); + /* 8000E0A8 */ virtual void setTevStage(u32, J3DTevStage); + /* 8000DF8C */ virtual bool getTevStage(u32); + /* 8032295C */ virtual void setTevSwapModeInfo(u32, J3DTevSwapModeInfo const*); + /* 80322958 */ virtual void setTevSwapModeInfo(u32, J3DTevSwapModeInfo); + /* 80322960 */ virtual void setTevSwapModeTable(u32, J3DTevSwapModeTable const*); + /* 8000E0B0 */ virtual void setTevSwapModeTable(u32, J3DTevSwapModeTable); + /* 8000DFA0 */ virtual bool getTevSwapModeTable(u32); + /* 80323554 */ virtual void setIndTevStage(u32, J3DIndTevStage const*); + /* 8000E0A4 */ virtual void setIndTevStage(u32, J3DIndTevStage); + /* 8000DF84 */ virtual bool getIndTevStage(u32); + /* 80323558 */ virtual bool getTexNoOffset() const; + /* 80322964 */ virtual bool getTevRegOffset() const; + /* 80321FE0 */ virtual void setTexNoOffset(u32); + /* 8032296C */ virtual void setTevRegOffset(u32); + /* 80317224 */ virtual ~J3DTevBlock(); + +private: + /* 8031E098 */ void indexToPtr_private(u32); + + /* 0x4 */ u32 mTexNoOffset; +}; + +class J3DTevBlockPatched : public J3DTevBlock { +public: + J3DTevBlockPatched() { + initialize(); + } + /* 803176E0 */ void initialize(); + + /* 80320418 */ virtual void reset(J3DTevBlock*); + /* 80322970 */ virtual void load(); + /* 8031CE00 */ virtual void diffTexNo(); + /* 8031D028 */ virtual void diffTevReg(); + /* 8031D0C4 */ virtual void diffTexCoordScale(); + /* 8031CE64 */ virtual void diffTevStage(); + /* 8031CF78 */ virtual void diffTevStageIndirect(); + /* 8031C228 */ virtual void patch(); + /* 8031BF4C */ virtual void patchTexNo(); + /* 8031BFE0 */ virtual void patchTevReg(); + /* 8031C0AC */ virtual void patchTexNoAndTexCoordScale(); + /* 8031DFB4 */ virtual void ptrToIndex(); + /* 80322974 */ virtual void indexToPtr(); + /* 80322998 */ virtual u32 getType(); + /* 80317BB4 */ virtual s32 countDLSize(); + /* 803229D0 */ virtual void setTexNo(u32, u16 const*); + /* 803229C0 */ virtual void setTexNo(u32, u16); + /* 803229E4 */ virtual u16 getTexNo(u32) const; + /* 80322A08 */ virtual void setTevOrder(u32, J3DTevOrder const*); + /* 803229F4 */ virtual void setTevOrder(u32, J3DTevOrder); + /* 80322A1C */ virtual J3DTevOrder* getTevOrder(u32); + /* 80322B24 */ virtual void setTevColor(u32, J3DGXColorS10 const*); + /* 80322AF8 */ virtual void setTevColor(u32, J3DGXColorS10); + /* 80322B50 */ virtual GXColorS10* getTevColor(u32); + /* 80322B90 */ virtual void setTevKColor(u32, J3DGXColor const*); + /* 80322B64 */ virtual void setTevKColor(u32, J3DGXColor); + /* 80322BBC */ virtual GXColor* getTevKColor(u32); + /* 80322BDC */ virtual void setTevKColorSel(u32, u8 const*); + /* 80322BD0 */ virtual void setTevKColorSel(u32, u8); + /* 80322BEC */ virtual bool getTevKColorSel(u32); + /* 803229AC */ virtual void setTevStageNum(u8 const*); + /* 803229A4 */ virtual void setTevStageNum(u8); + /* 803229B8 */ virtual u8 getTevStageNum() const; + /* 80322A6C */ virtual void setTevStage(u32, J3DTevStage const*); + /* 80322A30 */ virtual void setTevStage(u32, J3DTevStage); + /* 80322AA8 */ virtual bool getTevStage(u32); + /* 80322AD0 */ virtual void setIndTevStage(u32, J3DIndTevStage const*); + /* 80322ABC */ virtual void setIndTevStage(u32, J3DIndTevStage); + /* 80322AE4 */ virtual bool getIndTevStage(u32); + /* 80322BF8 */ virtual bool getTexNoOffset() const; + /* 80322C00 */ virtual bool getTevRegOffset() const; + /* 80322C08 */ virtual void setTevRegOffset(u32); + /* 80322C10 */ virtual ~J3DTevBlockPatched(); + +private: + /* 0x08 */ u16 mTexNo[8]; + /* 0x18 */ J3DTevOrder mTevOrder[8]; + /* 0x38 */ J3DTevStage mTevStage[8]; + /* 0x78 */ J3DIndTevStage mIndTevStage[8]; + /* 0x98 */ J3DGXColorS10 mTevColor[4]; + /* 0xB8 */ J3DGXColor mTevKColor[4]; + /* 0xC8 */ u8 mTevKColorSel[8]; + /* 0xD0 */ u8 mTevStageNum; + /* 0xD4 */ u32 mTevRegOffset; +}; // Size: 0xD8 + +class J3DTevBlockNull : public J3DTevBlock { + /* 803176D4 */ void initialize(); +}; + +class J3DTevBlock4 : public J3DTevBlock { +public: + J3DTevBlock4() { + initialize(); + } + /* 803178EC */ void initialize(); + + /* 8032098C */ virtual void reset(J3DTevBlock*); + /* 8031B4C0 */ virtual void load(); + /* 8031D758 */ virtual void diffTexNo(); + /* 8031D7BC */ virtual void diffTevReg(); + /* 8031DA1C */ virtual void diffTexCoordScale(); + /* 8031D858 */ virtual void diffTevStage(); + /* 8031D96C */ virtual void diffTevStageIndirect(); + /* 8031C9D0 */ virtual void patch(); + /* 8031C6F4 */ virtual void patchTexNo(); + /* 8031C788 */ virtual void patchTevReg(); + /* 8031C854 */ virtual void patchTexNoAndTexCoordScale(); + /* 80321FE8 */ virtual void ptrToIndex(); + /* 80321FEC */ virtual void indexToPtr(); + /* 80322010 */ virtual u32 getType(); + /* 80317BCC */ virtual s32 countDLSize(); + /* 8032202C */ virtual void setTexNo(u32, u16 const*); + /* 8032201C */ virtual void setTexNo(u32, u16); + /* 80322040 */ virtual u16 getTexNo(u32) const; + /* 80322064 */ virtual void setTevOrder(u32, J3DTevOrder const*); + /* 80322050 */ virtual void setTevOrder(u32, J3DTevOrder); + /* 80322078 */ virtual J3DTevOrder* getTevOrder(u32); + /* 803220B8 */ virtual void setTevColor(u32, J3DGXColorS10 const*); + /* 8032208C */ virtual void setTevColor(u32, J3DGXColorS10); + /* 803220E4 */ virtual GXColorS10* getTevColor(u32); + /* 80322124 */ virtual void setTevKColor(u32, J3DGXColor const*); + /* 803220F8 */ virtual void setTevKColor(u32, J3DGXColor); + /* 80322150 */ virtual GXColor* getTevKColor(u32); + /* 80322170 */ virtual void setTevKColorSel(u32, u8 const*); + /* 80322164 */ virtual void setTevKColorSel(u32, u8); + /* 80322180 */ virtual bool getTevKColorSel(u32); + /* 80322198 */ virtual void setTevKAlphaSel(u32, u8 const*); + /* 8032218C */ virtual void setTevKAlphaSel(u32, u8); + /* 803221A8 */ virtual bool getTevKAlphaSel(u32); + /* 803221BC */ virtual void setTevStageNum(u8 const*); + /* 803221B4 */ virtual void setTevStageNum(u8); + /* 803221C8 */ virtual u8 getTevStageNum() const; + /* 8032220C */ virtual void setTevStage(u32, J3DTevStage const*); + /* 803221D0 */ virtual void setTevStage(u32, J3DTevStage); + /* 80322248 */ virtual bool getTevStage(u32); + /* 80322294 */ virtual void setTevSwapModeInfo(u32, J3DTevSwapModeInfo const*); + /* 8032225C */ virtual void setTevSwapModeInfo(u32, J3DTevSwapModeInfo); + /* 803222DC */ virtual void setTevSwapModeTable(u32, J3DTevSwapModeTable const*); + /* 803222CC */ virtual void setTevSwapModeTable(u32, J3DTevSwapModeTable); + /* 803222EC */ virtual bool getTevSwapModeTable(u32); + /* 80322310 */ virtual void setIndTevStage(u32, J3DIndTevStage const*); + /* 803222FC */ virtual void setIndTevStage(u32, J3DIndTevStage); + /* 80322324 */ virtual bool getIndTevStage(u32); + /* 80322338 */ virtual bool getTexNoOffset() const; + /* 80322340 */ virtual bool getTevRegOffset() const; + /* 80322348 */ virtual void setTevRegOffset(u32); + /* 80322350 */ virtual ~J3DTevBlock4(); + +private: + /* 0x08 */ u16 mTexNo[4]; + /* 0x10 */ J3DTevOrder mTevOrder[4]; + /* 0x20 */ u8 mTevStageNum; + /* 0x21 */ J3DTevStage mTevStage[4]; + /* 0x42 */ J3DGXColorS10 mTevColor[4]; + /* 0x62 */ J3DGXColor mTevKColor[4]; + /* 0x72 */ u8 mTevKColorSel[4]; + /* 0x76 */ u8 mTevKAlphaSel[4]; + /* 0x7A */ J3DTevSwapModeTable mTevSwapModeTable[4]; + /* 0x80 */ J3DIndTevStage mIndTevStage[4]; + /* 0x90 */ u32 mTevRegOffset; +}; // Size: 0x94 + +class J3DTevBlock2 : public J3DTevBlock { +public: + J3DTevBlock2() { + initialize(); + } + /* 80317810 */ void initialize(); + + /* 803206AC */ virtual void reset(J3DTevBlock*); + /* 8031AFA4 */ virtual void load(); + /* 8031D3D0 */ virtual void diffTexNo(); + /* 8031D434 */ virtual void diffTevReg(); + /* 8031D694 */ virtual void diffTexCoordScale(); + /* 8031D4D0 */ virtual void diffTevStage(); + /* 8031D5E4 */ virtual void diffTevStageIndirect(); + /* 8031C6A8 */ virtual void patch(); + /* 8031C3F8 */ virtual void patchTexNo(); + /* 8031C48C */ virtual void patchTevReg(); + /* 8031C558 */ virtual void patchTexNoAndTexCoordScale(); + /* 803223AC */ virtual void ptrToIndex(); + /* 803223B0 */ virtual void indexToPtr(); + /* 803223D4 */ virtual u32 getType(); + /* 80317BC4 */ virtual s32 countDLSize(); + /* 803223F0 */ virtual void setTexNo(u32, u16 const*); + /* 803223E0 */ virtual void setTexNo(u32, u16); + /* 80322404 */ virtual u16 getTexNo(u32) const; + /* 80322428 */ virtual void setTevOrder(u32, J3DTevOrder const*); + /* 80322414 */ virtual void setTevOrder(u32, J3DTevOrder); + /* 8032243C */ virtual J3DTevOrder* getTevOrder(u32); + /* 8032247C */ virtual void setTevColor(u32, J3DGXColorS10 const*); + /* 80322450 */ virtual void setTevColor(u32, J3DGXColorS10); + /* 803224A8 */ virtual GXColorS10* getTevColor(u32); + /* 803224E8 */ virtual void setTevKColor(u32, J3DGXColor const*); + /* 803224BC */ virtual void setTevKColor(u32, J3DGXColor); + /* 80322514 */ virtual GXColor* getTevKColor(u32); + /* 80322534 */ virtual void setTevKColorSel(u32, u8 const*); + /* 80322528 */ virtual void setTevKColorSel(u32, u8); + /* 80322544 */ virtual bool getTevKColorSel(u32); + /* 8032255C */ virtual void setTevKAlphaSel(u32, u8 const*); + /* 80322550 */ virtual void setTevKAlphaSel(u32, u8); + /* 8032256C */ virtual bool getTevKAlphaSel(u32); + /* 80322580 */ virtual void setTevStageNum(u8 const*); + /* 80322578 */ virtual void setTevStageNum(u8); + /* 8032258C */ virtual u8 getTevStageNum() const; + /* 803225D0 */ virtual void setTevStage(u32, J3DTevStage const*); + /* 80322594 */ virtual void setTevStage(u32, J3DTevStage); + /* 8032260C */ virtual bool getTevStage(u32); + /* 80322658 */ virtual void setTevSwapModeInfo(u32, J3DTevSwapModeInfo const*); + /* 80322620 */ virtual void setTevSwapModeInfo(u32, J3DTevSwapModeInfo); + /* 803226A0 */ virtual void setTevSwapModeTable(u32, J3DTevSwapModeTable const*); + /* 80322690 */ virtual void setTevSwapModeTable(u32, J3DTevSwapModeTable); + /* 803226B0 */ virtual bool getTevSwapModeTable(u32); + /* 803226D4 */ virtual void setIndTevStage(u32, J3DIndTevStage const*); + /* 803226C0 */ virtual void setIndTevStage(u32, J3DIndTevStage); + /* 803226E8 */ virtual bool getIndTevStage(u32); + /* 803226FC */ virtual bool getTexNoOffset() const; + /* 80322704 */ virtual bool getTevRegOffset() const; + /* 8032270C */ virtual void setTevRegOffset(u32); + /* 80322714 */ virtual ~J3DTevBlock2(); + +private: + /* 0x08 */ u16 mTexNo[2]; + /* 0x0C */ J3DTevOrder mTevOrder[2]; + /* 0x14 */ J3DGXColorS10 mTevColor[4]; + /* 0x34 */ u8 mTevStageNum; + /* 0x35 */ J3DTevStage mTevStage[2]; + /* 0x45 */ J3DGXColor mTevKColor[4]; + /* 0x55 */ u8 mTevKColorSel[2]; + /* 0x57 */ u8 mTevKAlphaSel[2]; + /* 0x59 */ J3DTevSwapModeTable mTevSwapModeTable[4]; + /* 0x60 */ J3DIndTevStage mIndTevStage[2]; + /* 0x68 */ u32 mTevRegOffset; +}; // Size: 0x6C + +class J3DTevBlock16 : public J3DTevBlock { +public: + J3DTevBlock16() { + initialize(); + } + /* 80317A00 */ void initialize(); + + /* 80320E24 */ virtual void reset(J3DTevBlock*); + /* 8031BA04 */ virtual void load(); + /* 8031DB14 */ virtual void diffTexNo(); + /* 8031DB78 */ virtual void diffTevReg(); + /* 8031DDD8 */ virtual void diffTexCoordScale(); + /* 8031DC14 */ virtual void diffTevStage(); + /* 8031DD28 */ virtual void diffTevStageIndirect(); + /* 8031CCF8 */ virtual void patch(); + /* 8031CA1C */ virtual void patchTexNo(); + /* 8031CAB0 */ virtual void patchTevReg(); + /* 8031CB7C */ virtual void patchTexNoAndTexCoordScale(); + /* 8031DED0 */ virtual void ptrToIndex(); + /* 80321C20 */ virtual void indexToPtr(); + /* 80321C44 */ virtual u32 getType(); + /* 80317BD4 */ virtual s32 countDLSize(); + /* 80321C60 */ virtual void setTexNo(u32, u16 const*); + /* 80321C50 */ virtual void setTexNo(u32, u16); + /* 80321C74 */ virtual u16 getTexNo(u32) const; + /* 80321C98 */ virtual void setTevOrder(u32, J3DTevOrder const*); + /* 80321C84 */ virtual void setTevOrder(u32, J3DTevOrder); + /* 80321CAC */ virtual J3DTevOrder* getTevOrder(u32); + /* 80321CEC */ virtual void setTevColor(u32, J3DGXColorS10 const*); + /* 80321CC0 */ virtual void setTevColor(u32, J3DGXColorS10); + /* 80321D18 */ virtual GXColorS10* getTevColor(u32); + /* 80321D58 */ virtual void setTevKColor(u32, J3DGXColor const*); + /* 80321D2C */ virtual void setTevKColor(u32, J3DGXColor); + /* 80321D84 */ virtual GXColor* getTevKColor(u32); + /* 80321DA4 */ virtual void setTevKColorSel(u32, u8 const*); + /* 80321D98 */ virtual void setTevKColorSel(u32, u8); + /* 80321DB4 */ virtual bool getTevKColorSel(u32); + /* 80321DCC */ virtual void setTevKAlphaSel(u32, u8 const*); + /* 80321DC0 */ virtual void setTevKAlphaSel(u32, u8); + /* 80321DDC */ virtual bool getTevKAlphaSel(u32); + /* 80321DE8 */ virtual void setTevStageNum(u8); + /* 80321DF0 */ virtual void setTevStageNum(u8 const*); + /* 80321DFC */ virtual u8 getTevStageNum() const; + /* 80321E40 */ virtual void setTevStage(u32, J3DTevStage const*); + /* 80321E04 */ virtual void setTevStage(u32, J3DTevStage); + /* 80321E7C */ virtual bool getTevStage(u32); + /* 80321EC8 */ virtual void setTevSwapModeInfo(u32, J3DTevSwapModeInfo const*); + /* 80321E90 */ virtual void setTevSwapModeInfo(u32, J3DTevSwapModeInfo); + /* 80321F10 */ virtual void setTevSwapModeTable(u32, J3DTevSwapModeTable const*); + /* 80321F00 */ virtual void setTevSwapModeTable(u32, J3DTevSwapModeTable); + /* 80321F20 */ virtual bool getTevSwapModeTable(u32); + /* 80321F44 */ virtual void setIndTevStage(u32, J3DIndTevStage const*); + /* 80321F30 */ virtual void setIndTevStage(u32, J3DIndTevStage); + /* 80321F58 */ virtual bool getIndTevStage(u32); + /* 80321F6C */ virtual bool getTexNoOffset() const; + /* 80321F74 */ virtual bool getTevRegOffset() const; + /* 80321F7C */ virtual void setTevRegOffset(u32); + /* 80321F84 */ virtual ~J3DTevBlock16(); + +private: + /* 0x008 */ u16 mTexNo[8]; + /* 0x018 */ J3DTevOrder mTevOrder[16]; + /* 0x058 */ u8 mTevStageNum; + /* 0x059 */ J3DTevStage mTevStage[16]; + /* 0x0DA */ J3DGXColorS10 mTevColor[4]; + /* 0x0FA */ J3DGXColor mTevKColor[4]; + /* 0x10A */ u8 mTevKColorSel[16]; + /* 0x11A */ u8 mTevKAlphaSel[16]; + /* 0x12A */ J3DTevSwapModeTable mTevSwapModeTable[4]; + /* 0x130 */ J3DIndTevStage mIndTevStage[16]; + /* 0x170 */ u32 mTevRegOffset; +}; // Size: 0x174 + +class J3DTevBlock1 : public J3DTevBlock { +public: + J3DTevBlock1() { + initialize(); + } + /* 803177E8 */ void initialize(); + + /* 803205D4 */ virtual void reset(J3DTevBlock*); + /* 8031AD64 */ virtual void load(); + /* 8031D1BC */ virtual void diffTexNo(); + /* 8031D1F4 */ virtual void diffTevReg(); + /* 8031D368 */ virtual void diffTexCoordScale(); + /* 8031D1F8 */ virtual void diffTevStage(); + /* 8031D2E8 */ virtual void diffTevStageIndirect(); + /* 8031C3CC */ virtual void patch(); + /* 8031C274 */ virtual void patchTexNo(); + /* 8031C2E4 */ virtual void patchTevReg(); + /* 8031C2E8 */ virtual void patchTexNoAndTexCoordScale(); + /* 80322770 */ virtual void ptrToIndex(); + /* 80322774 */ virtual void indexToPtr(); + /* 80322798 */ virtual u32 getType(); + /* 80317BBC */ virtual s32 countDLSize(); + /* 803227B4 */ virtual void setTexNo(u32, u16 const*); + /* 803227A4 */ virtual void setTexNo(u32, u16); + /* 803227C8 */ virtual u16 getTexNo(u32) const; + /* 803227EC */ virtual void setTevOrder(u32, J3DTevOrder const*); + /* 803227D8 */ virtual void setTevOrder(u32, J3DTevOrder); + /* 80322800 */ virtual J3DTevOrder* getTevOrder(u32); + /* 80322818 */ virtual void setTevStageNum(u8 const*); + /* 80322814 */ virtual void setTevStageNum(u8); + /* 8032281C */ virtual u8 getTevStageNum() const; + /* 80322860 */ virtual void setTevStage(u32, J3DTevStage const*); + /* 80322824 */ virtual void setTevStage(u32, J3DTevStage); + /* 8032289C */ virtual bool getTevStage(u32); + /* 803228C4 */ virtual void setIndTevStage(u32, J3DIndTevStage const*); + /* 803228B0 */ virtual void setIndTevStage(u32, J3DIndTevStage); + /* 803228D8 */ virtual bool getIndTevStage(u32); + /* 803228EC */ virtual bool getTexNoOffset() const; + /* 803228F4 */ virtual ~J3DTevBlock1(); + +private: + /* 0x08 */ u16 mTexNo[1]; + /* 0x0A */ J3DTevOrder mTevOrder[1]; + /* 0x0E */ J3DTevStage mTevStage[1]; + /* 0x18 */ J3DIndTevStage mIndTevStage[1]; +}; // Size: 0x1C + +extern const u16 j3dDefaultZModeID; + +inline u16 calcZModeID(u8 param_0, u8 param_1, u8 param_2) { + return ((param_1 * 2) & 0x1FE) + (param_0 * 0x10) + param_2; +} + +struct J3DZModeInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 field_0x2; +}; + +struct J3DZMode { + J3DZMode() { + mZModeID = j3dDefaultZModeID; + } + + void setZModeInfo(const J3DZModeInfo& info) { + mZModeID = calcZModeID(info.field_0x0, info.field_0x1, info.field_0x2); + } + + /* 0x0 */ u16 mZModeID; +}; + +struct J3DBlendInfo { + void operator=(J3DBlendInfo const& other) { + *(int*)&mType = *(int*)&other.mType; + } + /* 0x0 */ u8 mType; + /* 0x1 */ u8 mSrcFactor; + /* 0x2 */ u8 mDstFactor; + /* 0x3 */ u8 mOp; +}; + +extern const J3DBlendInfo j3dDefaultBlendInfo; + +struct J3DBlend : public J3DBlendInfo { + J3DBlend() { + *(J3DBlendInfo*)this = j3dDefaultBlendInfo; + } +}; + +extern const J3DFogInfo j3dDefaultFogInfo; + +struct J3DFog : public J3DFogInfo { + J3DFog() { + *getFogInfo() = j3dDefaultFogInfo; + } + J3DFogInfo* getFogInfo() { return (J3DFogInfo*)this; } +}; + +struct J3DAlphaCompInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 mRef0; + /* 0x3 */ u8 mRef1; + /* 0x4 */ u8 field_0x4; + /* 0x5 */ u8 field_0x5; + /* 0x6 */ u8 field_0x6; + /* 0x7 */ u8 field_0x7; +}; + +extern const u16 j3dDefaultAlphaCmpID; + +struct J3DAlphaComp { + J3DAlphaComp() { + field_0x0 = j3dDefaultAlphaCmpID; + mRef0 = 0; + mRef1 = 0; + } + + void setAlphaCompInfo(const J3DAlphaCompInfo& param_1) { + mRef0 = param_1.field_0x1; + mRef1 = param_1.field_0x4; + u32 p1_mref1 = param_1.mRef1; + field_0x0 = calcAlphaCmpID(param_1.field_0x0, param_1.mRef0, p1_mref1); + + // this matches for `dKy_bg_MAxx_proc` but causes `addWarpMaterial` to fail, + // while the above matches for `addWarpMaterial` but causes `dKy_bg_MAxx_proc` to fail? + // field_0x0 = calcAlphaCmpID(param_1.field_0x0, param_1.mRef0, param_1.mRef1); + } + + /* 0x00 */ u16 field_0x0; + /* 0x02 */ u8 mRef0; + /* 0x03 */ u8 mRef1; +}; // Size: 0x4 + +class J3DPEBlock { +public: + /* 80317348 */ virtual void reset(J3DPEBlock*); + virtual void load() = 0; + /* 8000DBCC */ virtual void patch(); + /* 80317344 */ virtual void diff(u32); + /* 8031735C */ virtual void diffFog(); + /* 80317360 */ virtual void diffBlend(); + virtual s32 countDLSize(); + virtual u32 getType() = 0; + /* 80317368 */ virtual void setFog(J3DFog); + /* 80317364 */ virtual void setFog(J3DFog*); + /* 8000DF5C */ virtual J3DFog* getFog(); + /* 8031736C */ virtual void setAlphaComp(J3DAlphaComp const*); + /* 8000E01C */ virtual void setAlphaComp(J3DAlphaComp const&); + /* 8000DF54 */ virtual J3DAlphaComp* getAlphaComp(); + /* 80317370 */ virtual void setBlend(J3DBlend const*); + /* 8000E018 */ virtual void setBlend(J3DBlend const&); + /* 8000DF4C */ virtual bool getBlend(); + /* 80317374 */ virtual void setZMode(J3DZMode const*); + /* 8000E014 */ virtual void setZMode(J3DZMode); + /* 8000DF44 */ virtual J3DZMode* getZMode(); + /* 80317378 */ virtual void setZCompLoc(u8 const*); + /* 8000E010 */ virtual void setZCompLoc(u8); + /* 8000DF3C */ virtual bool getZCompLoc() const; + /* 80317380 */ virtual void setDither(u8 const*); + /* 8031737C */ virtual void setDither(u8); + /* 80317384 */ virtual bool getDither() const; + /* 8031738C */ virtual bool getFogOffset() const; + /* 80317394 */ virtual void setFogOffset(u32); + virtual ~J3DPEBlock(); +}; + +class J3DPEBlockXlu : public J3DPEBlock { +public: + /* 8031E98C */ virtual void load(); + /* 80317BF4 */ virtual s32 countDLSize(); + /* 80323258 */ virtual u32 getType(); + /* 80323264 */ virtual ~J3DPEBlockXlu(); +}; + +class J3DPEBlockTexEdge : public J3DPEBlock { +public: + /* 8031E6C8 */ virtual void load(); + /* 80317BEC */ virtual s32 countDLSize(); + /* 803232C0 */ virtual u32 getType(); + /* 803232CC */ virtual ~J3DPEBlockTexEdge(); +}; + +class J3DPEBlockOpa : public J3DPEBlock { +public: + /* 8031E408 */ virtual void load(); + /* 80317BE4 */ virtual s32 countDLSize(); + /* 80323328 */ virtual u32 getType(); + /* 80323334 */ virtual ~J3DPEBlockOpa(); +}; + +class J3DPEBlockFull : public J3DPEBlock { +public: + J3DPEBlockFull() { + initialize(); + } + /* 80317B58 */ void initialize(); + + /* 8032129C */ virtual void reset(J3DPEBlock*); + /* 8031F3C0 */ virtual void load(); + /* 8031F890 */ virtual void patch(); + /* 8031FCA0 */ virtual void diff(u32); + /* 8031F940 */ virtual void diffFog(); + /* 8031F9B8 */ virtual void diffBlend(); + /* 80317C04 */ virtual s32 countDLSize(); + /* 8032194C */ virtual u32 getType(); + /* 8032197C */ virtual void setFog(J3DFog); + /* 80321958 */ virtual void setFog(J3DFog*); + /* 803219A0 */ virtual J3DFog* getFog(); + /* 803219C4 */ virtual void setAlphaComp(J3DAlphaComp const*); + /* 803219A8 */ virtual void setAlphaComp(J3DAlphaComp const&); + /* 803219E0 */ virtual J3DAlphaComp* getAlphaComp(); + /* 803219F4 */ virtual void setBlend(J3DBlend const*); + /* 803219E8 */ virtual void setBlend(J3DBlend const&); + /* 80321A00 */ virtual bool getBlend(); + /* 80321A14 */ virtual void setZMode(J3DZMode const*); + /* 80321A08 */ virtual void setZMode(J3DZMode); + /* 80321A20 */ virtual J3DZMode* getZMode(); + /* 80321A30 */ virtual void setZCompLoc(u8 const*); + /* 80321A28 */ virtual void setZCompLoc(u8); + /* 80321A3C */ virtual bool getZCompLoc() const; + /* 80321A4C */ virtual void setDither(u8 const*); + /* 80321A44 */ virtual void setDither(u8); + /* 80321A58 */ virtual bool getDither() const; + /* 80321A60 */ virtual bool getFogOffset() const; + /* 80321A68 */ virtual void setFogOffset(u32); + /* 80321A70 */ virtual ~J3DPEBlockFull(); + +private: + /* 0x04 */ J3DFog mFog; + /* 0x30 */ J3DAlphaComp mAlphaComp; + /* 0x34 */ J3DBlend mBlend; + /* 0x38 */ J3DZMode mZMode; + /* 0x3A */ u8 mZCompLoc; + /* 0x3B */ u8 mDither; + /* 0x3C */ u32 mFogOffset; +}; // Size: 0x40 + +class J3DPEBlockFogOff : public J3DPEBlock { +public: + J3DPEBlockFogOff() { + initialize(); + } + /* 80317B34 */ void initialize(); + + /* 803211B4 */ virtual void reset(J3DPEBlock*); + /* 8031EC50 */ virtual void load(); + /* 80321ACC */ virtual void diff(u32); + /* 8031F0D8 */ virtual void diffBlend(); + /* 80317BFC */ virtual s32 countDLSize(); + /* 80321B00 */ virtual u32 getType(); + /* 80321B28 */ virtual void setAlphaComp(J3DAlphaComp const*); + /* 80321B0C */ virtual void setAlphaComp(J3DAlphaComp const&); + /* 80321B44 */ virtual J3DAlphaComp* getAlphaComp(); + /* 80321B58 */ virtual void setBlend(J3DBlend const*); + /* 80321B4C */ virtual void setBlend(J3DBlend const&); + /* 80321B64 */ virtual bool getBlend(); + /* 80321B78 */ virtual void setZMode(J3DZMode const*); + /* 80321B6C */ virtual void setZMode(J3DZMode); + /* 80321B84 */ virtual J3DZMode* getZMode(); + /* 80321B94 */ virtual void setZCompLoc(u8 const*); + /* 80321B8C */ virtual void setZCompLoc(u8); + /* 80321BA0 */ virtual bool getZCompLoc() const; + /* 80321BB0 */ virtual void setDither(u8 const*); + /* 80321BA8 */ virtual void setDither(u8); + /* 80321BBC */ virtual bool getDither() const; + /* 80321BC4 */ virtual ~J3DPEBlockFogOff(); + +private: + /* 0x04 */ J3DAlphaComp mAlphaComp; + /* 0x08 */ J3DBlend mBlend; + /* 0x0C */ J3DZMode mZMode; + /* 0x0E */ u8 mZCompLoc; + /* 0x0F */ u8 mDither; +}; // Size: 0x10 + +struct J3DIndTexCoordScale { + /* 8000E024 */ ~J3DIndTexCoordScale(); + /* 8000E0E4 */ J3DIndTexCoordScale(); + + /* 0x0 */ u8 mScaleS; + /* 0x1 */ u8 mScaleT; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; +}; + +struct J3DIndTexMtx { + /* 8000E064 */ ~J3DIndTexMtx(); + /* 8000E0F0 */ J3DIndTexMtx(); + + /* 0x00 */ Mtx23 mOffsetMtx; + /* 0x18 */ u8 mScaleExp; +}; // Size: 0x1C + +struct J3DIndTexOrder { + /* 8000E128 */ J3DIndTexOrder(); + + /* 0x0 */ u8 mMap; + /* 0x1 */ u8 mCoord; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; +}; + +class J3DIndBlock { +public: + /* 8031734C */ virtual void reset(J3DIndBlock*); + virtual void diff(u32) = 0; + virtual void load() = 0; + /* 80317314 */ virtual s32 countDLSize(); + virtual u32 getType() = 0; + /* 8000E0A0 */ virtual void setIndTexStageNum(u8); + /* 8000DF7C */ virtual u8 getIndTexStageNum() const; + /* 80317410 */ virtual void setIndTexOrder(u32, J3DIndTexOrder); + /* 8031740C */ virtual void setIndTexOrder(u32, J3DIndTexOrder const*); + /* 8000DF74 */ virtual bool getIndTexOrder(u32); + /* 80317414 */ virtual void setIndTexMtx(u32, J3DIndTexMtx const*); + /* 8000E060 */ virtual void setIndTexMtx(u32, J3DIndTexMtx); + /* 8000DF6C */ virtual bool getIndTexMtx(u32); + /* 8000E020 */ virtual void setIndTexCoordScale(u32, J3DIndTexCoordScale); + /* 80317418 */ virtual void setIndTexCoordScale(u32, J3DIndTexCoordScale const*); + /* 8000DF64 */ virtual bool getIndTexCoordScale(u32); + /* 8031726C */ virtual ~J3DIndBlock(); +}; + +class J3DIndBlockFull : public J3DIndBlock { +public: + J3DIndBlockFull() { + initialize(); + } + /* 80317B28 */ void initialize(); + + /* 803210B0 */ virtual void reset(J3DIndBlock*); + /* 8031E328 */ virtual void diff(u32); + /* 8031E12C */ virtual void load(); + /* 80317BDC */ virtual s32 countDLSize(); + /* 80323390 */ virtual u32 getType(); + /* 8032339C */ virtual void setIndTexStageNum(u8); + /* 803233A4 */ virtual u8 getIndTexStageNum() const; + /* 803233AC */ virtual void setIndTexOrder(u32, J3DIndTexOrder); + /* 803233C0 */ virtual void setIndTexOrder(u32, J3DIndTexOrder const*); + /* 803233D4 */ virtual bool getIndTexOrder(u32); + /* 8032341C */ virtual void setIndTexMtx(u32, J3DIndTexMtx const*); + /* 803233E8 */ virtual void setIndTexMtx(u32, J3DIndTexMtx); + /* 80323450 */ virtual bool getIndTexMtx(u32); + /* 80323478 */ virtual void setIndTexCoordScale(u32, J3DIndTexCoordScale const*); + /* 80323464 */ virtual void setIndTexCoordScale(u32, J3DIndTexCoordScale); + /* 8032348C */ virtual bool getIndTexCoordScale(u32); + /* 803234A0 */ virtual ~J3DIndBlockFull(); + +private: + /* 0x04 */ u8 mIndTexStageNum; + /* 0x05 */ J3DIndTexOrder mIndTexOrder[4]; + /* 0x18 */ J3DIndTexMtx mIndTexMtx[3]; + /* 0x6C */ J3DIndTexCoordScale mIndTexCoordScale[4]; +}; // Size: 0x7C + +class J3DIndBlockNull : public J3DIndBlock { +public: + /* 803173A0 */ virtual void reset(J3DIndBlock*); + /* 80317398 */ virtual void diff(u32); + /* 8031739C */ virtual void load(); + /* 803173A4 */ virtual u32 getType(); + /* 803173B0 */ virtual ~J3DIndBlockNull(); +}; + +struct J3DColorChanInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; + /* 0x4 */ u8 field_0x4; + /* 0x5 */ u8 field_0x5; +}; + +struct J3DColorChan { + /* 8000E47C */ J3DColorChan(); + u8 getLightMask() { return (((mColorChanID & 0x7800) >> 7) | (mColorChanID & 0x3c) >> 2); } + void setLightMask(u8 param_1) { + mColorChanID = (mColorChanID & ~0x3c) | ((param_1 & 0xf) << 2); + mColorChanID = (mColorChanID & ~0x7800) | ((param_1 & 0xf0) << 7); + } + + /* 0x0 */ u16 mColorChanID; +}; + +class J3DColorBlock { +public: + /* 80317324 */ virtual void load(); + /* 80317358 */ virtual void reset(J3DColorBlock*); + /* 8031733C */ virtual void patch(); + /* 80317434 */ virtual void patchMatColor(); + /* 8000DBD0 */ virtual void patchLight(); + /* 80317340 */ virtual void diff(u32); + /* 80317438 */ virtual void diffAmbColor(); + /* 8031743C */ virtual void diffMatColor(); + /* 80317440 */ virtual void diffColorChan(); + /* 80317444 */ virtual void diffLightObj(u32); + /* 80317304 */ virtual s32 countDLSize(); + virtual u32 getType() = 0; + /* 80317448 */ virtual void setMatColor(u32, J3DGXColor const*); + /* 8000E0DC */ virtual void setMatColor(u32, J3DGXColor); + /* 8000E000 */ virtual _GXColor* getMatColor(u32); + /* 801A4C0C */ virtual void setAmbColor(u32, J3DGXColor const*); + /* 8000E0D4 */ virtual void setAmbColor(u32, J3DGXColor); + /* 8000DFF0 */ virtual bool getAmbColor(u32); + /* 8000E0E0 */ virtual void setColorChanNum(u8); + /* 8031744C */ virtual void setColorChanNum(u8 const*); + /* 8000E008 */ virtual u8 getColorChanNum() const; + /* 8000E0D8 */ virtual void setColorChan(u32, J3DColorChan const&); + /* 80317450 */ virtual void setColorChan(u32, J3DColorChan const*); + /* 8000DFF8 */ virtual J3DColorChan* getColorChan(u32); + /* 801A4C08 */ virtual void setLight(u32, J3DLightObj*); + /* 80317454 */ virtual bool getLight(u32); + /* 80317460 */ virtual void setCullMode(u8 const*); + /* 8031745C */ virtual void setCullMode(u8); + /* 80317328 */ virtual s32 getCullMode() const; + /* 80317464 */ virtual bool getMatColorOffset() const; + /* 8031746C */ virtual bool getColorChanOffset() const; + /* 80317474 */ virtual void setMatColorOffset(u32); + /* 80317478 */ virtual void setColorChanOffset(u32); + /* 80317138 */ virtual ~J3DColorBlock(); +}; + +class J3DColorBlockLightOn : public J3DColorBlock { +public: + J3DColorBlockLightOn() { + initialize(); + } + /* 80317580 */ void initialize(); + + /* 803187F4 */ virtual void load(); + /* 8031FF34 */ virtual void reset(J3DColorBlock*); + /* 803194E8 */ virtual void patch(); + /* 80319534 */ virtual void patchMatColor(); + /* 803196E0 */ virtual void patchLight(); + /* 8031A13C */ virtual void diff(u32); + /* 8031A1DC */ virtual void diffAmbColor(); + /* 8031A358 */ virtual void diffMatColor(); + /* 8031A4D4 */ virtual void diffColorChan(); + /* 8031A8E0 */ virtual void diffLightObj(u32); + /* 80317B94 */ virtual s32 countDLSize(); + /* 80322E80 */ virtual u32 getType(); + /* 80322EB8 */ virtual void setMatColor(u32, J3DGXColor const*); + /* 80322E8C */ virtual void setMatColor(u32, J3DGXColor); + /* 80322EE4 */ virtual GXColor* getMatColor(u32); + /* 80322F24 */ virtual void setAmbColor(u32, J3DGXColor const*); + /* 80322EF8 */ virtual void setAmbColor(u32, J3DGXColor); + /* 80322F50 */ virtual bool getAmbColor(u32); + /* 80322F70 */ virtual void setColorChanNum(u8); + /* 80322F64 */ virtual void setColorChanNum(u8 const*); + /* 80322F78 */ virtual u8 getColorChanNum() const; + /* 80322F94 */ virtual void setColorChan(u32, J3DColorChan const&); + /* 80322F80 */ virtual void setColorChan(u32, J3DColorChan const*); + /* 80322FA8 */ virtual J3DColorChan* getColorChan(u32); + /* 80322FBC */ virtual void setLight(u32, J3DLightObj*); + /* 80322FCC */ virtual bool getLight(u32); + /* 80322FE4 */ virtual void setCullMode(u8 const*); + /* 80322FDC */ virtual void setCullMode(u8); + /* 80322FF0 */ virtual s32 getCullMode() const; + /* 80322FF8 */ virtual bool getMatColorOffset() const; + /* 80323000 */ virtual bool getColorChanOffset() const; + /* 80323008 */ virtual void setMatColorOffset(u32); + /* 80323010 */ virtual void setColorChanOffset(u32); + /* 80323018 */ virtual ~J3DColorBlockLightOn(); + +private: + /* 0x04 */ J3DGXColor mMatColor[2]; + /* 0x0C */ J3DGXColor mAmbColor[2]; + /* 0x14 */ u8 mColorChanNum; + /* 0x16 */ J3DColorChan mColorChan[4]; + /* 0x20 */ J3DLightObj* mLight[8]; + /* 0x40 */ u8 mCullMode; + /* 0x44 */ u32 mMatColorOffset; + /* 0x48 */ u32 mColorChanOffset; +}; // Size: 0x4C + +class J3DColorBlockLightOff : public J3DColorBlock { +public: + J3DColorBlockLightOff() { + initialize(); + } + /* 8031747C */ void initialize(); + + /* 80317C0C */ virtual void load(); + /* 8031FD08 */ virtual void reset(J3DColorBlock*); + /* 80318EB4 */ virtual void patch(); + /* 80318F00 */ virtual void patchMatColor(); + /* 803190AC */ virtual void patchLight(); + /* 80319B4C */ virtual void diff(u32); + /* 80319BB4 */ virtual void diffMatColor(); + /* 80319D30 */ virtual void diffColorChan(); + /* 80317B84 */ virtual s32 countDLSize(); + /* 80323560 */ virtual u32 getType(); + /* 80323184 */ virtual void setMatColor(u32, J3DGXColor const*); + /* 80323158 */ virtual void setMatColor(u32, J3DGXColor); + /* 803231B0 */ virtual GXColor* getMatColor(u32); + /* 803231D0 */ virtual void setColorChanNum(u8); + /* 803231C4 */ virtual void setColorChanNum(u8 const*); + /* 803231D8 */ virtual u8 getColorChanNum() const; + /* 803231F4 */ virtual void setColorChan(u32, J3DColorChan const&); + /* 803231E0 */ virtual void setColorChan(u32, J3DColorChan const*); + /* 80323208 */ virtual J3DColorChan* getColorChan(u32); + /* 80323224 */ virtual void setCullMode(u8 const*); + /* 8032321C */ virtual void setCullMode(u8); + /* 80323230 */ virtual s32 getCullMode() const; + /* 80323238 */ virtual bool getMatColorOffset() const; + /* 80323240 */ virtual bool getColorChanOffset() const; + /* 80323248 */ virtual void setMatColorOffset(u32); + /* 80323250 */ virtual void setColorChanOffset(u32); + /* 803170DC */ virtual ~J3DColorBlockLightOff(); + +private: + /* 0x04 */ J3DGXColor mMatColor[2]; + /* 0x0C */ u8 mColorChanNum; + /* 0x0E */ J3DColorChan mColorChan[4]; + /* 0x16 */ u8 mCullMode; + /* 0x18 */ u32 mMatColorOffset; + /* 0x1C */ u32 mColorChanOffset; +}; // Size: 0x20 + +class J3DColorBlockAmbientOn : public J3DColorBlockLightOff { +public: + J3DColorBlockAmbientOn() { + initialize(); + } + /* 803174DC */ void initialize(); + + /* 8031816C */ virtual void load(); + /* 8031FDE4 */ virtual void reset(J3DColorBlock*); + /* 80317B8C */ virtual s32 countDLSize(); + /* 80323074 */ virtual u32 getType(); + /* 803230AC */ virtual void setAmbColor(u32, J3DGXColor const*); + /* 80323080 */ virtual void setAmbColor(u32, J3DGXColor); + /* 803230D8 */ virtual bool getAmbColor(u32); + /* 803230EC */ virtual ~J3DColorBlockAmbientOn(); + +private: + /* 0x20 */ J3DGXColor mAmbColor[2]; +}; // Size: 0x28 + +#endif /* J3DMATBLOCK_H */ diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h new file mode 100644 index 000000000..1c5853f76 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -0,0 +1,126 @@ +#ifndef J3DMATERIAL_H +#define J3DMATERIAL_H + +#include "JSystem/J3DGraphBase/J3DMatBlock.h" +#include "JSystem/J3DGraphBase/J3DPacket.h" +#include "JSystem/J3DGraphBase/J3DShape.h" +#include "JSystem/J3DGraphBase/J3DTexture.h" +#include "dolphin/types.h" + +class J3DJoint; +class J3DMaterialAnm; + +class J3DMaterial { +public: + /* 803157A0 */ static J3DColorBlock* createColorBlock(u32); + /* 803159A0 */ static J3DTexGenBlock* createTexGenBlock(u32); + /* 80315B04 */ static J3DTevBlock* createTevBlock(int); + /* 80315E78 */ static J3DIndBlock* createIndBlock(int); + /* 80315F60 */ static J3DPEBlock* createPEBlock(u32, u32); + /* 80316100 */ static u32 calcSizeColorBlock(u32); + /* 80316150 */ static u32 calcSizeTexGenBlock(u32); + /* 8031617C */ static u32 calcSizeTevBlock(int); + /* 803161C4 */ static u32 calcSizeIndBlock(int); + /* 803161D8 */ static u32 calcSizePEBlock(u32, u32); + /* 80316240 */ void initialize(); + /* 80316290 */ u32 countDLSize(); + /* 80316344 */ void makeDisplayList_private(J3DDisplayListObj*); + /* 80316AB0 */ void setCurrentMtx(); + /* 80316AC8 */ void calcCurrentMtx(); + /* 80316D68 */ void copy(J3DMaterial*); + /* 80316E90 */ s32 newSharedDisplayList(u32); + /* 80316F24 */ s32 newSingleSharedDisplayList(u32); + + /* 803169DC */ virtual void calc(f32 const (*)[4]); + /* 80316A54 */ virtual void calcDiffTexMtx(f32 const (*)[4]); + /* 80316620 */ virtual void makeDisplayList(); + /* 80316668 */ virtual void makeSharedDisplayList(); + /* 8031668C */ virtual void load(); + /* 803166DC */ virtual void loadSharedDL(); + /* 80316740 */ virtual void patch(); + /* 803167D8 */ virtual void diff(u32); + /* 80316E14 */ virtual void reset(); + /* 80316E70 */ virtual void change(); + + J3DMaterial* getNext() const { return mNext; } + J3DShape* getShape() const { return mShape; } + J3DTevBlock* getTevBlock() const { return mTevBlock; } + J3DColorBlock* getColorBlock() const { return mColorBlock; } + J3DTexGenBlock* getTexGenBlock() const { return mTexGenBlock; } + J3DDisplayListObj* getSharedDisplayListObj() const { return mSharedDLObj; } + J3DIndBlock* getIndBlock() const { return mIndBlock; } + J3DShape* getShape() { return mShape; } + J3DJoint* getJoint() { return mJoint; } + J3DMaterialAnm* getMaterialAnm() const { + if ((u32)mMaterialAnm < 0xC0000000) { + return mMaterialAnm; + } else { + return NULL; + } + } + J3DNBTScale* getNBTScale() const { return mTexGenBlock->getNBTScale(); } + u16 getTexNo(u32 idx) const { return mTevBlock->getTexNo(idx); } + GXColor* getTevKColor(u32 param_0) { return mTevBlock->getTevKColor(param_0); } + GXColorS10* getTevColor(u32 param_0) { return mTevBlock->getTevColor(param_0); } + J3DFog* getFog() { return mPEBlock->getFog(); } + J3DTexMtx* getTexMtx(u32 idx) { return mTexGenBlock->getTexMtx(idx); } + u16 getIndex() { return mIndex; } + bool isDrawModeOpaTexEdge() { return (mMaterialMode & 3) == 0; } + J3DPEBlock* getPEBlock() { return mPEBlock; } + void onInvalid() { mInvalid = 1; } + u32 getTexGenNum() const { return mTexGenBlock->getTexGenNum(); } + u8 getTevStageNum() const { return mTevBlock->getTevStageNum(); } + + void setTevColor(u32 i, const J3DGXColorS10* i_color) { mTevBlock->setTevColor(i, i_color); } + void setTevKColor(u32 i, const J3DGXColor* i_color) { mTevBlock->setTevKColor(i, i_color); } + void setMaterialAnm(J3DMaterialAnm* i_anm) { mMaterialAnm = i_anm; } + void setCullMode(u8 i_mode) { mColorBlock->setCullMode(i_mode); } + +public: + /* 0x04 */ J3DMaterial* mNext; + /* 0x08 */ J3DShape* mShape; + /* 0x0C */ J3DJoint* mJoint; + /* 0x10 */ u32 mMaterialMode; + /* 0x14 */ u16 mIndex; + /* 0x18 */ u32 mInvalid; + /* 0x1C */ u32 field_0x1c; + /* 0x20 */ u32 mDiffFlag; + /* 0x24 */ J3DColorBlock* mColorBlock; + /* 0x28 */ J3DTexGenBlock* mTexGenBlock; + /* 0x2C */ J3DTevBlock* mTevBlock; + /* 0x30 */ J3DIndBlock* mIndBlock; + /* 0x34 */ J3DPEBlock* mPEBlock; + /* 0x38 */ J3DMaterial* mpOrigMaterial; + /* 0x3C */ J3DMaterialAnm* mMaterialAnm; + /* 0x40 */ J3DCurrentMtx mCurrentMtx; + /* 0x48 */ J3DDisplayListObj* mSharedDLObj; +}; + +class J3DPatchedMaterial : public J3DMaterial { +public: + /* 80316FB8 */ void initialize(); + + /* 80316FD8 */ virtual void makeDisplayList(); + /* 80316FDC */ virtual void makeSharedDisplayList(); + /* 80316FE0 */ virtual void load(); + /* 80316FFC */ virtual void loadSharedDL(); + /* 8031703C */ virtual void reset(); + /* 80317040 */ virtual void change(); +}; + +class J3DLockedMaterial : public J3DMaterial { +public: + /* 80317044 */ void initialize(); + + /* 803170D0 */ virtual void calc(f32 const (*)[4]); + /* 80317064 */ virtual void makeDisplayList(); + /* 80317068 */ virtual void makeSharedDisplayList(); + /* 8031706C */ virtual void load(); + /* 80317088 */ virtual void loadSharedDL(); + /* 803170C8 */ virtual void patch(); + /* 803170CC */ virtual void diff(u32); + /* 803170D4 */ virtual void reset(); + /* 803170D8 */ virtual void change(); +}; + +#endif /* J3DMATERIAL_H */ diff --git a/include/JSystem/J3DGraphBase/J3DPacket.h b/include/JSystem/J3DGraphBase/J3DPacket.h new file mode 100644 index 000000000..00827b896 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DPacket.h @@ -0,0 +1,215 @@ +#ifndef J3DPACKET_H +#define J3DPACKET_H + +#include "JSystem/J3DGraphBase/J3DSys.h" +#include "dolphin/gd/GDBase.h" +#include "dolphin/types.h" + +class J3DMatPacket; + +class J3DDrawBuffer; +class J3DMaterial; +class J3DMaterialAnm; +class J3DModel; +class J3DMtxBuffer; +class J3DShape; +class J3DTexMtx; +class J3DTexMtxObj; +class J3DTexture; + +inline u32 getDiffFlag_LightObjNum(u32 param_1) { + return (param_1 & 0xf0) >> 4; +} + +inline u32 getDiffFlag_TexGenNum(u32 param_1) { + return (param_1 & 0xf00) >> 8; +} + +inline int calcDifferedBufferSize_TexMtxSize(int param_1) { + return param_1 * 0x35; +} + +inline int calcDifferedBufferSize_TexGenSize(int param_1) { + return param_1 * 0x3d + 10; +} + +inline u32 getDiffFlag_TexNoNum(u32 param_1) { + return (param_1 & 0xf0000) >> 0x10; +} + +inline int calcDifferedBufferSize_TexNoSize(int param_1) { + return param_1 * 0x37; +} + +inline u32 calcDifferedBufferSize_TexNoAndTexCoordScaleSize(u32 param_1) { + u32 res = param_1 * 0x37; + res += ((param_1 + 1) >> 1) * 0x37; + return res; +} + +inline u32 getDiffFlag_TevStageNum(u32 param_1) { + return (param_1 & 0xf00000) >> 0x14; +} + +inline int calcDifferedBufferSize_TevStageSize(int param_1) { + return param_1 * 10; +} + +inline int calcDifferedBufferSize_TevStageDirectSize(int param_1) { + return param_1 * 5; +} + +class J3DDisplayListObj { +public: + J3DDisplayListObj() { + mpData[0] = NULL; + mpData[1] = NULL; + mSize = 0; + mCapacity = 0; + } + + J3DError newDisplayList(u32); + J3DError newSingleDisplayList(u32); + J3DError single_To_Double(); + void setSingleDisplayList(void*, u32); + void swapBuffer(); + void callDL() const; + void beginDL(); + u32 endDL(); + void beginPatch(); + u32 endPatch(); + + u8* getDisplayList(int idx) const { return (u8*)mpData[idx]; } + u32 getDisplayListSize() const { return mSize; } + + static GDLObj sGDLObj; + static s32 sInterruptFlag; + + /* 0x0 */ void* mpData[2]; + /* 0x8 */ u32 mSize; + /* 0xC */ u32 mCapacity; +}; // Size: 0x10 + +class J3DPacket { +public: + J3DPacket() { + mpNextPacket = NULL; + mpFirstChild = NULL; + mpUserData = NULL; + } + + void addChildPacket(J3DPacket*); + + J3DPacket* getNextPacket() const { return mpNextPacket; } + void setNextPacket(J3DPacket* i_packet) { mpNextPacket = i_packet; } + + void drawClear() { + mpNextPacket = NULL; + mpFirstChild = NULL; + } + + void setUserArea(u32 area) { mpUserData = (void*)area; } + + virtual int entry(J3DDrawBuffer*); + virtual void draw(); + virtual ~J3DPacket() {} + +public: + /* 0x04 */ J3DPacket* mpNextPacket; + /* 0x08 */ J3DPacket* mpFirstChild; + /* 0x0C */ void* mpUserData; +}; // Size: 0x10 + +class J3DDrawPacket : public J3DPacket { +public: + J3DDrawPacket(); + ~J3DDrawPacket(); + J3DError newDisplayList(u32); + J3DError newSingleDisplayList(u32); + virtual void draw(); + + J3DDisplayListObj* getDisplayListObj() const { return mpDisplayListObj; } + void setDisplayListObj(J3DDisplayListObj* pObj) { mpDisplayListObj = pObj; } + + void beginPatch() { mpDisplayListObj->beginPatch(); } + void endPatch() { mpDisplayListObj->endPatch(); } + + void callDL() const { getDisplayListObj()->callDL(); } + + enum { + LOCKED = 0x01, + }; + + bool checkFlag(u32 flag) const { return (mFlags & flag) != 0; } + 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; } + bool isLocked() const { return checkFlag(1); } + +public: + /* 0x10 */ u32 mFlags; + /* 0x14 */ char mPad0[0x0C]; // unk + /* 0x20 */ J3DDisplayListObj* mpDisplayListObj; + /* 0x24 */ J3DTexMtxObj* mpTexMtxObj; +}; // Size: 0x28 + +class J3DShapePacket : public J3DDrawPacket { +public: + J3DShapePacket(); + u32 calcDifferedBufferSize(u32); + J3DError 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 setMtxBuffer(J3DMtxBuffer* pMtxBuffer) { mpMtxBuffer = pMtxBuffer; } + void setBaseMtxPtr(Mtx* pMtx) { mpBaseMtxPtr = pMtx; } + + J3DShape* getShape() const { return mpShape; } + J3DModel* getModel() const { return mpModel; } + Mtx* getBaseMtxPtr() const { return mpBaseMtxPtr; } + +public: + /* 0x28 */ J3DShape* mpShape; + /* 0x2C */ J3DMtxBuffer* mpMtxBuffer; + /* 0x30 */ Mtx* mpBaseMtxPtr; + /* 0x34 */ u32 mDiffFlag; + /* 0x38 */ J3DModel* mpModel; +}; // Size: 0x3C + +class J3DMatPacket : public J3DDrawPacket { +public: + J3DMatPacket(); + void addShapePacket(J3DShapePacket*); + void beginDiff(); + void endDiff(); + bool isSame(J3DMatPacket*) const; + + J3DMaterial* getMaterial() const { return mpMaterial; } + J3DShapePacket* getShapePacket() const { return mpShapePacket; } + void setShapePacket(J3DShapePacket* packet) { mpShapePacket = packet; } + void setInitShapePacket(J3DShapePacket* packet) { mpInitShapePacket = packet; } + void setMaterialAnmID(J3DMaterialAnm* materialAnm) { mpMaterialAnm = materialAnm; } + bool isChanged() const { return mDiffFlag & 0x80000000; } + bool isEnabled_Diff() const { return mpInitShapePacket->getDisplayListObj() != NULL; } + + virtual ~J3DMatPacket(); + virtual int entry(J3DDrawBuffer*); + virtual void draw(); + +public: + /* 0x28 */ J3DShapePacket* mpInitShapePacket; + /* 0x2C */ J3DShapePacket* mpShapePacket; + /* 0x30 */ J3DMaterial* mpMaterial; + /* 0x34 */ u32 mDiffFlag; + /* 0x38 */ J3DTexture* mpTexture; + /* 0x3C */ J3DMaterialAnm* mpMaterialAnm; +}; // Size: 0x40 + +#endif /* J3DPACKET_H */ diff --git a/include/JSystem/J3DGraphBase/J3DShape.h b/include/JSystem/J3DGraphBase/J3DShape.h new file mode 100644 index 000000000..457724a86 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DShape.h @@ -0,0 +1,152 @@ +#ifndef J3DSHAPE_H +#define J3DSHAPE_H + +#include "JSystem/J3DGraphBase/J3DShapeDraw.h" +#include "JSystem/J3DGraphBase/J3DShapeMtx.h" +#include "dolphin/gx/GX.h" +#include "dolphin/types.h" + +class J3DCurrentMtxInfo { +public: + u32 mMtxIdxRegA; + u32 mMtxIdxRegB; +}; + +static inline void J3DFifoWriteCPCmd(u8 cmd, u32 param) { + GFX_FIFO(u8) = GX_CMD_LOAD_CP_REG; + GFX_FIFO(u8) = cmd; + GFX_FIFO(u32) = param; +} + +static inline void J3DFifoWriteXFCmd(u16 cmd, u16 len) { + GFX_FIFO(u8) = GX_CMD_LOAD_XF_REG; + GFX_FIFO(u16) = (len - 1); + GFX_FIFO(u16) = cmd; +} + +class J3DCurrentMtx : public J3DCurrentMtxInfo { +public: + J3DCurrentMtx() { + mMtxIdxRegA = 0x3cf3cf00; + mMtxIdxRegB = 0x00f3cf3c; + } + + u32 getMtxIdxRegA() const { return mMtxIdxRegA; } + u32 getMtxIdxRegB() const { return mMtxIdxRegB; } + + inline void load() const { + J3DFifoWriteCPCmd(0x30, getMtxIdxRegA()); // CP_MATINDEX_A + J3DFifoWriteCPCmd(0x40, getMtxIdxRegB()); // CP_MATINDEX_B + J3DFifoWriteXFCmd(0x1018, 2); + GFX_FIFO(u32) = getMtxIdxRegA(); + GFX_FIFO(u32) = getMtxIdxRegB(); + } + + void setCurrentTexMtx(u8 param_1, u8 param_2, u8 param_3, u8 param_4, + u8 param_5, u8 param_6, u8 param_7, u8 param_8) { + mMtxIdxRegA = ((param_1 & 0xff) << 6) | (param_2 << 0xc)| (param_3 << 0x12) | (param_4 << 0x18); + mMtxIdxRegB = (param_5) | param_6 << 6 | param_7 << 0xc | param_8 << 0x12; + } +}; + +class J3DMaterial; +class J3DVertexData; +class J3DDrawMtxData; + +enum J3DShpFlag { + J3DShpFlag_Visible = 0x0001, + J3DShpFlag_SkinPosCpu = 0x0004, + J3DShpFlag_SkinNrmCpu = 0x0008, + J3DShpFlag_Hidden = 0x0010, + J3DShpFlag_EnableLod = 0x0100, + J3DShpFlag_NoMtx = 0x0200, +}; + +class J3DShape { +public: + J3DShape() { + initialize(); + } + + enum { + kVcdVatDLSize = 0xC0, + }; + + /* 80314B48 */ void initialize(); + /* 80314BB8 */ void addTexMtxIndexInDL(_GXAttr, u32); + /* 80314CBC */ void addTexMtxIndexInVcd(_GXAttr); + /* 80314DA8 */ void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]); + /* 80314E28 */ u32 countBumpMtxNum() const; + /* 80314EEC */ void loadVtxArray() const; + /* 80314F5C */ bool isSameVcdVatCmd(J3DShape*); + /* 80314F98 */ void makeVtxArrayCmd(); + /* 80315260 */ void makeVcdVatCmd(); + /* 80315300 */ void loadPreDrawSetting() const; + /* 80315398 */ void setArrayAndBindPipeline() const; + + /* 803155E0 */ virtual void draw() const; + /* 8031544C */ virtual void drawFast() const; + /* 80315628 */ virtual void simpleDraw() const; + /* 803156AC */ virtual void simpleDrawCache() 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; } + void* getVcdVatCmd() const { 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 setCurrentMtx(J3DCurrentMtx& mtx) { mCurrentMtx = mtx; } + void setScaleFlagArray(u8* pScaleFlagArray) { mScaleFlagArray = pScaleFlagArray; } + void setDrawMtx(Mtx** pDrawMtx) { mDrawMtx = pDrawMtx; } + void setNrmMtx(Mtx33** pNrmMtx) { mNrmMtx = pNrmMtx; } + void setTexMtxLoadType(u32 type) { mFlags = (mFlags & 0xFFFF0FFF) | type; } + bool getNBTFlag() const { return mHasNBT; } + u32 getBumpMtxOffset() const { return mBumpMtxOffset; } + GXVtxDescList* getVtxDesc() const { return mVtxDesc; } + + J3DMaterial* getMaterial() const { return mMaterial; } + u32 getIndex() const { return mIndex; } + u32 getPipeline() const { return (mFlags >> 2) & 0x07; } + u32 getTexMtxLoadType() const { return mFlags & 0xF000; } + u32 getMtxGroupNum() const { return mMtxGroupNum; } + J3DShapeDraw* getShapeDraw(u32 idx) const { return mShapeDraw[idx]; } + J3DShapeMtx* getShapeMtx(u32 idx) const { return mShapeMtx[idx]; } + Vec* getMin() { return &mMin; } + Vec* getMax() { return &mMax; } + + static void resetVcdVatCache() { sOldVcdVatCmd = NULL; } + + static void* sOldVcdVatCmd; + +private: + friend struct J3DShapeFactory; + friend class J3DJointTree; + + /* 0x04 */ J3DMaterial* mMaterial; + /* 0x08 */ u16 mIndex; + /* 0x0A */ u16 mMtxGroupNum; + /* 0x0C */ u32 mFlags; + /* 0x10 */ f32 mRadius; + /* 0x14 */ Vec mMin; + /* 0x20 */ Vec mMax; + /* 0x2C */ u8* mVcdVatCmd; + /* 0x30 */ GXVtxDescList* mVtxDesc; + /* 0x34 */ bool mHasNBT; + /* 0x38 */ J3DShapeMtx** mShapeMtx; + /* 0x3C */ J3DShapeDraw** mShapeDraw; + /* 0x40 */ J3DCurrentMtx mCurrentMtx; + /* 0x48 */ bool mHasPNMTXIdx; + /* 0x4C */ J3DVertexData* mVertexData; + /* 0x50 */ J3DDrawMtxData* mDrawMtxData; + /* 0x54 */ u8* mScaleFlagArray; + /* 0x58 */ Mtx** mDrawMtx; + /* 0x5C */ Mtx33** mNrmMtx; + /* 0x60 */ u32* mCurrentViewNo; + /* 0x64 */ u32 mBumpMtxOffset; +}; + +#endif /* J3DSHAPE_H */ diff --git a/include/JSystem/J3DGraphBase/J3DShapeDraw.h b/include/JSystem/J3DGraphBase/J3DShapeDraw.h new file mode 100644 index 000000000..2293fd633 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DShapeDraw.h @@ -0,0 +1,24 @@ +#ifndef J3DSHAPEDRAW_H +#define J3DSHAPEDRAW_H + +#include "dolphin/types.h" + +class J3DShapeDraw { +public: + /* 80314924 */ u32 countVertex(u32); + /* 80314974 */ void addTexMtxIndexInDL(u32, u32, u32); + /* 80314ABC */ J3DShapeDraw(u8 const*, u32); + /* 80314AD4 */ void draw() const; + + /* 80314B00 */ virtual ~J3DShapeDraw(); + + u8* getDisplayList() const { return (u8*)mDisplayList; } + u32 getDisplayListSize() const { return mDisplayListSize; } + void setDisplayListSize(u32 size) { mDisplayListSize = size; } + +private: + /* 0x04 */ u32 mDisplayListSize; + /* 0x08 */ void* mDisplayList; +}; + +#endif /* J3DSHAPEDRAW_H */ diff --git a/include/JSystem/J3DGraphBase/J3DShapeMtx.h b/include/JSystem/J3DGraphBase/J3DShapeMtx.h new file mode 100644 index 000000000..5f23e39db --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DShapeMtx.h @@ -0,0 +1,156 @@ +#ifndef J3DSHAPEMTX_H +#define J3DSHAPEMTX_H + +#include "dolphin/mtx/mtxvec.h" + +class J3DTexMtx; +class J3DTexGenBlock; + +class J3DTexMtxObj { +public: + Mtx& getMtx(u16 idx) { return mpTexMtx[idx]; } + +private: + /* 0x00 */ Mtx *mpTexMtx; +}; + +class J3DDifferedTexMtx { +public: + /* 8031322C */ static void loadExecute(f32 const (*)[4]); + + static inline void load(Mtx m) { + if (sTexGenBlock != NULL) + loadExecute(m); + } + + static J3DTexGenBlock* sTexGenBlock; + static J3DTexMtxObj* sTexMtxObj; +}; + +extern u8 struct_804515B0; +extern u8 struct_804515B1; +extern u8 struct_804515B2; +extern u8 struct_804515B3; + +class J3DShapeMtx { +public: + J3DShapeMtx(u16 useMtxIndex) + : mUseMtxIndex(useMtxIndex) + {} + + /* 803130A8 */ void resetMtxLoadCache(); + /* 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; + /* 80273E08 */ virtual u32 getUseMtxNum() const; + /* 8031459C */ virtual u32 getUseMtxIndex(u16) const; + /* 80313B94 */ virtual void load() const; + /* 80313BF0 */ virtual void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]); + + static u8 sMtxLoadPipeline[48]; + static u16 sMtxLoadCache[10 + 2 /* padding */]; + static u32 sCurrentPipeline; + // static J3DScaleFlag sCurrentScaleFlag; + static u8* sCurrentScaleFlag; + static u32 sTexMtxLoadType; + + static void setCurrentPipeline(u32 pipeline) { sCurrentPipeline = pipeline; } + static void setLODFlag(u8 flag) { struct_804515B1 = flag; } + static u8 getLODFlag() { return struct_804515B1; } + static void resetMtxLoadCache(); + +private: + /* 0x04 */ u16 mUseMtxIndex; +}; + +class J3DShapeMtxConcatView : public J3DShapeMtx { +public: + J3DShapeMtxConcatView(u16 useMtxIndex) + : J3DShapeMtx(useMtxIndex) + {} + + /* 80314730 */ virtual ~J3DShapeMtxConcatView(); + /* 803147E0 */ virtual u32 getType() const; + /* 80313C54 */ virtual void load() const; + /* 80314598 */ virtual void loadNrmMtx(int, u16) const; + /* 80313D28 */ virtual void loadNrmMtx(int, u16, f32 (*)[4]) const; + + /* 80313828 */ void loadMtxConcatView_PNGP(int, u16) const; + /* 803138C8 */ void loadMtxConcatView_PCPU(int, u16) const; + /* 8031396C */ void loadMtxConcatView_NCPU(int, u16) const; + /* 80313A14 */ void loadMtxConcatView_PNCPU(int, u16) const; + /* 80313AC8 */ void loadMtxConcatView_PNGP_LOD(int, u16) const; + + static u8 sMtxLoadPipeline[48]; + static u8 sMtxLoadLODPipeline[48]; + static u8 sMtxPtrTbl[8]; +}; + +class J3DShapeMtxYBBoardConcatView : public J3DShapeMtxConcatView { +public: + J3DShapeMtxYBBoardConcatView(u16 useMtxIndex) + : J3DShapeMtxConcatView(useMtxIndex) + {} + + /* 80314520 */ virtual ~J3DShapeMtxYBBoardConcatView(); + /* 803147E0 */ virtual u32 getType() const; + /* 803143E4 */ virtual void load() const; +}; + +class J3DShapeMtxBBoardConcatView : public J3DShapeMtxConcatView { +public: + J3DShapeMtxBBoardConcatView(u16 useMtxIndex) + : J3DShapeMtxConcatView(useMtxIndex) + {} + + /* 803145A4 */ virtual ~J3DShapeMtxBBoardConcatView(); + /* 803147E0 */ virtual u32 getType() const; + /* 803142D4 */ virtual void load() const; +}; + +class J3DShapeMtxMulti : public J3DShapeMtx { +public: + J3DShapeMtxMulti(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable) + : J3DShapeMtx(useMtxIndex) + , mUseMtxNum(useMtxNum) + , mUseMtxIndexTable(useMtxIndexTable) + {} + + /* 803146B0 */ virtual ~J3DShapeMtxMulti(); + /* 803147E0 */ virtual u32 getType() const; + /* 80273E08 */ virtual u32 getUseMtxNum() const; + /* 8031459C */ virtual u32 getUseMtxIndex(u16) const; + /* 80313E4C */ virtual void load() const; + /* 80313EEC */ virtual void calcNBTScale(Vec const&, f32 (*)[3][3], f32 (*)[3][3]); + +private: + /* 0x6 */ u16 mUseMtxNum; + /* 0x8 */ u16* mUseMtxIndexTable; +}; + +class J3DShapeMtxMultiConcatView : public J3DShapeMtxConcatView { +public: + J3DShapeMtxMultiConcatView(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable) + : J3DShapeMtxConcatView(useMtxIndex) + , mUseMtxNum(useMtxNum) + , mUseMtxIndexTable(useMtxIndexTable) + {} + + /* 8031461C */ virtual ~J3DShapeMtxMultiConcatView(); + /* 803147E0 */ virtual u32 getType() const; + /* 80273E08 */ virtual u32 getUseMtxNum() const; + /* 8031459C */ virtual u32 getUseMtxIndex(u16) const; + /* 80313FA4 */ virtual void load() const; + /* 803146AC */ virtual void loadNrmMtx(int, u16) const; + /* 8031419C */ virtual void loadNrmMtx(int, u16, f32 (*)[4]) const; + +private: + /* 0x6 */ u16 mUseMtxNum; + /* 0x8 */ u16* mUseMtxIndexTable; +}; + +#endif /* J3DSHAPEMTX_H */ \ No newline at end of file diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h new file mode 100644 index 000000000..9063658da --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DStruct.h @@ -0,0 +1,87 @@ +#ifndef J3DSTRUCT_H +#define J3DSTRUCT_H + +#include "dolphin/gx/GXStruct.h" +#include "dolphin/mtx/mtx.h" +#include "dolphin/mtx/mtx44.h" +#include "dolphin/mtx/vec.h" + +class J3DLightInfo { +public: + /* 803256C4 */ void operator=(J3DLightInfo const&); + + /* 0x00 */ Vec mLightPosition; + /* 0x0C */ Vec mLightDirection; + /* 0x18 */ GXColor mColor; + /* 0x1C */ Vec mCosAtten; + /* 0x28 */ Vec mDistAtten; +}; // Size = 0x34 + +extern "C" extern J3DLightInfo const j3dDefaultLightInfo; + +class J3DLightObj { +public: + /* 80018C0C */ J3DLightObj() { mInfo = j3dDefaultLightInfo; } + /* 80323590 */ void load(u32) const; + + J3DLightInfo& getLightInfo() { return mInfo; } + J3DLightObj& operator=(J3DLightObj const& other) { + mInfo = other.mInfo; + return *this; + } + + /* 0x00 */ J3DLightInfo mInfo; + /* 0x34 */ u8 field_0x34[64]; +}; // Size = 0x74 + +struct J3DTextureSRTInfo { + /* 0x00 */ f32 mScaleX; + /* 0x04 */ f32 mScaleY; + /* 0x08 */ s16 mRotation; + /* 0x0C */ f32 mTranslationX; + /* 0x10 */ f32 mTranslationY; +}; // Size: 0x14 + +struct J3DTexMtxInfo { + /* 80325718 */ void operator=(J3DTexMtxInfo const&); + /* 80325794 */ void setEffectMtx(Mtx); + + /* 0x00 */ u8 mProjection; + /* 0x01 */ s8 mInfo; + /* 0x04 */ Vec mCenter; + /* 0x10 */ J3DTextureSRTInfo mSRT; + /* 0x24 */ Mtx44 mEffectMtx; +}; // Size: 0x64 + +struct J3DIndTexMtxInfo { + /* 803257DC */ void operator=(J3DIndTexMtxInfo const&); + + /* 0x00 */ Mtx23 field_0x0; + /* 0x18 */ u8 field_0x18; +}; // Size: 0x1C + +struct J3DFogInfo { + /* 80325800 */ void operator=(J3DFogInfo const&); + + /* 0x00 */ u8 field_0x0; + /* 0x01 */ u8 field_0x1; + /* 0x02 */ u16 field_0x2; + /* 0x04 */ f32 field_0x4; + /* 0x08 */ f32 field_0x8; + /* 0x0C */ f32 field_0xc; + /* 0x10 */ f32 field_0x10; + /* 0x14 */ u8 field_0x14; + /* 0x15 */ u8 field_0x15; + /* 0x16 */ u8 field_0x16; + /* 0x17 */ u8 field_0x17; + /* 0x18 */ u16 field_0x18[10]; +}; // Size: 0x2C + +struct J3DNBTScaleInfo { + /* 8032587C */ void operator=(J3DNBTScaleInfo const&); + + /* 0x0 */ u8 mbHasScale; + /* 0x4 */ Vec mScale; +}; // Size: 0x10 + +#endif /* J3DSTRUCT_H */ diff --git a/include/JSystem/J3DGraphBase/J3DSys.h b/include/JSystem/J3DGraphBase/J3DSys.h new file mode 100644 index 000000000..3bcf84f71 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DSys.h @@ -0,0 +1,140 @@ +#ifndef J3DSYS_H +#define J3DSYS_H + +#include "dolphin/gx/GX.h" +#include "dolphin/types.h" + +// Perhaps move to a new J3DEnum.h? +enum J3DError { + kJ3DError_Success = 0, + kJ3DError_Alloc = 4, +}; + +enum J3DSysDrawBuffer { + /* 0x0 */ OPA_BUFFER, + /* 0x1 */ XLU_BUFFER +}; + +class J3DMtxCalc; +class J3DModel; +class J3DMatPacket; +class J3DShapePacket; +class J3DShape; +class J3DDrawBuffer; +class J3DTexture; + +enum J3DSysFlag { + J3DSysFlag_SkinPosCpu = 0x00000004, + J3DSysFlag_SkinNrmCpu = 0x00000008, + J3DSysFlag_PostTexMtx = 0x40000000, +}; + +struct J3DSys { + /* 0x000 */ Mtx mViewMtx; + /* 0x030 */ J3DMtxCalc* mCurrentMtxCalc; + /* 0x034 */ u32 mFlags; + /* 0x038 */ J3DModel* mModel; + /* 0x03C */ J3DMatPacket* mMatPacket; + /* 0x040 */ J3DShapePacket* mShapePacket; + /* 0x044 */ J3DShape* mShape; + /* 0x048 */ J3DDrawBuffer* mDrawBuffer[2]; + /* 0x050 */ u32 mDrawMode; + /* 0x054 */ u32 mMaterialMode; + /* 0x058 */ J3DTexture* mTexture; + /* 0x05C */ u8 field_0x5c[0x04]; + /* 0x060 */ u32 mTexCacheRegionNum; + /* 0x064 */ GXTexRegion mTexCacheRegion[8]; + /* 0x0E4 */ u8 field_0xe4[0x20]; + /* 0x104 */ Mtx* mModelDrawMtx; + /* 0x108 */ Mtx33* mModelNrmMtx; + /* 0x10C */ void* mVtxPos; + /* 0x110 */ void* mVtxNrm; + /* 0x114 */ _GXColor* mVtxCol; + /* 0x118 */ Vec* mNBTScale; + + /* 8030FDE8 */ J3DSys(); + /* 8030FEC0 */ void loadPosMtxIndx(int, u16) const; + /* 8030FEE4 */ void loadNrmMtxIndx(int, u16) const; + /* 8030FF0C */ void setTexCacheRegion(_GXTexCacheSize); + /* 803100BC */ void drawInit(); + /* 8031073C */ void reinitGX(); + /* 8031079C */ void reinitGenMode(); + /* 803107E8 */ void reinitLighting(); + /* 80310894 */ void reinitTransform(); + /* 80310998 */ void reinitTexture(); + /* 80310A3C */ void reinitTevStages(); + /* 80310D44 */ void reinitIndStages(); + /* 80310E3C */ void reinitPixelProc(); + + enum DrawMode { + /* 0x3 */ OPA_TEX_EDGE = 3, + /* 0x4 */ XLU, + }; + + MtxP getViewMtx() { return mViewMtx; } + + void setDrawModeOpaTexEdge() { mDrawMode = OPA_TEX_EDGE; } + + void setDrawModeXlu() { mDrawMode = XLU; } + + void* getVtxPos() const { return mVtxPos; } + void setVtxPos(void* pVtxPos) { mVtxPos = pVtxPos; } + + void* getVtxNrm() const { return mVtxNrm; } + void setVtxNrm(void* pVtxNrm) { mVtxNrm = pVtxNrm; } + + void* getVtxCol() const { return mVtxCol; } + void setVtxCol(_GXColor* pVtxCol) { mVtxCol = pVtxCol; } + + void setModel(J3DModel* pModel) { mModel = pModel; } + void setShapePacket(J3DShapePacket* pPacket) { mShapePacket = pPacket; } + void setMatPacket(J3DMatPacket* pPacket) { mMatPacket = pPacket; } + J3DMatPacket* getMatPacket() { return mMatPacket; } + void setMaterialMode(u32 mode) { mMaterialMode = mode; } + + void setTexture(J3DTexture* pTex) { mTexture = pTex; } + J3DTexture* getTexture() { return mTexture; } + + void setNBTScale(Vec* scale) { mNBTScale = scale; } + + void onFlag(u32 flag) { mFlags |= flag; } + + void offFlag(u32 flag) { mFlags &= ~flag; } + + bool checkFlag(u32 flag) { return mFlags & flag; } + + void setModelDrawMtx(Mtx* pMtxArr) { + mModelDrawMtx = pMtxArr; + GXSetArray(GX_POS_MTX_ARRAY, mModelDrawMtx, sizeof(*mModelDrawMtx)); + } + + void setModelNrmMtx(Mtx33* 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) { mDrawBuffer[type] = buffer; } + + // Type 0: Opa Buffer + // Type 1: Xlu Buffer + J3DDrawBuffer* getDrawBuffer(int type) { return mDrawBuffer[type]; } + + Mtx& getModelDrawMtx(u16 no) const { return mModelDrawMtx[no]; } + J3DShapePacket* getShapePacket() const { return mShapePacket; } + + void setViewMtx(Mtx m) { MTXCopy(m, mViewMtx); } + + J3DModel* getModel() { return mModel; } + + static Mtx mCurrentMtx; + static Vec mCurrentS; + static Vec mParentS; + static u16 sTexCoordScaleTable[32]; +}; + +extern u32 j3dDefaultViewNo; +extern J3DSys j3dSys; + +#endif /* J3DSYS_H */ diff --git a/include/JSystem/J3DGraphBase/J3DTevs.h b/include/JSystem/J3DGraphBase/J3DTevs.h new file mode 100644 index 000000000..09081c527 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DTevs.h @@ -0,0 +1,72 @@ +#ifndef J3DTEVS_H +#define J3DTEVS_H + +#include "dolphin/types.h" + +struct J3DTevStageInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 mTevColorOp; + /* 0x2 */ u8 mTevColorAB; + /* 0x3 */ u8 mTevColorCD; + /* 0x4 */ u8 field_0x4; + /* 0x5 */ u8 mTevAlphaOp; + /* 0x6 */ u8 mTevAlphaAB; + /* 0x7 */ u8 mTevSwapModeInfo; +}; + +struct J3DTevStage : public J3DTevStageInfo { + /* 8000E230 */ J3DTevStage(); + /* 8000E298 */ void setTevStageInfo(J3DTevStageInfo const&); + /* 8003AACC */ J3DTevStage(J3DTevStageInfo const&); +}; + +struct J3DIndTevStageInfo { + /* 0x0 */ u8 mIndStage; + /* 0x1 */ u8 mIndFormat; + /* 0x2 */ u8 mBiasSel; + /* 0x3 */ u8 mMtxSel; + /* 0x4 */ u8 mWrapS; + /* 0x5 */ u8 mWrapT; + /* 0x6 */ u8 mPrev; + /* 0x7 */ u8 mLod; + /* 0x8 */ u8 mAlphaSel; +}; + +struct J3DIndTevStage { + /* 8000E14C */ J3DIndTevStage(); + + /* 0x0 */ u32 mInfo; +}; + +struct J3DTevOrderInfo { + void operator=(const J3DTevOrderInfo& other) { + *(u32*) this = *(u32*)&other; + } + + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 mTexMap; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; // Maybe padding +}; + +struct J3DTevOrder : public J3DTevOrderInfo { + /* 8000E140 */ J3DTevOrder(); + J3DTevOrder(const J3DTevOrderInfo& info) { + *(J3DTevOrderInfo*)this = info; + } + + u8 getTexMap() { return mTexMap; } +}; + +struct J3DTevSwapModeTable { + /* 8000E134 */ J3DTevSwapModeTable(); + + /* 0x0 */ u8 field_0x0; +}; // Size: 0x1 + +struct J3DTevSwapModeInfo {}; + +struct J3DNBTScale; +void loadNBTScale(J3DNBTScale& param_0); + +#endif /* J3DTEVS_H */ diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h new file mode 100644 index 000000000..8f646bbe9 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -0,0 +1,82 @@ +#ifndef J3DTEXTURE_H +#define J3DTEXTURE_H + +#include "JSystem/J3DGraphBase/J3DStruct.h" +#include "JSystem/JUtility/JUTTexture.h" +#include "dolphin/mtx/mtx.h" +#include "dolphin/types.h" + +class J3DTexture { +private: + /* 0x0 */ u16 mNum; + /* 0x4 */ ResTIMG* mpRes; + +public: + /* 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 { return &mpRes[entry]; } + 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))); + } +}; + +class J3DTexMtx { +public: + J3DTexMtx(const J3DTexMtxInfo& info) { + mTexMtxInfo = info; + } + /* 803238C4 */ void load(u32) const; + /* 80323900 */ void calc(f32 const (*)[4]); + /* 80323920 */ void calcTexMtx(f32 const (*)[4]); + /* 80323C0C */ void calcPostTexMtx(f32 const (*)[4]); + /* 80324358 */ void loadTexMtx(u32) const; + /* 803243BC */ void loadPostTexMtx(u32) const; + + J3DTexMtxInfo& getTexMtxInfo() { return mTexMtxInfo; } + Mtx& getMtx() { return mMtx; } + void setEffectMtx(Mtx effectMtx) { mTexMtxInfo.setEffectMtx(effectMtx); } + +private: + /* 0x00 */ J3DTexMtxInfo mTexMtxInfo; + /* 0x64 */ Mtx mMtx; +}; // Size: 0x94 + +struct J3DTexCoordInfo { + /* 0x0 */ u8 mTexGenType; + /* 0x1 */ u8 mTexGenSrc; + /* 0x2 */ u8 mTexGenMtx; + void operator=(J3DTexCoordInfo const& other) { + *(u32*) this = *(u32*)&other; + } +}; + +struct J3DTexCoord : public J3DTexCoordInfo { + /* 8000E464 */ J3DTexCoord(); + void setTexCoordInfo(J3DTexCoordInfo *param_1) { + *(J3DTexCoordInfo*)this = *param_1; + } + + u8 getTexGenMtx() { return mTexGenMtx & 0xff; } + u16 getTexMtxReg() { return mTexMtxReg & 0xff; } + + void resetTexMtxReg() { + mTexMtxReg = mTexGenMtx; + } + + /* 0x4 */ u16 mTexMtxReg; +}; // Size: 0x6 + +struct J3DDefaultTexCoordInfo { + /* 0x0 */ u8 mTexGenType; + /* 0x1 */ u8 mTexGenSrc; + /* 0x2 */ u8 mTexGenMtx; + /* 0x3 */ u8 pad; +}; + +#endif /* J3DTEXTURE_H */ diff --git a/include/JSystem/J3DGraphBase/J3DTransform.h b/include/JSystem/J3DGraphBase/J3DTransform.h new file mode 100644 index 000000000..327774c75 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DTransform.h @@ -0,0 +1,213 @@ +#ifndef J3DTRANSFORM_H +#define J3DTRANSFORM_H + +#include "JSystem/JGeometry.h" +#include "dolphin/mtx/mtxvec.h" + +struct J3DTransformInfo { + /* 0x00 */ JGeometry::TVec3 mScale; + /* 0x0C */ JGeometry::TVec3 mRotation; + /* 0x14 */ JGeometry::TVec3 mTranslate; +}; // Size: 0x20 + +extern J3DTransformInfo const j3dDefaultTransformInfo; +extern Vec const j3dDefaultScale; +extern Mtx const j3dDefaultMtx; +extern f32 PSMulUnit01[2]; + +void J3DGetTranslateRotateMtx(J3DTransformInfo const&, Mtx); +void J3DGetTranslateRotateMtx(s16, s16, s16, f32, f32, f32, Mtx); +void J3DPSCalcInverseTranspose(f32 (*param_0)[4], f32 (*param_1)[3]); +void J3DGQRSetup7(u32 param_0, u32 param_1, u32 param_2, u32 param_3); + +inline void J3DPSMtx33CopyFrom34(register MtxP src, register Mtx3P dst) { + register f32 x_y1; + register f32 z1; + register f32 x_y2; + register f32 z2; + register f32 x_y3; + register f32 z3; + asm { + psq_l x_y1, 0(src), 0, 0 + lfs z1, 8(src) + psq_l x_y2, 16(src), 0, 0 + lfs z2, 0x18(src) + psq_l x_y3, 32(src), 0, 0 + lfs z3, 0x28(src) + psq_st x_y1, 0(dst), 0, 0 + stfs z1, 8(dst) + psq_st x_y2, 12(dst), 0, 0 + stfs z2, 0x14(dst) + psq_st x_y3, 24(dst), 0, 0 + stfs z3, 0x20(dst) + } +} + +// regalloc issues +inline void J3DPSMulMtxVec(register MtxP mtx, register Vec* vec, register Vec* dst) { + register f32 fr12; + register f32 fr11; + register f32 fr10; + register f32 fr9; + register f32 fr8; + register f32 fr6; + register f32 fra6; + register f32 fr5; + register f32 fra5; + register f32 fra4; + register f32 fr4; + register f32 fr3; + register f32 fr2; + register f32 fra2; + register f32 fr01; + register f32 fr00; + asm { + psq_l fr00, 0(vec), 0, 0 + psq_l fr2, 0(mtx), 0, 0 + psq_l fr01, 8(vec), 1, 0 + ps_mul fr4, fr2, fr00 + psq_l fr3, 8(mtx), 0, 0 + ps_madd fr5, fr3, fr01, fr4 + psq_l fr8, 16(mtx), 0, 0 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr9, 24(mtx), 0, 0 + ps_mul fr10, fr8, fr00 + psq_st fr6, 0(dst), 1, 0 + ps_madd fr11, fr9, fr01, fr10 + psq_l fra2, 32(mtx), 0, 0 + ps_sum0 fr12, fr11, fr12, fr11 + psq_l fr3, 40(mtx), 0, 0 + ps_mul fra4, fra2, fr00 + psq_st fr12, 4(dst), 1, 0 + ps_madd fra5, fr3, fr01, fra4 + ps_sum0 fra6, fra5, fra6, fra5 + psq_st fra6, 8(dst), 1, 0 + } +} + +// regalloc issues +inline void J3DPSMulMtxVec(register MtxP mtx, register SVec* vec, register SVec* dst) { + register f32 fr12; + register f32 fr11; + register f32 fr10; + register f32 fr9; + register f32 fr8; + register f32 fr6; + register f32 fra6; + register f32 fr5; + register f32 fra5; + register f32 fra4; + register f32 fr4; + register f32 fr3; + register f32 fr2; + register f32 fra2; + register f32 fr01; + register f32 fr00; + asm { + psq_l fr00, 0(vec), 0, 7 + psq_l fr2, 0(mtx), 0, 0 + psq_l fr01, 4(vec), 1, 7 + ps_mul fr4, fr2, fr00 + psq_l fr3, 8(mtx), 0, 0 + ps_madd fr5, fr3, fr01, fr4 + psq_l fr8, 16(mtx), 0, 0 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr9, 24(mtx), 0, 0 + ps_mul fr10, fr8, fr00 + psq_st fr6, 0(dst), 1, 7 + ps_madd fr11, fr9, fr01, fr10 + psq_l fra2, 32(mtx), 0, 0 + ps_sum0 fr12, fr11, fr12, fr11 + psq_l fr3, 40(mtx), 0, 0 + ps_mul fra4, fra2, fr00 + psq_st fr12, 2(dst), 1, 7 + ps_madd fra5, fr3, fr01, fra4 + ps_sum0 fra6, fra5, fra6, fra5 + psq_st fra6, 4(dst), 1, 7 + } +} + +// regalloc issues +inline void J3DPSMulMtxVec(register Mtx3P mtx, register Vec* vec, register Vec* dst) { + register f32* punit; + register f32 unit; + register f32 fr12; + register f32 fr11; + register f32 fr10; + register f32 fr9; + register f32 fr8; + register f32 fr6; + register f32 fr5; + register f32 fr4; + register f32 fr3; + register f32 fr2; + register f32 fr01; + register f32 fr00; + asm { + lis punit, PSMulUnit01@ha + psq_l fr00, 0(vec), 0, 0 + addi punit, punit, PSMulUnit01@l + psq_l fr2, 0(mtx), 0, 0 + psq_l unit, 0(punit), 0, 0 + psq_l fr01, 8(vec), 1, 0 + ps_add fr01, unit, fr01 + psq_l fr3, 8(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_l fr8, 12(mtx), 0, 0 + ps_madd fr5, fr3, fr01, fr4 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr9, 20(mtx), 1, 0 + ps_mul fr10, fr8, fr00 + psq_st fr6, 0(dst), 1, 0 + ps_madd fr11, fr9, fr01, fr10 + psq_l fr2, 24(mtx), 0, 0 + ps_sum0 fr12, fr11, fr12, fr11 + psq_l fr3, 32(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_st fr12, 4(dst), 1, 0 + ps_madd fr5, fr3, fr01, fr4 + ps_sum0 fr6, fr5, fr6, fr5 + psq_st fr6, 8(dst), 1, 0 + } +} + +// regalloc issues +inline void J3DPSMulMtxVec(register Mtx3P mtx, register SVec* vec, register SVec* dst) { + register f32* punit; + register f32 unit; + register f32 fr6; + register f32 fr5; + register f32 fr4; + register f32 fr3; + register f32 fr2; + register f32 fr01; + register f32 fr00; + asm { + lis punit, PSMulUnit01@ha + psq_l fr00, 0(vec), 0, 7 + addi punit, punit, PSMulUnit01@l + psq_l fr2, 0(mtx), 0, 0 + psq_l unit, 0(punit), 0, 0 + psq_l fr01, 4(vec), 1, 7 + ps_add fr01, unit, fr01 + psq_l fr3, 8(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_l fr2, 12(mtx), 0, 0 + ps_madd fr5, fr3, fr01, fr4 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr3, 20(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_st fr6, 0(dst), 1, 7 + ps_madd fr5, fr3, fr01, fr4 + psq_l fr2, 24(mtx), 0, 0 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr3, 32(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_st fr6, 2(dst), 1, 7 + ps_madd fr5, fr3, fr01, fr4 + ps_sum0 fr6, fr5, fr6, fr5 + psq_st fr6, 4(dst), 1, 7 + } +} + +#endif /* J3DTRANSFORM_H */ diff --git a/include/JSystem/J3DGraphBase/J3DVertex.h b/include/JSystem/J3DGraphBase/J3DVertex.h new file mode 100644 index 000000000..0b184b0f0 --- /dev/null +++ b/include/JSystem/J3DGraphBase/J3DVertex.h @@ -0,0 +1,122 @@ +#ifndef J3DVERTEX_H +#define J3DVERTEX_H + +#include "dolphin/gx/GXAttr.h" +#include "dolphin/mtx/vec.h" +#include "dolphin/types.h" + +typedef struct _GXColor GXColor; +class J3DModel; +class J3DAnmVtxColor; +class J3DVertexBuffer; + +struct J3DVtxColorCalc { + /* 8032E180 */ void calc(J3DModel*); + virtual void calc(J3DVertexBuffer*); + + /* 0x0 */ void* vtable; // inlined vtable? + /* 0x4 */ u32 mFlags; + /* 0x8 */ J3DAnmVtxColor* mpVtxColor; +}; + +class J3DVertexData { +public: + J3DVertexData(); + + void* getVtxPosArray() const { return mVtxPosArray; } + void* getVtxNrmArray() const { return mVtxNrmArray; } + GXColor* getVtxColorArray(u8 idx) const { return mVtxColorArray[idx]; } + void* getVtxTexCoordArray(u8 idx) const { return mVtxTexCoordArray[idx]; } + void* getVtxNBTArray() const { return mVtxNBTArray; } + u32 getNrmNum() const { return mNrmNum; } + u32 getVtxNum() const { return mVtxNum; } + GXVtxAttrFmtList* getVtxAttrFmtList() { return mVtxAttrFmtList; } + u8 getVtxPosFrac() { return mVtxPosFrac; } + u8 getVtxNrmFrac() { return mVtxNrmFrac; } + int getVtxPosType() { return mVtxPosType; } + int getVtxNrmType() { return mVtxNrmType; } + + void setVtxPosFrac(u8 frac) { mVtxPosFrac = frac; } + void setVtxPosType(GXCompType type) { mVtxPosType = type; } + void setVtxNrmFrac(u8 frac) { mVtxNrmFrac = frac; } + void setVtxNrmType(GXCompType type) { mVtxNrmType = type; } + +private: + /* 0x00 */ u32 mVtxNum; + /* 0x04 */ u32 mNrmNum; + /* 0x08 */ u32 mColNum; + /* 0x0C */ u32 mTexCoordNum; + /* 0x10 */ u32 mPacketNum; + /* 0x14 */ GXVtxAttrFmtList* mVtxAttrFmtList; + /* 0x18 */ void* mVtxPosArray; + /* 0x1C */ void* mVtxNrmArray; + /* 0x20 */ void* mVtxNBTArray; + /* 0x24 */ GXColor* mVtxColorArray[2]; + /* 0x2C */ void* mVtxTexCoordArray[8]; + /* 0x4C */ u8 mVtxPosFrac; + /* 0x50 */ GXCompType mVtxPosType; + /* 0x54 */ u8 mVtxNrmFrac; + /* 0x58 */ GXCompType mVtxNrmType; +}; + +class J3DVertexBuffer { +public: + J3DVertexBuffer() { init(); } + + /* 80310F78 */ void setVertexData(J3DVertexData*); + /* 80310FD8 */ void init(); + /* 80311030 */ ~J3DVertexBuffer(); + /* 8031106C */ void setArray() const; + /* 80311090 */ s32 copyLocalVtxPosArray(u32); + /* 803111B0 */ s32 copyLocalVtxNrmArray(u32); + /* 803112D0 */ s32 copyLocalVtxArray(u32); + /* 80311478 */ s32 allocTransformedVtxPosArray(); + /* 8031152C */ s32 allocTransformedVtxNrmArray(); + + void setCurrentVtxPos(void* pVtxPos) { mCurrentVtxPos = pVtxPos; } + void* getCurrentVtxPos() { return mCurrentVtxPos; } + + void setCurrentVtxNrm(void* pVtxNrm) { mCurrentVtxNrm = pVtxNrm; } + void* getCurrentVtxNrm() { return mCurrentVtxNrm; } + + void setCurrentVtxCol(GXColor* pVtxCol) { mCurrentVtxCol = pVtxCol; } + + void frameInit() { + setCurrentVtxPos(mVtxPosArray[0]); + setCurrentVtxNrm(mVtxNrmArray[0]); + setCurrentVtxCol(mVtxColArray[0]); + } + + void* getTransformedVtxPos(int idx) { return mTransformedVtxPosArray[idx]; } + void* getTransformedVtxNrm(int idx) { return mTransformedVtxNrmArray[idx]; } + J3DVertexData* getVertexData() { return mVtxData; } + + void swapTransformedVtxPos() { + void* tmp = mTransformedVtxPosArray[0]; + mTransformedVtxPosArray[0] = mTransformedVtxPosArray[1]; + mTransformedVtxPosArray[1] = tmp; + } + + void swapTransformedVtxNrm() { + void* tmp = mTransformedVtxNrmArray[0]; + mTransformedVtxNrmArray[0] = mTransformedVtxNrmArray[1]; + mTransformedVtxNrmArray[1] = tmp; + } + +private: + /* 0x00 */ J3DVertexData* mVtxData; + /* 0x04 */ void* mVtxPosArray[2]; + /* 0x0C */ void* mVtxNrmArray[2]; + /* 0x14 */ GXColor* mVtxColArray[2]; + /* 0x1C */ void* mTransformedVtxPosArray[2]; + /* 0x24 */ void* mTransformedVtxNrmArray[2]; + /* 0x2C */ void* mCurrentVtxPos; + /* 0x30 */ void* mCurrentVtxNrm; + /* 0x34 */ GXColor* mCurrentVtxCol; +}; // Size: 0x38 + +struct VertexNormal { + Vec data; +}; + +#endif /* J3DVERTEX_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DAnmLoader.h b/include/JSystem/J3DGraphLoader/J3DAnmLoader.h new file mode 100644 index 000000000..937866341 --- /dev/null +++ b/include/JSystem/J3DGraphLoader/J3DAnmLoader.h @@ -0,0 +1,17 @@ +#ifndef J3DANMLOADER_H +#define J3DANMLOADER_H + +#include "dolphin/types.h" + +enum J3DAnmLoaderDataBaseFlag { J3DLOADER_UNK_FLAG0 }; + +class J3DAnmBase; + +struct J3DAnmLoaderDataBase { + /* 80337B40 */ static void* load(void const*, J3DAnmLoaderDataBaseFlag); + /* 80338134 */ static void setResource(J3DAnmBase*, void const*); + + static void* load(void const* param_0) { return load(param_0, J3DLOADER_UNK_FLAG0); } +}; + +#endif /* J3DANMLOADER_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DClusterLoader.h b/include/JSystem/J3DGraphLoader/J3DClusterLoader.h new file mode 100644 index 000000000..35a79ddbb --- /dev/null +++ b/include/JSystem/J3DGraphLoader/J3DClusterLoader.h @@ -0,0 +1,9 @@ +#ifndef J3DCLUSTERLOADER_H +#define J3DCLUSTERLOADER_H + + +struct J3DClusterLoaderDataBase { + /* 80334130 */ static void* load(void const*); +}; + +#endif /* J3DCLUSTERLOADER_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DJointFactory.h b/include/JSystem/J3DGraphLoader/J3DJointFactory.h new file mode 100644 index 000000000..2c7653b26 --- /dev/null +++ b/include/JSystem/J3DGraphLoader/J3DJointFactory.h @@ -0,0 +1,48 @@ +#ifndef J3DJOINTFACTORY_H +#define J3DJOINTFACTORY_H + +#include "JSystem/J3DGraphBase/J3DTransform.h" +#include "dolphin/types.h" + +class J3DJoint; +struct ResNTAB; + +struct J3DJointInitData { + /* 0x00 */ u16 mKind; + /* 0x02 */ bool mScaleCompensate; + /* 0x04 */ J3DTransformInfo mTransformInfo; + /* 0x24 */ f32 mRadius; + /* 0x28 */ Vec mMin; + /* 0x2C */ Vec mMax; +}; // Size: 0x30 + +struct J3DJointBlock { + /* 0x00 */ u8 mMagic[4]; + /* 0x04 */ u32 mSize; + + /* 0x08 */ u16 mJointNum; + /* 0x0A */ u16 _pad; + + /* 0x0C */ J3DJointInitData* mJointInitData; + /* 0x10 */ u16* mIndexTable; + /* 0x14 */ ResNTAB* mNameTable; +}; + +struct J3DJointFactory { + /* 80337178 */ J3DJointFactory(J3DJointBlock const&); + /* 803371D0 */ J3DJoint* create(int); + + J3DJointInitData* mJointInitData; + u16* mIndexTable; + + u16 getKind(int no) const { return mJointInitData[mIndexTable[no]].mKind; } + u8 getScaleCompensate(int no) const { return mJointInitData[mIndexTable[no]].mScaleCompensate; } + const J3DTransformInfo& getTransformInfo(int no) const { + return mJointInitData[mIndexTable[no]].mTransformInfo; + } + f32 getRadius(int no) const { return mJointInitData[mIndexTable[no]].mRadius; } + Vec& getMin(int no) const { return mJointInitData[mIndexTable[no]].mMin; } + Vec& getMax(int no) const { return mJointInitData[mIndexTable[no]].mMax; } +}; + +#endif /* J3DJOINTFACTORY_H */ \ No newline at end of file diff --git a/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h b/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h new file mode 100644 index 000000000..50785d4c1 --- /dev/null +++ b/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h @@ -0,0 +1,6 @@ +#ifndef J3DMATERIALFACTORY_H +#define J3DMATERIALFACTORY_H + +#include "dolphin/types.h" + +#endif /* J3DMATERIALFACTORY_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h b/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h new file mode 100644 index 000000000..41e88bdec --- /dev/null +++ b/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h @@ -0,0 +1,6 @@ +#ifndef J3DMATERIALFACTORY_V21_H +#define J3DMATERIALFACTORY_V21_H + +#include "dolphin/types.h" + +#endif /* J3DMATERIALFACTORY_V21_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DModelLoader.h b/include/JSystem/J3DGraphLoader/J3DModelLoader.h new file mode 100644 index 000000000..deff8ed97 --- /dev/null +++ b/include/JSystem/J3DGraphLoader/J3DModelLoader.h @@ -0,0 +1,11 @@ +#ifndef J3DMODELLOADER_H +#define J3DMODELLOADER_H + +#include "dolphin/types.h" + +class J3DModelLoaderDataBase { +public: + /* 803346BC */ static void* load(void const*, u32); +}; + +#endif /* J3DMODELLOADER_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DModelLoaderCalcSize.h b/include/JSystem/J3DGraphLoader/J3DModelLoaderCalcSize.h new file mode 100644 index 000000000..5b231aeb1 --- /dev/null +++ b/include/JSystem/J3DGraphLoader/J3DModelLoaderCalcSize.h @@ -0,0 +1,6 @@ +#ifndef J3DMODELLOADERCALCSIZE_H +#define J3DMODELLOADERCALCSIZE_H + +#include "dolphin/types.h" + +#endif /* J3DMODELLOADERCALCSIZE_H */ diff --git a/include/JSystem/J3DGraphLoader/J3DShapeFactory.h b/include/JSystem/J3DGraphLoader/J3DShapeFactory.h new file mode 100644 index 000000000..63df90923 --- /dev/null +++ b/include/JSystem/J3DGraphLoader/J3DShapeFactory.h @@ -0,0 +1,78 @@ +#ifndef J3DSHAPEFACTORY_H +#define J3DSHAPEFACTORY_H + +#include "dolphin/gx/GXAttr.h" +#include "dolphin/mtx/vec.h" + +class J3DShape; +class J3DShapeMtx; +class J3DShapeDraw; +struct ResNTAB; + +struct J3DShapeInitData { + /* 0x00 */ u8 mShapeMtxType; + /* 0x02 */ u16 mMtxGroupNum; + /* 0x04 */ u16 mVtxDescListIndex; + /* 0x06 */ u16 mMtxInitDataIndex; + /* 0x08 */ u16 mDrawInitDataIndex; + /* 0x0C */ f32 mRadius; + /* 0x10 */ Vec mMin; + /* 0x1C */ Vec mMax; +}; + +struct J3DShapeMtxInitData { + /* 0x00 */ u16 mUseMtxIndex; + /* 0x02 */ u16 mUseMtxCount; + /* 0x04 */ u32 mFirstUseMtxIndex; +}; + +struct J3DShapeDrawInitData { + /* 0x00 */ u32 mDisplayListSize; + /* 0x04 */ u32 mDisplayListIndex; +}; + +struct J3DShapeBlock { + /* 0x00 */ u8 mMagic[4]; + /* 0x04 */ u32 mSize; + + /* 0x08 */ u16 mShapeNum; + /* 0x0A */ u16 _pad; + + /* 0x0C */ J3DShapeInitData* mShapeInitData; + /* 0x10 */ u16* mIndexTable; + /* 0x14 */ ResNTAB* mNameTable; + /* 0x18 */ GXVtxDescList* mVtxDescList; + /* 0x1C */ u16* mMtxTable; + /* 0x20 */ u8* mDisplayListData; + /* 0x24 */ J3DShapeMtxInitData* mMtxInitData; + /* 0x28 */ J3DShapeDrawInitData* mDrawInitData; +}; + +struct J3DShapeFactory { + /* 80337350 */ J3DShapeFactory(J3DShapeBlock const&); + /* 80337400 */ J3DShape* create(int, u32, GXVtxDescList*); + /* 803375BC */ J3DShapeMtx* newShapeMtx(u32, int, int) const; + /* 8033784C */ J3DShapeDraw* newShapeDraw(int, int) const; + /* 803378D8 */ void allocVcdVatCmdBuffer(u32); + /* 80337944 */ s32 calcSize(int, u32); + /* 803379D8 */ s32 calcSizeVcdVatCmdBuffer(u32); + /* 803379E8 */ s32 calcSizeShapeMtx(u32, int, int) const; + + /* 0x00 */ J3DShapeInitData* mShapeInitData; + /* 0x04 */ u16* mIndexTable; + /* 0x08 */ GXVtxDescList* mVtxDescList; + /* 0x0C */ u16* mMtxTable; + /* 0x10 */ u8* mDisplayListData; + /* 0x14 */ J3DShapeMtxInitData* mMtxInitData; + /* 0x18 */ J3DShapeDrawInitData* mDrawInitData; + /* 0x1C */ u8* mVcdVatCmdBuffer; + + u32 getMtxGroupNum(int no) const { return mShapeInitData[mIndexTable[no]].mMtxGroupNum; } + GXVtxDescList* getVtxDescList(int no) const { return (GXVtxDescList*)((u8*)mVtxDescList + mShapeInitData[mIndexTable[no]].mVtxDescListIndex); } + f32 getRadius(int no) const { return mShapeInitData[mIndexTable[no]].mRadius; } + Vec& getMin(int no) const { return mShapeInitData[mIndexTable[no]].mMin; } + Vec& getMax(int no) const { return mShapeInitData[mIndexTable[no]].mMax; } +}; + + +#endif /* J3DSHAPEFACTORY_H */ \ No newline at end of file diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h new file mode 100644 index 000000000..ac4857ec3 --- /dev/null +++ b/include/JSystem/JGeometry.h @@ -0,0 +1,417 @@ +#ifndef JGEOMETRY_H +#define JGEOMETRY_H + +#include "dolphin/mtx/vec.h" +#include "MSL_C/float.h" +#include "MSL_C/math.h" + +namespace JGeometry { + +template +struct TVec3 { + T x; + T y; + T z; + + void set(const TVec3& other) { + x = other.x; + y = other.y; + z = other.z; + } +}; + +template <> +struct TVec3 { + s16 x, y, z; + + TVec3& operator=(const TVec3& b) { + // Force copies to use lwz/lha + *((s32*)this) = *((s32*)&b); + z = b.z; + return *this; + } + + void set(s16 x_, s16 y_, s16 z_) { + x = x_; + y = y_; + z = z_; + } +}; + +inline void setTVec3f(const f32* vec_a, f32* vec_b) { + const register f32* v_a = vec_a; + register f32* v_b = vec_b; + + register f32 a_x; + register f32 b_x; + + asm { + psq_l a_x, 0(v_a), 0, 0 + lfs b_x, 8(v_a) + psq_st a_x, 0(v_b), 0, 0 + stfs b_x, 8(v_b) + }; +} + +// Until we figure out TVec3 ctors +inline void setTVec3f(const Vec& vec_a, Vec& vec_b) { + setTVec3f(&vec_a.x, &vec_b.x); +} + +inline float fsqrt_step(float mag) { + f32 root = __frsqrte(mag); + return 0.5f * root * (3.0f - mag * (root * root)); +} + +template <> +struct TVec3 { + f32 x; + f32 y; + f32 z; + + // inline TVec3(const Vec& i_vec) { + // setTVec3f(&i_vec.x, &x); + // } + + // inline TVec3(const TVec3& i_vec) { + // setTVec3f(&i_vec.x, &x); + // } + + // TVec3() {} + + operator Vec*() { return (Vec*)&x; } + operator const Vec*() const { return (Vec*)&x; } + + void set(const TVec3& other) { + x = other.x; + y = other.y; + z = other.z; + } + + void set(f32 x_, f32 y_, f32 z_) { + x = x_; + y = y_; + z = z_; + } + + inline void add(const TVec3& b) { + C_VECAdd((Vec*)&x, (Vec*)&b.x, (Vec*)&x); + } + + void zero() { x = y = z = 0.0f; } + + void mul(const TVec3& a, const TVec3& b) { + register f32* dst = &x; + const register f32* srca = &a.x; + const register f32* srcb = &b.x; + register f32 a_x_y; + register f32 b_x_y; + register f32 x_y; + register f32 za; + register f32 zb; + register f32 z; + asm { + psq_l a_x_y, 0(srca), 0, 0 + psq_l b_x_y, 0(srcb), 0, 0 + ps_mul x_y, a_x_y, b_x_y + psq_st x_y, 0(dst), 0, 0 + lfs za, 8(srca) + lfs zb, 8(srcb) + fmuls z, za, zb + stfs z, 8(dst) + }; + } + + inline TVec3& operator+=(const TVec3& b) { + add(b); + return *this; + } + + // inline TVec3 operator+(const TVec3& b) { + // TVec3 res(*(Vec*)this); + // res += b; + // return res; + // } + + inline TVec3& operator=(const TVec3& b) { + register f32* dst = &x; + const register f32* src = &b.x; + register f32 x_y; + register f32 z; + asm { + psq_l x_y, 0(src), 0, 0 + psq_st x_y, 0(dst), 0, 0 + lfs z, 8(src) + stfs z, 8(dst) + }; + return *this; + } + + f32 squared() const { + return C_VECSquareMag((Vec*)&x); + } + + void normalize() { + f32 sq = squared(); + if (sq <= FLT_EPSILON * 32.0f) { + return; + } + f32 norm; + if (sq <= 0.0f) { + norm = sq; + } else { + norm = fsqrt_step(sq); + } + scale(norm); + } + + void normalize(const TVec3& other) { + f32 sq = other.squared(); + if (sq <= FLT_EPSILON * 32.0f) { + zero(); + return; + } + f32 norm; + if (sq <= 0.0f) { + norm = sq; + } else { + norm = fsqrt_step(sq); + } + scale(norm, other); + } + + f32 length() const { + return VECMag((Vec*)this); + } + + void scale(register f32 sc) { + register f32 z; + register f32 x_y; + register f32* dst = &x; + register f32 zres; + asm { + psq_l x_y, 0(dst), 0, 0 + psq_l z, 8(dst), 1, 0 + ps_muls0 x_y, x_y, sc + psq_st x_y, 0(dst), 0, 0 + ps_muls0 zres, z, sc + psq_st zres, 8(dst), 1, 0 + }; + } + + void scale(register f32 sc, const TVec3& other) { + register const f32* src = &other.x; + register f32 z; + register f32 x_y; + register f32* dst = &x; + register f32 zres; + asm { + psq_l x_y, 0(src), 0, 0 + psq_l z, 8(src), 1, 0 + ps_muls0 x_y, x_y, sc + psq_st x_y, 0(dst), 0, 0 + ps_muls0 zres, z, sc + psq_st zres, 8(dst), 1, 0 + }; + } + + void negateInternal(TVec3* dst) { + register f32* rdst = &dst->x; + const register f32* src = &x; + register f32 x_y; + register f32 z; + asm { + psq_l x_y, 0(src), 0, 0 + ps_neg x_y, x_y + psq_st x_y, 0(rdst), 0, 0 + lfs z, 8(src) + fneg z, z + stfs z, 8(rdst) + }; + } + + void negate() { + negateInternal(this); + } + + void sub(const TVec3& b) { + C_VECSubtract((Vec*)&x, (Vec*)&b.x, (Vec*)&x); + } + + void sub(const TVec3& a, const TVec3& b) { + C_VECSubtract((Vec*)&a.x, (Vec*)&b.x, (Vec*)&x); + } + + bool isZero() const { + return squared() <= 32.0f * FLT_EPSILON; + } + + void cross(const TVec3& a, const TVec3& b) { + VECCrossProduct(a, b, *this); + } + + void setLength(f32 len) { + f32 sq = squared(); + if (sq <= FLT_EPSILON * 32.0f) { + return; + } + f32 norm; + if (sq <= 0.0f) { + norm = sq; + } else { + norm = fsqrt_step(sq); + } + scale(norm * len); + } + + f32 dot(const TVec3& other) const { + register const f32* pThis = &x; + register const f32* pOther = &other.x; + register f32 otherReg; + register f32 thisyz; + register f32 res; + register f32 thisxy; + asm { + psq_l thisyz, 4(pThis), 0, 0 + psq_l otherReg, 4(pOther), 0, 0 + ps_mul thisyz, thisyz, otherReg + psq_l thisxy, 0(pThis), 0, 0 + psq_l otherReg, 0(pOther), 0, 0 + ps_madd res, thisxy, otherReg, thisyz + ps_sum0 res, res, thisyz, thisyz + }; + return res; + } +}; + +template +struct TVec2 { + TVec2() {} + TVec2(T x, T y) { set(x, y); } + + void set(T x, T y) { + this->x = x; + this->y = y; + } + + void set(const TVec2& other) { + x = other.x; + y = other.y; + } + + void setMin(const TVec2& min) { + if (x >= min.x) + x = min.x; + if (y >= min.y) + y = min.y; + } + + void setMax(const TVec2& max) { + if (x <= max.x) + x = max.x; + if (y <= max.y) + y = max.y; + } + + void add(const TVec2& other) { + x += other.x; + y += other.y; + } + + bool isAbove(const TVec2& other) const { + return (x >= other.x) && (y >= other.y) ? true : false; + } + + f32 dot(const TVec2& other) { + return x * other.x + y * other.y; + } + + f32 squared() { + return dot(*this); + } + + f32 length() { + f32 sqr = squared(); + if (sqr <= 0.0f) { + return sqr; + } + sqr *= fsqrt_step(sqr); + return sqr; + } + + T x; + T y; +}; + +template +struct TBox { + TBox() : i(), f() {} + TBox(const TBox& other) : i(other.f), f(other.y) {} + + T i, f; +}; + +// clang-format off +template<> struct TBox > { + f32 getWidth() const { return f.x - i.x; } + f32 getHeight() const { return f.y - i.y; } + + bool isValid() const { return f.isAbove(i); } + + void addPos(f32 x, f32 y) { + addPos(TVec2(x, y)); + } + + void addPos(const TVec2& pos) { + i.add(pos); + f.add(pos); + } + + bool intersect(const TBox >& other) { + i.setMax(other.i); + f.setMin(other.f); + return isValid(); + } + + TVec2 i, f; +}; + +template +struct TBox2 : TBox > { + TBox2() {} + TBox2(const TVec2& i, const TVec2 f) { set(i, f); } + TBox2(f32 x0, f32 y0, f32 x1, f32 y1) { set(x0, y0, x1, y1); } + + void absolute() { + if (!this->isValid()) { + TBox2 box(*this); + this->i.setMin(box.i); + this->i.setMin(box.f); + this->f.setMax(box.i); + this->f.setMax(box.f); + } + } + + void set(const TBox2& other) { set(other.i, other.f); } + void set(const TVec2& i, const TVec2& f) { this->i.set(i), this->f.set(f); } + void set(f32 x0, f32 y0, f32 x1, f32 y1) { i.set(x0, y0); f.set(x1, y1); } +}; + +template +struct TUtil { + static inline T clamp(T v, T min, T max) { + if (v < min) { + return min; + } + if (v > max) { + return max; + } + return v; + } +}; + +// clang-format on + +} // namespace JGeometry + +#endif diff --git a/include/JSystem/TPosition3.hh b/include/JSystem/TPosition3.hh new file mode 100644 index 000000000..3ff7bb5b2 --- /dev/null +++ b/include/JSystem/TPosition3.hh @@ -0,0 +1,40 @@ +#ifndef TPOSITION3_H +#define TPOSITION3_H + +#include "dolphin/mtx/mtx.h" +#include "JSystem/JMath/JMath.h" + +namespace JGeometry { + +template +struct SMatrix34C { + T data[3][4]; +}; + +template <> +struct SMatrix34C { + f32 data[3][4]; + + void identity() { MTXIdentity(data); } + + typedef f32 ArrType[4]; + void set(const ArrType* src) { JMath::gekko_ps_copy12((f32*)data, (f32*)src); } + + operator ArrType*() { return data; } + operator const ArrType*() const { return data; } +}; + +template +struct TMatrix34 : public T {}; + +template +struct TRotation3 : public T {}; + +template +struct TPosition3 : public T {}; + +typedef TPosition3 > > > TPosition3f32; + +} // namespace JGeometry + +#endif \ No newline at end of file diff --git a/include/d/d_a_obj.h b/include/d/d_a_obj.h new file mode 100644 index 000000000..e1278c9ee --- /dev/null +++ b/include/d/d_a_obj.h @@ -0,0 +1,14 @@ +#ifndef D_A_OBJ +#define D_A_OBJ + +#include "f_op/f_op_actor_mng.h" + +class daObj { +public: + template + static int PrmAbstract(const fopAc_ac_c* actor, T width, T shift) { + return ((1 << width) - 1) & (fopAcM_GetParam(actor) >> shift); + } +}; + +#endif /* D_A_OBJ */ diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 8ee0db3a9..ad78e6a36 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -306,7 +306,7 @@ class dComIfG_inf_c { /* 0x012A0 */ dComIfG_play_c play; /* 0x05D1C */ dDlst_list_c drawlist; /* 0x1BF50 */ u8 field_0x1BF50[0x1BFC0 - 0x1BF50]; - /* 0x1BFC0 */ dRes_control_c res_control; + /* 0x1BFC0 */ dRes_control_c mResControl; /* 0x1D1C0 */ u8 field_0x1d1c0; /* 0x1D1C1 */ u8 field_0x1d1c1; }; @@ -329,8 +329,36 @@ inline void dComIfGs_setEventReg(u16 i_reg, u8 i_no) { g_dComIfG_gameInfo.info.getEvent().setEventReg(i_reg, i_no); } +inline BOOL dComIfGs_isEventBit(u16 id) { + return g_dComIfG_gameInfo.info.getEvent().isEventBit(id); +} + /** * === PLAY === */ +/** + * === RESOURCE === + */ + +int dComIfG_resLoad(request_of_phase_process_class* i_phase, char const* arc_name); +int dComIfG_resLoad(request_of_phase_process_class* i_phase, char const* resName, JKRHeap* heap); +int dComIfG_resDelete(request_of_phase_process_class* i_phase, char const* resName); + +inline int dComIfG_deleteStageRes(const char* res) { + return g_dComIfG_gameInfo.mResControl.deleteStageRes(res); +} + +inline void* dComIfG_getStageRes(const char* arcName, const char* resName) { + return g_dComIfG_gameInfo.mResControl.getStageRes(arcName, resName); +} + +inline void* dComIfG_getObjectRes(const char* arcName, const char* resName) { + return g_dComIfG_gameInfo.mResControl.getObjectRes(arcName, resName); +} + +inline void* dComIfG_getObjectRes(const char* arcName, int param_1) { + return g_dComIfG_gameInfo.mResControl.getObjectRes(arcName, param_1); +} + #endif /* D_COM_D_COM_INF_GAME_H */ diff --git a/include/d/d_kankyo.h b/include/d/d_kankyo.h index 0ab43bba4..b1e23c771 100644 --- a/include/d/d_kankyo.h +++ b/include/d/d_kankyo.h @@ -10,6 +10,8 @@ struct J3DLightObj { u8 temp[0x74]; }; +class J3DModel; + class dKy_tevstr_c { public: /* 0x00 */ J3DLightObj mLightObj; @@ -34,4 +36,34 @@ class dKy_tevstr_c { STATIC_ASSERT(sizeof(dKy_tevstr_c) == 0xB0); -#endif /* D_KANKYO_D_KANKYO_H */ \ No newline at end of file +enum TevType { + TEV_TYPE_ACTOR, + TEV_TYPE_BG0, + TEV_TYPE_BG1, + TEV_TYPE_BG2, + TEV_TYPE_BG3, + TEV_TYPE_BG0_FULL, + TEV_TYPE_BG1_FULL, + TEV_TYPE_BG2_FULL, + TEV_TYPE_BG3_FULL, + TEV_TYPE_PLAYER, + TEV_TYPE_BG0_PLIGHT, + TEV_TYPE_BG1_PLIGHT, + TEV_TYPE_BG2_PLIGHT, + TEV_TYPE_ACTOR_NOLIGHT, +}; + +struct dScnKy_env_light_c { +public: + void settingTevStruct(int, cXyz*, dKy_tevstr_c*); + void setLightTevColorType(J3DModel*, dKy_tevstr_c*); + +public: + u8 pad[0xC9C]; +}; // Size = 0xC9C + +extern dScnKy_env_light_c g_env_light; + + + +#endif /* D_KANKYO_D_KANKYO_H */ diff --git a/include/d/d_save.h b/include/d/d_save.h index 903e32cd7..08625f17e 100644 --- a/include/d/d_save.h +++ b/include/d/d_save.h @@ -838,4 +838,8 @@ class dSv_info_c { STATIC_ASSERT(sizeof(dSv_info_c) == 0x12A0); +enum dSv_eventBit_e { + EV_BIT_TALKED_TO_IRCH_IN_FOREST_HAVEN = 0x3802, +}; + #endif /* D_SAVE_D_SAVE_H */ diff --git a/include/dolphin/gd/GDBase.h b/include/dolphin/gd/GDBase.h new file mode 100644 index 000000000..712b92f24 --- /dev/null +++ b/include/dolphin/gd/GDBase.h @@ -0,0 +1,41 @@ +#ifndef GDBASE_H +#define GDBASE_H + +#include "dolphin/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct GDLObj { + /* 0x0 */ u8* start; + /* 0x4 */ u32 length; + /* 0x8 */ u8* ptr; + /* 0xC */ u8* end; +} GDLObj; // Size: 0x10 + +extern GDLObj* __GDCurrentDL; + +inline void GDSetCurrent(GDLObj* obj) { + __GDCurrentDL = obj; +} + +inline void __GDWrite(u8 data) { + *__GDCurrentDL->ptr++ = data; +} + +inline u32 GDGetGDLObjOffset(GDLObj* obj) { + return (u32)(obj->ptr - obj->start); +} + +void GDInitGDLObj(GDLObj*, u8*, u32); +void GDFlushCurrToMem(); +void GDPadCurr32(); + +typedef void (*GDOverflowCallback)(void); + +#ifdef __cplusplus +}; +#endif + +#endif /* GDBASE_H */ diff --git a/include/dolphin/gd/GDGeometry.h b/include/dolphin/gd/GDGeometry.h new file mode 100644 index 000000000..4df5072e2 --- /dev/null +++ b/include/dolphin/gd/GDGeometry.h @@ -0,0 +1,20 @@ +#ifndef GDGEOMETRY_H +#define GDGEOMETRY_H + +#include "dolphin/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _GXVtxDescList GXVtxDescList; + +void GDSetVtxDescv(GXVtxDescList*); +void GDSetArray(GXAttr attr, const void* data, u8 stride); +void GDSetArrayRaw(GXAttr attr, u32 data, u8 stride); + +#ifdef __cplusplus +}; +#endif + +#endif /* GDGEOMETRY_H */ diff --git a/include/f_op/f_op_actor.h b/include/f_op/f_op_actor.h index 4f62ec248..56ddd726d 100644 --- a/include/f_op/f_op_actor.h +++ b/include/f_op/f_op_actor.h @@ -162,6 +162,7 @@ class fopAc_ac_c : public leafdraw_class { static u32 stopStatus; const cXyz& getPosition() const { return current.pos; } + cXyz* getPositionP() { return ¤t.pos; } const csXyz& getAngle() const { return current.angle; } s8 getRoomNo() const { return current.roomNo; } }; // Size: 0x290 diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h new file mode 100644 index 000000000..e9f5d4537 --- /dev/null +++ b/include/m_Do/m_Do_ext.h @@ -0,0 +1,182 @@ +#ifndef M_DO_EXT_H +#define M_DO_EXT_H + +#include "JSystem/J3DGraphAnimator/J3DAnimation.h" +#include "JSystem/J3DGraphAnimator/J3DModel.h" + +class JKRArchive; +class JKRAssertHeap; +class JKRExpHeap; +class JKRHeap; +class JKRSolidHeap; +struct ResTIMG; +class Z2Creature; + +class mDoExt_baseAnm { +public: + mDoExt_baseAnm() {} + /* 8000D320 */ int initPlay(s16 i_frameMax, int i_attribute, f32 i_rate, s16 i_startF, + s16 i_endF); + /* 8000D428 */ int play(); + + J3DFrameCtrl* getFrameCtrl() { return &mFrameCtrl; } + f32 getPlaySpeed() { return mFrameCtrl.getRate(); } + void setPlaySpeed(f32 speed) { mFrameCtrl.setRate(speed); } + f32 getFrame() { return mFrameCtrl.getFrame(); } + f32 getEndFrame() { return mFrameCtrl.getEnd(); } + void setFrame(f32 frame) { mFrameCtrl.setFrame(frame); } + void setPlayMode(int i_mode) { mFrameCtrl.setAttribute(i_mode); } + void setLoopFrame(f32 i_frame) { mFrameCtrl.setLoop(i_frame); } + bool isStop() { + bool stopped = true; + if (!mFrameCtrl.checkState(1) && mFrameCtrl.getRate() != 0.0f) { + stopped = false; + } + return stopped; + } + +private: + /* 0x0 */ J3DFrameCtrl mFrameCtrl; +}; // Size: 0x14 + +class mDoExt_btkAnm : public mDoExt_baseAnm { +public: + mDoExt_btkAnm() { mpAnm = 0; } + int init(J3DMaterialTable* i_matTable, J3DAnmTextureSRTKey* i_btk, int i_anmPlay, + int i_attribute, f32 i_rate, s16 i_start, s16 i_end, bool i_modify, bool i_entry); + void entry(J3DMaterialTable* i_matTable, f32 i_frame); + void entry(J3DModelData *i_modelData, f32 i_frame); + + void entry(J3DModelData* i_modelData) { entry(i_modelData, getFrame()); } + int init(J3DModelData* i_modelData, J3DAnmTextureSRTKey* i_btk, int i_anmPlay, int i_attribute, + f32 i_rate, s16 i_start, s16 i_end, bool i_modify, bool i_entry) { + return init(&i_modelData->getMaterialTable(), i_btk, i_anmPlay, i_attribute, i_rate, + i_start, i_end, i_modify, i_entry); + } + + int remove(J3DModelData* i_modelData) { return i_modelData->removeTexMtxAnimator(mpAnm); } + void entryFrame() { entryFrame(getFrame()); } + void entryFrame(f32 frame) { mpAnm->setFrame(frame); } + + J3DAnmTextureSRTKey* getBtkAnm() const { return mpAnm; } + +private: + /* 0x14 */ J3DAnmTextureSRTKey* mpAnm; +}; // Size: 0x18 + +STATIC_ASSERT(sizeof(mDoExt_btkAnm) == 0x18); + +class mDoExt_brkAnm : public mDoExt_baseAnm { +public: + mDoExt_brkAnm() { mpAnm = 0; } + /* 8000D70C */ int init(J3DMaterialTable* i_matTable, J3DAnmTevRegKey* i_brk, int i_anmPlay, + int i_attribute, f32 i_rate, s16 i_start, s16 param_6); + /* 8000D7A8 */ void entry(J3DMaterialTable* i_matTable, f32 i_frame); + + void entry(J3DModelData* i_modelData) { entry(i_modelData, getFrame()); } + void entry(J3DModelData* i_modelData, f32 i_frame) { + entry(&i_modelData->getMaterialTable(), i_frame); + } + + int init(J3DModelData* i_modelData, J3DAnmTevRegKey* i_brk, int i_anmPlay, int i_attribute, + f32 i_rate, s16 i_start, s16 param_6) { + return init(&i_modelData->getMaterialTable(), i_brk, i_anmPlay, i_attribute, i_rate, + i_start, param_6); + } + + int remove(J3DModelData* i_modelData) { return i_modelData->removeTevRegAnimator(mpAnm); } + void entryFrame() { entryFrame(getFrame()); } + void entryFrame(f32 frame) { mpAnm->setFrame(frame); } + + J3DAnmTevRegKey* getBrkAnm() const { return mpAnm; } + +private: + /* 0x14 */ J3DAnmTevRegKey* mpAnm; +}; // Size: 0x18 + +STATIC_ASSERT(sizeof(mDoExt_brkAnm) == 0x18); + +class mDoExt_bpkAnm : public mDoExt_baseAnm { +public: + mDoExt_bpkAnm() { mpAnm = 0; } + /* 8000D47C */ int init(J3DMaterialTable* i_matTable, J3DAnmColor* i_bpk, int i_anmPlay, + int i_attribute, f32 i_rate, s16 i_start, s16 param_6); + /* 8000D518 */ void entry(J3DMaterialTable* i_matTable, f32 i_frame); + + void entry(J3DModelData* i_modelData) { entry(i_modelData, getFrame()); } + void entry(J3DModelData* i_modelData, f32 i_frame) { + entry(&i_modelData->getMaterialTable(), i_frame); + } + + int init(J3DModelData* i_modelData, J3DAnmColor* i_bpk, int i_anmPlay, int i_attribute, + f32 i_rate, s16 i_start, s16 param_6) { + return init(&i_modelData->getMaterialTable(), i_bpk, i_anmPlay, i_attribute, i_rate, + i_start, param_6); + } + + int remove(J3DModelData* i_modelData) { return i_modelData->removeMatColorAnimator(mpAnm); } + +private: + /* 0x14 */ J3DAnmColor* mpAnm; +}; // Size: 0x18 + +STATIC_ASSERT(sizeof(mDoExt_bpkAnm) == 0x18); + +class mDoExt_bckAnm : public mDoExt_baseAnm { +public: + mDoExt_bckAnm() { mpMtxCalc = NULL; } + /* 8000D7DC */ int init(J3DModelData * i_model, J3DAnmTransform* i_bck, int i_play, int i_attr, + f32 i_rate, s16 i_startF, s16 i_endF1, bool i_modify); + /* 8000D990 */ void changeBckOnly(J3DAnmTransform* i_bck); + /* 8000D9CC */ void entry(J3DModelData* i_modelData, f32 i_frame); + /* 8000D9E8 */ void entryJoint(J3DModelData* i_modelData, u16 i_jntNo, f32 i_frame); + + void entry(J3DModelData* i_modelData) { entry(i_modelData, getFrame()); } + + void remove(J3DModelData* i_modelData) { i_modelData->getJointNodePointer(0)->setMtxCalc(NULL); } + + J3DAnmTransform* getBckAnm() { return mAnm; } + + void removeJoint(J3DModelData* i_modelData, u16 i_idx) { + J3DJoint* mpJnt = i_modelData->getJointNodePointer(i_idx); + mpJnt->setMtxCalc(0); + } + +private: + /* 0x14 */ J3DAnmTransform* mAnm; + /* 0x18 */ J3DMtxCalc* mpMtxCalc; +}; // Size: 0x1C + +STATIC_ASSERT(sizeof(mDoExt_bckAnm) == 0x1C); + +class mDoExt_btpAnm : public mDoExt_baseAnm { +public: + mDoExt_btpAnm() { mpAnm = NULL; } + /* 8000D54C */ int init(J3DMaterialTable* i_matTable, J3DAnmTexPattern* i_btk, int i_anmPlay, + int i_attribute, f32 i_rate, s16 i_start, s16 param_6); + /* 8000D5E8 */ void entry(J3DMaterialTable* i_matTable, s16 i_frame); + + void entry(J3DModelData* i_modelData) { entry(i_modelData, getFrame()); } + void entry(J3DModelData* i_modelData, s16 i_frame) { + entry(&i_modelData->getMaterialTable(), i_frame); + } + + int init(J3DModelData* i_modelData, J3DAnmTexPattern* i_btk, int i_anmPlay, int i_attribute, + f32 i_rate, s16 i_start, s16 param_6) { + return init(&i_modelData->getMaterialTable(), i_btk, i_anmPlay, i_attribute, i_rate, + i_start, param_6); + } + + int remove(J3DModelData* i_modelData) { return i_modelData->removeTexNoAnimator(mpAnm); } + +private: + /* 0x14 */ J3DAnmTexPattern* mpAnm; +}; + +J3DModel* mDoExt_J3DModel__create(J3DModelData* i_modelData, u32 i_modelFlag, u32 i_differedDlistFlag); + +void mDoExt_modelUpdate(J3DModel* i_model); +void mDoExt_modelUpdateDL(J3DModel* i_model); +void mDoExt_modelEntryDL(J3DModel* i_model); + +#endif diff --git a/src/d/actor/d_a_obj_Ygush00.cpp b/src/d/actor/d_a_obj_Ygush00.cpp index 2215f62ba..1f65660a4 100644 --- a/src/d/actor/d_a_obj_Ygush00.cpp +++ b/src/d/actor/d_a_obj_Ygush00.cpp @@ -3,81 +3,183 @@ // Translation Unit: d_a_obj_Ygush00.cpp // -#include "d_a_obj_Ygush00.h" -#include "dolphin/types.h" +#include "f_op/f_op_actor_mng.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "JSystem/JUtility/JUTAssert.h" +#include "d/d_a_obj.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo.h" +#include "d/d_procname.h" +#include "m_Do/m_Do_ext.h" +#include "dolphin/mtx/mtx.h" + +struct daObjGryw00_c { +public: + f32 get_draw_water_lvl(void *i_this); +}; + +struct daObjYgush00_c : public fopAc_ac_c { +public: + enum Param_e { + PRM_TYPE_W = 3, + PRM_TYPE_S = 0, + }; + + s32 _create(); + s32 _delete(); + s32 _execute(); + s32 _draw(); + s32 create_heap(); + static s32 solidHeapCB(fopAc_ac_c*); + +public: + request_of_phase_process_class mPhs; + J3DModel * mpModel; + mDoExt_btkAnm mBtkAnm; + mDoExt_bckAnm mBckAnm; + u32 mType; + daObjGryw00_c * mpGryw00; +}; /* 00000078-0000009C .text solidHeapCB__14daObjYgush00_cFP10fopAc_ac_c */ -void daObjYgush00_c::solidHeapCB(fopAc_ac_c*) { - /* Nonmatching */ +s32 daObjYgush00_c::solidHeapCB(fopAc_ac_c* ac) { + return ((daObjYgush00_c*)ac)->create_heap(); } /* 0000009C-00000250 .text create_heap__14daObjYgush00_cFv */ -void daObjYgush00_c::create_heap() { - /* Nonmatching */ -} +s32 daObjYgush00_c::create_heap() { + static const u32 mdl_table[] = { 0x0A, 0x09, 0x09, 0x09 }; + static const u32 btk_table[] = { 0x0E, 0x0D, 0x0D, 0x0D }; + static const u32 bck_table[] = { 0x06, 0x05, 0x05, 0x05 }; -/* 00000250-000003F4 .text _create__14daObjYgush00_cFv */ -void daObjYgush00_c::_create() { - /* Nonmatching */ -} + J3DModelData * pModelData = (J3DModelData *)dComIfG_getObjectRes("Ygush00", mdl_table[mType]); + J3DAnmTextureSRTKey * pBtk = (J3DAnmTextureSRTKey *)dComIfG_getObjectRes("Ygush00", btk_table[mType]); + J3DAnmTransform * pBck = (J3DAnmTransform *)dComIfG_getObjectRes("Ygush00", bck_table[mType]); -/* 000003F4-00000450 .text __dt__13mDoExt_bckAnmFv */ -mDoExt_bckAnm::~mDoExt_bckAnm() { - /* Nonmatching */ -} + if (!pModelData || !pBtk || !pBck) { + JUT_ASSERT(207, 0); + return 0; + } + + mpModel = mDoExt_J3DModel__create(pModelData, 0x80000, 0x11000222); + s32 btkRet = mBtkAnm.init(pModelData, pBtk, true, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false, false); + s32 bckRet = mBckAnm.init(pModelData, pBck, true, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false); -/* 00000450-000004AC .text __dt__13mDoExt_btkAnmFv */ -mDoExt_btkAnm::~mDoExt_btkAnm() { - /* Nonmatching */ + if (!mpModel || !btkRet || !bckRet) + return 0; + + return 1; } -/* 000004AC-000004F4 .text __dt__14mDoExt_baseAnmFv */ -mDoExt_baseAnm::~mDoExt_baseAnm() { - /* Nonmatching */ +/* 00000250-000003F4 .text _create__14daObjYgush00_cFv */ +s32 daObjYgush00_c::_create() { + fopAcM_SetupActor(this, daObjYgush00_c); + + if (fpcM_IsFirstCreating(this)) { + u32 type = daObj::PrmAbstract(this, PRM_TYPE_W, PRM_TYPE_S); + if (type >= 0 && type <= 2) { + mType = type; + } else { + mType = 0; + } + } + + if (dComIfG_resLoad(&mPhs, "Ygush00") == cPhs_COMPLEATE_e) { + if (!fopAcM_entrySolidHeap(this, (heapCallbackFunc)solidHeapCB, 0x740)) + return cPhs_ERROR_e; + + J3DModel * pModel = mpModel; + pModel->setBaseScale(mScale); + // mDoMtx_stack_c::transS(getPosition()); + // pModel->i_setBaseTRMtx(mDoMtx_stack_c::get()); + + fopAcM_setCullSizeBox(this, mScale.x * -80.0f, 0.0f, -mScale.z * -80.0f, + mScale.x * 80.0f, mScale.y * 125.0f, mScale.z * 80.0f); + } } /* 000004F4-00000524 .text _delete__14daObjYgush00_cFv */ -void daObjYgush00_c::_delete() { - /* Nonmatching */ +s32 daObjYgush00_c::_delete() { + dComIfG_resDelete(&mPhs, "Ygush00"); + return 1; } /* 00000524-0000066C .text _execute__14daObjYgush00_cFv */ -void daObjYgush00_c::_execute() { - /* Nonmatching */ +s32 daObjYgush00_c::_execute() { + if (mType != 3 || dComIfGs_isEventBit(EV_BIT_TALKED_TO_IRCH_IN_FOREST_HAVEN)) { + mBtkAnm.play(); + mBckAnm.play(); + } + + if (mType == 1) { + if (mpGryw00 != NULL) { + if (mpGryw00->get_draw_water_lvl(mpGryw00) <= getPosition().y) { + // fopAcM_seStartCurrent(this, 0x61fe, 0); + } + } else { + mpGryw00 = (daObjGryw00_c*)i_fopAcM_SearchByName(PROC_Obj_Gryw00); + } + } else { + // fopAcM_seStartCurrent(this, 0x61fe, 0); + } } /* 0000066C-000006FC .text _draw__14daObjYgush00_cFv */ -void daObjYgush00_c::_draw() { - /* Nonmatching */ +s32 daObjYgush00_c::_draw() { + g_env_light.settingTevStruct(TEV_TYPE_BG1, getPositionP(), &mTevStr); + g_env_light.setLightTevColorType(mpModel, &mTevStr); + mBtkAnm.entry(mpModel->getModelData()); + mBckAnm.entry(mpModel->getModelData()); + mDoExt_modelUpdateDL(mpModel); + return 1; } /* 000006FC-0000071C .text daObjYgush00_Create__FP14daObjYgush00_c */ -void daObjYgush00_Create(daObjYgush00_c*) { - /* Nonmatching */ +s32 daObjYgush00_Create(daObjYgush00_c* i_this) { + return i_this->_create(); } /* 0000071C-00000740 .text daObjYgush00_Delete__FP14daObjYgush00_c */ -void daObjYgush00_Delete(daObjYgush00_c*) { - /* Nonmatching */ +s32 daObjYgush00_Delete(daObjYgush00_c* i_this) { + return i_this->_delete(); } /* 00000740-00000764 .text daObjYgush00_Execute__FP14daObjYgush00_c */ -void daObjYgush00_Execute(daObjYgush00_c*) { - /* Nonmatching */ +s32 daObjYgush00_Execute(daObjYgush00_c* i_this) { + return i_this->_execute(); } /* 00000764-00000788 .text daObjYgush00_Draw__FP14daObjYgush00_c */ -void daObjYgush00_Draw(daObjYgush00_c*) { - /* Nonmatching */ +s32 daObjYgush00_Draw(daObjYgush00_c* i_this) { + return i_this->_draw(); } /* 00000788-00000790 .text daObjYgush00_IsDelete__FP14daObjYgush00_c */ -void daObjYgush00_IsDelete(daObjYgush00_c*) { - /* Nonmatching */ -} - -/* 00000790-000007AC .text PrmAbstract__5daObjFPC10fopAc_ac_cQ214daObjYgush00_c7Param_eQ214daObjYgush00_c7Param_e */ -void daObj::PrmAbstract(const fopAc_ac_c*, daObjYgush00_c::Param_e, daObjYgush00_c::Param_e) { - /* Nonmatching */ +s32 daObjYgush00_IsDelete(daObjYgush00_c* i_this) { + return 1; } +static actor_method_class l_daObjYgush00_Mehtod = { + (process_method_func)daObjYgush00_Create, + (process_method_func)daObjYgush00_Delete, + (process_method_func)daObjYgush00_Execute, + (process_method_func)daObjYgush00_IsDelete, + (process_method_func)daObjYgush00_Draw, +}; + +extern actor_process_profile_definition g_profile_Obj_Ygish00 = { + -3, + 2, + 0xFFFD, + PROC_Obj_Ygush00, + &g_fpcLf_Method.mBase, + sizeof(daObjYgush00_c), + 0, + 0, + &g_fopAc_Method.base, + 0x0116, + &l_daObjYgush00_Mehtod, + 0x00044000, + 0, + 6, +}; diff --git a/src/d/actor/d_a_obj.cpp b/src/d/d_a_obj.cpp similarity index 100% rename from src/d/actor/d_a_obj.cpp rename to src/d/d_a_obj.cpp