diff --git a/docs/recommended_todo.md b/docs/recommended_todo.md index 30d442b17..994bd4637 100644 --- a/docs/recommended_todo.md +++ b/docs/recommended_todo.md @@ -75,13 +75,13 @@ ###
plugProjectKandoU
| File | Size (bytes) | File | Size (bytes) | | ---- | ---- | ---- | ---- | -| flockMgr.cpp | 7469 | cellIterator.cpp | 9332 | -| creatureLOD.cpp | 10127 | aiEnter.cpp | 10852 | -| naviWhistle.cpp | 11601 | itemHoney.cpp | 12303 | -| itemWeed.cpp | 13922 | aiBreakGate.cpp | 13960 | +| flockMgr.cpp | 7475 | itemWeed.cpp | 9106 | +| cellIterator.cpp | 9332 | creatureLOD.cpp | 10127 | +| aiEnter.cpp | 10852 | naviWhistle.cpp | 11601 | +| itemHoney.cpp | 12303 | aiBreakGate.cpp | 13960 | | gameCaveInfo.cpp | 16141 | texCaster.cpp | 16211 | | singleGS_CaveResult.cpp | 19749 | itemCave.cpp | 20301 | -| pathfinder.cpp | 20409 | itemPikihead.cpp | 23892 | +| pathfinder.cpp | 20409 | itemPikihead.cpp | 23940 | | gameCPlate.cpp | 24190 | dynCreature.cpp | 25766 | | gameDynamics.cpp | 27114 | vsCardMgr.cpp | 30814 | | singleGS_MainGame.cpp | 31727 | itemBridge.cpp | 32179 | diff --git a/include/Game/Entities/ItemWeed.h b/include/Game/Entities/ItemWeed.h index 4408aa65f..413cf9403 100644 --- a/include/Game/Entities/ItemWeed.h +++ b/include/Game/Entities/ItemWeed.h @@ -74,71 +74,12 @@ struct WaitState : public State { u32 _0C; }; -struct Item : public FSMItem { - struct DummyShape : public SysShape::MtxObject { - virtual Matrixf* getMatrix(int); // _08 (weak) - - // _00 VTBL - Matrixf* mMatrix; // _04 - }; - - Item(); // unused/inlined - - inline Item(int objTypeID) // probably - : FSMItem(objTypeID) - { - } - - virtual void onInit(CreatureInitArg* initArg); // _30 - virtual BaseFlockMgr* getFlockMgr(); // _90 (weak) - virtual bool isCollisionFlick(); // _B0 (weak) - virtual bool ignoreAtari(Creature* toIgnore); // _190 - virtual char* getCreatureName(); // _1A8 (weak) - virtual void makeTrMatrix(); // _1C4 (weak) - virtual void doAI(); // _1C8 - virtual bool interactFlockAttack(InteractFlockAttack&); // _1EC - virtual void updateBoundSphere(); // _210 - virtual void onSetPosition(); // _21C - virtual void doSimpleDraw(Viewport* viewport); // _224 - - void setBoidTimer(); - - // _00 = VTABLE - // _00-_1E0 = FSMItem - DummyShape mDummyShape; // _1E0 - WeedMgr* mFlockMgr; // _1E8 - cWeedType mWeedType; // _1EC -}; - -struct Mgr : public TNodeItemMgr { - Mgr(); - - virtual void doSimpleDraw(Viewport* viewport); // _20 - virtual void onLoadResources(); // _48 - virtual u32 generatorGetID(); // _58 (weak) - virtual BaseItem* generatorBirth(Vector3f&, Vector3f&, GenItemParm*); // _5C - virtual void generatorWrite(Stream& output, GenItemParm* genItemParm); // _60 - virtual void generatorRead(Stream& input, GenItemParm* genItemParm, u32 version); // _64 - virtual u32 generatorLocalVersion(); // _68 (weak) - virtual GenItemParm* generatorNewItemParm(); // _70 - virtual BaseItem* doNew(); // _A0 (weak) - virtual ~Mgr(); // _B8 (weak) - virtual char* getCaveName(int); // _BC - virtual int getCaveID(char*); // _C0 - - // unused/inlined: - Item* birth(); - - // _00 = VTBL - // _00-_88 = TNodeItemMgr -}; - struct Weed : public TFlock { Weed(); - virtual void makeMatrix(); // _08 - virtual bool isWeed(); // _10 (weak) - virtual bool damaged(f32); // _1C + virtual void makeMatrix(); // _08 + virtual bool isWeed() { return mModelIdx == 0; } // _10 (weak) + virtual bool damaged(f32); // _1C // unused/inlined: void init(ItemWeed::WeedMgr*, Vector3f&); @@ -162,7 +103,7 @@ struct WeedMgr : public TFlockMgr { virtual void do_update(); // _1C virtual void do_update_boundSphere(); // _20 - virtual ~WeedMgr(); // _6C (weak) + // virtual ~WeedMgr(); // _6C (weak) // unused/inlined: void init(Sys::Sphere&, cWeedType); @@ -172,6 +113,67 @@ struct WeedMgr : public TFlockMgr { // _00-_6C = TFlockMgr }; +struct Item : public FSMItem { + struct DummyShape : public SysShape::MtxObject { + virtual Matrixf* getMatrix(int) { return mMatrix; } // _08 (weak) + + // _00 VTBL + Matrixf* mMatrix; // _04 + }; + + Item(); // unused/inlined + + inline Item(int objTypeID) // probably + : FSMItem(objTypeID) + { + } + + virtual void onInit(CreatureInitArg* initArg); // _30 + virtual bool isCollisionFlick(); // _B0 (weak) + virtual bool ignoreAtari(Creature* toIgnore); // _190 + virtual void doAI(); // _1C8 + virtual bool interactFlockAttack(InteractFlockAttack&); // _1EC + virtual void updateBoundSphere(); // _210 + virtual void onSetPosition(); // _21C + virtual void doSimpleDraw(Viewport* viewport); // _224 + virtual char* getCreatureName() { return "Weed"; } // _1A8 (weak) + virtual BaseFlockMgr* getFlockMgr() { return mFlockMgr; } // _90 (weak) + virtual void makeTrMatrix() { } // _1C4 (weak) + + void setBoidTimer(); + + inline WeedMgr* getWeedMgr() { return mFlockMgr; } + + // _00 = VTABLE + // _00-_1E0 = FSMItem + DummyShape mDummyShape; // _1E0 + WeedMgr* mFlockMgr; // _1E8 + cWeedType mWeedType; // _1EC +}; + +struct Mgr : public TNodeItemMgr { + Mgr(); + + virtual void doSimpleDraw(Viewport* viewport); // _20 + virtual void onLoadResources(); // _48 + virtual BaseItem* generatorBirth(Vector3f&, Vector3f&, GenItemParm*); // _5C + virtual void generatorWrite(Stream& output, GenItemParm* genItemParm); // _60 + virtual void generatorRead(Stream& input, GenItemParm* genItemParm, u32 version); // _64 + virtual GenItemParm* generatorNewItemParm(); // _70 + virtual ~Mgr(); // _B8 (weak) + virtual char* getCaveName(int); // _BC + virtual int getCaveID(char*); // _C0 + virtual BaseItem* doNew() { return new Item; } // _A0 (weak) + virtual u32 generatorGetID() { return 'weed'; } // _58 (weak) + virtual u32 generatorLocalVersion() { return '0001'; } // _68 (weak) + + // unused/inlined: + Item* birth(); + + // _00 = VTBL + // _00-_88 = TNodeItemMgr +}; + extern Mgr* mgr; } // namespace ItemWeed diff --git a/include/Game/flockMgr.h b/include/Game/flockMgr.h index 701a5e1da..67b767557 100644 --- a/include/Game/flockMgr.h +++ b/include/Game/flockMgr.h @@ -13,7 +13,7 @@ struct J3DModelData; namespace Game { struct TFlock : public Vector3f { inline TFlock() - : _40(0) + : mModelIdx(0) { } @@ -28,7 +28,7 @@ struct TFlock : public Vector3f { // _00 - _0C Vector3f // _0C VTBL Matrixf mTransformationMtx; // _10 - u8 _40; // _40 + u8 mModelIdx; // _40 }; struct BaseFlockMgr { diff --git a/src/plugProjectKandoU/aiWeed.cpp b/src/plugProjectKandoU/aiWeed.cpp index 11dd21e70..f39c6bca3 100644 --- a/src/plugProjectKandoU/aiWeed.cpp +++ b/src/plugProjectKandoU/aiWeed.cpp @@ -51,7 +51,7 @@ void ActWeed::init(ActionArg* arg) JUT_ASSERTLINE(124, arg, "no actweedarg"); mWeed = weedArg->mWeed; JUT_ASSERTLINE(127, mWeed, "ActWeed:no target"); - mFlockMgr = mWeed->getFlockMgr(); + mFlockMgr = static_cast(mWeed)->getFlockMgr(); JUT_ASSERTLINE(130, mFlockMgr, "no flockmgr"); mIsAttacking = false; diff --git a/src/plugProjectKandoU/flockMgr.cpp b/src/plugProjectKandoU/flockMgr.cpp index 1960553cf..47370eb01 100644 --- a/src/plugProjectKandoU/flockMgr.cpp +++ b/src/plugProjectKandoU/flockMgr.cpp @@ -340,7 +340,7 @@ void BaseFlockMgr::doSimpleDraw(Viewport* vp, J3DModelData** models, int p1) for (int j = 0; j < getMaxObjects(); j++) { TFlock* flock = getFlock(j); if (isFlagAlive(j)) { - if (flock->isVisible() && flock->_40 == i) { + if (flock->isVisible() && flock->mModelIdx == i) { Matrixf mtx; PSMTXConcat(vp->getMatrix(true)->mMatrix.mtxView, flock->mTransformationMtx.mMatrix.mtxView, mtx.mMatrix.mtxView); diff --git a/src/plugProjectKandoU/itemPikihead.cpp b/src/plugProjectKandoU/itemPikihead.cpp index a5901ace7..f454e0366 100644 --- a/src/plugProjectKandoU/itemPikihead.cpp +++ b/src/plugProjectKandoU/itemPikihead.cpp @@ -460,25 +460,22 @@ void Item::cacheLoad(Stream& input) */ void Item::makeTrMatrix() { - if (getStateID() == PIKIHEAD_Fall) { - if (mVelocity.length() > 0.0f) { - Vector3f xVec = mVelocity; - _normalise2(xVec); - xVec *= -1.0f; + if (getStateID() == PIKIHEAD_Fall && mVelocity.length() > 0.0f) { + Vector3f yVec = mVelocity; + yVec.normalise(); + yVec = yVec * -1.0f; - Vector3f zAxis(0.0f, 0.0f, -5.0f); - Vector3f yVec = cross(xVec, zAxis); - _normalise2(yVec); + Vector3f zAxis(0.0f, 0.0f, 1.0f); + Vector3f xVec = yVec.cross(zAxis); + xVec.normalise(); - Vector3f xAxis(1.0f, 0.0f, 0.0f); - Vector3f zVec = cross(yVec, xAxis); - _normalise2(zVec); + Vector3f zVec = xVec.cross(yVec); + zVec.normalise(); - mBaseTrMatrix.setColumn(0, xVec); - mBaseTrMatrix.setColumn(1, yVec); - mBaseTrMatrix.setColumn(2, zVec); - mBaseTrMatrix.setTranslation(mPosition); - } + mBaseTrMatrix.setColumn(0, xVec); + mBaseTrMatrix.setColumn(1, yVec); + mBaseTrMatrix.setColumn(2, zVec); + mBaseTrMatrix.setTranslation(mPosition); } else { BaseItem::makeTrMatrix(); } @@ -677,19 +674,20 @@ void Item::doAI() */ void Item::changeMaterial() { - J3DMaterial* mat = mModel->mJ3dModel->getModelData()->getMaterialNodePointer(0); - if (mat) { + // J3DMaterial* mat = mModel->mJ3dModel->getModelData()->getMaterialNodePointer(0); + if (mModel->mJ3dModel->getModelData()->getMaterialNodePointer(0)) { Color4 pikiColor = Piki::pikiColors[mColor]; - mat->getTevBlock()->setTevColor(0, J2DGXColorS10(pikiColor.r, pikiColor.g, pikiColor.b, pikiColor.a)); + mModel->mJ3dModel->getModelData()->getMaterialNodePointer(0)->getTevBlock()->setTevColor( + 0, J2DGXColorS10(pikiColor.r, pikiColor.g, pikiColor.b, pikiColor.a)); } mModel->mJ3dModel->calcMaterial(); for (u16 i = 0; i < mModel->mJ3dModel->getModelData()->getMaterialNum(); i++) { - J3DMatPacket* packet = mModel->getJ3DModel()->getMatPacket(i); + J3DMatPacket* packet = mModel->mJ3dModel->getMatPacket(i); if (packet->mInitShapePacket->mDisplayList) { packet->beginDiff(); - mModel->mJ3dModel->getModelData()->getMaterialNodePointer(i)->mTevBlock->diff(0x1000000); + mModel->mJ3dModel->getModelData()->getMaterialNodePointer(i)->getTevBlock()->diff(0x1000000); packet->endDiff(); } } diff --git a/src/plugProjectKandoU/itemWeed.cpp b/src/plugProjectKandoU/itemWeed.cpp index e7fa9554a..e3cda5181 100644 --- a/src/plugProjectKandoU/itemWeed.cpp +++ b/src/plugProjectKandoU/itemWeed.cpp @@ -103,18 +103,19 @@ void WeedMgr::init(Sys::Sphere& sphere, cWeedType weedType) */ void WeedMgr::createWeeds(cWeedType weedType) { + Weed* weed; for (int i = 0; i < getMaxObjects(); i++) { - Weed* weed = mMonoObjectMgr.birth(); + weed = mMonoObjectMgr.birth(); if (weed) { if (weedType == WEEDTYPE_Grass) { - weed->_40 = 0; + weed->mModelIdx = 0; } else { - weed->_40 = (int)(randFloat() * 3.0f) + 1; + weed->mModelIdx = (int)(randFloat() * 3.0f) + 1; // random between 1 and 4 } f32 randRadius = mActivationSpherePosition.mRadius * randFloat(); f32 randTheta = randFloat() * TAU; - Vector3f weedPos - = Vector3f(randRadius * sinf(randTheta), 0.0f, randRadius * cosf(randTheta)) + mActivationSpherePosition.mPosition; + Vector3f weedPos(randRadius * sinf(randTheta), 0.0f, randRadius * cosf(randTheta)); + weedPos += mActivationSpherePosition.mPosition; weed->init(this, weedPos); } } @@ -189,180 +190,9 @@ void Item::onInit(CreatureInitArg* initArg) void Item::onSetPosition() { mBaseTrMatrix.makeT(mPosition); - Sys::Sphere sphere(mPosition, mBoundingSphere.mRadius); + f32 radius = mBoundingSphere.mRadius; + Sys::Sphere sphere(mPosition, radius); mFlockMgr->init(sphere, mWeedType); - /* - stwu r1, -0x50(r1) - mflr r0 - stw r0, 0x54(r1) - stfd f31, 0x40(r1) - psq_st f31, 72(r1), 0, qr0 - stw r31, 0x3c(r1) - stw r30, 0x38(r1) - stw r29, 0x34(r1) - stw r28, 0x30(r1) - mr r28, r3 - addi r3, r28, 0x138 - addi r4, r28, 0x19c - bl "makeT__7MatrixfFR10Vector3" - lfs f3, 0x1d0(r28) - li r29, 0 - lfs f1, 0x1a0(r28) - lfs f2, 0x1a4(r28) - lwz r30, 0x1ec(r28) - lwz r31, 0x1e8(r28) - lfs f0, 0x19c(r28) - stfs f0, 0xc(r31) - stfs f1, 0x10(r31) - stfs f2, 0x14(r31) - stfs f3, 0x18(r31) - b lbl_8020F9CC - -lbl_8020F818: - addi r3, r31, 0x3c - lwz r12, 0x3c(r31) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - or. r28, r3, r3 - beq lbl_8020F9C8 - cmpwi r30, 1 - bne lbl_8020F848 - li r0, 0 - stb r0, 0x40(r28) - b lbl_8020F88C - -lbl_8020F848: - bl rand - xoris r3, r3, 0x8000 - lis r0, 0x4330 - stw r3, 0xc(r1) - lfd f3, lbl_80519F08@sda21(r2) - stw r0, 8(r1) - lfs f1, lbl_80519F00@sda21(r2) - lfd f2, 8(r1) - lfs f0, lbl_80519F14@sda21(r2) - fsubs f2, f2, f3 - fdivs f1, f2, f1 - fmuls f0, f0, f1 - fctiwz f0, f0 - stfd f0, 0x10(r1) - lwz r3, 0x14(r1) - addi r0, r3, 1 - stb r0, 0x40(r28) - -lbl_8020F88C: - bl rand - xoris r3, r3, 0x8000 - lis r0, 0x4330 - stw r3, 0x14(r1) - lfd f3, lbl_80519F08@sda21(r2) - stw r0, 0x10(r1) - lfs f1, lbl_80519F00@sda21(r2) - lfd f2, 0x10(r1) - lfs f0, 0x18(r31) - fsubs f2, f2, f3 - fdivs f1, f2, f1 - fmuls f31, f0, f1 - bl rand - xoris r3, r3, 0x8000 - lis r0, 0x4330 - stw r3, 0xc(r1) - lfd f3, lbl_80519F08@sda21(r2) - stw r0, 8(r1) - lfs f2, lbl_80519F00@sda21(r2) - lfd f0, 8(r1) - lfs f1, lbl_80519F04@sda21(r2) - fsubs f3, f0, f3 - lfs f0, lbl_80519EF8@sda21(r2) - fdivs f2, f3, f2 - fmuls f3, f1, f2 - fmr f1, f3 - fcmpo cr0, f3, f0 - bge lbl_8020F900 - fneg f1, f3 - -lbl_8020F900: - lfs f2, lbl_80519F18@sda21(r2) - lis r3, sincosTable___5JMath@ha - lfs f0, lbl_80519EF8@sda21(r2) - addi r4, r3, sincosTable___5JMath@l - fmuls f1, f1, f2 - fcmpo cr0, f3, f0 - fctiwz f0, f1 - stfd f0, 0x18(r1) - lwz r0, 0x1c(r1) - rlwinm r0, r0, 3, 0x12, 0x1c - add r3, r4, r0 - lfs f0, 4(r3) - fmuls f4, f31, f0 - bge lbl_8020F95C - lfs f0, lbl_80519F1C@sda21(r2) - fmuls f0, f3, f0 - fctiwz f0, f0 - stfd f0, 0x20(r1) - lwz r0, 0x24(r1) - rlwinm r0, r0, 3, 0x12, 0x1c - lfsx f0, r4, r0 - fneg f1, f0 - b lbl_8020F974 - -lbl_8020F95C: - fmuls f0, f3, f2 - fctiwz f0, f0 - stfd f0, 0x28(r1) - lwz r0, 0x2c(r1) - rlwinm r0, r0, 3, 0x12, 0x1c - lfsx f1, r4, r0 - -lbl_8020F974: - lfs f0, 0x14(r31) - fmuls f3, f31, f1 - lfs f2, 0xc(r31) - mr r3, r28 - lfs f1, 0x10(r31) - fadds f4, f4, f0 - lfs f0, lbl_80519EFC@sda21(r2) - stw r31, 0x50(r28) - fadds f3, f3, f2 - lfs f2, lbl_80519EF8@sda21(r2) - stfs f0, 0x44(r28) - fadds f2, f2, f1 - stfs f0, 0x48(r28) - stfs f0, 0x4c(r28) - stfs f3, 0(r28) - stfs f2, 4(r28) - stfs f4, 8(r28) - lwz r12, 0xc(r28) - lwz r12, 8(r12) - mtctr r12 - bctrl - -lbl_8020F9C8: - addi r29, r29, 1 - -lbl_8020F9CC: - mr r3, r31 - lwz r12, 0(r31) - lwz r12, 8(r12) - mtctr r12 - bctrl - cmpw r29, r3 - blt lbl_8020F818 - lfs f1, lbl_80519F10@sda21(r2) - mr r3, r31 - bl resolveCollision__Q24Game12BaseFlockMgrFf - psq_l f31, 72(r1), 0, qr0 - lwz r0, 0x54(r1) - lfd f31, 0x40(r1) - lwz r31, 0x3c(r1) - lwz r30, 0x38(r1) - lwz r29, 0x34(r1) - lwz r28, 0x30(r1) - mtlr r0 - addi r1, r1, 0x50 - blr - */ } /** @@ -573,59 +403,5 @@ BaseItem* Mgr::generatorBirth(Vector3f& position, Vector3f& p2, GenItemParm* gen return item; } -/** - * @note Address: 0x802105CC - * @note Size: 0x134 - */ -Mgr::~Mgr() { } - -/** - * @note Address: 0x80210700 - * @note Size: 0x148 - */ -BaseItem* Mgr::doNew() { return new Item; } - -/** - * @note Address: 0x80210848 - * @note Size: 0xC - */ -u32 Mgr::generatorGetID() { return 'weed'; } - -/** - * @note Address: 0x80210854 - * @note Size: 0xC - */ -u32 Mgr::generatorLocalVersion() { return '0001'; } - -/** - * @note Address: 0x80210860 - * @note Size: 0x8 - */ -char* Item::getCreatureName() { return "Weed"; } - -/** - * @note Address: 0x80210868 - * @note Size: 0x8 - */ -BaseFlockMgr* Item::getFlockMgr() { return mFlockMgr; } - -/** - * @note Address: 0x80210870 - * @note Size: 0x4 - */ -void Item::makeTrMatrix() { } - -/** - * @note Address: 0x80210874 - * @note Size: 0x8 - */ -Matrixf* Item::DummyShape::getMatrix(int) { return mMatrix; } - -/** - * @note Address: 0x802108B0 - * @note Size: 0x118 - */ -WeedMgr::~WeedMgr() { } - } // namespace ItemWeed } // namespace Game