From b60bf4df329ae35f00bff57ff96e8325f478d7ca Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 21 Sep 2023 23:26:10 -0700 Subject: [PATCH] J3DNode/J3DTransform progress --- include/JSystem/J3DGraphAnimator/J3DNode.h | 17 ++++---- include/JSystem/J3DGraphBase/J3DTransform.h | 24 +---------- src/JSystem/J3DGraphAnimator/J3DNode.cpp | 17 ++++++-- src/JSystem/J3DGraphBase/J3DTransform.cpp | 46 +++++++++++++++++++-- src/JSystem/JMath/JMath.cpp | 2 +- 5 files changed, 69 insertions(+), 37 deletions(-) diff --git a/include/JSystem/J3DGraphAnimator/J3DNode.h b/include/JSystem/J3DGraphAnimator/J3DNode.h index d5eaadc1c..342c3d3fb 100644 --- a/include/JSystem/J3DGraphAnimator/J3DNode.h +++ b/include/JSystem/J3DGraphAnimator/J3DNode.h @@ -1,6 +1,8 @@ #ifndef J3DNODE_H #define J3DNODE_H +#include "dolphin/mtx/mtx.h" + class J3DNode; typedef int (*J3DNodeCallBack)(J3DNode*, int); @@ -11,7 +13,8 @@ public: virtual void calcIn(); virtual u32 getType(); virtual ~J3DNode(); - + + J3DNode(); void appendChild(J3DNode*); J3DNode* getYounger() { return mYounger; } @@ -20,11 +23,11 @@ public: J3DNodeCallBack getCallBack() { return mCallBack; } J3DNode* getChild() { return mChild; } - /* 0x00 */ void* mCallBackUserData; - /* 0x04 */ J3DNodeCallBack mCallBack; - /* 0x08 */ void* field_0x8; - /* 0x0C */ J3DNode* mChild; - /* 0x10 */ J3DNode* mYounger; -}; // Size: 0x14 + /* 0x04 */ void* mCallBackUserData; + /* 0x08 */ J3DNodeCallBack mCallBack; + /* 0x0C */ void* field_0x8; + /* 0x10 */ J3DNode* mChild; + /* 0x14 */ J3DNode* mYounger; +}; // Size: 0x18 #endif /* J3DNODE_H */ diff --git a/include/JSystem/J3DGraphBase/J3DTransform.h b/include/JSystem/J3DGraphBase/J3DTransform.h index 2cc2cc506..10a7c9605 100644 --- a/include/JSystem/J3DGraphBase/J3DTransform.h +++ b/include/JSystem/J3DGraphBase/J3DTransform.h @@ -20,28 +20,8 @@ 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) - } -} +void J3DPSMtx33Copy(register Mtx3P src, register Mtx3P dst); +void J3DPSMtx33CopyFrom34(register MtxP src, register Mtx3P dst); // regalloc issues inline void J3DPSMulMtxVec(register MtxP mtx, register Vec* vec, register Vec* dst) { diff --git a/src/JSystem/J3DGraphAnimator/J3DNode.cpp b/src/JSystem/J3DGraphAnimator/J3DNode.cpp index c44a0ee31..006aec6f1 100644 --- a/src/JSystem/J3DGraphAnimator/J3DNode.cpp +++ b/src/JSystem/J3DGraphAnimator/J3DNode.cpp @@ -8,7 +8,10 @@ /* 802F5BA4-802F5BC8 .text __ct__7J3DNodeFv */ J3DNode::J3DNode() { - /* Nonmatching */ + mCallBackUserData = NULL; + mCallBack = NULL; + mChild = NULL; + mYounger = NULL; } /* 802F5BC8-802F5C10 .text __dt__7J3DNodeFv */ @@ -17,8 +20,16 @@ J3DNode::~J3DNode() { } /* 802F5C10-802F5C44 .text appendChild__7J3DNodeFP7J3DNode */ -void J3DNode::appendChild(J3DNode*) { - /* Nonmatching */ +void J3DNode::appendChild(J3DNode* pChild) { + if (mChild == NULL) { + mChild = pChild; + } else { + J3DNode* curChild = mChild; + while (curChild->getYounger() != NULL) { + curChild = curChild->getYounger(); + } + curChild->setYounger(pChild); + } } /* 802F5C44-802F5C48 .text entryIn__7J3DNodeFv */ diff --git a/src/JSystem/J3DGraphBase/J3DTransform.cpp b/src/JSystem/J3DGraphBase/J3DTransform.cpp index b231a3378..952da979a 100644 --- a/src/JSystem/J3DGraphBase/J3DTransform.cpp +++ b/src/JSystem/J3DGraphBase/J3DTransform.cpp @@ -4,6 +4,7 @@ // #include "JSystem/J3DGraphBase/J3DTransform.h" +#include "JSystem/J3DGraphBase/J3DStruct.h" #include "dolphin/types.h" /* 802DA0A8-802DA0B0 .text __MTGQR7__FUl */ @@ -103,13 +104,50 @@ void J3DMtxProjConcat(float(*)[4], float(*)[4], float(*)[4]) { } /* 802DACE0-802DAD0C .text J3DPSMtx33Copy__FPA3_fPA3_f */ -void J3DPSMtx33Copy(float(*)[3], float(*)[3]) { - /* Nonmatching */ +void J3DPSMtx33Copy(register Mtx3P src, register Mtx3P dst) { + register f32 x1_y1; + register f32 z1_x2; + register f32 y2_z2; + register f32 x3_y3; + register f32 z3; + + asm { + psq_l x1_y1, 0(src), 0, 0 + psq_l z1_x2, 8(src), 0, 0 + psq_l y2_z2, 16(src), 0, 0 + psq_l x3_y3, 24(src), 0, 0 + lfs z3, 32(src) + psq_st x1_y1, 0(dst), 0, 0 + psq_st z1_x2, 8(dst), 0, 0 + psq_st y2_z2, 16(dst), 0, 0 + psq_st x3_y3, 24(dst), 0, 0 + stfs z3, 32(dst) + } } /* 802DAD0C-802DAD40 .text J3DPSMtx33CopyFrom34__FPA4_fPA3_f */ -void J3DPSMtx33CopyFrom34(float(*)[4], float(*)[3]) { - /* Nonmatching */ +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 + psq_st x_y1, 0(dst), 0, 0 + lfs z1, 8(src) + stfs z1, 8(dst) + psq_l x_y2, 16(src), 0, 0 + psq_st x_y2, 12(dst), 0, 0 + lfs z2, 0x18(src) + stfs z2, 0x14(dst) + psq_l x_y3, 32(src), 0, 0 + psq_st x_y3, 24(dst), 0, 0 + lfs z3, 0x28(src) + stfs z3, 0x20(dst) + } } /* 802DAD40-802DAE1C .text J3DPSMtxArrayConcat__FPA4_fPA4_fPA4_fUl */ diff --git a/src/JSystem/JMath/JMath.cpp b/src/JSystem/JMath/JMath.cpp index 0bedd62ae..4639bda3b 100644 --- a/src/JSystem/JMath/JMath.cpp +++ b/src/JSystem/JMath/JMath.cpp @@ -3,7 +3,7 @@ // Translation Unit: JMath.cpp // -#include "JMath.h" +#include "JSystem/JMath/JMath.h" #include "dolphin/types.h" /* 80301028-80301150 .text JMANewSinTable__FUc */