summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-07-10 22:06:08 +0200
committerTreeki <treeki@gmail.com>2011-07-10 22:06:08 +0200
commit4161c5d1c46436e3b942d707da1b40317e87180e (patch)
tree7266831f88805ff0fa5f0517e64d8ec2dd8cbb73 /include
parent54cbbfb69c8a9562d89f05967ae38011327e8da0 (diff)
downloadkamek-4161c5d1c46436e3b942d707da1b40317e87180e.tar.gz
kamek-4161c5d1c46436e3b942d707da1b40317e87180e.zip
custom blocks, states and static initialisers. fuck yeah
Diffstat (limited to '')
-rwxr-xr-xinclude/common.h3
-rwxr-xr-xinclude/game.h83
-rw-r--r--include/statelib.h133
3 files changed, 211 insertions, 8 deletions
diff --git a/include/common.h b/include/common.h
index 6f3c84f..2e7dc80 100755
--- 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"
diff --git a/include/game.h b/include/game.h
index 4927345..ff2e2de 100755
--- 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" {
@@ -974,6 +977,66 @@ public:
};
+#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 {
@@ -1169,7 +1232,7 @@ public:
u8 direction;
u8 currentZoneID;
u8 _34A, _34B;
- u32 _350, _354, _358, _35C, _360;
+ u32 _34C, _350, _354, _358, _35C, _360;
u8 _364, _365, _366, _367;
u32 _368;
u8 _36C, _36D;
@@ -1248,13 +1311,9 @@ class dActorMultiState_c : public dStageActor_c {
public:
~dActorMultiState_c();
- // fuck all of this. I'll just use a data blob here
- // because I don't feel like reimplementing the State stuff in C++
- // right now.
-
- u8 stateClassesAndStuff[0x410 - 0x394];
+ MultiStateMgr acState;
- virtual void doStateChange(void *state); // might return bool? overridden by dEn_c
+ virtual void doStateChange(StateBase *state); // might return bool? overridden by dEn_c
virtual void _vfD8(); // nullsub ??
virtual void _vfDC(); // nullsub ??
virtual void _vfE0(); // nullsub ??
@@ -1306,7 +1365,7 @@ public:
void _vfCC(Vec2 *p);
void _vfD0(Vec2 *p);
- void doStateChange(void *state); // might return bool, dunno
+ void doStateChange(StateBase *state); // might return bool, dunno
// Now here's where the fun starts.
@@ -1450,6 +1509,7 @@ public:
// Regular methods
void blockInit(float initialY);
void blockUpdate();
+ u8 blockResult();
virtual void calledWhenUpMoveBegins();
virtual void calledWhenDownMoveBegins();
@@ -1490,6 +1550,13 @@ public:
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();
};
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
+
+