Skip to content

Commit

Permalink
Merge pull request #496 from Jcw87/J3DTevs
Browse files Browse the repository at this point in the history
J3DTevs
  • Loading branch information
magcius authored Sep 30, 2023
2 parents afda360 + 8888b85 commit 836bf25
Show file tree
Hide file tree
Showing 10 changed files with 429 additions and 167 deletions.
33 changes: 0 additions & 33 deletions include/JSystem/J3DGraphBase/J3DMatBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ struct J3DGXColor : public GXColor {
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:
virtual void reset(J3DTexGenBlock*);
Expand Down Expand Up @@ -536,8 +525,6 @@ class J3DTevBlock1 : public J3DTevBlock {
/* 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;
}
Expand Down Expand Up @@ -568,15 +555,6 @@ struct J3DZMode {
/* 0x0 */ u16 mZModeID;
};

struct J3DBlendInfo {
/* 0x0 */ u8 mType;
/* 0x1 */ u8 mSrcFactor;
/* 0x2 */ u8 mDstFactor;
/* 0x3 */ u8 mOp;
};

extern const J3DBlendInfo j3dDefaultBlendInfo;

struct J3DBlend : public J3DBlendInfo {
J3DBlend() { *(J3DBlendInfo*)this = j3dDefaultBlendInfo; }

Expand Down Expand Up @@ -613,8 +591,6 @@ struct J3DAlphaCompInfo {
/* 0x7 */ u8 field_0x7;
};

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);
}
Expand Down Expand Up @@ -892,15 +868,6 @@ class J3DIndBlockNull : public J3DIndBlock {
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;
};

/*
inline u32 setChanCtrlMacro(u8 param_0, GXColorSrc param_1, GXColorSrc param_2, u32 param_3, GXDiffuseFn param_4, GXAttnFn param_5) {
GXDiffuseFn r31;
Expand Down
115 changes: 96 additions & 19 deletions include/JSystem/J3DGraphBase/J3DStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ class J3DLightInfo {
/* 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;
Expand All @@ -47,10 +30,11 @@ struct J3DTexMtxInfo {
/* 80325794 */ void setEffectMtx(Mtx);

/* 0x00 */ u8 mProjection;
/* 0x01 */ s8 mInfo;
/* 0x01 */ u8 mInfo;
/* 0x02 */ u8 padding[2];
/* 0x04 */ Vec mCenter;
/* 0x10 */ J3DTextureSRTInfo mSRT;
/* 0x24 */ Mtx44 mEffectMtx;
/* 0x24 */ Mtx44 mEffectMtx;
}; // Size: 0x64

struct J3DIndTexMtxInfo {
Expand All @@ -77,4 +61,97 @@ struct J3DNBTScaleInfo {
inline void operator=(const J3DNBTScaleInfo & other) { mbHasScale = other.mbHasScale; mScale = other.mScale; }
}; // Size: 0x10

struct J3DIndTexOrderInfo {
/* 0x0 */ u8 mCoord;
/* 0x1 */ u8 mMap;
/* 0x2 */ u8 field_0x2;
/* 0x3 */ u8 field_0x3;
};

struct J3DTevSwapModeInfo {
/* 0x0 */ u8 field_0x0;
/* 0x1 */ u8 field_0x1;
};

struct J3DTevSwapModeTableInfo {
/* 0x0 */ u8 field_0x0;
/* 0x1 */ u8 field_0x1;
/* 0x2 */ u8 field_0x2;
/* 0x3 */ u8 field_0x3;
};

struct J3DTevStageInfo {
/* 0x0 */ u8 field_0x0;
/* 0x1 */ u8 field_0x1;
/* 0x2 */ u8 field_0x2;
/* 0x3 */ u8 field_0x3;
/* 0x4 */ u8 field_0x4;
/* 0x5 */ u8 field_0x5;
/* 0x6 */ u8 field_0x6;
/* 0x7 */ u8 field_0x7;
/* 0x8 */ u8 field_0x8;
/* 0x9 */ u8 field_0x9;
/* 0xA */ u8 field_0xa;
/* 0xB */ u8 field_0xb;
/* 0xC */ u8 field_0xc;
/* 0xD */ u8 field_0xd;
/* 0xE */ u8 field_0xe;
/* 0xF */ u8 field_0xf;
/* 0x10 */ u8 field_0x10;
/* 0x11 */ u8 field_0x11;
/* 0x12 */ u8 field_0x12;
/* 0x13 */ u8 field_0x13;
};

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 J3DTexCoordInfo {
/* 0x0 */ u8 mTexGenType __attribute__((aligned(4)));
/* 0x1 */ u8 mTexGenSrc;
/* 0x2 */ u8 mTexGenMtx;
};

struct J3DIndTexCoordScaleInfo {
/* 0x0 */ u8 mScaleS;
/* 0x1 */ u8 mScaleT;
/* 0x2 */ u8 field_0x2;
/* 0x3 */ u8 field_0x3;
};

struct J3DBlendInfo {
/* 0x0 */ u8 mType;
/* 0x1 */ u8 mSrcFactor;
/* 0x2 */ u8 mDstFactor;
/* 0x3 */ u8 mOp;
};

struct J3DTevOrderInfo {
/* 0x0 */ u8 mTexCoord __attribute__((aligned(2)));
/* 0x1 */ u8 mTexMap;
/* 0x2 */ u8 mColorChan;
};

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;
/* 0x6 */ u8 field_0x6;
/* 0x7 */ u8 field_0x7;
};

STATIC_ASSERT(sizeof(J3DTevStageInfo) == 0x14);

#endif /* J3DSTRUCT_H */
95 changes: 48 additions & 47 deletions include/JSystem/J3DGraphBase/J3DTevs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@
#define J3DTEVS_H

#include "JSystem/J3DGraphBase/J3DGD.h"
#include "JSystem/J3DGraphBase/J3DStruct.h"

extern u8 j3dTevSwapTableTable[1024];

struct J3DTevStageInfo {
/* 0x0 */ u8 field_0x0;
/* 0x1 */ u8 field_0x1;
/* 0x2 */ u8 field_0x2;
/* 0x3 */ u8 field_0x3;
/* 0x4 */ u8 field_0x4;
/* 0x5 */ u8 field_0x5;
/* 0x6 */ u8 field_0x6;
/* 0x7 */ u8 field_0x7;
/* 0x8 */ u8 field_0x8;
/* 0x9 */ u8 field_0x9;
/* 0xA */ u8 field_0xa;
/* 0xB */ u8 field_0xb;
/* 0xC */ u8 field_0xc;
/* 0xD */ u8 field_0xd;
/* 0xE */ u8 field_0xe;
/* 0xF */ u8 field_0xf;
/* 0x10 */ u8 field_0x10;
/* 0x11 */ u8 field_0x11;
/* 0x12 */ u8 field_0x12;
/* 0x13 */ u8 field_0x13;
};

STATIC_ASSERT(sizeof(J3DTevStageInfo) == 0x14);
extern const J3DLightInfo j3dDefaultLightInfo;
extern const J3DTexCoordInfo j3dDefaultTexCoordInfo[8];
extern const J3DTexMtxInfo j3dDefaultTexMtxInfo;
extern const J3DIndTexMtxInfo j3dDefaultIndTexMtxInfo;
extern const J3DTevStageInfo j3dDefaultTevStageInfo;
extern const J3DIndTevStageInfo j3dDefaultIndTevStageInfo;
extern const J3DFogInfo j3dDefaultFogInfo;
extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo;

extern const GXColor j3dDefaultColInfo;
extern const GXColor j3dDefaultAmbInfo;
extern const u8 j3dDefaultColorChanNum;
extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull;
extern const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull;
extern const GXColorS10 j3dDefaultTevColor;
extern const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo;
extern const GXColor j3dDefaultTevKColor;
extern const J3DTevSwapModeInfo j3dDefaultTevSwapMode;
extern const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable;
extern const J3DBlendInfo j3dDefaultBlendInfo;
extern const J3DColorChanInfo j3dDefaultColorChanInfo;
extern const u16 j3dDefaultTevSwapTableID;
extern const u16 j3dDefaultAlphaCmpID;
extern const u16 j3dDefaultZModeID;

struct J3DTevStageTevSwapModeInfo {
u8 field_0x0_29 : 2;
Expand All @@ -37,8 +38,7 @@ struct J3DTevStageTevSwapModeInfo {

struct J3DTevStage {
J3DTevStage() {
// TODO
// setTevStageInfo(j3dDefaultTevStageInfo);
setTevStageInfo(j3dDefaultTevStageInfo);
mTevSwapModeInfo.field_0x0_29 = 0;
mTevSwapModeInfo.field_0x0_31 = 0;
}
Expand Down Expand Up @@ -74,18 +74,6 @@ struct J3DTevStage {
/* 0x7 */ J3DTevStageTevSwapModeInfo mTevSwapModeInfo;
};

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 {
J3DIndTevStage();

Expand All @@ -96,12 +84,6 @@ struct J3DIndTevStage {
/* 0x0 */ u32 mInfo;
};

struct J3DTevOrderInfo {
/* 0x0 */ u8 mTexCoord __attribute__((aligned(2)));
/* 0x1 */ u8 mTexMap;
/* 0x2 */ u8 mColorChan;
};

struct J3DTevOrder : public J3DTevOrderInfo {
J3DTevOrder();

Expand All @@ -120,11 +102,30 @@ struct J3DTevSwapModeTable {
/* 0x0 */ u8 field_0x0;
}; // Size: 0x1

struct J3DTevSwapModeInfo {
/* 0x0 */ u8 field_0x0;
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 J3DNBTScale : public J3DNBTScaleInfo {
J3DNBTScale() {}
J3DNBTScale(J3DNBTScaleInfo const& info) {
mbHasScale = info.mbHasScale;
mScale = info.mScale;
}
Vec* getScale() { return &mScale; }
};

struct J3DNBTScale;
class J3DTexCoord;
void loadTexCoordGens(u32, J3DTexCoord*);
void loadNBTScale(J3DNBTScale& param_0);
Expand Down
20 changes: 5 additions & 15 deletions include/JSystem/J3DGraphBase/J3DTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class J3DTexMtx {
GDOverflowCheck(53);
J3DGDLoadTexMtxImm((Mtx&)mMtx, i * 3 + 30, (GXTexMtxType)mTexMtxInfo.mProjection);
};
void calc(f32 const (*)[4]);
void calc();
void calcTexMtx(f32 const (*)[4]);
void calcPostTexMtx(f32 const (*)[4]);
void loadTexMtx(u32) const;
Expand All @@ -71,26 +71,16 @@ class J3DTexMtx {
private:
/* 0x00 */ J3DTexMtxInfo mTexMtxInfo;
/* 0x64 */ Mtx mMtx;
}; // Size: 0x94

struct J3DTexCoordInfo {
/* 0x0 */ u8 mTexGenType __attribute__((aligned(4)));
/* 0x1 */ u8 mTexGenSrc;
/* 0x2 */ u8 mTexGenMtx;
};
/* 0x94 */ Mtx field_0x94;
}; // Size: 0xc4

struct J3DTexCoord : public J3DTexCoordInfo {
J3DTexCoord();

u8 getTexGenType() { return mTexGenType; }
u8 getTexGenSrc() { return mTexGenSrc; }
u8 getTexGenMtx() { return mTexGenMtx & 0xff; }
void setTexGenMtx(u8 v) { mTexGenMtx = v; }
}; // Size: 0x4

struct J3DDefaultTexCoordInfo {
/* 0x0 */ u8 mTexGenType;
/* 0x1 */ u8 mTexGenSrc;
/* 0x2 */ u8 mTexGenMtx;
/* 0x3 */ u8 pad;
};

#endif /* J3DTEXTURE_H */
Loading

0 comments on commit 836bf25

Please sign in to comment.