summaryrefslogtreecommitdiff
path: root/include/JSystem/J2DGraph
diff options
context:
space:
mode:
authorTakaRikka <takarikka@outlook.com>2023-07-16 23:45:01 -0700
committerTakaRikka <takarikka@outlook.com>2023-07-16 23:45:01 -0700
commit0b60233fae3aee1d46ab8be3d6aba895bd61ef54 (patch)
tree0c3d81664e976877c7bf9797760b119a5630b112 /include/JSystem/J2DGraph
parent3e5903296fc3308a7199b3d7a55f320fd90c0c21 (diff)
parent8a579ec1613f78ec273516af265c02317cea6fc9 (diff)
Merge branch 'master' of https://github.com/zeldaret/tp into lv4floor
Diffstat (limited to 'include/JSystem/J2DGraph')
-rw-r--r--include/JSystem/J2DGraph/J2DGrafContext.h31
-rw-r--r--include/JSystem/J2DGraph/J2DMatBlock.h26
-rw-r--r--include/JSystem/J2DGraph/J2DOrthoGraph.h21
-rw-r--r--include/JSystem/J2DGraph/J2DTevs.h138
4 files changed, 185 insertions, 31 deletions
diff --git a/include/JSystem/J2DGraph/J2DGrafContext.h b/include/JSystem/J2DGraph/J2DGrafContext.h
index be64fcc38f..47b6cdaabc 100644
--- a/include/JSystem/J2DGraph/J2DGrafContext.h
+++ b/include/JSystem/J2DGraph/J2DGrafContext.h
@@ -9,23 +9,30 @@
class J2DGrafContext {
public:
- /* 802E8B08 */ J2DGrafContext(f32, f32, f32, f32);
- /* 802E90C0 */ void scissor(JGeometry::TBox2<f32> const&);
+ struct Blend {
+ /* 0x0 */ u8 mType;
+ /* 0x1 */ u8 mSrcFactor;
+ /* 0x2 */ u8 mDstFactor;
+ };
+
+
+ /* 802E8B08 */ J2DGrafContext(f32 x, f32 y, f32 width, f32 height);
+ /* 802E90C0 */ void scissor(JGeometry::TBox2<f32> const& bounds);
void setColor(JUtility::TColor c) { this->setColor(c, c, c, c); }
- /* 802E9118 */ void setColor(JUtility::TColor, JUtility::TColor, JUtility::TColor,
- JUtility::TColor);
+ /* 802E9118 */ void setColor(JUtility::TColor colorTL, JUtility::TColor colorTR,
+ JUtility::TColor colorBR, JUtility::TColor colorBL);
/* 802E9234 */ void setLineWidth(u8);
- /* 802E9260 */ void fillBox(JGeometry::TBox2<f32> const&);
- /* 802E9368 */ void drawFrame(JGeometry::TBox2<f32> const&);
- /* 802E9488 */ void line(JGeometry::TVec2<f32>, JGeometry::TVec2<f32>);
- /* 802E9564 */ void lineTo(JGeometry::TVec2<f32>);
+ /* 802E9260 */ void fillBox(JGeometry::TBox2<f32> const& box);
+ /* 802E9368 */ void drawFrame(JGeometry::TBox2<f32> const& box);
+ /* 802E9488 */ void line(JGeometry::TVec2<f32> start, JGeometry::TVec2<f32> end);
+ /* 802E9564 */ void lineTo(JGeometry::TVec2<f32> pos);
void lineTo(f32 x, f32 y) { this->lineTo(JGeometry::TVec2<f32>(x, y)); }
void moveTo(f32 x, f32 y) { this->moveTo(JGeometry::TVec2<f32>(x, y)); }
void moveTo(JGeometry::TVec2<f32> pos) { mPrevPos = pos; }
/* 802E95D4 */ virtual ~J2DGrafContext() {}
- /* 802E90E4 */ virtual void place(JGeometry::TBox2<f32> const&);
+ /* 802E90E4 */ virtual void place(JGeometry::TBox2<f32> const& bounds);
/* 802E961C */ virtual void place(f32 x, f32 y, f32 width, f32 height) {
JGeometry::TBox2<f32> box(x, y, x + width, y + height);
this->place(box);
@@ -47,9 +54,9 @@ public:
/* 0x38 */ JGeometry::TVec2<f32> mPrevPos;
/* 0x40 */ Mtx44 mMtx44;
/* 0x80 */ Mtx mPosMtx;
- /* 0xB0 */ J2DBlendInfo field_0xb0;
- /* 0xB3 */ J2DBlendInfo mLinePart;
- /* 0xB6 */ J2DBlendInfo mBoxPart;
+ /* 0xB0 */ Blend field_0xb0;
+ /* 0xB3 */ Blend mLinePart;
+ /* 0xB6 */ Blend mBoxPart;
};
#endif /* J2DGRAFCONTEXT_H */
diff --git a/include/JSystem/J2DGraph/J2DMatBlock.h b/include/JSystem/J2DGraph/J2DMatBlock.h
index 5b4466de38..1a036dc072 100644
--- a/include/JSystem/J2DGraph/J2DMatBlock.h
+++ b/include/JSystem/J2DGraph/J2DMatBlock.h
@@ -422,6 +422,11 @@ struct J2DAlphaComp {
mRef0 = 0;
mRef1 = 0;
}
+ u8 getComp0() { return mAlphaCmp >> 5 & 7; }
+ u8 getRef0() { return mRef0; }
+ u8 getOp() { return mAlphaCmp >> 3 & 3; }
+ u8 getComp1() { return mAlphaCmp & 7; }
+ u8 getRef1() { return mRef1; }
/* 0x0 */ u16 mAlphaCmp;
/* 0x2 */ u8 mRef0;
@@ -433,21 +438,26 @@ struct J2DBlendInfo {
mType = other.mType;
mSrcFactor = other.mSrcFactor;
mDstFactor = other.mDstFactor;
- // mOp = other.mOp;
+ mOp = other.mOp;
}
/* 0x0 */ u8 mType;
/* 0x1 */ u8 mSrcFactor;
/* 0x2 */ u8 mDstFactor;
+ /* 0x3 */ u8 mOp;
};
extern J2DBlendInfo j2dDefaultBlendInfo;
struct J2DBlend {
J2DBlend() { mBlendInfo = j2dDefaultBlendInfo; }
+ void setBlendInfo(const J2DBlendInfo& info) { mBlendInfo = info; }
+ u8 getType() { return mBlendInfo.mType; }
+ u8 getSrcFactor() { return mBlendInfo.mSrcFactor; }
+ u8 getDstFactor() { return mBlendInfo.mDstFactor; }
+ u8 getOp() { return mBlendInfo.mOp; }
/* 0x0 */ J2DBlendInfo mBlendInfo;
- /* 0x3 */ u8 mOp;
};
class J2DPEBlock {
@@ -532,17 +542,23 @@ public:
}; // Size: 0x48
struct J2DColorChanInfo {
- /* 0x0 */ u16 field_0x0;
+ /* 0x0 */ u8 field_0x0;
+ /* 0x0 */ u8 field_0x1;
};
+inline u8 J2DCalcColorChanID(u8 param_1) { return param_1; }
+
class J2DColorChan {
public:
/* 802EB280 */ J2DColorChan();
- u16 getMatSrc() const { return mColorChanInfo.field_0x0 & 1; }
+ void setColorChanInfo(const J2DColorChanInfo& info) {
+ mColorChan = J2DCalcColorChanID(info.field_0x1);
+ }
+ u16 getMatSrc() const { return mColorChan & 1; }
private:
- /* 0x0 */ J2DColorChanInfo mColorChanInfo;
+ /* 0x0 */ u16 mColorChan;
};
class J2DColorBlock {
diff --git a/include/JSystem/J2DGraph/J2DOrthoGraph.h b/include/JSystem/J2DGraph/J2DOrthoGraph.h
index f17459296c..8c31b878a1 100644
--- a/include/JSystem/J2DGraph/J2DOrthoGraph.h
+++ b/include/JSystem/J2DGraph/J2DOrthoGraph.h
@@ -7,8 +7,8 @@
class J2DOrthoGraph : public J2DGrafContext {
public:
/* 802E9670 */ J2DOrthoGraph();
- /* 802E96D0 */ J2DOrthoGraph(f32, f32, f32, f32, f32, f32);
- /* 802E980C */ void setOrtho(JGeometry::TBox2<f32> const&, f32, f32);
+ /* 802E96D0 */ J2DOrthoGraph(f32 x, f32 y, f32 width, f32 height, f32 far, f32 near);
+ /* 802E980C */ void setOrtho(JGeometry::TBox2<f32> const& bounds, f32 far, f32 near);
/* 802E987C */ void scissorBounds(JGeometry::TBox2<f32>*, JGeometry::TBox2<f32> const*);
/* 8000B118 */ virtual ~J2DOrthoGraph() {}
@@ -19,9 +19,9 @@ public:
f32 getWidthPower() const { return mBounds.getWidth() / mOrtho.getWidth(); }
f32 getHeightPower() const { return mBounds.getHeight() / mOrtho.getHeight(); }
- void setOrtho(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f32 param_4, f32 param_5) {
- JGeometry::TBox2<f32> ortho(param_0, param_1, param_0 + param_2, param_1 + param_3);
- setOrtho(ortho, param_4, param_5);
+ void setOrtho(f32 x, f32 y, f32 width, f32 height, f32 far, f32 near) {
+ JGeometry::TBox2<f32> ortho(x, y, x + width, y + height);
+ setOrtho(ortho, far, near);
}
private:
@@ -30,12 +30,11 @@ private:
/* 0xD0 */ f32 mFar;
};
-void J2DDrawLine(f32 param_0, f32 param_1, f32 param_2, f32 param_3, JUtility::TColor color,
+void J2DDrawLine(f32 x1, f32 y1, f32 x2, f32 y2, JUtility::TColor color,
int line_width);
-void J2DFillBox(f32 param_0, f32 param_1, f32 param_2, f32 param_3, JUtility::TColor color);
-void J2DFillBox(JGeometry::TBox2<f32> const& param_0, JUtility::TColor param_1);
-void J2DDrawFrame(f32 param_0, f32 param_1, f32 param_2, f32 param_3, JUtility::TColor param_4,
- u8 param_5);
-void J2DDrawFrame(JGeometry::TBox2<f32> const& param_0, JUtility::TColor param_1, u8 param_2);
+void J2DFillBox(f32 x, f32 y, f32 width, f32 height, JUtility::TColor color);
+void J2DFillBox(JGeometry::TBox2<f32> const& box, JUtility::TColor color);
+void J2DDrawFrame(f32 x, f32 y, f32 width, f32 height, JUtility::TColor color, u8 line_width);
+void J2DDrawFrame(JGeometry::TBox2<f32> const& box, JUtility::TColor color, u8 line_width);
#endif /* J2DORTHOGRAPH_H */
diff --git a/include/JSystem/J2DGraph/J2DTevs.h b/include/JSystem/J2DGraph/J2DTevs.h
index 63e0201b9c..6a561e9557 100644
--- a/include/JSystem/J2DGraph/J2DTevs.h
+++ b/include/JSystem/J2DGraph/J2DTevs.h
@@ -27,14 +27,25 @@ struct J2DTexMtxInfo {
/* 0x10 */ J2DTextureSRTInfo mTexSRTInfo;
GXTexMtxType getTexMtxType() const { return (GXTexMtxType)mTexMtxType; }
+ J2DTexMtxInfo& operator=(const J2DTexMtxInfo& other) {
+ mCenter = other.mCenter;
+ mTexMtxType = other.mTexMtxType;
+ mTexMtxDCC = other.mTexMtxDCC;
+ mTexSRTInfo = other.mTexSRTInfo;
+ return *this;
+ }
+
}; // Size: 0x24
class J2DTexMtx {
public:
+ J2DTexMtx(const J2DTexMtxInfo& info) { mInfo = info; }
/* 802E9C90 */ void load(u32);
/* 802E9CC4 */ void calc();
/* 802E9D2C */ void getTextureMtx(J2DTextureSRTInfo const&, Vec, f32 (*)[4]);
/* 802E9EBC */ void getTextureMtxMaya(J2DTextureSRTInfo const&, f32 (*)[4]);
+ J2DTexMtxInfo& getTexMtxInfo() { return mInfo; }
+ void setTexMtxInfo(J2DTexMtxInfo info) { mInfo = info; }
private:
/* 0x00 */ J2DTexMtxInfo mInfo;
@@ -45,6 +56,11 @@ struct J2DIndTexOrderInfo {
/* 0x0 */ u8 mTexCoordID;
/* 0x1 */ u8 mTexMapID;
+ J2DIndTexOrderInfo& operator=(const J2DIndTexOrderInfo& other) {
+ mTexCoordID = other.mTexCoordID;
+ mTexMapID = other.mTexMapID;
+ return *this;
+ }
GXTexCoordID getTexCoordID() const { return (GXTexCoordID)mTexCoordID; }
GXTexMapID getTexMapID() const { return (GXTexMapID)mTexMapID; }
};
@@ -61,6 +77,16 @@ private:
struct J2DIndTexMtxInfo {
/* 0x00 */ Mtx23 mMtx;
/* 0x18 */ s8 mScaleExp;
+
+ J2DIndTexMtxInfo& operator=(const J2DIndTexMtxInfo& other) {
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 3; j++) {
+ mMtx[i][j] = other.mMtx[i][j];
+ }
+ }
+ mScaleExp = other.mScaleExp;
+ return *this;
+ }
};
class J2DIndTexMtx {
@@ -77,8 +103,13 @@ private:
struct J2DIndTexCoordScaleInfo {
/* 0x0 */ u8 mScaleS;
- /* 0x0 */ u8 mScaleT;
+ /* 0x1 */ u8 mScaleT;
+ J2DIndTexCoordScaleInfo& operator=(const J2DIndTexCoordScaleInfo& other) {
+ mScaleS = other.mScaleS;
+ mScaleT = other.mScaleT;
+ return *this;
+ }
GXIndTexScale getScaleS() const { return (GXIndTexScale)mScaleS; }
GXIndTexScale getScaleT() const { return (GXIndTexScale)mScaleT; }
};
@@ -135,11 +166,22 @@ struct J2DTexCoordInfo {
/* 0x1 */ u8 mTexGenSrc;
/* 0x2 */ u8 mTexGenMtx;
u8 padding; // ?
+
+ J2DTexCoordInfo& operator=(const J2DTexCoordInfo& other) {
+ this->mTexGenType = other.mTexGenType;
+ this->mTexGenSrc = other.mTexGenSrc;
+ this->mTexGenMtx = other.mTexGenMtx;
+ return *this;
+ }
};
class J2DTexCoord {
public:
/* 802EB260 */ J2DTexCoord();
+ void setTexCoordInfo(const J2DTexCoordInfo& info) { mTexCoordInfo = info; }
+ s32 getTexGenType() { return mTexCoordInfo.mTexGenType; }
+ s32 getTexGenSrc() { return mTexCoordInfo.mTexGenSrc; }
+ s32 getTexGenMtx() { return mTexCoordInfo.mTexGenMtx; }
private:
/* 0x0 */ J2DTexCoordInfo mTexCoordInfo;
@@ -204,13 +246,98 @@ public:
}
void setTexSel(u8 param_0) {
- field_0x7 = (field_0x7 & ~12) | (param_0 * 4);
+ field_0x7 = (field_0x7 & ~0x0c) | (param_0 * 4);
}
void setRasSel(u8 param_0) {
- field_0x7 = (field_0x7 & ~3) | param_0;
+ field_0x7 = (field_0x7 & ~0x03) | param_0;
+ }
+
+ void setColorABCD(u8 param_0, u8 param_1, u8 param_2, u8 param_3) {
+ setTevColorAB(param_0, param_1);
+ setTevColorCD(param_2, param_3);
+ }
+
+ void setTevColorAB(u8 param_0, u8 param_1) { field_0x2 = param_0 << 4 | param_1; }
+ void setTevColorCD(u8 param_0, u8 param_1) { field_0x3 = param_0 << 4 | param_1; }
+
+ void setTevColorOp(u8 param_0, u8 param_1, u8 param_2, u8 param_3, u8 param_4) {
+ field_0x1 = field_0x1 & ~0x04 | param_0 << 2;
+ if (param_0 <= 1) {
+ field_0x1 = field_0x1 & ~0x30 | param_2 << 4;
+ field_0x1 = field_0x1 & ~0x03 | param_1;
+ } else {
+ field_0x1 = field_0x1 & ~0x30 | (param_0 >> 1 & 3) << 4;
+ field_0x1 = field_0x1 & ~0x03 | 3;
+ }
+ field_0x1 = field_0x1 & ~0x08 | param_3 << 3;
+ field_0x1 = field_0x1 & ~0xc0 | param_4 << 6;
}
+ void setAlphaABCD(u8 param_0, u8 param_1, u8 param_2, u8 param_3) {
+ setAlphaA(param_0);
+ setAlphaB(param_1);
+ setAlphaC(param_2);
+ setAlphaD(param_3);
+ }
+
+ void setAlphaA(u8 param_0) {
+ field_0x6 = field_0x6 & ~0xe0 | param_0 << 5;
+ }
+ void setAlphaB(u8 param_0) {
+ field_0x6 = field_0x6 & ~0x1c | param_0 << 2;
+ }
+ void setAlphaC(u8 param_0) {
+ field_0x6 = field_0x6 & ~0x03 | param_0 >> 1;
+ field_0x7 = field_0x7 & ~0x80 | param_0 << 7;
+ }
+ void setAlphaD(u8 param_0) {
+ field_0x7 = field_0x7 & ~0x70 | param_0 << 4;
+ }
+ void setTevAlphaOp(u8 param_0, u8 param_1, u8 param_2, u8 param_3, u8 param_4) {
+ field_0x5 = field_0x5 & ~0x04 | param_0 << 2;
+ if (param_0 <= 1) {
+ field_0x5 = field_0x5 & ~0x03 | param_1;
+ field_0x5 = field_0x5 & ~0x30 | param_2 << 4;
+ } else {
+ field_0x5 = field_0x5 & ~0x30 | (param_0 >> 1 & 3) << 4;
+ field_0x5 = field_0x5 & ~0x03 | 3;
+ }
+ field_0x5 = field_0x5 & ~0x08 | param_3 << 3;
+ field_0x5 = field_0x5 & ~0xc0 | param_4 << 6;
+ }
+
+ u8 getColorA() { return (field_0x2 & 0xf0) >> 4; }
+ u8 getColorB() { return field_0x2 & 0x0f; }
+ u8 getColorC() { return (field_0x3 & 0xf0) >> 4; }
+ u8 getColorD() { return field_0x3 & 0x0f; }
+ u8 getAlphaA() { return (field_0x6 & 0xe0) >> 5; }
+ u8 getAlphaB() { return (field_0x6 & 0x1c) >> 2; }
+ u8 getAlphaC() { return (field_0x6 & 0x03) << 1 | (field_0x7 & 0x80) >> 7; }
+ u8 getAlphaD() { return (field_0x7 & 0x70) >> 4; }
+ u8 getCOp() {
+ if (getCBias() != 3) {
+ return (field_0x1 & 4) >> 2;
+ }
+ return ((field_0x1 & 4) >> 2) + 8 + ((field_0x1 & 0x30) >> 3);
+ }
+ u8 getCBias() { return field_0x1 & 0x03; }
+ u8 getCScale() { return (field_0x1 & 0x30) >> 4; }
+ u8 getCClamp() { return (field_0x1 & 0x08) >> 3; }
+ u8 getCReg() { return (field_0x1 & 0xc0) >> 6; }
+ u8 getAOp() {
+ if (getABias() != 3) {
+ return (field_0x5 & 4) >> 2;
+ }
+ return ((field_0x5 & 4) >> 2) + 8 + ((field_0x5 & 0x30) >> 3);
+ }
+ u8 getABias() { return field_0x5 & 0x03; }
+ u8 getAScale() { return (field_0x5 & 0x30) >> 4; }
+ u8 getAClamp() { return (field_0x5 & 0x08) >> 3; }
+ u8 getAReg() { return (field_0x5 & 0xc0) >> 6; }
+ u8 getRasSel() { return field_0x7 & 3; }
+ u8 getTexSel() { return (field_0x7 & 0x0c) >> 2; }
+
void operator=(J2DTevStage const& other) {
field_0x1 = other.field_0x1;
field_0x2 = other.field_0x2;
@@ -235,6 +362,11 @@ class J2DTevSwapModeTable {
public:
/* 802F1934 */ J2DTevSwapModeTable();
+ u8 getR() { return field_0x0 >> 6 & 3; }
+ u8 getG() { return field_0x0 >> 4 & 3; }
+ u8 getB() { return field_0x0 >> 2 & 3; }
+ u8 getA() { return field_0x0 & 3; }
+
private:
/* 0x0 */ u8 field_0x0;
};