diff --git a/.vscode/settings.json b/.vscode/settings.json index 86585ec2..8ce58beb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,6 +23,7 @@ "math_api.h": "c", "types.h": "c", "math_ppc.h": "c", - "pikidemo.h": "c" + "pikidemo.h": "c", + "mtx.h": "c" } } diff --git a/configure.py b/configure.py index 08682ed3..98f9e6bc 100755 --- a/configure.py +++ b/configure.py @@ -438,10 +438,10 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "plugPikiKando/courseDebug.cpp"), Object(NonMatching, "plugPikiKando/memStat.cpp"), Object(NonMatching, "plugPikiKando/collInfo.cpp"), - Object(NonMatching, "plugPikiKando/complexCreature.cpp"), + Object(Matching, "plugPikiKando/complexCreature.cpp"), Object(NonMatching, "plugPikiKando/creature.cpp"), Object(NonMatching, "plugPikiKando/creatureCollision.cpp"), - Object(NonMatching, "plugPikiKando/creatureCollPart.cpp"), + Object(Matching, "plugPikiKando/creatureCollPart.cpp"), Object(NonMatching, "plugPikiKando/creatureMove.cpp"), Object(NonMatching, "plugPikiKando/creatureStick.cpp"), Object(NonMatching, "plugPikiKando/dualCreature.cpp"), @@ -524,7 +524,7 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "plugPikiKando/itemAI.cpp"), Object(NonMatching, "plugPikiKando/itemMgr.cpp"), Object(Matching, "plugPikiKando/itemObject.cpp"), - Object(NonMatching, "plugPikiKando/mizuItem.cpp"), + Object(Matching, "plugPikiKando/mizuItem.cpp"), Object(Matching, "plugPikiKando/paniItemAnimator.cpp"), Object(NonMatching, "plugPikiKando/genNavi.cpp"), Object(NonMatching, "plugPikiKando/navi.cpp"), @@ -542,12 +542,12 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "plugPikiKando/genMapParts.cpp"), Object(NonMatching, "plugPikiKando/mapParts.cpp"), Object(Matching, "plugPikiKando/panipikianimator.cpp"), - Object(NonMatching, "plugPikiKando/actor.cpp"), + Object(Matching, "plugPikiKando/actor.cpp"), Object(Matching, "plugPikiKando/actorMgr.cpp"), Object(NonMatching, "plugPikiKando/genActor.cpp"), Object(Matching, "plugPikiKando/pikiInfo.cpp"), Object(NonMatching, "plugPikiKando/plantMgr.cpp"), - Object(NonMatching, "plugPikiKando/paniPlantAnimator.cpp"), + Object(Matching, "plugPikiKando/paniPlantAnimator.cpp"), ], }, { @@ -555,9 +555,9 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]: "cflags": cflags_pikmin, "mw_version": "GC/1.2.5n", "objects": [ - Object(NonMatching, "plugPikiNakata/genteki.cpp"), + Object(Matching, "plugPikiNakata/genteki.cpp"), Object(Matching, "plugPikiNakata/nakatacode.cpp"), - Object(NonMatching, "plugPikiNakata/nlibfunction.cpp"), + Object(Matching, "plugPikiNakata/nlibfunction.cpp"), Object(NonMatching, "plugPikiNakata/nlibgeometry.cpp"), Object(NonMatching, "plugPikiNakata/nlibgeometry3d.cpp"), Object(NonMatching, "plugPikiNakata/nlibgraphics.cpp"), @@ -565,8 +565,8 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "plugPikiNakata/nlibspline.cpp"), Object(NonMatching, "plugPikiNakata/nlibsystem.cpp"), Object(Matching, "plugPikiNakata/panianimator.cpp"), - Object(NonMatching, "plugPikiNakata/panipikianimmgr.cpp"), - Object(NonMatching, "plugPikiNakata/panitekianimator.cpp"), + Object(Matching, "plugPikiNakata/panipikianimmgr.cpp"), + Object(Matching, "plugPikiNakata/panitekianimator.cpp"), Object(NonMatching, "plugPikiNakata/panitestsection.cpp"), Object(Matching, "plugPikiNakata/paraparameters.cpp"), Object(NonMatching, "plugPikiNakata/pcamcamera.cpp"), @@ -710,7 +710,7 @@ def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "plugPikiYamashita/TAImar.cpp"), Object(NonMatching, "plugPikiYamashita/TAIAreaction.cpp"), Object(NonMatching, "plugPikiYamashita/TAIAmove.cpp"), - Object(NonMatching, "plugPikiYamashita/TAIAmotion.cpp"), + Object(Matching, "plugPikiYamashita/TAIAmotion.cpp"), Object(NonMatching, "plugPikiYamashita/TAIAjudge.cpp"), Object(NonMatching, "plugPikiYamashita/TAIAattack.cpp"), Object(NonMatching, "plugPikiYamashita/P2DGrafContext.cpp"), diff --git a/include/Actor.h b/include/Actor.h index 55b44395..0dc61ce5 100644 --- a/include/Actor.h +++ b/include/Actor.h @@ -2,8 +2,9 @@ #define _ACTOR_H #include "types.h" -#include "Creature.h" #include "ObjectMgr.h" +#include "AICreature.h" +#include "PaniPikiAnimator.h" struct CreatureProp; struct MapMgr; @@ -13,9 +14,9 @@ struct SimpleAI; /** * @brief TODO * - * @note This HAS to inherit creature to be spawned by ActorMgr::birth, but it doesn't have a vtable?? + * @note Fun fact: The vtable for this does spawn, but then gets stripped :') */ -struct Actor : public Creature { +struct Actor : public AICreature { Actor(); // unused/inlined void setType(int, PikiShapeObject*, CreatureProp*, SimpleAI*); @@ -32,19 +33,20 @@ struct Actor : public Creature { void finishMotion(); void finishMotion(f32); - // TODO: members + // _00 = VTBL + // _00-_304 = AICreature + PaniPikiAnimMgr mPikiAnimMgr; // _304 + PikiShapeObject* mPikiShape; // _3B0 }; /** * @brief TODO * - * @note Inheritance is a guess - it doesn't spawn a vtable, but it uses a virtual method?? MonoObjectMgr seems the best fit. + * @note This also spawns a vtable but it gets stripped. */ struct ActorMgr : public MonoObjectMgr { ActorMgr(MapMgr*); // unused/inlined - // how the hell doesn't this spawn a vtable. - Actor* newActor(int); // unused/inlined: @@ -55,10 +57,10 @@ struct ActorMgr : public MonoObjectMgr { // _08 = VTBL // _00-_3C = MonoObjectMgr // TODO: members? - u8 _3C[0x4]; // _3C, unknown - PikiShapeObject** _40; // _40 - CreatureProp** _44; // _44 - SimpleAI** _48; // _48 + PaniMotionTable* mMotionTable; // _3C + PikiShapeObject** _40; // _40 + CreatureProp** _44; // _44 + SimpleAI** _48; // _48 }; extern ActorMgr* actorMgr; diff --git a/include/ComplexCreature.h b/include/ComplexCreature.h index 52c9d626..3da4962a 100644 --- a/include/ComplexCreature.h +++ b/include/ComplexCreature.h @@ -11,7 +11,7 @@ */ template struct SmartPtr { - SmartPtr(); // should be weak + SmartPtr() { mPtr = nullptr; } void set(T*); @@ -33,7 +33,8 @@ struct ComplexCreature { void doAI(); void postUpdate(int, f32); - // TODO: members + // just here to spawn the right weak functions, who knows what this actually was lol + SmartPtr mCreatures[3]; // _00 }; #endif diff --git a/include/CreatureCollPart.h b/include/CreatureCollPart.h index 2d6e2504..bbd25bcb 100644 --- a/include/CreatureCollPart.h +++ b/include/CreatureCollPart.h @@ -8,6 +8,8 @@ struct CollPart; /** * @brief TODO + * + * @note Size: 0x148. */ struct CreatureCollPart : public DynCollShape { CreatureCollPart() // TODO: fix this, it's implicit but required/this is just a guess @@ -15,13 +17,14 @@ struct CreatureCollPart : public DynCollShape { { } - virtual void update(); // _10 (weak) + virtual void update() { } // _10 (weak) virtual void touchCallback(Plane&, Vector3f&, Vector3f&); // _38 - virtual void refresh(Graphics&); // _44 (weak) + virtual void refresh(Graphics&) { } // _44 (weak) - // _00 = VTBL - // _00-_?? = DynCollShape - // TODO: members + // _00 = VTBL + // _00-_140 = DynCollShape + u8 _140[0x4]; // _140, unknown + int _144; // _144, anim matrix ID? }; /* @@ -32,10 +35,9 @@ struct CreaturePlatMgr { void release(); void update(Graphics&); - // TODO: members - Shape* _00; // _00 - CollPart* _04[16]; // _04 - u32 _44; // _44, count of something? + Shape* mPlatShape; // _00 + CreatureCollPart* mPlatParts[16]; // _04 + int mPartCount; // _44 }; #endif diff --git a/include/DynColl.h b/include/DynColl.h index 33ef9c62..29891f85 100644 --- a/include/DynColl.h +++ b/include/DynColl.h @@ -36,6 +36,8 @@ struct DynCollObject : public Node { /** * @brief TODO + * + * @note Size: 0x140. */ struct DynCollShape : public DynCollObject { DynCollShape(Shape* shape); @@ -59,7 +61,8 @@ struct DynCollShape : public DynCollObject { u8 _30[0x44 - 0x30]; // _30, unknown BoundBox _44; // _44 Matrix4f _5C; // _5C - u8 _9C[0x11C - 0x9C]; // _9C, unknown + Matrix4f _9C; // _9C + u8 _DC[0x11C - 0xDC]; // _CC, unknown Vector3f _11C; // _11C Vector3f _128; // _128 Vector3f _134; // _134 @@ -67,6 +70,8 @@ struct DynCollShape : public DynCollObject { /** * @brief TODO + * + * @note Size: 0x144. */ struct DynCollObjBody : public DynCollShape { DynCollObjBody() // TODO: fix this, it's implicit but required/this is just a guess @@ -79,13 +84,15 @@ struct DynCollObjBody : public DynCollShape { virtual void applyVelocity(Plane&, Vector3f&, Vector3f&); // _34 virtual void touchCallback(Plane&, Vector3f&, Vector3f&); // _38 - // _00 = VTBL - // _00-_?? = DynCollShape - // TODO: members + // _00 = VTBL + // _00-_140 = DynCollShape + u8 _140[0x4]; // _140, unknown }; /** * @brief TODO + * + * @note Size: 0x140. */ struct DynBuildShape : public DynCollShape { DynBuildShape() // TODO: fix this, it's implicit but required/this is just a guess @@ -96,9 +103,8 @@ struct DynBuildShape : public DynCollShape { virtual void update(); // _10 virtual void refresh(Graphics&); // _44 - // _00 = VTBL - // _00-_?? = DynCollShape - // TODO: members + // _00 = VTBL + // _00-_140 = DynCollShape }; #endif diff --git a/include/Generator.h b/include/Generator.h index 6df4cf5e..0d63b40d 100644 --- a/include/Generator.h +++ b/include/Generator.h @@ -11,13 +11,18 @@ struct Creature; struct MapMgr; struct Pellet; +struct Generator; +struct GenType; struct TekiPersonality; /** * @brief TODO */ struct BirthInfo { - // TODO: members + Vector3f _00; // _00 + Vector3f _0C; // _0C, maybe rotation? + Vector3f _18; // _18 + Generator* mGenerator; // _24 }; template @@ -51,7 +56,9 @@ struct Generator : public Node { // _00 = VTBL // _00-_20 = Node - u8 _20[0x58 - 0x20]; // _20, unknown + u8 _20[0x28 - 0x20]; // _20, unknown + GenType* _28; // _28 + u8 _2C[0x58 - 0x2C]; // _2C, unknown ID32 _58; // _58, generator ID? ID32 _64; // _64 // TODO: members @@ -423,6 +430,18 @@ struct GenObjectWorkObject : public GenObject { // TODO: members }; +typedef GenObject* (*GenFunc)(); + +/** + * @brief Fabricated. Need an array of something to go at 0x8 in GenObjectFactory + */ +struct GenObjectInfo { + u32 mID; // _00 + GenFunc mGenFunction; // _04 + char* mName; // _08 + int _0C; // _0C +}; + /** * @brief TODO */ @@ -434,7 +453,9 @@ struct GenObjectFactory : public Factory { static GenObjectFactory* factory; - // TODO: members + int mSpawnerCount; // _00 + int mMaxSpawners; // _04 + GenObjectInfo* mSpawnerInfo; // _08, array }; /** diff --git a/include/ItemMgr.h b/include/ItemMgr.h index 5a5f681c..d560ee45 100644 --- a/include/ItemMgr.h +++ b/include/ItemMgr.h @@ -5,6 +5,7 @@ #include "AICreature.h" #include "ObjectMgr.h" #include "CreatureNode.h" +#include "SimpleAI.h" struct BuildingItemProp; struct GoalAI; @@ -57,6 +58,8 @@ struct ItemCreature : public AICreature { virtual void stopMotion(); // _150 virtual void finalSetup(); // _158 (weak) + inline SimpleAI* getAI() { return static_cast(mStateMachine); } + // _00 = VTBL // _00-_304 = AICreature f32 mMotionSpeed; // _304 diff --git a/include/MapMgr.h b/include/MapMgr.h index e3d53de6..89a27259 100644 --- a/include/MapMgr.h +++ b/include/MapMgr.h @@ -8,6 +8,7 @@ #include "Material.h" struct Controller; +struct CreatureCollPart; struct MoveTrace; /** @@ -198,7 +199,7 @@ struct MapMgr { void recTraceMove(CollGroup*, MoveTrace&, f32); void traceMove(Creature*, MoveTrace&, f32); void loadPlatshape(char*); - CollPart* requestCollPart(ObjCollInfo*, Creature*); + CreatureCollPart* requestCollPart(ObjCollInfo*, Creature*); // unused/inlined: void closeCollTri(CollGroup*, CollTriInfo*); diff --git a/include/Matrix4f.h b/include/Matrix4f.h index a891efa9..02a0b1c7 100644 --- a/include/Matrix4f.h +++ b/include/Matrix4f.h @@ -43,6 +43,15 @@ struct Matrix4f { void makeProjection(Vector3f&, struct Plane&); void makeReflection(Plane&); + inline void set(Matrix4f& other) + { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + mMtx[i][j] = other.mMtx[i][j]; + } + } + } + static Matrix4f ident; Mtx44 mMtx; // _00-_40 diff --git a/include/PaniAnimator.h b/include/PaniAnimator.h index 6857ad93..575cf722 100644 --- a/include/PaniAnimator.h +++ b/include/PaniAnimator.h @@ -65,6 +65,12 @@ struct PaniAnimator : public Animator { void checkCounter_4DEBUG(); inline bool isFinished() const { return mIsFinished; } + inline f32 getCurrentFrame() const { return mCurrentFrame; } + inline void setCurrentFrame(f32 frame) { mCurrentFrame = frame; } + + inline int getMotionID() { return mMotionIdx; } + + inline int get38() { return _38; } // TODO: rename later inline int getInfoKeyValue(int idx) { return mAnimInfo->getInfoKey(idx)->_00; } inline int getEventKeyValue(int idx) { return mAnimInfo->getEventKey(idx)->_00; } @@ -118,6 +124,8 @@ struct PaniPlantAnimator : public PaniAnimator { static PaniMotionTable* createMotionTable(); + static char* motionLabels[7]; + // _30 = VTBL // _00-_54 = PaniAnimator }; @@ -130,6 +138,8 @@ struct PaniTekiAnimator : public PaniAnimator { static PaniMotionTable* createMotionTable(); + static char* motionLabels[15]; + // _30 = VTBL // _00-_54 = PaniAnimator // TODO: members @@ -188,14 +198,28 @@ struct PaniMotionTable { PaniMotion** mMotions; // _04 }; +/** + * @brief Fabricated. + * + * @note Size: 0x4. + */ +struct PaniSound { + PaniSound(int soundID) + : mSoundID(soundID) + { + } + + int mSoundID; // _00 +}; + /** * @brief TODO */ struct PaniSoundTable { PaniSoundTable(int); - int mSoundCount; // _00 - u32** mSounds; // _04, array of some type of pointer + int mSoundCount; // _00 + PaniSound** mSounds; // _04, array of mSoundCount sounds }; #endif diff --git a/include/ParaParameters.h b/include/ParaParameters.h index 53c65005..4403169c 100644 --- a/include/ParaParameters.h +++ b/include/ParaParameters.h @@ -44,7 +44,7 @@ struct ParaParameters { } } - T get(int); + T get(int idx) { return mParameters[idx]; } void set(int idx, T val) { mParameters[idx] = val; } @@ -128,9 +128,9 @@ struct ParaMultiParameters { ParaMultiParameters(int, ParaParameterInfoI*, int, ParaParameterInfoF*); void input(ParaMultiParameters&); - void getF(int); + f32 getF(int idx) { return mFloatParams->get(idx); } - void getI(int); + int getI(int idx) { return mIntParams->get(idx); } void setF(int idx, f32 val) { mFloatParams->set(idx, val); } void setI(int idx, int val) { mIntParams->set(idx, val); } diff --git a/include/Piki.h b/include/Piki.h index 55cc7483..fa27f0e0 100644 --- a/include/Piki.h +++ b/include/Piki.h @@ -22,6 +22,7 @@ enum PikiColor { PikiMinColor = Blue, PikiMaxColor = Yellow, + PIKI_Kinoko = 3, }; /** @@ -189,7 +190,7 @@ struct Piki : public Creature, public PaniAnimKeyListener { u8 _519; // _519 u8 _51A[0x520 - 0x51A]; // _51A, unknown int mHappa; // _520, leaf/bud/flower - u8 _524[0x585 - 0x524]; // _4FC, TODO: work out members + u8 _524[0x585 - 0x524]; // _524, TODO: work out members }; /** @@ -199,15 +200,21 @@ struct PikiShapeObject { PikiShapeObject(Shape*); void exitCourse(); - void getAnimMgr(); - void initOnce(); + static AnimMgr* getAnimMgr(); static void init(); + static void initOnce(); // unused/inlined: void create(int); - // TODO: members + static bool firstTime; + static PikiShapeObject* _instances[4]; + + Shape* mShape; // _00 + AnimContext _04; // _04 + AnimContext _14; // _14 + AnimMgr* mAnimMgr; // _24 }; #endif diff --git a/include/TAI/Amotion.h b/include/TAI/Amotion.h index 56bc133b..a4e0f22a 100644 --- a/include/TAI/Amotion.h +++ b/include/TAI/Amotion.h @@ -3,6 +3,7 @@ #include "types.h" #include "TAI/Action.h" +#include "teki.h" /** * @brief TODO @@ -15,7 +16,7 @@ struct TAIAmotion : public TaiAction { // _04 = VTBL // _00-_08 = TaiAction - int _08; // _08 + int mMotionID; // _08 }; /** @@ -29,7 +30,7 @@ struct TAIAreserveMotion : public TaiAction { // _04 = VTBL // _00-_08 = TaiAction - int _08; // _08 + int mMotionID; // _08 }; /** @@ -41,9 +42,12 @@ struct TAIAmotionLoop : public TAIAreserveMotion { { } - virtual void start(Teki&); // _08 - virtual bool act(Teki&); // _10 - virtual f32 getFrameMax(Teki&); // _1C (weak) + virtual void start(Teki&); // _08 + virtual bool act(Teki&); // _10 + virtual f32 getFrameMax(Teki&) // _1C (weak) + { + return mFrameMax; + } // _04 = VTBL // _00-_0C = TaiAreserveMotion @@ -59,11 +63,16 @@ struct TAIAsetMotionSpeed : public TAIAmotion { { } - virtual void start(Teki&); // _08 + virtual void start(Teki& teki) // _08 + { + u32 badCompiler; + TAIAmotion::start(teki); + teki.setMotionSpeed(mMotionSpeed); + } // _04 = VTBL // _00-_0C = TaiAmotion - // TODO: members + f32 mMotionSpeed; // _0C }; #endif diff --git a/include/TAI/Amove.h b/include/TAI/Amove.h index 9fc5e03d..3ba0e4a7 100644 --- a/include/TAI/Amove.h +++ b/include/TAI/Amove.h @@ -18,8 +18,8 @@ struct TAIAappearKabekui : public TAIAsetMotionSpeed { virtual bool act(Teki&); // _10 // _04 = VTBL - // _00-_0C = TAIAsetMotionSpeed? - // TODO: members + // _00-_10 = TAIAsetMotionSpeed + u8 _10; // _10 }; /** @@ -199,11 +199,12 @@ struct TAIAturnToTarget : public TAIAreserveMotion { virtual f32 getTurnVelocity(Teki&); // _1C // unused/inlined: - void getTurnMotionIndex(Teki&); + int getTurnMotionIndex(Teki&); // _04 = VTBL // _00-_0C = TAIAreserveMotion - // TODO: members + int _0C; // _0C + int _10; // _10 }; /** diff --git a/include/TekiParameters.h b/include/TekiParameters.h index 6afafe59..d0acb1fb 100644 --- a/include/TekiParameters.h +++ b/include/TekiParameters.h @@ -3,6 +3,8 @@ #include "types.h" #include "Node.h" +#include "ID32.h" +#include "ParaParameters.h" /** * @brief TODO @@ -10,7 +12,7 @@ * @note Size: 0x88. */ struct TekiParameters : public Node { - TekiParameters(int, int); + TekiParameters(int iParamNum, int fParamNum); virtual void read(RandomAccessStream&); // _0C @@ -18,7 +20,9 @@ struct TekiParameters : public Node { // _00 = VTBL // _00-_20 = Node - u8 _20[0x88 - 0x20]; // _20, unknown + int _20; // _20 + ID32 mParaIDs[8]; // _24 + ParaMultiParameters* mParameters; // _84 }; #endif diff --git a/include/TekiPersonality.h b/include/TekiPersonality.h index be659ac1..5b64cbeb 100644 --- a/include/TekiPersonality.h +++ b/include/TekiPersonality.h @@ -4,6 +4,7 @@ #include "types.h" #include "Vector.h" #include "ID32.h" +#include "ParaParameters.h" struct RandomAccessStream; struct ParaMultiParameters; @@ -35,7 +36,14 @@ struct TekiPersonality { void reset(); void input(TekiPersonality&); - void getF(int); + f32 getF(int idx) { return mParams->getF(idx); } + + inline void init() + { + _04.set(Vector3f(0.0f, 0.0f, 0.0f)); + _10.set(Vector3f(0.0f, 0.0f, 0.0f)); + _1C = 0.0f; + } // _00 = VTBL Vector3f _04; // _04 diff --git a/include/Vector.h b/include/Vector.h index ca5646ce..cafb838d 100644 --- a/include/Vector.h +++ b/include/Vector.h @@ -74,6 +74,10 @@ struct Vector3f { z = pZ; } + inline void input(const Vector3f& other) { set(other.x, other.y, other.z); } + + inline void set(Vector3f& other) { set(other.x, other.y, other.z); } + inline void operator*=(const f32 other) { this->x *= other; @@ -130,6 +134,13 @@ struct Vector3f { void input(Vector3f&); + void makeIdentity() + { + x = 1.0f; + y = 1.0f; + z = 1.0f; + } + // unused/inlined: void rotateTranspose(Matrix4f&); void rotate(Quat&); diff --git a/include/ViewPiki.h b/include/ViewPiki.h index cc4fe785..6eefe39f 100644 --- a/include/ViewPiki.h +++ b/include/ViewPiki.h @@ -30,7 +30,7 @@ struct ViewPiki : public Piki { // _00 = VTBL // _00-_588 = Piki - // TODO: members + PikiShapeObject* mPikiShape; // _588 }; #endif diff --git a/include/YaiStrategy.h b/include/YaiStrategy.h index fb9cd336..d991a509 100644 --- a/include/YaiStrategy.h +++ b/include/YaiStrategy.h @@ -4,10 +4,12 @@ #include "types.h" #include "TekiStrategy.h" +struct TaiState; + /** * @brief TODO */ -struct YaiStrategy { +struct YaiStrategy : public TekiStrategy { YaiStrategy(int, int); virtual void start(Teki&); // _08 @@ -18,8 +20,10 @@ struct YaiStrategy { void init(int, int); // _00 = VTBL - // _00-_?? = TekiStrategy - // TODO: members + // _00-_04 = TekiStrategy + int _04; // _04 + TaiState** mStates; // _08, array of something + int _0C; // _0C, _324 in teki }; #endif diff --git a/include/gameflow.h b/include/gameflow.h index e48d5eb5..b3a121b4 100644 --- a/include/gameflow.h +++ b/include/gameflow.h @@ -363,7 +363,7 @@ struct GameFlow : public Node { u32 _2FC; // _2FC, unknown, but same as 0x30 in CreatureInf u32 _300; // _300, unknown f32 _304; // _304 - u8 _308[0x4]; // _308, unknown + u32 _308; // _308, unknown GameGenFlow* mGenFlow; // _30C Texture* _310; // _310 f32 _314; // _314 diff --git a/include/nlib/Function.h b/include/nlib/Function.h index 6fbc04c3..4ed3c759 100644 --- a/include/nlib/Function.h +++ b/include/nlib/Function.h @@ -1,9 +1,7 @@ #ifndef _NLIB_FUNCTION_H #define _NLIB_FUNCTION_H -#include "types.h" - -struct NVector3f; +#include "nlib/Geometry.h" /** * @brief TODO @@ -11,7 +9,7 @@ struct NVector3f; struct NFunction { virtual f32 getValue(f32) = 0; // _08 - // TODO: members + // _00 = VTBL }; /** @@ -31,7 +29,9 @@ struct NPolynomialFunction : public NFunction { void mul2(NPolynomialFunction&, NPolynomialFunction&); void getCoefficient(int); - // TODO: members + // _00 = VTBL + // _00-_04 = NFunction + NVector _04; // _04 }; /** @@ -44,7 +44,8 @@ struct NLinearFunction : public NPolynomialFunction { void construct(f32*); void makeLinearFunction(f32, f32, f32, f32); - // TODO: members + // _00 = VTBL + // _00-_0C = NPolynomialFunction }; /** @@ -59,7 +60,10 @@ struct NClampLinearFunction : public NLinearFunction { void construct(f32*); void makeClampLinearFunction(f32, f32, f32, f32); - // TODO: members + // _00 = VTBL + // _00-_0C = NLinearFunction + f32 _0C; // _0C + f32 _10; // _10 }; /** @@ -72,7 +76,11 @@ struct NVibrationFunction : public NFunction { void makeVibrationFunction(f32, f32, f32); - // TODO: members + // _00 = VTBL + // _00-_04 = NFunction + f32 mPhase; // _04 + f32 mAngularFreq; // _08 + f32 mAmplitude; // _0C }; /** @@ -86,7 +94,9 @@ struct NFunction3D { // unused/inlined: void construct(NFunction*, NFunction*, NFunction*); - // TODO: members + NFunction* _00; // _00 + NFunction* _04; // _04 + NFunction* _08; // _08 }; #endif diff --git a/include/nlib/Geometry.h b/include/nlib/Geometry.h index c8820950..44fc58c3 100644 --- a/include/nlib/Geometry.h +++ b/include/nlib/Geometry.h @@ -4,8 +4,8 @@ #include "types.h" #include "Dolphin/mtx.h" #include "Vector.h" +#include "Matrix4f.h" -struct Matrix4f; struct Stream; struct NTransform3D; @@ -25,7 +25,8 @@ struct NVector { void input(NVector&); void println(); - // TODO: members + f32* mValues; // _00, array of size mSize + int mSize; // _04 }; /** @@ -40,16 +41,16 @@ struct NVector3f : public Vector3f { void construct(Vector3f&); void construct(f32, f32, f32); void construct(Vector3f&, Vector3f&); - void isParallel(Vector3f&); + bool isParallel(Vector3f&); void println(); - void normalizeCheck(); + bool normalizeCheck(); void normalize(); // unused/inlined: void printVector3f(Vector3f&); void printlnVector3f(Vector3f&); void interpolate(Vector3f&, Vector3f&, f32); - void isZero(); + bool isZero(); void equals(Vector3f&); void isVertical(Vector3f&); void makeUnitVector(Vector3f&, Vector3f&); @@ -92,7 +93,7 @@ struct NVector3fIOClass : public NVector3fIO { /** * @brief TODO */ -struct NMatrix4f { +struct NMatrix4f : public Matrix4f { NMatrix4f(); NMatrix4f(f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32); NMatrix4f(Matrix4f&); // unused/inlined @@ -124,7 +125,7 @@ struct NMatrix4f { void transpose(); void println(); - // TODO: members + // _00-_30 = Matrix4f }; /** @@ -138,7 +139,8 @@ struct NSpecialMatrix { // unused/inlined: void construct(int); - // TODO: members + // _00 = VTBL + int mDimension; // _04 }; /** @@ -183,7 +185,11 @@ struct LUMatrix : public NSpecialMatrix { void decompose(); void println(); - // TODO: members + // _00 = VTBL + // _00-_08 = NSpecialMatrix + NSpecialMatrix _08; // _08, maybe NLowerMatrix? + u8 _10[0x4]; // _10, unknown + NSpecialMatrix _14; // _14, maybe NUpperMatrix? }; /** @@ -209,7 +215,8 @@ struct NOrientation { void inputRotation(NTransform3D&); void println(); - // TODO: members + NVector3f _00; // _00 + NVector3f _0C; // _0C }; /** @@ -236,7 +243,9 @@ struct NPolar3f { void clampMeridian(f32); void println(); - // TODO: members + f32 _00; // _00 + f32 _04; // _04 + f32 _08; // _08 }; /** @@ -248,7 +257,8 @@ struct NAxisAngle4f { void construct(NVector3f&, f32); - // TODO: members + NVector3f _00; // _00 + f32 _0C; // _0C }; /** @@ -267,7 +277,11 @@ struct NPosture2D { void outputAxisAngle(NAxisAngle4f&); void println(); - // TODO: members + // _00 = VTBL + f32 _04; // _04 + f32 _08; // _08 + f32 _0C; // _0C + f32 _10; // _10 }; /** @@ -301,7 +315,9 @@ struct NPosture3D { void calcDirection(); void println(); - // TODO: members + // _00 = VTBL + NVector3f _04; // _04 + NVector3f _10; // _10 }; /** @@ -338,7 +354,7 @@ struct NTransform3D { void inputRotation(Matrix4f&); void inputRotation(NAxisAngle4f&); - // TODO: members + NMatrix4f mMtx; // _00 }; /** @@ -358,7 +374,11 @@ struct NAlpha { void fadeInOutValue(f32); void fadeOutInValue(f32); - // TODO: members + // _00 = VTBL + f32 _04; // _04 + f32 _08; // _08 + f32 _0C; // _0C + u8 _10; // _10 }; #endif diff --git a/include/nlib/Graphics.h b/include/nlib/Graphics.h index 09b54ef8..0a37245f 100644 --- a/include/nlib/Graphics.h +++ b/include/nlib/Graphics.h @@ -2,6 +2,7 @@ #define _NLIB_GRAPHICS_H #include "types.h" +#include "nlib/Geometry.h" struct Camera; @@ -14,7 +15,10 @@ struct NCamera { void makeMatrix(); void makeCamera(); - // TODO: members + f32 _00; // _00 + Camera* mCamera; // _04 + NVector3f _08; // _08 + NVector3f _14; // _14 }; #endif diff --git a/include/nlib/Math.h b/include/nlib/Math.h index 452fe12c..f6401ce1 100644 --- a/include/nlib/Math.h +++ b/include/nlib/Math.h @@ -4,9 +4,10 @@ #include "types.h" #include "Dolphin/mtx.h" #include "system.h" +#include "Vector.h" namespace NMathF { -f32 cos(f32) +static inline f32 cos(f32) { /* .loc_0x0: @@ -20,7 +21,7 @@ f32 cos(f32) blr */ } -f32 sin(f32) +static inline f32 sin(f32) { /* .loc_0x0: @@ -40,15 +41,46 @@ f32 remainder(f32, f32); // unused/inlined: f32 roundAngle(f32); +inline f32 atan2Vec(Vector3f vec) { return atan2(vec.x, vec.z); } + extern f32 pi; inline f32 getRandomAngle() { return 2.0f * StdSystem::getRand(1.0f) * pi; } + +extern f32 error; } // namespace NMathF template struct NMath { - void copyArray44(Mtx44, Mtx44); - void absolute(f32); + static void copyArray44(Mtx44 output, Mtx44 input) + { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + output[i][j] = input[i][j]; + } + } + } + + static T absolute(T val) + { + if (val > 0) { + return val; + } + return -val; + } + + static T clamp(T val, T lower, T upper) + { + if (val < lower) { + return lower; + } + if (val > upper) { + return upper; + } + return val; + } }; +typedef NMath NMathf; + #endif diff --git a/include/teki.h b/include/teki.h index a4d9d592..dca7949f 100644 --- a/include/teki.h +++ b/include/teki.h @@ -7,6 +7,7 @@ #include "PaniAnimator.h" #include "PelletView.h" #include "Interactions.h" +#include "system.h" struct NTeki; struct Teki; @@ -20,6 +21,7 @@ struct PeveParabolaEvent; struct PeveAccelerationEvent; struct PeveCircleMoveEvent; struct PeveHorizontalSinWaveEvent; +struct TekiPersonality; namespace TekiNakata { // Teki-making utility functions @@ -202,16 +204,19 @@ struct BTeki : public Creature, virtual public PaniAnimKeyListener, public Pelle virtual void playSound(int); // _1C0 virtual void stopSound(int); // _1C4 virtual void createTekiEffect(int); // _1C8 - virtual void setTekiOption(int); // _1CC - virtual void clearTekiOption(int); // _1D0 - virtual void setTekiOptions(int); // _1D4 - virtual void clearTekiOptions(); // _1D8 - virtual void setAnimationKeyOption(int); // _1DC - virtual void clearAnimationKeyOption(int); // _1E0 - virtual void setAnimationKeyOptions(int); // _1E4 - virtual void clearAnimationKeyOptions(); // _1E8 - virtual void dieSoon(); // _1EC - virtual void becomeCorpse(); // _1F0 + virtual void setTekiOption(int opt) // _1CC + { + mTekiOptions |= opt; + } + virtual void clearTekiOption(int); // _1D0 + virtual void setTekiOptions(int); // _1D4 + virtual void clearTekiOptions(); // _1D8 + virtual void setAnimationKeyOption(int); // _1DC + virtual void clearAnimationKeyOption(int); // _1E0 + virtual void setAnimationKeyOptions(int); // _1E4 + virtual void clearAnimationKeyOptions(); // _1E8 + virtual void dieSoon(); // _1EC + virtual void becomeCorpse(); // _1F0 bool isPellet(int); void calcCircleDistanceStatic(Vector3f&, f32, Vector3f&, f32); @@ -240,7 +245,7 @@ struct BTeki : public Creature, virtual public PaniAnimKeyListener, public Pelle void visibleCreature(Creature&); void separateCreature(Creature&); void contactCreature(Creature&); - void attackableCreature(Creature&); + bool attackableCreature(Creature&); void calcTargetAngle(Vector3f&); void moveToward(Vector3f&, f32); void turnToward(f32, f32); @@ -317,9 +322,19 @@ struct BTeki : public Creature, virtual public PaniAnimKeyListener, public Pelle } } + inline void setMotionSpeed(f32 speed) + { + setTekiOption(TEKI_OPTION_MANUAL_ANIMATION); + mMotionSpeed = speed; + } + + inline void setVisible() { setTekiOption(TEKI_OPTION_VISIBLE); } + inline bool isTekiOption(int opt) const { return mTekiOptions & opt; } inline bool isAnimKeyOption(int opt) const { return mAnimKeyOptions & opt; } + inline int getStateID() { return _324; } + // this is basically two static enums smh static int TEKI_OPTION_VISIBLE; static int TEKI_OPTION_SHADOW_VISIBLE; @@ -345,28 +360,31 @@ struct BTeki : public Creature, virtual public PaniAnimKeyListener, public Pelle // _00 = VTBL // _000-_2B8 = Creature // _2B8-_2C0 = PelletView - u8 _2C0[0x2C8 - 0x2C4]; // _2C0, TODO: work out members - void* _2C8; // _2C8 - PaniAnimator* _2CC; // _2CC - u8 _2D0[0x31C - 0x2D0]; // _2D0, TODO: work out members - u32 _31C; // _31C - TekiTypes mTekiType; // _320 - int _324; // _324, related to states - bool _328; // _328, related to states - u8 _329[0x334 - 0x329]; // _329, TODO: work out members - int _334; // _334, related to actions - int _338; // _338, unknown, state id of some description? - u8 _33C[0x388 - 0x33C]; // _33C, TODO: work out members - Vector3f _388; // _388, possibly position - f32 _394; // _394 - u8 _398[0x3B4 - 0x398]; // _398, TODO: work out members - f32 mMotionSpeed; // _3B4 - u8 _3B8[0x410 - 0x3B8]; // _3B8, TODO: work out members - int mTekiOptions; // _410 - int mAnimKeyOptions; // _414 - Creature* _418; // _418, maybe attack target? - u8 _41C[0x454 - 0x41C]; // _41C, TODO: work out members - // _454 = PaniAnimKeyListener + u8 _2C0[0x2C8 - 0x2C4]; // _2C0, TODO: work out members + TekiPersonality* mPersonality; // _2C8 + PaniAnimator* mTekiAnimator; // _2CC + u8 _2D0[0x31C - 0x2D0]; // _2D0, TODO: work out members + u32 _31C; // _31C + TekiTypes mTekiType; // _320 + int _324; // _324, related to states + bool _328; // _328, related to states + u8 _329[0x330 - 0x329]; // _329, TODO: work out members + int _330; // _330 + int _334; // _334, related to actions + int _338; // _338, unknown, state id of some description? + u8 _33C[0x388 - 0x33C]; // _33C, TODO: work out members + Vector3f _388; // _388, possibly position + f32 _394; // _394 + u8 _398[0x3A8 - 0x398]; // _398, TODO: work out members + int _3A8; // _3A8 + u8 _3AC[0x3B4 - 0x3AC]; // _3AC, TODO: work out members + f32 mMotionSpeed; // _3B4 + u8 _3B8[0x410 - 0x3B8]; // _3B8, TODO: work out members + int mTekiOptions; // _410 + int mAnimKeyOptions; // _414 + Creature* _418; // _418, maybe attack target? + u8 _41C[0x454 - 0x41C]; // _41C, TODO: work out members + // _454 = PaniAnimKeyListener }; /** @@ -409,13 +427,23 @@ struct YTeki : public NTeki { // unused/inlined: void getMapAttribute(); + // see TAIAappearKabekui::start + inline void set4C8(u32 val) { _4C8 = (_4C8 & ~0xFFFFFFEF); } + + inline f32 getMotionLoopTimer() { return _478; } // name is a guess + inline void updateMotionLoopTimer() { _478 = getMotionLoopTimer() + gsys->getFrameTime(); } // name is a guess + // _00 = VTBL // _000-_46C = NTeki - u8 _46C[0x478 - 0x46C]; // _46C, TODO: work out members + u8 _46C[0x470 - 0x46C]; // _46C, TODO: work out members + u32 _470; // _470, unknown + u8 _474[0x4]; // _474, TODO: work out members f32 _478; // _478 u8 _47C[0x498 - 0x47C]; // _47C, TODO: work out members u32 _498[8]; // _498, array of something, probably not u32s - u8 _4B8[0x538 - 0x4B8]; // _4B8, TODO: work out members + u8 _4B8[0x4C8 - 0x4B8]; // _4B8, TODO: work out members + u8 _4C8; // _4C8, bitflag? + u8 _4C9[0x538 - 0x4C9]; // _4C9, TODO: work out members // _538 = PaniAnimKeyListener }; diff --git a/src/plugPikiColin/mapMgr.cpp b/src/plugPikiColin/mapMgr.cpp index dc050eb9..d6228576 100644 --- a/src/plugPikiColin/mapMgr.cpp +++ b/src/plugPikiColin/mapMgr.cpp @@ -9481,7 +9481,7 @@ void MapMgr::loadPlatshape(char*) * Address: 80069494 * Size: 00009C */ -CollPart* MapMgr::requestCollPart(ObjCollInfo*, Creature*) +CreatureCollPart* MapMgr::requestCollPart(ObjCollInfo*, Creature*) { /* .loc_0x0: diff --git a/src/plugPikiKando/actor.cpp b/src/plugPikiKando/actor.cpp index b25befe1..764c9ccb 100644 --- a/src/plugPikiKando/actor.cpp +++ b/src/plugPikiKando/actor.cpp @@ -1,4 +1,6 @@ #include "Actor.h" +#include "Piki.h" +#include "SimpleAI.h" /* * --INFO-- @@ -26,7 +28,7 @@ static void _Print(char*, ...) * Size: 000074 */ Actor::Actor() - : Creature(nullptr) + : AICreature(nullptr) { // UNUSED FUNCTION } @@ -36,52 +38,16 @@ Actor::Actor() * Address: 80119A10 * Size: 0000A4 */ -void Actor::setType(int, PikiShapeObject*, CreatureProp*, SimpleAI*) +void Actor::setType(int, PikiShapeObject* shape, CreatureProp* props, SimpleAI* ai) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x40(r1) - stw r31, 0x3C(r1) - stw r30, 0x38(r1) - mr r30, r7 - stw r29, 0x34(r1) - mr r29, r3 - stw r6, 0x224(r3) - stw r5, 0x3B0(r3) - bl -0x41154 - lwz r4, 0x3B0(r29) - stw r3, 0x24(r4) - addi r3, r29, 0x304 - lwz r8, 0x3B0(r29) - lwz r6, 0x3130(r13) - lwz r4, 0x24(r8) - addi r5, r8, 0x14 - lwz r7, 0x3C(r6) - addi r6, r8, 0x4 - bl 0x5E7C - addi r3, r1, 0x1C - li r4, 0x3 - bl 0x54EC - addi r31, r3, 0 - addi r3, r1, 0x24 - li r4, 0x3 - li r5, 0 - bl 0x550C - addi r4, r3, 0 - addi r5, r31, 0 - addi r3, r29, 0x304 - bl 0x5FD8 - stw r30, 0x2E8(r29) - lwz r0, 0x44(r1) - lwz r31, 0x3C(r1) - lwz r30, 0x38(r1) - lwz r29, 0x34(r1) - addi r1, r1, 0x40 - mtlr r0 - blr - */ + mProps = props; + mPikiShape = shape; + mPikiShape->mAnimMgr = PikiShapeObject::getAnimMgr(); + mPikiAnimMgr.init(mPikiShape->mAnimMgr, &mPikiShape->_14, &mPikiShape->_04, actorMgr->mMotionTable); + + mPikiAnimMgr.startMotion(PaniMotionInfo(PIKIANIM_Wait, nullptr), PaniMotionInfo(PIKIANIM_Wait)); + + mStateMachine = ai; } /* diff --git a/src/plugPikiKando/complexCreature.cpp b/src/plugPikiKando/complexCreature.cpp index d8745e1c..dc3c10dc 100644 --- a/src/plugPikiKando/complexCreature.cpp +++ b/src/plugPikiKando/complexCreature.cpp @@ -1,4 +1,5 @@ #include "ComplexCreature.h" +#include "Collision.h" /* * --INFO-- @@ -30,13 +31,6 @@ ComplexCreature::ComplexCreature(int, CreatureProp*) // UNUSED FUNCTION } -/* - * --INFO-- - * Address: 8008A02C - * Size: 00000C - */ -SmartPtr::SmartPtr() { mPtr = nullptr; } - /* * --INFO-- * Address: ........ @@ -94,19 +88,8 @@ void ComplexCreature::doAI() */ void ComplexCreature::postUpdate(int, f32) { + // this is just here for the weak function generation + mCreatures[0].mPtr->bounceCallback(); + mCreatures[0].mPtr->collisionCallback(CollEvent()); // UNUSED FUNCTION } - -// /* -// * --INFO-- -// * Address: 8008A038 -// * Size: 000004 -// */ -// void Creature::collisionCallback(CollEvent&) { } - -// /* -// * --INFO-- -// * Address: 8008A03C -// * Size: 000004 -// */ -// void Creature::bounceCallback() { } diff --git a/src/plugPikiKando/creatureCollPart.cpp b/src/plugPikiKando/creatureCollPart.cpp index 77b76a56..937cb134 100644 --- a/src/plugPikiKando/creatureCollPart.cpp +++ b/src/plugPikiKando/creatureCollPart.cpp @@ -1,6 +1,7 @@ #include "CreatureCollPart.h" #include "Dolphin/os.h" #include "Shape.h" +#include "Graphics.h" #include "MapMgr.h" /* @@ -34,64 +35,19 @@ void CreatureCollPart::touchCallback(Plane&, Vector3f&, Vector3f&) { } */ void CreaturePlatMgr::init(Creature* creature, MapMgr* map, Shape* shape) { - _44 = 0; - _00 = shape; - FOREACH_NODE(ObjCollInfo, _00->mCollisionInfo.mChild, collInfo) + u32 badCompiler; + u32 badCompiler2; + u32 badCompiler3; + + mPartCount = 0; + mPlatShape = shape; + FOREACH_NODE(ObjCollInfo, mPlatShape->mCollisionInfo.mChild, collInfo) { if (collInfo->_48) { - CollPart* part = map->requestCollPart(collInfo, creature); - _04[_44++] = part; + CreatureCollPart* part = map->requestCollPart(collInfo, creature); + mPlatParts[mPartCount++] = part; } } - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - li r0, 0 - stwu r1, -0x38(r1) - stw r31, 0x34(r1) - stw r30, 0x30(r1) - addi r30, r5, 0 - stw r29, 0x2C(r1) - addi r29, r4, 0 - stw r28, 0x28(r1) - addi r28, r3, 0 - stw r0, 0x44(r3) - stw r6, 0x0(r3) - lwz r3, 0x0(r3) - lwz r31, 0xF8(r3) - b .loc_0x78 - - .loc_0x40: - lwz r0, 0x48(r31) - cmplwi r0, 0 - beq- .loc_0x74 - addi r3, r30, 0 - addi r4, r31, 0 - addi r5, r29, 0 - bl -0x24C84 - lwz r4, 0x44(r28) - addi r0, r4, 0x1 - rlwinm r4,r4,2,0,29 - stw r0, 0x44(r28) - addi r0, r4, 0x4 - stwx r3, r28, r0 - - .loc_0x74: - lwz r31, 0xC(r31) - - .loc_0x78: - cmplwi r31, 0 - bne+ .loc_0x40 - lwz r0, 0x3C(r1) - lwz r31, 0x34(r1) - lwz r30, 0x30(r1) - lwz r29, 0x2C(r1) - lwz r28, 0x28(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ } /* @@ -101,39 +57,12 @@ void CreaturePlatMgr::init(Creature* creature, MapMgr* map, Shape* shape) */ void CreaturePlatMgr::release() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - stw r30, 0x18(r1) - li r30, 0 - stw r29, 0x14(r1) - addi r29, r3, 0 - addi r31, r29, 0 - b .loc_0x38 - - .loc_0x28: - lwz r3, 0x4(r31) - bl -0x4DB7C - addi r31, r31, 0x4 - addi r30, r30, 0x1 + for (int i = 0; i < mPartCount; i++) { + CreatureCollPart* part = mPlatParts[i]; + part->del(); + } - .loc_0x38: - lwz r0, 0x44(r29) - cmpw r30, r0 - blt+ .loc_0x28 - li r0, 0 - stw r0, 0x44(r29) - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + mPartCount = 0; } /* @@ -141,90 +70,12 @@ void CreaturePlatMgr::release() * Address: 8008E1C8 * Size: 0000FC */ -void CreaturePlatMgr::update(Graphics&) +void CreaturePlatMgr::update(Graphics& gfx) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x68(r1) - stmw r27, 0x54(r1) - addi r28, r3, 0 - addi r29, r4, 0 - addi r31, r28, 0 - li r30, 0 - b .loc_0xDC - - .loc_0x24: - lwz r27, 0x4(r31) - addi r3, r27, 0x5C - addi r4, r27, 0x9C - bl -0x4FDBC - lwz r3, 0x0(r28) - lwz r4, 0x144(r27) - bl -0x5921C - lwz r6, 0x0(r3) - addi r4, r1, 0x10 - lwz r0, 0x4(r3) - addi r5, r27, 0x5C - stw r6, 0x10(r1) - stw r0, 0x14(r1) - lwz r6, 0x8(r3) - lwz r0, 0xC(r3) - stw r6, 0x18(r1) - stw r0, 0x1C(r1) - lwz r6, 0x10(r3) - lwz r0, 0x14(r3) - stw r6, 0x20(r1) - stw r0, 0x24(r1) - lwz r6, 0x18(r3) - lwz r0, 0x1C(r3) - stw r6, 0x28(r1) - stw r0, 0x2C(r1) - lwz r6, 0x20(r3) - lwz r0, 0x24(r3) - stw r6, 0x30(r1) - stw r0, 0x34(r1) - lwz r6, 0x28(r3) - lwz r0, 0x2C(r3) - stw r6, 0x38(r1) - stw r0, 0x3C(r1) - lwz r6, 0x30(r3) - lwz r0, 0x34(r3) - stw r6, 0x40(r1) - stw r0, 0x44(r1) - lwz r6, 0x38(r3) - lwz r0, 0x3C(r3) - stw r6, 0x48(r1) - stw r0, 0x4C(r1) - lwz r3, 0x2E4(r29) - addi r3, r3, 0x220 - bl -0x501C4 - addi r31, r31, 0x4 - addi r30, r30, 0x1 - - .loc_0xDC: - lwz r0, 0x44(r28) - cmpw r30, r0 - blt+ .loc_0x24 - lmw r27, 0x54(r1) - lwz r0, 0x6C(r1) - addi r1, r1, 0x68 - mtlr r0 - blr - */ + for (int i = 0; i < mPartCount; i++) { + CreatureCollPart* part = mPlatParts[i]; + part->_5C.inverse(&part->_9C); + Matrix4f mat = mPlatShape->getAnimMatrix(part->_144); + gfx._2E4->_220.multiplyTo(mat, part->_5C); + } } - -/* - * --INFO-- - * Address: 8008E2C4 - * Size: 000004 - */ -void CreatureCollPart::update() { } - -/* - * --INFO-- - * Address: 8008E2C8 - * Size: 000004 - */ -void CreatureCollPart::refresh(Graphics&) { } diff --git a/src/plugPikiKando/mizuItem.cpp b/src/plugPikiKando/mizuItem.cpp index 1f3ebbd5..7e3620eb 100644 --- a/src/plugPikiKando/mizuItem.cpp +++ b/src/plugPikiKando/mizuItem.cpp @@ -1,14 +1,13 @@ #include "MizuItem.h" +#include "SimpleAI.h" +#include "Dolphin/os.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) -{ - // UNUSED FUNCTION -} +static void _Error(char* fmt, ...) { OSPanic(__FILE__, __LINE__, fmt, "matoItem"); } /* * --INFO-- @@ -25,38 +24,11 @@ static void _Print(char*, ...) * Address: 800F7CB0 * Size: 000068 */ -MizuItem::MizuItem(int p1, CreatureProp* props, ItemShapeObject*, SimpleAI*) - : ItemCreature(p1, props, nullptr) +MizuItem::MizuItem(int objType, CreatureProp* props, ItemShapeObject* shape, SimpleAI* ai) + : ItemCreature(objType, props, nullptr) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - addi r31, r7, 0 - stw r30, 0x28(r1) - addi r30, r6, 0 - li r6, 0 - stw r29, 0x24(r1) - addi r29, r3, 0 - bl -0x242C - lis r3, 0x802C - subi r3, r3, 0x280 - stw r3, 0x0(r29) - addi r0, r3, 0x114 - addi r3, r29, 0 - stw r0, 0x2B8(r29) - stw r30, 0x3C0(r29) - stw r31, 0x2E8(r29) - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - lwz r30, 0x28(r1) - lwz r29, 0x24(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + mItemShapeObject = shape; + mStateMachine = ai; } /* @@ -66,39 +38,13 @@ MizuItem::MizuItem(int p1, CreatureProp* props, ItemShapeObject*, SimpleAI*) */ void MizuItem::update() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - bl -0x2138 - lwz r0, 0x28C(r31) - cmplwi r0, 0 - beq- .loc_0x5C - lwz r0, 0x6C(r31) - cmpwi r0, 0x6 - bne- .loc_0x5C - li r0, 0x9 - stw r0, 0xC(r1) - lwz r3, 0x2E8(r31) - cmplwi r3, 0 - beq- .loc_0x5C - lwz r12, 0x0(r3) - addi r4, r31, 0 - addi r5, r1, 0xC - lwz r12, 0x10(r12) - mtlr r12 - blrl - - .loc_0x5C: - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + ItemCreature::update(); + if (mFloorTri && mObjType == OBJTYPE_FallWater) { + MsgGround msg; + if (getAI()) { + getAI()->procMsg(this, &msg); + } + } } /* @@ -115,51 +61,18 @@ bool MizuItem::needFlick(Creature*) { return false; } */ void MizuItem::startAI(int) { - /* - .loc_0x0: - mflr r0 - li r4, 0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - addi r31, r3, 0 - addi r3, r1, 0x10 - lfs f0, -0x63B0(r2) - stfs f0, 0x7C(r31) - stfs f0, 0x80(r31) - stfs f0, 0x84(r31) - bl 0x2719C - addi r4, r3, 0 - addi r3, r31, 0x36C - bl 0x273F8 - lwz r0, 0x6C(r31) - cmpwi r0, 0x6 - beq- .loc_0x6C - bge- .loc_0x7C - cmpwi r0, 0x1 - beq- .loc_0x58 - b .loc_0x7C + u32 badCompiler; + _7C.makeIdentity(); + mItemAnimator.startMotion(PaniMotionInfo(0)); - .loc_0x58: - lwz r3, 0x2E8(r31) - addi r4, r31, 0 - li r5, 0x3 - bl -0x7A69C - b .loc_0x7C - - .loc_0x6C: - lwz r3, 0x2E8(r31) - addi r4, r31, 0 - li r5, 0 - bl -0x7A6B0 - - .loc_0x7C: - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + switch (mObjType) { + case OBJTYPE_Water: + getAI()->start(this, 3); + break; + case OBJTYPE_FallWater: + getAI()->start(this, 0); + break; + } } /* @@ -169,42 +82,14 @@ void MizuItem::startAI(int) */ bool MizuItem::isAlive() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr r31, r3 - lwz r12, 0x0(r31) - lwz r12, 0x120(r12) - mtlr r12 - blrl - lwz r0, 0x6C(r31) - lwz r3, 0x4(r3) - cmpwi r0, 0x6 - bne- .loc_0x3C - li r3, 0 - b .loc_0x58 - - .loc_0x3C: - cmpwi r3, 0x4 - beq- .loc_0x4C - cmpwi r3, 0x2 - bne- .loc_0x54 - - .loc_0x4C: - li r3, 0 - b .loc_0x58 + int stateID = getCurrState()->getStateID(); + if (mObjType == OBJTYPE_FallWater) { + return false; + } - .loc_0x54: - li r3, 0x1 + if (stateID == 4 || stateID == 2) { + return false; + } - .loc_0x58: - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + return true; } diff --git a/src/plugPikiKando/paniPlantAnimator.cpp b/src/plugPikiKando/paniPlantAnimator.cpp index 53c7d5ed..99488151 100644 --- a/src/plugPikiKando/paniPlantAnimator.cpp +++ b/src/plugPikiKando/paniPlantAnimator.cpp @@ -1,14 +1,13 @@ #include "PaniAnimator.h" +#include "Dolphin/os.h" +#include "sysNew.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) -{ - // UNUSED FUNCTION -} +static void _Error(char* fmt, ...) { OSPanic(__FILE__, __LINE__, fmt, "paniPlantAnimator"); } /* * --INFO-- @@ -20,6 +19,10 @@ static void _Print(char*, ...) // UNUSED FUNCTION } +char* PaniPlantAnimator::motionLabels[7] = { + "1", "2", "3", "4", "5", "6", "7", +}; + /* * --INFO-- * Address: 8011B148 @@ -27,107 +30,16 @@ static void _Print(char*, ...) */ PaniMotionTable* PaniPlantAnimator::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 -0xD415C - addi r31, r3, 0 - mr. r3, r31 - beq- .loc_0x30 - li r4, 0x7 - bl 0x3E94 - - .loc_0x30: - li r3, 0x8 - bl -0xD4178 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x4C - li r4, 0 - bl 0x3E38 - - .loc_0x4C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x0(r4) - bl -0xD419C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x70 - li r4, 0x1 - bl 0x3E14 - - .loc_0x70: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x4(r4) - bl -0xD41C0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x94 - li r4, 0x2 - bl 0x3DF0 - - .loc_0x94: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x8(r4) - bl -0xD41E4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xB8 - li r4, 0x3 - bl 0x3DCC - - .loc_0xB8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xC(r4) - bl -0xD4208 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xDC - li r4, 0x4 - bl 0x3DA8 - - .loc_0xDC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x10(r4) - bl -0xD422C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x100 - li r4, 0x5 - bl 0x3D84 - - .loc_0x100: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x14(r4) - bl -0xD4250 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x124 - li r4, 0x6 - bl 0x3D60 - - .loc_0x124: - lwz r4, 0x4(r31) - mr r3, r31 - stw r30, 0x18(r4) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + PaniMotionTable* table = new PaniMotionTable(7); + 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; } /* @@ -135,24 +47,4 @@ PaniMotionTable* PaniPlantAnimator::createMotionTable() * Address: 8011B290 * Size: 00003C */ -PaniPlantAnimator::PaniPlantAnimator() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - bl 0x3E3C - lis r3, 0x802C - addi r0, r3, 0x4068 - stw r0, 0x30(r31) - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} +PaniPlantAnimator::PaniPlantAnimator() { } diff --git a/src/plugPikiKando/viewPiki.cpp b/src/plugPikiKando/viewPiki.cpp index 66a2d00d..6d3c2da7 100644 --- a/src/plugPikiKando/viewPiki.cpp +++ b/src/plugPikiKando/viewPiki.cpp @@ -1,4 +1,7 @@ #include "ViewPiki.h" +#include "gameflow.h" +#include "Shape.h" +#include "sysNew.h" /* * --INFO-- @@ -20,6 +23,9 @@ static void _Print(char*, ...) // UNUSED FUNCTION } +PikiShapeObject* PikiShapeObject::_instances[4]; +bool PikiShapeObject::firstTime = true; + /* * --INFO-- * Address: 800D8894 @@ -27,19 +33,8 @@ static void _Print(char*, ...) */ void PikiShapeObject::exitCourse() { - /* - .loc_0x0: - li r0, 0x1 - lis r3, 0x803D - stb r0, -0x3B90(r13) - addi r3, r3, 0x1E48 - li r0, 0 - stw r0, 0xC(r3) - stw r0, 0x8(r3) - stw r0, 0x4(r3) - stw r0, 0x0(r3) - blr - */ + firstTime = true; + _instances[0] = _instances[1] = _instances[2] = _instances[3] = nullptr; } /* @@ -49,19 +44,8 @@ void PikiShapeObject::exitCourse() */ void PikiShapeObject::init() { - /* - .loc_0x0: - li r0, 0x1 - lis r3, 0x803D - stb r0, -0x3B90(r13) - addi r3, r3, 0x1E48 - li r0, 0 - stw r0, 0xC(r3) - stw r0, 0x8(r3) - stw r0, 0x4(r3) - stw r0, 0x0(r3) - blr - */ + firstTime = true; + _instances[0] = _instances[1] = _instances[2] = _instances[3] = nullptr; } /* @@ -79,30 +63,13 @@ void PikiShapeObject::create(int) * Address: 800D88E4 * Size: 00003C */ -void PikiShapeObject::getAnimMgr() +AnimMgr* PikiShapeObject::getAnimMgr() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lbz r0, -0x3B90(r13) - cmplwi r0, 0 - beq- .loc_0x1C - bl .loc_0x3C - - .loc_0x1C: - lis r3, 0x803D - addi r3, r3, 0x1E48 - lwz r3, 0x0(r3) - lwz r3, 0x24(r3) - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr + if (firstTime) { + initOnce(); + } - .loc_0x3C: - */ + return _instances[0]->mAnimMgr; } /* @@ -112,130 +79,19 @@ void PikiShapeObject::getAnimMgr() */ void PikiShapeObject::initOnce() { - /* - .loc_0x0: - mflr r0 - lis r4, 0x802C - stw r0, 0x4(r1) - lis r3, 0x803D - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r3, 0x1E48 - li r3, 0x28 - stw r30, 0x10(r1) - subi r30, r4, 0x5CE0 - stw r29, 0xC(r1) - stw r28, 0x8(r1) - bl -0x9194C - addi r29, r3, 0 - mr. r28, r29 - beq- .loc_0x60 - lis r3, 0x803A - subi r3, r3, 0x2848 - addi r4, r30, 0x2C - li r5, 0x1 - bl -0x85C60 - addi r4, r3, 0 - addi r3, r28, 0 - bl .loc_0x1B4 - - .loc_0x60: - stw r29, 0x0(r31) - li r3, 0xB8 - bl -0x91984 - addi r28, r3, 0 - mr. r3, r28 - beq- .loc_0x94 - lwz r4, 0x0(r31) - lis r6, 0x1 - addi r5, r30, 0x40 - lwz r4, 0x0(r4) - subi r6, r6, 0x8000 - li r7, 0 - bl -0x8810C - - .loc_0x94: - lwz r4, 0x0(r31) - lis r3, 0x803A - subi r29, r3, 0x2848 - stw r28, 0x24(r4) - addi r3, r29, 0 - addi r4, r30, 0x54 - lwz r5, 0x0(r31) - lwz r5, 0x24(r5) - bl -0x85C74 - li r3, 0x28 - bl -0x919D8 - mr. r28, r3 - beq- .loc_0xE4 - addi r3, r29, 0 - addi r4, r30, 0x60 - li r5, 0x1 - bl -0x85CE4 - addi r4, r3, 0 - addi r3, r28, 0 - bl .loc_0x1B4 + _instances[Blue] = new PikiShapeObject(gameflow.loadShape("pikis/bluModel.mod", true)); + _instances[Blue]->mAnimMgr = new AnimMgr(_instances[Blue]->mShape, "pikis/animMgr.bin", 0x8000, nullptr); - .loc_0xE4: - addi r4, r31, 0x4 - stw r28, 0x4(r31) - li r3, 0x28 - lwz r5, 0x0(r31) - lwz r4, 0x0(r4) - lwz r0, 0x24(r5) - stw r0, 0x24(r4) - bl -0x91A1C - mr. r28, r3 - beq- .loc_0x12C - lis r3, 0x803A - subi r3, r3, 0x2848 - addi r4, r30, 0x74 - li r5, 0x1 - bl -0x85D2C - addi r4, r3, 0 - addi r3, r28, 0 - bl .loc_0x1B4 - - .loc_0x12C: - addi r4, r31, 0x8 - stw r28, 0x8(r31) - li r3, 0x28 - lwz r5, 0x0(r31) - lwz r4, 0x0(r4) - lwz r0, 0x24(r5) - stw r0, 0x24(r4) - bl -0x91A64 - mr. r28, r3 - beq- .loc_0x174 - lis r3, 0x803A - subi r3, r3, 0x2848 - addi r4, r30, 0x88 - li r5, 0x1 - bl -0x85D74 - addi r4, r3, 0 - addi r3, r28, 0 - bl .loc_0x1B4 + gameflow.addGenNode("pikiAnimMgr", _instances[Blue]->mAnimMgr); - .loc_0x174: - addi r3, r31, 0xC - stw r28, 0xC(r31) - li r0, 0 - lwz r4, 0x0(r31) - lwz r3, 0x0(r3) - lwz r4, 0x24(r4) - stw r4, 0x24(r3) - stb r0, -0x3B90(r13) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - lwz r29, 0xC(r1) - lwz r28, 0x8(r1) - addi r1, r1, 0x18 - mtlr r0 - blr + _instances[Red] = new PikiShapeObject(gameflow.loadShape("pikis/redModel.mod", true)); + _instances[Red]->mAnimMgr = _instances[Blue]->mAnimMgr; + _instances[Yellow] = new PikiShapeObject(gameflow.loadShape("pikis/yelModel.mod", true)); + _instances[Yellow]->mAnimMgr = _instances[Blue]->mAnimMgr; + _instances[PIKI_Kinoko] = new PikiShapeObject(gameflow.loadShape("pikis/kinModel.mod", true)); + _instances[PIKI_Kinoko]->mAnimMgr = _instances[Blue]->mAnimMgr; - .loc_0x1B4: - */ + firstTime = false; } /* @@ -243,50 +99,13 @@ void PikiShapeObject::initOnce() * Address: 800D8AD4 * Size: 00009C */ -PikiShapeObject::PikiShapeObject(Shape*) +PikiShapeObject::PikiShapeObject(Shape* shape) { - /* - .loc_0x0: - mflr r0 - lis r5, 0x8023 - stw r0, 0x4(r1) - subi r0, r5, 0x7730 - li r6, 0 - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r3, 0 - addi r5, r31, 0x4 - stw r0, 0x10(r3) - lis r3, 0x803A - subi r3, r3, 0x2848 - stw r6, 0x4(r31) - lfs f1, -0x6818(r2) - stfs f1, 0x8(r31) - lfs f0, -0x6814(r2) - stfs f0, 0xC(r31) - stw r0, 0x20(r31) - stw r6, 0x14(r31) - stfs f1, 0x18(r31) - stfs f0, 0x1C(r31) - stw r4, 0x0(r31) - li r4, 0 - lwz r0, 0x308(r3) - lwz r3, 0x0(r31) - stw r0, 0x24(r3) - stw r6, 0x24(r31) - lwz r3, 0x0(r31) - bl -0xA3AE0 - lwz r3, 0x0(r31) - addi r5, r31, 0x14 - li r4, 0x1 - bl -0xA3AF0 - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + mShape = shape; + mShape->_24 = gameflow._308; + mAnimMgr = nullptr; + mShape->overrideAnim(0, &_04); + mShape->overrideAnim(1, &_14); } /* @@ -294,20 +113,7 @@ PikiShapeObject::PikiShapeObject(Shape*) * Address: 800D8B70 * Size: 000020 */ -bool ViewPiki::isKinoko() -{ - /* - .loc_0x0: - lis r4, 0x803D - lwz r5, 0x588(r3) - addi r3, r4, 0x1E48 - lwz r0, 0xC(r3) - sub r0, r0, r5 - cntlzw r0, r0 - rlwinm r3,r0,27,5,31 - blr - */ -} +bool ViewPiki::isKinoko() { return mPikiShape == PikiShapeObject::_instances[PIKI_Kinoko]; } /* * --INFO-- diff --git a/src/plugPikiNakata/genteki.cpp b/src/plugPikiNakata/genteki.cpp index f81b8a9b..a9bac9ac 100644 --- a/src/plugPikiNakata/genteki.cpp +++ b/src/plugPikiNakata/genteki.cpp @@ -1,6 +1,7 @@ #include "Generator.h" #include "sysNew.h" #include "TekiPersonality.h" +#include "TekiParameters.h" #include "Dolphin/os.h" #include "teki.h" @@ -30,7 +31,7 @@ static void _Print(char*, ...) * Address: 8011B2CC * Size: 000040 */ -static GenObjectTeki* makeObjectTeki() { return new GenObjectTeki(); } +static GenObject* makeObjectTeki() { return new GenObjectTeki(); } /* * --INFO-- @@ -39,43 +40,17 @@ static GenObjectTeki* makeObjectTeki() { return new GenObjectTeki(); } */ void GenObjectTeki::initialise() { - /* - .loc_0x0: - lwz r7, 0x3074(r13) - lwz r5, 0x0(r7) - lwz r0, 0x4(r7) - cmpw r5, r0 - bgelr- - lis r4, 0x7465 - lwz r3, 0x8(r7) - addi r4, r4, 0x6B69 - rlwinm r0,r5,4,0,27 - stwx r4, r3, r0 - lis r4, 0x8012 - lis r3, 0x802C - lwz r0, 0x0(r7) - subi r6, r4, 0x4D34 - lwz r4, 0x8(r7) - addi r5, r3, 0x4094 - rlwinm r0,r0,4,0,27 - add r3, r4, r0 - stw r6, 0x4(r3) - li r4, 0xA - lwz r0, 0x0(r7) - lwz r3, 0x8(r7) - rlwinm r0,r0,4,0,27 - add r3, r3, r0 - stw r5, 0x8(r3) - lwz r0, 0x0(r7) - lwz r3, 0x8(r7) - rlwinm r0,r0,4,0,27 - add r3, r3, r0 - stw r4, 0xC(r3) - lwz r3, 0x0(r7) - addi r0, r3, 0x1 - stw r0, 0x0(r7) - blr - */ + GenObjectFactory* fact = GenObjectFactory::factory; + if (fact->mSpawnerCount >= fact->mMaxSpawners) { + return; + } + + fact->mSpawnerInfo[fact->mSpawnerCount].mID = 'teki'; + fact->mSpawnerInfo[fact->mSpawnerCount].mGenFunction = &makeObjectTeki; + fact->mSpawnerInfo[fact->mSpawnerCount].mName = "敵を発生"; // 'spawn enemies' + fact->mSpawnerInfo[fact->mSpawnerCount]._0C = 10; + + fact->mSpawnerCount++; } /* @@ -133,39 +108,11 @@ void GenObjectTeki::updateUseList(Generator*, int) if (!tekiMgr->mTekiParams[mTekiType]) { return; } - /* - .loc_0x0: - lwz r4, 0x1C(r3) - cmpwi r4, 0 - bltlr- - cmpwi r4, 0x23 - blt- .loc_0x18 - blr - .loc_0x18: - lwz r0, 0x3160(r13) - li r5, 0x1 - add r4, r0, r4 - stb r5, 0x164(r4) - lwz r0, 0x1C(r3) - lwz r4, 0x3160(r13) - rlwinm r0,r0,2,0,29 - add r3, r4, r0 - lwz r3, 0x4C(r3) - cmplwi r3, 0 - beqlr- - lwz r3, 0x84(r3) - lwz r3, 0x0(r3) - lwz r3, 0x0(r3) - lwz r0, 0xC(r3) - cmpwi r0, 0 - bltlr- - cmpwi r0, 0x23 - bgelr- - add r3, r4, r0 - stb r5, 0x164(r3) - blr - */ + int tekiType = tekiMgr->mTekiParams[mTekiType]->mParameters->mIntParams[0].mParameters[3]; + if (tekiType >= TEKI_START && tekiType < TEKI_TypeCount) { + tekiMgr->mUsingType[tekiType] = true; + } } /* @@ -175,85 +122,27 @@ void GenObjectTeki::updateUseList(Generator*, int) */ void* GenObjectTeki::birth(BirthInfo& info) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x48(r1) - stw r31, 0x44(r1) - stw r30, 0x40(r1) - mr r30, r4 - stw r29, 0x3C(r1) - mr r29, r3 - lwz r3, 0x3160(r13) - lwz r4, 0x1C(r29) - bl 0x2F598 - mr. r31, r3 - bne- .loc_0x3C - li r3, 0 - b .loc_0x104 - - .loc_0x3C: - lwz r3, 0x18(r29) - lfs f0, 0x0(r30) - stfsu f0, 0x4(r3) - lfs f0, 0x4(r30) - stfs f0, 0x4(r3) - lfs f0, 0x8(r30) - stfs f0, 0x8(r3) - lwz r3, 0x18(r29) - lfs f0, 0x18(r30) - stfsu f0, 0x10(r3) - lfs f0, 0x1C(r30) - stfs f0, 0x4(r3) - lfs f0, 0x20(r30) - stfs f0, 0x8(r3) - lfs f0, 0x10(r30) - lwz r3, 0x18(r29) - stfs f0, 0x1C(r3) - lwz r3, 0x2C8(r31) - lwz r4, 0x18(r29) - bl 0x31770 - mr r3, r31 - lwz r12, 0x0(r31) - lwz r12, 0x170(r12) - mtlr r12 - blrl - mr r3, r31 - lwz r12, 0x0(r31) - li r4, 0 - lwz r12, 0x34(r12) - mtlr r12 - blrl - lwz r3, 0xC(r30) - lwz r0, 0x10(r30) - stw r3, 0x88(r31) - stw r0, 0x8C(r31) - lwz r0, 0x14(r30) - stw r0, 0x90(r31) - lwz r3, 0x24(r30) - lwz r3, 0x28(r3) - lwz r0, 0x34(r3) - cmpwi r0, 0 - beq- .loc_0xF0 - lwz r0, 0xC8(r31) - oris r0, r0, 0x1 - stw r0, 0xC8(r31) + // TODO: work out the right inlines for this + u32 badCompiler; + u32 badCompiler2; + u32 badCompiler3; + + Teki* teki = tekiMgr->newTeki(mTekiType); + if (!teki) { + return nullptr; + } - .loc_0xF0: - lwz r4, 0x24(r30) - mr r3, r31 - lwz r4, 0x28(r4) - lwz r0, 0x24(r4) - stw r0, 0x34(r31) + mPersonality->_04.set(info._00); + mPersonality->_10.set(info._18); + mPersonality->_1C = info._0C.y; + teki->mPersonality->input(*mPersonality); + teki->reset(); + teki->startAI(0); + teki->_88 = info._0C; + if (info.mGenerator->_28->_28()) { + teki->setCreatureFlag(CF_Unk16); + } - .loc_0x104: - lwz r0, 0x4C(r1) - lwz r31, 0x44(r1) - lwz r30, 0x40(r1) - lwz r29, 0x3C(r1) - addi r1, r1, 0x48 - mtlr r0 - blr - */ + teki->_34 = info.mGenerator->_28->_18(); + return teki; } diff --git a/src/plugPikiNakata/nlibfunction.cpp b/src/plugPikiNakata/nlibfunction.cpp index faef1c01..1ec26054 100644 --- a/src/plugPikiNakata/nlibfunction.cpp +++ b/src/plugPikiNakata/nlibfunction.cpp @@ -1,12 +1,16 @@ #include "nlib/Function.h" +#include "nlib/Math.h" +#include "PikiMacros.h" +#include "Dolphin/os.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) +static void _Error(char* fmt, ...) { + OSPanic(__FILE__, __LINE__, fmt, "nlibfunction"); // UNUSED FUNCTION } @@ -35,22 +39,7 @@ NPolynomialFunction::NPolynomialFunction(f32*, int) * Address: 8011B6E4 * Size: 000028 */ -void NPolynomialFunction::construct(f32*, int) -{ - /* - .loc_0x0: - mflr r0 - addi r3, r3, 0x4 - stw r0, 0x4(r1) - addi r5, r5, 0x1 - stwu r1, -0x8(r1) - bl 0x16D8 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NPolynomialFunction::construct(f32* p1, int p2) { _04.construct(p1, p2 + 1); } /* * --INFO-- @@ -69,7 +58,8 @@ NPolynomialFunction::NPolynomialFunction(f32*, NPolynomialFunction&) */ void NPolynomialFunction::construct(f32*, NPolynomialFunction&) { - // UNUSED FUNCTION + _04.mValues[0] = 0.0f; // need 0.0f to get used before getValue + // UNUSED FUNCTION } /* @@ -87,90 +77,15 @@ void NPolynomialFunction::mul2(NPolynomialFunction&, NPolynomialFunction&) * Address: 8011B70C * Size: 000114 */ -f32 NPolynomialFunction::getValue(f32) +f32 NPolynomialFunction::getValue(f32 p1) { - /* - .loc_0x0: - lwz r6, 0x8(r3) - li r7, 0 - lfs f7, -0x5FFC(r2) - cmpwi r6, 0 - lfs f8, -0x6000(r2) - ble- .loc_0x100 - cmpwi r6, 0x8 - subi r4, r6, 0x8 - ble- .loc_0x108 - addi r0, r4, 0x7 - rlwinm r0,r0,29,3,31 - cmpwi r4, 0 - mtctr r0 - li r4, 0 - ble- .loc_0x108 - - .loc_0x3C: - lwz r0, 0x4(r3) - addi r7, r7, 0x8 - add r5, r0, r4 - lfs f2, 0x0(r5) - addi r4, r4, 0x20 - lfs f0, 0x4(r5) - fmuls f2, f7, f2 - lfs f6, 0x8(r5) - fmuls f7, f7, f1 - lfs f5, 0xC(r5) - lfs f4, 0x10(r5) - fmuls f0, f7, f0 - lfs f3, 0x14(r5) - fadds f8, f8, f2 - lfs f2, 0x18(r5) - fmuls f7, f7, f1 - fadds f8, f8, f0 - lfs f0, 0x1C(r5) - fmuls f6, f7, f6 - fmuls f7, f7, f1 - fadds f8, f8, f6 - fmuls f5, f7, f5 - fmuls f7, f7, f1 - fadds f8, f8, f5 - fmuls f4, f7, f4 - fmuls f7, f7, f1 - fadds f8, f8, f4 - fmuls f3, f7, f3 - fmuls f7, f7, f1 - fadds f8, f8, f3 - fmuls f2, f7, f2 - fmuls f7, f7, f1 - fadds f8, f8, f2 - fmuls f0, f7, f0 - fmuls f7, f7, f1 - fadds f8, f8, f0 - bdnz+ .loc_0x3C - b .loc_0x108 - - .loc_0xD4: - sub r0, r6, r7 - cmpw r7, r6 - mtctr r0 - bge- .loc_0x100 - - .loc_0xE4: - lwz r4, 0x4(r3) - lfsx f0, r4, r5 - addi r5, r5, 0x4 - fmuls f0, f7, f0 - fmuls f7, f7, f1 - fadds f8, f8, f0 - bdnz+ .loc_0xE4 - - .loc_0x100: - fmr f1, f8 - blr - - .loc_0x108: - rlwinm r5,r7,2,0,29 - b .loc_0xD4 - blr - */ + f32 factor = 1.0f; + f32 value = 0.0f; + for (int i = 0; i < _04.mSize; i++) { + value += factor * _04.mValues[i]; + factor *= p1; + } + return value; } /* @@ -190,37 +105,10 @@ void NPolynomialFunction::getCoefficient(int) */ void NPolynomialFunction::println() { - /* - .loc_0x0: - lwz r5, 0x8(r3) - li r6, 0 - cmpwi r5, 0 - blelr- - cmpwi r5, 0x8 - subi r4, r5, 0x8 - ble- .loc_0x38 - addi r0, r4, 0x7 - rlwinm r0,r0,29,3,31 - cmpwi r4, 0 - mtctr r0 - ble- .loc_0x38 - - .loc_0x30: - addi r6, r6, 0x8 - bdnz+ .loc_0x30 - - .loc_0x38: - sub r0, r5, r6 - cmpw r6, r5 - mtctr r0 - bgelr- - - .loc_0x48: - bdnz- .loc_0x48 - blr - b .loc_0x38 - blr - */ + DEBUGPRINT(_04.mSize); + for (int i = 0; i < _04.mSize; i++) { + DEBUGPRINT(_04.mValues[i]); + } } /* @@ -228,8 +116,8 @@ void NPolynomialFunction::println() * Address: ........ * Size: 000070 */ -NLinearFunction::NLinearFunction(f32* p1) - : NPolynomialFunction(p1, 1) +NLinearFunction::NLinearFunction(f32* values) + : NPolynomialFunction(values, 1) { // UNUSED FUNCTION } @@ -239,7 +127,7 @@ NLinearFunction::NLinearFunction(f32* p1) * Address: ........ * Size: 000028 */ -void NLinearFunction::construct(f32*) +void NLinearFunction::construct(f32* values) { // UNUSED FUNCTION } @@ -259,45 +147,10 @@ void NLinearFunction::makeLinearFunction(f32, f32, f32, f32) * Address: 8011B878 * Size: 00007C */ -NClampLinearFunction::NClampLinearFunction(f32* p1) - : NLinearFunction(p1) +NClampLinearFunction::NClampLinearFunction(f32* values) + : NLinearFunction(values) { - /* - .loc_0x0: - mflr r0 - lis r5, 0x802C - stw r0, 0x4(r1) - addi r0, r5, 0x425C - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r4, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - lis r3, 0x802C - stw r0, 0x0(r30) - addi r0, r3, 0x424C - addi r3, r30, 0x4 - stw r0, 0x0(r30) - bl 0x1510 - lis r3, 0x802C - addi r0, r3, 0x423C - lis r3, 0x802C - stw r0, 0x0(r30) - addi r0, r3, 0x422C - stw r0, 0x0(r30) - addi r3, r30, 0 - addi r4, r31, 0 - bl .loc_0x7C - mr r3, r30 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - - .loc_0x7C: - */ + construct(values); } /* @@ -305,85 +158,25 @@ NClampLinearFunction::NClampLinearFunction(f32* p1) * Address: 8011B8F4 * Size: 000028 */ -void NClampLinearFunction::construct(f32*) -{ - /* - .loc_0x0: - mflr r0 - addi r3, r3, 0x4 - stw r0, 0x4(r1) - li r5, 0x2 - stwu r1, -0x8(r1) - bl 0x14C8 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NClampLinearFunction::construct(f32* values) { _04.construct(values, 2); } /* * --INFO-- * Address: 8011B91C * Size: 000090 */ -void NClampLinearFunction::makeClampLinearFunction(f32, f32, f32, f32) +void NClampLinearFunction::makeClampLinearFunction(f32 p1, f32 p2, f32 p3, f32 p4) { - /* - .loc_0x0: - fsubs f5, f3, f1 - lfs f0, -0x6000(r2) - fcmpo cr0, f5, f0 - ble- .loc_0x18 - fmr f3, f5 - b .loc_0x1C - - .loc_0x18: - fneg f3, f5 - - .loc_0x1C: - lfs f0, -0x1CB0(r13) - fcmpo cr0, f3, f0 - cror 2, 0, 0x2 - bne- .loc_0x3C - lfs f0, -0x5FFC(r2) - lwz r4, 0x4(r3) - stfs f0, 0x4(r4) - b .loc_0x4C + if (NMathf::absolute(p3 - p1) <= NMathF::error) { + _04.mValues[1] = 1.0f; + } else { + _04.mValues[1] = (p4 - p2) / (p3 - p1); + } - .loc_0x3C: - fsubs f0, f4, f2 - lwz r4, 0x4(r3) - fdivs f0, f0, f5 - stfs f0, 0x4(r4) + _04.mValues[0] = p2 - _04.mValues[1] * p1; - .loc_0x4C: - lwz r4, 0x4(r3) - fcmpo cr0, f2, f4 - lfs f0, 0x4(r4) - fmuls f0, f0, f1 - fsubs f0, f2, f0 - stfs f0, 0x0(r4) - bge- .loc_0x70 - fmr f0, f2 - b .loc_0x74 - - .loc_0x70: - fmr f0, f4 - - .loc_0x74: - fcmpo cr0, f2, f4 - stfs f0, 0xC(r3) - bge- .loc_0x84 - b .loc_0x88 - - .loc_0x84: - fmr f4, f2 - - .loc_0x88: - stfs f4, 0x10(r3) - blr - */ + _0C = p2 < p4 ? p2 : p4; + _10 = p2 < p4 ? p4 : p2; } /* @@ -391,100 +184,10 @@ void NClampLinearFunction::makeClampLinearFunction(f32, f32, f32, f32) * Address: 8011B9AC * Size: 000134 */ -f32 NClampLinearFunction::getValue(f32) +f32 NClampLinearFunction::getValue(f32 p1) { - /* - .loc_0x0: - lwz r6, 0x8(r3) - li r4, 0 - lfs f8, -0x5FFC(r2) - cmpwi r6, 0 - lfs f7, -0x6000(r2) - ble- .loc_0x100 - cmpwi r6, 0x8 - subi r5, r6, 0x8 - ble- .loc_0x128 - addi r0, r5, 0x7 - rlwinm r0,r0,29,3,31 - cmpwi r5, 0 - mtctr r0 - addi r5, r4, 0 - ble- .loc_0x128 - - .loc_0x3C: - lwz r0, 0x4(r3) - addi r4, r4, 0x8 - add r7, r0, r5 - lfs f2, 0x0(r7) - addi r5, r5, 0x20 - lfs f0, 0x4(r7) - fmuls f2, f8, f2 - lfs f6, 0x8(r7) - fmuls f8, f8, f1 - lfs f5, 0xC(r7) - lfs f4, 0x10(r7) - fmuls f0, f8, f0 - lfs f3, 0x14(r7) - fadds f7, f7, f2 - lfs f2, 0x18(r7) - fmuls f8, f8, f1 - fadds f7, f7, f0 - lfs f0, 0x1C(r7) - fmuls f6, f8, f6 - fmuls f8, f8, f1 - fadds f7, f7, f6 - fmuls f5, f8, f5 - fmuls f8, f8, f1 - fadds f7, f7, f5 - fmuls f4, f8, f4 - fmuls f8, f8, f1 - fadds f7, f7, f4 - fmuls f3, f8, f3 - fmuls f8, f8, f1 - fadds f7, f7, f3 - fmuls f2, f8, f2 - fmuls f8, f8, f1 - fadds f7, f7, f2 - fmuls f0, f8, f0 - fmuls f8, f8, f1 - fadds f7, f7, f0 - bdnz+ .loc_0x3C - b .loc_0x128 - - .loc_0xD4: - sub r0, r6, r4 - cmpw r4, r6 - mtctr r0 - bge- .loc_0x100 - - .loc_0xE4: - lwz r4, 0x4(r3) - lfsx f0, r4, r5 - addi r5, r5, 0x4 - fmuls f0, f8, f0 - fmuls f8, f8, f1 - fadds f7, f7, f0 - bdnz+ .loc_0xE4 - - .loc_0x100: - lfs f1, 0xC(r3) - lfs f0, 0x10(r3) - fcmpo cr0, f7, f1 - bltlr- - fcmpo cr0, f7, f0 - ble- .loc_0x120 - fmr f1, f0 - blr - - .loc_0x120: - fmr f1, f7 - blr - - .loc_0x128: - rlwinm r5,r4,2,0,29 - b .loc_0xD4 - blr - */ + f32 val = NPolynomialFunction::getValue(p1); + return NMathf::clamp(val, _0C, _10); } /* @@ -494,37 +197,9 @@ f32 NClampLinearFunction::getValue(f32) */ void NClampLinearFunction::println() { - /* - .loc_0x0: - lwz r6, 0x8(r3) - li r4, 0 - cmpwi r6, 0 - blelr- - cmpwi r6, 0x8 - subi r5, r6, 0x8 - ble- .loc_0x38 - addi r0, r5, 0x7 - rlwinm r0,r0,29,3,31 - cmpwi r5, 0 - mtctr r0 - ble- .loc_0x38 - - .loc_0x30: - addi r4, r4, 0x8 - bdnz+ .loc_0x30 - - .loc_0x38: - sub r0, r6, r4 - cmpw r4, r6 - mtctr r0 - bgelr- - - .loc_0x48: - bdnz- .loc_0x48 - blr - b .loc_0x38 - blr - */ + NPolynomialFunction::println(); + DEBUGPRINT(_0C); + DEBUGPRINT(_10); } /* @@ -534,24 +209,9 @@ void NClampLinearFunction::println() */ NVibrationFunction::NVibrationFunction() { - /* - .loc_0x0: - lis r4, 0x802C - addi r0, r4, 0x425C - lis r4, 0x802C - stw r0, 0x0(r3) - addi r0, r4, 0x41A8 - stw r0, 0x0(r3) - lfs f0, -0x6000(r2) - stfs f0, 0x4(r3) - lfs f1, -0x5FF8(r2) - lfs f0, -0x1CA4(r13) - fmuls f0, f1, f0 - stfs f0, 0x8(r3) - lfs f0, -0x5FFC(r2) - stfs f0, 0xC(r3) - blr - */ + mPhase = 0.0f; + mAngularFreq = 2.0f * NMathF::pi; + mAmplitude = 1.0f; } /* @@ -559,19 +219,11 @@ NVibrationFunction::NVibrationFunction() * Address: 8011BB74 * Size: 000020 */ -void NVibrationFunction::makeVibrationFunction(f32, f32, f32) +void NVibrationFunction::makeVibrationFunction(f32 phase, f32 period, f32 amp) { - /* - .loc_0x0: - stfs f1, 0x4(r3) - lfs f1, -0x5FF8(r2) - lfs f0, -0x1CA4(r13) - fmuls f0, f1, f0 - fdivs f0, f0, f2 - stfs f0, 0x8(r3) - stfs f3, 0xC(r3) - blr - */ + mPhase = phase; + mAngularFreq = (2.0f * NMathF::pi) / period; + mAmplitude = amp; } /* @@ -579,28 +231,10 @@ void NVibrationFunction::makeVibrationFunction(f32, f32, f32) * Address: 8011BB94 * Size: 000044 */ -f32 NVibrationFunction::getValue(f32) +f32 NVibrationFunction::getValue(f32 p1) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr r31, r3 - lfs f0, 0x8(r3) - lfs f2, 0x4(r3) - fmuls f0, f0, f1 - fadds f1, f2, f0 - bl 0x100130 - lfs f0, 0xC(r31) - lwz r0, 0x24(r1) - fmuls f1, f0, f1 - lwz r31, 0x1C(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + u32 badCompiler; + return mAmplitude * sinf(mPhase + mAngularFreq * p1); } /* @@ -628,51 +262,4 @@ void NFunction3D::construct(NFunction*, NFunction*, NFunction*) * Address: 8011BBD8 * Size: 0000A8 */ -void NFunction3D::outputPosition(f32, NVector3f&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x38(r1) - stfd f31, 0x30(r1) - stfd f30, 0x28(r1) - stfd f29, 0x20(r1) - fmr f29, f1 - stw r31, 0x1C(r1) - mr r31, r4 - stw r30, 0x18(r1) - mr r30, r3 - lwz r3, 0x8(r3) - lwz r12, 0x0(r3) - lwz r12, 0x8(r12) - mtlr r12 - blrl - lwz r3, 0x4(r30) - fmr f30, f1 - fmr f1, f29 - lwz r12, 0x0(r3) - lwz r12, 0x8(r12) - mtlr r12 - blrl - lwz r3, 0x0(r30) - fmr f31, f1 - fmr f1, f29 - lwz r12, 0x0(r3) - lwz r12, 0x8(r12) - mtlr r12 - blrl - stfs f1, 0x0(r31) - stfs f31, 0x4(r31) - stfs f30, 0x8(r31) - lwz r0, 0x3C(r1) - lfd f31, 0x30(r1) - lfd f30, 0x28(r1) - lfd f29, 0x20(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x38 - mtlr r0 - blr - */ -} +void NFunction3D::outputPosition(f32 val, NVector3f& vec) { vec.set(_00->getValue(val), _04->getValue(val), _08->getValue(val)); } diff --git a/src/plugPikiNakata/nlibgeometry.cpp b/src/plugPikiNakata/nlibgeometry.cpp index ce9342a8..d6556658 100644 --- a/src/plugPikiNakata/nlibgeometry.cpp +++ b/src/plugPikiNakata/nlibgeometry.cpp @@ -37,55 +37,17 @@ NAxisAngle4f::NAxisAngle4f() * Address: 8011BC80 * Size: 000058 */ -NAxisAngle4f::NAxisAngle4f(NVector3f&, f32) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stfd f31, 0x20(r1) - fmr f31, f1 - stw r31, 0x1C(r1) - addi r31, r4, 0 - stw r30, 0x18(r1) - addi r30, r3, 0 - bl 0x11B0 - fmr f1, f31 - addi r3, r30, 0 - addi r4, r31, 0 - bl .loc_0x58 - mr r3, r30 - lwz r0, 0x2C(r1) - lfd f31, 0x20(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - - .loc_0x58: - */ -} +NAxisAngle4f::NAxisAngle4f(NVector3f& p1, f32 p2) { construct(p1, p2); } /* * --INFO-- * Address: 8011BCD8 * Size: 000020 */ -void NAxisAngle4f::construct(NVector3f&, f32) +void NAxisAngle4f::construct(NVector3f& p1, f32 p2) { - /* - .loc_0x0: - lfs f0, 0x0(r4) - stfs f0, 0x0(r3) - lfs f0, 0x4(r4) - stfs f0, 0x4(r3) - lfs f0, 0x8(r4) - stfs f0, 0x8(r3) - stfs f1, 0xC(r3) - blr - */ + _00.input(p1); + _0C = p2; } /* @@ -93,44 +55,7 @@ void NAxisAngle4f::construct(NVector3f&, f32) * Address: 8011BCF8 * Size: 000080 */ -NMatrix4f::NMatrix4f() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x78(r1) - stw r31, 0x74(r1) - addi r31, r3, 0 - addi r3, r1, 0x2C - lfs f2, -0x5FF0(r2) - stfs f2, 0x8(r1) - fmr f3, f2 - fmr f4, f2 - stfs f2, 0xC(r1) - fmr f5, f2 - fmr f7, f2 - lfs f1, -0x5FEC(r2) - fmr f8, f2 - stfs f1, 0x10(r1) - fmr f6, f1 - stfs f2, 0x14(r1) - stfs f2, 0x18(r1) - stfs f2, 0x1C(r1) - stfs f2, 0x20(r1) - stfs f1, 0x24(r1) - bl 0x48 - addi r4, r3, 0 - addi r3, r31, 0 - bl 0xAC - mr r3, r31 - lwz r0, 0x7C(r1) - lwz r31, 0x74(r1) - addi r1, r1, 0x78 - mtlr r0 - blr - */ -} +NMatrix4f::NMatrix4f() { input(NMatrix4f(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f)); } /* * --INFO-- @@ -147,59 +72,17 @@ NMatrix4f::NMatrix4f(Matrix4f&) * Address: 8011BD78 * Size: 000020 */ -void NMatrix4f::construct(Matrix4f&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - bl 0x84 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NMatrix4f::construct(Matrix4f& mat) { input(mat); } /* * --INFO-- * Address: 8011BD98 * Size: 000070 */ -NMatrix4f::NMatrix4f(f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32) +NMatrix4f::NMatrix4f(f32 x00, f32 x01, f32 x02, f32 x03, f32 x10, f32 x11, f32 x12, f32 x13, f32 x20, f32 x21, f32 x22, f32 x23, f32 x30, + f32 x31, f32 x32, f32 x33) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x58(r1) - stw r31, 0x54(r1) - mr r31, r3 - lfs f0, 0x60(r1) - lfs f9, 0x68(r1) - stfs f0, 0x8(r1) - lfs f0, 0x64(r1) - stfs f0, 0xC(r1) - lfs f0, 0x6C(r1) - stfs f9, 0x10(r1) - lfs f9, 0x70(r1) - stfs f0, 0x14(r1) - lfs f0, 0x74(r1) - stfs f9, 0x18(r1) - stfs f0, 0x1C(r1) - lfs f0, 0x78(r1) - stfs f0, 0x20(r1) - lfs f0, 0x7C(r1) - stfs f0, 0x24(r1) - bl 0xAC - mr r3, r31 - lwz r0, 0x5C(r1) - lwz r31, 0x54(r1) - addi r1, r1, 0x58 - mtlr r0 - blr - */ + set(x00, x01, x02, x03, x10, x11, x12, x13, x20, x21, x22, x23, x30, x31, x32, x33); } /* @@ -257,86 +140,35 @@ void NMatrix4f::output(Mtx) * Address: 8011BE08 * Size: 000090 */ -void NMatrix4f::input(Matrix4f&) -{ - /* - .loc_0x0: - lfs f0, 0x0(r4) - addi r5, r4, 0x10 - addi r6, r3, 0x10 - stfs f0, 0x0(r3) - lfs f0, 0x4(r4) - stfs f0, 0x4(r3) - lfs f0, 0x8(r4) - stfs f0, 0x8(r3) - lfs f0, 0xC(r4) - stfs f0, 0xC(r3) - lfs f0, 0x10(r4) - stfs f0, 0x10(r3) - lfs f0, 0x14(r4) - stfs f0, 0x14(r3) - lfs f0, 0x18(r4) - stfs f0, 0x18(r3) - lfs f0, 0x1C(r4) - stfs f0, 0x1C(r3) - lfsu f0, 0x10(r5) - stfsu f0, 0x10(r6) - lfs f0, 0x4(r5) - stfs f0, 0x24(r3) - lfs f0, 0x8(r5) - stfs f0, 0x8(r6) - lfs f0, 0xC(r5) - stfs f0, 0xC(r6) - lfsu f0, 0x10(r5) - stfs f0, 0x10(r6) - lfs f0, 0x4(r5) - stfs f0, 0x14(r6) - addi r6, r6, 0x10 - lfs f0, 0x8(r5) - stfs f0, 0x8(r6) - lfs f0, 0xC(r5) - stfs f0, 0xC(r6) - blr - */ -} +void NMatrix4f::input(Matrix4f& mat) { NMathf::copyArray44(this->mMtx, mat.mMtx); } /* * --INFO-- * Address: 8011BE98 * Size: 00006C */ -void NMatrix4f::set(f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32) +void NMatrix4f::set(f32 x00, f32 x01, f32 x02, f32 x03, f32 x10, f32 x11, f32 x12, f32 x13, f32 x20, f32 x21, f32 x22, f32 x23, f32 x30, + f32 x31, f32 x32, f32 x33) { - /* - .loc_0x0: - stwu r1, -0x30(r1) - stfs f1, 0x0(r3) - lfs f11, 0x38(r1) - stfs f2, 0x4(r3) - lfs f10, 0x3C(r1) - stfs f3, 0x8(r3) - lfs f9, 0x40(r1) - stfs f4, 0xC(r3) - lfs f4, 0x44(r1) - stfs f5, 0x10(r3) - lfs f3, 0x48(r1) - stfs f6, 0x14(r3) - lfs f2, 0x4C(r1) - stfs f7, 0x18(r3) - lfs f1, 0x50(r1) - stfs f8, 0x1C(r3) - lfs f0, 0x54(r1) - stfs f11, 0x20(r3) - stfs f10, 0x24(r3) - stfs f9, 0x28(r3) - stfs f4, 0x2C(r3) - stfs f3, 0x30(r3) - stfs f2, 0x34(r3) - stfs f1, 0x38(r3) - stfs f0, 0x3C(r3) - addi r1, r1, 0x30 - blr - */ + mMtx[0][0] = x00; + mMtx[0][1] = x01; + mMtx[0][2] = x02; + mMtx[0][3] = x03; + + mMtx[1][0] = x10; + mMtx[1][1] = x11; + mMtx[1][2] = x12; + mMtx[1][3] = x13; + + mMtx[2][0] = x20; + mMtx[2][1] = x21; + mMtx[2][2] = x22; + mMtx[2][3] = x23; + + mMtx[3][0] = x30; + mMtx[3][1] = x31; + mMtx[3][2] = x32; + mMtx[3][3] = x33; } /* @@ -344,9 +176,11 @@ void NMatrix4f::set(f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, * Address: ........ * Size: 000018 */ -void NMatrix4f::setRow(int, f32, f32, f32) +void NMatrix4f::setRow(int row, f32 x, f32 y, f32 z) { - // UNUSED FUNCTION + mMtx[row][0] = x; + mMtx[row][1] = y; + mMtx[row][2] = z; } /* @@ -404,8 +238,11 @@ void NMatrix4f::setCol(int, f32, f32, f32) * Address: ........ * Size: 000024 */ -void NMatrix4f::inputCol(int, Vector3f&) +void NMatrix4f::inputCol(int col, Vector3f& input) { + mMtx[0][col] = input.x; + mMtx[1][col] = input.y; + mMtx[2][col] = input.z; // UNUSED FUNCTION } @@ -424,20 +261,11 @@ void NMatrix4f::inputCol(int, Vector3f&, f32) * Address: 8011BF04 * Size: 000024 */ -void NMatrix4f::outputCol(int, Vector3f&) +void NMatrix4f::outputCol(int col, Vector3f& output) { - /* - .loc_0x0: - rlwinm r0,r4,2,0,29 - lfsx f0, r3, r0 - add r3, r3, r0 - stfs f0, 0x0(r5) - lfs f0, 0x10(r3) - stfs f0, 0x4(r5) - lfs f0, 0x20(r3) - stfs f0, 0x8(r5) - blr - */ + output.x = mMtx[0][col]; + output.y = mMtx[1][col]; + output.z = mMtx[2][col]; } /* @@ -495,20 +323,10 @@ void NMatrix4f::transpose() * Address: 8011BF28 * Size: 000024 */ -void NMatrix4f::makeIdentRow(int) +void NMatrix4f::makeIdentRow(int row) { - /* - .loc_0x0: - lfs f0, -0x5FF0(r2) - rlwinm r0,r4,4,0,27 - add r4, r3, r0 - stfsx f0, r3, r0 - stfs f0, 0x4(r4) - stfs f0, 0x8(r4) - lfs f0, -0x5FEC(r2) - stfs f0, 0xC(r4) - blr - */ + setRow(row, 0.0f, 0.0f, 0.0f); + mMtx[row][3] = 1.0f; } /* @@ -536,75 +354,18 @@ NOrientation::NOrientation() * Address: 8011BF4C * Size: 000050 */ -NOrientation::NOrientation(Vector3f&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r4, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - bl 0xEEC - addi r3, r30, 0xC - bl 0xEE4 - addi r3, r30, 0 - addi r4, r31, 0 - bl .loc_0x50 - mr r3, r30 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - - .loc_0x50: - */ -} +NOrientation::NOrientation(Vector3f& p1) { construct(p1); } /* * --INFO-- * Address: 8011BF9C * Size: 000078 */ -void NOrientation::construct(Vector3f&) +void NOrientation::construct(Vector3f& p1) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - mr r31, r4 - stw r30, 0x20(r1) - mr r30, r3 - addi r3, r1, 0x10 - lfs f1, -0x5FF0(r2) - lfs f2, -0x5FEC(r2) - fmr f3, f1 - bl 0xF14 - lfs f0, 0x0(r31) - stfs f0, 0x0(r30) - lfs f0, 0x4(r31) - stfs f0, 0x4(r30) - lfs f0, 0x8(r31) - stfs f0, 0x8(r30) - lfs f0, 0x10(r1) - stfs f0, 0xC(r30) - lfs f0, 0x14(r1) - stfs f0, 0x10(r30) - lfs f0, 0x18(r1) - stfs f0, 0x14(r30) - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + NVector3f vert(0.0f, 1.0f, 0.0f); + _00.input(p1); + _0C.input(vert); } /* @@ -634,6 +395,18 @@ void NOrientation::construct(Vector3f&, Vector3f&) */ void NOrientation::normalize() { + if (_0C.isParallel(_00)) { + makeUp(); + } + + NVector3f left; + outputLeft(left); + + NTransform3D transform; + + transform.inputAxisAngle(NAxisAngle4f(left, NMathF::pi * 0.5f)); + _0C.input(_00); + transform.transform(_0C); /* .loc_0x0: mflr r0 @@ -916,25 +689,6 @@ void NOrientation::makeUp() */ } -/* - * --INFO-- - * Address: 8011C388 - * Size: 00001C - */ -void Vector3f::input(Vector3f&) -{ - /* - .loc_0x0: - lfs f0, 0x0(r4) - stfs f0, 0x0(r3) - lfs f0, 0x4(r4) - stfs f0, 0x4(r3) - lfs f0, 0x8(r4) - stfs f0, 0x8(r3) - blr - */ -} - /* * --INFO-- * Address: ........ @@ -990,27 +744,7 @@ void NOrientation::println() * Address: 8011C3A4 * Size: 00003C */ -NPolar3f::NPolar3f() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - lfs f2, -0x5FF0(r2) - lfs f1, -0x5FEC(r2) - fmr f3, f2 - bl 0x6C - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} +NPolar3f::NPolar3f() { set(1.0f, 0.0f, 0.0f); } /* * --INFO-- @@ -1057,61 +791,25 @@ void NPolar3f::construct(NPolar3f&) * Address: 8011C3E0 * Size: 000030 */ -NPolar3f::NPolar3f(Vector3f&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - bl .loc_0x30 - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - - .loc_0x30: - */ -} +NPolar3f::NPolar3f(Vector3f& point) { construct(point); } /* * --INFO-- * Address: 8011C410 * Size: 000020 */ -void NPolar3f::construct(Vector3f&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - bl 0x24 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void NPolar3f::construct(Vector3f& point) { input(point); } /* * --INFO-- * Address: 8011C430 * Size: 000010 */ -void NPolar3f::set(f32, f32, f32) +void NPolar3f::set(f32 p1, f32 p2, f32 p3) { - /* - .loc_0x0: - stfs f1, 0x0(r3) - stfs f2, 0x4(r3) - stfs f3, 0x8(r3) - blr - */ + _00 = p1; + _04 = p2; + _08 = p3; } /* @@ -1129,8 +827,9 @@ void NPolar3f::input(NPolar3f&) * Address: 8011C440 * Size: 0000A8 */ -void NPolar3f::input(Vector3f&) +void NPolar3f::input(Vector3f& point) { + set(point.length(), NMathF::atan2(point.length2D(), point.y), NMathF::atan2(point.x, point.z)); /* .loc_0x0: mflr r0 @@ -1356,48 +1055,12 @@ void NPosture2D::outputAxisAngle(NAxisAngle4f&) * Address: 8011C58C * Size: 000094 */ -void NPosture2D::readData(Stream&) +void NPosture2D::readData(Stream& input) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r4, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - addi r3, r31, 0 - lwz r12, 0x4(r31) - lwz r12, 0x14(r12) - mtlr r12 - blrl - stfs f1, 0x4(r30) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0x14(r12) - mtlr r12 - blrl - stfs f1, 0x8(r30) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0x14(r12) - mtlr r12 - blrl - stfs f1, 0xC(r30) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0x14(r12) - mtlr r12 - blrl - stfs f1, 0x10(r30) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + _04 = input.readFloat(); + _08 = input.readFloat(); + _0C = input.readFloat(); + _10 = input.readFloat(); } /* @@ -1417,49 +1080,10 @@ void NPosture2D::println() */ NPosture3D::NPosture3D() { - /* - .loc_0x0: - mflr r0 - lis r4, 0x802C - stw r0, 0x4(r1) - addi r0, r4, 0x4334 - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - addi r31, r3, 0 - stw r0, 0x0(r3) - addi r3, r31, 0x4 - bl 0x810 - addi r3, r31, 0x10 - bl 0x808 - lfs f1, -0x5FF0(r2) - addi r3, r1, 0x18 - fmr f2, f1 - fmr f3, f1 - bl 0x87C - lfs f0, 0x18(r1) - addi r3, r1, 0xC - stfs f0, 0x4(r31) - lfs f0, 0x1C(r1) - stfs f0, 0x8(r31) - lfs f0, 0x20(r1) - stfs f0, 0xC(r31) - lfs f1, -0x5FF0(r2) - lfs f3, -0x5FEC(r2) - fmr f2, f1 - bl 0x850 - lfs f0, 0xC(r1) - mr r3, r31 - stfs f0, 0x10(r31) - lfs f0, 0x10(r1) - stfs f0, 0x14(r31) - lfs f0, 0x14(r1) - stfs f0, 0x18(r31) - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + NVector3f vec1(0.0f, 0.0f, 0.0f); + _04.set(vec1); + NVector3f vec2(0.0f, 0.0f, 1.0f); + _10.set(vec2); } /* @@ -1487,66 +1111,17 @@ void NPosture3D::construct(NPosture3D&) * Address: 8011C6C0 * Size: 000070 */ -NPosture3D::NPosture3D(Vector3f&, Vector3f&) -{ - /* - .loc_0x0: - mflr r0 - lis r6, 0x802C - stw r0, 0x4(r1) - addi r0, r6, 0x4334 - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - addi r31, r5, 0 - stw r30, 0x20(r1) - addi r30, r4, 0 - stw r29, 0x1C(r1) - addi r29, r3, 0 - stw r0, 0x0(r3) - addi r3, r29, 0x4 - bl 0x760 - addi r3, r29, 0x10 - bl 0x758 - addi r3, r29, 0 - addi r4, r30, 0 - addi r5, r31, 0 - bl .loc_0x70 - mr r3, r29 - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - lwz r29, 0x1C(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - - .loc_0x70: - */ -} +NPosture3D::NPosture3D(Vector3f& p1, Vector3f& p2) { construct(p1, p2); } /* * --INFO-- * Address: 8011C730 * Size: 000034 */ -void NPosture3D::construct(Vector3f&, Vector3f&) +void NPosture3D::construct(Vector3f& p1, Vector3f& p2) { - /* - .loc_0x0: - lfs f0, 0x0(r4) - stfs f0, 0x4(r3) - lfs f0, 0x4(r4) - stfs f0, 0x8(r3) - lfs f0, 0x8(r4) - stfs f0, 0xC(r3) - lfs f0, 0x0(r5) - stfs f0, 0x10(r3) - lfs f0, 0x4(r5) - stfs f0, 0x14(r3) - lfs f0, 0x8(r5) - stfs f0, 0x18(r3) - blr - */ + _04.set(p1); + _10.set(p2); } /* @@ -1984,6 +1559,8 @@ void NUpperMatrix::println() */ LUMatrix::LUMatrix(f32*, f32*, f32*, int p4) : NSpecialMatrix(p4) + , _08(p4) + , _14(p4) { // UNUSED FUNCTION } @@ -2003,36 +1580,11 @@ void LUMatrix::construct(f32*, f32*, f32*, int) * Address: 8011C994 * Size: 000064 */ -void LUMatrix::setDimension(int) +void LUMatrix::setDimension(int dim) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r4, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - stw r31, 0x4(r3) - addi r3, r30, 0x8 - lwz r12, 0x8(r30) - lwz r12, 0x8(r12) - mtlr r12 - blrl - addi r3, r30, 0x14 - lwz r12, 0x14(r30) - mr r4, r31 - lwz r12, 0x8(r12) - mtlr r12 - blrl - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + mDimension = dim; + _08.setDimension(dim); + _14.setDimension(dim); } /* @@ -2040,11 +1592,7 @@ void LUMatrix::setDimension(int) * Address: 8011C9F8 * Size: 000008 */ -void NSpecialMatrix::setDimension(int a1) -{ - // Generated from stw r4, 0x4(r3) - // _04 = a1; -} +void NSpecialMatrix::setDimension(int dim) { mDimension = dim; } /* * --INFO-- @@ -2081,92 +1629,7 @@ void LUMatrix::println() * Address: 8011CA00 * Size: 000080 */ -NTransform3D::NTransform3D() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x78(r1) - stw r31, 0x74(r1) - addi r31, r3, 0 - addi r3, r1, 0x2C - lfs f2, -0x5FF0(r2) - stfs f2, 0x8(r1) - fmr f3, f2 - fmr f4, f2 - stfs f2, 0xC(r1) - fmr f5, f2 - fmr f7, f2 - lfs f1, -0x5FEC(r2) - fmr f8, f2 - stfs f1, 0x10(r1) - fmr f6, f1 - stfs f2, 0x14(r1) - stfs f2, 0x18(r1) - stfs f2, 0x1C(r1) - stfs f2, 0x20(r1) - stfs f1, 0x24(r1) - bl -0xBC0 - addi r3, r31, 0 - addi r4, r1, 0x2C - bl .loc_0x80 - mr r3, r31 - lwz r0, 0x7C(r1) - lwz r31, 0x74(r1) - addi r1, r1, 0x78 - mtlr r0 - blr - - .loc_0x80: - */ -} - -/* - * --INFO-- - * Address: 8011CA80 - * Size: 000088 - */ -void NMath::copyArray44(f32 (*)[4], f32 (*)[4]) -{ - /* - .loc_0x0: - lfs f0, 0x0(r4) - addi r6, r3, 0x10 - stfs f0, 0x0(r3) - lfs f0, 0x4(r4) - stfs f0, 0x4(r3) - lfs f0, 0x8(r4) - stfs f0, 0x8(r3) - lfs f0, 0xC(r4) - stfs f0, 0xC(r3) - lfs f0, 0x10(r4) - stfs f0, 0x10(r3) - lfs f0, 0x14(r4) - stfs f0, 0x14(r3) - lfs f0, 0x18(r4) - stfs f0, 0x18(r3) - lfs f0, 0x1C(r4) - stfs f0, 0x1C(r3) - lfs f0, 0x20(r4) - stfsu f0, 0x10(r6) - lfs f0, 0x24(r4) - stfs f0, 0x24(r3) - lfs f0, 0x28(r4) - stfs f0, 0x28(r3) - lfs f0, 0x2C(r4) - stfs f0, 0xC(r6) - lfs f0, 0x30(r4) - stfs f0, 0x10(r6) - lfs f0, 0x34(r4) - stfs f0, 0x14(r6) - lfs f0, 0x38(r4) - stfs f0, 0x18(r6) - lfs f0, 0x3C(r4) - stfs f0, 0x1C(r6) - blr - */ -} +NTransform3D::NTransform3D() { } /* * --INFO-- @@ -2507,13 +1970,8 @@ void NTransform3D::inputRotation(NAxisAngle4f&) */ NVector::NVector() { - /* - .loc_0x0: - li r0, 0 - stw r0, 0x0(r3) - stw r0, 0x4(r3) - blr - */ + mValues = nullptr; + mSize = 0; } /* @@ -2521,33 +1979,18 @@ NVector::NVector() * Address: ........ * Size: 000030 */ -NVector::NVector(f32*, int) -{ - // UNUSED FUNCTION -} +NVector::NVector(f32* values, int size) { construct(values, size); } /* * --INFO-- * Address: 8011CDD0 * Size: 000028 */ -void NVector::construct(f32*, int) +void NVector::construct(f32* values, int size) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - stw r4, 0x0(r3) - stw r5, 0x4(r3) - bl .loc_0x28 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - - .loc_0x28: - */ + mValues = values; + mSize = size; + makeZero(); } /* @@ -2557,25 +2000,9 @@ void NVector::construct(f32*, int) */ void NVector::makeZero() { - /* - .loc_0x0: - lfs f0, -0x5FF0(r2) - li r6, 0 - li r5, 0 - b .loc_0x20 - - .loc_0x10: - lwz r4, 0x0(r3) - addi r6, r6, 0x1 - stfsx f0, r4, r5 - addi r5, r5, 0x4 - - .loc_0x20: - lwz r0, 0x4(r3) - cmpw r6, r0 - blt+ .loc_0x10 - blr - */ + for (int i = 0; i < mSize; i++) { + mValues[i] = 0.0f; + } } /* @@ -2656,173 +2083,49 @@ void NVector3f::printlnVector3f(Vector3f&) * Address: 8011CE54 * Size: 00002C */ -NVector3f::NVector3f() -{ - /* - .loc_0x0: - lfs f0, -0x5FF0(r2) - stfs f0, 0x8(r3) - stfs f0, 0x4(r3) - stfs f0, 0x0(r3) - lfs f0, -0x1D38(r13) - stfs f0, 0x0(r3) - lfs f0, -0x1D34(r13) - stfs f0, 0x4(r3) - lfs f0, -0x1D30(r13) - stfs f0, 0x8(r3) - blr - */ -} +NVector3f::NVector3f() { set(0.0f, 0.0f, 0.0f); } /* * --INFO-- * Address: 8011CE80 * Size: 000040 */ -NVector3f::NVector3f(Vector3f&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - lfs f0, -0x5FF0(r2) - stfs f0, 0x8(r3) - stfs f0, 0x4(r31) - stfs f0, 0x0(r31) - bl .loc_0x40 - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - - .loc_0x40: - */ -} +NVector3f::NVector3f(Vector3f& vec) { construct(vec); } /* * --INFO-- * Address: 8011CEC0 * Size: 00001C */ -void NVector3f::construct(Vector3f&) -{ - /* - .loc_0x0: - lfs f0, 0x0(r4) - stfs f0, 0x0(r3) - lfs f0, 0x4(r4) - stfs f0, 0x4(r3) - lfs f0, 0x8(r4) - stfs f0, 0x8(r3) - blr - */ -} +void NVector3f::construct(Vector3f& vec) { input(vec); } /* * --INFO-- * Address: 8011CEDC * Size: 000040 */ -NVector3f::NVector3f(f32, f32, f32) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr r31, r3 - lfs f0, -0x5FF0(r2) - stfs f0, 0x8(r31) - stfs f0, 0x4(r31) - stfs f0, 0x0(r31) - bl .loc_0x40 - mr r3, r31 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - - .loc_0x40: - */ -} +NVector3f::NVector3f(f32 x, f32 y, f32 z) { construct(x, y, z); } /* * --INFO-- * Address: 8011CF1C * Size: 000010 */ -void NVector3f::construct(f32, f32, f32) -{ - /* - .loc_0x0: - stfs f1, 0x0(r3) - stfs f2, 0x4(r3) - stfs f3, 0x8(r3) - blr - */ -} +void NVector3f::construct(f32 x, f32 y, f32 z) { set(x, y, z); } /* * --INFO-- * Address: 8011CF2C * Size: 000040 */ -NVector3f::NVector3f(Vector3f&, Vector3f&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr r31, r3 - lfs f0, -0x5FF0(r2) - stfs f0, 0x8(r3) - stfs f0, 0x4(r31) - stfs f0, 0x0(r31) - bl .loc_0x40 - mr r3, r31 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - - .loc_0x40: - */ -} +NVector3f::NVector3f(Vector3f& start, Vector3f& end) { construct(start, end); } /* * --INFO-- * Address: 8011CF6C * Size: 000034 */ -void NVector3f::construct(Vector3f&, Vector3f&) -{ - /* - .loc_0x0: - lfs f1, 0x0(r5) - lfs f0, 0x0(r4) - lfs f3, 0x4(r5) - lfs f2, 0x4(r4) - fsubs f0, f1, f0 - lfs f4, 0x8(r5) - lfs f1, 0x8(r4) - fsubs f2, f3, f2 - stfs f0, 0x0(r3) - fsubs f0, f4, f1 - stfs f2, 0x4(r3) - stfs f0, 0x8(r3) - blr - */ -} +void NVector3f::construct(Vector3f& start, Vector3f& end) { set(end.x - start.x, end.y - start.y, end.z - start.z); } /* * --INFO-- @@ -2839,18 +2142,9 @@ void NVector3f::interpolate(Vector3f&, Vector3f&, f32) * Address: ........ * Size: 0000B4 */ -void NVector3f::isZero() -{ - // UNUSED FUNCTION -} - -/* - * --INFO-- - * Address: ........ - * Size: 000014 - */ -void NMath::absolute(f32) +bool NVector3f::isZero() { + return (NMathf::absolute(x) != 0.0f && NMathf::absolute(y) != 0.0f && NMathf::absolute(z) != 0.0f); // UNUSED FUNCTION } @@ -2879,48 +2173,9 @@ void NVector3f::isVertical(Vector3f&) * Address: 8011CFA0 * Size: 000074 */ -void NVector3f::isParallel(Vector3f&) +bool NVector3f::isParallel(Vector3f& vec) { - /* - .loc_0x0: - lfs f3, 0x0(r3) - lfs f2, 0x0(r4) - lfs f1, 0x4(r3) - lfs f0, 0x4(r4) - fmuls f2, f3, f2 - lfs f4, 0x8(r3) - fmuls f1, f1, f0 - lfs f3, 0x8(r4) - lfs f0, -0x5FF0(r2) - fmuls f3, f4, f3 - fadds f1, f2, f1 - fadds f2, f3, f1 - fcmpo cr0, f2, f0 - ble- .loc_0x3C - b .loc_0x40 - - .loc_0x3C: - fneg f2, f2 - - .loc_0x40: - lfs f1, -0x5FEC(r2) - lfs f0, -0x5FF0(r2) - fsubs f1, f2, f1 - fcmpo cr0, f1, f0 - ble- .loc_0x58 - b .loc_0x5C - - .loc_0x58: - fneg f1, f1 - - .loc_0x5C: - lfs f0, -0x1CB0(r13) - fcmpo cr0, f1, f0 - cror 2, 0, 0x2 - mfcr r0 - rlwinm r3,r0,3,31,31 - blr - */ + return NMathf::absolute(NMathf::absolute(x * vec.x + y * vec.y + z * vec.z) - 1.0f) <= NMathF::error; } /* @@ -2985,9 +2240,11 @@ void NVector3f::println() { } * Address: ........ * Size: 000028 */ -void NVector3f::normalizeByLength(f32) +void NVector3f::normalizeByLength(f32 length) { - // UNUSED FUNCTION + x /= length; + y /= length; + z /= length; } /* @@ -2995,79 +2252,15 @@ void NVector3f::normalizeByLength(f32) * Address: 8011D018 * Size: 0000E8 */ -void NVector3f::normalizeCheck() +bool NVector3f::normalizeCheck() { - /* - .loc_0x0: - stwu r1, -0x18(r1) - lfs f1, 0x0(r3) - lfs f0, 0x4(r3) - fmuls f2, f1, f1 - lfs f3, 0x8(r3) - fmuls f1, f0, f0 - lfs f0, -0x5FF0(r2) - fmuls f3, f3, f3 - fadds f1, f2, f1 - fadds f4, f3, f1 - fcmpo cr0, f4, f0 - ble- .loc_0x88 - fsqrte f1, f4 - lfd f3, -0x5FE0(r2) - lfd f2, -0x5FD8(r2) - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f1, f1, f0 - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f1, f1, f0 - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f0, f1, f0 - fmul f0, f4, f0 - frsp f0, f0 - stfs f0, 0x10(r1) - lfs f4, 0x10(r1) - - .loc_0x88: - lfs f0, -0x5FF0(r2) - fcmpo cr0, f4, f0 - ble- .loc_0x9C - fmr f1, f4 - b .loc_0xA0 - - .loc_0x9C: - fneg f1, f4 - - .loc_0xA0: - lfs f0, -0x1CB0(r13) - fcmpo cr0, f1, f0 - cror 2, 0, 0x2 - bne- .loc_0xB8 - li r3, 0 - b .loc_0xE0 + f32 len = length(); + if (NMathf::absolute(len) <= NMathF::error) { + return false; + } - .loc_0xB8: - lfs f0, 0x0(r3) - fdivs f0, f0, f4 - stfs f0, 0x0(r3) - lfs f0, 0x4(r3) - fdivs f0, f0, f4 - stfs f0, 0x4(r3) - lfs f0, 0x8(r3) - fdivs f0, f0, f4 - stfs f0, 0x8(r3) - li r3, 0x1 - - .loc_0xE0: - addi r1, r1, 0x18 - blr - */ + normalizeByLength(len); + return true; } /* @@ -3077,72 +2270,13 @@ void NVector3f::normalizeCheck() */ void NVector3f::normalize() { - /* - .loc_0x0: - stwu r1, -0x20(r1) - lfs f1, 0x0(r3) - lfs f0, 0x4(r3) - fmuls f2, f1, f1 - lfs f3, 0x8(r3) - fmuls f1, f0, f0 - lfs f0, -0x5FF0(r2) - fmuls f3, f3, f3 - fadds f1, f2, f1 - fadds f4, f3, f1 - fcmpo cr0, f4, f0 - ble- .loc_0x88 - fsqrte f1, f4 - lfd f3, -0x5FE0(r2) - lfd f2, -0x5FD8(r2) - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f1, f1, f0 - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f1, f1, f0 - fmul f0, f1, f1 - fmul f1, f3, f1 - fmul f0, f4, f0 - fsub f0, f2, f0 - fmul f0, f1, f0 - fmul f0, f4, f0 - frsp f0, f0 - stfs f0, 0x10(r1) - lfs f4, 0x10(r1) - - .loc_0x88: - lfs f0, -0x5FF0(r2) - fcmpo cr0, f4, f0 - ble- .loc_0x9C - fmr f1, f4 - b .loc_0xA0 - - .loc_0x9C: - fneg f1, f4 + u32 badCompiler; // idek man. + f32 len = length(); + if (NMathf::absolute(len) <= NMathF::error) { + return; + } - .loc_0xA0: - lfs f0, -0x1CB0(r13) - fcmpo cr0, f1, f0 - cror 2, 0, 0x2 - beq- .loc_0xD4 - lfs f0, 0x0(r3) - fdivs f0, f0, f4 - stfs f0, 0x0(r3) - lfs f0, 0x4(r3) - fdivs f0, f0, f4 - stfs f0, 0x4(r3) - lfs f0, 0x8(r3) - fdivs f0, f0, f4 - stfs f0, 0x8(r3) - - .loc_0xD4: - addi r1, r1, 0x20 - blr - */ + normalizeByLength(len); } /* @@ -3200,23 +2334,41 @@ NAlpha::NAlpha() * Address: 8011D1DC * Size: 00000C */ -void NAlpha::reset() -{ - /* - .loc_0x0: - lfs f0, 0x8(r3) - stfs f0, 0x4(r3) - blr - */ -} +void NAlpha::reset() { _04 = _08; } /* * --INFO-- * Address: 8011D1E8 * Size: 000198 */ -f32 NAlpha::getValue(f32) -{ +f32 NAlpha::getValue(f32 p1) +{ + if (NMathf::absolute(_0C) <= NMathF::error) { + _0C = 1.0f; + } + + f32 val = (p1 - _08) / _0C; + + switch (_10) { + case 0: + return val; + case 1: + return sinf(NMathF::pi + val * (NMathF::pi / 2)) - 1.0f; + case 2: + return sinf(val * (NMathF::pi / 2)); + case 3: + if (val < 0.5f) { + return 0.5f * (1.0f - sinf((NMathF::pi / 2) + (2.0f * val) * (NMathF::pi / 2))); + } + return 0.5f + (0.5f * sinf((2.0f * (val - 0.5f)) * (NMathF::pi / 2))); + case 4: + if (val < 0.5f) { + return (0.5f * sinf((2.0f * val) * (NMathF::pi / 2))); + } + return 0.5f + 0.5f * (1.0f - sinf((NMathF::pi / 2) + (2.0f * (val - 0.5f)) * (NMathF::pi / 2))); + default: + return val; + } /* .loc_0x0: mflr r0 @@ -3351,40 +2503,9 @@ f32 NAlpha::getValue(f32) * Address: 8011D380 * Size: 00007C */ -void NAlpha::readData(Stream&) +void NAlpha::readData(Stream& input) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r4, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - addi r3, r31, 0 - lwz r12, 0x4(r31) - lwz r12, 0x14(r12) - mtlr r12 - blrl - stfs f1, 0x8(r30) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0x14(r12) - mtlr r12 - blrl - stfs f1, 0xC(r30) - mr r3, r31 - lwz r12, 0x4(r31) - lwz r12, 0xC(r12) - mtlr r12 - blrl - stb r3, 0x10(r30) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + _08 = input.readFloat(); + _0C = input.readFloat(); + _10 = input.readByte(); } diff --git a/src/plugPikiNakata/nlibgraphics.cpp b/src/plugPikiNakata/nlibgraphics.cpp index 1e661e7d..382e5d61 100644 --- a/src/plugPikiNakata/nlibgraphics.cpp +++ b/src/plugPikiNakata/nlibgraphics.cpp @@ -1,4 +1,6 @@ #include "nlib/Graphics.h" +#include "nlib/Math.h" +#include "Camera.h" /* * --INFO-- @@ -25,44 +27,12 @@ static void _Print(char*, ...) * Address: 8011D95C * Size: 000084 */ -NCamera::NCamera(Camera*) +NCamera::NCamera(Camera* cam) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - addi r31, r4, 0 - stw r30, 0x10(r1) - addi r30, r3, 0 - addi r3, r30, 0x8 - bl -0xB28 - addi r3, r30, 0x14 - bl -0xB30 - stw r31, 0x4(r30) - mr r3, r30 - lfs f0, -0x1CC8(r13) - stfs f0, 0x8(r30) - lfs f0, -0x1CC4(r13) - stfs f0, 0xC(r30) - lfs f0, -0x1CC0(r13) - stfs f0, 0x10(r30) - lfs f0, -0x1CBC(r13) - stfs f0, 0x14(r30) - lfs f0, -0x1CB8(r13) - stfs f0, 0x18(r30) - lfs f0, -0x1CB4(r13) - stfs f0, 0x1C(r30) - lfs f0, -0x5FC8(r2) - stfs f0, 0x0(r30) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + mCamera = cam; + _08.set(0.0f, 0.0f, 0.0f); + _14.set(0.0f, 0.0f, 1.0f); + _00 = 0.0f; } /* @@ -72,6 +42,22 @@ NCamera::NCamera(Camera*) */ void NCamera::makeMatrix() { + NVector3f& v3 = _14; + NVector3f& v2 = _08; + NVector3f vec(v2, v3); + vec.normalize(); + + NOrientation orient(vec); + orient.normalize(); + + NVector3f v1(orient._0C); + + NAxisAngle4f angle(vec, _00); + NTransform3D transform; + transform.inputAxisAngle(angle); + transform.transform(v1); + v1.normalize(); + mCamera->calcLookAt(v2, v3, &v1); /* .loc_0x0: mflr r0 @@ -136,45 +122,10 @@ void NCamera::makeMatrix() */ void NCamera::makeCamera() { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - mr r31, r3 - addi r4, r31, 0x14 - lwz r5, 0x4(r3) - addi r3, r1, 0x18 - lfs f0, 0x8(r31) - addi r6, r5, 0x164 - stfs f0, 0x164(r5) - addi r5, r31, 0x8 - lfs f0, 0xC(r31) - stfs f0, 0x4(r6) - lfs f0, 0x10(r31) - stfs f0, 0x8(r6) - bl -0xBC4 - addi r3, r1, 0xC - addi r4, r1, 0x18 - bl -0x171C - lfs f1, -0x1CA4(r13) - lfs f0, -0x5FC4(r2) - lfs f2, 0x10(r1) - fmuls f0, f1, f0 - lwz r3, 0x4(r31) - fsubs f0, f2, f0 - stfs f0, 0x320(r3) - lfs f0, 0x14(r1) - lwz r3, 0x4(r31) - stfs f0, 0x324(r3) - lfs f0, -0x5FC8(r2) - lwz r3, 0x4(r31) - stfs f0, 0x328(r3) - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + mCamera->_164.set(_08); + NVector3f vec(_14, _08); + NPolar3f polar(vec); + mCamera->_320.x = polar._04 - NMathF::pi / 2; + mCamera->_320.y = polar._08; + mCamera->_320.z = 0.0f; } diff --git a/src/plugPikiNakata/panianimator.cpp b/src/plugPikiNakata/panianimator.cpp index f0a922ff..9bd278d0 100644 --- a/src/plugPikiNakata/panianimator.cpp +++ b/src/plugPikiNakata/panianimator.cpp @@ -105,7 +105,7 @@ PaniMotionTable::PaniMotionTable(int count) PaniSoundTable::PaniSoundTable(int count) { mSoundCount = count; - mSounds = new u32*[mSoundCount]; + mSounds = new PaniSound*[mSoundCount]; for (int i = 0; i < mSoundCount; i++) { mSounds[i] = 0; diff --git a/src/plugPikiNakata/panitekianimator.cpp b/src/plugPikiNakata/panitekianimator.cpp index f1f6cc51..28b4e1be 100644 --- a/src/plugPikiNakata/panitekianimator.cpp +++ b/src/plugPikiNakata/panitekianimator.cpp @@ -1,14 +1,13 @@ #include "PaniAnimator.h" +#include "sysNew.h" +#include "Dolphin/os.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) -{ - // UNUSED FUNCTION -} +static void _Error(char* fmt, ...) { OSPanic(__FILE__, __LINE__, fmt, "panitekianimator"); } /* * --INFO-- @@ -20,6 +19,24 @@ static void _Print(char*, ...) // UNUSED FUNCTION } +char* PaniTekiAnimator::motionLabels[15] = { + "DEAD", // 0 + "DAMAGE", // 1 + "WAIT_1", // 2 + "WAIT_2", // 3 + "WAITACTION_1", // 4 + "WAITACTION_2", // 5 + "MOVE_1", // 6 + "MOVE_2", // 7 + "ATTACK", // 8 + "FLICK", // 9 + "TYPE_1", // 10 + "TYPE_2", // 11 + "TYPE_3", // 12 + "TYPE_4", // 13 + "TYPE_5", // 14 +}; + /* * --INFO-- * Address: 8011FC54 @@ -27,195 +44,24 @@ static void _Print(char*, ...) */ PaniMotionTable* PaniTekiAnimator::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 -0xD8C68 - addi r31, r3, 0 - mr. r3, r31 - beq- .loc_0x30 - li r4, 0xF - bl -0xC78 - - .loc_0x30: - li r3, 0x8 - bl -0xD8C84 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x4C - li r4, 0 - bl -0xCD4 - - .loc_0x4C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x0(r4) - bl -0xD8CA8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x70 - li r4, 0x1 - bl -0xCF8 - - .loc_0x70: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x4(r4) - bl -0xD8CCC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x94 - li r4, 0x2 - bl -0xD1C - - .loc_0x94: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x8(r4) - bl -0xD8CF0 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xB8 - li r4, 0x3 - bl -0xD40 - - .loc_0xB8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0xC(r4) - bl -0xD8D14 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0xDC - li r4, 0x4 - bl -0xD64 - - .loc_0xDC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x10(r4) - bl -0xD8D38 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x100 - li r4, 0x5 - bl -0xD88 - - .loc_0x100: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x14(r4) - bl -0xD8D5C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x124 - li r4, 0x6 - bl -0xDAC - - .loc_0x124: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x18(r4) - bl -0xD8D80 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x148 - li r4, 0x7 - bl -0xDD0 - - .loc_0x148: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x1C(r4) - bl -0xD8DA4 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x16C - li r4, 0x8 - bl -0xDF4 - - .loc_0x16C: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x20(r4) - bl -0xD8DC8 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x190 - li r4, 0x9 - bl -0xE18 - - .loc_0x190: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x24(r4) - bl -0xD8DEC - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x1B4 - li r4, 0xA - bl -0xE3C - - .loc_0x1B4: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x28(r4) - bl -0xD8E10 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x1D8 - li r4, 0xB - bl -0xE60 - - .loc_0x1D8: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x2C(r4) - bl -0xD8E34 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x1FC - li r4, 0xC - bl -0xE84 - - .loc_0x1FC: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x30(r4) - bl -0xD8E58 - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x220 - li r4, 0xD - bl -0xEA8 - - .loc_0x220: - lwz r4, 0x4(r31) - li r3, 0x8 - stw r30, 0x34(r4) - bl -0xD8E7C - addi r30, r3, 0 - mr. r3, r30 - beq- .loc_0x244 - li r4, 0xE - bl -0xECC - - .loc_0x244: - lwz r4, 0x4(r31) - mr r3, r31 - stw r30, 0x38(r4) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + PaniMotionTable* table = new PaniMotionTable(15); + 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); + table->mMotions[7] = new PaniMotion(7); + table->mMotions[8] = new PaniMotion(8); + table->mMotions[9] = new PaniMotion(9); + table->mMotions[10] = new PaniMotion(10); + table->mMotions[11] = new PaniMotion(11); + table->mMotions[12] = new PaniMotion(12); + table->mMotions[13] = new PaniMotion(13); + table->mMotions[14] = new PaniMotion(14); + + return table; } /* @@ -223,24 +69,4 @@ PaniMotionTable* PaniTekiAnimator::createMotionTable() * Address: 8011FEBC * Size: 00003C */ -PaniTekiAnimator::PaniTekiAnimator() -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r3 - bl -0xDF0 - lis r3, 0x802C - addi r0, r3, 0x4E28 - stw r0, 0x30(r31) - mr r3, r31 - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ -} +PaniTekiAnimator::PaniTekiAnimator() { } diff --git a/src/plugPikiNakata/panitestsection.cpp b/src/plugPikiNakata/panitestsection.cpp index 8e2caef1..2956879d 100644 --- a/src/plugPikiNakata/panitestsection.cpp +++ b/src/plugPikiNakata/panitestsection.cpp @@ -17,6 +17,7 @@ #include "teki.h" #include "Collision.h" #include "Font.h" +#include "TekiPersonality.h" #include "Pcam/CameraManager.h" #include "Pcam/Camera.h" @@ -101,7 +102,7 @@ PaniTestNode::PaniTestNode() for (int i = 0; i < TEKI_TypeCount; i++) { if (tekiMgr->mTekiParams[i]) { _668[i] = tekiMgr->newTeki(i); - _668[i]->_2C8; // need to set some vectors(?) here, idk what it is though + _668[i]->mPersonality->init(); _668[i]->reset(); } else { _668[i] = nullptr; diff --git a/src/plugPikiNakata/pcamcamera.cpp b/src/plugPikiNakata/pcamcamera.cpp index 716babc4..4d8fd1d3 100644 --- a/src/plugPikiNakata/pcamcamera.cpp +++ b/src/plugPikiNakata/pcamcamera.cpp @@ -744,22 +744,6 @@ void PcamCamera::parameterUpdated() */ } -/* - * --INFO-- - * Address: 801224D4 - * Size: 000010 - */ -f32 ParaParameters::get(int) -{ - /* - .loc_0x0: - lwz r3, 0x0(r3) - rlwinm r0,r4,2,0,29 - lfsx f1, r3, r0 - blr - */ -} - /* * --INFO-- * Address: 801224E4 @@ -1879,23 +1863,6 @@ void PcamCamera::getCurrentAngle() */ } -/* - * --INFO-- - * Address: 80123210 - * Size: 000014 - */ -void ParaMultiParameters::getF(int) -{ - /* - .loc_0x0: - lwz r3, 0x4(r3) - rlwinm r0,r4,2,0,29 - lwz r3, 0x0(r3) - lfsx f1, r3, r0 - blr - */ -} - /* * --INFO-- * Address: 80123224 diff --git a/src/plugPikiNakata/tai.cpp b/src/plugPikiNakata/tai.cpp index 44238a83..8e3f0bc0 100644 --- a/src/plugPikiNakata/tai.cpp +++ b/src/plugPikiNakata/tai.cpp @@ -53,47 +53,9 @@ void TaiSerialAction::start(Teki& teki) void TaiSerialAction::finish(Teki& teki) { for (int i = 0; i < mCount; i++) { - mActionQueue[i]->finish(teki); + TaiAction* action = mActionQueue[i]; + action->finish(teki); } - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - li r31, 0 - stw r30, 0x18(r1) - li r30, 0 - stw r29, 0x14(r1) - addi r29, r4, 0 - stw r28, 0x10(r1) - addi r28, r3, 0 - b .loc_0x54 - - .loc_0x30: - lwz r3, 0xC(r28) - mr r4, r29 - lwzx r3, r3, r31 - lwz r12, 0x4(r3) - lwz r12, 0xC(r12) - mtlr r12 - blrl - addi r31, r31, 0x4 - addi r30, r30, 0x1 - - .loc_0x54: - lwz r0, 0x8(r28) - cmpw r30, r0 - blt+ .loc_0x30 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - lwz r28, 0x10(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ } /* @@ -152,47 +114,9 @@ TaiState::TaiState(int count) void TaiState::start(Teki& teki) { for (int i = 0; i < mCount; i++) { - mActions[i]->start(teki); + TaiAction* action = mActions[i]; + action->start(teki); } - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - li r31, 0 - stw r30, 0x18(r1) - li r30, 0 - stw r29, 0x14(r1) - addi r29, r4, 0 - stw r28, 0x10(r1) - addi r28, r3, 0 - b .loc_0x54 - - .loc_0x30: - lwz r3, 0x8(r28) - mr r4, r29 - lwzx r3, r3, r31 - lwz r12, 0x4(r3) - lwz r12, 0x8(r12) - mtlr r12 - blrl - addi r31, r31, 0x4 - addi r30, r30, 0x1 - - .loc_0x54: - lwz r0, 0x4(r28) - cmpw r30, r0 - blt+ .loc_0x30 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - lwz r28, 0x10(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ } /* @@ -203,47 +127,9 @@ void TaiState::start(Teki& teki) void TaiState::finish(Teki& teki) { for (int i = 0; i < mCount; i++) { - mActions[i]->finish(teki); + TaiAction* action = mActions[i]; + action->finish(teki); } - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - li r31, 0 - stw r30, 0x18(r1) - li r30, 0 - stw r29, 0x14(r1) - addi r29, r4, 0 - stw r28, 0x10(r1) - addi r28, r3, 0 - b .loc_0x54 - - .loc_0x30: - lwz r3, 0x8(r28) - mr r4, r29 - lwzx r3, r3, r31 - lwz r12, 0x4(r3) - lwz r12, 0xC(r12) - mtlr r12 - blrl - addi r31, r31, 0x4 - addi r30, r30, 0x1 - - .loc_0x54: - lwz r0, 0x4(r28) - cmpw r30, r0 - blt+ .loc_0x30 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - lwz r28, 0x10(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ } /* @@ -253,11 +139,18 @@ void TaiState::finish(Teki& teki) */ bool TaiState::act(Teki& teki) { + // this assembly is so weird. does this have a custom iterator?? for (int i = 0; i < mCount; i++) { TaiAction* action = mActions[i]; if (action->act(teki) && action->hasNextState()) { - // something teki-related here - teki._334 = 0; + int& val = teki._324; + int startVal = teki._324; + if (action->mNextState == -2) { + val = teki._330; + } else { + val = action->mNextState; + } + teki._330 = startVal; return true; } } @@ -349,8 +242,14 @@ bool TaiState::eventPerformed(TekiEvent& event) for (int i = 0; i < mCount; i++) { TaiAction* action = mActions[i]; if (action->actByEvent(event) && action->hasNextState()) { - // some teki-related thing - event.mTeki->_334 = 0; + int& val = event.mTeki->_324; + int startVal = event.mTeki->_324; + if (action->mNextState == -2) { + val = event.mTeki->_330; + } else { + val = action->mNextState; + } + event.mTeki->_330 = startVal; return true; } } diff --git a/src/plugPikiNakata/taiattackactions.cpp b/src/plugPikiNakata/taiattackactions.cpp index 0254f55e..ad991c99 100644 --- a/src/plugPikiNakata/taiattackactions.cpp +++ b/src/plugPikiNakata/taiattackactions.cpp @@ -3,6 +3,8 @@ #include "TekiPersonality.h" #include "TekiParameters.h" #include "TekiConditions.h" +#include "NaviMgr.h" +#include "PikiMgr.h" #include "Dolphin/os.h" /* @@ -54,52 +56,16 @@ bool TaiAttackableNaviPikiAction::act(Teki& teki) */ bool TaiAttackableNaviAction::act(Teki& teki) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - stw r30, 0x10(r1) - mr r30, r4 - lwz r3, 0x3120(r13) - bl -0x10308 - addi r31, r3, 0 - addi r3, r30, 0 - addi r4, r31, 0 - bl 0x1FA70 - rlwinm. r0,r3,0,24,31 - beq- .loc_0x70 - lwz r3, 0x418(r30) - cmplwi r3, 0 - beq- .loc_0x54 - beq- .loc_0x54 - bl -0x4338C - li r0, 0 - stw r0, 0x418(r30) - - .loc_0x54: - stw r31, 0x418(r30) - lwz r3, 0x418(r30) - cmplwi r3, 0 - beq- .loc_0x68 - bl -0x433B8 - - .loc_0x68: - li r3, 0x1 - b .loc_0x74 - - .loc_0x70: - li r3, 0 - - .loc_0x74: - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - lwz r30, 0x10(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + Navi* navi = naviMgr->getNavi(); + if (teki.attackableCreature(*navi)) { + if (teki._418) { + resetCreature(teki._418); + } + teki._418 = navi; + postSetCreature(teki._418); + return true; + } + return false; } /* @@ -107,65 +73,23 @@ bool TaiAttackableNaviAction::act(Teki& teki) * Address: 8012773C * Size: 0000B8 */ -bool TaiAttackablePikiAction::act(Teki&) +bool TaiAttackablePikiAction::act(Teki& teki) { - /* - .loc_0x0: - mflr r0 - lis r5, 0x802B - stw r0, 0x4(r1) - subi r0, r5, 0xF68 - lis r5, 0x802C - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - stw r30, 0x20(r1) - addi r30, r4, 0 - addi r4, r30, 0x94 - stw r0, 0x18(r1) - addi r0, r5, 0x6964 - lis r5, 0x802D - lwz r3, 0x3068(r13) - stw r0, 0x18(r1) - subi r0, r5, 0x2ABC - stw r0, 0x18(r1) - addi r5, r1, 0x18 - stw r30, 0x1C(r1) - lwz r12, 0x0(r3) - lwz r12, 0x6C(r12) - mtlr r12 - blrl - mr. r31, r3 - bne- .loc_0x6C - li r3, 0 - b .loc_0xA0 - - .loc_0x6C: - lwz r3, 0x418(r30) - cmplwi r3, 0 - beq- .loc_0x88 - beq- .loc_0x88 - bl -0x4344C - li r0, 0 - stw r0, 0x418(r30) - - .loc_0x88: - stw r31, 0x418(r30) - lwz r3, 0x418(r30) - cmplwi r3, 0 - beq- .loc_0x9C - bl -0x43478 - - .loc_0x9C: - li r3, 0x1 + TekiAttackableCondition cond(&teki); + Creature* nearest = pikiMgr->findClosest(teki.mPosition, &cond); + if (!nearest) { + return false; + } - .loc_0xA0: - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ + if (teki._418) { + resetCreature(teki._418); + } + teki._418 = nearest; + postSetCreature(teki._418); + // sigh + u32 badCompiler; + u32 badCompiler2; + return true; } /* @@ -173,45 +97,11 @@ bool TaiAttackablePikiAction::act(Teki&) * Address: 801277F4 * Size: 000040 */ -void TaiAnimationSwallowingAction::start(Teki&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r0, 0x418(r4) - cmplwi r0, 0 - beq- .loc_0x30 - mr r3, r4 - lwz r4, -0x9B4(r13) - lwz r12, 0x0(r3) - lwz r12, 0x1CC(r12) - mtlr r12 - blrl - - .loc_0x30: - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} - -/* - * --INFO-- - * Address: 80127834 - * Size: 000010 - */ -void BTeki::setTekiOption(int) +void TaiAnimationSwallowingAction::start(Teki& teki) { - /* - .loc_0x0: - lwz r0, 0x410(r3) - or r0, r0, r4 - stw r0, 0x410(r3) - blr - */ + if (teki._418) { + teki.setTekiOption(BTeki::TEKI_OPTION_INVINCIBLE); + } } /* @@ -219,8 +109,14 @@ void BTeki::setTekiOption(int) * Address: 80127844 * Size: 000660 */ -bool TaiAnimationSwallowingAction::act(Teki&) +bool TaiAnimationSwallowingAction::act(Teki& teki) { + if (teki.isAnimKeyOption(BTeki::ANIMATION_KEY_OPTION_ACTION_0)) { + teki.flickUpper(); + Vector3f center; + teki.outputHitCenter(center); + TekiPikiStateCondition cond; + } /* .loc_0x0: mflr r0 @@ -697,34 +593,7 @@ bool TaiAnimationSwallowingAction::act(Teki&) * Address: 80127EA4 * Size: 000010 */ -void BTeki::clearTekiOption(int) -{ - /* - .loc_0x0: - lwz r0, 0x410(r3) - andc r0, r0, r4 - stw r0, 0x410(r3) - blr - */ -} - -/* - * --INFO-- - * Address: 80127EB4 - * Size: 000018 - */ -void TekiPersonality::getF(int) -{ - /* - .loc_0x0: - lwz r3, 0x34(r3) - rlwinm r0,r4,2,0,29 - lwz r3, 0x4(r3) - lwz r3, 0x0(r3) - lfsx f1, r3, r0 - blr - */ -} +void BTeki::clearTekiOption(int opt) { mTekiOptions &= ~opt; } /* * --INFO-- @@ -749,7 +618,7 @@ void TekiParameters::getF(int) * Address: 80127EE4 * Size: 00012C */ -void TaiAnimationSwallowingAction::finish(Teki&) +void TaiAnimationSwallowingAction::finish(Teki& teki) { /* .loc_0x0: @@ -904,7 +773,7 @@ bool TaiBangingAction::actByEvent(TekiEvent&) * Address: 80128098 * Size: 0000D4 */ -bool TaiFlickAction::act(Teki&) +bool TaiFlickAction::act(Teki& teki) { /* .loc_0x0: @@ -969,7 +838,7 @@ bool TaiFlickAction::act(Teki&) * Address: 8012816C * Size: 000028 */ -bool TaiTargetStickAction::act(Teki&) +bool TaiTargetStickAction::act(Teki& teki) { /* .loc_0x0: @@ -993,7 +862,7 @@ bool TaiTargetStickAction::act(Teki&) * Address: 80128194 * Size: 000044 */ -void TaiFlickingAction::start(Teki&) +void TaiFlickingAction::start(Teki& teki) { /* .loc_0x0: @@ -1022,7 +891,7 @@ void TaiFlickingAction::start(Teki&) * Address: 801281D8 * Size: 000034 */ -void TaiFlickingAction::finish(Teki&) +void TaiFlickingAction::finish(Teki& teki) { /* .loc_0x0: @@ -1047,7 +916,7 @@ void TaiFlickingAction::finish(Teki&) * Address: 8012820C * Size: 00007C */ -bool TaiFlickingAction::act(Teki&) +bool TaiFlickingAction::act(Teki& teki) { /* .loc_0x0: @@ -1096,7 +965,7 @@ bool TaiFlickingAction::act(Teki&) * Address: 80128288 * Size: 000058 */ -bool TaiFlickingUpperAction::act(Teki&) +bool TaiFlickingUpperAction::act(Teki& teki) { /* .loc_0x0: diff --git a/src/plugPikiNakata/tekibteki.cpp b/src/plugPikiNakata/tekibteki.cpp index b14d50b6..8867e2a2 100644 --- a/src/plugPikiNakata/tekibteki.cpp +++ b/src/plugPikiNakata/tekibteki.cpp @@ -77,7 +77,7 @@ void BTeki::viewDoAnimation() { doAnimation(); } */ void BTeki::viewFinishMotion() { - _2CC->finishMotion(PaniMotionInfo(-1, this)); + mTekiAnimator->finishMotion(PaniMotionInfo(-1, this)); /* .loc_0x0: mflr r0 @@ -4196,7 +4196,7 @@ void BTeki::contactCreature(Creature&) * Address: 8014714C * Size: 0001B4 */ -void BTeki::attackableCreature(Creature&) +bool BTeki::attackableCreature(Creature&) { /* .loc_0x0: diff --git a/src/plugPikiNakata/tekiparameters.cpp b/src/plugPikiNakata/tekiparameters.cpp index 12ce01b2..fcf55dbe 100644 --- a/src/plugPikiNakata/tekiparameters.cpp +++ b/src/plugPikiNakata/tekiparameters.cpp @@ -1,4 +1,5 @@ #include "TekiParameters.h" +#include "sysNew.h" /* * --INFO-- @@ -25,8 +26,26 @@ static void _Print(char*, ...) * Address: 8014BD48 * Size: 000954 */ -TekiParameters::TekiParameters(int, int) +TekiParameters::TekiParameters(int iParamNum, int fParamNum) { + for (int i = 0; i < 8; i++) { + mParaIDs[i].setID('none'); + } + + ParaParameterInfoI* intParams = new ParaParameterInfoI[iParamNum]; + // set all these params somehow + + ParaParameterInfoF* f32Params = new ParaParameterInfoF[fParamNum]; + // set all these params somehow + + mParameters = new ParaMultiParameters(iParamNum, intParams, fParamNum, f32Params); + ParaMultiParameters* multiP = mParameters; + multiP->mIntParams->mParameters[3] = -1; + multiP->mFloatParams->mParameters[20] = 10.0f; + multiP->mFloatParams->mParameters[21] = 10.0f; + multiP->mFloatParams->mParameters[28] = 1000.0f; + multiP->mFloatParams->mParameters[44] = 16.0f; + /* .loc_0x0: mflr r0 @@ -638,8 +657,22 @@ TekiParameters::TekiParameters(int, int) * Address: 8014C69C * Size: 0003C4 */ -void TekiParameters::read(RandomAccessStream&) +void TekiParameters::read(RandomAccessStream& input) { + _20 = input.readInt(); + ParaMultiParameters* multiP = mParameters; + if (_20 <= 7) { + for (int i = 0; i < 8; i++) { + mParaIDs[i].read(input); + } + + input.readInt(); + input.readInt(); + + for (int i = 0; i < 16; i++) { + multiP->mIntParams->mParameters[i] = input.readInt(); + } + } /* .loc_0x0: mflr r0 diff --git a/src/plugPikiNakata/tekipersonality.cpp b/src/plugPikiNakata/tekipersonality.cpp index f1d6c2b3..81914b17 100644 --- a/src/plugPikiNakata/tekipersonality.cpp +++ b/src/plugPikiNakata/tekipersonality.cpp @@ -38,7 +38,11 @@ TekiPersonality::TekiPersonality() intParams[4].set("WATER_MAX_COUNT", -128, 127); ParaParameterInfoF* floatParams = new ParaParameterInfoF[i]; - // some setup of these params + floatParams[0].set("SIZE", 0.1f, 10.0f); + floatParams[1].set("STRENGTH", 0.0f, 100.0f); + floatParams[2].set("TERRITORY_RANGE", 0.0f, 10000.0f); + floatParams[3].set("PELLET_APPEARANCE_PROBABILITY", 0.0f, 1.0f); + floatParams[4].set("WATER_APPEARANCE_PROBABILITY", 0.0f, 1.0f); mParams = new ParaMultiParameters(5, intParams, 5, floatParams); reset(); diff --git a/src/plugPikiYamashita/TAIAmotion.cpp b/src/plugPikiYamashita/TAIAmotion.cpp index 0eda8813..3a60ea59 100644 --- a/src/plugPikiYamashita/TAIAmotion.cpp +++ b/src/plugPikiYamashita/TAIAmotion.cpp @@ -1,14 +1,14 @@ #include "TAI/Amotion.h" +#include "teki.h" +#include "system.h" +#include "Dolphin/os.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) -{ - // UNUSED FUNCTION -} +static void _Error(char* fmt, ...) { OSPanic(__FILE__, __LINE__, fmt, "TAIAmotion"); } /* * --INFO-- @@ -25,10 +25,10 @@ static void _Print(char*, ...) * Address: 801ACC54 * Size: 000024 */ -TAIAmotion::TAIAmotion(int nextState, int p2) +TAIAmotion::TAIAmotion(int nextState, int motionID) : TaiAction(nextState) { - _08 = p2; + mMotionID = motionID; } /* @@ -36,53 +36,20 @@ TAIAmotion::TAIAmotion(int nextState, int p2) * Address: 801ACC78 * Size: 00004C */ -void TAIAmotion::start(Teki&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr. r31, r4 - addi r5, r31, 0 - beq- .loc_0x20 - lwz r5, 0x2C0(r31) - - .loc_0x20: - lwz r4, 0x8(r3) - addi r3, r1, 0x10 - bl -0x8DD14 - mr r4, r3 - lwz r3, 0x2CC(r31) - bl -0x8DAEC - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ -} +void TAIAmotion::start(Teki& teki) { teki.mTekiAnimator->startMotion(PaniMotionInfo(mMotionID, &teki)); } /* * --INFO-- * Address: 801ACCC4 * Size: 00001C */ -bool TAIAmotion::act(Teki&) +bool TAIAmotion::act(Teki& teki) { - /* - .loc_0x0: - lwz r0, 0x3A8(r4) - cmpwi r0, 0 - bne- .loc_0x14 - li r3, 0x1 - blr + if (teki._3A8 == 0) { + return true; + } - .loc_0x14: - li r3, 0 - blr - */ + return false; } /* @@ -90,10 +57,10 @@ bool TAIAmotion::act(Teki&) * Address: 801ACCE0 * Size: 000024 */ -TAIAreserveMotion::TAIAreserveMotion(int nextState, int p2) +TAIAreserveMotion::TAIAreserveMotion(int nextState, int motionID) : TaiAction(nextState) { - _08 = p2; + mMotionID = motionID; } /* @@ -101,140 +68,32 @@ TAIAreserveMotion::TAIAreserveMotion(int nextState, int p2) * Address: 801ACD04 * Size: 0001B4 */ -void TAIAreserveMotion::start(Teki&) +void TAIAreserveMotion::start(Teki& teki) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x78(r1) - stfd f31, 0x70(r1) - stw r31, 0x6C(r1) - mr r31, r4 - stw r30, 0x68(r1) - mr r30, r3 - lwz r5, 0x2CC(r4) - lwz r4, 0x8(r3) - lwz r0, 0x44(r5) - cmpw r4, r0 - beq- .loc_0xF4 - cmpwi r0, 0 - bge- .loc_0x64 - cmplwi r31, 0 - addi r5, r31, 0 - beq- .loc_0x4C - lwz r5, 0x2C0(r31) - - .loc_0x4C: - addi r3, r1, 0x54 - bl -0x8DDC8 - mr r4, r3 - lwz r3, 0x2CC(r31) - bl -0x8DBA0 - b .loc_0x198 - - .loc_0x64: - lwz r3, 0x28(r5) - lis r0, 0x4330 - lfd f1, -0x49F0(r2) - lwz r3, 0x68(r3) - lfs f2, 0x2C(r5) - lwz r3, 0x30(r3) - subi r3, r3, 0x2 - xoris r3, r3, 0x8000 - stw r3, 0x64(r1) - stw r0, 0x60(r1) - lfd f0, 0x60(r1) - fsubs f0, f0, f1 - fcmpo cr0, f2, f0 - cror 2, 0x1, 0x2 - bne- .loc_0xC8 - cmplwi r31, 0 - addi r5, r31, 0 - beq- .loc_0xB0 - lwz r5, 0x2C0(r31) - - .loc_0xB0: - addi r3, r1, 0x4C - bl -0x8DE2C - mr r4, r3 - lwz r3, 0x2CC(r31) - bl -0x8DC04 - b .loc_0x198 - - .loc_0xC8: - cmplwi r31, 0 - addi r5, r31, 0 - beq- .loc_0xD8 - lwz r5, 0x2C0(r31) - - .loc_0xD8: - addi r3, r1, 0x44 - li r4, -0x1 - bl -0x8DE58 - mr r4, r3 - lwz r3, 0x2CC(r31) - bl -0x8DBC0 - b .loc_0x198 - - .loc_0xF4: - lwz r3, 0x28(r5) - lis r0, 0x4330 - lfd f1, -0x49F0(r2) - lwz r3, 0x68(r3) - lfs f2, 0x2C(r5) - lwz r3, 0x30(r3) - subi r3, r3, 0x2 - xoris r3, r3, 0x8000 - stw r3, 0x64(r1) - stw r0, 0x60(r1) - lfd f0, 0x60(r1) - fsubs f0, f0, f1 - fcmpo cr0, f2, f0 - cror 2, 0x1, 0x2 - bne- .loc_0x154 - cmplwi r31, 0 - addi r5, r31, 0 - beq- .loc_0x140 - lwz r5, 0x2C0(r31) - - .loc_0x140: - addi r3, r1, 0x3C - bl -0x8DEBC - mr r4, r3 - lwz r3, 0x2CC(r31) - bl -0x8DC94 - - .loc_0x154: - lwz r3, 0x2CC(r31) - lbz r0, 0x48(r3) - cmplwi r0, 0 - beq- .loc_0x198 - cmplwi r31, 0 - lfs f31, 0x2C(r3) - mr r5, r31 - beq- .loc_0x178 - lwz r5, 0x2C0(r31) - - .loc_0x178: - lwz r4, 0x8(r30) - addi r3, r1, 0x34 - bl -0x8DEF8 - mr r4, r3 - lwz r3, 0x2CC(r31) - bl -0x8DCD0 - lwz r3, 0x2CC(r31) - stfs f31, 0x2C(r3) - - .loc_0x198: - lwz r0, 0x7C(r1) - lfd f31, 0x70(r1) - lwz r31, 0x6C(r1) - lwz r30, 0x68(r1) - addi r1, r1, 0x78 - mtlr r0 - blr - */ + if (mMotionID != teki.mTekiAnimator->mMotionIdx) { + if (teki.mTekiAnimator->mMotionIdx < 0) { + teki.mTekiAnimator->startMotion(PaniMotionInfo(mMotionID, &teki)); + return; + } + + if (teki.mTekiAnimator->getCurrentFrame() >= f32(teki.mTekiAnimator->mAnimInfo->mData->mNumFrames - 2)) { + teki.mTekiAnimator->startMotion(PaniMotionInfo(mMotionID, &teki)); + return; + } + + teki.mTekiAnimator->finishMotion(PaniMotionInfo(-1, &teki)); + return; + } + + if (teki.mTekiAnimator->getCurrentFrame() >= f32(teki.mTekiAnimator->mAnimInfo->mData->mNumFrames - 2)) { + teki.mTekiAnimator->startMotion(PaniMotionInfo(mMotionID, &teki)); + } + + if (teki.mTekiAnimator->mIsFinished) { + f32 frame = teki.mTekiAnimator->getCurrentFrame(); + teki.mTekiAnimator->startMotion(PaniMotionInfo(mMotionID, &teki)); + teki.mTekiAnimator->setCurrentFrame(frame); + } } /* @@ -242,53 +101,18 @@ void TAIAreserveMotion::start(Teki&) * Address: 801ACEB8 * Size: 000088 */ -bool TAIAreserveMotion::act(Teki&) +bool TAIAreserveMotion::act(Teki& teki) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x30(r1) - stw r31, 0x2C(r1) - mr r31, r4 - lwz r4, 0x8(r3) - lwz r3, 0x2CC(r31) - lwz r0, 0x44(r3) - cmpw r4, r0 - beq- .loc_0x70 - lwz r0, 0x38(r3) - cmpwi r0, 0 - bge- .loc_0x68 - cmplwi r31, 0 - addi r5, r31, 0 - beq- .loc_0x44 - lwz r5, 0x2C0(r31) - - .loc_0x44: - addi r3, r1, 0x1C - bl -0x8DF74 - mr r4, r3 - lwz r3, 0x2CC(r31) - bl -0x8DD4C - li r0, 0x9 - stw r0, 0x3A8(r31) - li r3, 0x1 - b .loc_0x74 - - .loc_0x68: - li r3, 0 - b .loc_0x74 - - .loc_0x70: - li r3, 0x1 - - .loc_0x74: - lwz r0, 0x34(r1) - lwz r31, 0x2C(r1) - addi r1, r1, 0x30 - mtlr r0 - blr - */ + if (mMotionID != teki.mTekiAnimator->mMotionIdx) { + if (teki.mTekiAnimator->get38() < 0) { + teki.mTekiAnimator->startMotion(PaniMotionInfo(mMotionID, &teki)); + teki._3A8 = 9; + return true; + } + return false; + } + + return true; } /* @@ -296,24 +120,10 @@ bool TAIAreserveMotion::act(Teki&) * Address: 801ACF40 * Size: 000034 */ -void TAIAmotionLoop::start(Teki&) +void TAIAmotionLoop::start(Teki& teki) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x18(r1) - stw r31, 0x14(r1) - mr r31, r4 - bl -0x250 - lfs f0, -0x49E8(r2) - stfs f0, 0x478(r31) - lwz r0, 0x1C(r1) - lwz r31, 0x14(r1) - addi r1, r1, 0x18 - mtlr r0 - blr - */ + TAIAreserveMotion::start(teki); + teki._478 = 0.0f; } /* @@ -321,98 +131,15 @@ void TAIAmotionLoop::start(Teki&) * Address: 801ACF74 * Size: 000118 */ -bool TAIAmotionLoop::act(Teki&) +bool TAIAmotionLoop::act(Teki& teki) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x58(r1) - stfd f31, 0x50(r1) - stw r31, 0x4C(r1) - li r31, 0 - stw r30, 0x48(r1) - mr r30, r4 - stw r29, 0x44(r1) - mr r29, r3 - lwz r5, 0x2CC(r4) - lwz r4, 0x8(r3) - lwz r0, 0x44(r5) - cmpw r4, r0 - beq- .loc_0x84 - lwz r0, 0x38(r5) - cmpwi r0, 0 - bge- .loc_0x7C - cmplwi r30, 0 - addi r5, r30, 0 - beq- .loc_0x58 - lwz r5, 0x2C0(r30) - - .loc_0x58: - addi r3, r1, 0x2C - bl -0x8E044 - mr r4, r3 - lwz r3, 0x2CC(r30) - bl -0x8DE1C - li r0, 0x9 - stw r0, 0x3A8(r30) - li r0, 0x1 - b .loc_0x88 - - .loc_0x7C: - li r0, 0 - b .loc_0x88 - - .loc_0x84: - li r0, 0x1 - - .loc_0x88: - rlwinm. r0,r0,0,24,31 - beq- .loc_0xF4 - lwz r5, 0x2DEC(r13) - mr r3, r29 - lfs f1, 0x478(r30) - mr r4, r30 - lfs f0, 0x28C(r5) - fadds f0, f1, f0 - stfs f0, 0x478(r30) - lwz r12, 0x4(r29) - lfs f31, 0x478(r30) - lwz r12, 0x1C(r12) - mtlr r12 - blrl - fcmpo cr0, f31, f1 - ble- .loc_0xF4 - cmplwi r30, 0 - addi r5, r30, 0 - li r31, 0x1 - beq- .loc_0xDC - lwz r5, 0x2C0(r30) - - .loc_0xDC: - addi r3, r1, 0x34 - li r4, -0x1 - bl -0x8E0CC - mr r4, r3 - lwz r3, 0x2CC(r30) - bl -0x8DE34 - - .loc_0xF4: - mr r3, r31 - lwz r0, 0x5C(r1) - lfd f31, 0x50(r1) - lwz r31, 0x4C(r1) - lwz r30, 0x48(r1) - lwz r29, 0x44(r1) - addi r1, r1, 0x58 - mtlr r0 - blr - */ + bool res = false; + if (TAIAreserveMotion::act(teki)) { + teki.updateMotionLoopTimer(); + if (teki.getMotionLoopTimer() > getFrameMax(teki)) { + res = true; + teki.mTekiAnimator->finishMotion(PaniMotionInfo(-1, &teki)); + } + } + return res; } - -/* - * --INFO-- - * Address: 801AD08C - * Size: 000008 - */ -f32 TAIAmotionLoop::getFrameMax(Teki&) { return mFrameMax; } diff --git a/src/plugPikiYamashita/TAIAmove.cpp b/src/plugPikiYamashita/TAIAmove.cpp index e610f950..47b4e70b 100644 --- a/src/plugPikiYamashita/TAIAmove.cpp +++ b/src/plugPikiYamashita/TAIAmove.cpp @@ -1,12 +1,15 @@ #include "TAI/Amove.h" +#include "nlib/Math.h" +#include "Dolphin/os.h" /* * --INFO-- * Address: ........ * Size: 00009C */ -static void _Error(char*, ...) +static void _Error(char* fmt, ...) { + OSPanic(__FILE__, __LINE__, fmt, "TAIAmove"); // UNUSED FUNCTION } @@ -25,8 +28,14 @@ static void _Print(char*, ...) * Address: 801A8C2C * Size: 000094 */ -void TAIAappearKabekui::start(Teki&) +void TAIAappearKabekui::start(Teki& teki) { + TAIAmotion::start(teki); + teki.setMotionSpeed(mMotionSpeed); + teki.set4C8(0); + if (_10) { + teki.setVisible(); + } /* .loc_0x0: mflr r0 @@ -76,7 +85,7 @@ void TAIAappearKabekui::start(Teki&) * Address: 801A8CC0 * Size: 0001A4 */ -bool TAIAappearKabekui::act(Teki&) +bool TAIAappearKabekui::act(Teki& teki) { /* .loc_0x0: @@ -207,7 +216,7 @@ bool TAIAappearKabekui::act(Teki&) * Address: 801A8E64 * Size: 000140 */ -void TAIAsetTargetPointWorkObject::start(Teki&) +void TAIAsetTargetPointWorkObject::start(Teki& teki) { /* .loc_0x0: @@ -301,14 +310,14 @@ void TAIAsetTargetPointWorkObject::start(Teki&) * Address: 801A8FA4 * Size: 000008 */ -bool TAIAsetTargetPointWorkObject::act(Teki&) { return true; } +bool TAIAsetTargetPointWorkObject::act(Teki& teki) { return true; } /* * --INFO-- * Address: 801A8FAC * Size: 0001B0 */ -void TAIAgoGoalPath::makePath(Teki&) +void TAIAgoGoalPath::makePath(Teki& teki) { /* .loc_0x0: @@ -442,8 +451,11 @@ void TAIAgoGoalPath::makePath(Teki&) * Address: 801A915C * Size: 00004C */ -void TAIAgoGoalPath::start(Teki&) +void TAIAgoGoalPath::start(Teki& teki) { + teki._470 = 0; + makePath(teki); + TAIAgoTargetPriorityFaceDir::start(teki); /* .loc_0x0: mflr r0 @@ -473,7 +485,7 @@ void TAIAgoGoalPath::start(Teki&) * Address: 801A91A8 * Size: 000118 */ -bool TAIAgoGoalPath::act(Teki&) +bool TAIAgoGoalPath::act(Teki& teki) { /* .loc_0x0: @@ -565,7 +577,7 @@ bool TAIAgoGoalPath::act(Teki&) * Address: 801A92C0 * Size: 0000EC */ -bool TAIAgoGoalPath::checkArrival(Teki&) +bool TAIAgoGoalPath::checkArrival(Teki& teki) { /* .loc_0x0: @@ -640,7 +652,7 @@ bool TAIAgoGoalPath::checkArrival(Teki&) * Address: 801A93AC * Size: 000100 */ -void TAIAsetTargetPointCircleRandom::start(Teki&) +void TAIAsetTargetPointCircleRandom::start(Teki& teki) { /* .loc_0x0: @@ -716,14 +728,14 @@ void TAIAsetTargetPointCircleRandom::start(Teki&) * Address: 801A94AC * Size: 000008 */ -bool TAIAsetTargetPointCircleRandom::act(Teki&) { return true; } +bool TAIAsetTargetPointCircleRandom::act(Teki& teki) { return true; } /* * --INFO-- * Address: 801A94B4 * Size: 000020 */ -void TAIAsetTargetPointCircle::start(Teki&) +void TAIAsetTargetPointCircle::start(Teki& teki) { /* .loc_0x0: @@ -743,7 +755,7 @@ void TAIAsetTargetPointCircle::start(Teki&) * Address: 801A94D4 * Size: 000024 */ -bool TAIAsetTargetPointCircle::act(Teki&) +bool TAIAsetTargetPointCircle::act(Teki& teki) { /* .loc_0x0: @@ -766,7 +778,7 @@ bool TAIAsetTargetPointCircle::act(Teki&) * Address: 801A94F8 * Size: 000110 */ -void TAIAsetTargetPointCircle::setTargetPoint(Teki&) +void TAIAsetTargetPointCircle::setTargetPoint(Teki& teki) { /* .loc_0x0: @@ -846,7 +858,7 @@ void TAIAsetTargetPointCircle::setTargetPoint(Teki&) * Address: 801A9608 * Size: 000038 */ -void TAIAgoTarget::start(Teki&) +void TAIAgoTarget::start(Teki& teki) { /* .loc_0x0: @@ -872,7 +884,7 @@ void TAIAgoTarget::start(Teki&) * Address: 801A9640 * Size: 000108 */ -bool TAIAgoTarget::act(Teki&) +bool TAIAgoTarget::act(Teki& teki) { /* .loc_0x0: @@ -954,7 +966,7 @@ bool TAIAgoTarget::act(Teki&) * Address: 801A9748 * Size: 000018 */ -f32 TAIAgoTarget::getVelocity(Teki&) +f32 TAIAgoTarget::getVelocity(Teki& teki) { /* .loc_0x0: @@ -972,7 +984,7 @@ f32 TAIAgoTarget::getVelocity(Teki&) * Address: 801A9760 * Size: 000038 */ -void TAIAgoTargetPriorityFaceDir::start(Teki&) +void TAIAgoTargetPriorityFaceDir::start(Teki& teki) { /* .loc_0x0: @@ -998,7 +1010,7 @@ void TAIAgoTargetPriorityFaceDir::start(Teki&) * Address: 801A9798 * Size: 00009C */ -bool TAIAgoTargetPriorityFaceDir::act(Teki&) +bool TAIAgoTargetPriorityFaceDir::act(Teki& teki) { /* .loc_0x0: @@ -1053,7 +1065,7 @@ bool TAIAgoTargetPriorityFaceDir::act(Teki&) * Address: 801A9834 * Size: 0000B8 */ -bool TAIAgoTargetPriorityFaceDir::checkArrival(Teki&) +bool TAIAgoTargetPriorityFaceDir::checkArrival(Teki& teki) { /* .loc_0x0: @@ -1111,7 +1123,7 @@ bool TAIAgoTargetPriorityFaceDir::checkArrival(Teki&) * Address: 801A98EC * Size: 000018 */ -f32 TAIAgoTargetPriorityFaceDir::getWalkVelocity(Teki&) +f32 TAIAgoTargetPriorityFaceDir::getWalkVelocity(Teki& teki) { /* .loc_0x0: @@ -1129,7 +1141,7 @@ f32 TAIAgoTargetPriorityFaceDir::getWalkVelocity(Teki&) * Address: 801A9904 * Size: 000038 */ -void TAIAapproachTargetPriorityFaceDir::start(Teki&) +void TAIAapproachTargetPriorityFaceDir::start(Teki& teki) { /* .loc_0x0: @@ -1155,7 +1167,7 @@ void TAIAapproachTargetPriorityFaceDir::start(Teki&) * Address: 801A993C * Size: 000088 */ -bool TAIAapproachTargetPriorityFaceDir::act(Teki&) +bool TAIAapproachTargetPriorityFaceDir::act(Teki& teki) { /* .loc_0x0: @@ -1207,7 +1219,7 @@ bool TAIAapproachTargetPriorityFaceDir::act(Teki&) * Address: 801A99C4 * Size: 000018 */ -f32 TAIAapproachTargetPriorityFaceDir::getVelocity(Teki&) +f32 TAIAapproachTargetPriorityFaceDir::getVelocity(Teki& teki) { /* .loc_0x0: @@ -1235,7 +1247,7 @@ void TAIAlookAround::setTargetDirection(Teki&, f32) * Address: 801A99DC * Size: 0000DC */ -void TAIAlookAround::start(Teki&) +void TAIAlookAround::start(Teki& teki) { /* .loc_0x0: @@ -1306,7 +1318,7 @@ void TAIAlookAround::start(Teki&) * Address: 801A9AB8 * Size: 00031C */ -bool TAIAlookAround::act(Teki&) +bool TAIAlookAround::act(Teki& teki) { /* .loc_0x0: @@ -1557,8 +1569,15 @@ bool TAIAlookAround::act(Teki&) * Address: ........ * Size: 00004C */ -void TAIAturnToTarget::getTurnMotionIndex(Teki&) +int TAIAturnToTarget::getTurnMotionIndex(Teki& teki) { + Vector3f vec; + vec.sub2(teki._388, teki.mPosition); + teki._394 = NMathF::atan2Vec(vec); + if (angDist(teki._394, teki.mDirection) > 0.0f) { + return _0C; + } + return _10; // UNUSED FUNCTION } @@ -1567,8 +1586,16 @@ void TAIAturnToTarget::getTurnMotionIndex(Teki&) * Address: 801A9DD4 * Size: 0000CC */ -void TAIAturnToTarget::start(Teki&) +void TAIAturnToTarget::start(Teki& teki) { + teki.setCreatureFlag(CF_Unk11); + mMotionID = getTurnMotionIndex(teki); + // Vector3f vec; + // vec = teki._388 - teki.mPosition; + // teki._394 = NMathF::atan2(vec.x, vec.z); + // mMotionID = (angDist(teki._394, teki.mDirection) > 0.0f) ? _0C : _10; + TAIAreserveMotion::start(teki); + /* .loc_0x0: mflr r0 @@ -1634,7 +1661,7 @@ void TAIAturnToTarget::start(Teki&) * Address: 801A9EA0 * Size: 0001E8 */ -bool TAIAturnToTarget::act(Teki&) +bool TAIAturnToTarget::act(Teki& teki) { /* .loc_0x0: @@ -1788,7 +1815,7 @@ bool TAIAturnToTarget::act(Teki&) * Address: 801AA088 * Size: 000078 */ -void TAIAstop::start(Teki&) +void TAIAstop::start(Teki& teki) { /* .loc_0x0: @@ -1830,7 +1857,7 @@ void TAIAstop::start(Teki&) * Address: 801AA100 * Size: 00005C */ -void TAIArandomWalk::start(Teki&) +void TAIArandomWalk::start(Teki& teki) { /* .loc_0x0: @@ -1865,7 +1892,7 @@ void TAIArandomWalk::start(Teki&) * Address: 801AA15C * Size: 0000E8 */ -bool TAIArandomWalk::act(Teki&) +bool TAIArandomWalk::act(Teki& teki) { /* .loc_0x0: @@ -1939,7 +1966,7 @@ bool TAIArandomWalk::act(Teki&) * Address: 801AA244 * Size: 000100 */ -void TAIArandomWalk::makeTargetPosition(Teki&) +void TAIArandomWalk::makeTargetPosition(Teki& teki) { /* .loc_0x0: @@ -2015,7 +2042,7 @@ void TAIArandomWalk::makeTargetPosition(Teki&) * Address: 801AA344 * Size: 000020 */ -void TAIAturnOccasion::start(Teki&) +void TAIAturnOccasion::start(Teki& teki) { /* .loc_0x0: @@ -2035,7 +2062,7 @@ void TAIAturnOccasion::start(Teki&) * Address: 801AA364 * Size: 0000B4 */ -bool TAIAturnOccasion::act(Teki&) +bool TAIAturnOccasion::act(Teki& teki) { /* .loc_0x0: @@ -2096,7 +2123,7 @@ bool TAIAturnOccasion::act(Teki&) * Address: 801AA418 * Size: 000118 */ -void TAIAturnFocusCreature::start(Teki&) +void TAIAturnFocusCreature::start(Teki& teki) { /* .loc_0x0: @@ -2186,7 +2213,7 @@ void TAIAturnFocusCreature::start(Teki&) * Address: 801AA530 * Size: 000078 */ -bool TAIAturnFocusCreature::act(Teki&) +bool TAIAturnFocusCreature::act(Teki& teki) { /* .loc_0x0: @@ -2232,7 +2259,7 @@ bool TAIAturnFocusCreature::act(Teki&) * Address: 801AA5A8 * Size: 000084 */ -void TAIAwait::start(Teki&) +void TAIAwait::start(Teki& teki) { /* .loc_0x0: @@ -2277,7 +2304,7 @@ void TAIAwait::start(Teki&) * Address: 801AA62C * Size: 000098 */ -bool TAIAwait::act(Teki&) +bool TAIAwait::act(Teki& teki) { /* .loc_0x0: @@ -2329,7 +2356,7 @@ bool TAIAwait::act(Teki&) * Address: 801AA6C4 * Size: 000008 */ -f32 TAIAwait::getWaitCounterMax(Teki&) +f32 TAIAwait::getWaitCounterMax(Teki& teki) { /* .loc_0x0: @@ -2343,7 +2370,7 @@ f32 TAIAwait::getWaitCounterMax(Teki&) * Address: ........ * Size: 000058 */ -void TAIApatrol::changeStatus(int, Teki&) +void TAIApatrol::changeStatus(int, Teki& teki) { // UNUSED FUNCTION } @@ -2396,7 +2423,7 @@ TAIApatrol::TAIApatrol(int, int, int, int, Vector3f*, int, bool) * Address: ........ * Size: 000070 */ -void TAIApatrol::setTargetPosition(Teki&) +void TAIApatrol::setTargetPosition(Teki& teki) { // UNUSED FUNCTION } @@ -2406,7 +2433,7 @@ void TAIApatrol::setTargetPosition(Teki&) * Address: 801AA748 * Size: 0002B0 */ -void TAIApatrol::start(Teki&) +void TAIApatrol::start(Teki& teki) { /* .loc_0x0: @@ -2614,7 +2641,7 @@ void TAIApatrol::start(Teki&) * Address: 801AA9F8 * Size: 000354 */ -bool TAIApatrol::act(Teki&) +bool TAIApatrol::act(Teki& teki) { /* .loc_0x0: @@ -2871,7 +2898,7 @@ bool TAIApatrol::act(Teki&) * Address: 801AAD4C * Size: 000008 */ -f32 TAIApatrol::getTimeout(Teki&) +f32 TAIApatrol::getTimeout(Teki& teki) { /* .loc_0x0: @@ -2885,7 +2912,7 @@ f32 TAIApatrol::getTimeout(Teki&) * Address: 801AAD54 * Size: 000038 */ -void TAIAstepBack::start(Teki&) +void TAIAstepBack::start(Teki& teki) { /* .loc_0x0: @@ -2911,7 +2938,7 @@ void TAIAstepBack::start(Teki&) * Address: 801AAD8C * Size: 000164 */ -bool TAIAstepBack::act(Teki&) +bool TAIAstepBack::act(Teki& teki) { /* .loc_0x0: @@ -3018,7 +3045,7 @@ bool TAIAstepBack::act(Teki&) * Address: 801AAEF0 * Size: 000018 */ -f32 TAIAstepBack::getVelocity(Teki&) +f32 TAIAstepBack::getVelocity(Teki& teki) { /* .loc_0x0: @@ -3036,7 +3063,7 @@ f32 TAIAstepBack::getVelocity(Teki&) * Address: 801AAF08 * Size: 000110 */ -void TAIAturnHome::start(Teki&) +void TAIAturnHome::start(Teki& teki) { /* .loc_0x0: @@ -3120,7 +3147,7 @@ void TAIAturnHome::start(Teki&) * Address: 801AB018 * Size: 0000C4 */ -bool TAIAturnHome::act(Teki&) +bool TAIAturnHome::act(Teki& teki) { /* .loc_0x0: @@ -3185,7 +3212,7 @@ bool TAIAturnHome::act(Teki&) * Address: 801AB0DC * Size: 000038 */ -void TAIAgoingHome::start(Teki&) +void TAIAgoingHome::start(Teki& teki) { /* .loc_0x0: @@ -3211,7 +3238,7 @@ void TAIAgoingHome::start(Teki&) * Address: 801AB114 * Size: 0000F0 */ -bool TAIAgoingHome::act(Teki&) +bool TAIAgoingHome::act(Teki& teki) { /* .loc_0x0: @@ -3287,7 +3314,7 @@ bool TAIAgoingHome::act(Teki&) * Address: 801AB204 * Size: 000038 */ -void TAIAgoingHomePriorityFaceDir::start(Teki&) +void TAIAgoingHomePriorityFaceDir::start(Teki& teki) { /* .loc_0x0: @@ -3313,7 +3340,7 @@ void TAIAgoingHomePriorityFaceDir::start(Teki&) * Address: 801AB23C * Size: 0000F0 */ -bool TAIAgoingHomePriorityFaceDir::act(Teki&) +bool TAIAgoingHomePriorityFaceDir::act(Teki& teki) { /* .loc_0x0: @@ -3389,7 +3416,7 @@ bool TAIAgoingHomePriorityFaceDir::act(Teki&) * Address: 801AB32C * Size: 00002C */ -void TAIAflyingBase::start(Teki&) +void TAIAflyingBase::start(Teki& teki) { /* .loc_0x0: @@ -3412,7 +3439,7 @@ void TAIAflyingBase::start(Teki&) * Address: 801AB358 * Size: 000078 */ -bool TAIAflyingBase::act(Teki&) +bool TAIAflyingBase::act(Teki& teki) { /* .loc_0x0: @@ -3456,7 +3483,7 @@ bool TAIAflyingBase::act(Teki&) * Address: 801AB3D0 * Size: 00003C */ -f32 TAIAflyingBase::getFlyingStayVelocity(Teki&) +f32 TAIAflyingBase::getFlyingStayVelocity(Teki& teki) { /* .loc_0x0: @@ -3485,7 +3512,7 @@ f32 TAIAflyingBase::getFlyingStayVelocity(Teki&) * Address: ........ * Size: 000144 */ -void TAIAflyingInTerritory::setTargetPosition(Teki&) +void TAIAflyingInTerritory::setTargetPosition(Teki& teki) { // UNUSED FUNCTION } @@ -3495,7 +3522,7 @@ void TAIAflyingInTerritory::setTargetPosition(Teki&) * Address: 801AB40C * Size: 0001B0 */ -void TAIAflyingInTerritory::start(Teki&) +void TAIAflyingInTerritory::start(Teki& teki) { /* .loc_0x0: @@ -3617,7 +3644,7 @@ void TAIAflyingInTerritory::start(Teki&) * Address: 801AB5BC * Size: 000430 */ -bool TAIAflyingInTerritory::act(Teki&) +bool TAIAflyingInTerritory::act(Teki& teki) { /* .loc_0x0: @@ -3909,7 +3936,7 @@ bool TAIAflyingInTerritory::act(Teki&) * Address: 801AB9EC * Size: 000050 */ -void TAIAflyingToGoal::start(Teki&) +void TAIAflyingToGoal::start(Teki& teki) { /* .loc_0x0: @@ -3941,7 +3968,7 @@ void TAIAflyingToGoal::start(Teki&) * Address: 801ABA3C * Size: 000330 */ -bool TAIAflyingToGoal::act(Teki&) +bool TAIAflyingToGoal::act(Teki& teki) { /* .loc_0x0: @@ -4173,14 +4200,14 @@ bool TAIAflyingToGoal::act(Teki&) * Address: 801ABD6C * Size: 000008 */ -bool TAIAflyingToGoal::goal(Teki&) { return true; } +bool TAIAflyingToGoal::goal(Teki& teki) { return true; } /* * --INFO-- * Address: 801ABD74 * Size: 000018 */ -f32 TAIAflyingToGoal::getVelocity(Teki&) +f32 TAIAflyingToGoal::getVelocity(Teki& teki) { /* .loc_0x0: @@ -4198,7 +4225,7 @@ f32 TAIAflyingToGoal::getVelocity(Teki&) * Address: 801ABD8C * Size: 000080 */ -void TAIAflyingDistanceInTerritory::start(Teki&) +void TAIAflyingDistanceInTerritory::start(Teki& teki) { /* .loc_0x0: @@ -4242,7 +4269,7 @@ void TAIAflyingDistanceInTerritory::start(Teki&) * Address: 801ABE0C * Size: 000048 */ -bool TAIAflyingDistanceInTerritory::act(Teki&) +bool TAIAflyingDistanceInTerritory::act(Teki& teki) { /* .loc_0x0: @@ -4272,7 +4299,7 @@ bool TAIAflyingDistanceInTerritory::act(Teki&) * Address: 801ABE54 * Size: 000348 */ -bool TAIAflyingDistanceInTerritory::goal(Teki&) +bool TAIAflyingDistanceInTerritory::goal(Teki& teki) { /* .loc_0x0: @@ -4510,7 +4537,7 @@ bool TAIAflyingDistanceInTerritory::goal(Teki&) * Address: 801AC19C * Size: 00003C */ -void TAIAflyingDistance::start(Teki&) +void TAIAflyingDistance::start(Teki& teki) { /* .loc_0x0: @@ -4537,7 +4564,7 @@ void TAIAflyingDistance::start(Teki&) * Address: 801AC1D8 * Size: 0003A0 */ -bool TAIAflyingDistance::act(Teki&) +bool TAIAflyingDistance::act(Teki& teki) { /* .loc_0x0: @@ -4825,7 +4852,7 @@ bool TAIAflyingDistance::act(Teki&) * Address: 801AC578 * Size: 000020 */ -f32 TAIAflyingDistance::getGoalAreaRange(Teki&) +f32 TAIAflyingDistance::getGoalAreaRange(Teki& teki) { /* .loc_0x0: @@ -4845,7 +4872,7 @@ f32 TAIAflyingDistance::getGoalAreaRange(Teki&) * Address: 801AC598 * Size: 000080 */ -void TAIAdescent::start(Teki&) +void TAIAdescent::start(Teki& teki) { /* .loc_0x0: @@ -4889,7 +4916,7 @@ void TAIAdescent::start(Teki&) * Address: 801AC618 * Size: 0002BC */ -bool TAIAdescent::act(Teki&) +bool TAIAdescent::act(Teki& teki) { /* .loc_0x0: @@ -5092,7 +5119,7 @@ bool TAIAdescent::act(Teki&) * Address: 801AC8D4 * Size: 000018 */ -f32 TAIAdescent::getFlyingVelocity(Teki&) +f32 TAIAdescent::getFlyingVelocity(Teki& teki) { /* .loc_0x0: @@ -5110,7 +5137,7 @@ f32 TAIAdescent::getFlyingVelocity(Teki&) * Address: 801AC8EC * Size: 000008 */ -f32 TAIAdescent::getForceDescentFrame(Teki&) +f32 TAIAdescent::getForceDescentFrame(Teki& teki) { /* .loc_0x0: @@ -5124,7 +5151,7 @@ f32 TAIAdescent::getForceDescentFrame(Teki&) * Address: 801AC8F4 * Size: 000090 */ -void TAIAlanding::start(Teki&) +void TAIAlanding::start(Teki& teki) { /* .loc_0x0: @@ -5172,7 +5199,7 @@ void TAIAlanding::start(Teki&) * Address: 801AC984 * Size: 000110 */ -bool TAIAlanding::act(Teki&) +bool TAIAlanding::act(Teki& teki) { /* .loc_0x0: @@ -5262,14 +5289,14 @@ bool TAIAlanding::act(Teki&) * Address: 801ACA94 * Size: 000004 */ -void TAIAlanding::landingEffect(Teki&) { } +void TAIAlanding::landingEffect(Teki& teki) { } /* * --INFO-- * Address: 801ACA98 * Size: 000090 */ -void TAIAtakeOff::start(Teki&) +void TAIAtakeOff::start(Teki& teki) { /* .loc_0x0: @@ -5317,7 +5344,7 @@ void TAIAtakeOff::start(Teki&) * Address: 801ACB28 * Size: 000118 */ -bool TAIAtakeOff::act(Teki&) +bool TAIAtakeOff::act(Teki& teki) { /* .loc_0x0: @@ -5417,7 +5444,7 @@ bool TAIAtakeOff::act(Teki&) * Address: 801ACC40 * Size: 000014 */ -void TAIAtakeOff::startFlying(Teki&) +void TAIAtakeOff::startFlying(Teki& teki) { /* .loc_0x0: diff --git a/src/plugPikiYamashita/TAIkabekuiA.cpp b/src/plugPikiYamashita/TAIkabekuiA.cpp index c3ca02cb..fa123726 100644 --- a/src/plugPikiYamashita/TAIkabekuiA.cpp +++ b/src/plugPikiYamashita/TAIkabekuiA.cpp @@ -1,4 +1,5 @@ #include "TAI/KabekuiA.h" +#include "sysNew.h" /* * --INFO-- @@ -28,48 +29,9 @@ static void _Print(char*, ...) TAIkabekuiASoundTable::TAIkabekuiASoundTable() : PaniSoundTable(3) { - /* - .loc_0x0: - mflr r0 - li r4, 0x3 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - stw r30, 0x18(r1) - stw r29, 0x14(r1) - addi r29, r3, 0 - bl -0xAB254 - li r30, 0 - li r31, 0 - b .loc_0x58 - - .loc_0x30: - li r3, 0x4 - bl -0x1832D8 - cmplwi r3, 0 - beq- .loc_0x48 - addi r0, r30, 0x7C - stw r0, 0x0(r3) - - .loc_0x48: - lwz r4, 0x4(r29) - addi r30, r30, 0x1 - stwx r3, r4, r31 - addi r31, r31, 0x4 - - .loc_0x58: - lwz r0, 0x0(r29) - cmpw r30, r0 - blt+ .loc_0x30 - mr r3, r29 - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + for (int i = 0; i < mSoundCount; i++) { + mSounds[i] = new PaniSound(i + 124); + } } /* @@ -78,7 +40,7 @@ TAIkabekuiASoundTable::TAIkabekuiASoundTable() * Size: 00036C */ TAIkabekuiAParameters::TAIkabekuiAParameters() - : TekiParameters(0, 0) // TODO: fix + : TekiParameters(20, 54) // TODO: fix { /* .loc_0x0: @@ -310,7 +272,7 @@ TAIkabekuiAParameters::TAIkabekuiAParameters() * Size: 000A84 */ TAIkabekuiAStrategy::TAIkabekuiAStrategy() - : YaiStrategy(0, 0) // TODO: fix + : YaiStrategy(11, 1) // TODO: fix { /* .loc_0x0: @@ -1870,39 +1832,3 @@ void TAIAinvincibleOn::start(Teki&) blr */ } - -/* - * --INFO-- - * Address: 801CBB08 - * Size: 000060 - */ -void TAIAsetMotionSpeed::start(Teki&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stfd f31, 0x20(r1) - stw r31, 0x1C(r1) - addi r31, r4, 0 - stw r30, 0x18(r1) - addi r30, r3, 0 - bl -0x1EEB0 - mr r3, r31 - lfs f31, 0xC(r30) - lwz r12, 0x0(r31) - lwz r4, -0x9BC(r13) - lwz r12, 0x1CC(r12) - mtlr r12 - blrl - stfs f31, 0x3B4(r31) - lwz r0, 0x2C(r1) - lfd f31, 0x20(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - */ -} diff --git a/src/plugPikiYamashita/TAItamago.cpp b/src/plugPikiYamashita/TAItamago.cpp index 3184d3f7..8652cb6a 100644 --- a/src/plugPikiYamashita/TAItamago.cpp +++ b/src/plugPikiYamashita/TAItamago.cpp @@ -1149,22 +1149,6 @@ bool TAIAhatch::act(Teki&) */ } -/* - * --INFO-- - * Address: 801D0D40 - * Size: 000010 - */ -int ParaParameters::get(int) -{ - /* - .loc_0x0: - lwz r3, 0x0(r3) - rlwinm r0,r4,2,0,29 - lwzx r3, r3, r0 - blr - */ -} - /* * --INFO-- * Address: 801D0D50 diff --git a/src/plugPikiYamashita/yai.cpp b/src/plugPikiYamashita/yai.cpp index 37d9a9d3..766e6b8c 100644 --- a/src/plugPikiYamashita/yai.cpp +++ b/src/plugPikiYamashita/yai.cpp @@ -1,4 +1,7 @@ #include "YaiStrategy.h" +#include "teki.h" +#include "TAI/Action.h" +#include "sysNew.h" /* * --INFO-- @@ -25,69 +28,18 @@ static void _Print(char*, ...) * Address: 801E9654 * Size: 000064 */ -YaiStrategy::YaiStrategy(int, int) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x28(r1) - stw r31, 0x24(r1) - addi r31, r5, 0 - stw r30, 0x20(r1) - addi r30, r4, 0 - stw r29, 0x1C(r1) - addi r29, r3, 0 - bl -0x9C4D4 - lis r3, 0x802E - addi r0, r3, 0x5AA8 - stw r0, 0x0(r29) - addi r3, r29, 0 - addi r4, r30, 0 - addi r5, r31, 0 - bl .loc_0x64 - mr r3, r29 - lwz r0, 0x2C(r1) - lwz r31, 0x24(r1) - lwz r30, 0x20(r1) - lwz r29, 0x1C(r1) - addi r1, r1, 0x28 - mtlr r0 - blr - - .loc_0x64: - */ -} +YaiStrategy::YaiStrategy(int p1, int p2) { init(p1, p2); } /* * --INFO-- * Address: 801E96B8 * Size: 00004C */ -void YaiStrategy::init(int, int) +void YaiStrategy::init(int p1, int p2) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x20(r1) - stw r31, 0x1C(r1) - mr r31, r5 - stw r30, 0x18(r1) - mr r30, r3 - stw r4, 0x4(r3) - lwz r0, 0x4(r3) - rlwinm r3,r0,2,0,29 - bl -0x1A26DC - stw r3, 0x8(r30) - stw r31, 0xC(r30) - lwz r0, 0x24(r1) - lwz r31, 0x1C(r1) - lwz r30, 0x18(r1) - addi r1, r1, 0x20 - mtlr r0 - blr - */ + _04 = p1; + mStates = new TaiState*[_04]; // TODO: work out type + _0C = p2; } /* @@ -95,28 +47,10 @@ void YaiStrategy::init(int, int) * Address: 801E9704 * Size: 000044 */ -void YaiStrategy::start(Teki&) +void YaiStrategy::start(Teki& teki) { - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - lwz r0, 0xC(r3) - stw r0, 0x324(r4) - lwz r0, 0x324(r4) - lwz r3, 0x8(r3) - rlwinm r0,r0,2,0,29 - lwzx r3, r3, r0 - lwz r12, 0x0(r3) - lwz r12, 0x8(r12) - mtlr r12 - blrl - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ + teki._324 = _0C; + mStates[teki._324]->start(teki); } /* @@ -124,8 +58,14 @@ void YaiStrategy::start(Teki&) * Address: 801E9748 * Size: 0000AC */ -void YaiStrategy::act(Teki&) +void YaiStrategy::act(Teki& teki) { + // what on earth did yamashita do + int stateID = teki._324; + if (mStates[teki._324]->act(teki)) { + mStates[stateID]->finish(teki); + mStates[teki._324]->start(teki); + } /* .loc_0x0: mflr r0 @@ -181,7 +121,7 @@ void YaiStrategy::act(Teki&) * Address: 801E97F4 * Size: 0000AC */ -void YaiStrategy::eventPerformed(TekiEvent&) +void YaiStrategy::eventPerformed(TekiEvent& event) { /* .loc_0x0: @@ -238,17 +178,4 @@ void YaiStrategy::eventPerformed(TekiEvent&) * Address: 801E98A0 * Size: 000020 */ -void YaiStrategy::draw(Teki&, Graphics&) -{ - /* - .loc_0x0: - mflr r0 - stw r0, 0x4(r1) - stwu r1, -0x8(r1) - bl -0x9C6E8 - lwz r0, 0xC(r1) - addi r1, r1, 0x8 - mtlr r0 - blr - */ -} +void YaiStrategy::draw(Teki& teki, Graphics& gfx) { TekiStrategy::draw(teki, gfx); }