summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorColin Noga <Tempus@Spectrum-Song.local>2011-07-19 17:07:00 -0500
committerColin Noga <Tempus@Spectrum-Song.local>2011-07-19 17:07:00 -0500
commitc2cc0c0d58b09d4e11003ca53e33b38723709bc1 (patch)
tree63cca09448468beaa000b055acb6d70c712c7ba3 /include
parent4457c47b7cb1e56577760df0e6ddfdc8bf28a7a8 (diff)
downloadkamek-c2cc0c0d58b09d4e11003ca53e33b38723709bc1.tar.gz
kamek-c2cc0c0d58b09d4e11003ca53e33b38723709bc1.zip
Bunch of fixes, Zorder stuff, and non-working sprespawner
Diffstat (limited to 'include')
-rw-r--r--[-rwxr-xr-x]include/common.h4
-rw-r--r--[-rwxr-xr-x]include/game.h758
-rw-r--r--include/statelib.h133
3 files changed, 881 insertions, 14 deletions
diff --git a/include/common.h b/include/common.h
index b8bce80..2e7dc80 100755..100644
--- a/include/common.h
+++ b/include/common.h
@@ -44,6 +44,9 @@ typedef struct { f32 x, y, z; } VEC3, Vec, *VecPtr, Point3d, *Point3dPtr;
typedef struct { s16 x; s16 y; s16 z; }S16Vec, *S16VecPtr;
typedef struct { f32 x, y, z, w; } Quaternion, *QuaternionPtr, Qtrn, *QtrnPtr;
+extern "C" const char * strrchr ( const char * str, int character );
+extern "C" int strcmp ( const char * str1, const char * str2 );
+
#include "rvl/mtx.h"
@@ -76,6 +79,7 @@ int sprintf(char *buffer, const char *format, ...);
int snprintf(char *buffer, int buff_size, const char *format, ...);
char *strcat(const char *destination, const char *source);
void *memset(void *ptr, int value, unsigned int num);
+int memcmp(const void *ptr1, const void *ptr2, unsigned int num);
void *AllocFromGameHeap1(u32 size);
void FreeFromGameHeap1(void *block);
diff --git a/include/game.h b/include/game.h
index b26842b..81f4e69 100755..100644
--- a/include/game.h
+++ b/include/game.h
@@ -1,11 +1,14 @@
#ifndef __KAMEK_GAME_H
#define __KAMEK_GAME_H
+//#define offsetof(type, member) ((__std(size_t)) &(((type *) 0)->member))
+
#include <common.h>
#include <rvl/mtx.h>
#include <rvl/GXEnum.h>
#include <rvl/vifuncs.h>
#include <rvl/arc.h>
+#define offsetof(type, member) ((u32) &(((type *) 0)->member))
extern "C" {
@@ -281,6 +284,49 @@ void *BgTexMng__LoadAnimTile(void *self, int tileset, short tile, char *name, ch
extern void *GameHeaps[];
+class dFlagMgr_c {
+public:
+ dFlagMgr_c();
+
+ enum ActionFlag {
+ ACTIVATE = 1,
+ TICKS = 2
+ };
+
+ u64 flags;
+ float _8[64], _108[64];
+ u8 _208[64];
+ u64 _248[64];
+ u8 _448[64];
+
+ u32 ticksRemainingForAction[64];
+ u8 actionFlag[64];
+ u32 _5C8[64]; // somehow sound related?! assigned by last param to set(); only checked for == 0
+ u8 _6C8; // assigned -1 by FlagMgr, and other values by the Switch object, nothing else though
+
+ void setup(bool isNewLevel);
+ void applyAndClearAllTimedActions(); // only used when setup(true) is called
+ void execute();
+
+ void set(u8 number, int delay, bool activate, bool reverseEffect, bool makeNoise, u32 unknown=0);
+
+ u8 findLowestFlagInSet(u32 unk, u64 set);
+
+ void setSpecial(u8 number, float to8, float to108, u8 to208, u32 unk, u64 to248);
+ float get8(u8 number);
+ float get108(u8 number);
+ u8 get208(u8 number);
+ u64 get248(u8 number);
+ u8 get448(u8 number);
+
+ // convenience inline functions which may or may not actually exist in Nintendo's original code
+ u64 mask(u8 number) { return (u64)1 << number; }
+ bool active(u8 number) { return (flags & mask(number)) != 0; }
+ bool inactive(u8 number) { return (flags & mask(number)) == 0; }
+
+ static dFlagMgr_c *instance;
+};
+
namespace nw4r {
@@ -386,7 +432,7 @@ namespace lyt {
public:
//Pane(nw4r::lyt::res::Pane const *); // todo: this struct
Pane(void *);
- ~Pane();
+ virtual ~Pane();
virtual void *GetRuntimeTypeInfo() const;
virtual void CalculateMtx(const DrawInfo &info);
@@ -455,7 +501,7 @@ namespace lyt {
u8 origin;
u8 flag;
- char name[0x14];
+ char name[0x11];
char userdata[8];
u8 _D5;
@@ -802,6 +848,238 @@ namespace EGG {
}
+class TileRenderer {
+public:
+ TileRenderer();
+ ~TileRenderer();
+
+ TileRenderer *list1, *list2;
+ u16 tileNumber;
+ u8 unkFlag, someBool;
+ float x, y, z;
+ float scale;
+ s16 rotation;
+ u8 unkByte;
+
+ u16 getTileNum();
+ bool getSomeBool();
+ void setSomeBool(u8 value);
+
+ float getX();
+ float getY();
+ float getZ();
+ void setPosition(float x, float y);
+ void setPosition(float x, float y, float z);
+
+ u8 getUnkFlag();
+
+ void setVars(float scale); // sets unkFlag=1, rotation=0, unkByte=0
+ void setVars(float scale, s16 rotation); // sets unkFlag=2, unkByte=0
+
+ float getScale();
+ float getRotationFloat();
+ s16 getRotation();
+
+ u8 getUnkByte();
+
+ class List {
+ public:
+ u32 count;
+ TileRenderer *first, *last; // order?
+
+ void add(TileRenderer *r);
+ void remove(TileRenderer *r);
+ void removeAll();
+
+ List();
+ ~List();
+ };
+};
+
+class dActor_c; // forward declaration
+
+class Physics {
+public:
+ struct Unknown {
+ Unknown();
+ ~Unknown();
+
+ float x, y;
+ };
+
+ struct Info {
+ float x1, y1, x2, y2; // Might be distance to center/edge like APhysics
+ void *otherCallback1, *otherCallback2, *otherCallback3;
+ };
+
+ Physics();
+ ~Physics();
+
+ dActor_c *owner;
+ Physics *next, *prev;
+ u32 _C, _10, _14, _18, _1C, _20, _24, _28, _2C, _30, _34, _38, _3C;
+ void *otherCallback1, *otherCallback2, *otherCallback3;
+ void *callback1, *callback2, *callback3;
+ float lastX, lastY;
+ Unknown unkArray[4];
+ float x, y;
+ float _88, _8C, _90;
+ Vec lastActorPosition;
+ float _A0, _A4, last_A0, last_A4, _B0, _B4;
+ u32 _B8;
+ s16 *ptrToRotationShort;
+ s16 currentRotation;
+ s16 rotDiff;
+ s16 rotDiffAlt;
+ u32 isRound;
+ u32 _CC;
+ u32 flagsMaybe;
+ u32 _D4, _D8;
+ u8 isAddedToList, _DD, layer;
+ u32 id;
+
+ void addToList();
+ void removeFromList();
+
+ void baseSetup(dActor_c *actor, u32 t_40, u32 t_44, u32 t_48, u8 t_DD, u8 layer);
+
+ // note: Scale can be a null pointer (in that case, it'll use 1.0)
+ void setup(dActor_c *actor,
+ float x1, float y1, float x2, float y2,
+ void *otherCB1, void *otherCB2, void *otherCB3,
+ u8 t_DD, u8 layer, Vec2 *scale = 0);
+
+ void setup(dActor_c *actor,
+ Vec2 *p1, Vec2 *p2,
+ void *otherCB1, void *otherCB2, void *otherCB3,
+ u8 t_DD, u8 layer, Vec2 *scale = 0);
+
+ void setup(dActor_c *actor, Info *pInfo, u8 t_DD, u8 layer, Vec2 *scale = 0);
+
+ // radius might be diameter? dunno
+ void setupRound(dActor_c *actor,
+ float x, float y, float radius,
+ void *otherCB1, void *otherCB2, void *otherCB3,
+ u8 t_DD, u8 layer);
+
+ void setRect(float x1, float y1, float x2, float y2, Vec2 *scale = 0);
+ void setRect(Vec2 *p1, Vec2 *p2, Vec2 *scale = 0);
+
+ void setX(float value);
+ void setY(float value);
+ void setWidth(float value);
+ void setHeight(float value);
+
+ void setPtrToRotation(s16 *ptr);
+
+ void update();
+
+ // todo: more stuff that might not be relevant atm
+};
+
+
+class ActivePhysics {
+public:
+ struct Info; // forward declaration
+ typedef void (*Callback)(Info *self, Info *other);
+
+ struct Info {
+ float xDistToCenter;
+ float yDistToCenter;
+ float xDistToEdge;
+ float yDistToEdge;
+ u8 category1;
+ u8 category2;
+ u32 bitfield1;
+ u32 bitfield2;
+ u16 unkShort1C;
+ Callback callback;
+ };
+
+ ActivePhysics();
+ virtual ~ActivePhysics();
+
+ dActor_c *owner; // should be dStageActor? dunno
+ u32 _8;
+ u32 _C;
+ ActivePhysics *listPrev, *listNext;
+ u32 _18;
+ Info info;
+ u32 _40, _44, _48, _4C;
+ float firstFloatArray[8];
+ float secondFloatArray[8];
+ Vec2 positionOfLastCollision;
+ u16 result1;
+ u16 result2;
+ u16 result3;
+ u8 collisionCheckType;
+ u8 chainlinkMode;
+ u8 layer;
+ u8 someFlagByte;
+ u8 isLinkedIntoList;
+};
+
+
+#include <statelib.h>
+
+class dActorState_c;
+class dActorMultiState_c;
+
+
+class AcStateMgrBase {
+public:
+ virtual ~AcStateMgrBase();
+
+ u32 cls1, cls2, cls3;
+ dActorMultiState_c *owner;
+ u32 unkZero;
+
+ StateMgr<dActorMultiState_c> manager;
+
+ // All these are passed straight through to the manager
+ virtual void _vfC();
+ virtual void _vf10();
+ virtual void _vf14();
+ virtual void _vf18();
+ virtual void _vf1C();
+ virtual void _vf20();
+ virtual void _vf24();
+ virtual void _vf28();
+ virtual void _vf2C();
+};
+
+class AcStateMgr : public AcStateMgrBase {
+public:
+ ~AcStateMgr();
+};
+
+class MultiStateMgrBase {
+public:
+ virtual ~MultiStateMgrBase();
+
+ AcStateMgr s1, s2;
+ AcStateMgr *ptrToStateMgr;
+
+ virtual void _vfC(); // calls vfC on ptrToStateMgr
+ virtual void execute(); // calls vf10 on ptrToStateMgr
+ virtual void _vf14(); // if (isSecondStateMgr()) { disableSecond(); } else { ptrToStateMgr->_vf14(); }
+ virtual void setState(StateBase *state); // calls vf18 on ptrToStateMgr
+ virtual void _vf1C(); // calls vf1C on ptrToStateMgr
+ virtual void _vf20(); // calls vf20 on ptrToStateMgr
+ virtual void _vf24(); // calls vf24 on ptrToStateMgr
+ virtual StateBase *getCurrentState(); // calls vf28 on ptrToStateMgr
+ virtual void _vf2C(); // calls vf2C on ptrToStateMgr
+ virtual void enableSecond(); // sets ptrToStateMgr to s2, calls vf18 on it
+ virtual void disableSecond(); // if (isSecondStateMgr()) { ptrToStateMgr->vf14(); ptrToStateMgr = &s1; }
+ virtual bool isSecondStateMgr();
+ virtual void _vf3C(); // calls vf28 on s1
+};
+
+class MultiStateMgr : public MultiStateMgrBase {
+public:
+ // what the fuck does this do
+ ~MultiStateMgr();
+};
struct LinkListEntry {
@@ -875,19 +1153,19 @@ public:
virtual int onCreate();
virtual int beforeCreate();
- virtual int afterCreate();
+ virtual int afterCreate(int);
virtual int onDelete();
virtual int beforeDelete();
- virtual int afterDelete();
+ virtual int afterDelete(int);
virtual int onExecute();
virtual int beforeExecute();
- virtual int afterExecute();
+ virtual int afterExecute(int);
virtual int onDraw();
virtual int beforeDraw();
- virtual int afterDraw();
+ virtual int afterDraw(int);
virtual void willBeDeleted();
@@ -915,13 +1193,13 @@ public:
dBase_c();
int beforeCreate();
- int afterCreate();
+ int afterCreate(int);
int beforeDelete();
- int afterDelete();
+ int afterDelete(int);
int beforeExecute();
- int afterExecute();
+ int afterExecute(int);
int beforeDraw();
- int afterDraw();
+ int afterDraw(int);
~dBase_c();
@@ -935,13 +1213,13 @@ public:
dScene_c();
int beforeCreate();
- int afterCreate();
+ int afterCreate(int);
int beforeDelete();
- int afterDelete();
+ int afterDelete(int);
int beforeExecute();
- int afterExecute();
+ int afterExecute(int);
int beforeDraw();
- int afterDraw();
+ int afterDraw(int);
~dScene_c();
@@ -982,6 +1260,386 @@ public:
~dActor_c();
};
+class dStageActor_c : public dActor_c {
+public:
+ u8 _125;
+ u32 _128, _12C, _130, _134, _138, _13C;
+ float _140;
+ u32 _144;
+ ActivePhysics aPhysics;
+ u8 classAt1EC[236];
+ u32 _2D8;
+ u8 classAt2DC[0x34];
+ u32 _310, _314;
+ float spriteSomeRectX, spriteSomeRectY;
+ float _320, _324, _328, _32C, _330, _334, _338, _33C, _340, _344;
+ u8 direction;
+ u8 currentZoneID;
+ u8 _34A, _34B;
+ u8 *spriteByteStorage;
+ u16 *spriteShortStorage;
+ u16 spriteEventNum;
+ u64 spriteEventMask;
+ u32 _360;
+ u16 spriteSomeFlag;
+ u8 _366, _367;
+ u32 _368;
+ u8 _36C, _36D;
+ Vec somethingRelatedToScale;
+ u32 _37C, _380, _384, _388;
+ u8 _38C, _38D, enableFlag, currentLayerID;
+ u8 _390, _391, _392, _padding;
+
+ dStageActor_c();
+
+ int beforeCreate();
+ int afterCreate(int);
+ int beforeDelete();
+ int afterDelete(int);
+ int beforeExecute();
+ int afterExecute(int);
+ int beforeDraw();
+ int afterDraw(int);
+
+ const char *GetExplanationString();
+
+ virtual bool _vf60(); // does stuff with BG_GM
+ virtual void kill(); // nullsub here, defined in StageActor. probably no params
+ virtual int _vf68(); // params unknown. return (1) might be bool
+ virtual u8 *_vf6C(); // returns byte 0x38D
+ virtual Vec2 _vf70(); // returns Vec Actor.pos + Vec Actor.field_D0
+ virtual int _vf74(); // params unknown. return (1) might be bool
+ virtual void _vf78(); // params unknown. nullsub
+ virtual void _vf7C(); // params unknown. nullsub
+ virtual void eatIn(); // copies Actor.scale into StageActor.somethingRelatedToScale
+ virtual void disableEatIn(); // params unknown. nullsub
+ virtual void _vf88(); // params unknown. nullsub
+ virtual bool _vf8C(void *other); // dAcPy_c/daPlBase_c? return (1) is probably bool. seems related to EatOut. uses vfA4
+ virtual bool _vf90(dStageActor_c *other); // does something with scores
+ virtual void _vf94(void *other); // dAcPy_c/daPlBase_c? modifies This's position
+ virtual void removeMyActivePhysics();
+ virtual void addMyActivePhysics();
+ virtual void returnRegularScale(); // the reverse of vf80, yay
+ virtual void _vfA4(void *other); // AcPy/PlBase? similar to vf94 but not quite the same
+ virtual float _vfA8(void *other); // AcPy/PlBase? what DOES this do...? does a bit of float math
+ virtual void _vfAC(void *other); // copies somethingRelatedToScale into scale, then multiplies scale by vfA8's return
+ virtual void _vfB0(); // plays Wm_en_burst_s at actor position
+ virtual void _vfB4(); // params unknown. nullsub
+ virtual void _vfB8(); // params unknown. nullsub
+ virtual void _vfBC(); // params unknown. nullsub
+ virtual void _vfC0(); // params unknown. nullsub
+ virtual void _vfC4(); // params unknown. nullsub
+ virtual void _vfC8(Vec2 *p); // does stuff including effects and playing PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH
+ virtual void _vfCC(Vec2 *p); // mostly same as vfC8, but uses PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH_LAVA
+ virtual void _vfD0(Vec2 *p); // mostly same as vfC8, but uses PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH_POISON
+
+ // I'll add methods as I need them
+ void checkZoneBoundaries(u32 flags); // I think this method is for that, anyway
+
+ ~dStageActor_c();
+
+
+ static void create(Actors type, u32 settings, Vec *pos, S16Vec *rot, u8 layer);
+ static void createChild(Actors type, u32 settings, Vec *pos, S16Vec *rot, u8 layer);
+};
+
+
+class dAc_Py_c : public dStageActor_c {
+public:
+ u8 data[0x1164 - 0x394];
+ ActivePhysics bPhysics;
+ ActivePhysics cPhysics;
+ ActivePhysics dPhysics;
+ ActivePhysics ePhysics;
+
+ dAc_Py_c();
+
+ int beforeCreate();
+ int afterCreate(int);
+ int beforeDelete();
+ int afterDelete(int);
+ int beforeExecute();
+ int afterExecute(int);
+ int beforeDraw();
+ int afterDraw(int);
+
+ ~dAc_Py_c();
+};
+
+
+/* TODO
+class dActorState_c : public dStageActor_c {
+public:
+ ~dActorState_c();
+
+ virtual void _vfD4();
+ virtual void _vfD8();
+ virtual void _vfDC();
+};
+*/
+
+
+class dActorMultiState_c : public dStageActor_c {
+public:
+ ~dActorMultiState_c();
+
+ MultiStateMgr acState;
+
+ virtual void doStateChange(StateBase *state); // might return bool? overridden by dEn_c
+ virtual void _vfD8(); // nullsub ??
+ virtual void _vfDC(); // nullsub ??
+ virtual void _vfE0(); // nullsub ??
+};
+
+
+class dEn_c : public dActorMultiState_c {
+public:
+ float _414, _418, _41C, _420;
+ void *nextState;
+ u32 _428, _42C;
+ u8 _430, _431, isDead;
+ u32 _434;
+ u16 _438;
+ u32 _43C;
+ Vec velocity1, velocity2;
+ u8 _458, _459, _45A, _45B, _45C, _45D, _45E;
+ u32 _460;
+ Vec initialScale;
+ float _470;
+ u32 _474, _478;
+ dEn_c *_47C;
+ u32 _480;
+ u8 classAt484[0x4EC - 0x484];
+ u32 _4EC;
+ float _4F0, _4F4, _4F8;
+ u32 flags_4FC;
+ u16 counter_500, counter_502;
+ u16 counter_504[4];
+ u16 counter_50C;
+ u32 _510, _514, _518;
+ void *_51C;
+ dEn_c *_520;
+ u32 _524, _528, _52C, _530;
+
+ dEn_c();
+
+ int afterCreate(int);
+ int beforeExecute(int);
+ int afterExecute(int);
+ int beforeDraw(int);
+
+ void kill();
+
+ void eatIn();
+ void disableEatIn();
+ bool _vf8C(void *other); // AcPy/PlBase?
+ void _vfAC();
+ void _vfCC(Vec2 *p);
+ void _vfD0(Vec2 *p);
+
+ void doStateChange(StateBase *state); // might return bool, dunno
+
+ // Now here's where the fun starts.
+
+ virtual bool preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual bool prePlayerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual bool preYoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+
+ virtual bool stageActorCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+
+ virtual void spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
+
+ // WHAT A MESS
+ virtual void collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat5_Mario(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void _vf108(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void _vf110(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat8_FencePunch(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat7_WMWaggleWaterYoshi(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void _vf120(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCatA_PenguinMario(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat11_PipeCannon(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther);
+ virtual void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther);
+
+ virtual void _vf140(dStageActor_c *actor);
+ virtual void _vf144(int something);
+ virtual void _vf148(); // deletes actors held by Class484 and other stuff
+ virtual void _vf14C(); // deletes actors held by Class484 and makes an En Coin Jump
+ virtual u32 _vf150(); // reads some bits from a value in Class1EC
+ virtual void eatenByYoshiProbably(); // nullsub, params unknown
+ virtual void playHpdpSound1(); // plays PLAYER_SE_EMY/GROUP_BOOT/SE_EMY_DOWN_HPDP_S or _H
+ virtual void playEnemyDownSound1();
+ virtual void playEnemyDownComboSound(void *player); // AcPy_c/daPlBase_c?
+ virtual void playHpdpSound2(); // plays PLAYER_SE_EMY/GROUP_BOOT/SE_EMY_DOWN_HPDP_S or _H
+ virtual void _vf168(); // nullsub, params unknown
+
+ // State Functions
+ virtual void dieFumi_Begin(); // does something involving looping thruogh players
+ virtual void dieFumi_Execute(); // does movement and some other stuff
+ virtual void dieFumi_End(); // nullsub
+ virtual void dieFall_Begin(); // does something involving looping thruogh players
+ virtual void dieFall_Execute(); // does movement and some other stuff
+ virtual void dieFall_End(); // nullsub
+ virtual void dieBigFall_Begin(); // calls vf178 [dieFall_Begin]
+ virtual void dieBigFall_Execute(); // does movement and some other stuff (but less than 170 and 17C)
+ virtual void dieBigFall_End(); // calls vf180 [dieFall_End]
+ virtual void dieSmoke_Begin(); // spawns Wm_en_burst_m effect and then removeMyActivePhysics
+ virtual void dieSmoke_Execute(); // deletes actor with r4=1
+ virtual void dieSmoke_End(); // nullsub
+ virtual void dieYoshiFumi_Begin(); // spawns Wm_mr_yoshistep effect and then removeMyActivePhysics
+ virtual void dieYoshiFumi_Execute(); // deletes actor with r4=1
+ virtual void dieYoshiFumi_End(); // nullsub
+ virtual void dieIceVanish_Begin(); // lots of weird stuff
+ virtual void dieIceVanish_Execute(); // deletes actor with r4=1
+ virtual void dieIceVanish_End(); // nullsub
+ virtual void dieGoal_Begin(); // nullsub
+ virtual void dieGoal_Execute(); // nullsub
+ virtual void dieGoal_End(); // nullsub
+ virtual void dieOther_Begin(); // deletes actor with r4=1
+ virtual void dieOther_Execute(); // nullsub
+ virtual void dieOther_End(); // nullsub
+ virtual void eatIn_Begin(); // nullsub
+ virtual void eatIn_Execute(); // changes to EatNow on one condition, otherwise calls vfAC
+ virtual void eatIn_End(); // nullsub
+ virtual void eatNow_Begin(); // nullsub
+ virtual void eatNow_Execute(); // nullsub
+ virtual void eatNow_End(); // nullsub
+ virtual void eatOut_Begin(); // nullsub
+ virtual void eatOut_Execute(); // nullsub
+ virtual void eatOut_End(); // nullsub
+ virtual void hitSpin_Begin(); // nullsub
+ virtual void hitSpin_Execute(); // nullsub
+ virtual void hitSpin_End(); // nullsub
+ virtual void ice_Begin(); // does stuff with Class484 and lots of vf's
+ virtual void ice_Execute(); // tons of stuff with Class484
+ virtual void ice_End(); // sets a field in Class484 to 0
+
+ virtual void spawnHitEffectAtPosition(Vec2 pos);
+ virtual void doSomethingWithHardHitAndSoftHitEffects(Vec pos);
+ virtual void playEnemyDownSound2();
+ virtual void add2ToYSpeed();
+ virtual bool _vf218(); // stuff with floats and camera
+ virtual void _vf21C(); // does stuff with the speeds
+ virtual void _vf220(void *other); // some type of actor, PlBase? calls vf3F4 on other with r4=this, r5=0
+ virtual void _vf224(); // stores a couple of values into the struct at 464
+ virtual void _vf228(); // more fun stuff with 464 and floats
+ virtual bool _vf22C(); // does stuff involving ICE_ACTORs and arrays
+ virtual void _vf230(); // "relatedToPlayerOrYoshiCollision" apparently. nullsub, params unknown for now.
+ virtual void _vf234(); // nullsub, params unknown
+ virtual void _vf238(); // calls vf34 on class394, params unknown
+ virtual void _vf23C(); // nullsub, params unknown
+ virtual void _vf240(); // nullsub, params unknown
+ virtual int _vf244(); // returns 0. might be bool. params unknown
+ virtual int _vf248(int something); // does some math involving field510 and [7,7,4,0] and param
+ virtual void _vf24C(void *other); // deals with something in the class involving the bahp flag
+ virtual void _vf250(void *other);
+ virtual void _vf254(void *other);
+ virtual void _vf258(void *other);
+ virtual void _vf25C(void *other); // calls vf250
+ virtual void _vf260(void *other); // AcPy/PlBase? plays the SE_EMY_FUMU_%d sounds based on some value
+ virtual void _vf264(dStageActor_c *other); // if other is player or yoshi, do Wm_en_hit and a few other things
+ virtual void _vf268(void *other); // AcPy/PlBase? plays the SE_EMY_DOWN_SPIN_%d sounds based on some value
+ virtual void spawnHitEffectAtPositionAgain(Vec2 pos);
+ virtual void playMameStepSound(); // SE_EMY_MAME_STEP at actor position
+ virtual void _vf274(); // nullsub, params unknown
+ virtual void _vf278(void *other); // AcPy/PlBase? plays the SE_EMY_YOSHI_FUMU_%d sounds based on some value
+ virtual void _vf27C(); // nullsub, params unknown
+
+ ~dEn_c();
+};
+
+
+class daEnBlockMain_c : public dEn_c {
+public:
+ Physics physics;
+ float _618, _61C, _620;
+ u32 _624, _628, _62C;
+ float initialY;
+ float _634, _638, _63C, _640;
+ u32 countdown, _648, _64C;
+ u32 _650, _654, _658, _65C;
+ u16 _660;
+ u8 _662, _663, _664, _665, _666, _667;
+ u8 _668, _669, _66A, _66B, _66C, _66D, _66E, _66F;
+ u8 _670, _671, _672, _673;
+ u8 _674;
+ u8 _675, _676, _677, _678, _679, _67A, _67B, _67C;
+ u8 _67D, _67E, _67F, _680;
+ u32 _684;
+ u8 _688, isGroundPound, anotherFlag, _68B, _68C, _68D, _68E, _68F;
+ u32 _690;
+ u8 _694;
+
+ // Regular methods
+ void blockInit(float initialY);
+ void blockUpdate();
+ u8 blockResult();
+
+ virtual void calledWhenUpMoveBegins();
+ virtual void calledWhenDownMoveBegins();
+
+ virtual void calledWhenUpMoveExecutes();
+ virtual void calledWhenUpMoveDiffExecutes();
+ virtual void calledWhenDownMoveExecutes();
+ virtual void calledWhenDownMoveEndExecutes();
+ virtual void calledWhenDownMoveDiffExecutes();
+ virtual void calledWhenDownMoveDiffEndExecutes();
+
+ virtual void updateScale(bool movingDown);
+
+ // State functions
+ virtual void upMove_Begin();
+ virtual void upMove_Execute();
+ virtual void upMove_End();
+ virtual void downMove_Begin();
+ virtual void downMove_Execute();
+ virtual void downMove_End();
+ virtual void downMoveEnd_Begin();
+ virtual void downMoveEnd_Execute();
+ virtual void downMoveEnd_End();
+ virtual void upMove_Diff_Begin();
+ virtual void upMove_Diff_Execute();
+ virtual void upMove_Diff_End();
+ virtual void downMove_Diff_Begin();
+ virtual void downMove_Diff_Execute();
+ virtual void downMove_Diff_End();
+ virtual void downMove_DiffEnd_Begin();
+ virtual void downMove_DiffEnd_Execute();
+ virtual void downMove_DiffEnd_End();
+
+ static void *PhysicsCallback1;
+ static void *PhysicsCallback2;
+ static void *PhysicsCallback3;
+ static void *OPhysicsCallback1;
+ static void *OPhysicsCallback2;
+ static void *OPhysicsCallback3;
+
+ static State<daEnBlockMain_c> StateID_UpMove;
+ static State<daEnBlockMain_c> StateID_DownMove;
+ static State<daEnBlockMain_c> StateID_DownMoveEnd;
+ static State<daEnBlockMain_c> StateID_UpMove_Diff;
+ static State<daEnBlockMain_c> StateID_DownMove_Diff;
+ static State<daEnBlockMain_c> StateID_DownMove_DiffEnd;
+
+ ~daEnBlockMain_c();
+};
+
+
+class dBgGm_c {
+public:
+ // TODO TODO TODO TODO TODO
+ static dBgGm_c *instance;
+
+ TileRenderer::List *getTileRendererList(int index);
+};
class dPlayerModelBase_c {
@@ -1157,6 +1815,78 @@ private:
+namespace nw4r {
+ namespace ut {
+ class CharWriter {
+ public:
+ CharWriter();
+ ~CharWriter();
+
+ void SetupGX();
+
+ void SetFontSize(float w, float h);
+ void SetFontSize(float v);
+ float GetFontWidth() const;
+ float GetFontHeight() const;
+ float GetFontAscent() const;
+ float GetFontDescent() const;
+
+ // returns width
+ float Print(ushort character);
+
+ void PrintGlyph(float, float, float, /* nw4r::ut::Glyph const & */ void*);
+
+ void UpdateVertexColor();
+
+ private:
+ void SetupGXWithColorMapping(Color c1, Color c2);
+
+ public:
+ Color colors[8]; // todo: document
+ u32 modeOfSomeKind;
+ float scaleX;
+ float scaleY;
+ float posX;
+ float posY;
+ float posZ;
+ GXTexFilter minFilt;
+ GXTexFilter magFilt;
+ u16 completelyUnknown;
+ u8 alpha;
+ u8 isFixedWidth;
+ float fixedWidthValue;
+ /* ResFont* */ void *font;
+ };
+
+ // actually TextWriterBase<w>, but ...
+ class TextWriter : public CharWriter {
+ public:
+ TextWriter();
+ ~TextWriter();
+
+ float GetLineHeight() const;
+
+ // left out most of these to avoid all the format string vararg bullshit
+ float CalcStringWidth(wchar_t const *string, int length) const;
+
+ float Print(wchar_t const *string, int length);
+
+ float CalcLineWidth(wchar_t const *string, int length);
+
+ float GetLineSpace() const;
+
+ bool IsDrawFlagSet(ulong, ulong) const;
+
+ float _4C;
+ float charSpace;
+ float somethingRelatedToLineHeight;
+ u32 _58;
+ u32 drawFlag;
+ void *tagProcessorMaybe;
+ };
+ }
+}
+
// More layout crap
// This file REALLY needs to be reorganised.
diff --git a/include/statelib.h b/include/statelib.h
new file mode 100644
index 0000000..34ab282
--- /dev/null
+++ b/include/statelib.h
@@ -0,0 +1,133 @@
+/******************************************************************************/
+// StateBase class
+/******************************************************************************/
+
+class StateBase {
+public:
+ StateBase(const char *name);
+
+ virtual ~StateBase();
+ virtual bool isInvalid();
+ virtual bool isEqualNotUsedForSomeReason(StateBase *another);
+ virtual bool isEqual(StateBase *another);
+ virtual bool isNotEqual(StateBase *another);
+ virtual bool isSameStateName(const char *name);
+ virtual const char *getName();
+ virtual int getID();
+
+ static StateBase mNoState;
+
+private:
+ const char *mName;
+ int mID;
+
+ static int mLastID;
+};
+
+/******************************************************************************/
+// State<TOwner> : StateBase class
+/******************************************************************************/
+
+template <class TOwner>
+class State : public StateBase {
+public:
+ typedef void (TOwner::*funcPtr)();
+
+ State(const char *name, funcPtr begin, funcPtr execute, funcPtr end) : StateBase(name) {
+ mBegin = begin;
+ mExecute = execute;
+ mEnd = end;
+ }
+
+ ~State();
+ bool isSameStateName(const char *name);
+
+ virtual void doBegin(TOwner *owner);
+ virtual void doExecute(TOwner *owner);
+ virtual void doEnd(TOwner *owner);
+
+ funcPtr mBegin;
+ funcPtr mExecute;
+ funcPtr mEnd;
+};
+
+template <class TOwner>
+State<TOwner>::~State() { }
+
+template <class TOwner>
+bool State<TOwner>::isSameStateName(const char *name) {
+ const char *p = strrchr(name, ':');
+ if (p)
+ name = p + 1;
+
+ int cmp = strcmp(strrchr(getName(), ':')+1, name);
+ if (cmp == 0)
+ return true;
+ else
+ return false;
+}
+
+template <class TOwner>
+void State<TOwner>::doBegin(TOwner *owner) {
+ (owner->*mBegin)();
+}
+
+template <class TOwner>
+void State<TOwner>::doExecute(TOwner *owner) {
+ (owner->*mExecute)();
+}
+
+template <class TOwner>
+void State<TOwner>::doEnd(TOwner *owner) {
+ (owner->*mEnd)();
+}
+
+/******************************************************************************/
+// StateMgrBase class
+/******************************************************************************/
+
+class StateMgrBase {
+public:
+ StateMgrBase(void *one, void *two, StateBase *pInitState);
+
+ virtual ~StateMgrBase();
+ virtual void _vf0C();
+ virtual void execute();
+ virtual void _vf14();
+ virtual void setState(StateBase *pNewState);
+ virtual void setField10ToOne();
+ virtual StateBase *getField20();
+ virtual StateBase *getField14();
+ virtual StateBase *getCurrentState_maybe();
+ virtual StateBase *getField18();
+ virtual bool _vf30() = 0;
+ virtual void _vf34() = 0;
+ virtual void _vf38() = 0;
+ virtual void _vf3C(StateBase *pState) = 0;
+
+private:
+ void *m04, *m08;
+ bool m0C, m0D, m0E, m0F, m10;
+ StateBase *m14, *m18, *m1C;
+ StateBase *m20; // maybe not a StateBase?
+};
+
+/******************************************************************************/
+// StateMgr<TOwner> : StateMgrBase class
+/******************************************************************************/
+
+template <class TOwner>
+class StateMgr : public StateMgrBase {
+public:
+ StateMgr(void *one, void *two, StateBase *pInitState);
+ ~StateMgr();
+
+ bool _vf30();
+ void _vf34();
+ void _vf38();
+ void _vf3C(StateBase *pState);
+};
+
+// TODO: add template methods
+
+