summaryrefslogtreecommitdiff
path: root/include/JSystem/J3DGraphBase
diff options
context:
space:
mode:
Diffstat (limited to 'include/JSystem/J3DGraphBase')
-rw-r--r--include/JSystem/J3DGraphBase/J3DMatBlock.h10
-rw-r--r--include/JSystem/J3DGraphBase/J3DMaterial.h2
-rw-r--r--include/JSystem/J3DGraphBase/J3DStruct.h2
-rw-r--r--include/JSystem/J3DGraphBase/J3DTevs.h109
-rw-r--r--include/JSystem/J3DGraphBase/J3DTexture.h6
5 files changed, 104 insertions, 25 deletions
diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h
index 4f8e8bf0aa..d488d0b703 100644
--- a/include/JSystem/J3DGraphBase/J3DMatBlock.h
+++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h
@@ -48,7 +48,7 @@ public:
/* 8000DFE8 */ virtual u32 getTexGenNum() const;
/* 8000E0CC */ virtual void setTexCoord(u32, J3DTexCoord const*);
/* 8000DFE0 */ virtual J3DTexCoord* getTexCoord(u32);
- /* 8003AB2C */ virtual void setTexMtx(u32, J3DTexMtx*);
+ /* 8003AB2C */ virtual void setTexMtx(u32, J3DTexMtx*) {}
/* 8000DFD8 */ virtual J3DTexMtx* getTexMtx(u32);
/* 80317424 */ virtual void setNBTScale(J3DNBTScale const*);
/* 80317420 */ virtual void setNBTScale(J3DNBTScale);
@@ -611,7 +611,7 @@ 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`
+// matches for `J3DMaterialFactory::newAlphaComp,J3DMaterialFactory_v21::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;
// }
@@ -794,7 +794,7 @@ struct J3DIndTexCoordScaleInfo {
/* 0x3 */ u8 field_0x3;
}; // Size: 0x4
-extern J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo;
+extern const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo;
struct J3DIndTexCoordScale : public J3DIndTexCoordScaleInfo {
/* 8000E0E4 */ J3DIndTexCoordScale() : J3DIndTexCoordScaleInfo(j3dDefaultIndTexCoordScaleInfo) {}
@@ -817,7 +817,7 @@ struct J3DIndTexOrderInfo {
/* 0x3 */ u8 field_0x3;
}; // Size: 0x04
-extern J3DIndTexOrderInfo j3dDefaultIndTexOrderNull;
+extern const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull;
struct J3DIndTexOrder : public J3DIndTexOrderInfo {
/* 8000E128 */ J3DIndTexOrder() : J3DIndTexOrderInfo(j3dDefaultIndTexOrderNull) {}
@@ -895,7 +895,7 @@ struct J3DColorChanInfo {
/* 0x6 */ u8 pad[2];
};
-extern J3DColorChanInfo j3dDefaultColorChanInfo;
+extern const J3DColorChanInfo j3dDefaultColorChanInfo;
/* static inline u32 setChanCtrlMacro(u8 param_0, GXColorSrc param_1, GXColorSrc param_2, u32 param_3, GXDiffuseFn param_4, GXAttnFn param_5) {
diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h
index c7838fb96e..fd9fce606a 100644
--- a/include/JSystem/J3DGraphBase/J3DMaterial.h
+++ b/include/JSystem/J3DGraphBase/J3DMaterial.h
@@ -72,11 +72,13 @@ public:
void onInvalid() { mInvalid = 1; }
u32 getTexGenNum() const { return mTexGenBlock->getTexGenNum(); }
u8 getTevStageNum() const { return mTevBlock->getTevStageNum(); }
+ J3DTexCoord* getTexCoord(u32 idx) { return mTexGenBlock->getTexCoord(idx); }
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); }
+ void setTexMtx(u32 idx, J3DTexMtx* mtx) { mTexGenBlock->setTexMtx(idx, mtx); }
public:
/* 0x04 */ J3DMaterial* mNext;
diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h
index e0e23f6379..13e097cf3e 100644
--- a/include/JSystem/J3DGraphBase/J3DStruct.h
+++ b/include/JSystem/J3DGraphBase/J3DStruct.h
@@ -66,6 +66,8 @@ struct J3DTexMtxInfo {
/* 0x00 */ u8 mProjection;
/* 0x01 */ u8 mInfo;
+ /* 0x02 */ u8 field_0x2;
+ /* 0x03 */ u8 field_0x3;
/* 0x04 */ Vec mCenter;
/* 0x10 */ J3DTextureSRTInfo mSRT;
/* 0x24 */ Mtx44 mEffectMtx;
diff --git a/include/JSystem/J3DGraphBase/J3DTevs.h b/include/JSystem/J3DGraphBase/J3DTevs.h
index 35bfd28691..6453019814 100644
--- a/include/JSystem/J3DGraphBase/J3DTevs.h
+++ b/include/JSystem/J3DGraphBase/J3DTevs.h
@@ -12,16 +12,101 @@ struct J3DTevStageInfo {
/* 0x5 */ u8 mTevAlphaOp;
/* 0x6 */ u8 mTevAlphaAB;
/* 0x7 */ u8 mTevSwapModeInfo;
- /* 0x8 */ u8 field_0x8[0xc];
+ /* 0x8 */ u8 field_0x8;
+ /* 0x8 */ u8 field_0x9;
+ /* 0x8 */ u8 field_0xa;
+ /* 0x8 */ u8 field_0xb;
+ /* 0x8 */ u8 field_0xc;
+ /* 0x8 */ u8 field_0xd;
+ /* 0x8 */ u8 field_0xe;
+ /* 0x8 */ u8 field_0xf;
+ /* 0x8 */ u8 field_0x10;
+ /* 0x8 */ u8 field_0x11;
+ /* 0x8 */ u8 field_0x12;
+ /* 0x8 */ u8 field_0x13;
};
extern J3DTevStageInfo const j3dDefaultTevStageInfo;
+struct J3DTevSwapModeTableInfo {
+ /* 0x0 */ u8 field_0x0;
+ /* 0x1 */ u8 field_0x1;
+ /* 0x2 */ u8 field_0x2;
+ /* 0x3 */ u8 field_0x3;
+}; // Size: 0x4
+
+extern const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable;
+
+struct J3DTevSwapModeInfo {
+ /* 0x0 */ u8 mRasSel;
+ /* 0x1 */ u8 mTexSel;
+ /* 0x2 */ u8 field_0x2;
+ /* 0x3 */ u8 field_0x3;
+}; // Size: 0x4
+
+extern J3DTevSwapModeInfo const j3dDefaultTevSwapMode;
+
struct J3DTevStage {
/* 8000E230 */ J3DTevStage();
- /* 8000E298 */ void setTevStageInfo(J3DTevStageInfo const&);
- /* 8003AACC */ J3DTevStage(J3DTevStageInfo const&);
+ void setTevColorOp(u8 param_1, u8 param_2, u8 param_3, u8 param_4, u8 param_5) {
+ mTevColorOp = mTevColorOp & ~(0x01 << 2) | param_1 << 2;
+ if (param_1 <= 1) {
+ mTevColorOp = mTevColorOp & ~(0x03 << 4) | param_3 << 4;
+ mTevColorOp = mTevColorOp & ~0x03 | param_2;
+ } else {
+ mTevColorOp = mTevColorOp & ~(0x03 << 4) | (param_1 >> 1 & 3) << 4;
+ mTevColorOp = mTevColorOp & ~0x03 | 3;
+ }
+ mTevColorOp = mTevColorOp & ~(0x01 << 3) | param_4 << 3;
+ mTevColorOp = mTevColorOp & ~(0x03 << 6) | param_5 << 6;
+ }
+
+ void setTevColorAB(u8 a, u8 b) { mTevColorAB = a << 4 | b; }
+ void setTevColorCD(u8 c, u8 d) { mTevColorCD = c << 4 | d; }
+ void setAlphaA(u8 a) { mTevAlphaAB = mTevAlphaAB & ~(0x07 << 5) | a << 5; }
+ void setAlphaB(u8 b) { mTevAlphaAB = mTevAlphaAB & ~(0x07 << 2) | b << 2; }
+ void setAlphaC(u8 c) {
+ mTevAlphaAB = mTevAlphaAB & ~0x03 | c >> 1;
+ mTevSwapModeInfo = mTevSwapModeInfo & ~(0x01 << 7) | c << 7;
+ }
+ void setAlphaD(u8 d) { mTevSwapModeInfo = mTevSwapModeInfo & ~(0x07 << 4) | d << 4; }
+ void setAlphaABCD(u8 a, u8 b, u8 c, u8 d) {
+ setAlphaA(a);
+ setAlphaB(b);
+ setAlphaC(c);
+ setAlphaD(d);
+ }
+
+ void setTevAlphaOp(u8 param_1, u8 param_2, u8 param_3, u8 param_4, u8 param_5) {
+ mTevAlphaOp = mTevAlphaOp & ~(0x01 << 2) | param_1 << 2;
+ if (param_1 <= 1) {
+ mTevAlphaOp = mTevAlphaOp & ~0x03 | param_2;
+ mTevAlphaOp = mTevAlphaOp & ~(0x03 << 4) | param_3 << 4;
+ } else {
+ mTevAlphaOp = mTevAlphaOp & ~(0x03 << 4) | (param_1 >> 1 & 3) << 4;
+ mTevAlphaOp = mTevAlphaOp & ~0x03 | 3;
+ }
+ mTevAlphaOp = mTevAlphaOp & ~(0x01 << 3) | param_4 << 3;
+ mTevAlphaOp = mTevAlphaOp & ~(0x03 << 6) | param_5 << 6;
+ }
+
+ void setTevStageInfo(const J3DTevStageInfo& info) {
+ setTevColorOp(info.mTevAlphaOp, info.mTevAlphaAB, info.mTevSwapModeInfo, info.field_0x8, info.field_0x9);
+ setTevColorAB(info.mTevColorOp, info.mTevColorAB);
+ setTevColorCD(info.mTevColorCD, info.field_0x4);
+ setAlphaABCD(info.field_0xa, info.field_0xb, info.field_0xc, info.field_0xd);
+ setTevAlphaOp(info.field_0xe, info.field_0xf, info.field_0x10, info.field_0x11, info.field_0x12);
+ }
+ /* 8003AACC */ J3DTevStage(J3DTevStageInfo const& param_0) {
+ setTevStageInfo(param_0);
+ setTevSwapModeInfo(j3dDefaultTevSwapMode);
+ }
+
+ void setTevSwapModeInfo(J3DTevSwapModeInfo const& param_0) {
+ setTexSel(param_0.mTexSel);
+ setRasSel(param_0.mRasSel);
+ }
void setRasSel(u8 ras_sel) { mTevSwapModeInfo = (mTevSwapModeInfo & ~3) | ras_sel; }
void setTexSel(u8 tex_sel) { mTevSwapModeInfo = (mTevSwapModeInfo & ~0xc) | (tex_sel << 2); }
@@ -88,7 +173,7 @@ struct J3DTevOrderInfo {
/* 0x3 */ u8 field_0x3; // Maybe padding
};
-extern J3DTevOrderInfo j3dDefaultTevOrderInfoNull;
+extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull;
struct J3DTevOrder : public J3DTevOrderInfo {
/* 8000E140 */ J3DTevOrder() : J3DTevOrderInfo(j3dDefaultTevOrderInfoNull) {}
@@ -97,15 +182,6 @@ struct J3DTevOrder : public J3DTevOrderInfo {
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) {
@@ -118,13 +194,6 @@ struct J3DTevSwapModeTable {
/* 0x0 */ u8 field_0x0;
}; // Size: 0x1
-struct J3DTevSwapModeInfo {
- /* 0x0 */ u8 mRasSel;
- /* 0x1 */ u8 mTexSel;
- /* 0x2 */ u8 field_0x2;
- /* 0x3 */ u8 field_0x3;
-}; // Size: 0x4
-
struct J3DNBTScale;
struct J3DTexCoord;
void loadNBTScale(J3DNBTScale& param_0);
diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h
index c0741a4d0a..6deb7e563f 100644
--- a/include/JSystem/J3DGraphBase/J3DTexture.h
+++ b/include/JSystem/J3DGraphBase/J3DTexture.h
@@ -28,8 +28,13 @@ public:
}
};
+extern J3DTexMtxInfo const j3dDefaultTexMtxInfo;
+
class J3DTexMtx {
public:
+ J3DTexMtx() {
+ mTexMtxInfo = j3dDefaultTexMtxInfo;
+ }
J3DTexMtx(const J3DTexMtxInfo& info) {
mTexMtxInfo = info;
}
@@ -75,6 +80,7 @@ struct J3DTexCoord : public J3DTexCoordInfo {
u8 getTexGenSrc() { return mTexGenSrc; }
u8 getTexGenMtx() { return mTexGenMtx & 0xff; }
u16 getTexMtxReg() { return mTexMtxReg & 0xff; }
+ void setTexGenMtx(u8 param_1) { mTexGenMtx = param_1; }
void resetTexMtxReg() {
mTexMtxReg = mTexGenMtx;