From 02f29ac056b76e0e78e28081969ce8af7f8172b5 Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Sat, 30 Sep 2023 15:39:23 -0700 Subject: [PATCH] m_Do_ext WIP --- .../JSystem/J3DGraphAnimator/J3DMaterialAnm.h | 87 +++-- include/JSystem/J3DGraphAnimator/J3DModel.h | 2 + include/JSystem/J3DGraphBase/J3DMatBlock.h | 2 +- include/JSystem/J3DGraphBase/J3DStruct.h | 12 +- include/JSystem/J3DGraphBase/J3DTexture.h | 5 +- include/m_Do/m_Do_ext.h | 38 ++- src/m_Do/m_Do_ext.cpp | 311 +++++++++++++++--- 7 files changed, 365 insertions(+), 92 deletions(-) diff --git a/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h b/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h index fd986b8c0..89f43ac6a 100644 --- a/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h +++ b/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h @@ -9,24 +9,29 @@ typedef struct _GXColorS10 GXColorS10; class J3DMatColorAnm { public: ~J3DMatColorAnm() {} - J3DMatColorAnm() {} - J3DMatColorAnm(J3DAnmColor * pAnm, u16 materialIdx) { + J3DMatColorAnm() { + mAnmColor = NULL; + mAnmIndex = 0; + } + J3DMatColorAnm(J3DAnmColor* pAnm, u16 anmIdx) { mAnmColor = pAnm; - mMaterialIdx = materialIdx; + mAnmIndex = anmIdx; } void operator=(J3DMatColorAnm const& other) { mAnmColor = other.mAnmColor; - mMaterialIdx = other.mMaterialIdx; + mAnmIndex = other.mAnmIndex; mAnmFlag = other.mAnmFlag; } + void setAnmIndex(u16 index) { mAnmIndex = index; } void setAnmFlag(bool flag) { mAnmFlag = flag; } bool getAnmFlag() const { return mAnmFlag; } - void calc(_GXColor* pColor) const { mAnmColor->getColor(mMaterialIdx, pColor); } + void setAnmColor(J3DAnmColor* anmColor) { mAnmColor = anmColor; } + void calc(_GXColor* pColor) const { mAnmColor->getColor(mAnmIndex, pColor); } private: - /* 0x0 */ u16 mMaterialIdx; + /* 0x0 */ u16 mAnmIndex; /* 0x2 */ u16 mAnmFlag; /* 0x4 */ J3DAnmColor* mAnmColor; }; // Size: 0x8 @@ -34,21 +39,26 @@ private: class J3DTexNoAnm { public: ~J3DTexNoAnm() {}; - J3DTexNoAnm() {}; - virtual void calc(u16* param_0) const { mAnmTexPattern->getTexNo(field_0x4, param_0); } + J3DTexNoAnm() { + mAnmTexPattern = NULL; + mAnmIndex = 0; + }; + virtual void calc(u16* param_0) const { mAnmTexPattern->getTexNo(mAnmIndex, param_0); } void operator=(J3DTexNoAnm const& other) { mAnmTexPattern = other.mAnmTexPattern; - field_0x4 = other.field_0x4; + mAnmIndex = other.mAnmIndex; mAnmFlag = other.mAnmFlag; } + void setAnmIndex(u16 index) { mAnmIndex = index; } void setAnmFlag(bool flag) { mAnmFlag = flag; } bool getAnmFlag() const { return mAnmFlag; } J3DAnmTexPattern* getAnmTexPattern() { return mAnmTexPattern; } + void setAnmTexPattern(J3DAnmTexPattern* pattern) { mAnmTexPattern = pattern; } private: - /* 0x4 */ u16 field_0x4; + /* 0x4 */ u16 mAnmIndex; /* 0x6 */ u16 mAnmFlag; /* 0x8 */ J3DAnmTexPattern* mAnmTexPattern; }; // Size: 0xC @@ -56,26 +66,31 @@ private: class J3DTexMtxAnm { public: ~J3DTexMtxAnm() {} - J3DTexMtxAnm() {} - J3DTexMtxAnm(J3DAnmTextureSRTKey * pAnm, u16 materialIdx) { + J3DTexMtxAnm() { + mAnmIndex = 0; + mAnmTransform = NULL; + } + J3DTexMtxAnm(J3DAnmTextureSRTKey * pAnm, u16 anmIdx) { mAnmTransform = pAnm; - mMaterialIdx = materialIdx; + mAnmIndex = anmIdx; } void operator=(J3DTexMtxAnm const& other) { mAnmTransform = other.mAnmTransform; - mMaterialIdx = other.mMaterialIdx; + mAnmIndex = other.mAnmIndex; mAnmFlag = other.mAnmFlag; } - void setAnmFlag(bool flag) { mAnmFlag = flag; } - void calc(J3DTextureSRTInfo* pSRTInfo) const { - mAnmTransform->getTransform(mMaterialIdx, pSRTInfo); - } + void setAnmIndex(u16 index) { mAnmIndex = index; } bool getAnmFlag() const { return mAnmFlag; } + void setAnmFlag(bool flag) { mAnmFlag = flag; } + void setAnmTransform(J3DAnmTextureSRTKey* transform) { mAnmTransform = transform; } + void calc(J3DTextureSRTInfo* pSRTInfo) const { + mAnmTransform->getTransform(mAnmIndex, pSRTInfo); + } private: - /* 0x0 */ u16 mMaterialIdx; + /* 0x0 */ u16 mAnmIndex; /* 0x2 */ u16 mAnmFlag; /* 0x4 */ J3DAnmTextureSRTKey* mAnmTransform; }; // Size: 0x8 @@ -83,24 +98,29 @@ private: class J3DTevKColorAnm { public: ~J3DTevKColorAnm() {} - J3DTevKColorAnm() {} - J3DTevKColorAnm(J3DAnmTevRegKey * pAnm, u16 materialIdx) { + J3DTevKColorAnm() { + mAnmTevReg = NULL; + mAnmIndex = 0; + } + J3DTevKColorAnm(J3DAnmTevRegKey * pAnm, u16 anmIdx) { mAnmTevReg = pAnm; - mMaterialIdx = materialIdx; + mAnmIndex = anmIdx; } void operator=(J3DTevKColorAnm const& other) { mAnmTevReg = other.mAnmTevReg; - mMaterialIdx = other.mMaterialIdx; + mAnmIndex = other.mAnmIndex; mAnmFlag = other.mAnmFlag; } + void setAnmIndex(u16 index) { mAnmIndex = index; } void setAnmFlag(bool flag) { mAnmFlag = flag; } bool getAnmFlag() const { return mAnmFlag; } - void calc(_GXColor* pColor) const { mAnmTevReg->getTevKonstReg(mMaterialIdx, pColor); } + void setAnmTevReg(J3DAnmTevRegKey* tevReg) { mAnmTevReg = tevReg; } + void calc(_GXColor* pColor) const { mAnmTevReg->getTevKonstReg(mAnmIndex, pColor); } private: - /* 0x0 */ u16 mMaterialIdx; + /* 0x0 */ u16 mAnmIndex; /* 0x2 */ u16 mAnmFlag; /* 0x4 */ J3DAnmTevRegKey* mAnmTevReg; }; // Size: 0x8 @@ -108,24 +128,29 @@ private: class J3DTevColorAnm { public: ~J3DTevColorAnm() {} - J3DTevColorAnm() {} - J3DTevColorAnm(J3DAnmTevRegKey * pAnm, u16 materialIdx) { + J3DTevColorAnm() { + mAnmTevReg = NULL; + mAnmIndex = 0; + } + J3DTevColorAnm(J3DAnmTevRegKey * pAnm, u16 anmIdx) { mAnmTevReg = pAnm; - mMaterialIdx = materialIdx; + mAnmIndex = anmIdx; } void operator=(J3DTevColorAnm const& other) { mAnmTevReg = other.mAnmTevReg; - mMaterialIdx = other.mMaterialIdx; + mAnmIndex = other.mAnmIndex; mAnmFlag = other.mAnmFlag; } + void setAnmIndex(u16 index) { mAnmIndex = index; } void setAnmFlag(bool flag) { mAnmFlag = flag; } bool getAnmFlag() const { return mAnmFlag; } - void calc(_GXColorS10* pColor) const { mAnmTevReg->getTevColorReg(mMaterialIdx, pColor); } + void setAnmTevReg(J3DAnmTevRegKey* tevReg) { mAnmTevReg = tevReg; } + void calc(_GXColorS10* pColor) const { mAnmTevReg->getTevColorReg(mAnmIndex, pColor); } private: - /* 0x0 */ u16 mMaterialIdx; + /* 0x0 */ u16 mAnmIndex; /* 0x2 */ u16 mAnmFlag; /* 0x4 */ J3DAnmTevRegKey* mAnmTevReg; }; // Size: 0x8 diff --git a/include/JSystem/J3DGraphAnimator/J3DModel.h b/include/JSystem/J3DGraphAnimator/J3DModel.h index c59887b4c..d82d6d144 100644 --- a/include/JSystem/J3DGraphAnimator/J3DModel.h +++ b/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -65,6 +65,7 @@ public: void calcDrawMtx(); void prepareShapePackets(); MtxP getAnmMtx(int idx) { return mpNodeMtx[idx]; } + void setAnmMtx(int idx, Mtx mtx) { MTXCopy(mtx, mpNodeMtx[idx]); } MtxP getWeightAnmMtx(int idx) { return mpWeightEnvMtx[idx]; } s32 setNoUseDrawMtx(); @@ -105,6 +106,7 @@ public: u32 getMtxCalcMode() const { return mFlags & 0x03; } u32* getCurrentViewNoPtr() { return &mCurrentViewNo; } u8* getScaleFlagArray() const { return mpScaleFlagArr; } + void setScaleFlag(int idx, u8 param_1) { mpScaleFlagArr[idx] = param_1; } J3DVertexBuffer* getVertexBuffer() const { return (J3DVertexBuffer*)&mVertexBuffer; } J3DMatPacket* getMatPacket(u16 idx) const { return &mpMatPacket[idx]; } J3DShapePacket* getShapePacket(u16 idx) const { return &mpShapePacket[idx]; } diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index 42cd2084a..e68d63d4e 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -32,7 +32,7 @@ public: virtual void setTexCoord(u32, J3DTexCoord const*); virtual J3DTexCoord* getTexCoord(u32); virtual void setTexMtx(u32, J3DTexMtx*); - virtual J3DTexMtx* getTexMtx(u32); + virtual J3DTexMtx* getTexMtx(u32) { return NULL; } virtual void setNBTScale(J3DNBTScale const*); virtual void setNBTScale(J3DNBTScale); virtual J3DNBTScale* getNBTScale(); diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h index d579ba6d7..557723a39 100644 --- a/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/include/JSystem/J3DGraphBase/J3DStruct.h @@ -41,7 +41,17 @@ enum J3DTexMtxMode { }; struct J3DTexMtxInfo { - void operator=(J3DTexMtxInfo const&); + void operator=(J3DTexMtxInfo const& other) { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + mEffectMtx[i][j] = other.mEffectMtx[i][j]; + } + } + mCenter = other.mCenter; + mProjection = other.mProjection; + mInfo = other.mInfo; + mSRT = other.mSRT; + } void setEffectMtx(Mtx); /* 0x00 */ u8 mProjection; diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h index 92bc64ed7..a8a3eaa5e 100644 --- a/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -1,8 +1,9 @@ #ifndef J3DTEXTURE_H #define J3DTEXTURE_H -#include "JSystem/J3DGraphBase/J3DStruct.h" #include "JSystem/J3DGraphBase/J3DGD.h" +#include "JSystem/J3DGraphBase/J3DStruct.h" +#include "JSystem/J3DGraphBase/J3DTevs.h" #include "JSystem/JUtility/JUTTexture.h" #include "dolphin/mtx/mtx.h" #include "dolphin/types.h" @@ -49,7 +50,7 @@ public: class J3DTexMtx { public: - J3DTexMtx(); + J3DTexMtx() { mTexMtxInfo = j3dDefaultTexMtxInfo; } J3DTexMtx(const J3DTexMtxInfo& info) { mTexMtxInfo = info; } diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h index 165188a60..08884aa10 100644 --- a/include/m_Do/m_Do_ext.h +++ b/include/m_Do/m_Do_ext.h @@ -18,30 +18,30 @@ class J3DTexMtxAnm; class mDoExt_baseAnm { public: - mDoExt_baseAnm() { mpFrameCtrl = NULL; } + mDoExt_baseAnm() { mFrameCtrl = NULL; } virtual ~mDoExt_baseAnm() {} int initPlay(s16 i_frameMax, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool); int play(); - J3DFrameCtrl* getFrameCtrl() { return mpFrameCtrl; } - f32 getPlaySpeed() { return mpFrameCtrl->getRate(); } - void setPlaySpeed(f32 speed) { mpFrameCtrl->setRate(speed); } - f32 getFrame() { return mpFrameCtrl->getFrame(); } - f32 getEndFrame() { return mpFrameCtrl->getEnd(); } - void setFrame(f32 frame) { mpFrameCtrl->setFrame(frame); } - void setPlayMode(int i_mode) { mpFrameCtrl->setAttribute(i_mode); } - void setLoopFrame(f32 i_frame) { mpFrameCtrl->setLoop(i_frame); } + J3DFrameCtrl* getFrameCtrl() { return mFrameCtrl; } + f32 getPlaySpeed() { return mFrameCtrl->getRate(); } + void setPlaySpeed(f32 speed) { mFrameCtrl->setRate(speed); } + f32 getFrame() { return mFrameCtrl->getFrame(); } + f32 getEndFrame() { return mFrameCtrl->getEnd(); } + void setFrame(f32 frame) { mFrameCtrl->setFrame(frame); } + void setPlayMode(int i_mode) { mFrameCtrl->setAttribute(i_mode); } + void setLoopFrame(f32 i_frame) { mFrameCtrl->setLoop(i_frame); } bool isStop() { bool stopped = true; - if (!mpFrameCtrl->checkState(1) && mpFrameCtrl->getRate() != 0.0f) { + if (!mFrameCtrl->checkState(1) && mFrameCtrl->getRate() != 0.0f) { stopped = false; } return stopped; } private: - /* 0x4 */ J3DFrameCtrl* mpFrameCtrl; + /* 0x4 */ J3DFrameCtrl* mFrameCtrl; }; // Size: 0x08 class mDoExt_btkAnm : public mDoExt_baseAnm { @@ -65,7 +65,7 @@ public: private: /* 0x08 */ J3DAnmTextureSRTKey* mpAnm; /* 0x0C */ J3DTexMtxAnm* mpTexMtxAnm; - /* 0x10 */ s16 mUpdateMaterialNum; + /* 0x10 */ u16 mUpdateMaterialNum; }; // Size: 0x14 STATIC_ASSERT(sizeof(mDoExt_btkAnm) == 0x14); @@ -138,12 +138,10 @@ public: int i_attribute, f32 i_rate, s16 i_start, s16 param_6); int init(J3DModelData*, J3DAnmTexPattern*, int, int, float, short, short, bool, int); int init(J3DMaterialTable*, J3DAnmTexPattern*, int, int, float, short, short, bool, int); + void entry(J3DModelData* i_modelData, s16 i_frame); /* 8000D5E8 */ void entry(J3DMaterialTable* i_matTable, s16 i_frame); void entry(J3DModelData* i_modelData) { entry(i_modelData, getFrame()); } - void entry(J3DModelData* i_modelData, s16 i_frame) { - entry(&i_modelData->getMaterialTable(), i_frame); - } int init(J3DModelData* i_modelData, J3DAnmTexPattern* i_btk, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_start, s16 param_6) { @@ -154,7 +152,9 @@ public: int remove(J3DModelData* i_modelData) { return i_modelData->removeTexNoAnimator(mpAnm); } private: - /* 0x14 */ J3DAnmTexPattern* mpAnm; + /* 0x08 */ J3DAnmTexPattern* mpAnm; + /* 0x0C */ J3DTexNoAnm* field_0xc; + /* 0x10 */ u16 mUpdateMaterialNum; }; class mDoExt_blkAnm : public mDoExt_baseAnm { @@ -177,7 +177,9 @@ public: void entry(J3DMaterialTable*, float); private: - // TODO + /* 0x08 */ J3DAnmColor* mpAnm; + /* 0x0C */ J3DMatColorAnm* field_0xc; + /* 0x10 */ u16 mUpdateMaterialNum; }; class mDoExt_bvaAnm : public mDoExt_baseAnm { @@ -465,4 +467,6 @@ extern JKRExpHeap* gameHeap; extern JKRExpHeap* commandHeap; extern JKRExpHeap* archiveHeap; +//inline void mDoMtx_concat(const Mtx a, const Mtx b, Mtx ab) { MTXConcat(a, b, ab); } + #endif diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index f55e2361e..d323c16b5 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -4,91 +4,279 @@ // #include "m_Do/m_Do_ext.h" -#include "dolphin/types.h" +#include "JSystem/J3DGraphBase/J3DTransform.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "JSystem/JUtility/JUTAssert.h" +#include "SSystem/SComponent/c_m3d.h" +#include "m_Do/m_Do_printf.h" /* 8000DA70-8000DCF0 .text mDoExt_setJ3DData__FPA4_fPC16J3DTransformInfoUs */ -void mDoExt_setJ3DData(f32(*)[4], const J3DTransformInfo*, u16) { - /* Nonmatching */ +void mDoExt_setJ3DData(Mtx mtx, const J3DTransformInfo* transformInfo, u16 param_2) { + bool local_28; + if (cM3d_IsZero(transformInfo->mScale.x - 1.0f) && cM3d_IsZero(transformInfo->mScale.y - 1.0f) && cM3d_IsZero(transformInfo->mScale.z - 1.0f)) { + j3dSys.getModel()->setScaleFlag(param_2, 1); + local_28 = true; + } else { + j3dSys.getModel()->setScaleFlag(param_2, 0); + local_28 = false; + } + mtx[0][3] = transformInfo->mTranslate.x; + mtx[1][3] = transformInfo->mTranslate.y; + mtx[2][3] = transformInfo->mTranslate.z; + + if (!local_28) { + mtx[0][0] *= transformInfo->mScale.x; + mtx[0][1] *= transformInfo->mScale.y; + mtx[0][2] *= transformInfo->mScale.z; + mtx[1][0] *= transformInfo->mScale.x; + mtx[1][1] *= transformInfo->mScale.y; + mtx[1][2] *= transformInfo->mScale.z; + mtx[2][0] *= transformInfo->mScale.x; + mtx[2][1] *= transformInfo->mScale.y; + mtx[2][2] *= transformInfo->mScale.z; + } + if (j3dSys.getModel()->getModelData()->getJointNodePointer(param_2)->getScaleCompensate() == 1) { + f32 x = 1.0f / J3DSys::mParentS.x; + f32 y = 1.0f / J3DSys::mParentS.y; + f32 z = 1.0f / J3DSys::mParentS.z; + mtx[0][0] *= x; + mtx[0][1] *= x; + mtx[0][2] *= x; + mtx[1][0] *= y; + mtx[1][1] *= y; + mtx[1][2] *= y; + mtx[2][0] *= z; + mtx[2][1] *= z; + mtx[2][2] *= z; + } + //mDoMtx_concat(J3DSys::mCurrentMtx, mtx, J3DSys::mCurrentMtx); + j3dSys.getModel()->setAnmMtx(param_2, J3DSys::mCurrentMtx); + J3DSys::mParentS.x = transformInfo->mScale.x; + J3DSys::mParentS.y = transformInfo->mScale.y; + J3DSys::mParentS.z = transformInfo->mScale.z; } /* 8000DCF0-8000DCF4 .text getTransform__15J3DAnmTransformCFUsP16J3DTransformInfo */ -void J3DAnmTransform::getTransform(u16, J3DTransformInfo*) const { - /* Nonmatching */ -} +void J3DAnmTransform::getTransform(u16, J3DTransformInfo*) const {} /* 8000DCF4-8000DD4C .text isCurrentSolidHeap__Fv */ -void isCurrentSolidHeap() { - /* Nonmatching */ +bool isCurrentSolidHeap() { + if (JKRGetCurrentHeap()->getHeapType() != 'SLID') { + OSReport_Error("ソリッドヒープちゃうがな!\n"); + return false; + } + return true; } /* 8000DD4C-8000DF24 .text initPlay__14mDoExt_baseAnmFsifssb */ -int mDoExt_baseAnm::initPlay(s16, int, f32, s16, s16, bool) { - /* Nonmatching */ +int mDoExt_baseAnm::initPlay(s16 i_frameMax, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify) { + JUT_ASSERT(421, i_modify || isCurrentSolidHeap()); + if (!i_modify) { + mFrameCtrl = new J3DFrameCtrl(); + if (!mFrameCtrl) { + return 0; + } + } + + mFrameCtrl->setStart(i_startF); + + if (i_endF < 0) { + mFrameCtrl->init(i_frameMax); + } else { + mFrameCtrl->init(i_endF); + } + mFrameCtrl->setAttribute(i_attribute); + mFrameCtrl->setRate(i_rate); + + if (i_rate >= 0.0f) { + mFrameCtrl->setFrame(i_startF); + } else { + mFrameCtrl->setFrame(mFrameCtrl->getEnd()); + } + + mFrameCtrl->setLoop(mFrameCtrl->getFrame()); + + return 1; } /* 8000DF24-8000DFC4 .text play__14mDoExt_baseAnmFv */ int mDoExt_baseAnm::play() { - /* Nonmatching */ + JUT_ASSERT(462, mFrameCtrl != 0); + mFrameCtrl->update(); + return isStop(); } /* 8000DFC4-8000DFF0 .text init__13mDoExt_bpkAnmFP12J3DModelDataP11J3DAnmColoriifssbi */ -int mDoExt_bpkAnm::init(J3DModelData*, J3DAnmColor*, int, int, f32, s16, s16, bool, int) { - /* Nonmatching */ +int mDoExt_bpkAnm::init(J3DModelData* i_modelData, J3DAnmColor* i_bpk, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { + return init(&i_modelData->getMaterialTable(), i_bpk, i_anmPlay, i_attribute, i_rate, i_startF, i_endF, i_modify, i_entry); } /* 8000DFF0-8000E014 .text entry__13mDoExt_bpkAnmFP12J3DModelDataf */ -void mDoExt_bpkAnm::entry(J3DModelData*, f32) { +void mDoExt_bpkAnm::entry(J3DModelData* i_modelData, f32 param_1) { + entry(&i_modelData->getMaterialTable(), param_1); /* Nonmatching */ } /* 8000E014-8000E2A8 .text init__13mDoExt_bpkAnmFP16J3DMaterialTableP11J3DAnmColoriifssbi */ -int mDoExt_bpkAnm::init(J3DMaterialTable*, J3DAnmColor*, int, int, f32, s16, s16, bool, int) { - /* Nonmatching */ +int mDoExt_bpkAnm::init(J3DMaterialTable* i_matTable, J3DAnmColor* i_bpk, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { + + JUT_ASSERT(531, i_modify || isCurrentSolidHeap()); + JUT_ASSERT(533, i_matTable != 0 && i_bpk != 0); + mpAnm = i_bpk; + mpAnm->searchUpdateMaterialID(i_matTable); + + u16 updateMaterialNum = mpAnm->getUpdateMaterialNum(); + if (!i_modify) { + mUpdateMaterialNum = updateMaterialNum; + JUT_ASSERT(541, mUpdateMaterialNum); + field_0xc = new J3DMatColorAnm[mUpdateMaterialNum]; + if (!field_0xc) { + return 0; + } + } + JUT_ASSERT(548, updateMaterialNum <= mUpdateMaterialNum); + J3DMatColorAnm* matColorAnm = field_0xc; + for (u16 i = 0; i < updateMaterialNum; i++) { + matColorAnm->setAnmColor(mpAnm); + matColorAnm->setAnmIndex(i); + matColorAnm++; + } + + if (!i_modify && i_entry) { + i_matTable->setMatColorAnimator(mpAnm, field_0xc); + } + + if (i_anmPlay) { + if (initPlay(mpAnm->getFrameMax(), i_attribute, i_rate, i_startF, i_endF, i_modify) == 0) { + return 0; + } + } + return 1; } /* 8000E2F4-8000E32C .text entry__13mDoExt_bpkAnmFP16J3DMaterialTablef */ -void mDoExt_bpkAnm::entry(J3DMaterialTable*, f32) { - /* Nonmatching */ +void mDoExt_bpkAnm::entry(J3DMaterialTable* i_matTable, f32 i_frame) { + mpAnm->setFrame(i_frame); + i_matTable->setMatColorAnimator(mpAnm, field_0xc); } /* 8000E32C-8000E358 .text init__13mDoExt_btpAnmFP12J3DModelDataP16J3DAnmTexPatterniifssbi */ -int mDoExt_btpAnm::init(J3DModelData*, J3DAnmTexPattern*, int, int, f32, s16, s16, bool, int) { - /* Nonmatching */ +int mDoExt_btpAnm::init(J3DModelData* i_modelData, J3DAnmTexPattern* i_btp, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { + init(&i_modelData->getMaterialTable(), i_btp, i_anmPlay, i_attribute, i_rate, i_startF, i_endF, i_modify, i_entry); +} + +/* 8000E358-8000E37C .text entry__13mDoExt_btpAnmFP12J3DModelDatas */ +void mDoExt_btpAnm::entry(J3DModelData* i_modelData, s16 i_frame) { + entry(&i_modelData->getMaterialTable(), i_frame); } /* 8000E37C-8000E610 .text init__13mDoExt_btpAnmFP16J3DMaterialTableP16J3DAnmTexPatterniifssbi */ -int mDoExt_btpAnm::init(J3DMaterialTable*, J3DAnmTexPattern*, int, int, f32, s16, s16, bool, int) { +int mDoExt_btpAnm::init(J3DMaterialTable* i_matTable, J3DAnmTexPattern* i_btp, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { /* Nonmatching */ + JUT_ASSERT(648, i_modify || isCurrentSolidHeap()); + JUT_ASSERT(650, i_matTable != 0 && i_btp != 0); + mpAnm = i_btp; + mpAnm->searchUpdateMaterialID(i_matTable); + + u16 updateMaterialNum = mpAnm->getUpdateMaterialNum(); + if (!i_modify) { + mUpdateMaterialNum = updateMaterialNum; + JUT_ASSERT(658, mUpdateMaterialNum); + field_0xc = new J3DTexNoAnm[mUpdateMaterialNum]; + if (!field_0xc) { + return 0; + } + } + JUT_ASSERT(665, updateMaterialNum <= mUpdateMaterialNum); + J3DTexNoAnm* texNoAnm = field_0xc; + for (u16 i = 0; i < updateMaterialNum; i++) { + texNoAnm->setAnmTexPattern(mpAnm); + texNoAnm->setAnmIndex(i); + texNoAnm++; + } + + if (!i_modify && i_entry) { + i_matTable->setTexNoAnimator(mpAnm, field_0xc); + } + + if (i_anmPlay) { + if (initPlay(mpAnm->getFrameMax(), i_attribute, i_rate, i_startF, i_endF, i_modify) == 0) { + return 0; + } + } + return 1; } /* 8000E674-8000E6CC .text entry__13mDoExt_btpAnmFP16J3DMaterialTables */ -void mDoExt_btpAnm::entry(J3DMaterialTable*, s16) { - /* Nonmatching */ +void mDoExt_btpAnm::entry(J3DMaterialTable* i_matTable, s16 i_frame) { + mpAnm->setFrame(i_frame); + i_matTable->setTexNoAnimator(mpAnm, field_0xc); } /* 8000E6CC-8000E6F8 .text init__13mDoExt_btkAnmFP12J3DModelDataP19J3DAnmTextureSRTKeyiifssbi */ -int mDoExt_btkAnm::init(J3DModelData*, J3DAnmTextureSRTKey*, int, int, f32, s16, s16, bool, int) { - /* Nonmatching */ +int mDoExt_btkAnm::init(J3DModelData* i_modelData, J3DAnmTextureSRTKey* i_btk, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { + init(&i_modelData->getMaterialTable(), i_btk, i_anmPlay, i_attribute, i_rate, i_startF, i_endF, i_modify, i_entry); } /* 8000E6F8-8000E71C .text entry__13mDoExt_btkAnmFP12J3DModelDataf */ -void mDoExt_btkAnm::entry(J3DModelData*, f32) { - /* Nonmatching */ +void mDoExt_btkAnm::entry(J3DModelData* i_modelData, f32 i_frame) { + entry(&i_modelData->getMaterialTable(), i_frame); } /* 8000E71C-8000EAE4 .text init__13mDoExt_btkAnmFP16J3DMaterialTableP19J3DAnmTextureSRTKeyiifssbi */ -int mDoExt_btkAnm::init(J3DMaterialTable*, J3DAnmTextureSRTKey*, int, int, f32, s16, s16, bool, int) { +int mDoExt_btkAnm::init(J3DMaterialTable* i_matTable, J3DAnmTextureSRTKey* i_btk, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { /* Nonmatching */ -} + JUT_ASSERT(781, i_modify || isCurrentSolidHeap()); + JUT_ASSERT(783, i_matTable != 0 && i_btk != 0); + mpAnm = i_btk; + mpAnm->searchUpdateMaterialID(i_matTable); -/* 8000EB30-8000EB38 .text getTexMtx__14J3DTexGenBlockFUl */ -J3DTexMtx* J3DTexGenBlock::getTexMtx(u32) { - /* Nonmatching */ + u16 updateMaterialNum = mpAnm->getUpdateMaterialNum(); + if (!i_modify) { + mUpdateMaterialNum = updateMaterialNum; + JUT_ASSERT(791, mUpdateMaterialNum); + for (u16 i = 0; i < mUpdateMaterialNum; i++) { + u16 materialId = mpAnm->getUpdateMaterialID(i); + if (materialId != 0xFFFF) { + J3DMaterial* material = i_matTable->getMaterialNodePointer(materialId); + u8 texMtxId = mpAnm->getUpdateTexMtxID(i); + if (texMtxId != 0xFF) { + J3DTexMtx* texMtx = material->getTexGenBlock()->getTexMtx(texMtxId); + if (!texMtx) { + texMtx = new J3DTexMtx(); + } + } + } + } + mpTexMtxAnm = new J3DTexMtxAnm[mUpdateMaterialNum]; + if (!mpTexMtxAnm) { + return 0; + } + } + JUT_ASSERT(811, updateMaterialNum <= mUpdateMaterialNum); + J3DTexMtxAnm* texMtxAnm = mpTexMtxAnm; + for (u16 i = 0; i < updateMaterialNum; i++) { + texMtxAnm->setAnmTransform(mpAnm); + texMtxAnm->setAnmIndex(i); + texMtxAnm++; + } + + if (!i_modify && i_entry) { + i_matTable->setTexMtxAnimator(mpAnm, mpTexMtxAnm, NULL); + } + + if (i_anmPlay) { + if (initPlay(mpAnm->getFrameMax(), i_attribute, i_rate, i_startF, i_endF, i_modify) == 0) { + return 0; + } + } + return 1; } /* 8000EB38-8000EB74 .text entry__13mDoExt_btkAnmFP16J3DMaterialTablef */ -void mDoExt_btkAnm::entry(J3DMaterialTable*, f32) { - /* Nonmatching */ +void mDoExt_btkAnm::entry(J3DMaterialTable* i_matTable, f32 i_frame) { + mpAnm->setFrame(i_frame); + i_matTable->setTexMtxAnimator(mpAnm, mpTexMtxAnm, NULL); } /* 8000EB74-8000EBA0 .text init__13mDoExt_brkAnmFP12J3DModelDataP15J3DAnmTevRegKeyiifssbi */ @@ -104,7 +292,55 @@ void mDoExt_brkAnm::entry(J3DModelData* i_modelData, f32 i_frame) { } /* 8000EBC4-8000EEE8 .text init__13mDoExt_brkAnmFP16J3DMaterialTableP15J3DAnmTevRegKeyiifssbi */ -int mDoExt_brkAnm::init(J3DMaterialTable*, J3DAnmTevRegKey*, int, int, f32, s16, s16, bool, int) { +int mDoExt_brkAnm::init(J3DMaterialTable* i_matTable, J3DAnmTevRegKey* i_brk, int i_anmPlay, int i_attribute, f32 i_rate, s16 i_startF, s16 i_endF, bool i_modify, int i_entry) { + JUT_ASSERT(910, i_modify || isCurrentSolidHeap()); + JUT_ASSERT(912, i_matTable != 0 && i_brk != 0); + mpAnm = i_brk; + mpAnm->searchUpdateMaterialID(i_matTable); + + u16 CRegUpdateMaterialNum = mpAnm->getCRegUpdateMaterialNum(); + if (!i_modify) { + mCRegUpdateMaterialNum = CRegUpdateMaterialNum; + mpCRegAnm = new J3DTevColorAnm[mCRegUpdateMaterialNum]; + if (!mpCRegAnm) { + return 0; + } + } + JUT_ASSERT(926, CRegUpdateMaterialNum <= mCRegUpdateMaterialNum); + u16 KRegUpdateMaterialNum = mpAnm->getKRegUpdateMaterialNum(); + if (!i_modify) { + mKRegUpdateMaterialNum = KRegUpdateMaterialNum; + mpKRegAnm = new J3DTevKColorAnm[mKRegUpdateMaterialNum]; + if (!mpKRegAnm) { + return 0; + } + } + JUT_ASSERT(937, KRegUpdateMaterialNum <= mKRegUpdateMaterialNum); + + J3DTevColorAnm* cRegAnm = mpCRegAnm; + for (u16 i = 0; i < CRegUpdateMaterialNum; i++) { + cRegAnm->setAnmIndex(i); + cRegAnm->setAnmTevReg(mpAnm); + cRegAnm++; + } + J3DTevKColorAnm* kRegAnm = mpKRegAnm; + for (u16 i = 0; i < KRegUpdateMaterialNum; i++) { + kRegAnm->setAnmIndex(i); + kRegAnm->setAnmTevReg(mpAnm); + kRegAnm++; + } + + if (!i_modify && i_entry) { + i_matTable->setTevRegAnimator(mpAnm, mpCRegAnm, mpKRegAnm); + } + + if (i_anmPlay) { + if (initPlay(mpAnm->getFrameMax(), i_attribute, i_rate, i_startF, i_endF, i_modify) == 0) { + return 0; + } + } + return 1; + /* Nonmatching */ } @@ -343,11 +579,6 @@ void J3DTevStage::setTevStageInfo(const J3DTevStageInfo&) { /* Nonmatching */ } -/* 80011110-800111B4 .text __ct__9J3DTexMtxFv */ -J3DTexMtx::J3DTexMtx() { - /* Nonmatching */ -} - /* 800111B4-800111D4 .text __ct__11J3DTexCoordFv */ J3DTexCoord::J3DTexCoord() { /* Nonmatching */