From 9780adcc4eb5d0f13d33762e6ebaba5e0279e1d7 Mon Sep 17 00:00:00 2001 From: Caroline Madsen <69010899+randomsalience@users.noreply.github.com> Date: Wed, 27 Dec 2023 20:17:39 -0500 Subject: work on J3DMaterialFactory and J3DMaterialFactory_v21 (#2012) --- include/JSystem/J3DGraphBase/J3DMatBlock.h | 193 ++++++++++++------ include/JSystem/J3DGraphBase/J3DMaterial.h | 257 ++++++++++++------------ include/JSystem/J3DGraphBase/J3DShape.h | 310 +++++++++++++++-------------- include/JSystem/J3DGraphBase/J3DStruct.h | 18 +- include/JSystem/J3DGraphBase/J3DTevs.h | 73 ++++++- include/JSystem/J3DGraphBase/J3DTexture.h | 172 ++++++++-------- 6 files changed, 578 insertions(+), 445 deletions(-) (limited to 'include/JSystem/J3DGraphBase') diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index e0520caba5..46f5dc49f7 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -5,14 +5,17 @@ #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() {} + J3DGXColorS10(J3DGXColorS10 const& other) { __memcpy(this, &other, sizeof(J3DGXColorS10)); } + J3DGXColorS10(GXColorS10 const& color) : GXColorS10(color) {} }; struct J3DGXColor : public GXColor { /* 8000E538 */ J3DGXColor() {} + J3DGXColor(J3DGXColor const& other) { __memcpy(this, &other, sizeof(J3DGXColor)); } + J3DGXColor(GXColor const& color) : GXColor(color) {} }; struct J3DNBTScale : public J3DNBTScaleInfo { @@ -52,7 +55,21 @@ public: /* 80317334 */ virtual J3DNBTScale* getNBTScale(); /* 80317428 */ virtual bool getTexMtxOffset() const; /* 80317430 */ virtual void setTexMtxOffset(u32); - /* 803171DC */ virtual ~J3DTexGenBlock(); + /* 803171DC */ virtual ~J3DTexGenBlock() {} +}; + +struct J3DTexGenBlockNull : public J3DTexGenBlock { + /* 80332AA0 */ virtual void calc(f32 const (*)[4]); // {} + /* 80332AA4 */ virtual void calcWithoutViewMtx(f32 const (*)[4]); // {} + /* 80332AA8 */ virtual void calcPostTexMtx(f32 const (*)[4]); // {} + /* 80332AAC */ virtual void calcPostTexMtxWithoutViewMtx(f32 const (*)[4]); // {} + /* 80332AB0 */ virtual void load(); // {} + /* 80332AB4 */ virtual void patch(); // {} + /* 80332AB8 */ virtual void diff(u32); // {} + /* 80332ABC */ virtual void diffTexMtx(); // {} + /* 80332AC0 */ virtual void diffTexGen(); // {} + /* 80332AC4 */ virtual u32 getType(); // { return 'TGNL'; } + /* 80332AD0 */ virtual ~J3DTexGenBlockNull(); // {} }; class J3DTexGenBlockPatched : public J3DTexGenBlock { @@ -188,14 +205,25 @@ public: /* 80322964 */ virtual bool getTevRegOffset() const; /* 80321FE0 */ virtual void setTexNoOffset(u32); /* 8032296C */ virtual void setTevRegOffset(u32); - /* 80317224 */ virtual ~J3DTevBlock(); + /* 80317224 */ virtual ~J3DTevBlock() {} -private: +protected: /* 8031E098 */ void indexToPtr_private(u32); /* 0x4 */ u32 mTexNoOffset; }; +class J3DTevBlockNull : public J3DTevBlock { +public: + J3DTevBlockNull() { initialize(); } + /* 803176D4 */ void initialize(); + /* 80332A0C */ virtual void reset(J3DTevBlock*); // {} + /* 80332A10 */ virtual void ptrToIndex(); // {} + /* 80332A14 */ virtual void indexToPtr(); // { indexToPtr_private(mTexNoOffset); } + /* 80332A38 */ virtual u32 getType(); // { return 'TVNL'; } + /* 80332A44 */ virtual ~J3DTevBlockNull(); // {} +}; + class J3DTevBlockPatched : public J3DTevBlock { public: J3DTevBlockPatched() { @@ -259,10 +287,6 @@ private: /* 0xD4 */ u32 mTevRegOffset; }; // Size: 0xD8 -class J3DTevBlockNull : public J3DTevBlock { - /* 803176D4 */ void initialize(); -}; - class J3DTevBlock4 : public J3DTevBlock { public: J3DTevBlock4() { @@ -532,19 +556,19 @@ private: 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; + return param_1 * 2 + param_0 * 0x10 + param_2; } struct J3DZModeInfo { /* 0x0 */ u8 field_0x0; /* 0x1 */ u8 field_0x1; /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 pad; }; struct J3DZMode { - J3DZMode() { - mZModeID = j3dDefaultZModeID; - } + J3DZMode() : mZModeID(j3dDefaultZModeID) {} + J3DZMode(J3DZModeInfo const& info) : mZModeID(calcZModeID(info.field_0x0, info.field_0x1, info.field_0x2)) {} void setZModeInfo(const J3DZModeInfo& info) { mZModeID = calcZModeID(info.field_0x0, info.field_0x1, info.field_0x2); @@ -566,18 +590,16 @@ struct J3DBlendInfo { extern const J3DBlendInfo j3dDefaultBlendInfo; struct J3DBlend : public J3DBlendInfo { - J3DBlend() { - *(J3DBlendInfo*)this = j3dDefaultBlendInfo; - } + J3DBlend() : J3DBlendInfo(j3dDefaultBlendInfo) {} + J3DBlend(J3DBlendInfo const& info) : J3DBlendInfo(info) {} }; extern const J3DFogInfo j3dDefaultFogInfo; struct J3DFog : public J3DFogInfo { - J3DFog() { - *getFogInfo() = j3dDefaultFogInfo; - } - J3DFogInfo* getFogInfo() { return (J3DFogInfo*)this; } + J3DFog() { *(J3DFogInfo*)this = j3dDefaultFogInfo; } + J3DFogInfo* getFogInfo() { return this; } + void setFogInfo(J3DFogInfo info) { *(J3DFogInfo*)this = info; } }; struct J3DAlphaCompInfo { @@ -593,25 +615,36 @@ struct J3DAlphaCompInfo { extern const u16 j3dDefaultAlphaCmpID; +inline u32 calcAlphaCmpID(u32 param_1, u32 param_2, u32 param_3) { + return ((param_1 & 0xff) << 5) + ((param_2 & 0xff) << 3) + (param_3 & 0xff); +} + +// matches for `J3DMaterialFactory::newAlphaComp` but fails for `d_resorce::addWarpMaterial` +// inline u32 calcAlphaCmpID(u8 param_1, u8 param_2, u8 param_3) { +// return param_1 * 0x20 + param_2 * 8 + param_3; +// } + struct J3DAlphaComp { - J3DAlphaComp() { - field_0x0 = j3dDefaultAlphaCmpID; - mRef0 = 0; - mRef1 = 0; - } + J3DAlphaComp() : mID(j3dDefaultAlphaCmpID), mRef0(0), mRef1(0) {} + J3DAlphaComp(u16 id) : mID(id), mRef0(0), mRef1(0) {} + J3DAlphaComp(J3DAlphaCompInfo const& info) : + mID(calcAlphaCmpID(info.field_0x0, info.mRef0, info.mRef1)), + mRef0(info.field_0x1), + mRef1(info.field_0x4) + {} 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); + mID = 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); + // mID = calcAlphaCmpID(param_1.field_0x0, param_1.mRef0, param_1.mRef1); } - /* 0x00 */ u16 field_0x0; + /* 0x00 */ u16 mID; /* 0x02 */ u8 mRef0; /* 0x03 */ u8 mRef1; }; // Size: 0x4 @@ -646,7 +679,13 @@ public: /* 80317384 */ virtual bool getDither() const; /* 8031738C */ virtual bool getFogOffset() const; /* 80317394 */ virtual void setFogOffset(u32); - virtual ~J3DPEBlock(); + virtual ~J3DPEBlock() {} +}; + +struct J3DPEBlockNull : public J3DPEBlock { + /* 803329A0 */ virtual void load(); // {} + /* 803329A4 */ virtual u32 getType(); // { return 'PENL'; } + /* 803329B0 */ virtual ~J3DPEBlockNull(); // {} }; class J3DPEBlockXlu : public J3DPEBlock { @@ -763,24 +802,22 @@ struct J3DIndTexCoordScaleInfo { /* 0x1 */ u8 mScaleT; /* 0x2 */ u8 field_0x2; /* 0x3 */ u8 field_0x3; -}; +}; // Size: 0x4 -struct J3DIndTexCoordScale { - /* 8000E024 */ ~J3DIndTexCoordScale(); - /* 8000E0E4 */ J3DIndTexCoordScale(); +extern J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo; - /* 0x0 */ u8 mScaleS; - /* 0x1 */ u8 mScaleT; - /* 0x2 */ u8 field_0x2; - /* 0x3 */ u8 field_0x3; -}; +struct J3DIndTexCoordScale : public J3DIndTexCoordScaleInfo { + /* 8000E0E4 */ J3DIndTexCoordScale() : J3DIndTexCoordScaleInfo(j3dDefaultIndTexCoordScaleInfo) {} + J3DIndTexCoordScale(J3DIndTexCoordScaleInfo const& info) : J3DIndTexCoordScaleInfo(info) {} + /* 8000E024 */ ~J3DIndTexCoordScale() {} +}; // Size: 0x4 -struct J3DIndTexMtx { - /* 8000E064 */ ~J3DIndTexMtx(); - /* 8000E0F0 */ J3DIndTexMtx(); +extern J3DIndTexMtxInfo const j3dDefaultIndTexMtxInfo; - /* 0x00 */ Mtx23 mOffsetMtx; - /* 0x18 */ u8 mScaleExp; +struct J3DIndTexMtx : public J3DIndTexMtxInfo { + /* 8000E0F0 */ J3DIndTexMtx() { *(J3DIndTexMtxInfo*)this = j3dDefaultIndTexMtxInfo; } + J3DIndTexMtx(J3DIndTexMtxInfo const& info) { *(J3DIndTexMtxInfo*)this = info; } + /* 8000E064 */ ~J3DIndTexMtx() {} }; // Size: 0x1C struct J3DIndTexOrderInfo { @@ -788,16 +825,14 @@ struct J3DIndTexOrderInfo { /* 0x1 */ u8 mCoord; /* 0x2 */ u8 field_0x2; /* 0x3 */ u8 field_0x3; -}; +}; // Size: 0x04 -struct J3DIndTexOrder { - /* 8000E128 */ J3DIndTexOrder(); +extern J3DIndTexOrderInfo j3dDefaultIndTexOrderNull; - /* 0x0 */ u8 mMap; - /* 0x1 */ u8 mCoord; - /* 0x2 */ u8 field_0x2; - /* 0x3 */ u8 field_0x3; -}; +struct J3DIndTexOrder : public J3DIndTexOrderInfo { + /* 8000E128 */ J3DIndTexOrder() : J3DIndTexOrderInfo(j3dDefaultIndTexOrderNull) {} + J3DIndTexOrder(J3DIndTexOrderInfo const& info) : J3DIndTexOrderInfo(info) {} +}; // Size: 0x04 class J3DIndBlock { public: @@ -820,6 +855,15 @@ public: /* 8031726C */ virtual ~J3DIndBlock(); }; +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(); +}; + class J3DIndBlockFull : public J3DIndBlock { public: J3DIndBlockFull() { @@ -852,15 +896,6 @@ private: /* 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; @@ -868,10 +903,41 @@ struct J3DColorChanInfo { /* 0x3 */ u8 field_0x3; /* 0x4 */ u8 field_0x4; /* 0x5 */ u8 field_0x5; + /* 0x6 */ u8 pad[2]; }; +extern J3DColorChanInfo j3dDefaultColorChanInfo; + struct J3DColorChan { - /* 8000E47C */ J3DColorChan(); + /* 8000E47C */ J3DColorChan() { + setColorChanInfo(j3dDefaultColorChanInfo); + } + J3DColorChan(J3DColorChanInfo const& info) { + setColorChanInfo(info); + } + void setColorChanInfo(J3DColorChanInfo const& info) { + mColorChanID = calcColorChanID(info.field_0x0, info.field_0x1, info.field_0x2, + info.field_0x3, info.field_0x4, info.field_0x5 == 0xff ? 0 : info.field_0x5); + } + u16 calcColorChanID(u16 param_0, u8 param_1, u8 param_2, u8 param_3, u8 param_4, u8 param_5) { + // if (param_4 == 0) { + // param_3 = 0; + // } + u32 b0 = ((param_2 & 1) != 0); + u32 b1 = ((param_2 & 2) != 0); + u32 b2 = ((param_2 & 4) != 0); + u32 b3 = ((param_2 & 8) != 0); + u32 b4 = ((param_2 & 0x10) != 0); + u32 b5 = ((param_2 & 0x20) != 0); + u32 b6 = ((param_2 & 0x40) != 0); + u32 b7 = ((param_2 & 0x80) != 0); + return param_1 | (param_0 << 1) | (b0 << 2) | (b1 << 3) | (b2 << 4) | (b3 << 5) | + (param_5 << 6) | (param_3 << 7) | ((param_4 != 2) << 9) | ((param_4 != 0) << 10) | + (b4 << 11) | (b5 << 12) | (b6 << 13) | (b7 << 14); + // return (b7 << 14) | (b6 << 13) | (b5 << 12) | (b4 << 11) | + // ((param_4 != 0) << 10) | ((param_4 != 2) << 9) | ((param_3 != 0) << 7) | ((param_5 != 0) << 6) | + // (b3 << 5) | (b2 << 4) | (b1 << 3) | (b0 << 2) | ((param_0 != 0) << 1) | param_1; + } u8 getLightMask() { return (((mColorChanID & 0x7800) >> 7) | (mColorChanID & 0x3c) >> 2); } void setLightMask(u8 param_1) { mColorChanID = (mColorChanID & ~0x3c) | ((param_1 & 0xf) << 2); @@ -916,7 +982,12 @@ public: /* 8031746C */ virtual bool getColorChanOffset() const; /* 80317474 */ virtual void setMatColorOffset(u32); /* 80317478 */ virtual void setColorChanOffset(u32); - /* 80317138 */ virtual ~J3DColorBlock(); + /* 80317138 */ virtual ~J3DColorBlock() {} +}; + +struct J3DColorBlockNull : public J3DColorBlock { + /* 80332B2C */ virtual u32 getType(); // { return 'CLNL'; } + /* 80332B38 */ virtual ~J3DColorBlockNull(); // {} }; class J3DColorBlockLightOn : public J3DColorBlock { diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h index d633954691..c7838fb96e 100644 --- a/include/JSystem/J3DGraphBase/J3DMaterial.h +++ b/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -1,128 +1,129 @@ -#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() { initialize(); } - ~J3DMaterial() {} - 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 */ +#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() { initialize(); } + ~J3DMaterial() {} + 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: + J3DLockedMaterial() { initialize(); } + /* 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/J3DShape.h b/include/JSystem/J3DGraphBase/J3DShape.h index 457724a868..afa53214db 100644 --- a/include/JSystem/J3DGraphBase/J3DShape.h +++ b/include/JSystem/J3DGraphBase/J3DShape.h @@ -1,152 +1,158 @@ -#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 */ +#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; + } + + J3DCurrentMtx& operator=(J3DCurrentMtxInfo const& info) { + mMtxIdxRegA = info.mMtxIdxRegA; + mMtxIdxRegB = info.mMtxIdxRegB; + return *this; + } + + 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/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h index 8693afa648..1932113cb1 100644 --- a/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/include/JSystem/J3DGraphBase/J3DStruct.h @@ -8,7 +8,7 @@ class J3DLightInfo { public: - /* 803256C4 */ void operator=(J3DLightInfo const&); + /* 803256C4 */ J3DLightInfo& operator=(J3DLightInfo const&); /* 0x00 */ Vec mLightPosition; /* 0x0C */ Vec mLightDirection; @@ -61,7 +61,7 @@ struct J3DTextureSRTInfo { }; // Size: 0x14 struct J3DTexMtxInfo { - /* 80325718 */ void operator=(J3DTexMtxInfo const&); + /* 80325718 */ J3DTexMtxInfo& operator=(J3DTexMtxInfo const&); /* 80325794 */ void setEffectMtx(Mtx); /* 0x00 */ u8 mProjection; @@ -72,14 +72,13 @@ struct J3DTexMtxInfo { }; // Size: 0x64 struct J3DIndTexMtxInfo { - /* 803257DC */ void operator=(J3DIndTexMtxInfo const&); - + J3DIndTexMtxInfo& operator=(J3DIndTexMtxInfo const&); /* 0x00 */ Mtx23 field_0x0; /* 0x18 */ u8 field_0x18; }; // Size: 0x1C struct J3DFogInfo { - /* 80325800 */ void operator=(J3DFogInfo const&); + /* 80325800 */ J3DFogInfo& operator=(J3DFogInfo const&); /* 0x00 */ u8 field_0x0; /* 0x01 */ u8 field_0x1; @@ -88,15 +87,12 @@ struct J3DFogInfo { /* 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]; + /* 0x14 */ GXColor field_0x14; + /* 0x18 */ GXFogAdjTable field_0x18; }; // Size: 0x2C struct J3DNBTScaleInfo { - /* 8032587C */ void operator=(J3DNBTScaleInfo const&); + /* 8032587C */ J3DNBTScaleInfo& operator=(J3DNBTScaleInfo const&); /* 0x0 */ bool mbHasScale; /* 0x4 */ Vec mScale; diff --git a/include/JSystem/J3DGraphBase/J3DTevs.h b/include/JSystem/J3DGraphBase/J3DTevs.h index 09081c5277..8d63bd4d92 100644 --- a/include/JSystem/J3DGraphBase/J3DTevs.h +++ b/include/JSystem/J3DGraphBase/J3DTevs.h @@ -12,12 +12,27 @@ struct J3DTevStageInfo { /* 0x5 */ u8 mTevAlphaOp; /* 0x6 */ u8 mTevAlphaAB; /* 0x7 */ u8 mTevSwapModeInfo; + /* 0x8 */ u8 field_0x8[0xc]; }; -struct J3DTevStage : public J3DTevStageInfo { +extern J3DTevStageInfo const j3dDefaultTevStageInfo; + +struct J3DTevStage { /* 8000E230 */ J3DTevStage(); /* 8000E298 */ void setTevStageInfo(J3DTevStageInfo const&); /* 8003AACC */ J3DTevStage(J3DTevStageInfo const&); + + void setRasSel(u8 ras_sel) { mTevSwapModeInfo = (mTevSwapModeInfo & ~3) | ras_sel; } + void setTexSel(u8 tex_sel) { mTevSwapModeInfo = (mTevSwapModeInfo & ~0xc) | (tex_sel << 2); } + + /* 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 J3DIndTevStageInfo { @@ -30,10 +45,34 @@ struct J3DIndTevStageInfo { /* 0x6 */ u8 mPrev; /* 0x7 */ u8 mLod; /* 0x8 */ u8 mAlphaSel; + /* 0x9 */ u8 pad[3]; }; +extern J3DIndTevStageInfo const j3dDefaultIndTevStageInfo; + struct J3DIndTevStage { - /* 8000E14C */ J3DIndTevStage(); + /* 8000E14C */ J3DIndTevStage() : mInfo(0) { setIndTevStageInfo(j3dDefaultIndTevStageInfo); } + J3DIndTevStage(J3DIndTevStageInfo const& info) : mInfo(0) { setIndTevStageInfo(info); } + void setIndTevStageInfo(J3DIndTevStageInfo const& info) { + setIndStage(info.mIndStage); + setIndFormat(info.mIndFormat); + setBiasSel(info.mBiasSel); + setMtxSel(info.mMtxSel); + setWrapS(info.mWrapS); + setWrapT(info.mWrapT); + setPrev(info.mPrev); + setLod(info.mLod); + setAlphaSel(info.mAlphaSel); + } + void setIndStage(u8 indStage) { mInfo = (mInfo & ~3) | indStage; } + void setIndFormat(u8 indFormat) { mInfo = (mInfo & ~0xc) | (indFormat << 2); } + void setBiasSel(u8 biasSel) { mInfo = (mInfo & ~0x70) | (biasSel << 4); } + void setMtxSel(u8 mtxSel) { mInfo = (mInfo & ~0x1e00) | (mtxSel << 9); } + void setWrapS(u8 wrapS) { mInfo = (mInfo & ~0xe000) | (wrapS << 13); } + void setWrapT(u8 wrapT) { mInfo = (mInfo & ~0x70000) | (wrapT << 16); } + void setPrev(u8 prev) { mInfo = (mInfo & ~0x100000) | (prev << 20); } + void setLod(u8 lod) { mInfo = (mInfo & ~0x80000) | (lod << 19); } + void setAlphaSel(u8 alphaSel) { mInfo = (mInfo & ~0x180) | (alphaSel << 7); } /* 0x0 */ u32 mInfo; }; @@ -49,22 +88,42 @@ struct J3DTevOrderInfo { /* 0x3 */ u8 field_0x3; // Maybe padding }; +extern J3DTevOrderInfo j3dDefaultTevOrderInfoNull; + struct J3DTevOrder : public J3DTevOrderInfo { - /* 8000E140 */ J3DTevOrder(); - J3DTevOrder(const J3DTevOrderInfo& info) { - *(J3DTevOrderInfo*)this = info; - } + /* 8000E140 */ J3DTevOrder() : J3DTevOrderInfo(j3dDefaultTevOrderInfoNull) {} + J3DTevOrder(const J3DTevOrderInfo& info) : J3DTevOrderInfo(info) {} u8 getTexMap() { return mTexMap; } }; +struct J3DTevSwapModeTableInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; +}; // Size: 0x4 + +extern J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable; + struct J3DTevSwapModeTable { /* 8000E134 */ J3DTevSwapModeTable(); + J3DTevSwapModeTable(J3DTevSwapModeTableInfo const& info) { + field_0x0 = calcTevSwapTableID(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); + } + u8 calcTevSwapTableID(u8 param_0, u8 param_1, u8 param_2, u8 param_3) { + return 0x40 * param_0 + 0x10 * param_1 + 4 * param_2 + param_3; + } /* 0x0 */ u8 field_0x0; }; // Size: 0x1 -struct J3DTevSwapModeInfo {}; +struct J3DTevSwapModeInfo { + /* 0x0 */ u8 mRasSel; + /* 0x1 */ u8 mTexSel; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; +}; // Size: 0x4 struct J3DNBTScale; void loadNBTScale(J3DNBTScale& param_0); diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h index e2bf0c9052..a37ceb8006 100644 --- a/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -1,86 +1,86 @@ -#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; - /* 0x2 */ u16 field_0x2; - /* 0x4 */ ResTIMG* mpRes; - -public: - J3DTexture(u16 num, ResTIMG* res) : mNum(num), field_0x2(0), mpRes(res) {} - /* 8031204C */ void loadGX(u16, _GXTexMapID) const; - /* 803121A4 */ void entryNum(u16); - /* 8031221C */ void addResTIMG(u16, ResTIMG const*); - /* 803366A4 */ virtual ~J3DTexture() {} - - u16 getNum() const { return mNum; } - ResTIMG* getResTIMG(u16 entry) const { 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(const Mtx); - /* 80323920 */ void calcTexMtx(const Mtx); - /* 80323C0C */ void calcPostTexMtx(const Mtx); - /* 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 getTexGenType() { return mTexGenType; } - u8 getTexGenSrc() { return mTexGenSrc; } - 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 */ +#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; + /* 0x2 */ u16 field_0x2; + /* 0x4 */ ResTIMG* mpRes; + +public: + J3DTexture(u16 num, ResTIMG* res) : mNum(num), field_0x2(0), mpRes(res) {} + /* 8031204C */ void loadGX(u16, _GXTexMapID) const; + /* 803121A4 */ void entryNum(u16); + /* 8031221C */ void addResTIMG(u16, ResTIMG const*); + /* 803366A4 */ virtual ~J3DTexture() {} + + u16 getNum() const { return mNum; } + ResTIMG* getResTIMG(u16 entry) const { 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(const Mtx); + /* 80323920 */ void calcTexMtx(const Mtx); + /* 80323C0C */ void calcPostTexMtx(const Mtx); + /* 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; + /* 0x3 */ u8 pad; +}; + +extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8]; + +struct J3DTexCoord : public J3DTexCoordInfo { + /* 8000E464 */ J3DTexCoord() { + setTexCoordInfo(j3dDefaultTexCoordInfo[0]); + resetTexMtxReg(); + } + J3DTexCoord(J3DTexCoordInfo const& info) { + setTexCoordInfo(info); + resetTexMtxReg(); + } + void setTexCoordInfo(J3DTexCoordInfo const& info) { + __memcpy(this, &info, sizeof(J3DTexCoordInfo)); + } + + u8 getTexGenType() { return mTexGenType; } + u8 getTexGenSrc() { return mTexGenSrc; } + u8 getTexGenMtx() { return mTexGenMtx & 0xff; } + u16 getTexMtxReg() { return mTexMtxReg & 0xff; } + + void resetTexMtxReg() { + mTexMtxReg = mTexGenMtx; + } + + /* 0x4 */ u16 mTexMtxReg; +}; // Size: 0x6 + +#endif /* J3DTEXTURE_H */ -- cgit v1.2.3