From d7480d5d8bf998c2ece5cbd76374deb8e279e77c Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 31 Dec 2022 09:45:22 -0800 Subject: [PATCH] Couple more J3DModel matches, d_kyeff/d_kyeff2 cleanups --- .../J3DModel/calcBumpMtx__8J3DModelFv.s | 70 -------- .../newDifferedDisplayList__8J3DModelFUl.s | 37 ---- .../JSystem/J3DGraphAnimator/J3DJointTree.h | 1 + include/JSystem/J3DGraphAnimator/J3DModel.h | 1 + .../JSystem/J3DGraphAnimator/J3DModelData.h | 3 +- .../JSystem/J3DGraphAnimator/J3DMtxBuffer.h | 6 +- include/JSystem/J3DGraphBase/J3DMaterial.h | 2 +- include/JSystem/J3DGraphBase/J3DPacket.h | 5 +- include/JSystem/J3DGraphBase/J3DShape.h | 1 + include/JSystem/J3DGraphBase/J3DShapeMtx.h | 10 +- include/JSystem/J3DGraphBase/J3DTexture.h | 1 + libs/JSystem/J3DGraphAnimator/J3DModel.cpp | 170 ++++++++++++++---- libs/JSystem/J3DGraphBase/J3DPacket.cpp | 8 +- libs/JSystem/J3DGraphBase/J3DShapeMtx.cpp | 2 +- src/d/d_kyeff.cpp | 23 +-- src/d/d_kyeff2.cpp | 46 +---- 16 files changed, 185 insertions(+), 201 deletions(-) delete mode 100644 asm/JSystem/J3DGraphAnimator/J3DModel/calcBumpMtx__8J3DModelFv.s delete mode 100644 asm/JSystem/J3DGraphAnimator/J3DModel/newDifferedDisplayList__8J3DModelFUl.s diff --git a/asm/JSystem/J3DGraphAnimator/J3DModel/calcBumpMtx__8J3DModelFv.s b/asm/JSystem/J3DGraphAnimator/J3DModel/calcBumpMtx__8J3DModelFv.s deleted file mode 100644 index f990aa4f487..00000000000 --- a/asm/JSystem/J3DGraphAnimator/J3DModel/calcBumpMtx__8J3DModelFv.s +++ /dev/null @@ -1,70 +0,0 @@ -lbl_803281B4: -/* 803281B4 94 21 FF D0 */ stwu r1, -0x30(r1) -/* 803281B8 7C 08 02 A6 */ mflr r0 -/* 803281BC 90 01 00 34 */ stw r0, 0x34(r1) -/* 803281C0 39 61 00 30 */ addi r11, r1, 0x30 -/* 803281C4 48 03 A0 09 */ bl _savegpr_25 -/* 803281C8 7C 7E 1B 78 */ mr r30, r3 -/* 803281CC 80 63 00 04 */ lwz r3, 4(r3) -/* 803281D0 A0 03 00 0C */ lhz r0, 0xc(r3) -/* 803281D4 28 00 00 01 */ cmplwi r0, 1 -/* 803281D8 40 82 00 C8 */ bne lbl_803282A0 -/* 803281DC 3B A0 00 00 */ li r29, 0 -/* 803281E0 A3 83 00 5C */ lhz r28, 0x5c(r3) -/* 803281E4 3B E0 00 00 */ li r31, 0 -/* 803281E8 48 00 00 AC */ b lbl_80328294 -lbl_803281EC: -/* 803281EC 80 7E 00 04 */ lwz r3, 4(r30) -/* 803281F0 80 63 00 60 */ lwz r3, 0x60(r3) -/* 803281F4 57 E0 13 BA */ rlwinm r0, r31, 2, 0xe, 0x1d -/* 803281F8 7F 63 00 2E */ lwzx r27, r3, r0 -/* 803281FC 80 7B 00 28 */ lwz r3, 0x28(r27) -/* 80328200 81 83 00 00 */ lwz r12, 0(r3) -/* 80328204 81 8C 00 5C */ lwz r12, 0x5c(r12) -/* 80328208 7D 89 03 A6 */ mtctr r12 -/* 8032820C 4E 80 04 21 */ bctrl -/* 80328210 88 03 00 00 */ lbz r0, 0(r3) -/* 80328214 28 00 00 01 */ cmplwi r0, 1 -/* 80328218 40 82 00 78 */ bne lbl_80328290 -/* 8032821C 80 9E 00 84 */ lwz r4, 0x84(r30) -/* 80328220 80 64 00 28 */ lwz r3, 0x28(r4) -/* 80328224 7C 63 E8 2E */ lwzx r3, r3, r29 -/* 80328228 80 04 00 30 */ lwz r0, 0x30(r4) -/* 8032822C 54 00 10 3A */ slwi r0, r0, 2 -/* 80328230 7F 43 00 2E */ lwzx r26, r3, r0 -/* 80328234 80 64 00 20 */ lwz r3, 0x20(r4) -/* 80328238 7F 23 00 2E */ lwzx r25, r3, r0 -/* 8032823C 80 7B 00 28 */ lwz r3, 0x28(r27) -/* 80328240 81 83 00 00 */ lwz r12, 0(r3) -/* 80328244 81 8C 00 5C */ lwz r12, 0x5c(r12) -/* 80328248 7D 89 03 A6 */ mtctr r12 -/* 8032824C 4E 80 04 21 */ bctrl -/* 80328250 38 83 00 04 */ addi r4, r3, 4 -/* 80328254 80 7B 00 08 */ lwz r3, 8(r27) -/* 80328258 7F 25 CB 78 */ mr r5, r25 -/* 8032825C 7F 46 D3 78 */ mr r6, r26 -/* 80328260 4B FE CB 49 */ bl calcNBTScale__8J3DShapeFRC3VecPA3_A3_fPA3_A3_f -/* 80328264 80 7E 00 04 */ lwz r3, 4(r30) -/* 80328268 A0 83 00 44 */ lhz r4, 0x44(r3) -/* 8032826C 80 BE 00 84 */ lwz r5, 0x84(r30) -/* 80328270 80 65 00 28 */ lwz r3, 0x28(r5) -/* 80328274 7C 63 E8 2E */ lwzx r3, r3, r29 -/* 80328278 80 05 00 30 */ lwz r0, 0x30(r5) -/* 8032827C 54 00 10 3A */ slwi r0, r0, 2 -/* 80328280 7C 63 00 2E */ lwzx r3, r3, r0 -/* 80328284 1C 84 00 24 */ mulli r4, r4, 0x24 -/* 80328288 48 01 33 55 */ bl DCStoreRange -/* 8032828C 3B BD 00 04 */ addi r29, r29, 4 -lbl_80328290: -/* 80328290 3B FF 00 01 */ addi r31, r31, 1 -lbl_80328294: -/* 80328294 57 E0 04 3E */ clrlwi r0, r31, 0x10 -/* 80328298 7C 00 E0 40 */ cmplw r0, r28 -/* 8032829C 41 80 FF 50 */ blt lbl_803281EC -lbl_803282A0: -/* 803282A0 39 61 00 30 */ addi r11, r1, 0x30 -/* 803282A4 48 03 9F 75 */ bl _restgpr_25 -/* 803282A8 80 01 00 34 */ lwz r0, 0x34(r1) -/* 803282AC 7C 08 03 A6 */ mtlr r0 -/* 803282B0 38 21 00 30 */ addi r1, r1, 0x30 -/* 803282B4 4E 80 00 20 */ blr diff --git a/asm/JSystem/J3DGraphAnimator/J3DModel/newDifferedDisplayList__8J3DModelFUl.s b/asm/JSystem/J3DGraphAnimator/J3DModel/newDifferedDisplayList__8J3DModelFUl.s deleted file mode 100644 index e2b0b15fa44..00000000000 --- a/asm/JSystem/J3DGraphAnimator/J3DModel/newDifferedDisplayList__8J3DModelFUl.s +++ /dev/null @@ -1,37 +0,0 @@ -lbl_803275FC: -/* 803275FC 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 80327600 7C 08 02 A6 */ mflr r0 -/* 80327604 90 01 00 24 */ stw r0, 0x24(r1) -/* 80327608 39 61 00 20 */ addi r11, r1, 0x20 -/* 8032760C 48 03 AB CD */ bl _savegpr_28 -/* 80327610 7C 7C 1B 78 */ mr r28, r3 -/* 80327614 7C 9D 23 78 */ mr r29, r4 -/* 80327618 93 A3 00 0C */ stw r29, 0xc(r3) -/* 8032761C 80 63 00 04 */ lwz r3, 4(r3) -/* 80327620 A3 E3 00 7C */ lhz r31, 0x7c(r3) -/* 80327624 3B C0 00 00 */ li r30, 0 -/* 80327628 48 00 00 2C */ b lbl_80327654 -lbl_8032762C: -/* 8032762C 80 7C 00 C4 */ lwz r3, 0xc4(r28) -/* 80327630 57 C0 04 3E */ clrlwi r0, r30, 0x10 -/* 80327634 1C 00 00 3C */ mulli r0, r0, 0x3c -/* 80327638 7C 63 02 14 */ add r3, r3, r0 -/* 8032763C 7F A4 EB 78 */ mr r4, r29 -/* 80327640 4B FE B7 7D */ bl newDifferedDisplayList__14J3DShapePacketFUl -/* 80327644 2C 03 00 00 */ cmpwi r3, 0 -/* 80327648 41 82 00 08 */ beq lbl_80327650 -/* 8032764C 48 00 00 18 */ b lbl_80327664 -lbl_80327650: -/* 80327650 3B DE 00 01 */ addi r30, r30, 1 -lbl_80327654: -/* 80327654 57 C0 04 3E */ clrlwi r0, r30, 0x10 -/* 80327658 7C 00 F8 40 */ cmplw r0, r31 -/* 8032765C 41 80 FF D0 */ blt lbl_8032762C -/* 80327660 38 60 00 00 */ li r3, 0 -lbl_80327664: -/* 80327664 39 61 00 20 */ addi r11, r1, 0x20 -/* 80327668 48 03 AB BD */ bl _restgpr_28 -/* 8032766C 80 01 00 24 */ lwz r0, 0x24(r1) -/* 80327670 7C 08 03 A6 */ mtlr r0 -/* 80327674 38 21 00 20 */ addi r1, r1, 0x20 -/* 80327678 4E 80 00 20 */ blr diff --git a/include/JSystem/J3DGraphAnimator/J3DJointTree.h b/include/JSystem/J3DGraphAnimator/J3DJointTree.h index 80513fb4de3..c73d96deeeb 100644 --- a/include/JSystem/J3DGraphAnimator/J3DJointTree.h +++ b/include/JSystem/J3DGraphAnimator/J3DJointTree.h @@ -48,6 +48,7 @@ public: 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; } private: /* 0x04 */ J3DModelHierarchy* mHierarchy; diff --git a/include/JSystem/J3DGraphAnimator/J3DModel.h b/include/JSystem/J3DGraphAnimator/J3DModel.h index 931c225adbc..0c54118357a 100644 --- a/include/JSystem/J3DGraphAnimator/J3DModel.h +++ b/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -71,6 +71,7 @@ public: void i_setBaseTRMtx(Mtx m) { PSMTXCopy(m, mBaseTransformMtx); } u32 getMtxCalcMode() const { return mFlags & 0x03; } J3DVertexBuffer* getVertexBuffer() const { return (J3DVertexBuffer*)&mVertexBuffer; } + J3DMatPacket* getMatPacket(u16 idx) const { return &mMatPacket[idx]; } J3DShapePacket* getShapePacket(u16 idx) const { return &mShapePacket[idx]; } Mtx33* getBumpMtxPtr(int idx) const { return mMtxBuffer->getBumpMtxPtr(idx); } Mtx33* getNrmMtxPtr() const { return mMtxBuffer->getNrmMtxPtr(); } diff --git a/include/JSystem/J3DGraphAnimator/J3DModelData.h b/include/JSystem/J3DGraphAnimator/J3DModelData.h index 51d8f08e8cc..85c00949454 100644 --- a/include/JSystem/J3DGraphAnimator/J3DModelData.h +++ b/include/JSystem/J3DGraphAnimator/J3DModelData.h @@ -38,11 +38,12 @@ public: J3DTexture* getTexture() const { return mMaterialTable.getTexture(); } JUTNameTab* getTextureName() const { return mMaterialTable.getTextureName(); } u16 getWEvlpMtxNum() const { return mJointTree.getWEvlpMtxNum(); } + u32 getModelDataType() const { return mJointTree.getModelDataType(); } void* getVtxPosArray() const { return mVertexData.getVtxPosArray(); } void* getVtxNrmArray() const { return mVertexData.getVtxNrmArray(); } GXColor* getVtxColorArray(u8 idx) const { return mVertexData.getVtxColorArray(idx); } bool checkFlag(u32 flag) const { return !!(mFlags & flag); } - bool checkBumpFlag() const { return mbHasBumpArray; } + u16 checkBumpFlag() const { return mbHasBumpArray; } bool checkBBoardFlag() const { return mbHasBillboard == 1; } bool isLocked() { return mMaterialTable.isLocked(); } void entryTexMtxAnimator(J3DAnmTextureSRTKey* anm) { mMaterialTable.entryTexMtxAnimator(anm); } diff --git a/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h b/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h index 1977afe281c..5ce09d7fedb 100644 --- a/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h +++ b/include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h @@ -33,8 +33,8 @@ public: Mtx* getDrawMtxPtr() const { return mpDrawMtxArr[mCurrentViewNo]; } Mtx33** getNrmMtxPtrPtr() const { return mpNrmMtxArr; } Mtx33* getNrmMtxPtr() const { return mpNrmMtxArr[mCurrentViewNo]; } - Mtx33** getBumpMtxPtrPtr() const { return mpBumpMtxArr; } - Mtx33* getBumpMtxPtr(int idx) const { return mpBumpMtxArr[idx]; } + Mtx33*** getBumpMtxPtrPtr() const { return mpBumpMtxArr; } + Mtx33* getBumpMtxPtr(int idx) const { return mpBumpMtxArr[idx][mCurrentViewNo]; } void swapDrawMtx() { Mtx* tmp = mpOldDrawMtxArr[mCurrentViewNo]; @@ -64,7 +64,7 @@ private: /* 0x1C */ Mtx33** mpOldNrmMtxArr; /* 0x20 */ Mtx33** mpNrmMtxArr; /* 0x24 */ u32 field_0x24; - /* 0x28 */ Mtx33** mpBumpMtxArr; + /* 0x28 */ Mtx33*** mpBumpMtxArr; /* 0x2C */ u32 mFlags; /* 0x30 */ u32 mCurrentViewNo; /* 0x34 */ Mtx** mUserAnmMtx; diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h index 3e6b8228233..d14c2fca4e2 100644 --- a/include/JSystem/J3DGraphBase/J3DMaterial.h +++ b/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -71,7 +71,7 @@ public: /* 0x14 */ u16 mIndex; /* 0x18 */ u32 mInvalid; /* 0x1C */ u32 field_0x1c; - /* 0x20 */ u32 field_0x20; + /* 0x20 */ u32 mDiffFlag; /* 0x24 */ J3DColorBlock* mColorBlock; /* 0x28 */ J3DTexGenBlock* mTexGenBlock; /* 0x2C */ J3DTevBlock* mTevBlock; diff --git a/include/JSystem/J3DGraphBase/J3DPacket.h b/include/JSystem/J3DGraphBase/J3DPacket.h index 232db283d3d..6b21f537ba8 100644 --- a/include/JSystem/J3DGraphBase/J3DPacket.h +++ b/include/JSystem/J3DGraphBase/J3DPacket.h @@ -15,6 +15,7 @@ class J3DModel; class J3DMtxBuffer; class J3DShape; class J3DTexMtx; +class J3DTexMtxObj; class J3DTexture; class J3DDisplayListObj { @@ -100,13 +101,13 @@ public: void offFlag(u32 flag) { mFlags &= ~flag; } void lock() { onFlag(LOCKED); } void unlock() { offFlag(LOCKED); } - J3DTexMtx* getTexMtxObj() const { return mpTexMtx; } + J3DTexMtxObj* getTexMtxObj() const { return mpTexMtxObj; } public: /* 0x10 */ u32 mFlags; /* 0x14 */ char mPad0[0x0C]; // unk /* 0x20 */ J3DDisplayListObj* mpDisplayListObj; - /* 0x24 */ J3DTexMtx* mpTexMtx; + /* 0x24 */ J3DTexMtxObj* mpTexMtxObj; }; // Size: 0x28 class J3DShapePacket : public J3DDrawPacket { diff --git a/include/JSystem/J3DGraphBase/J3DShape.h b/include/JSystem/J3DGraphBase/J3DShape.h index 372dacc9766..3d26ef2d6be 100644 --- a/include/JSystem/J3DGraphBase/J3DShape.h +++ b/include/JSystem/J3DGraphBase/J3DShape.h @@ -101,6 +101,7 @@ public: u32 getBumpMtxOffset() const { return mBumpMtxOffset; } inline J3DMaterial* getMaterial() const { return mMaterial; } + inline u32 getIndex() const { return mIndex; } inline u32 getPipeline() const { return (mFlags >> 2) & 0x07; } inline u32 getTexMtxLoadType() const { return mFlags & 0xF000; } inline u32 getMtxGroupNum() const { return mMtxGroupNum; } diff --git a/include/JSystem/J3DGraphBase/J3DShapeMtx.h b/include/JSystem/J3DGraphBase/J3DShapeMtx.h index 2496c9b8a3d..177f7542612 100644 --- a/include/JSystem/J3DGraphBase/J3DShapeMtx.h +++ b/include/JSystem/J3DGraphBase/J3DShapeMtx.h @@ -7,6 +7,14 @@ class J3DTexMtx; class J3DTexGenBlock; +class J3DTexMtxObj { +public: + Mtx& getMtx(u16 idx) { return mpTexMtx[idx]; } + +private: + /* 0x00 */ Mtx *mpTexMtx; +}; + class J3DDifferedTexMtx { public: /* 8031322C */ static void loadExecute(f32 const (*)[4]); @@ -17,7 +25,7 @@ public: } static J3DTexGenBlock* sTexGenBlock; - static J3DTexMtx* sTexMtxObj; + static J3DTexMtxObj* sTexMtxObj; }; extern u8 struct_804515B0[4]; diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h index e5559255ba2..8a8158b7bac 100644 --- a/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -54,6 +54,7 @@ public: /* 803243BC */ void loadPostTexMtx(u32) const; J3DTexMtxInfo& getTexMtxInfo() { return mTexMtxInfo; } + Mtx& getMtx() { return mMtx; } private: /* 0x00 */ J3DTexMtxInfo mTexMtxInfo; diff --git a/libs/JSystem/J3DGraphAnimator/J3DModel.cpp b/libs/JSystem/J3DGraphAnimator/J3DModel.cpp index 80f312c3815..ba72ac4999e 100644 --- a/libs/JSystem/J3DGraphAnimator/J3DModel.cpp +++ b/libs/JSystem/J3DGraphAnimator/J3DModel.cpp @@ -206,7 +206,6 @@ s32 J3DModel::entryModelData(J3DModelData* p_modelData, u32 param_1, u32 param_2 /* 80327300-803273CC 321C40 00CC+00 1/1 0/0 0/0 .text createShapePacket__8J3DModelFP12J3DModelData */ -// probably some wrong member types s32 J3DModel::createShapePacket(J3DModelData* p_modelData) { if (p_modelData->getShapeNum() != 0) { u16 shapeNum = p_modelData->getShapeNum(); @@ -229,6 +228,87 @@ s32 J3DModel::createShapePacket(J3DModelData* p_modelData) { /* 803273CC-803275FC 321D0C 0230+00 1/1 0/0 0/0 .text createMatPacket__8J3DModelFP12J3DModelDataUl */ +#if defined NON_MATCHING +s32 J3DModel::createMatPacket(J3DModelData* p_modelData, u32 flag) { + // regalloc + if (p_modelData->getMaterialNum() != 0) { + mMatPacket = new J3DMatPacket[p_modelData->getMaterialNum()]; + + if (mMatPacket == NULL) { + return kJ3DError_Alloc; + } + } + + s32 ret; + u16 matNum = p_modelData->getMaterialNum(); + u16 i = 0; + + u32 singleDLFlag = flag & 0x40000; + for (; i < matNum; i++) { + J3DMaterial* materialNode = p_modelData->getMaterialNodePointer(i); + J3DMatPacket* pkt = getMatPacket(i); + u16 shapeIndex = materialNode->getShape()->getIndex(); + J3DShapePacket* shapePacket = getShapePacket(shapeIndex); + pkt->mpMaterial = materialNode; + pkt->mpInitShapePacket = shapePacket; + pkt->addShapePacket(shapePacket); + pkt->mpTexture = p_modelData->getMaterialTable().getTexture(); + pkt->mDiffFlag = materialNode->mDiffFlag; + + if (p_modelData->getModelDataType() == 1) { + pkt->mFlags |= 0x01; + } + + if (!!(flag & 0x80000)) { + pkt->mpDisplayListObj = materialNode->getSharedDisplayListObj(); + } else { + if (p_modelData->getModelDataType() == 1) { + if (!!(flag & 0x40000)) { + pkt->mpDisplayListObj = materialNode->getSharedDisplayListObj(); + } else { + J3DDisplayListObj* sharedDL = materialNode->getSharedDisplayListObj(); + ret = sharedDL->single_To_Double(); + if (ret != kJ3DError_Success) + return ret; + + pkt->mpDisplayListObj = sharedDL; + } + } else if (!!(flag & 0x20000)) { + if (!!(flag & 0x40000)) { + ret = materialNode->newSingleSharedDisplayList(materialNode->countDLSize()); + if (ret != kJ3DError_Success) + return ret; + + pkt->mpDisplayListObj = materialNode->getSharedDisplayListObj(); + } else { + ret = materialNode->newSharedDisplayList(materialNode->countDLSize()); + if (ret != kJ3DError_Success) + return ret; + + J3DDisplayListObj* sharedDL = materialNode->getSharedDisplayListObj(); + ret = sharedDL->single_To_Double(); + if (ret != kJ3DError_Success) + return ret; + + pkt->mpDisplayListObj = sharedDL; + } + } else { + if (!!(flag & 0x40000)) { + ret = pkt->newSingleDisplayList(materialNode->countDLSize()); + if (ret != kJ3DError_Success) + return ret; + } else { + ret = pkt->newDisplayList(materialNode->countDLSize()); + if (ret != kJ3DError_Success) + return ret; + } + } + } + } + + return kJ3DError_Success; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -237,16 +317,19 @@ asm s32 J3DModel::createMatPacket(J3DModelData* param_0, u32 param_1) { #include "asm/JSystem/J3DGraphAnimator/J3DModel/createMatPacket__8J3DModelFP12J3DModelDataUl.s" } #pragma pop +#endif /* 803275FC-8032767C 321F3C 0080+00 0/0 1/1 0/0 .text newDifferedDisplayList__8J3DModelFUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 J3DModel::newDifferedDisplayList(u32 param_0) { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DModel/newDifferedDisplayList__8J3DModelFUl.s" +s32 J3DModel::newDifferedDisplayList(u32 flag) { + mDiffFlag = flag; + u16 shapeNum = getModelData()->getShapeNum(); + for (u16 i = 0; i < shapeNum; i++) { + s32 ret = mShapePacket[i].newDifferedDisplayList(flag); + if (ret != kJ3DError_Success) + return ret; + } + return kJ3DError_Success; } -#pragma pop /* 8032767C-803276B4 321FBC 0038+00 0/0 4/4 0/0 .text lock__8J3DModelFv */ void J3DModel::lock() { @@ -300,6 +383,33 @@ void J3DModel::calcMaterial() { } /* 80327858-803279A0 322198 0148+00 1/0 0/0 0/0 .text calcDiffTexMtx__8J3DModelFv */ +#if defined NON_MATCHING +void J3DModel::calcDiffTexMtx() { + // regalloc + j3dSys.setModel(this); + + u16 num; + num = getModelData()->getMaterialNum(); + for (u16 i = 0; i < num; i++) { + j3dSys.setMatPacket(getMatPacket(i)); + J3DMaterial* materialNode = getModelData()->getMaterialNodePointer(i); + materialNode->calcDiffTexMtx(i_getAnmMtx(materialNode->getJoint()->getJntNo())); + } + + num = getModelData()->getShapeNum(); + for (u16 i = 0; i < num; i++) { + J3DShapePacket* shapePacket = getShapePacket(i); + J3DTexGenBlock* texGenBlock = getModelData()->getShapeNodePointer(i)->getMaterial()->getTexGenBlock(); + for (u16 j = 0; (int)j < 8; j++) { + J3DTexMtx* texMtxNode = texGenBlock->getTexMtx(j); + J3DTexMtxObj* texMtxObj = shapePacket->getTexMtxObj(); + if (texMtxNode != NULL && texMtxObj != NULL) { + PSMTXCopy(texMtxNode->getMtx(), texMtxObj->getMtx(j)); + } + } + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -308,6 +418,7 @@ asm void J3DModel::calcDiffTexMtx() { #include "asm/JSystem/J3DGraphAnimator/J3DModel/calcDiffTexMtx__8J3DModelFv.s" } #pragma pop +#endif /* 803279A0-80327A2C 3222E0 008C+00 0/0 2/2 0/0 .text diff__8J3DModelFv */ void J3DModel::diff() { @@ -350,7 +461,7 @@ s32 J3DModel::setSkinDeform(J3DSkinDeform* p_skinDeform, u32 flags) { mSkinDeform->initMtxIndexArray(mModelData); ret = mModelData->checkFlag(0x100); - if (ret != 0) { + if (ret != kJ3DError_Success) { mSkinDeform->changeFastSkinDL(mModelData); flags &= ~2; flags &= ~4; @@ -540,33 +651,22 @@ void J3DModel::calcNrmMtx() { } /* 803281B4-803282B8 322AF4 0104+00 1/1 0/0 0/0 .text calcBumpMtx__8J3DModelFv */ -#ifdef NONMATCHING void J3DModel::calcBumpMtx() { - // comparison (might be b/c of bool rather than u8?) - if (!getModelData()->checkBumpFlag()) - return; + if (getModelData()->checkBumpFlag() == 1) { + u32 bumpMtxIdx = 0; + u16 materialNum = getModelData()->getMaterialNum(); + u16 i = 0; - // loop is a bit different - for (u16 n = getModelData()->getMaterialNum(), i = 0; i < n; i++) { - J3DMaterial* material = getModelData()->getMaterialNodePointer(i); - if (!material->getNBTScale()->mbHasScale) - continue; - - material->getShape()->calcNBTScale(*material->getNBTScale()->getScale(), getNrmMtxPtr(), - getBumpMtxPtr(i)); - DCStoreRange(getBumpMtxPtr(i), getModelData()->getDrawMtxNum() * 0x24); + for (; i < materialNum; i++) { + J3DMaterial* material = getModelData()->getMaterialNodePointer(i); + if (material->getNBTScale()->mbHasScale == 1) { + material->getShape()->calcNBTScale(*material->getNBTScale()->getScale(), getNrmMtxPtr(), getBumpMtxPtr(bumpMtxIdx)); + DCStoreRange(getBumpMtxPtr(bumpMtxIdx), getModelData()->getDrawMtxNum() * 0x24); + bumpMtxIdx++; + } + } } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J3DModel::calcBumpMtx() { - nofralloc -#include "asm/JSystem/J3DGraphAnimator/J3DModel/calcBumpMtx__8J3DModelFv.s" -} -#pragma pop -#endif /* 803282B8-803282EC 322BF8 0034+00 1/1 0/0 0/0 .text calcBBoardMtx__8J3DModelFv */ void J3DModel::calcBBoardMtx() { @@ -576,9 +676,11 @@ void J3DModel::calcBBoardMtx() { } /* 803282EC-80328350 322C2C 0064+00 2/2 0/0 0/0 .text prepareShapePackets__8J3DModelFv */ -#ifdef NONMATCHING +#if defined NONMATCHING void J3DModel::prepareShapePackets() { - for (u16 n = getModelData()->getShapeNum(), i = 0; i < n; i++) { + u16 shapeNum = getModelData()->getShapeNum(); + + for (u16 i = 0; i < shapeNum; i++) { // two swapped instructions right around here when calling getShapePacket J3DShapePacket* pkt = getShapePacket(i); pkt->setMtxBuffer(mMtxBuffer); diff --git a/libs/JSystem/J3DGraphBase/J3DPacket.cpp b/libs/JSystem/J3DGraphBase/J3DPacket.cpp index bf734f17107..adbaad79176 100644 --- a/libs/JSystem/J3DGraphBase/J3DPacket.cpp +++ b/libs/JSystem/J3DGraphBase/J3DPacket.cpp @@ -348,7 +348,7 @@ J3DError J3DShapePacket::newDifferedDisplayList(u32 flag) { } /* 80312E08-80312F24 30D748 011C+00 2/2 0/0 0/0 .text prepareDraw__14J3DShapePacketCFv */ -#ifdef NONMATCHING +#if defined NONMATCHING void J3DShapePacket::prepareDraw() const { mpModel->getVertexBuffer()->setArray(); j3dSys.setModel(mpModel); @@ -376,7 +376,7 @@ void J3DShapePacket::prepareDraw() const { if (!mpShape->getNBTFlag()) { mpShape->setNrmMtx(mpMtxBuffer->getNrmMtxPtrPtr()); } else { - mpShape->setNrmMtx(mpMtxBuffer->getBumpMtxPtrPtr() + mpShape->getBumpMtxOffset()); + mpShape->setNrmMtx(mpMtxBuffer->getBumpMtxPtrPtr()[mpShape->getBumpMtxOffset()]); } mpModel->getModelData()->syncJ3DSysFlags(); @@ -397,7 +397,7 @@ void J3DShapePacket::draw() { if (!checkFlag(J3DShpFlag_Hidden) && mpShape != NULL) { prepareDraw(); - if (mpTexMtx != NULL) { + if (mpTexMtxObj != NULL) { J3DMaterial* material = mpShape->getMaterial(); J3DDifferedTexMtx::sTexGenBlock = material->getTexGenBlock(); J3DDifferedTexMtx::sTexMtxObj = getTexMtxObj(); @@ -418,7 +418,7 @@ void J3DShapePacket::drawFast() { if (!checkFlag(J3DShpFlag_Hidden) && mpShape != NULL) { prepareDraw(); - if (mpTexMtx != NULL) { + if (mpTexMtxObj != NULL) { J3DMaterial* material = mpShape->getMaterial(); J3DDifferedTexMtx::sTexGenBlock = material->getTexGenBlock(); J3DDifferedTexMtx::sTexMtxObj = getTexMtxObj(); diff --git a/libs/JSystem/J3DGraphBase/J3DShapeMtx.cpp b/libs/JSystem/J3DGraphBase/J3DShapeMtx.cpp index 86d52ff500b..dd9d77b10c3 100644 --- a/libs/JSystem/J3DGraphBase/J3DShapeMtx.cpp +++ b/libs/JSystem/J3DGraphBase/J3DShapeMtx.cpp @@ -370,7 +370,7 @@ u8 J3DShapeMtxConcatView::sMtxPtrTbl[8]; J3DTexGenBlock* J3DDifferedTexMtx::sTexGenBlock; /* 804515C4-804515C8 000AC4 0004+00 1/1 2/2 0/0 .sbss sTexMtxObj__17J3DDifferedTexMtx */ -J3DTexMtx* J3DDifferedTexMtx::sTexMtxObj; +J3DTexMtxObj* J3DDifferedTexMtx::sTexMtxObj; /* 80456398-8045639C 004998 0004+00 2/2 0/0 0/0 .sdata2 @1032 */ SECTION_SDATA2 static u8 lit_1032[4] = { diff --git a/src/d/d_kyeff.cpp b/src/d/d_kyeff.cpp index fc8551f2d32..209563d338f 100644 --- a/src/d/d_kyeff.cpp +++ b/src/d/d_kyeff.cpp @@ -4,18 +4,17 @@ // #include "d/d_kyeff.h" + #include "Z2AudioLib/Z2EnvSeMgr.h" #include "d/com/d_com_inf_game.h" +#include "f_op/f_op_actor.h" +#include "f_op/f_op_kankyo.h" +#include "OS/OSTime.h" #include "d/kankyo/d_kankyo.h" +#include "d/kankyo/d_kankyo_wether.h" #include "dol2asm.h" #include "dolphin/types.h" -// -// Types: -// - -struct kankyo_class {}; - // // Forward References: // @@ -131,12 +130,16 @@ static asm int dKyeff_Create(kankyo_class* param_0) { /* ############################################################################################## */ /* 803BC158-803BC16C -00001 0014+00 1/0 0/0 0/0 .data l_dKyeff_Method */ -SECTION_DATA static void* l_dKyeff_Method[5] = { - (void*)dKyeff_Create__FP12kankyo_class, (void*)dKyeff_Delete__FP8dKyeff_c, - (void*)dKyeff_Execute__FP8dKyeff_c, (void*)dKyeff_IsDelete__FP8dKyeff_c, - (void*)dKyeff_Draw__FP8dKyeff_c, +static leafdraw_method_class l_dKyeff_Method = { + (process_method_func)dKyeff_Create, + (process_method_func)dKyeff_Delete, + (process_method_func)dKyeff_Execute, + (process_method_func)dKyeff_IsDelete, + (process_method_func)dKyeff_Draw, }; +extern "C" extern void* g_fopKy_Method[5 + 1 /* padding */]; + /* 803BC16C-803BC198 -00001 0028+04 0/0 0/0 1/0 .data g_profile_KYEFF */ SECTION_DATA extern void* g_profile_KYEFF[10 + 1 /* padding */] = { (void*)0xFFFFFFFD, diff --git a/src/d/d_kyeff2.cpp b/src/d/d_kyeff2.cpp index 2c501a71068..b419aa95a54 100644 --- a/src/d/d_kyeff2.cpp +++ b/src/d/d_kyeff2.cpp @@ -4,43 +4,11 @@ // #include "d/d_kyeff2.h" +#include "f_op/f_op_kankyo.h" #include "d/kankyo/d_kankyo_wether.h" #include "dol2asm.h" #include "dolphin/types.h" -// -// Types: -// - -struct kankyo_class {}; - -// -// Forward References: -// - -extern "C" static void dKyeff2_Draw__FP9dKyeff2_c(); -extern "C" void execute__9dKyeff2_cFv(); -extern "C" static void dKyeff2_Execute__FP9dKyeff2_c(); -extern "C" static bool dKyeff2_IsDelete__FP9dKyeff2_c(); -extern "C" static void dKyeff2_Delete__FP9dKyeff2_c(); -extern "C" static void dKyeff2_Create__FP12kankyo_class(); -extern "C" extern void* g_profile_KYEFF2[10 + 1 /* padding */]; - -// -// External References: -// - -extern "C" void dKyw_wether_init2__Fv(); -extern "C" void dKyw_wether_delete2__Fv(); -extern "C" void dKyw_wether_move_draw2__Fv(); -extern "C" void dKyw_wether_draw2__Fv(); -extern "C" extern void* g_fopKy_Method[5 + 1 /* padding */]; -extern "C" extern void* g_fpcLf_Method[5 + 1 /* padding */]; - -// -// Declarations: -// - static bool dKyeff2_Draw(dKyeff2_c* ptr) { dKyw_wether_draw2(); return true; @@ -71,12 +39,16 @@ static int dKyeff2_Create(kankyo_class* ptr) { /* ############################################################################################## */ /* 803BC198-803BC1AC -00001 0014+00 1/0 0/0 0/0 .data l_dKyeff2_Method */ -SECTION_DATA static void* l_dKyeff2_Method[5] = { - (void*)dKyeff2_Create__FP12kankyo_class, (void*)dKyeff2_Delete__FP9dKyeff2_c, - (void*)dKyeff2_Execute__FP9dKyeff2_c, (void*)dKyeff2_IsDelete__FP9dKyeff2_c, - (void*)dKyeff2_Draw__FP9dKyeff2_c, +static leafdraw_method_class l_dKyeff2_Method = { + (process_method_func)dKyeff2_Create, + (process_method_func)dKyeff2_Delete, + (process_method_func)dKyeff2_Execute, + (process_method_func)dKyeff2_IsDelete, + (process_method_func)dKyeff2_Draw, }; +extern "C" extern void* g_fopKy_Method[5 + 1 /* padding */]; + /* 803BC1AC-803BC1D8 -00001 0028+04 0/0 0/0 1/0 .data g_profile_KYEFF2 */ SECTION_DATA extern void* g_profile_KYEFF2[10 + 1 /* padding */] = { (void*)0xFFFFFFFD,