diff --git a/configure.py b/configure.py index 6ddf077e..8beaaf09 100755 --- a/configure.py +++ b/configure.py @@ -419,8 +419,8 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "plugPikiKando/omake.cpp"), Object(Matching, "plugPikiKando/radarInfo.cpp"), Object(NonMatching, "plugPikiKando/interactBattle.cpp"), - Object(NonMatching, "plugPikiKando/interactGrab.cpp"), - Object(NonMatching, "plugPikiKando/interactEtc.cpp"), + Object(Matching, "plugPikiKando/interactGrab.cpp"), + Object(Matching, "plugPikiKando/interactEtc.cpp"), Object(NonMatching, "plugPikiKando/interactPullout.cpp"), Object(Matching, "plugPikiKando/saiEvents.cpp"), Object(NonMatching, "plugPikiKando/simpleAI.cpp"), @@ -541,7 +541,7 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "plugPikiKando/naviMgr.cpp"), Object(NonMatching, "plugPikiKando/genMapParts.cpp"), Object(NonMatching, "plugPikiKando/mapParts.cpp"), - Object(NonMatching, "plugPikiKando/panipikianimator.cpp"), + Object(Matching, "plugPikiKando/panipikianimator.cpp"), Object(NonMatching, "plugPikiKando/actor.cpp"), Object(Matching, "plugPikiKando/actorMgr.cpp"), Object(NonMatching, "plugPikiKando/genActor.cpp"), diff --git a/include/AICreature.h b/include/AICreature.h index 6f0e024b..4b9014fe 100644 --- a/include/AICreature.h +++ b/include/AICreature.h @@ -18,24 +18,24 @@ struct StateMachine; struct AICreature : public Creature, public PaniAnimKeyListener { AICreature(CreatureProp*); - virtual void collisionCallback(CollEvent&); // _A8 - virtual void bounceCallback(); // _AC - virtual void refresh(Graphics&) = 0; // _EC - virtual void doKill() = 0; // _10C - virtual AState* getCurrState(); // _120 (weak) - virtual void setCurrState(AState*); // _124 (weak) - virtual void playSound(int); // _128 (weak) - virtual void playEffect(int); // _12C (weak) - virtual void startMotion(int); // _130 (weak) - virtual void finishMotion(); // _134 (weak) - virtual void finishMotion(f32); // _138 (weak) - virtual void startMotion(int, f32); // _13C (weak) - virtual void getCurrentMotionName(); // _140 (weak) - virtual void getCurrentMotionCounter(); // _144 (weak) - virtual void getMotionSpeed(); // _148 (weak) - virtual void setMotionSpeed(f32); // _14C (weak) - virtual void stopMotion(); // _150 (weak) - virtual void animationKeyUpdated(PaniAnimKeyEvent&); // _154 (weak) + virtual void collisionCallback(CollEvent&); // _A8 + virtual void bounceCallback(); // _AC + virtual void refresh(Graphics&) = 0; // _EC + virtual void doKill() = 0; // _10C + virtual AState* getCurrState() { return mCurrentState; } // _120 (weak) + virtual void setCurrState(AState*); // _124 (weak) + virtual void playSound(int) { } // _128 (weak) + virtual void playEffect(int) { } // _12C (weak) + virtual void startMotion(int); // _130 (weak) + virtual void finishMotion(); // _134 (weak) + virtual void finishMotion(f32); // _138 (weak) + virtual void startMotion(int, f32); // _13C (weak) + virtual char* getCurrentMotionName(); // _140 (weak) + virtual f32 getCurrentMotionCounter(); // _144 (weak) + virtual f32 getMotionSpeed(); // _148 (weak) + virtual void setMotionSpeed(f32); // _14C (weak) + virtual void stopMotion(); // _150 (weak) + virtual void animationKeyUpdated(PaniAnimKeyEvent&); // _154 (weak) void clearEventFlags(); void setEventFlag(int, bool); diff --git a/include/Animator.h b/include/Animator.h index 7d395a3d..fd2f9e77 100644 --- a/include/Animator.h +++ b/include/Animator.h @@ -197,6 +197,11 @@ struct AnimKey { */ struct AnimInfo : public CoreNode { + enum AnimInfoFlags { + FLAG_Unk1 = 0x1, + FLAG_Unk2 = 0x2, + }; + /** * @brief Fabricated. Offsets relative to AnimInfo for convenience. */ @@ -230,6 +235,8 @@ struct AnimInfo : public CoreNode { // unused/inlined: void initAnimData(AnimData*); + inline f32 getAnimSpeed() { return mParams.mSpeed(); } + // _00 = VTBL // _00-_14 = CoreNode AnimInfoParams mParams; // _14 diff --git a/include/BaseInf.h b/include/BaseInf.h index 092dee1d..7a3c71d7 100644 --- a/include/BaseInf.h +++ b/include/BaseInf.h @@ -49,8 +49,8 @@ struct BPikiInf : public BaseInf { // _00 = VTBL // _00-_2C = BaseInf - u8 mPikiColor; // _2C - u8 mPikiHappa; // _2D + u8 _2C; // _2C + u8 _2D; // _2D }; /** diff --git a/include/Collision.h b/include/Collision.h index 771fd6df..0f04fdda 100644 --- a/include/Collision.h +++ b/include/Collision.h @@ -116,6 +116,15 @@ struct CollPartUpdater { // TODO: members }; +/** + * @brief TODO + */ +struct CollEvent { + u32 _00; // _00, unknown + u32 _04; // _04, unknown + u32 _08; // _08, unknown +}; + /** * @brief TODO */ diff --git a/include/Creature.h b/include/Creature.h index 6a993057..4f6afacf 100644 --- a/include/Creature.h +++ b/include/Creature.h @@ -45,7 +45,7 @@ enum CreatureFlags { CF_Unk10 = 1 << 9, // 0x200 CF_Unk11 = 1 << 10, // 0x400 CF_Unk12 = 1 << 11, // 0x800 - CF_Unk13 = 1 << 12, // 0x1000 + CF_Free = 1 << 12, // 0x1000 CF_Unk14 = 1 << 13, // 0x2000 CF_StuckToObject = 1 << 14, // 0x4000, stuck to an object CF_StuckToMouth = 1 << 15, // 0x8000, stuck to mouth of some enemy diff --git a/include/FlowController.h b/include/FlowController.h index b8b80dad..afdf6558 100644 --- a/include/FlowController.h +++ b/include/FlowController.h @@ -3,6 +3,8 @@ #include "types.h" +struct StageInfo; + /** * @brief TODO * @@ -15,7 +17,9 @@ struct FlowController { void setStage(char*); // TODO: members - u8 _00[0xB0]; // _00, unknown + u8 _00[0xA8]; // _00, unknown + StageInfo* _A8; // _A8 + u8 _AC[0x4]; // _AC, unknown char _B0[0x10]; // _B0, i have no idea how big this array is, this is a guess for now u8 _C0[0x244 - 0xC0]; // _B4, unknown int _244; // _244 diff --git a/include/ItemMgr.h b/include/ItemMgr.h index aee67d80..2f75af3c 100644 --- a/include/ItemMgr.h +++ b/include/ItemMgr.h @@ -23,24 +23,24 @@ struct ItemShapeObject { struct ItemCreature : public AICreature { ItemCreature(int objType, CreatureProp*, Shape*); - virtual void init(Vector3f&); // _28 - virtual f32 getHeight(); // _40 - virtual bool stimulate(Interaction&); // _A0 - virtual void update(); // _E0 - virtual void refresh(Graphics&); // _EC - virtual void doAI(); // _104 - virtual void doAnimation(); // _108 - virtual void doKill(); // _10C - virtual void startMotion(int); // _130 - virtual void finishMotion(); // _134 - virtual void finishMotion(f32); // _138 - virtual void startMotion(int, f32); // _13C - virtual void getCurrentMotionName(); // _140 - virtual void getCurrentMotionCounter(); // _144 - virtual void getMotionSpeed(); // _148 - virtual void setMotionSpeed(f32); // _14C - virtual void stopMotion(); // _150 - virtual void finalSetup(); // _158 (weak) + virtual void init(Vector3f&); // _28 + virtual f32 getHeight(); // _40 + virtual bool stimulate(Interaction&); // _A0 + virtual void update(); // _E0 + virtual void refresh(Graphics&); // _EC + virtual void doAI(); // _104 + virtual void doAnimation(); // _108 + virtual void doKill(); // _10C + virtual void startMotion(int); // _130 + virtual void finishMotion(); // _134 + virtual void finishMotion(f32); // _138 + virtual void startMotion(int, f32); // _13C + virtual char* getCurrentMotionName(); // _140 + virtual f32 getCurrentMotionCounter(); // _144 + virtual f32 getMotionSpeed(); // _148 + virtual void setMotionSpeed(f32); // _14C + virtual void stopMotion(); // _150 + virtual void finalSetup(); // _158 (weak) // _00 = VTBL // _00-_304 = AICreature? diff --git a/include/Msg.h b/include/Msg.h index 849a14ee..6d3dfb34 100644 --- a/include/Msg.h +++ b/include/Msg.h @@ -2,6 +2,11 @@ #define _MSG_H #include "types.h" +#include "Collision.h" +#include "Vector.h" + +struct Creature; +struct PaniAnimKeyEvent; /** * @brief TODO @@ -24,7 +29,12 @@ enum MsgType { * @brief TODO */ struct Msg { - u32 _00; // _00, maybe msg type? + inline Msg(int type) + : mMsgType(type) + { + } + + int mMsgType; // _00 }; /** @@ -33,62 +43,133 @@ struct Msg { * @note will need to fix saiEvents.cpp when this gets worked out */ struct MsgAnim : public Msg { + inline MsgAnim(PaniAnimKeyEvent* event) // adjust when type of _04 is known + : Msg(MSG_Anim) + , mKeyEvent(event) + { + } + // _00-_04 = Msg - u32* _04; // _04, probably a pointer to a struct with a u32 or int at _00 + PaniAnimKeyEvent* mKeyEvent; // _04, probably a pointer to a struct with a u32 or int at _00 }; /** * @brief TODO */ struct MsgBounce : public Msg { + inline MsgBounce(Vector3f& normal) + : Msg(MSG_Bounce) + , mNormal(normal) + { + } + + // _00-_04 = Msg + Vector3f mNormal; // _04 }; /** * @brief TODO */ struct MsgCollide : public Msg { + inline MsgCollide(CollEvent& event) + : Msg(MSG_Collide) + , mEvent(event) + { + } + + // _00-_04 = Msg + CollEvent mEvent; // _04 }; /** * @brief TODO */ struct MsgDamage : public Msg { + inline MsgDamage() + : Msg(MSG_Damage) + { + } + + // _00-_04 = Msg + // TODO: members }; /** * @brief TODO */ struct MsgGround : public Msg { + inline MsgGround() + : Msg(MSG_Ground) + { + } + + // _00-_04 = Msg + // TODO: members }; /** * @brief TODO */ struct MsgHang : public Msg { + inline MsgHang() + : Msg(MSG_Hang) + { + } + + // _00-_04 = Msg + // TODO: members }; /** * @brief TODO */ struct MsgOffWall : public Msg { + inline MsgOffWall() + : Msg(MSG_OffWall) + { + } + + // _00-_04 = Msg + // TODO: members }; /** * @brief TODO */ struct MsgStick : public Msg { + inline MsgStick() + : Msg(MSG_Stick) + { + } + + // _00-_04 = Msg + // TODO: members }; /** * @brief TODO */ struct MsgTarget : public Msg { + MsgTarget(Creature* target) + : Msg(MSG_Target) + { + mTarget = target; + } + + // _00-_04 = Msg + Creature* mTarget; // _04 }; /** * @brief TODO */ struct MsgUser : public Msg { + inline MsgUser(u32 val) + : Msg(MSG_User) + { + _04 = val; + } + // _00-_04 = Msg u32 _04; // _04, could be int }; @@ -97,6 +178,13 @@ struct MsgUser : public Msg { * @brief TODO */ struct MsgWall : public Msg { + inline MsgWall() + : Msg(MSG_Wall) + { + } + + // _00-_04 = Msg + // TODO: members }; #endif diff --git a/include/Navi.h b/include/Navi.h index aedc6ecb..50406981 100644 --- a/include/Navi.h +++ b/include/Navi.h @@ -102,7 +102,10 @@ struct Navi : public Creature, public PaniAnimKeyListener, public PelletView { // _000-_2B8 = Creature // _2B8-_2BC = PaniAnimKeyListener // _2BC-_2C4 = PelletView - u8 _2C4[0xADC - 0x2C4]; // _2C4, TODO: work out members + u8 _2C4[0x7E4 - 0x2C4]; // _2C4, TODO: work out members + u8 _7E4; // _7E4 + u8 _7E5; // _7E5 + u8 _7E6[0xADC - 0x7E6]; // _7E6, TODO: work out members NaviState* mCurrState; // _ADC }; diff --git a/include/PaniAnimator.h b/include/PaniAnimator.h index 285fe6ec..d8d35d67 100644 --- a/include/PaniAnimator.h +++ b/include/PaniAnimator.h @@ -52,6 +52,8 @@ struct PaniAnimator : public Animator { // unused/inlined: void checkCounter_4DEBUG(); + inline bool isFinished() const { return mIsFinished; } + inline int getInfoKeyValue(int idx) { return mAnimInfo->getInfoKey(idx)->_00; } inline int getEventKeyValue(int idx) { return mAnimInfo->getEventKey(idx)->_00; } inline f32 getKeyValue(int idx) { return mAnimInfo->getKeyValue(idx); } @@ -64,7 +66,7 @@ struct PaniAnimator : public Animator { int _38; // _38 u8 _3C[0x4]; // _3C, unknown u32 _40; // _40, unknown - int _44; // _44 + int mMotionIdx; // _44 bool mIsFinished; // _48 u32 _4C; // _4C, unknown PaniMotionTable* mMotionTable; // _50 @@ -79,7 +81,7 @@ struct PaniItemAnimator : public PaniAnimator { PaniMotionTable* createMotionTable(); // _30 = VTBL - // _00-_34 = PaniAnimator + // _00-_54 = PaniAnimator // TODO: members }; @@ -89,25 +91,10 @@ struct PaniItemAnimator : public PaniAnimator { struct PaniPelletAnimator : public PaniAnimator { PaniPelletAnimator(); - PaniMotionTable* createMotionTable(); - - // _30 = VTBL - // _00-_34 = PaniAnimator - u8 _34[0x54 - 0x34]; // _34, unknown - // TODO: members -}; - -/** - * @brief TODO - */ -struct PaniPikiAnimator : public PaniAnimator { - PaniPikiAnimator(); - - PaniMotionTable* createMotionTable(); + static PaniMotionTable* createMotionTable(); // _30 = VTBL - // _00-_34 = PaniAnimator - // TODO: members + // _00-_54 = PaniAnimator }; /** @@ -116,10 +103,10 @@ struct PaniPikiAnimator : public PaniAnimator { struct PaniPlantAnimator : public PaniAnimator { PaniPlantAnimator(); - PaniMotionTable* createMotionTable(); + static PaniMotionTable* createMotionTable(); // _30 = VTBL - // _00-_34 = PaniAnimator + // _00-_54 = PaniAnimator // TODO: members }; @@ -132,7 +119,7 @@ struct PaniTekiAnimator : public PaniAnimator { static PaniMotionTable* createMotionTable(); // _30 = VTBL - // _00-_34 = PaniAnimator + // _00-_54 = PaniAnimator // TODO: members }; @@ -142,33 +129,10 @@ struct PaniTekiAnimator : public PaniAnimator { struct PaniUfoAnimator : public PaniAnimator { PaniUfoAnimator(); - PaniMotionTable* createMotionTable(); + static PaniMotionTable* createMotionTable(); // _30 = VTBL - // _00-_34 = PaniAnimator - // TODO: members -}; - -/** - * @brief TODO - */ -struct PaniPikiAnimMgr { - PaniPikiAnimMgr(); - - void init(AnimMgr*, AnimContext*, AnimContext*, PaniMotionTable*); - void changeContext(AnimContext*, AnimContext*); - void startMotion(PaniMotionInfo*, PaniMotionInfo*); - void finishMotion(PaniMotionInfo*, PaniMotionInfo*); - void startMotion(PaniMotionInfo&, PaniMotionInfo&); - void finishMotion(PaniAnimKeyListener*); - void updateAnimation(f32); - void updateContext(); - - // unused/inlined: - PaniMotionTable* getMotionTable(); - - static PaniMotionTable* motionTable; - + // _00-_54 = PaniAnimator // TODO: members }; @@ -181,7 +145,7 @@ struct PaniMotionInfo { void init(int, PaniAnimKeyListener*); - int _00; // _00 + int mMotionIdx; // _00 PaniAnimKeyListener* mListener; // _04 }; @@ -208,8 +172,8 @@ struct PaniMotion { struct PaniMotionTable { PaniMotionTable(int); - int mMotionCount; // _00 - PaniMotion** _04; // _04 + int mMotionCount; // _00 + PaniMotion** mMotions; // _04 }; /** @@ -219,7 +183,7 @@ struct PaniSoundTable { PaniSoundTable(int); int mSoundCount; // _00 - u32** _04; // _04, array of some type of pointer + u32** mSounds; // _04, array of some type of pointer }; #endif diff --git a/include/PaniPikiAnimator.h b/include/PaniPikiAnimator.h new file mode 100644 index 00000000..f1a2a27a --- /dev/null +++ b/include/PaniPikiAnimator.h @@ -0,0 +1,150 @@ +#ifndef _PANIPIKIANIMATOR_H +#define _PANIPIKIANIMATOR_H + +#include "types.h" +#include "PaniAnimator.h" + +/** + * @brief Animation indices for Piki and Navi + */ +enum PikiNaviAnim { + PIKIANIM_Run = 0, // Run + PIKIANIM_Nigeru = 1, // 'Run away' + PIKIANIM_Walk = 2, // Walk + PIKIANIM_Wait = 3, // Wait + PIKIANIM_Pick = 4, // Pick (up) + PIKIANIM_Nuku = 5, // 'Pluck' + PIKIANIM_Nukareru = 6, // 'Be plucked' + PIKIANIM_Dead = 7, // Dead + PIKIANIM_Dead2 = 8, // Dead (2) + PIKIANIM_Dead3 = 9, // Dead (3) + PIKIANIM_Damage = 10, // Damage + PIKIANIM_Asibumi = 11, // 'Step' + PIKIANIM_OCarry = 12, // 'O(limar) carry' + PIKIANIM_LSuberu = 13, // 'L slip' + PIKIANIM_RSuberu = 14, // 'R slip' + PIKIANIM_Tanemaki = 15, // 'seed sowing' + PIKIANIM_Job1 = 16, // Job (1) + PIKIANIM_GrowUp1 = 17, // Grow up (1) + PIKIANIM_GrowUp2 = 18, // Grow up (2) + PIKIANIM_Job2 = 19, // Job (2) + PIKIANIM_Korobu = 20, // 'Fall' + PIKIANIM_Jump = 21, // Jump + PIKIANIM_StillJump = 22, // Still jump + PIKIANIM_Attack = 23, // Attack + PIKIANIM_Butukaru = 24, // 'Collide' + PIKIANIM_Punch = 25, // Punch + PIKIANIM_Kenka = 26, // 'Fight' + PIKIANIM_Throw = 27, // Throw + PIKIANIM_Hang = 28, // Hang + PIKIANIM_Fall = 29, // Fall + PIKIANIM_JKoke = 30, // 'J Moss(?)' + PIKIANIM_JHit = 31, // J Hit + PIKIANIM_GetUp = 32, // Get up + PIKIANIM_NewJmp = 33, // New jump + PIKIANIM_RollJmp = 34, // Roll jump + PIKIANIM_WaveJmp = 35, // Wave jump + PIKIANIM_ThrowWait = 36, // Throw wait + PIKIANIM_Push = 37, // Push + PIKIANIM_Umaru = 38, // 'Bury' + PIKIANIM_Akubi = 39, // 'Yawn' + PIKIANIM_Rinbow = 40, // 'Rainbow' + PIKIANIM_Iraira = 41, // 'Annoyed' + PIKIANIM_Furimuku = 42, // 'Turn around' + PIKIANIM_JumpKick = 43, // Jump Kick + PIKIANIM_Kaifuku = 44, // 'Recovery' + PIKIANIM_Kizuku = 45, // 'Scratches' + PIKIANIM_PickLoop = 46, // Pick (up) loop + PIKIANIM_Mizunomi = 47, // 'Water only' + PIKIANIM_Kuttuku = 48, // 'Stick' + PIKIANIM_Fue = 49, // 'Flute (whistle)' + PIKIANIM_Suwaru = 50, // 'Sit' + PIKIANIM_Aogu = 51, // 'Fan' + PIKIANIM_Neru = 52, // 'Sleep' + PIKIANIM_Press1 = 53, // Press (1) + PIKIANIM_Press2 = 54, // Press (2) + PIKIANIM_SPress = 55, // S Press + PIKIANIM_TYakusui = 56, // 'T Easy(?)' + PIKIANIM_Oboreru = 57, // 'Drowning' + PIKIANIM_Sizumu = 58, // 'Sink' or 'Trembling'? + PIKIANIM_Hikakaru = 59, // 'Get hit' + PIKIANIM_Otikake = 60, // 'Fall' + PIKIANIM_Otiru = 61, // 'Fall' + PIKIANIM_HNoboru = 62, // 'H Climb' (horizontal?) + PIKIANIM_Noboru = 63, // 'Climb' + PIKIANIM_Chatting = 64, // Chatting + PIKIANIM_Sagasu2 = 65, // 'Search (2)' + PIKIANIM_Otikake2 = 66, // 'Fall (2)' + PIKIANIM_Kaifuku3 = 67, // 'Recovery (2)' + PIKIANIM_Punch2 = 68, // 'Punch!' + PIKIANIM_Moeru = 69, // 'Burn' + PIKIANIM_Esa = 70, // 'Food' + PIKIANIM_GameOver = 71, // Game over + PIKIANIM_Gattu = 72, // 'Gluttony' + PIKIANIM_Gakkari = 73, // 'Disappointed' + PIKIANIM_Okoru = 74, // 'Occur'? + PIKIANIM_RotJump = 75, // Rotate jump + PIKIANIM_GWait1 = 76, // G wait (1) + PIKIANIM_GWait2 = 77, // G wait (2) + PIKIANIM_GFuri1 = 78, // 'G pretend (1)' + PIKIANIM_GFuri2 = 79, // 'G pretend (2)' + PIKIANIM_GNuke = 80, // 'G escape' + PIKIANIM_Jump_B1 = 81, // Jump B(1) + PIKIANIM_Nuku_Fast = 82, // 'Pluck' fast + PIKIANIM_Nukare_Fast = 83, // 'Be plucked' fast + PIKIANIM_Mizuage = 84, // 'Water' something + PIKIANIM_Sagasu = 85, // 'Search' + PIKIANIM_Osu = 86, // 'Push' + PIKIANIM_Osu_Walk = 87, // 'Push walk' + PIKIANIM_Noru = 88, // 'Ride' + PIKIANIM_ODead = 89, // O(limar) dead + PIKIANIM_COUNT, // 90 +}; + +/** + * @brief TODO + */ +struct PaniPikiAnimator : public PaniAnimator { + PaniPikiAnimator(); + + static PaniMotionTable* createMotionTable(); + static char* motionLabels[90]; + + // _30 = VTBL + // _00-_54 = PaniAnimator + // TODO: members +}; + +/** + * @brief TODO + * + * @note Size: 0xAC. + */ +struct PaniPikiAnimMgr { + PaniPikiAnimMgr(); + + void init(AnimMgr*, AnimContext*, AnimContext*, PaniMotionTable*); + void changeContext(AnimContext*, AnimContext*); + void startMotion(PaniMotionInfo*, PaniMotionInfo*); + void finishMotion(PaniMotionInfo*, PaniMotionInfo*); + void startMotion(PaniMotionInfo&, PaniMotionInfo&); + void finishMotion(PaniAnimKeyListener*); + void updateAnimation(f32); + void updateContext(); + + // unused/inlined: + static PaniMotionTable* getMotionTable(); + + inline bool isFinished() const { return _04.isFinished(); } + + inline f32 getAnimSpeed() { return mAnimSpeed; } + inline void setAnimSpeed(f32 speed) { mAnimSpeed = speed; } + + static PaniMotionTable* motionTable; + + f32 mAnimSpeed; // _00 + PaniPikiAnimator _04; // _04 + PaniPikiAnimator _58; // _58 +}; + +#endif diff --git a/include/Pellet.h b/include/Pellet.h index c0723107..972945e8 100644 --- a/include/Pellet.h +++ b/include/Pellet.h @@ -5,8 +5,10 @@ #include "DualCreature.h" #include "CreatureProp.h" #include "ObjectMgr.h" +#include "Animator.h" struct PaniAnimKeyEvent; +struct PaniMotionTable; struct PelletShapeObject; struct PelletView; struct Shape; @@ -133,7 +135,7 @@ struct PelletMgr : public MonoObjectMgr { void registerUfoParts(); void newNumberPellet(int, int); void newPellet(u32, PelletView*); - void getShapeObject(u32); + PelletShapeObject* getShapeObject(u32); void addUseList(u32); void initShapeInfos(); void getConfigIndex(u32); @@ -153,7 +155,9 @@ struct PelletMgr : public MonoObjectMgr { // _08 = VTBL 2 // _00-_3C = MonoObjectMgr // TODO: members - u8 _3C[0x204 - 0x3C]; // _3C, unknown + u8 _3C[0x1F8 - 0x3C]; // _3C, unknown + PaniMotionTable* _1F8; // _1F8 + u8 _1FC[0x204 - 0x1FC]; // _1FC, unknown }; /** @@ -161,6 +165,12 @@ struct PelletMgr : public MonoObjectMgr { */ struct PelletShapeObject { PelletShapeObject(char*, Shape*, char*, char*, int); + + Shape* mShape; // _00 + AnimMgr* mAnimMgr; // _04 + AnimContext _08; // _08 + AnimContext _18; // _18 + // TODO: members }; extern PelletMgr* pelletMgr; diff --git a/include/Piki.h b/include/Piki.h index f86b81dc..061607b7 100644 --- a/include/Piki.h +++ b/include/Piki.h @@ -3,7 +3,7 @@ #include "types.h" #include "Creature.h" -#include "PaniAnimator.h" +#include "PaniPikiAnimator.h" struct TopAction; struct Navi; @@ -152,33 +152,35 @@ struct Piki : public Creature, public PaniAnimKeyListener { // _00 = VTBL // _00-_2B8 = Creature // _2B8 = PaniAnimKeyListener - u8 _2BC[0x3CC - 0x2BC]; // _2BC, TODO: work out members - int _3CC; // _3CC, piki color? - int _3D0; // _3D0, piki happa? - u8 _3D4[0x424 - 0x3D4]; // _3D4, unknown - u8 _424; // _424 - u16 _426; // _426 - u8 _428[0x8]; // _428, unknown - u32 _430; // _430, unknown - u8 _434[0x48C - 0x434]; // _434, unknown - f32 _48C; // _48C - PikiStateMachine* mFSM; // _490 - u8 _494[0x4]; // _494, unknown - f32 _498; // _498 - f32 _49C; // _49C, some form of angle? - u8 _4A0[4]; // _4A0, unknown - CollPart* mSwallowMouthPart; // _4A4 - Creature* _4A8; // _4A8, maybe puffstool/kinoko leader? - u8 _4AC[0x4F8 - 0x4AC]; // _4AC, unknown - TopAction* _4F8; // _4F8, may be just Action* - u16 _4FC; // _4FC - u32 _500; // _500, unknown - Navi* mNavi; // _504 - u8 _508[0x8]; // _508, unknown - u16 mColor; // _510, red/yellow/blue - u8 _512[0x520 - 0x512]; // _4FC, TODO: work out members - int mHappa; // _520, leaf/bud/flower - u8 _524[0x585 - 0x524]; // _4FC, TODO: work out members + u8 _2BC[0x354 - 0x2BC]; // _2BC, TODO: work out members + PaniPikiAnimMgr mPikiAnimMgr; // _354 + u8 _400[0x408 - 0x400]; // _400, unknown + u8 _408; // _408 + u8 _409; // _409 + u8 _40A[0x424 - 0x40A]; // _40A, unknown + u8 _424; // _424 + u16 _426; // _426 + u8 _428[0x8]; // _428, unknown + u32 _430; // _430, unknown + u8 _434[0x48C - 0x434]; // _434, unknown + f32 _48C; // _48C + PikiStateMachine* mFSM; // _490 + u8 _494[0x4]; // _494, unknown + f32 _498; // _498 + f32 _49C; // _49C, some form of angle? + u8 _4A0; // _4A0 + CollPart* mSwallowMouthPart; // _4A4 + Creature* _4A8; // _4A8, maybe puffstool/kinoko leader? + u8 _4AC[0x4F8 - 0x4AC]; // _4AC, unknown + TopAction* _4F8; // _4F8, may be just Action* + u16 _4FC; // _4FC + u32 _500; // _500, unknown + Navi* mNavi; // _504 + u8 _508[0x8]; // _508, unknown + u16 mColor; // _510, red/yellow/blue + u8 _512[0x520 - 0x512]; // _4FC, TODO: work out members + int mHappa; // _520, leaf/bud/flower + u8 _524[0x585 - 0x524]; // _4FC, TODO: work out members }; /** diff --git a/include/PlayerState.h b/include/PlayerState.h index c7a1b33a..3400d409 100644 --- a/include/PlayerState.h +++ b/include/PlayerState.h @@ -4,10 +4,13 @@ #include "types.h" #include "Demo.h" #include "ResultFlags.h" -#include "PaniAnimator.h" +#include "PaniPikiAnimator.h" +#include "PelletAnimator.h" +#include "Shape.h" struct Graphics; struct PelletShapeObject; +struct PermanentEffect; struct Shape; /** @@ -22,7 +25,7 @@ struct TimeGraph { void set(int, int); - // TODO: members + int mNum[3]; // _00 }; TimeGraph(); // unused/inlined @@ -58,8 +61,16 @@ struct PlayerState { void startMotion(int, int); void stopMotion(); - // _00 = VTBL? - u8 _04[0xE0 - 0x4]; // _04, unknown + // _00 = VTBL + int _04; // _04 + u32 _08; // _08 + u32 _0C; // _0C + PelletAnimator mAnimator; // _10 + Vector3f _B8; // _B8 + ShapeDynMaterials _C4; // _C4 + PelletShapeObject* mPelletShape; // _D4 + f32 _D8; // _D8 + u8 _DC; // _DC }; PlayerState(); @@ -67,11 +78,11 @@ struct PlayerState { bool isEnding(); bool existUfoParts(u32); void initGame(); - void courseOpen(int); - void happyEndable(); + bool courseOpen(int); + bool happyEndable(); void setChallengeMode(); void getPartsGetCount(int); - void getCardUfoPartsCount(); + int getCardUfoPartsCount(); void getTotalPikiCount(int); void saveCard(RandomAccessStream&); void loadCard(RandomAccessStream&); @@ -86,7 +97,7 @@ struct PlayerState { void initCourse(); void exitCourse(); void setNavi(bool); - void getFinalDeadPikis(); + int getFinalDeadPikis(); void updateFinalResult(); int getCurrDay(); int getTotalDays(); @@ -119,25 +130,36 @@ struct PlayerState { static int totalUfoParts; // TODO: members - u8 _00[0x54]; // _00, unknown + u8 _00[0x11]; // _00, unknown + u8 _11; // _11 + u8 _12[0x54 - 0x12]; // _12, unknown DemoFlags mDemoFlags; // _54 ResultFlags mResultFlags; // _70 u8 _BC[0xC4 - 0xBC]; // _BC, unknown PaniPikiAnimMgr mPikiAnimMgr; // _C4 - u8 _C8[0x174 - 0xC8]; // _C8, adjust when size of PaniPikiAnimMgr is known + int _170; // _170 int mTotalParts; // _174 UfoParts* mUfoParts; // _178 int mCurrParts; // _17C - u32 _180; // _180, unknown + int _180; // _180 u8 _184; // _184 - u8 _185; // _185 + bool _185; // _185 u8 _186; // _186 u8 _187; // _187 u8 _188; // _188 u8 _189; // _189 u8 _18A; // _18A u8 _18B; // _18B - u8 _18C[0x1C0 - 0x18C]; // _18C, unknown + u8 _18C[0x1A0 - 0x18C]; // _18C, unknown + int _1A0; // _1A0, final dead pikis count? + u8 _1A4[0x1AC - 0x1A4]; // _1A4, unknown + u8 _1AC; // _1AC + u8 _1AD[0x1B4 - 0x1AD]; // _1AD, unknown + u8 _1B4; // _1B4 + u8 _1B5; // _1B5 + u8 _1B6; // _1B6 + PermanentEffect* _1B8; // _1B8 + PermanentEffect* _1BC; // _1BC Vector3f _1C0; // _1C0 }; diff --git a/include/Receiver.h b/include/Receiver.h index f4156382..5fec9a70 100644 --- a/include/Receiver.h +++ b/include/Receiver.h @@ -12,38 +12,38 @@ struct Receiver { virtual void procMsg(T* target, Msg* msg) // _08 (weak) { - switch (msg->_00) { - case 0: + switch (msg->mMsgType) { + case MSG_Bounce: procBounceMsg(target, static_cast(msg)); break; - case 8: + case MSG_Stick: procStickMsg(target, static_cast(msg)); break; - case 1: + case MSG_Hang: procHangMsg(target, static_cast(msg)); break; - case 2: + case MSG_Target: procTargetMsg(target, static_cast(msg)); break; - case 3: + case MSG_Collide: procCollideMsg(target, static_cast(msg)); break; - case 4: + case MSG_Anim: procAnimMsg(target, static_cast(msg)); break; - case 5: + case MSG_Damage: procDamageMsg(target, static_cast(msg)); break; - case 6: + case MSG_Wall: procWallMsg(target, static_cast(msg)); break; - case 7: + case MSG_OffWall: procOffWallMsg(target, static_cast(msg)); break; - case 10: + case MSG_User: procUserMsg(target, static_cast(msg)); break; - case 9: + case MSG_Ground: procGroundMsg(target, static_cast(msg)); break; } diff --git a/include/Shape.h b/include/Shape.h index 6cea968f..98c1a19b 100644 --- a/include/Shape.h +++ b/include/Shape.h @@ -61,8 +61,21 @@ struct MtxGroup { * @brief TODO */ struct ShapeDynMaterials { + ShapeDynMaterials() + : _00(0) + , _04(0) + , _08(0) + , _0C(0) + { + } + void animate(f32*); void updateContext(); + + u32 _00; // _00, unknown + u32 _04; // _04, unknown + u32 _08; // _08, unknown + u32 _0C; // _0C, unknown }; /** diff --git a/include/SimpleAI.h b/include/SimpleAI.h index f5f41d95..1d0f77ef 100644 --- a/include/SimpleAI.h +++ b/include/SimpleAI.h @@ -5,6 +5,8 @@ #include "AICreature.h" #include "StateMachine.h" +struct SAIEvent; + /** * @brief TODO */ @@ -18,12 +20,14 @@ struct SAIAction { /** * @brief TODO */ -struct SAIArrow : public CoreNode { - inline SAIArrow() - : CoreNode("SAIArrowRoot") +struct SAICondition : public CoreNode { + inline SAICondition() + : CoreNode() { } + virtual bool satisfy(AICreature*); // _10 (weak) + // _00 = VTBL // _00-_14 = CoreNode // TODO: members @@ -32,17 +36,27 @@ struct SAIArrow : public CoreNode { /** * @brief TODO */ -struct SAICondition : public CoreNode { - inline SAICondition() - : CoreNode() +struct SAIArrow : public CoreNode { + inline SAIArrow(char* name, SAIEvent* event, int p3) + : CoreNode(name) { + _18 = event; + _14 = p3; } - virtual bool satisfy(AICreature*); // _10 (weak) + inline SAIArrow(char* name) + : CoreNode(name) + { + _14 = -1; + _18 = nullptr; + } // _00 = VTBL // _00-_14 = CoreNode - // TODO: members + int _14; // _14 + SAIEvent* _18; // _18 + int mArrowIdx; // _1C + SAICondition mCondition; // _20 }; /** @@ -155,6 +169,8 @@ struct SAIUserEvent : public SAIEvent { /** * @brief TODO + * + * @note Size: 0x58. */ struct SAIState : public AState { SAIState(int); @@ -166,12 +182,13 @@ struct SAIState : public AState { // _00 = VTBL // _00-_0C = AState - char* mName; // _0C, probably - SAIArrow mArrow; // _0C - int _24; // _24 - u32 _28; // _28, unknown - u32 _2C; // _2C, unknown - SAICondition mCondition; // _30 + char* mName; // _0C, probably + SAIArrow mRootArrow; // _10 + int mArrowCount; // _44 + int _48; // _48 + SAIAction* _4C; // _4C + SAIAction* _50; // _50 + SAIAction* _54; // _54 }; /** @@ -184,10 +201,12 @@ struct SimpleAI : public StateMachine { virtual void procMsg(AICreature*, Msg*); // _10 void addState(int, int, SAIAction*, SAIAction*, SAIAction*); - void addArrow(int, SAIEvent*, int); + SAIArrow* addArrow(int, SAIEvent*, int); void start(AICreature*, int); void checkEvent(AICreature*); + inline SAIState* getState(int idx) { return static_cast(mStates[idx]); } + // _00 = VTBL // _00-_1C = StateMachine // TODO: members diff --git a/include/StateMachine.h b/include/StateMachine.h index 4fb40938..8b8e06c4 100644 --- a/include/StateMachine.h +++ b/include/StateMachine.h @@ -4,6 +4,9 @@ #include "types.h" #include "Receiver.h" +template +struct StateMachine; + struct Msg; /** @@ -13,7 +16,7 @@ template struct AState : public Receiver { inline AState(int stateID) : mStateID(stateID) - , _08(0) + , mStateMachine(nullptr) { } @@ -27,8 +30,8 @@ struct AState : public Receiver { inline int getStateID() const { return mStateID; } // _00 = VTBL - int mStateID; // _04 - u32 _08; // _08, unknown + int mStateID; // _04 + StateMachine* mStateMachine; // _08 }; /** @@ -46,9 +49,37 @@ struct StateMachine { virtual void procMsg(T*, Msg*); // _10 virtual void transit(T*, int); // _14 + inline bool isValidState(AState* state) + { + if (state->mStateID < 0 || state->mStateID >= mStateLimit) { + return false; + } + + return true; + } + + inline AState* getState(int idx) { return mStates[idx]; } + inline void setState(int idx, AState* state) { mStates[idx] = state; } + + inline void appendState(AState* state) { setState(mStateCount, state); } + + inline void initState(AState* state) + { + state->mStateMachine = this; + mStateIDs[mStateCount] = state->mStateID; + mStateIndexes[state->mStateID] = mStateCount; + mStateCount++; + } + + inline bool isFull() { return mStateCount >= mStateLimit; } + // _00 = VTBL - u8 _04[0x18 - 0x4]; // _04, unknown - int _18; // _18, state ID? + AState** mStates; // _04 + int mStateCount; // _08 + int mStateLimit; // _0C + int* mStateIDs; // _10, indexed by state index (load order) + int* mStateIndexes; // _14, indexed by state IDs + int _18; // _18, state ID? }; #endif diff --git a/include/gameflow.h b/include/gameflow.h index 1d3a2c06..530a3ef7 100644 --- a/include/gameflow.h +++ b/include/gameflow.h @@ -43,7 +43,9 @@ struct GameFlow : public Node { // _00 = VTBL // _00-_20 = Node - u8 _20[0x1F0 - 0x20]; // _20, unknown + u8 _20[0x1C8 - 0x20]; // _20, unknown + u32 _1C8; // _1C8, maybe course open flags? + u8 _1CC[0x1F0 - 0x1CC]; // _1CC, unknown u32 _1F0; // _1F0, could be int int _1F4; // _1F4 u8 _1F8[0x2B0 - 0x1F8]; // _1F8, unknown diff --git a/include/math.h b/include/math.h index a5ff6ee8..312ae26c 100644 --- a/include/math.h +++ b/include/math.h @@ -66,4 +66,24 @@ static inline f32 sqrtf(f32 x) return x; } +#ifdef __cplusplus +// Pikmin-specific global math functions +struct Vector3f; +struct BoundBox; +struct KTri; +struct KRect; +struct KSegment; + +f32 roundAng(f32 angle); +f32 angDist(f32 x, f32 z); +f32 qdist2(f32 x0, f32 z0, f32 x1, f32 z1); +f32 triRectDistance(Vector3f*, Vector3f*, Vector3f*, BoundBox&, bool); +f32 distanceTriRect(KTri&, KRect&, f32*, f32*, f32*, f32*); +f32 sqrDistance(KSegment&, KTri&, f32*, f32*, f32*); +f32 sqrDistance(KSegment&, KSegment&, f32*, f32*); +f32 sqrDistance(KSegment&, KRect&, f32*, f32*, f32*); +f32 sqrDistance(KTri&, KRect&, f32*, f32*, f32*, f32*); +f32 sqrDistance(Vector3f&, KTri&, f32*, f32*); +#endif + #endif // _MATH_H diff --git a/src/plugPikiKando/animPellet.cpp b/src/plugPikiKando/animPellet.cpp index 4a405325..f54cb55f 100644 --- a/src/plugPikiKando/animPellet.cpp +++ b/src/plugPikiKando/animPellet.cpp @@ -454,13 +454,13 @@ void PelletAnimator::updateContext() PaniMotionTable* PaniPelletAnimator::createMotionTable() { PaniMotionTable* table = new PaniMotionTable(7); - table->_04[0] = new PaniMotion(0); - table->_04[1] = new PaniMotion(1); - table->_04[2] = new PaniMotion(2); - table->_04[3] = new PaniMotion(3); - table->_04[4] = new PaniMotion(4); - table->_04[5] = new PaniMotion(5); - table->_04[6] = new PaniMotion(6); + table->mMotions[0] = new PaniMotion(0); + table->mMotions[1] = new PaniMotion(1); + table->mMotions[2] = new PaniMotion(2); + table->mMotions[3] = new PaniMotion(3); + table->mMotions[4] = new PaniMotion(4); + table->mMotions[5] = new PaniMotion(5); + table->mMotions[6] = new PaniMotion(6); return table; } diff --git a/src/plugPikiKando/creature.cpp b/src/plugPikiKando/creature.cpp index 38fd6552..d494fc59 100644 --- a/src/plugPikiKando/creature.cpp +++ b/src/plugPikiKando/creature.cpp @@ -576,7 +576,7 @@ void Creature::init() _1A0 = -1; resetCreatureFlag(CF_Unk19); _21C = 0; - setCreatureFlag(CF_Unk13); + setCreatureFlag(CF_Free); resetCreatureFlag(CF_Unk9 | CF_Unk12 | CF_Unk14 | CF_Unk20); _D0 = 0.0f; _2A8 = nullptr; @@ -673,9 +673,7 @@ void Creature::kill(bool p1) AState* state = static_cast(bomb)->getCurrState(); int currState = state->getStateID(); if (currState != 1) { - MsgUser msg; - msg._00 = MSG_User; - msg._04 = 1; + MsgUser msg(1); static_cast(bomb)->_2D0 = 1; static_cast(bomb)->mStateMachine->procMsg(static_cast(bomb), &msg); } diff --git a/src/plugPikiKando/interactBattle.cpp b/src/plugPikiKando/interactBattle.cpp index 7db7f055..c241d0eb 100644 --- a/src/plugPikiKando/interactBattle.cpp +++ b/src/plugPikiKando/interactBattle.cpp @@ -428,7 +428,7 @@ bool InteractAttack::actPiki(Piki* piki) piki->finishDamage(); piki->mFSM->transit(piki, PIKISTATE_Dying); } else { - piki->startMotion(PaniMotionInfo(10, piki), PaniMotionInfo(10)); + piki->startMotion(PaniMotionInfo(PIKIANIM_Damage, piki), PaniMotionInfo(PIKIANIM_Damage)); } return true; } @@ -463,9 +463,9 @@ bool InteractSwallow::actPiki(Piki* piki) piki->getState(); if (_08 == 0) { - piki->startMotion(PaniMotionInfo(70), PaniMotionInfo(70)); + piki->startMotion(PaniMotionInfo(PIKIANIM_Esa), PaniMotionInfo(PIKIANIM_Esa)); } else { - piki->startMotion(PaniMotionInfo(29), PaniMotionInfo(29)); + piki->startMotion(PaniMotionInfo(PIKIANIM_Fall), PaniMotionInfo(PIKIANIM_Fall)); } piki->mFSM->transit(piki, PIKISTATE_Swallowed); @@ -795,9 +795,7 @@ bool InteractPress::actPiki(Piki* piki) Creature* bomb = piki->_2AC; bomb->resetStateGrabbed(); if (bomb->mObjType == OBJTYPE_Bomb) { - MsgUser msg; - msg._00 = MSG_User; - msg._04 = 1; + MsgUser msg(1); static_cast(bomb)->_2D0 = 0; static_cast(bomb)->mStateMachine->procMsg(static_cast(bomb), &msg); } diff --git a/src/plugPikiKando/interactEtc.cpp b/src/plugPikiKando/interactEtc.cpp index afd82d61..d0252af7 100644 --- a/src/plugPikiKando/interactEtc.cpp +++ b/src/plugPikiKando/interactEtc.cpp @@ -2,6 +2,7 @@ #include "Msg.h" #include "Piki.h" #include "PikiAI.h" +#include "PikiState.h" static char file[] = __FILE__; static char name[] = "interactEtc"; @@ -33,25 +34,9 @@ static void _Print(char*, ...) */ bool InteractTalk::actPiki(Piki* piki) { - - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - li r0, 0x2 - stwu r1, -0x18(r1) - lwz r3, 0x4(r3) - stw r0, 0x10(r1) - stw r3, 0x14(r1) - lwz r3, 0x4F8(r4) - addi r4, r1, 0x10 - bl 0x470C8 - li r3, 0x1 - lwz r0, 0x1C(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + MsgTarget msg(mOwner); + piki->_4F8->procMsg(&msg); + return true; } /* @@ -61,88 +46,25 @@ bool InteractTalk::actPiki(Piki* piki) */ bool InteractWarn::actPiki(Piki* piki) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - stw r30, 0x10(r1) - addi r30, r4, 0 - addi r3, r30, 0 - bl 0x4BB04 - addi r31, r3, 0 - addi r3, r30, 0 - lwz r12, 0x0(r30) - lwz r12, 0x88(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - bne- .loc_0x48 - li r3, 0 - b .loc_0xEC - - .loc_0x48: - mr r3, r30 - lwz r12, 0x0(r30) - lwz r12, 0x120(r12) - mtlr r12 - blrl - rlwinm. r0,r3,0,24,31 - bne- .loc_0x7C - lbz r0, 0x409(r30) - cmplwi r0, 0 - beq- .loc_0x7C - lhz r0, 0x4FC(r30) - cmplwi r0, 0x1 - bne- .loc_0x84 - - .loc_0x7C: - li r3, 0 - b .loc_0xEC - - .loc_0x84: - cmpwi r31, 0x8 - beq- .loc_0xA4 - cmpwi r31, 0x18 - beq- .loc_0xA4 - cmpwi r31, 0x1A - beq- .loc_0xA4 - cmpwi r31, 0x21 - bne- .loc_0xAC + int state = piki->getState(); + if (!piki->isAlive()) { + return false; + } - .loc_0xA4: - li r3, 0 - b .loc_0xEC + if (piki->isKinoko() || !piki->_409 || piki->_4FC == 1) { + return false; + } - .loc_0xAC: - lbz r0, 0x2B4(r30) - cmplwi r0, 0 - bne- .loc_0xE0 - cmpwi r31, 0x16 - beq- .loc_0xE0 - lwz r3, 0x490(r30) - addi r4, r30, 0 - li r5, 0x1A - lwz r12, 0x0(r3) - lwz r12, 0x14(r12) - mtlr r12 - blrl - b .loc_0xE8 + if (state == PIKISTATE_Swallowed || state == PIKISTATE_Drown || state == PIKISTATE_LookAt || state == PIKISTATE_Pressed) { + return false; + } - .loc_0xE0: - li r0, 0x1 - stb r0, 0x4A0(r30) + if (piki->_2B4 == 0 && state != PIKISTATE_Flick) { + piki->mFSM->transit(piki, PIKISTATE_LookAt); - .loc_0xE8: - li r3, 0x1 + } else { + piki->_4A0 = 1; + } - .loc_0xEC: - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + return true; } diff --git a/src/plugPikiKando/interactGrab.cpp b/src/plugPikiKando/interactGrab.cpp index 97e202dd..7c208a9a 100644 --- a/src/plugPikiKando/interactGrab.cpp +++ b/src/plugPikiKando/interactGrab.cpp @@ -45,81 +45,10 @@ bool InteractGrab::actCommon(Creature* creature) * Address: 8007C8D8 * Size: 000120 */ -bool InteractRelease::actCommon(Creature*) +bool InteractRelease::actCommon(Creature* creature) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0xB8(r1) - stfd f31, 0xB0(r1) - stfd f30, 0xA8(r1) - stfd f29, 0xA0(r1) - stw r31, 0x9C(r1) - addi r31, r4, 0 - stw r30, 0x98(r1) - addi r30, r3, 0 - addi r3, r31, 0 - bl 0xE0D0 - lwz r4, 0x4(r30) - mr r5, r31 - lfs f0, -0x6358(r13) - addi r3, r1, 0x60 - lfsu f1, 0x70(r4) - lfs f2, -0x76A8(r2) - fadds f1, f1, f0 - lfs f0, -0x6354(r13) - stfs f1, 0x48(r1) - lfs f1, 0x48(r1) - stfs f1, 0x88(r1) - lfs f1, 0x8(r30) - lfs f3, 0x4(r4) - fmuls f1, f2, f1 - fadds f1, f3, f1 - stfs f1, 0x8C(r1) - lfs f1, 0x8(r4) - fadds f0, f1, f0 - stfs f0, 0x90(r1) - lwz r4, 0x88(r1) - lwz r0, 0x8C(r1) - stw r4, 0x70(r31) - stw r0, 0x74(r31) - lwz r0, 0x90(r1) - stw r0, 0x78(r31) - lwz r4, 0x4(r30) - lfs f31, -0x6350(r13) - lwz r12, 0x0(r4) - lfs f30, -0x634C(r13) - lwz r12, 0x100(r12) - lfs f29, -0x6348(r13) - mtlr r12 - blrl - lfs f0, 0x60(r1) - li r3, 0x1 - lfs f1, 0x64(r1) - fadds f2, f0, f31 - lfs f0, 0x68(r1) - fadds f1, f1, f30 - fadds f0, f0, f29 - stfs f2, 0x3C(r1) - lfs f2, 0x3C(r1) - stfs f2, 0x6C(r1) - stfs f1, 0x70(r1) - stfs f0, 0x74(r1) - lwz r4, 0x6C(r1) - lwz r0, 0x70(r1) - stw r4, 0x94(r31) - stw r0, 0x98(r31) - lwz r0, 0x74(r1) - stw r0, 0x9C(r31) - lwz r0, 0xBC(r1) - lfd f31, 0xB0(r1) - lfd f30, 0xA8(r1) - lfd f29, 0xA0(r1) - lwz r31, 0x9C(r1) - lwz r30, 0x98(r1) - addi r1, r1, 0xB8 - mtlr r0 - blr - */ + creature->resetStateGrabbed(); + creature->_70 = mOwner->_70 + Vector3f(0.0f, 100.0f * _08, 0.0f); + creature->mPosition = mOwner->getCatchPos(creature) + Vector3f(0.0f, 8.0f, 0.0f); + return true; } diff --git a/src/plugPikiKando/interactPullout.cpp b/src/plugPikiKando/interactPullout.cpp index 43d6fd7b..eddb8a8e 100644 --- a/src/plugPikiKando/interactPullout.cpp +++ b/src/plugPikiKando/interactPullout.cpp @@ -1,4 +1,7 @@ #include "Interactions.h" +#include "Piki.h" +#include "Navi.h" +#include "PikiState.h" /* * --INFO-- @@ -32,8 +35,22 @@ bool InteractPullout::actCommon(Creature*) { return true; } * Address: 8007CB40 * Size: 0002BC */ -bool InteractPullout::actPiki(Piki*) +bool InteractPullout::actPiki(Piki* piki) { + if (piki->getState() == PIKISTATE_Nukare) { + return false; + } + + piki->mDirection = roundAng(mOwner->mDirection); + piki->_88.set(0.0f, piki->mDirection, 0.0f); + piki->mFSM->transit(piki, PIKISTATE_Nukare); + + if (piki->mNavi->_7E5) { + piki->mPikiAnimMgr.startMotion(PaniMotionInfo(PIKIANIM_Nukare_Fast, piki), PaniMotionInfo(PIKIANIM_Nukare_Fast)); + } else { + piki->mPikiAnimMgr.startMotion(PaniMotionInfo(PIKIANIM_Nukareru, piki), PaniMotionInfo(PIKIANIM_Nukareru)); + } + /* .loc_0x0: mflr r0 diff --git a/src/plugPikiKando/itemMgr.cpp b/src/plugPikiKando/itemMgr.cpp index 67cf4d47..4ac0cba8 100644 --- a/src/plugPikiKando/itemMgr.cpp +++ b/src/plugPikiKando/itemMgr.cpp @@ -3824,7 +3824,7 @@ void ItemCreature::setMotionSpeed(f32) * Address: 800F59EC * Size: 000008 */ -void ItemCreature::getMotionSpeed() +f32 ItemCreature::getMotionSpeed() { /* .loc_0x0: @@ -3853,7 +3853,7 @@ void ItemCreature::stopMotion() * Address: 800F5A00 * Size: 000008 */ -void ItemCreature::getCurrentMotionCounter() +f32 ItemCreature::getCurrentMotionCounter() { /* .loc_0x0: @@ -3867,7 +3867,7 @@ void ItemCreature::getCurrentMotionCounter() * Address: 800F5A08 * Size: 00002C */ -void ItemCreature::getCurrentMotionName() +char* ItemCreature::getCurrentMotionName() { /* .loc_0x0: diff --git a/src/plugPikiKando/panipikianimator.cpp b/src/plugPikiKando/panipikianimator.cpp index b563ef98..54cb1563 100644 --- a/src/plugPikiKando/panipikianimator.cpp +++ b/src/plugPikiKando/panipikianimator.cpp @@ -1,12 +1,15 @@ -#include "PaniAnimator.h" +#include "PaniPikiAnimator.h" +#include "sysNew.h" +#include "Dolphin/os.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) +static void _Error(char* fmt, ...) { + OSPanic(__FILE__, __LINE__, fmt, "panipikianimator"); // UNUSED FUNCTION } @@ -20,6 +23,27 @@ static void _Print(char*, ...) // UNUSED FUNCTION } +char* PaniPikiAnimator::motionLabels[90] = { + "RUN", "NIGERU", "WALK", "WAIT", "PICK", // 0-4 + "NUKU", "NUKARERU", "DEAD", "DEAD2", "DEAD3", // 5-9 + "DAMAGE", "ASIBUMI", "OCARRY", "LSUBERU", "RSUBERU", // 10-14 + "TANEMAKI", "JOB1", "GROWUP1", "GROWUP2", "JOB2", // 15-19 + "KOROBU", "JUMP", "STILLJUMP", "ATTACK", "BUTUKARU", // 20-24 + "PUNCH", "KENKA", "THROW", "HANG", "FALL", // 25-29 + "JKOKE", "JHIT", "GETUP", "NEWJMP", "ROLLJMP", // 30-34 + "WAVEJMP", "THROWWAIT", "PUSH", "UMARU", "AKUBI", // 35-39 + "RINBOW", "IRAIRA", "FURIMUKU", "JUMPKICK", "KAIFUKU", // 40-44 + "KIZUKU", "PICKLOOP", "MIZUNOMI", "KUTTUKU", "FUE", // 45-49 + "SUWARU", "AOGU", "NERU", "PRESS1", "PRESS2", // 50-54 + "SPRESS", "TYAKUSUI", "OBORERU", "SIZUMU", "HIKAKARU", // 55-59 + "OTIKAKE", "OTIRU", "HNOBORU", "NOBORU", "CHATTING", // 60-64 + "SAGASU2", "OTIKAKE2", "KAIFUKU3", "Punch!", "MOERU", // 65-69 + "ESA", "GAMEOVER", "GATTU", "GAKKARI", "OKORU", // 70-74 + "ROTJUMP", "gwait1", "gwait2", "gfuri1", "gfuri2", // 75-79 + "gnuke", "jump b1", "nuku fast", "nukare fast", "mizuage", // 80-84 + "sagasu", "osu", "osu-walk", "noru", "odead", // 85-89 +}; + /* * --INFO-- * Address: 80118D04 @@ -27,1009 +51,97 @@ static void _Print(char*, ...) */ PaniMotionTable* PaniPikiAnimator::createMotionTable() { - /* - .loc_0x0: - mflr r0 - li r3, 0x8 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - stw r30, 0x10(r1) - bl -0xD1D18 - addi r31, r3, 0 - mr. r3, r31 - beq- .loc_0x30 - li r4, 0x5A - bl 0x62D8 - - .loc_0x30: - li r3, 0x8 - bl -0xD1D34 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x4C - li r4, 0 - bl 0x627C - - .loc_0x4C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x0(r4) - bl -0xD1D58 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x70 - li r4, 0x4 - bl 0x6258 - - .loc_0x70: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x4(r4) - bl -0xD1D7C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x94 - li r4, 0x19 - bl 0x6234 - - .loc_0x94: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x8(r4) - bl -0xD1DA0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xB8 - li r4, 0xC - bl 0x6210 - - .loc_0xB8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xC(r4) - bl -0xD1DC4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xDC - li r4, 0x1 - bl 0x61EC - - .loc_0xDC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x10(r4) - bl -0xD1DE8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x100 - li r4, 0x1C - bl 0x61C8 - - .loc_0x100: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x14(r4) - bl -0xD1E0C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x124 - li r4, 0x1D - bl 0x61A4 - - .loc_0x124: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x18(r4) - bl -0xD1E30 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x148 - li r4, 0x14 - bl 0x6180 - - .loc_0x148: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x1C(r4) - bl -0xD1E54 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x16C - li r4, 0x2A - bl 0x615C - - .loc_0x16C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x20(r4) - bl -0xD1E78 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x190 - li r4, 0x30 - bl 0x6138 - - .loc_0x190: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x24(r4) - bl -0xD1E9C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x1B4 - li r4, 0x15 - bl 0x6114 - - .loc_0x1B4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x28(r4) - bl -0xD1EC0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x1D8 - li r4, 0x2C - bl 0x60F0 - - .loc_0x1D8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x2C(r4) - bl -0xD1EE4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x1FC - li r4, 0x2D - bl 0x60CC - - .loc_0x1FC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x30(r4) - bl -0xD1F08 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x220 - li r4, 0x34 - bl 0x60A8 - - .loc_0x220: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x34(r4) - bl -0xD1F2C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x244 - li r4, 0x35 - bl 0x6084 - - .loc_0x244: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x38(r4) - bl -0xD1F50 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x268 - li r4, 0x22 - bl 0x6060 - - .loc_0x268: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x3C(r4) - bl -0xD1F74 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x28C - li r4, 0x27 - bl 0x603C - - .loc_0x28C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x44(r4) - bl -0xD1F98 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x2B0 - li r4, 0x28 - bl 0x6018 - - .loc_0x2B0: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x48(r4) - bl -0xD1FBC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x2D4 - li r4, 0x29 - bl 0x5FF4 - - .loc_0x2D4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x4C(r4) - bl -0xD1FE0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x2F8 - li r4, 0x18 - bl 0x5FD0 - - .loc_0x2F8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x50(r4) - bl -0xD2004 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x31C - li r4, 0x9 - bl 0x5FAC - - .loc_0x31C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x54(r4) - bl -0xD2028 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x340 - li r4, 0xD - bl 0x5F88 - - .loc_0x340: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x58(r4) - bl -0xD204C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x364 - li r4, 0x12 - bl 0x5F64 - - .loc_0x364: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x5C(r4) - bl -0xD2070 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x388 - li r4, 0x21 - bl 0x5F40 - - .loc_0x388: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x60(r4) - bl -0xD2094 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x3AC - li r4, 0x5E - bl 0x5F1C - - .loc_0x3AC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x64(r4) - bl -0xD20B8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x3D0 - li r4, 0x24 - bl 0x5EF8 - - .loc_0x3D0: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x68(r4) - bl -0xD20DC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x3F4 - li r4, 0x36 - bl 0x5ED4 - - .loc_0x3F4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x6C(r4) - bl -0xD2100 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x418 - li r4, 0x37 - bl 0x5EB0 - - .loc_0x418: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x70(r4) - bl -0xD2124 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x43C - li r4, 0x38 - bl 0x5E8C - - .loc_0x43C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x74(r4) - bl -0xD2148 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x460 - li r4, 0x39 - bl 0x5E68 - - .loc_0x460: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x78(r4) - bl -0xD216C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x484 - li r4, 0x3A - bl 0x5E44 - - .loc_0x484: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x7C(r4) - bl -0xD2190 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x4A8 - li r4, 0x3B - bl 0x5E20 - - .loc_0x4A8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x80(r4) - bl -0xD21B4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x4CC - li r4, 0x3C - bl 0x5DFC - - .loc_0x4CC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x84(r4) - bl -0xD21D8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x4F0 - li r4, 0x3D - bl 0x5DD8 - - .loc_0x4F0: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x88(r4) - bl -0xD21FC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x514 - li r4, 0x3E - bl 0x5DB4 - - .loc_0x514: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x8C(r4) - bl -0xD2220 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x538 - li r4, 0x3F - bl 0x5D90 - - .loc_0x538: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x90(r4) - bl -0xD2244 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x55C - li r4, 0x40 - bl 0x5D6C - - .loc_0x55C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x94(r4) - bl -0xD2268 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x580 - li r4, 0x1F - bl 0x5D48 - - .loc_0x580: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x98(r4) - bl -0xD228C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x5A4 - li r4, 0xA - bl 0x5D24 - - .loc_0x5A4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x9C(r4) - bl -0xD22B0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x5C8 - li r4, 0x10 - bl 0x5D00 - - .loc_0x5C8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xA0(r4) - bl -0xD22D4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x5EC - li r4, 0x3 - bl 0x5CDC - - .loc_0x5EC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xA4(r4) - bl -0xD22F8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x610 - li r4, 0x26 - bl 0x5CB8 - - .loc_0x610: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xA8(r4) - bl -0xD231C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x634 - li r4, 0x2F - bl 0x5C94 - - .loc_0x634: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xAC(r4) - bl -0xD2340 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x658 - li r4, 0x20 - bl 0x5C70 - - .loc_0x658: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xB0(r4) - bl -0xD2364 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x67C - li r4, 0x42 - bl 0x5C4C - - .loc_0x67C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xB4(r4) - bl -0xD2388 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x6A0 - li r4, 0x44 - bl 0x5C28 - - .loc_0x6A0: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xB8(r4) - bl -0xD23AC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x6C4 - li r4, 0x43 - bl 0x5C04 - - .loc_0x6C4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xBC(r4) - bl -0xD23D0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x6E8 - li r4, 0x47 - bl 0x5BE0 - - .loc_0x6E8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xC0(r4) - bl -0xD23F4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x70C - li r4, 0x4A - bl 0x5BBC - - .loc_0x70C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xC4(r4) - bl -0xD2418 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x730 - li r4, 0x4B - bl 0x5B98 - - .loc_0x730: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xC8(r4) - bl -0xD243C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x754 - li r4, 0x4C - bl 0x5B74 - - .loc_0x754: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xCC(r4) - bl -0xD2460 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x778 - li r4, 0x4D - bl 0x5B50 - - .loc_0x778: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xD0(r4) - bl -0xD2484 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x79C - li r4, 0x4E - bl 0x5B2C - - .loc_0x79C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xD4(r4) - bl -0xD24A8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x7C0 - li r4, 0x4F - bl 0x5B08 - - .loc_0x7C0: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xD8(r4) - bl -0xD24CC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x7E4 - li r4, 0x50 - bl 0x5AE4 - - .loc_0x7E4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xDC(r4) - bl -0xD24F0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x808 - li r4, 0x51 - bl 0x5AC0 - - .loc_0x808: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xE0(r4) - bl -0xD2514 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x82C - li r4, 0x52 - bl 0x5A9C - - .loc_0x82C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xE4(r4) - bl -0xD2538 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x850 - li r4, 0x53 - bl 0x5A78 - - .loc_0x850: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xE8(r4) - bl -0xD255C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x874 - li r4, 0x54 - bl 0x5A54 - - .loc_0x874: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xEC(r4) - bl -0xD2580 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x898 - li r4, 0x55 - bl 0x5A30 - - .loc_0x898: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xF0(r4) - bl -0xD25A4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x8BC - li r4, 0x56 - bl 0x5A0C - - .loc_0x8BC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xF4(r4) - bl -0xD25C8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x8E0 - li r4, 0x57 - bl 0x59E8 - - .loc_0x8E0: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xF8(r4) - bl -0xD25EC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x904 - li r4, 0x58 - bl 0x59C4 - - .loc_0x904: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xFC(r4) - bl -0xD2610 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x928 - li r4, 0x59 - bl 0x59A0 - - .loc_0x928: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x100(r4) - bl -0xD2634 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x94C - li r4, 0x5A - bl 0x597C - - .loc_0x94C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x104(r4) - bl -0xD2658 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x970 - li r4, 0x5B - bl 0x5958 - - .loc_0x970: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x108(r4) - bl -0xD267C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x994 - li r4, 0x5C - bl 0x5934 - - .loc_0x994: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x10C(r4) - bl -0xD26A0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x9B8 - li r4, 0x5F - bl 0x5910 - - .loc_0x9B8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x114(r4) - bl -0xD26C4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x9DC - li r4, 0x8 - bl 0x58EC - - .loc_0x9DC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x118(r4) - bl -0xD26E8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xA00 - li r4, 0x1A - bl 0x58C8 - - .loc_0xA00: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x11C(r4) - bl -0xD270C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xA24 - li r4, 0x23 - bl 0x58A4 - - .loc_0xA24: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x40(r4) - bl -0xD2730 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xA48 - li r4, 0x5 - bl 0x5880 - - .loc_0xA48: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x120(r4) - bl -0xD2754 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xA6C - li r4, 0x6 - bl 0x585C - - .loc_0xA6C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x124(r4) - bl -0xD2778 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xA90 - li r4, 0x7 - bl 0x5838 - - .loc_0xA90: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x128(r4) - bl -0xD279C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xAB4 - li r4, 0xE - bl 0x5814 - - .loc_0xAB4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x12C(r4) - bl -0xD27C0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xAD8 - li r4, 0xB - bl 0x57F0 - - .loc_0xAD8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x130(r4) - bl -0xD27E4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xAFC - li r4, 0x11 - bl 0x57CC - - .loc_0xAFC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x134(r4) - bl -0xD2808 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xB20 - li r4, 0x13 - bl 0x57A8 - - .loc_0xB20: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x138(r4) - bl -0xD282C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xB44 - li r4, 0x1B - bl 0x5784 - - .loc_0xB44: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x13C(r4) - bl -0xD2850 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xB68 - li r4, 0x25 - bl 0x5760 - - .loc_0xB68: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x140(r4) - bl -0xD2874 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xB8C - li r4, 0x16 - bl 0x573C - - .loc_0xB8C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x144(r4) - bl -0xD2898 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xBB0 - li r4, 0x2B - bl 0x5718 - - .loc_0xBB0: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x148(r4) - bl -0xD28BC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xBD4 - li r4, 0x5D - bl 0x56F4 - - .loc_0xBD4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x14C(r4) - bl -0xD28E0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xBF8 - li r4, 0x45 - bl 0x56D0 - - .loc_0xBF8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x150(r4) - bl -0xD2904 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xC1C - li r4, 0x48 - bl 0x56AC - - .loc_0xC1C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x154(r4) - bl -0xD2928 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xC40 - li r4, 0x60 - bl 0x5688 - - .loc_0xC40: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x158(r4) - bl -0xD294C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xC64 - li r4, 0x61 - bl 0x5664 - - .loc_0xC64: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x15C(r4) - bl -0xD2970 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xC88 - li r4, 0x62 - bl 0x5640 - - .loc_0xC88: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x160(r4) - bl -0xD2994 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xCAC - li r4, 0x63 - bl 0x561C - - .loc_0xCAC: - lwz r4, 0x4(r31) - mr r3, r31 - stw r30, 0x164(r4) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + PaniMotionTable* table = new PaniMotionTable(PIKIANIM_COUNT); + table->mMotions[0] = new PaniMotion(0); + table->mMotions[1] = new PaniMotion(4); + table->mMotions[2] = new PaniMotion(25); + table->mMotions[3] = new PaniMotion(12); + table->mMotions[4] = new PaniMotion(1); + table->mMotions[5] = new PaniMotion(28); + table->mMotions[6] = new PaniMotion(29); + table->mMotions[7] = new PaniMotion(20); + table->mMotions[8] = new PaniMotion(42); + table->mMotions[9] = new PaniMotion(48); + table->mMotions[10] = new PaniMotion(21); + table->mMotions[11] = new PaniMotion(44); + table->mMotions[12] = new PaniMotion(45); + table->mMotions[13] = new PaniMotion(52); + table->mMotions[14] = new PaniMotion(53); + table->mMotions[15] = new PaniMotion(34); + table->mMotions[17] = new PaniMotion(39); + table->mMotions[18] = new PaniMotion(40); + table->mMotions[19] = new PaniMotion(41); + table->mMotions[20] = new PaniMotion(24); + table->mMotions[21] = new PaniMotion(9); + table->mMotions[22] = new PaniMotion(13); + table->mMotions[23] = new PaniMotion(18); + table->mMotions[24] = new PaniMotion(33); + table->mMotions[25] = new PaniMotion(94); + table->mMotions[26] = new PaniMotion(36); + table->mMotions[27] = new PaniMotion(54); + table->mMotions[28] = new PaniMotion(55); + table->mMotions[29] = new PaniMotion(56); + table->mMotions[30] = new PaniMotion(57); + table->mMotions[31] = new PaniMotion(58); + table->mMotions[32] = new PaniMotion(59); + table->mMotions[33] = new PaniMotion(60); + table->mMotions[34] = new PaniMotion(61); + table->mMotions[35] = new PaniMotion(62); + table->mMotions[36] = new PaniMotion(63); + table->mMotions[37] = new PaniMotion(64); + table->mMotions[38] = new PaniMotion(31); + table->mMotions[39] = new PaniMotion(10); + table->mMotions[40] = new PaniMotion(16); + table->mMotions[41] = new PaniMotion(3); + table->mMotions[42] = new PaniMotion(38); + table->mMotions[43] = new PaniMotion(47); + table->mMotions[44] = new PaniMotion(32); + table->mMotions[45] = new PaniMotion(66); + table->mMotions[46] = new PaniMotion(68); + table->mMotions[47] = new PaniMotion(67); + table->mMotions[48] = new PaniMotion(71); + table->mMotions[49] = new PaniMotion(74); + table->mMotions[50] = new PaniMotion(75); + table->mMotions[51] = new PaniMotion(76); + table->mMotions[52] = new PaniMotion(77); + table->mMotions[53] = new PaniMotion(78); + table->mMotions[54] = new PaniMotion(79); + table->mMotions[55] = new PaniMotion(80); + table->mMotions[56] = new PaniMotion(81); + table->mMotions[57] = new PaniMotion(82); + table->mMotions[58] = new PaniMotion(83); + table->mMotions[59] = new PaniMotion(84); + table->mMotions[60] = new PaniMotion(85); + table->mMotions[61] = new PaniMotion(86); + table->mMotions[62] = new PaniMotion(87); + table->mMotions[63] = new PaniMotion(88); + table->mMotions[64] = new PaniMotion(89); + table->mMotions[65] = new PaniMotion(90); + table->mMotions[66] = new PaniMotion(91); + table->mMotions[67] = new PaniMotion(92); + table->mMotions[69] = new PaniMotion(95); + table->mMotions[70] = new PaniMotion(8); + table->mMotions[71] = new PaniMotion(26); + table->mMotions[16] = new PaniMotion(35); + table->mMotions[72] = new PaniMotion(5); + table->mMotions[73] = new PaniMotion(6); + table->mMotions[74] = new PaniMotion(7); + table->mMotions[75] = new PaniMotion(14); + table->mMotions[76] = new PaniMotion(11); + table->mMotions[77] = new PaniMotion(17); + table->mMotions[78] = new PaniMotion(19); + table->mMotions[79] = new PaniMotion(27); + table->mMotions[80] = new PaniMotion(37); + table->mMotions[81] = new PaniMotion(22); + table->mMotions[82] = new PaniMotion(43); + table->mMotions[83] = new PaniMotion(93); + table->mMotions[84] = new PaniMotion(69); + table->mMotions[85] = new PaniMotion(72); + table->mMotions[86] = new PaniMotion(96); + table->mMotions[87] = new PaniMotion(97); + table->mMotions[88] = new PaniMotion(98); + table->mMotions[89] = new PaniMotion(99); + return table; } /* @@ -1037,24 +149,4 @@ PaniMotionTable* PaniPikiAnimator::createMotionTable() * Address: 801199D4 * Size: 00003C */ -PaniPikiAnimator::PaniPikiAnimator() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - bl 0x56F8 - lis r3, 0x802C - addi r0, r3, 0x37A4 - stw r0, 0x30(r31) - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} +PaniPikiAnimator::PaniPikiAnimator() { } diff --git a/src/plugPikiKando/pelletMgr.cpp b/src/plugPikiKando/pelletMgr.cpp index 66fc85bf..06593d0f 100644 --- a/src/plugPikiKando/pelletMgr.cpp +++ b/src/plugPikiKando/pelletMgr.cpp @@ -5253,7 +5253,7 @@ void PelletMgr::newPellet(u32, PelletView*) * Address: 80098704 * Size: 000094 */ -void PelletMgr::getShapeObject(u32) +PelletShapeObject* PelletMgr::getShapeObject(u32) { /* .loc_0x0: diff --git a/src/plugPikiKando/pikiInf.cpp b/src/plugPikiKando/pikiInf.cpp index c06815d5..3ca46503 100644 --- a/src/plugPikiKando/pikiInf.cpp +++ b/src/plugPikiKando/pikiInf.cpp @@ -221,8 +221,7 @@ void BaseInf::loadCard(RandomAccessStream& card) */ BPikiInf::BPikiInf() { - mPikiHappa = Leaf; - mPikiColor = Blue; + _2C = _2D = 0; // UNUSED FUNCTION } @@ -234,7 +233,7 @@ BPikiInf::BPikiInf() void BPikiInf::saveCard(RandomAccessStream& card) { BaseInf::saveCard(card); - u8 byte = (mPikiHappa << 2) | mPikiColor; + u8 byte = (_2D << 2) | _2C; card.writeByte(byte); } @@ -246,9 +245,9 @@ void BPikiInf::saveCard(RandomAccessStream& card) void BPikiInf::loadCard(RandomAccessStream& card) { BaseInf::loadCard(card); - u8 byte = card.readByte(); - mPikiColor = byte & 0x3; - mPikiHappa = (byte >> 2) & 0x3F; + u8 byte = card.readByte(); + _2C = byte & 0x3; + _2D = (byte >> 2) & 0x3F; } /* @@ -258,8 +257,8 @@ void BPikiInf::loadCard(RandomAccessStream& card) */ void BPikiInf::doStore(Creature* piki) { - mPikiColor = static_cast(piki)->_3CC; - mPikiHappa = static_cast(piki)->_3D0; + _2C = static_cast(piki)->mPikiAnimMgr._58._20; + _2D = static_cast(piki)->mPikiAnimMgr._58._24; } /* @@ -269,8 +268,8 @@ void BPikiInf::doStore(Creature* piki) */ void BPikiInf::doRestore(Creature* piki) { - static_cast(piki)->_3CC = mPikiColor; - static_cast(piki)->_3D0 = mPikiHappa; + static_cast(piki)->mPikiAnimMgr._58._20 = _2C; + static_cast(piki)->mPikiAnimMgr._58._24 = _2D; } /* @@ -400,7 +399,7 @@ int BPikiInfMgr::getPikiCount(int color) int count = 0; FOREACH_NODE(BPikiInf, mActiveList.mChild, currInf) { - if (currInf->mPikiColor == color) { + if (currInf->_2C == color) { count++; } } diff --git a/src/plugPikiKando/playerState.cpp b/src/plugPikiKando/playerState.cpp index ee3df14f..d58fd35c 100644 --- a/src/plugPikiKando/playerState.cpp +++ b/src/plugPikiKando/playerState.cpp @@ -1,7 +1,13 @@ #include "PlayerState.h" #include "Generator.h" #include "FlowController.h" +#include "gameflow.h" +#include "UtEffect.h" +#include "OnePlayerSection.h" +#include "Pellet.h" #include "sysNew.h" +#include "Shape.h" +#include "Piki.h" int PlayerState::totalUfoParts = 30; @@ -636,24 +642,14 @@ PlayerState::PlayerState() * Address: 8007FAA8 * Size: 00002C */ -void TimeGraph::PikiNum::set(int, int) +void TimeGraph::PikiNum::set(int color, int num) { - /* - .loc_0x0: - cmpwi r4, 0 - blt- .loc_0x1C - cmpwi r4, 0x2 - bgt- .loc_0x1C - rlwinm r0,r4,2,0,29 - stwx r5, r3, r0 - blr + if (color >= PikiMinColor && color <= PikiMaxColor) { + mNum[color] = num; + return; + } - .loc_0x1C: - stw r5, 0x8(r3) - stw r5, 0x4(r3) - stw r5, 0x0(r3) - blr - */ + mNum[Blue] = mNum[Red] = mNum[Yellow] = num; } /* @@ -661,69 +657,19 @@ void TimeGraph::PikiNum::set(int, int) * Address: 8007FAD4 * Size: 000070 */ -PlayerState::UfoParts::UfoParts() -{ - /* - .loc_0x0: - mflr r0 - lis r4, 0x802B - stw r0, 0x4(r1) - subi r0, r4, 0x246C - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r3, 0 - lis r3, 0x802B - stw r0, 0x0(r31) - subi r0, r3, 0x21F8 - addi r3, r31, 0x10 - stw r0, 0x0(r31) - bl 0x19E68 - lfs f0, -0x7620(r2) - li r0, 0 - addi r3, r31, 0 - stfs f0, 0xC0(r31) - stfs f0, 0xBC(r31) - stfs f0, 0xB8(r31) - stw r0, 0xC4(r31) - stw r0, 0xC8(r31) - stw r0, 0xCC(r31) - stw r0, 0xD0(r31) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} +PlayerState::UfoParts::UfoParts() { } /* * --INFO-- * Address: 8007FB44 * Size: 000040 */ -void PlayerState::courseOpen(int) +bool PlayerState::courseOpen(int courseID) { - /* - .loc_0x0: - cmpwi r4, 0 - blt- .loc_0x38 - cmpwi r4, 0x5 - bgt- .loc_0x38 - lis r3, 0x803A - subi r3, r3, 0x2848 - li r0, 0x1 - lwz r3, 0x1C8(r3) - slw r0, r0, r4 - and r0, r3, r0 - neg r3, r0 - subic r0, r3, 0x1 - subfe r3, r0, r3 - blr - - .loc_0x38: - li r3, 0 - blr - */ + if (courseID >= 0 && courseID <= 5) { + return (gameflow._1C8 & (1 << courseID)) != 0; + } + return false; } /* @@ -731,19 +677,7 @@ void PlayerState::courseOpen(int) * Address: 8007FB84 * Size: 00001C */ -void PlayerState::happyEndable() -{ - /* - .loc_0x0: - lwz r5, 0x180(r3) - li r0, 0x19 - rlwinm r4,r0,1,31,31 - srawi r3, r5, 0x1F - subc r0, r5, r0 - adde r3, r3, r4 - blr - */ -} +bool PlayerState::happyEndable() { return _180 >= 25; } /* * --INFO-- @@ -752,40 +686,16 @@ void PlayerState::happyEndable() */ void PlayerState::setChallengeMode() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - li r0, 0x1 - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - li r31, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - stb r0, 0x1B6(r3) + _1B6 = 1; + for (int i = 0; i < 63; i++) { + mDemoFlags.setFlagOnly(i); + } - .loc_0x24: - addi r3, r30, 0x54 - addi r4, r31, 0 - bl 0x2B84 - addi r31, r31, 0x1 - cmpwi r31, 0x3F - blt+ .loc_0x24 - li r4, 0 - stb r4, 0x185(r30) - li r3, 0xFF - li r0, 0x1 - stb r3, 0x184(r30) - stb r4, 0x186(r30) - stb r3, 0x1AC(r30) - stb r0, 0x11(r30) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + _185 = 0; + _184 = 255; + _186 = 0; + _1AC = 255; + _11 = 1; } /* @@ -828,14 +738,7 @@ void PlayerState::getCardPikiCount(int) * Address: 8007FC20 * Size: 000008 */ -void PlayerState::getCardUfoPartsCount() -{ - /* - .loc_0x0: - lwz r3, 0x17C(r3) - blr - */ -} +int PlayerState::getCardUfoPartsCount() { return mCurrParts; } /* * --INFO-- @@ -1455,31 +1358,15 @@ void PlayerState::loadCard(RandomAccessStream&) */ bool PlayerState::isTutorial() { - return false; - /* - .loc_0x0: - lis r4, 0x803A - subi r4, r4, 0x24E0 - lwz r4, 0xA8(r4) - cmplwi r4, 0 - beq- .loc_0x28 - lhz r0, 0x26(r4) - cmplwi r0, 0 - beq- .loc_0x28 - li r3, 0 - blr + if (flowCont._A8 && flowCont._A8->_26) { + return false; + } - .loc_0x28: - lbz r0, 0x1B6(r3) - cmplwi r0, 0 - beq- .loc_0x3C - li r3, 0 - blr + if (_1B6) { + return false; + } - .loc_0x3C: - lbz r3, 0x185(r3) - blr - */ + return _185; } /* @@ -1489,21 +1376,8 @@ bool PlayerState::isTutorial() */ bool PlayerState::isGameCourse() { - return false; - /* - .loc_0x0: - lis r3, 0x803A - subi r3, r3, 0x24E0 - lwz r4, 0xA8(r3) - li r3, 0 - lhz r0, 0x24(r4) - cmpwi r0, 0 - bltlr- - cmpwi r0, 0x5 - bgelr- - li r3, 0x1 - blr - */ + int val = flowCont._A8->_24; + return (val >= 0 && val < 5); } /* @@ -1651,41 +1525,15 @@ void PlayerState::init() * Address: 80080604 * Size: 00005C */ -bool PlayerState::hasUfoParts(u32) +bool PlayerState::hasUfoParts(u32 idx) { - return false; - /* - .loc_0x0: - lwz r0, 0x174(r3) - li r7, 0 - li r5, 0 - cmpwi r0, 0 - mtctr r0 - ble- .loc_0x54 - - .loc_0x18: - lwz r6, 0x178(r3) - addi r0, r5, 0x8 - lwzx r0, r6, r0 - cmplw r4, r0 - bne- .loc_0x48 - mulli r0, r7, 0xE0 - add r3, r6, r0 - lbz r0, 0xDC(r3) - neg r3, r0 - subic r0, r3, 0x1 - subfe r3, r0, r3 - blr - - .loc_0x48: - addi r5, r5, 0xE0 - addi r7, r7, 0x1 - bdnz+ .loc_0x18 + for (int i = 0; i < mTotalParts; i++) { + if (idx == mUfoParts[i]._08) { + return mUfoParts[i]._DC != 0; + } + } - .loc_0x54: - li r3, 0 - blr - */ + return false; } /* @@ -1976,52 +1824,19 @@ void PlayerState::exitCourse() * Address: 800809C4 * Size: 000094 */ -void PlayerState::setNavi(bool) +void PlayerState::setNavi(bool p1) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - rlwinm. r0,r4,0,24,31 - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - stw r30, 0x20(r1) - addi r30, r3, 0 - bne- .loc_0x2C - li r0, 0 - stb r0, 0x1B4(r30) - b .loc_0x7C - - .loc_0x2C: - lbz r0, 0x1B4(r30) - cmplwi r0, 0 - bne- .loc_0x7C - lwz r3, 0x1B8(r30) - bl 0x93AF8 - lwz r3, 0x1BC(r30) - bl 0x93AF0 - li r0, 0x1 - stb r0, 0x1B4(r30) - addi r3, r1, 0x10 - li r4, 0x58 - bl 0x9E53C - addi r31, r3, 0 - addi r3, r1, 0x18 - li r4, 0x58 - bl 0x9E52C - addi r4, r3, 0 - addi r5, r31, 0 - addi r3, r30, 0xC4 - bl 0x9F02C + if (!p1) { + _1B4 = 0; + return; + } - .loc_0x7C: - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + if (_1B4 == 0) { + _1B8->restart(); + _1BC->restart(); + _1B4 = 1; + mPikiAnimMgr.startMotion(PaniMotionInfo(88), PaniMotionInfo(88)); + } } /* @@ -2029,14 +1844,7 @@ void PlayerState::setNavi(bool) * Address: 80080A58 * Size: 000008 */ -void PlayerState::getFinalDeadPikis() -{ - /* - .loc_0x0: - lwz r3, 0x1A0(r3) - blr - */ -} +int PlayerState::getFinalDeadPikis() { return _1A0; } /* * --INFO-- @@ -2153,18 +1961,7 @@ void PlayerState::updateFinalResult() * Address: 80080BB0 * Size: 000014 */ -int PlayerState::getCurrDay() -{ - return 0; - /* - .loc_0x0: - lis r3, 0x803A - subi r3, r3, 0x2848 - lwz r3, 0x2FC(r3) - subi r3, r3, 0x1 - blr - */ -} +int PlayerState::getCurrDay() { return gameflow._2FC - 1; } /* * --INFO-- @@ -2258,30 +2055,14 @@ int PlayerState::getPikiHourCount(int, int) * Address: 80080C68 * Size: 000008 */ -int PlayerState::getTotalParts() -{ - return 0; - /* - .loc_0x0: - lwz r3, 0x174(r3) - blr - */ -} +int PlayerState::getTotalParts() { return mTotalParts; } /* * --INFO-- * Address: 80080C70 * Size: 000008 */ -int PlayerState::getCurrParts() -{ - return 0; - /* - .loc_0x0: - lwz r3, 0x17C(r3) - blr - */ -} +int PlayerState::getCurrParts() { return mCurrParts; } /* * --INFO-- @@ -2300,36 +2081,19 @@ void PlayerState::getRestParts() */ bool PlayerState::isUfoBroken() { - return false; - /* - .loc_0x0: - lbz r0, 0x1B6(r3) - cmplwi r0, 0 - beq- .loc_0x14 - li r3, 0 - blr + if (_1B6) { + return false; + } - .loc_0x14: - lwz r0, 0x17C(r3) - cmpwi r0, 0 - ble- .loc_0x28 - li r3, 0 - blr + if (mCurrParts > 0) { + return false; + } - .loc_0x28: - lis r3, 0x803A - subi r3, r3, 0x24E0 - lwz r3, 0xA8(r3) - lhz r0, 0x26(r3) - cmplwi r0, 0 - bne- .loc_0x48 - li r3, 0x1 - blr + if (flowCont._A8->_26 == 0) { + return true; + } - .loc_0x48: - li r3, 0 - blr - */ + return false; } /* @@ -2337,66 +2101,26 @@ bool PlayerState::isUfoBroken() * Address: 80080CC8 * Size: 0000C4 */ -void PlayerState::registerUfoParts(int, u32, u32) +void PlayerState::registerUfoParts(int p1, u32 p2, u32 p3) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x48(r1) - stmw r27, 0x34(r1) - addi r27, r3, 0 - addi r28, r4, 0 - addi r29, r5, 0 - addi r30, r6, 0 - bl 0x18EA8 - lwz r4, 0x301C(r13) - stw r3, 0x1F8(r4) - lwz r3, 0x170(r27) - lwz r0, 0x174(r27) - cmpw r3, r0 - blt- .loc_0x54 - addi r3, r1, 0x24 - addi r4, r29, 0 - bl -0x3CE78 - addi r3, r1, 0x18 - addi r4, r30, 0 - bl -0x3CE84 + pelletMgr->_1F8 = PaniPelletAnimator::createMotionTable(); + if (_170 >= mTotalParts) { + ID32 id1(p2); + ID32 id2(p3); + } - .loc_0x54: - lwz r0, 0x170(r27) - mr r4, r29 - lwz r3, 0x178(r27) - mulli r0, r0, 0xE0 - add r31, r3, r0 - stw r28, 0x4(r31) - stw r30, 0xC(r31) - stw r29, 0x8(r31) - lwz r3, 0x301C(r13) - bl 0x179C4 - addi r30, r3, 0 - addi r3, r31, 0 - addi r4, r30, 0 - bl .loc_0xC4 - cmplwi r30, 0 - beq- .loc_0xA4 - lwz r3, 0x0(r30) - addi r4, r31, 0xC4 - li r5, 0 - bl -0x5143C + UfoParts* part = &mUfoParts[_170]; + part->_04 = p1; + part->_0C = p3; + part->_08 = p2; + PelletShapeObject* shape = pelletMgr->getShapeObject(p2); + part->initAnim(shape); - .loc_0xA4: - lwz r3, 0x170(r27) - addi r0, r3, 0x1 - stw r0, 0x170(r27) - lwz r0, 0x4C(r1) - lmw r27, 0x34(r1) - addi r1, r1, 0x48 - mtlr r0 - blr + if (shape) { + shape->mShape->makeInstance(part->_C4, 0); + } - .loc_0xC4: - */ + _170++; } /* @@ -2404,42 +2128,16 @@ void PlayerState::registerUfoParts(int, u32, u32) * Address: 80080D8C * Size: 000074 */ -void PlayerState::UfoParts::initAnim(PelletShapeObject*) +void PlayerState::UfoParts::initAnim(PelletShapeObject* shape) { - /* - .loc_0x0: - mflr r0 - cmplwi r4, 0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - addi r31, r3, 0 - stw r4, 0xD4(r3) - beq- .loc_0x60 - lwz r8, 0xD4(r31) - addi r3, r31, 0x10 - lwz r5, 0x301C(r13) - lwz r6, 0x4(r8) - addi r4, r8, 0x8 - lwz r7, 0x1F8(r5) - addi r5, r8, 0x18 - bl 0x18BDC - lfs f0, -0x7620(r2) - addi r3, r1, 0x10 - li r4, 0 - stfs f0, 0xD8(r31) - bl 0x9E17C - addi r4, r3, 0 - addi r3, r31, 0x10 - bl 0x18CD8 + mPelletShape = shape; + if (!shape) { + return; + } - .loc_0x60: - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + mAnimator.init(&mPelletShape->_08, &mPelletShape->_18, mPelletShape->mAnimMgr, pelletMgr->_1F8); + _D8 = 0.0f; + mAnimator.startMotion(PaniMotionInfo(0)); } /* diff --git a/src/plugPikiKando/saiEvents.cpp b/src/plugPikiKando/saiEvents.cpp index 6301104e..8f04204a 100644 --- a/src/plugPikiKando/saiEvents.cpp +++ b/src/plugPikiKando/saiEvents.cpp @@ -46,28 +46,40 @@ void SAIEventInit() * Address: 8007CF58 * Size: 000040 */ -void SAIMotionDoneEvent::procAnimMsg(AICreature* creature, MsgAnim* msg) { creature->setEventFlag(mEventID, *msg->_04 == 0); } +void SAIMotionDoneEvent::procAnimMsg(AICreature* creature, MsgAnim* msg) +{ + creature->setEventFlag(mEventID, msg->mKeyEvent->mKeyFrame == 0); +} /* * --INFO-- * Address: 8007CF98 * Size: 000040 */ -void SAIMotionAction0Event::procAnimMsg(AICreature* creature, MsgAnim* msg) { creature->setEventFlag(mEventID, *msg->_04 == 1); } +void SAIMotionAction0Event::procAnimMsg(AICreature* creature, MsgAnim* msg) +{ + creature->setEventFlag(mEventID, msg->mKeyEvent->mKeyFrame == 1); +} /* * --INFO-- * Address: 8007CFD8 * Size: 000040 */ -void SAIMotionLoopStartEvent::procAnimMsg(AICreature* creature, MsgAnim* msg) { creature->setEventFlag(mEventID, *msg->_04 == 5); } +void SAIMotionLoopStartEvent::procAnimMsg(AICreature* creature, MsgAnim* msg) +{ + creature->setEventFlag(mEventID, msg->mKeyEvent->mKeyFrame == 5); +} /* * --INFO-- * Address: 8007D018 * Size: 000040 */ -void SAIMotionLoopEndEvent::procAnimMsg(AICreature* creature, MsgAnim* msg) { creature->setEventFlag(mEventID, *msg->_04 == 6); } +void SAIMotionLoopEndEvent::procAnimMsg(AICreature* creature, MsgAnim* msg) +{ + creature->setEventFlag(mEventID, msg->mKeyEvent->mKeyFrame == 6); +} /* * --INFO-- diff --git a/src/plugPikiKando/simpleAI.cpp b/src/plugPikiKando/simpleAI.cpp index 66ca5b68..719ec8a8 100644 --- a/src/plugPikiKando/simpleAI.cpp +++ b/src/plugPikiKando/simpleAI.cpp @@ -1,4 +1,6 @@ #include "SimpleAI.h" +#include "PikiMacros.h" +#include "sysNew.h" static char file[] = __FILE__; static char name[] = "simpleAI"; @@ -46,8 +48,14 @@ AICreature::AICreature(CreatureProp* props) * Address: 8007D310 * Size: 00006C */ -void AICreature::collisionCallback(CollEvent&) +void AICreature::collisionCallback(CollEvent& event) { + u32 thing = event._00; + MsgCollide msg(event); + _2BC = thing; + if (mStateMachine) { + mStateMachine->procMsg(this, &msg); + } /* .loc_0x0: mflr r0 @@ -89,35 +97,10 @@ void AICreature::collisionCallback(CollEvent&) */ void AICreature::bounceCallback() { - /* - .loc_0x0: - mflr r0 - mr r4, r3 - stw r0, 0x4(r1) - li r0, 0 - stwu r1, -0x38(r1) - lfs f0, -0x6294(r13) - stw r0, 0x24(r1) - lfs f1, -0x6290(r13) - stfs f0, 0x28(r1) - lfs f0, -0x628C(r13) - stfs f1, 0x2C(r1) - stfs f0, 0x30(r1) - lwz r3, 0x2E8(r3) - cmplwi r3, 0 - beq- .loc_0x50 - lwz r12, 0x0(r3) - addi r5, r1, 0x24 - lwz r12, 0x10(r12) - mtlr r12 - blrl - - .loc_0x50: - lwz r0, 0x3C(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ + MsgBounce msg(Vector3f(0.0f, 1.0f, 0.0f)); + if (mStateMachine) { + mStateMachine->procMsg(this, &msg); + } } /* @@ -125,77 +108,24 @@ void AICreature::bounceCallback() * Address: 8007D3DC * Size: 0000B4 */ -void AICreature::animationKeyUpdated(PaniAnimKeyEvent&) +void AICreature::animationKeyUpdated(PaniAnimKeyEvent& event) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - li r0, 0x4 - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - addi r31, r4, 0 - stw r30, 0x18(r1) - mr r30, r3 - lwz r3, 0x6C(r3) - stw r0, 0x10(r1) - subfic r0, r3, 0x10 - stw r31, 0x14(r1) - lwz r3, 0x2E8(r30) - cmplwi r3, 0 - beq- .loc_0x54 - lwz r12, 0x0(r3) - addi r4, r30, 0 - addi r5, r1, 0x10 - lwz r12, 0x10(r12) - mtlr r12 - blrl - - .loc_0x54: - lwz r0, 0x0(r31) - cmpwi r0, 0x7 - bne- .loc_0x78 - mr r3, r30 - lwz r4, 0x4(r31) - lwz r12, 0x0(r30) - lwz r12, 0x128(r12) - mtlr r12 - blrl + DEBUGPRINT(mObjType == OBJTYPE_Goal); - .loc_0x78: - lwz r0, 0x0(r31) - cmpwi r0, 0x8 - bne- .loc_0x9C - mr r3, r30 - lwz r4, 0x4(r31) - lwz r12, 0x0(r30) - lwz r12, 0x12C(r12) - mtlr r12 - blrl + MsgAnim msg(&event); - .loc_0x9C: - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ -} + if (mStateMachine) { + mStateMachine->procMsg(this, &msg); + } -/* - * --INFO-- - * Address: 8007D490 - * Size: 000004 - */ -void AICreature::playEffect(int) { } + if (event.mKeyFrame == 7) { + playSound(event.mValue); + } -/* - * --INFO-- - * Address: 8007D494 - * Size: 000004 - */ -void AICreature::playSound(int) { } + if (event.mKeyFrame == 8) { + playEffect(event.mValue); + } +} /* * --INFO-- @@ -255,126 +185,39 @@ SimpleAI::SimpleAI() { } * Address: 8007D508 * Size: 000068 */ -void SimpleAI::procMsg(AICreature*, Msg*) +void SimpleAI::procMsg(AICreature* creature, Msg* msg) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr r31, r5 - stw r30, 0x18(r1) - addi r30, r4, 0 - addi r3, r30, 0 - lwz r12, 0x0(r30) - lwz r12, 0x120(r12) - mtlr r12 - blrl - cmplwi r3, 0 - beq- .loc_0x50 - lwz r12, 0x0(r3) - addi r4, r30, 0 - addi r5, r31, 0 - lwz r12, 0x8(r12) - mtlr r12 - blrl + AState* state = creature->getCurrState(); - .loc_0x50: - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + if (state) { + state->procMsg(creature, msg); + } } -/* - * --INFO-- - * Address: 8007D570 - * Size: 000008 - */ -AState* AICreature::getCurrState() { return mCurrentState; } - /* * --INFO-- * Address: 8007D578 * Size: 0000E8 */ -void SimpleAI::addState(int, int, SAIAction*, SAIAction*, SAIAction*) +void SimpleAI::addState(int p1, int p2, SAIAction* p3, SAIAction* p4, SAIAction* p5) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x50(r1) - stmw r25, 0x34(r1) - addi r31, r3, 0 - addi r25, r4, 0 - addi r26, r5, 0 - addi r27, r6, 0 - addi r28, r7, 0 - addi r29, r8, 0 - li r3, 0x58 - bl -0x365A0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x44 - mr r4, r25 - bl 0x430 + u32 badCompiler; // god i tried really hard to get this working. - .loc_0x44: - stw r26, 0x48(r30) - stw r27, 0x4C(r30) - stw r28, 0x50(r30) - stw r29, 0x54(r30) - lwz r4, 0x8(r31) - lwz r0, 0xC(r31) - cmpw r4, r0 - bge- .loc_0xD4 - lwz r3, 0x4(r31) - rlwinm r0,r4,2,0,29 - stwx r30, r3, r0 - lwz r3, 0x4(r30) - cmpwi r3, 0 - blt- .loc_0x88 - lwz r0, 0xC(r31) - cmpw r3, r0 - blt- .loc_0x90 - - .loc_0x88: - li r0, 0 - b .loc_0x94 - - .loc_0x90: - li r0, 0x1 - - .loc_0x94: - rlwinm. r0,r0,0,24,31 - beq- .loc_0xD4 - stw r31, 0x8(r30) - lwz r0, 0x8(r31) - lwz r4, 0x4(r30) - lwz r3, 0x10(r31) - rlwinm r0,r0,2,0,29 - stwx r4, r3, r0 - lwz r0, 0x4(r30) - lwz r4, 0x8(r31) - lwz r3, 0x14(r31) - rlwinm r0,r0,2,0,29 - stwx r4, r3, r0 - lwz r3, 0x8(r31) - addi r0, r3, 0x1 - stw r0, 0x8(r31) - - .loc_0xD4: - lmw r25, 0x34(r1) - lwz r0, 0x54(r1) - addi r1, r1, 0x50 - mtlr r0 - blr - */ + SAIState* state = new SAIState(p1); + state->_48 = p2; + state->_4C = p3; + state->_50 = p4; + state->_54 = p5; + + if (isFull()) { + return; + } + + appendState(state); + + if (isValidState(state)) { + initState(state); + } } /* @@ -382,79 +225,21 @@ void SimpleAI::addState(int, int, SAIAction*, SAIAction*, SAIAction*) * Address: 8007D660 * Size: 0000F8 */ -void SimpleAI::addArrow(int, SAIEvent*, int) +SAIArrow* SimpleAI::addArrow(int p1, SAIEvent* event, int p3) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x38(r1) - stmw r27, 0x24(r1) - addi r27, r3, 0 - addi r28, r4, 0 - addi r29, r5, 0 - addi r30, r6, 0 - li r3, 0x34 - bl -0x36680 - addi r31, r3, 0 - mr. r7, r31 - beq- .loc_0x98 - lis r3, 0x8022 - addi r0, r3, 0x738C - lis r3, 0x8022 - stw r0, 0x0(r31) - addi r0, r3, 0x737C - stw r0, 0x0(r31) - li r0, 0 - lis r3, 0x802B - stw r0, 0x10(r31) - lis r6, 0x802B - subi r4, r3, 0x28C0 - stw r0, 0xC(r31) - subi r3, r6, 0x28CC - lis r5, 0x802B - stw r0, 0x8(r31) - subi r0, r5, 0x26D4 - stw r3, 0x4(r31) - addi r3, r7, 0x20 - stw r0, 0x0(r31) - bl -0x48728 - lis r3, 0x802B - subi r0, r3, 0x26FC - stw r0, 0x20(r31) - stw r29, 0x18(r31) - stw r30, 0x14(r31) - - .loc_0x98: - lwz r3, 0x14(r27) - rlwinm r0,r28,2,0,29 - addi r4, r31, 0 - lwzx r0, r3, r0 - cmpwi r0, -0x1 - bne- .loc_0xB8 - li r3, 0 - b .loc_0xE4 + u32 badCompiler; - .loc_0xB8: - lwz r3, 0x4(r27) - rlwinm r0,r0,2,0,29 - lwzx r27, r3, r0 - lwz r0, 0x44(r27) - addi r3, r27, 0x10 - stw r0, 0x1C(r31) - bl -0x3D158 - lwz r4, 0x44(r27) - addi r3, r31, 0 - addi r0, r4, 0x1 - stw r0, 0x44(r27) + SAIArrow* arrow = new SAIArrow("SAIArrow", event, p3); + int stateIdx = mStateIndexes[p1]; + if (stateIdx == -1) { + return nullptr; + } - .loc_0xE4: - lmw r27, 0x24(r1) - lwz r0, 0x3C(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ + SAIState* state = getState(stateIdx); + arrow->mArrowIdx = state->mArrowCount; + state->mRootArrow.add(arrow); + state->mArrowCount++; + return arrow; } /* @@ -679,77 +464,15 @@ bool SAICondition::satisfy(AICreature*) { return true; } */ SAIState::SAIState(int stateID) : AState(stateID) + , mRootArrow("SAIArrowRoot") { - /* - .loc_0x0: - mflr r0 - lis r5, 0x802B - stw r0, 0x4(r1) - subi r0, r5, 0x2950 - lis r6, 0x802B - stwu r1, -0x20(r1) - lis r5, 0x8022 - stw r31, 0x1C(r1) - addi r31, r3, 0 - lis r3, 0x802B - stw r30, 0x18(r1) - li r30, 0 - stw r29, 0x14(r1) - stw r0, 0x0(r31) - subi r0, r3, 0x27B4 - lis r3, 0x8022 - stw r0, 0x0(r31) - subi r0, r6, 0x2804 - stw r4, 0x4(r31) - lis r4, 0x802B - subi r29, r4, 0x28E8 - stw r30, 0x8(r31) - addi r4, r29, 0x28 - stw r0, 0x0(r31) - addi r0, r5, 0x738C - addi r5, r29, 0x34 - stw r0, 0x10(r31) - addi r0, r3, 0x737C - lis r3, 0x802B - stw r0, 0x10(r31) - subi r0, r3, 0x26D4 - addi r3, r31, 0x30 - stw r30, 0x20(r31) - stw r30, 0x1C(r31) - stw r30, 0x18(r31) - stw r5, 0x14(r31) - stw r0, 0x10(r31) - bl -0x48AC4 - lis r3, 0x802B - subi r0, r3, 0x26FC - stw r0, 0x30(r31) - li r5, -0x1 - addi r4, r29, 0x44 - stw r5, 0x24(r31) - addi r0, r29, 0x54 - addi r3, r31, 0 - stw r30, 0x28(r31) - stw r30, 0x40(r31) - stw r30, 0x3C(r31) - stw r30, 0x38(r31) - stw r4, 0x34(r31) - stw r5, 0x48(r31) - stw r30, 0x54(r31) - stw r30, 0x50(r31) - stw r30, 0x4C(r31) - stw r30, 0x20(r31) - stw r30, 0x1C(r31) - stw r30, 0x18(r31) - stw r0, 0x14(r31) - stw r30, 0x44(r31) - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + mRootArrow.mCondition.initCore("saiCondition"); + _48 = -1; + _54 = 0; + _50 = 0; + _4C = 0; + mRootArrow.initCore("rootArrow"); + mArrowCount = 0; } /* @@ -981,27 +704,16 @@ void AICreature::finishMotion() { } * Address: 8007DCF4 * Size: 000008 */ -void AICreature::getCurrentMotionName() -{ - /* - .loc_0x0: - subi r3, r13, 0x6210 - blr - */ -} +char* AICreature::getCurrentMotionName() { return "noname"; } /* * --INFO-- * Address: 8007DCFC * Size: 000008 */ -void AICreature::getCurrentMotionCounter() +f32 AICreature::getCurrentMotionCounter() { - /* - .loc_0x0: - lfs f1, -0x768C(r2) - blr - */ + return -123.4f; // lol } /* @@ -1009,13 +721,9 @@ void AICreature::getCurrentMotionCounter() * Address: 8007DD04 * Size: 000008 */ -void AICreature::getMotionSpeed() +f32 AICreature::getMotionSpeed() { - /* - .loc_0x0: - lfs f1, -0x768C(r2) - blr - */ + return -123.4f; // lol } /* @@ -1079,57 +787,28 @@ void Creature::startAI(int) { } * Address: 8007DD38 * Size: 000008 */ -f32 Creature::getiMass() -{ - return 0.0f; - /* - .loc_0x0: - lfs f1, -0x7688(r2) - blr - */ -} +f32 Creature::getiMass() { return 100.0f; } /* * --INFO-- * Address: 8007DD40 * Size: 000008 */ -f32 Creature::getSize() -{ - /* - .loc_0x0: - lfs f1, -0x7684(r2) - blr - */ -} +f32 Creature::getSize() { return 15.0f; } /* * --INFO-- * Address: 8007DD48 * Size: 000008 */ -f32 Creature::getHeight() -{ - /* - .loc_0x0: - lfs f1, -0x7690(r2) - blr - */ -} +f32 Creature::getHeight() { return 0.0f; } /* * --INFO-- * Address: 8007DD50 * Size: 000008 */ -f32 Creature::getCylinderHeight() -{ - /* - .loc_0x0: - lfs f1, -0x7680(r2) - blr - */ -} +f32 Creature::getCylinderHeight() { return 10.0f; } /* * --INFO-- @@ -1164,38 +843,14 @@ void Creature::doLoad(RandomAccessStream&) { } * Address: 8007DD68 * Size: 00001C */ -Vector3f Creature::getShadowPos() -{ - /* - .loc_0x0: - lfs f0, 0x94(r4) - stfs f0, 0x0(r3) - lfs f0, 0x98(r4) - stfs f0, 0x4(r3) - lfs f0, 0x9C(r4) - stfs f0, 0x8(r3) - blr - */ -} +Vector3f Creature::getShadowPos() { return mPosition; } /* * --INFO-- * Address: 8007DD84 * Size: 00001C */ -void Creature::setCentre(Vector3f&) -{ - /* - .loc_0x0: - lwz r5, 0x0(r4) - lwz r0, 0x4(r4) - stw r5, 0x94(r3) - stw r0, 0x98(r3) - lwz r0, 0x8(r4) - stw r0, 0x9C(r3) - blr - */ -} +void Creature::setCentre(Vector3f& centre) { mPosition = centre; } /* * --INFO-- @@ -1216,18 +871,7 @@ bool Creature::isBuried() { return false; } * Address: 8007DDB8 * Size: 000018 */ -bool Creature::isAlive() -{ - /* - .loc_0x0: - lfs f1, 0x58(r3) - lfs f0, -0x7690(r2) - fcmpo cr0, f1, f0 - mfcr r0 - rlwinm r3,r0,2,31,31 - blr - */ -} +bool Creature::isAlive() { return mHealth > 0.0f; } /* * --INFO-- @@ -1255,18 +899,7 @@ bool Creature::ignoreAtari(Creature*) { return false; } * Address: 8007DDE8 * Size: 000018 */ -bool Creature::isFree() -{ - /* - .loc_0x0: - lwz r0, 0xC8(r3) - rlwinm r0,r0,0,19,19 - neg r3, r0 - subic r0, r3, 0x1 - subfe r3, r0, r3 - blr - */ -} +bool Creature::isFree() { return isCreatureFlag(CF_Free) != 0; } /* * --INFO-- diff --git a/src/plugPikiNakata/nakatacode.cpp b/src/plugPikiNakata/nakatacode.cpp index 20ccb25c..0edcebab 100644 --- a/src/plugPikiNakata/nakatacode.cpp +++ b/src/plugPikiNakata/nakatacode.cpp @@ -1,6 +1,6 @@ #include "CodeInitializer.h" #include "nlib/System.h" -#include "PaniAnimator.h" +#include "PaniPikiAnimator.h" #include "system.h" #include "Teki.h" diff --git a/src/plugPikiNakata/panianimator.cpp b/src/plugPikiNakata/panianimator.cpp index 0de0e7c2..3f77af05 100644 --- a/src/plugPikiNakata/panianimator.cpp +++ b/src/plugPikiNakata/panianimator.cpp @@ -33,24 +33,24 @@ char* PaniAnimator::keyNames[6] = { * Address: 8011EF58 * Size: 000034 */ -PaniMotionInfo::PaniMotionInfo(int p1) { init(p1, nullptr); } +PaniMotionInfo::PaniMotionInfo(int motionIdx) { init(motionIdx, nullptr); } /* * --INFO-- * Address: 8011EF8C * Size: 000030 */ -PaniMotionInfo::PaniMotionInfo(int p1, PaniAnimKeyListener* listener) { init(p1, listener); } +PaniMotionInfo::PaniMotionInfo(int motionIdx, PaniAnimKeyListener* listener) { init(motionIdx, listener); } /* * --INFO-- * Address: 8011EFBC * Size: 00000C */ -void PaniMotionInfo::init(int p1, PaniAnimKeyListener* listener) +void PaniMotionInfo::init(int motionIdx, PaniAnimKeyListener* listener) { - _00 = p1; - mListener = listener; + mMotionIdx = motionIdx; + mListener = listener; } /* @@ -90,10 +90,10 @@ void PaniMotion::init(int p1, int p2) PaniMotionTable::PaniMotionTable(int count) { mMotionCount = count; - _04 = new PaniMotion*[mMotionCount]; + mMotions = new PaniMotion*[mMotionCount]; for (int i = 0; i < mMotionCount; i++) { - _04[i] = nullptr; + mMotions[i] = nullptr; } } @@ -105,10 +105,10 @@ PaniMotionTable::PaniMotionTable(int count) PaniSoundTable::PaniSoundTable(int count) { mSoundCount = count; - _04 = new u32*[mSoundCount]; + mSounds = new u32*[mSoundCount]; for (int i = 0; i < mSoundCount; i++) { - _04[i] = 0; + mSounds[i] = 0; } } @@ -124,7 +124,7 @@ PaniAnimator::PaniAnimator() mListener = nullptr; mAnimInfo = nullptr; mMotionTable = nullptr; - _44 = -1; + mMotionIdx = -1; mCurrentFrame = 0.0f; } @@ -173,12 +173,12 @@ void PaniAnimator::updateContext() void PaniAnimator::startMotion(PaniMotionInfo& info) { if (mAnimInfo) { - _44 = info._00; + mMotionIdx = info.mMotionIdx; mListener = info.mListener; _38 = 0; _40 = 0; mIsFinished = false; - startAnim(2, mMotionTable->_04[_44]->_00, 0, 8); + startAnim(2, mMotionTable->mMotions[mMotionIdx]->_00, 0, 8); } } @@ -210,13 +210,13 @@ void PaniAnimator::finishMotion(PaniMotionInfo& info) * Address: 8011F2E0 * Size: 00010C */ -void PaniAnimator::animate(f32 p1) +void PaniAnimator::animate(f32 speed) { if (!mAnimInfo) { return; } - if (p1 < 0.0f) { + if (speed < 0.0f) { DEBUGPRINT(_38 < 0); } @@ -231,11 +231,11 @@ void PaniAnimator::animate(f32 p1) return; } - p1 *= NSystem::system->getFrameTime(); - mCurrentFrame += p1; + speed *= NSystem::system->getFrameTime(); + mCurrentFrame += speed; checkConstantKeys(); - checkEventKeys(mCurrentFrame - p1, mCurrentFrame); + checkEventKeys(mCurrentFrame - speed, mCurrentFrame); if (mCurrentFrame >= keyVal2) { mCurrentFrame = keyVal2; finishAnimation(); diff --git a/src/plugPikiNakata/panipikianimmgr.cpp b/src/plugPikiNakata/panipikianimmgr.cpp index 85ede0db..4c8f1c09 100644 --- a/src/plugPikiNakata/panipikianimmgr.cpp +++ b/src/plugPikiNakata/panipikianimmgr.cpp @@ -1,4 +1,6 @@ -#include "PaniAnimator.h" +#include "PaniPikiAnimator.h" + +PaniMotionTable* PaniPikiAnimMgr::motionTable; /* * --INFO-- @@ -25,81 +27,31 @@ static void _Print(char*, ...) * Address: ........ * Size: 000034 */ -PaniMotionTable* PaniPikiAnimMgr::getMotionTable() -{ - // UNUSED FUNCTION -} +PaniMotionTable* PaniPikiAnimMgr::getMotionTable() { return motionTable; } /* * --INFO-- * Address: 8011F8A0 * Size: 00003C */ -PaniPikiAnimMgr::PaniPikiAnimMgr() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r3, 0 - addi r3, r31, 0x4 - bl -0x5EE4 - addi r3, r31, 0x58 - bl -0x5EEC - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} +PaniPikiAnimMgr::PaniPikiAnimMgr() { } /* * --INFO-- * Address: 8011F8DC * Size: 00007C */ -void PaniPikiAnimMgr::init(AnimMgr*, AnimContext*, AnimContext*, PaniMotionTable*) +void PaniPikiAnimMgr::init(AnimMgr* mgr, AnimContext* context1, AnimContext* context2, PaniMotionTable* table) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x38(r1) - stmw r27, 0x24(r1) - addi r27, r3, 0 - addi r28, r4, 0 - addi r29, r5, 0 - addi r30, r6, 0 - lwz r0, 0x3158(r13) - cmplwi r0, 0 - bne- .loc_0x34 - bl -0x6C04 - stw r3, 0x3158(r13) + if (!motionTable) { + motionTable = PaniPikiAnimator::createMotionTable(); + } + + PaniMotionTable* sTable = getMotionTable(); + _04.init(context1, mgr, sTable); + _58.init(context2, mgr, sTable); - .loc_0x34: - lwz r31, 0x3158(r13) - addi r4, r29, 0 - addi r5, r28, 0 - addi r6, r31, 0 - addi r3, r27, 0x4 - bl -0x800 - addi r4, r30, 0 - addi r5, r28, 0 - addi r6, r31, 0 - addi r3, r27, 0x58 - bl -0x814 - lfs f0, -0x5F80(r2) - stfs f0, 0x0(r27) - lmw r27, 0x24(r1) - lwz r0, 0x3C(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ + mAnimSpeed = 30.0f; } /* @@ -107,35 +59,10 @@ void PaniPikiAnimMgr::init(AnimMgr*, AnimContext*, AnimContext*, PaniMotionTable * Address: 8011F958 * Size: 000060 */ -void PaniPikiAnimMgr::changeContext(AnimContext*, AnimContext*) +void PaniPikiAnimMgr::changeContext(AnimContext* context1, AnimContext* context2) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr r31, r5 - stw r30, 0x18(r1) - addi r30, r3, 0 - addi r3, r30, 0x4 - lwz r12, 0x34(r30) - lwz r12, 0x8(r12) - mtlr r12 - blrl - addi r3, r30, 0x58 - lwz r12, 0x88(r30) - mr r4, r31 - lwz r12, 0x8(r12) - mtlr r12 - blrl - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + _04.changeContext(context1); + _58.changeContext(context2); } /* @@ -143,37 +70,14 @@ void PaniPikiAnimMgr::changeContext(AnimContext*, AnimContext*) * Address: 8011F9B8 * Size: 000058 */ -void PaniPikiAnimMgr::startMotion(PaniMotionInfo*, PaniMotionInfo*) +void PaniPikiAnimMgr::startMotion(PaniMotionInfo* motion1, PaniMotionInfo* motion2) { - /* - .loc_0x0: - mflr r0 - cmplwi r4, 0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - addi r31, r5, 0 - stw r30, 0x18(r1) - addi r30, r3, 0 - beq- .loc_0x2C - addi r3, r30, 0x4 - bl -0x820 - - .loc_0x2C: - cmplwi r31, 0 - beq- .loc_0x40 - addi r3, r30, 0x58 - addi r4, r31, 0 - bl -0x834 - - .loc_0x40: - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + if (motion1) { + _04.startMotion(*motion1); + } + if (motion2) { + _58.startMotion(*motion2); + } } /* @@ -181,37 +85,14 @@ void PaniPikiAnimMgr::startMotion(PaniMotionInfo*, PaniMotionInfo*) * Address: 8011FA10 * Size: 000058 */ -void PaniPikiAnimMgr::finishMotion(PaniMotionInfo*, PaniMotionInfo*) +void PaniPikiAnimMgr::finishMotion(PaniMotionInfo* motion1, PaniMotionInfo* motion2) { - /* - .loc_0x0: - mflr r0 - cmplwi r4, 0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - addi r31, r5, 0 - stw r30, 0x18(r1) - addi r30, r3, 0 - beq- .loc_0x2C - addi r3, r30, 0x4 - bl -0x808 - - .loc_0x2C: - cmplwi r31, 0 - beq- .loc_0x40 - addi r3, r30, 0x58 - addi r4, r31, 0 - bl -0x81C - - .loc_0x40: - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + if (motion1) { + _04.finishMotion(*motion1); + } + if (motion2) { + _58.finishMotion(*motion2); + } } /* @@ -219,86 +100,16 @@ void PaniPikiAnimMgr::finishMotion(PaniMotionInfo*, PaniMotionInfo*) * Address: 8011FA68 * Size: 000058 */ -void PaniPikiAnimMgr::startMotion(PaniMotionInfo&, PaniMotionInfo&) -{ - /* - .loc_0x0: - mflr r0 - cmplwi r4, 0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - addi r31, r5, 0 - stw r30, 0x18(r1) - addi r30, r3, 0 - beq- .loc_0x2C - addi r3, r30, 0x4 - bl -0x8D0 - - .loc_0x2C: - cmplwi r31, 0 - beq- .loc_0x40 - addi r3, r30, 0x58 - addi r4, r31, 0 - bl -0x8E4 - - .loc_0x40: - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ -} +void PaniPikiAnimMgr::startMotion(PaniMotionInfo& motion1, PaniMotionInfo& motion2) { startMotion(&motion1, &motion2); } /* * --INFO-- * Address: 8011FAC0 * Size: 000084 */ -void PaniPikiAnimMgr::finishMotion(PaniAnimKeyListener*) +void PaniPikiAnimMgr::finishMotion(PaniAnimKeyListener* listener) { - /* - .loc_0x0: - mflr r0 - li r5, 0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - stw r30, 0x28(r1) - addi r30, r4, 0 - li r4, -0x1 - stw r29, 0x24(r1) - addi r29, r3, 0 - addi r3, r1, 0x10 - bl -0xB60 - addi r31, r3, 0 - addi r5, r30, 0 - addi r3, r1, 0x18 - li r4, -0x1 - bl -0xB74 - mr. r4, r3 - beq- .loc_0x54 - addi r3, r29, 0x4 - bl -0x8E0 - - .loc_0x54: - cmplwi r31, 0 - beq- .loc_0x68 - addi r3, r29, 0x58 - addi r4, r31, 0 - bl -0x8F4 - - .loc_0x68: - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - lwz r30, 0x28(r1) - lwz r29, 0x24(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + finishMotion(&PaniMotionInfo(-1, listener), &PaniMotionInfo(-1, nullptr)); } /* @@ -306,67 +117,30 @@ void PaniPikiAnimMgr::finishMotion(PaniAnimKeyListener*) * Address: 8011FB44 * Size: 0000C0 */ -void PaniPikiAnimMgr::updateAnimation(f32) +void PaniPikiAnimMgr::updateAnimation(f32 speed) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x70(r1) - stfd f31, 0x68(r1) - stw r31, 0x64(r1) - mr r31, r3 - lbz r0, 0x4C(r3) - cmplwi r0, 0 - beq- .loc_0x40 - lwz r3, 0x2C(r31) - lfs f1, 0x0(r31) - lfs f0, 0x34(r3) - fcmpo cr0, f1, f0 - bge- .loc_0x44 - stfs f0, 0x0(r31) - b .loc_0x44 + u32 badCompiler; // i tried really hard to get the inlines to work, i promise + + if (isFinished()) { + if (mAnimSpeed < _04.mAnimInfo->mParams.mSpeed()) { + setAnimSpeed(_04.mAnimInfo->mParams.mSpeed()); + } + } else { + setAnimSpeed(speed); + } - .loc_0x40: - stfs f1, 0x0(r31) + f32 currSpeed = mAnimSpeed; + if (!(_04.mAnimInfo->mParams.mFlags() & AnimInfo::FLAG_Unk2)) { + setAnimSpeed(_04.mAnimInfo->mParams.mSpeed()); + } - .loc_0x44: - lwz r4, 0x2C(r31) - lfs f31, 0x0(r31) - lwz r0, 0x24(r4) - rlwinm. r0,r0,0,30,30 - bne- .loc_0x60 - lfs f0, 0x34(r4) - stfs f0, 0x0(r31) + _04.animate(mAnimSpeed); - .loc_0x60: - addi r3, r31, 0x4 - lfs f1, 0x0(r31) - lwz r12, 0x34(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - lwz r4, 0x80(r31) - lwz r0, 0x24(r4) - rlwinm. r0,r0,0,30,30 - bne- .loc_0x90 - lfs f0, 0x34(r4) - stfs f0, 0x0(r31) + if (!(_58.mAnimInfo->mParams.mFlags() & AnimInfo::FLAG_Unk2)) { + setAnimSpeed(_58.mAnimInfo->mParams.mSpeed()); + } - .loc_0x90: - addi r3, r31, 0x58 - fmr f1, f31 - lwz r12, 0x88(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - lwz r0, 0x74(r1) - lfd f31, 0x68(r1) - lwz r31, 0x64(r1) - addi r1, r1, 0x70 - mtlr r0 - blr - */ + _58.animate(currSpeed); } /* @@ -376,27 +150,6 @@ void PaniPikiAnimMgr::updateAnimation(f32) */ void PaniPikiAnimMgr::updateContext() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r3, 0 - addi r3, r31, 0x4 - lwz r12, 0x34(r31) - lwz r12, 0x18(r12) - mtlr r12 - blrl - addi r3, r31, 0x58 - lwz r12, 0x88(r31) - lwz r12, 0x18(r12) - mtlr r12 - blrl - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + _04.updateContext(); + _58.updateContext(); } diff --git a/src/sysCommon/sysMath.cpp b/src/sysCommon/sysMath.cpp index 375a850c..e21b010f 100644 --- a/src/sysCommon/sysMath.cpp +++ b/src/sysCommon/sysMath.cpp @@ -1438,7 +1438,7 @@ f32 roundAng(f32 x) * Address: 800385B4 * Size: 000074 */ -void angDist(f32, f32) +f32 angDist(f32, f32) { /* .loc_0x0: @@ -1487,7 +1487,7 @@ void angDist(f32, f32) * Address: 80038628 * Size: 000050 */ -void qdist2(f32, f32, f32, f32) +f32 qdist2(f32, f32, f32, f32) { // f32 differenceX = point2X - point1X; // f32 absoluteDifferenceX = (differenceX < 0.0f) ? -differenceX : differenceX; @@ -2245,7 +2245,7 @@ void pointInsideTri(KTri&, Vector3f&) * Address: 80039024 * Size: 000260 */ -void triRectDistance(Vector3f*, Vector3f*, Vector3f*, BoundBox&, bool) +f32 triRectDistance(Vector3f*, Vector3f*, Vector3f*, BoundBox&, bool) { /* .loc_0x0: @@ -2427,7 +2427,7 @@ void triRectDistance(Vector3f*, Vector3f*, Vector3f*, BoundBox&, bool) * Address: 80039284 * Size: 0001A8 */ -void distanceTriRect(KTri&, KRect&, f32*, f32*, f32*, f32*) +f32 distanceTriRect(KTri&, KRect&, f32*, f32*, f32*, f32*) { /* .loc_0x0: @@ -2689,7 +2689,7 @@ KSegment::KSegment() * Address: 8003958C * Size: 0018C4 */ -void sqrDistance(KSegment&, KTri&, f32*, f32*, f32*) +f32 sqrDistance(KSegment&, KTri&, f32*, f32*, f32*) { /* .loc_0x0: @@ -4356,7 +4356,7 @@ void sqrDistance(KSegment&, KTri&, f32*, f32*, f32*) * Address: 8003AE50 * Size: 000828 */ -void sqrDistance(KSegment&, KSegment&, f32*, f32*) +f32 sqrDistance(KSegment&, KSegment&, f32*, f32*) { /* .loc_0x0: @@ -4976,7 +4976,7 @@ void sqrDistance(KSegment&, KSegment&, f32*, f32*) * Address: 8003B678 * Size: 001D9C */ -void sqrDistance(KSegment&, KRect&, f32*, f32*, f32*) +f32 sqrDistance(KSegment&, KRect&, f32*, f32*, f32*) { /* .loc_0x0: @@ -6969,7 +6969,7 @@ void sqrDistance(KSegment&, KRect&, f32*, f32*, f32*) * Address: 8003D414 * Size: 000468 */ -void sqrDistance(KTri&, KRect&, f32*, f32*, f32*, f32*) +f32 sqrDistance(KTri&, KRect&, f32*, f32*, f32*, f32*) { /* .loc_0x0: @@ -7283,7 +7283,7 @@ void sqrDistance(KTri&, KRect&, f32*, f32*, f32*, f32*) * Address: 8003D87C * Size: 000540 */ -void sqrDistance(Vector3f&, KTri&, f32*, f32*) +f32 sqrDistance(Vector3f&, KTri&, f32*, f32*) { /* .loc_0x0: