diff options
| author | TakaRikka <takarikka@outlook.com> | 2023-07-16 23:45:01 -0700 |
|---|---|---|
| committer | TakaRikka <takarikka@outlook.com> | 2023-07-16 23:45:01 -0700 |
| commit | 0b60233fae3aee1d46ab8be3d6aba895bd61ef54 (patch) | |
| tree | 0c3d81664e976877c7bf9797760b119a5630b112 /include/JSystem | |
| parent | 3e5903296fc3308a7199b3d7a55f320fd90c0c21 (diff) | |
| parent | 8a579ec1613f78ec273516af265c02317cea6fc9 (diff) | |
Merge branch 'master' of https://github.com/zeldaret/tp into lv4floor
Diffstat (limited to 'include/JSystem')
| -rw-r--r-- | include/JSystem/J2DGraph/J2DGrafContext.h | 31 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DMatBlock.h | 26 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DOrthoGraph.h | 21 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DTevs.h | 138 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DJointTree.h | 3 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DModel.h | 1 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DModelData.h | 7 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h | 5 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DSkinDeform.h | 45 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DShape.h | 1 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DShapeDraw.h | 1 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DTransform.h | 193 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DVertex.h | 24 | ||||
| -rw-r--r-- | include/JSystem/JGeometry.h | 32 | ||||
| -rw-r--r-- | include/JSystem/JParticle/JPAParticle.h | 4 |
15 files changed, 479 insertions, 53 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; }; diff --git a/include/JSystem/J3DGraphAnimator/J3DJointTree.h b/include/JSystem/J3DGraphAnimator/J3DJointTree.h index dc74089af3..3697cdb62b 100644 --- a/include/JSystem/J3DGraphAnimator/J3DJointTree.h +++ b/include/JSystem/J3DGraphAnimator/J3DJointTree.h @@ -45,13 +45,14 @@ public: u16 getJointNum() const { return mJointNum; } u16 getDrawMtxNum() const { return mDrawMtxData.mEntryNum; } u8 getDrawMtxFlag(u16 idx) const { return mDrawMtxData.mDrawMtxFlag[idx]; } - u8 getDrawMtxIndex(u16 idx) const { return mDrawMtxData.mDrawMtxIndex[idx]; } + u16 getDrawMtxIndex(u16 idx) const { return mDrawMtxData.mDrawMtxIndex[idx]; } JUTNameTab* getJointName() const { return mJointName; } J3DJoint* getRootNode() { return mRootNode; } J3DJoint* getJointNodePointer(u16 idx) const { return mJointNodePointer[idx]; } J3DMtxCalc* getBasicMtxCalc() const { return mBasicMtxCalc; } Mtx& getInvJointMtx(s32 idx) const { return mInvJointMtx[idx]; } u32 getModelDataType() const { return mModelDataType; } + bool checkFlag(u32 flag) { return mFlags & flag; } private: /* 0x04 */ J3DModelHierarchy* mHierarchy; diff --git a/include/JSystem/J3DGraphAnimator/J3DModel.h b/include/JSystem/J3DGraphAnimator/J3DModel.h index 80176968f8..d5610fc11b 100644 --- a/include/JSystem/J3DGraphAnimator/J3DModel.h +++ b/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -79,6 +79,7 @@ public: J3DVertexBuffer* getVertexBuffer() const { return (J3DVertexBuffer*)&mVertexBuffer; } J3DMatPacket* getMatPacket(u16 idx) const { return &mMatPacket[idx]; } J3DShapePacket* getShapePacket(u16 idx) const { return &mShapePacket[idx]; } + J3DMtxBuffer* getMtxBuffer() const { return mMtxBuffer; } Mtx33* getBumpMtxPtr(int idx) const { return mMtxBuffer->getBumpMtxPtr(idx); } Mtx33* getNrmMtxPtr() const { return mMtxBuffer->getNrmMtxPtr(); } Mtx* getDrawMtxPtr() const { return mMtxBuffer->getDrawMtxPtr(); } diff --git a/include/JSystem/J3DGraphAnimator/J3DModelData.h b/include/JSystem/J3DGraphAnimator/J3DModelData.h index 441b2fdebd..ca2d8ee971 100644 --- a/include/JSystem/J3DGraphAnimator/J3DModelData.h +++ b/include/JSystem/J3DGraphAnimator/J3DModelData.h @@ -34,6 +34,10 @@ public: J3DMaterial* getMaterialNodePointer(u16 idx) const { return mMaterialTable.getMaterialNodePointer(idx); } + u32 getVtxNum() const { return mVertexData.getVtxNum(); } + u32 getNrmNum() const { return mVertexData.getNrmNum(); } + u8 getDrawMtxFlag(u16 idx) const { return mJointTree.getDrawMtxFlag(idx); } + u16 getDrawMtxIndex(u16 idx) const { return mJointTree.getDrawMtxIndex(idx); } J3DShape* getShapeNodePointer(u16 idx) const { return mShapeTable.getShapeNodePointer(idx); } J3DJoint* getJointNodePointer(u16 idx) const { return mJointTree.getJointNodePointer(idx); } J3DJointTree& getJointTree() { return mJointTree; } @@ -42,6 +46,9 @@ public: J3DTexture* getTexture() const { return mMaterialTable.getTexture(); } JUTNameTab* getTextureName() const { return mMaterialTable.getTextureName(); } u16 getWEvlpMtxNum() const { return mJointTree.getWEvlpMtxNum(); } + u16* getWEvlpMixMtxIndex() const { return mJointTree.getWEvlpMixIndex(); } + f32* getWEvlpMixWeight() const { return mJointTree.getWEvlpMixWeight(); } + u8 getWEvlpMixMtxNum(u16 idx) const { return mJointTree.getWEvlpMixMtxNum(idx); } u32 getModelDataType() const { return mJointTree.getModelDataType(); } void* getVtxPosArray() const { return mVertexData.getVtxPosArray(); } void* getVtxNrmArray() const { return mVertexData.getVtxNrmArray(); } diff --git a/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h b/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h index c709985d7c..4aece3b46d 100644 --- a/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h +++ b/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h @@ -26,11 +26,13 @@ public: MtxP getAnmMtx(int idx) const { return mpAnmMtx[idx]; } void setAnmMtx(int i, Mtx m) { PSMTXCopy(m, (MtxP)mpAnmMtx[i]); } + MtxP getWeightAnmMtx(int idx) const { return mpWeightEvlpMtx[idx]; } void setScaleFlag(int idx, u8 flag) { mpScaleFlagArr[idx] = flag; } u32* getCurrentViewNoPtr() { return &mCurrentViewNo; } u8* getScaleFlagArray() const { return mpScaleFlagArr; } - u8 getScaleFlag(u16 idx) const { return mpScaleFlagArr[idx]; } + u8 getScaleFlag(int idx) const { return mpScaleFlagArr[idx]; } + u8 getEnvScaleFlag(int idx) const { return mpEvlpScaleFlagArr[idx]; } Mtx** getDrawMtxPtrPtr() const { return mpDrawMtxArr[1]; } Mtx* getDrawMtxPtr() const { return mpDrawMtxArr[1][mCurrentViewNo]; } Mtx* getDrawMtx(u16 idx) const { return &mpDrawMtxArr[1][mCurrentViewNo][idx]; } @@ -39,6 +41,7 @@ public: Mtx33* getNrmMtx(u16 idx) const { return &mpNrmMtxArr[1][mCurrentViewNo][idx]; } Mtx33*** getBumpMtxPtrPtr() const { return mpBumpMtxArr[1]; } Mtx33* getBumpMtxPtr(int idx) const { return mpBumpMtxArr[1][idx][mCurrentViewNo]; } + J3DJointTree* getJointTree() const { return mJointTree; } void swapDrawMtx() { Mtx* tmp = mpDrawMtxArr[0][mCurrentViewNo]; diff --git a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h index 63d138b1c2..520e0f67fd 100644 --- a/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h +++ b/include/JSystem/J3DGraphAnimator/J3DSkinDeform.h @@ -5,6 +5,7 @@ #include "JSystem/J3DGraphAnimator/J3DModelData.h" #include "JSystem/J3DGraphAnimator/J3DMtxBuffer.h" #include "JSystem/J3DGraphBase/J3DVertex.h" +#include "JSystem/J3DGraphBase/J3DTransform.h" #include "dolphin/types.h" class J3DModel; @@ -38,10 +39,10 @@ struct J3DSkinNList { /* 8032C85C */ void calcSkin_VtxPosF32(f32 (*)[4], void*, void*); /* 8032C8E4 */ void calcSkin_VtxNrmF32(f32 (*)[4], void*, void*); - /* 0x00 */ int field_0x0; - /* 0x04 */ int field_0x4; - /* 0x08 */ int field_0x8; - /* 0x0C */ int field_0xc; + /* 0x00 */ u16* field_0x0; + /* 0x04 */ u16* field_0x4; + /* 0x08 */ f32* field_0x8; + /* 0x0C */ f32* field_0xc; /* 0x10 */ u16 field_0x10; /* 0x12 */ u16 field_0x12; }; // Size: 0x14 @@ -50,7 +51,7 @@ class J3DSkinDeform { public: /* 8032C96C */ J3DSkinDeform(); /* 8032C9B0 */ void initSkinInfo(J3DModelData*); - /* 8032CF44 */ void initMtxIndexArray(J3DModelData*); + /* 8032CF44 */ int initMtxIndexArray(J3DModelData*); /* 8032D378 */ void changeFastSkinDL(J3DModelData*); /* 8032D5C4 */ void calcNrmMtx(J3DMtxBuffer*); /* 8032D738 */ void transformVtxPosNrm(J3DModelData*); @@ -62,25 +63,32 @@ public: /* 8032DDB8 */ void deformVtxNrm_F32(J3DVertexBuffer*) const; /* 8032DEBC */ void deformVtxNrm_S16(J3DVertexBuffer*) const; /* 8032DFDC */ void deform(J3DModel*); + void setNrmMtx(int i, MtxP mtx) { + J3DPSMtx33CopyFrom34(mtx, (Mtx3P)mNrmMtx[i]); + } + Mtx3P getNrmMtx(int i) { return mNrmMtx[i]; } + void onFlag(u32 flag) { mFlags |= flag; } + void offFlag(u32 flag) { mFlags &= ~flag; } + bool checkFlag(u32 flag) { return mFlags & flag; } /* 8032E064 */ virtual void deform(J3DVertexBuffer*, J3DMtxBuffer*); /* 8032E1B0 */ virtual ~J3DSkinDeform(); - static u8 sWorkArea_WEvlpMixMtx[4096]; - static u8 sWorkArea_WEvlpMixWeight[4096]; - static u8 sWorkArea_MtxReg[2048 + 8 /* padding */]; + static u16* sWorkArea_WEvlpMixMtx[1024]; + static f32* sWorkArea_WEvlpMixWeight[1024]; + static u16 sWorkArea_MtxReg[1024 + 4 /* padding */]; private: - /* 0x04 */ void** mPosData; - /* 0x08 */ void** field_0x8; - /* 0x0C */ void** field_0xc; - /* 0x10 */ Mtx** mNrmMtx; + /* 0x04 */ u16* mPosData; + /* 0x08 */ u16* mNrmData; + /* 0x0C */ Mtx* mPosMtx; + /* 0x10 */ Mtx33* mNrmMtx; /* 0x14 */ u32 mFlags; /* 0x18 */ u8 field_0x18; /* 0x19 */ u8 field_0x19; /* 0x1C */ int field_0x1c; /* 0x20 */ int field_0x20; - /* 0x24 */ J3DSkinNList** mSkinNList; + /* 0x24 */ J3DSkinNList* mSkinNList; }; class J3DDeformer { @@ -100,4 +108,15 @@ private: /* 0x10 */ u32 mFlags; }; // Size: 0x14 +inline void J3DFillZero32B(register void* param_0, register u32 param_1) { + asm { + srwi param_1, param_1, 5 + mtctr param_1 + lbl_8032D948: + dcbz 0, param_0 + addi param_0, param_0, 0x20 + bdnz lbl_8032D948 + } +} + #endif /* J3DSKINDEFORM_H */ diff --git a/include/JSystem/J3DGraphBase/J3DShape.h b/include/JSystem/J3DGraphBase/J3DShape.h index 8ceaf59661..102fb430da 100644 --- a/include/JSystem/J3DGraphBase/J3DShape.h +++ b/include/JSystem/J3DGraphBase/J3DShape.h @@ -107,6 +107,7 @@ public: 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; } diff --git a/include/JSystem/J3DGraphBase/J3DShapeDraw.h b/include/JSystem/J3DGraphBase/J3DShapeDraw.h index 8ad82a0c3d..2293fd6337 100644 --- a/include/JSystem/J3DGraphBase/J3DShapeDraw.h +++ b/include/JSystem/J3DGraphBase/J3DShapeDraw.h @@ -14,6 +14,7 @@ public: u8* getDisplayList() const { return (u8*)mDisplayList; } u32 getDisplayListSize() const { return mDisplayListSize; } + void setDisplayListSize(u32 size) { mDisplayListSize = size; } private: /* 0x04 */ u32 mDisplayListSize; diff --git a/include/JSystem/J3DGraphBase/J3DTransform.h b/include/JSystem/J3DGraphBase/J3DTransform.h index a162bd5b7c..884506ce42 100644 --- a/include/JSystem/J3DGraphBase/J3DTransform.h +++ b/include/JSystem/J3DGraphBase/J3DTransform.h @@ -14,8 +14,201 @@ struct J3DTransformInfo { extern J3DTransformInfo const j3dDefaultTransformInfo; extern Vec const j3dDefaultScale; extern Mtx const j3dDefaultMtx; +extern f32 PSMulUnit01[2]; void J3DGetTranslateRotateMtx(J3DTransformInfo const&, Mtx); void J3DGetTranslateRotateMtx(s16, s16, s16, f32, f32, f32, Mtx); +void J3DPSCalcInverseTranspose(f32 (*param_0)[4], f32 (*param_1)[3]); +void J3DGQRSetup7(u32 param_0, u32 param_1, u32 param_2, u32 param_3); + +inline void J3DPSMtx33CopyFrom34(register MtxP src, register Mtx3P dst) { + register f32 x_y1; + register f32 z1; + register f32 x_y2; + register f32 z2; + register f32 x_y3; + register f32 z3; + asm { + psq_l x_y1, 0(src), 0, 0 + lfs z1, 8(src) + psq_l x_y2, 16(src), 0, 0 + lfs z2, 0x18(src) + psq_l x_y3, 32(src), 0, 0 + lfs z3, 0x28(src) + psq_st x_y1, 0(dst), 0, 0 + stfs z1, 8(dst) + psq_st x_y2, 12(dst), 0, 0 + stfs z2, 0x14(dst) + psq_st x_y3, 24(dst), 0, 0 + stfs z3, 0x20(dst) + } +} + +// regalloc issues +inline void J3DPSMulMtxVec(register MtxP mtx, register Vec* vec, register Vec* dst) { + register f32 fr12; + register f32 fr11; + register f32 fr10; + register f32 fr9; + register f32 fr8; + register f32 fr6; + register f32 fra6; + register f32 fr5; + register f32 fra5; + register f32 fra4; + register f32 fr4; + register f32 fr3; + register f32 fr2; + register f32 fra2; + register f32 fr01; + register f32 fr00; + asm { + psq_l fr00, 0(vec), 0, 0 + psq_l fr2, 0(mtx), 0, 0 + psq_l fr01, 8(vec), 1, 0 + ps_mul fr4, fr2, fr00 + psq_l fr3, 8(mtx), 0, 0 + ps_madd fr5, fr3, fr01, fr4 + psq_l fr8, 16(mtx), 0, 0 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr9, 24(mtx), 0, 0 + ps_mul fr10, fr8, fr00 + psq_st fr6, 0(dst), 1, 0 + ps_madd fr11, fr9, fr01, fr10 + psq_l fra2, 32(mtx), 0, 0 + ps_sum0 fr12, fr11, fr12, fr11 + psq_l fr3, 40(mtx), 0, 0 + ps_mul fra4, fra2, fr00 + psq_st fr12, 4(dst), 1, 0 + ps_madd fra5, fr3, fr01, fra4 + ps_sum0 fra6, fra5, fra6, fra5 + psq_st fra6, 8(dst), 1, 0 + } +} + +// regalloc issues +inline void J3DPSMulMtxVec(register MtxP mtx, register SVec* vec, register SVec* dst) { + register f32 fr12; + register f32 fr11; + register f32 fr10; + register f32 fr9; + register f32 fr8; + register f32 fr6; + register f32 fra6; + register f32 fr5; + register f32 fra5; + register f32 fra4; + register f32 fr4; + register f32 fr3; + register f32 fr2; + register f32 fra2; + register f32 fr01; + register f32 fr00; + asm { + psq_l fr00, 0(vec), 0, 7 + psq_l fr2, 0(mtx), 0, 0 + psq_l fr01, 4(vec), 1, 7 + ps_mul fr4, fr2, fr00 + psq_l fr3, 8(mtx), 0, 0 + ps_madd fr5, fr3, fr01, fr4 + psq_l fr8, 16(mtx), 0, 0 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr9, 24(mtx), 0, 0 + ps_mul fr10, fr8, fr00 + psq_st fr6, 0(dst), 1, 7 + ps_madd fr11, fr9, fr01, fr10 + psq_l fra2, 32(mtx), 0, 0 + ps_sum0 fr12, fr11, fr12, fr11 + psq_l fr3, 40(mtx), 0, 0 + ps_mul fra4, fra2, fr00 + psq_st fr12, 2(dst), 1, 7 + ps_madd fra5, fr3, fr01, fra4 + ps_sum0 fra6, fra5, fra6, fra5 + psq_st fra6, 4(dst), 1, 7 + } +} + +// regalloc issues +inline void J3DPSMulMtxVec(register Mtx3P mtx, register Vec* vec, register Vec* dst) { + register f32* punit; + register f32 unit; + register f32 fr12; + register f32 fr11; + register f32 fr10; + register f32 fr9; + register f32 fr8; + register f32 fr6; + register f32 fr5; + register f32 fr4; + register f32 fr3; + register f32 fr2; + register f32 fr01; + register f32 fr00; + asm { + lis punit, PSMulUnit01@ha + psq_l fr00, 0(vec), 0, 0 + addi punit, punit, PSMulUnit01@l + psq_l fr2, 0(mtx), 0, 0 + psq_l unit, 0(punit), 0, 0 + psq_l fr01, 8(vec), 1, 0 + ps_add fr01, unit, fr01 + psq_l fr3, 8(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_l fr8, 12(mtx), 0, 0 + ps_madd fr5, fr3, fr01, fr4 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr9, 20(mtx), 1, 0 + ps_mul fr10, fr8, fr00 + psq_st fr6, 0(dst), 1, 0 + ps_madd fr11, fr9, fr01, fr10 + psq_l fr2, 24(mtx), 0, 0 + ps_sum0 fr12, fr11, fr12, fr11 + psq_l fr3, 32(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_st fr12, 4(dst), 1, 0 + ps_madd fr5, fr3, fr01, fr4 + ps_sum0 fr6, fr5, fr6, fr5 + psq_st fr6, 8(dst), 1, 0 + } +} + +// regalloc issues +inline void J3DPSMulMtxVec(register Mtx3P mtx, register SVec* vec, register SVec* dst) { + register f32* punit; + register f32 unit; + register f32 fr6; + register f32 fr5; + register f32 fr4; + register f32 fr3; + register f32 fr2; + register f32 fr01; + register f32 fr00; + asm { + lis punit, PSMulUnit01@ha + psq_l fr00, 0(vec), 0, 7 + addi punit, punit, PSMulUnit01@l + psq_l fr2, 0(mtx), 0, 0 + psq_l unit, 0(punit), 0, 0 + psq_l fr01, 4(vec), 1, 7 + ps_add fr01, unit, fr01 + psq_l fr3, 8(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_l fr2, 12(mtx), 0, 0 + ps_madd fr5, fr3, fr01, fr4 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr3, 20(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_st fr6, 0(dst), 1, 7 + ps_madd fr5, fr3, fr01, fr4 + psq_l fr2, 24(mtx), 0, 0 + ps_sum0 fr6, fr5, fr6, fr5 + psq_l fr3, 32(mtx), 1, 0 + ps_mul fr4, fr2, fr00 + psq_st fr6, 2(dst), 1, 7 + ps_madd fr5, fr3, fr01, fr4 + ps_sum0 fr6, fr5, fr6, fr5 + psq_st fr6, 4(dst), 1, 7 + } +} #endif /* J3DTRANSFORM_H */ diff --git a/include/JSystem/J3DGraphBase/J3DVertex.h b/include/JSystem/J3DGraphBase/J3DVertex.h index a601987c1d..2803c7838a 100644 --- a/include/JSystem/J3DGraphBase/J3DVertex.h +++ b/include/JSystem/J3DGraphBase/J3DVertex.h @@ -9,9 +9,11 @@ typedef struct _GXColor GXColor; class J3DModel; struct J3DAnmVtxColor; +struct J3DVertexBuffer; struct J3DVtxColorCalc { /* 8032E180 */ void calc(J3DModel*); + virtual void calc(J3DVertexBuffer*); /* 0x0 */ void* vtable; // inlined vtable? /* 0x4 */ u32 mFlags; @@ -30,6 +32,10 @@ public: u32 getNrmNum() const { return mNrmNum; } u32 getVtxNum() const { return mVtxNum; } GXVtxAttrFmtList* getVtxAttrFmtList() { return mVtxAttrFmtList; } + u8 getVtxPosFrac() { return mVtxPosFrac; } + u8 getVtxNrmFrac() { return mVtxNrmFrac; } + int getVtxPosType() { return mVtxPosType; } + int getVtxNrmType() { return mVtxNrmType; } void setVtxPosFrac(u8 frac) { mVtxPosFrac = frac; } void setVtxPosType(GXCompType type) { mVtxPosType = type; } @@ -69,8 +75,10 @@ public: /* 8031152C */ s32 allocTransformedVtxNrmArray(); void setCurrentVtxPos(void* pVtxPos) { mCurrentVtxPos = pVtxPos; } + void* getCurrentVtxPos() { return mCurrentVtxPos; } void setCurrentVtxNrm(void* pVtxNrm) { mCurrentVtxNrm = pVtxNrm; } + void* getCurrentVtxNrm() { return mCurrentVtxNrm; } void setCurrentVtxCol(GXColor* pVtxCol) { mCurrentVtxCol = pVtxCol; } @@ -80,6 +88,22 @@ public: setCurrentVtxCol(mVtxColArray[0]); } + void* getTransformedVtxPos(int idx) { return mTransformedVtxPosArray[idx]; } + void* getTransformedVtxNrm(int idx) { return mTransformedVtxNrmArray[idx]; } + J3DVertexData* getVertexData() { return mVtxData; } + + void swapTransformedVtxPos() { + void* tmp = mTransformedVtxPosArray[0]; + mTransformedVtxPosArray[0] = mTransformedVtxPosArray[1]; + mTransformedVtxPosArray[1] = tmp; + } + + void swapTransformedVtxNrm() { + void* tmp = mTransformedVtxNrmArray[0]; + mTransformedVtxNrmArray[0] = mTransformedVtxNrmArray[1]; + mTransformedVtxNrmArray[1] = tmp; + } + private: /* 0x00 */ J3DVertexData* mVtxData; /* 0x04 */ void* mVtxPosArray[2]; diff --git a/include/JSystem/JGeometry.h b/include/JSystem/JGeometry.h index 8f37b01fc9..34a243ee68 100644 --- a/include/JSystem/JGeometry.h +++ b/include/JSystem/JGeometry.h @@ -59,11 +59,15 @@ struct TVec3<f32> { f32 y; f32 z; - /* TVec3(const Vec& i_vec) { - setTVec3f(&i_vec.x, &x); - } */ + // inline TVec3(const Vec& i_vec) { + // setTVec3f(&i_vec.x, &x); + // } - /* TVec3() {} */ + // inline TVec3(const TVec3<f32>& i_vec) { + // setTVec3f(&i_vec.x, &x); + // } + + // TVec3() {} operator Vec*() { return (Vec*)&x; } operator const Vec*() const { return (Vec*)&x; } @@ -80,6 +84,10 @@ struct TVec3<f32> { z = z_; } + inline void add(const TVec3<f32>& b) { + C_VECAdd((Vec*)&x, (Vec*)&b.x, (Vec*)&x); + } + void zero() { x = y = z = 0.0f; } void mul(const TVec3<f32>& a, const TVec3<f32>& b) { @@ -104,6 +112,17 @@ struct TVec3<f32> { }; } + inline TVec3<f32>& operator+=(const TVec3<f32>& b) { + add(b); + return *this; + } + + // inline TVec3<f32> operator+(const TVec3<f32>& b) { + // TVec3<f32> res(*(Vec*)this); + // res += b; + // return res; + // } + inline TVec3<f32>& operator=(const TVec3<f32>& b) { register f32* dst = &x; const register f32* src = &b.x; @@ -140,13 +159,14 @@ struct TVec3<f32> { register f32 z; register f32 x_y; register f32* dst = &x; + register f32 zres; asm { psq_l x_y, 0(dst), 0, 0 psq_l z, 8(dst), 1, 0 ps_muls0 x_y, x_y, sc psq_st x_y, 0(dst), 0, 0 - ps_muls0 x_y, z, sc - psq_st x_y, 8(dst), 1, 0 + ps_muls0 zres, z, sc + psq_st zres, 8(dst), 1, 0 }; } }; diff --git a/include/JSystem/JParticle/JPAParticle.h b/include/JSystem/JParticle/JPAParticle.h index 3d27dca8e4..c43cc89a51 100644 --- a/include/JSystem/JParticle/JPAParticle.h +++ b/include/JSystem/JParticle/JPAParticle.h @@ -357,11 +357,13 @@ public: /* 80280548 */ f32 getWidth(JPABaseEmitter const*) const; /* 80280568 */ f32 getHeight(JPABaseEmitter const*) const; int getAge() { return mAge; } + void setOffsetPosition(const JGeometry::TVec3<f32>& pos) { mOffsetPosition.set(pos); } + void getOffsetPosition(JGeometry::TVec3<f32>& pos) { pos.set(mOffsetPosition); } public: /* 0x00 */ Vec mPosition; /* 0x0C */ Vec mLocalPosition; - /* 0x18 */ Vec mOffsetPosition; + /* 0x18 */ JGeometry::TVec3<f32> mOffsetPosition; /* 0x24 */ Vec mVelocity; /* 0x30 */ Vec mVelType1; /* 0x3C */ Vec mVelType0; |
