diff options
| author | Tal Hayon <talhayon1@gmail.com> | 2023-07-09 20:21:18 +0300 |
|---|---|---|
| committer | Tal Hayon <talhayon1@gmail.com> | 2023-07-09 20:21:18 +0300 |
| commit | e00ce8bc31ce57f3aeff7c4844ffa926fa08e95f (patch) | |
| tree | 97873da548ff40005e563245aa002e9fc0117f9f /include/JSystem/J3DGraphBase | |
| parent | cf26cd610d4e88f391c7d854b5da5b7460d130c5 (diff) | |
Work on J3DMaterial
Diffstat (limited to 'include/JSystem/J3DGraphBase')
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DGD.h | 35 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DMatBlock.h | 95 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DMaterial.h | 20 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DPacket.h | 4 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DShape.h | 7 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DSys.h | 1 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DTevs.h | 3 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DTexture.h | 3 |
8 files changed, 150 insertions, 18 deletions
diff --git a/include/JSystem/J3DGraphBase/J3DGD.h b/include/JSystem/J3DGraphBase/J3DGD.h index 6cd5659f57..87ab8b94a6 100644 --- a/include/JSystem/J3DGraphBase/J3DGD.h +++ b/include/JSystem/J3DGraphBase/J3DGD.h @@ -3,6 +3,33 @@ #include "dolphin/types.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; @@ -10,4 +37,12 @@ static inline void J3DFifoLoadIndx(u8 cmd, u16 indx, u16 addr) { 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 index c7c28056f5..ed9ffd645c 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -27,9 +27,16 @@ struct J3DNBTScaleInfo { }; // Size: 0x10 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*); @@ -61,6 +68,9 @@ public: class J3DTexGenBlockPatched : public J3DTexGenBlock { public: + J3DTexGenBlockPatched() { + initialize(); + } /* 80317644 */ void initialize(); /* 80320084 */ virtual void reset(J3DTexGenBlock*); @@ -88,13 +98,16 @@ public: private: /* 0x04 */ u32 mTexGenNum; - /* 0x08 */ J3DTexCoord mTexCoord[9]; + /* 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*); @@ -113,6 +126,9 @@ private: class J3DTexGenBlock4 : public J3DTexGenBlockPatched { public: + J3DTexGenBlock4() : mNBTScale(j3dDefaultNBTScaleInfo) { + initialize(); + } /* 80317674 */ void initialize(); /* 803201A0 */ virtual void reset(J3DTexGenBlock*); @@ -193,6 +209,9 @@ private: class J3DTevBlockPatched : public J3DTevBlock { public: + J3DTevBlockPatched() { + initialize(); + } /* 803176E0 */ void initialize(); /* 80320418 */ virtual void reset(J3DTevBlock*); @@ -257,6 +276,9 @@ class J3DTevBlockNull : public J3DTevBlock { class J3DTevBlock4 : public J3DTevBlock { public: + J3DTevBlock4() { + initialize(); + } /* 803178EC */ void initialize(); /* 8032098C */ virtual void reset(J3DTevBlock*); @@ -327,6 +349,9 @@ private: class J3DTevBlock2 : public J3DTevBlock { public: + J3DTevBlock2() { + initialize(); + } /* 80317810 */ void initialize(); /* 803206AC */ virtual void reset(J3DTevBlock*); @@ -397,6 +422,9 @@ private: class J3DTevBlock16 : public J3DTevBlock { public: + J3DTevBlock16() { + initialize(); + } /* 80317A00 */ void initialize(); /* 80320E24 */ virtual void reset(J3DTevBlock*); @@ -467,6 +495,9 @@ private: class J3DTevBlock1 : public J3DTevBlock { public: + J3DTevBlock1() { + initialize(); + } /* 803177E8 */ void initialize(); /* 803205D4 */ virtual void reset(J3DTevBlock*); @@ -509,18 +540,32 @@ private: /* 0x18 */ J3DIndTevStage mIndTevStage[1]; }; // Size: 0x1C +extern const u16 j3dDefaultZModeID; + struct J3DZMode { + J3DZMode() { + mZModeID = j3dDefaultZModeID; + } /* 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; }; -struct J3DBlend : public J3DBlendInfo {}; +extern const J3DBlendInfo j3dDefaultBlendInfo; + +struct J3DBlend : public J3DBlendInfo { + J3DBlend() { + *(J3DBlendInfo*)this = j3dDefaultBlendInfo; + } +}; struct J3DFogInfo { /* 80325800 */ void operator=(J3DFogInfo const&); @@ -539,7 +584,12 @@ struct J3DFogInfo { /* 0x18 */ u16 field_0x18[10]; }; // Size: 0x2C +extern const J3DFogInfo j3dDefaultFogInfo; + struct J3DFog : public J3DFogInfo { + J3DFog() { + *getFogInfo() = j3dDefaultFogInfo; + } J3DFogInfo* getFogInfo() { return (J3DFogInfo*)this; } }; @@ -548,15 +598,22 @@ struct J3DAlphaCompInfo { /* 0x1 */ u8 field_0x1; /* 0x2 */ u8 mRef0; /* 0x3 */ u8 mRef1; - /* 0x4 */ u8 field_0x4; }; +extern const J3DAlphaCompInfo j3dDefaultAlphaCmpID; + struct J3DAlphaComp: public J3DAlphaCompInfo { + J3DAlphaComp() { + *(u16*)&field_0x0 = *(u16*)&j3dDefaultAlphaCmpID.field_0x0; + mRef0 = 0; + mRef1 = 0; + } + void setAlphaCompInfo(J3DAlphaCompInfo *param_1) { - mRef0 = param_1->field_0x1; - mRef1 = param_1->field_0x4; - u32 p1_mref1 = param_1->mRef1; - *(u16*)&field_0x0 = calcAlphaCmpID(param_1->field_0x0, param_1->mRef0, p1_mref1); + mRef0 = param_1[0].field_0x1; + mRef1 = param_1[1].field_0x0; + u32 p1_mref1 = param_1[0].mRef1; + *(u16*)&field_0x0 = calcAlphaCmpID(param_1[0].field_0x0, param_1[0].mRef0, p1_mref1); } }; // Size: 0x4 @@ -619,6 +676,9 @@ public: class J3DPEBlockFull : public J3DPEBlock { public: + J3DPEBlockFull() { + initialize(); + } /* 80317B58 */ void initialize(); /* 8032129C */ virtual void reset(J3DPEBlock*); @@ -663,6 +723,9 @@ private: class J3DPEBlockFogOff : public J3DPEBlock { public: + J3DPEBlockFogOff() { + initialize(); + } /* 80317B34 */ void initialize(); /* 803211B4 */ virtual void reset(J3DPEBlock*); @@ -702,6 +765,8 @@ struct J3DIndTexCoordScale { /* 0x0 */ u8 mScaleS; /* 0x1 */ u8 mScaleT; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; }; struct J3DIndTexMtx { @@ -717,13 +782,15 @@ struct 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 load() = 0; virtual void diff(u32) = 0; + virtual void load() = 0; /* 80317314 */ virtual s32 countDLSize(); virtual u32 getType() = 0; /* 8000E0A0 */ virtual void setIndTexStageNum(u8); @@ -742,6 +809,9 @@ public: class J3DIndBlockFull : public J3DIndBlock { public: + J3DIndBlockFull() { + initialize(); + } /* 80317B28 */ void initialize(); /* 803210B0 */ virtual void reset(J3DIndBlock*); @@ -838,6 +908,9 @@ public: class J3DColorBlockLightOn : public J3DColorBlock { public: + J3DColorBlockLightOn() { + initialize(); + } /* 80317580 */ void initialize(); /* 803187F4 */ virtual void load(); @@ -888,6 +961,9 @@ private: class J3DColorBlockLightOff : public J3DColorBlock { public: + J3DColorBlockLightOff() { + initialize(); + } /* 8031747C */ void initialize(); /* 80317C0C */ virtual void load(); @@ -929,6 +1005,9 @@ private: class J3DColorBlockAmbientOn : public J3DColorBlockLightOff { public: + J3DColorBlockAmbientOn() { + initialize(); + } /* 803174DC */ void initialize(); /* 8031816C */ virtual void load(); diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h index 4ad02396d4..a237249980 100644 --- a/include/JSystem/J3DGraphBase/J3DMaterial.h +++ b/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -14,16 +14,16 @@ class J3DMaterialAnm; class J3DMaterial { public: - /* 803157A0 */ void createColorBlock(u32); - /* 803159A0 */ void createTexGenBlock(u32); - /* 80315B04 */ void createTevBlock(int); - /* 80315E78 */ void createIndBlock(int); - /* 80315F60 */ void createPEBlock(u32, u32); - /* 80316100 */ void calcSizeColorBlock(u32); - /* 80316150 */ void calcSizeTexGenBlock(u32); - /* 8031617C */ void calcSizeTevBlock(int); - /* 803161C4 */ void calcSizeIndBlock(int); - /* 803161D8 */ void calcSizePEBlock(u32, u32); + /* 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*); diff --git a/include/JSystem/J3DGraphBase/J3DPacket.h b/include/JSystem/J3DGraphBase/J3DPacket.h index 790e734825..0b80f6b50b 100644 --- a/include/JSystem/J3DGraphBase/J3DPacket.h +++ b/include/JSystem/J3DGraphBase/J3DPacket.h @@ -90,6 +90,9 @@ public: 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 { @@ -153,6 +156,7 @@ public: 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*); diff --git a/include/JSystem/J3DGraphBase/J3DShape.h b/include/JSystem/J3DGraphBase/J3DShape.h index ab571a668f..8ceaf59661 100644 --- a/include/JSystem/J3DGraphBase/J3DShape.h +++ b/include/JSystem/J3DGraphBase/J3DShape.h @@ -42,6 +42,12 @@ public: 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; @@ -94,6 +100,7 @@ public: 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; } diff --git a/include/JSystem/J3DGraphBase/J3DSys.h b/include/JSystem/J3DGraphBase/J3DSys.h index 01f882e3f4..fe25597bc0 100644 --- a/include/JSystem/J3DGraphBase/J3DSys.h +++ b/include/JSystem/J3DGraphBase/J3DSys.h @@ -90,6 +90,7 @@ struct J3DSys { 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; } diff --git a/include/JSystem/J3DGraphBase/J3DTevs.h b/include/JSystem/J3DGraphBase/J3DTevs.h index 5462140ce8..09081c5277 100644 --- a/include/JSystem/J3DGraphBase/J3DTevs.h +++ b/include/JSystem/J3DGraphBase/J3DTevs.h @@ -66,4 +66,7 @@ struct J3DTevSwapModeTable { 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 index 96ee30877a..27e7349dee 100644 --- a/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -82,6 +82,9 @@ struct J3DTexCoord : public J3DTexCoordInfo { *(J3DTexCoordInfo*)this = *param_1; } + u8 getTexGenMtx() { return mTexGenMtx & 0xff; } + u16 getTexMtxReg() { return mTexMtxReg & 0xff; } + void resetTexMtxReg() { mTexMtxReg = mTexGenMtx; } |
