diff options
Diffstat (limited to '')
-rw-r--r-- | NewerProject.yaml | 1 | ||||
-rw-r--r-- | compression.yaml | 2 | ||||
-rwxr-xr-x | include/common.h | 3 | ||||
-rwxr-xr-x | include/game.h | 83 | ||||
-rw-r--r-- | include/statelib.h | 133 | ||||
-rw-r--r-- | kamek_ntsc.x | 25 | ||||
-rw-r--r-- | kamek_ntsc2.x | 25 | ||||
-rw-r--r-- | kamek_pal.x | 25 | ||||
-rw-r--r-- | kamek_pal2.x | 25 | ||||
-rw-r--r-- | prolog.yaml | 9 | ||||
-rw-r--r-- | src/prolog.S | 65 | ||||
-rw-r--r-- | src/testblock.cpp | 83 |
12 files changed, 465 insertions, 14 deletions
diff --git a/NewerProject.yaml b/NewerProject.yaml index 09254f4..ff05041 100644 --- a/NewerProject.yaml +++ b/NewerProject.yaml @@ -2,6 +2,7 @@ output_dir: "NewerASM"
code_address: 0x808D9000
modules:
+ - processed/prolog.yaml
- processed/bugfixes.yaml
- processed/worldmap.yaml
- processed/levelnames.yaml
diff --git a/compression.yaml b/compression.yaml index 9d3a058..542ee6a 100644 --- a/compression.yaml +++ b/compression.yaml @@ -4,7 +4,7 @@ hooks: - name: InitialiseEverything type: branch_insn branch_type: b - src_addr_pal: 0x8015BC70 + src_addr_pal: 0x8015BCA0 target_func: 'InitCompression' - name: GetFileEntrynumNew 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 + + diff --git a/kamek_ntsc.x b/kamek_ntsc.x index ece3fd6..4bee094 100644 --- a/kamek_ntsc.x +++ b/kamek_ntsc.x @@ -101,6 +101,9 @@ SECTIONS { __construct_new_array = 0x802DC7E0; __destroy_new_array = 0x802DCB10; + __register_global_object = 0x802DC780; + __ptmf_scall = 0x802DCBFC; + setup__13FunctionChainFPPFPv_bUs = 0x8015F600; @@ -144,12 +147,19 @@ SECTIONS { downMove_DiffEnd_End__15daEnBlockMain_cFv = 0x800232E0; blockInit__15daEnBlockMain_cFf = 0x80021690; blockUpdate__15daEnBlockMain_cFv = 0x800217B0; + blockResult__15daEnBlockMain_cFv = 0x800212C0; PhysicsCallback1__15daEnBlockMain_c = 0x80021180; PhysicsCallback2__15daEnBlockMain_c = 0x80021170; PhysicsCallback3__15daEnBlockMain_c = 0x800211A0; OPhysicsCallback1__15daEnBlockMain_c = 0x80020BF0; OPhysicsCallback2__15daEnBlockMain_c = 0x80020E70; OPhysicsCallback3__15daEnBlockMain_c = 0x80021010; + StateID_UpMove__15daEnBlockMain_c = 0x80352A34; + StateID_DownMove__15daEnBlockMain_c = 0x80352A74; + StateID_DownMoveEnd__15daEnBlockMain_c = 0x80352AB4; + StateID_UpMove_Diff__15daEnBlockMain_c = 0x80352AF4; + StateID_DownMove_Diff__15daEnBlockMain_c = 0x80352B34; + StateID_DownMove_DiffEnd__15daEnBlockMain_c = 0x80352B74; __ct__5dEn_cFv = 0x80094E80; afterCreate__5dEn_cFi = 0x800951D0; @@ -160,7 +170,7 @@ SECTIONS { _vf8C__5dEn_cFPv = 0x80097D30; _vfCC__5dEn_cFP7Point2d = 0x800973F0; _vfD0__5dEn_cFP7Point2d = 0x800974F0; - doStateChange__5dEn_cFPv = 0x800A7DF0; + doStateChange__5dEn_cFP9StateBase = 0x800A7DF0; preSpriteCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095CE0; prePlayerCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095D30; preYoshiCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095F50; @@ -303,6 +313,7 @@ SECTIONS { _vfC0__13dStageActor_cFv = 0x80065B60; _vfC4__13dStageActor_cFv = 0x80065B70; _vfC8__13dStageActor_cFP7Point2d = 0x80065CC0; + checkZoneBoundaries__13dStageActor_cFUi = 0x80064F50; __ct__8dScene_cFv = 0x800E19B0; __dt__8dScene_cFv = 0x800E1A20; @@ -336,6 +347,15 @@ SECTIONS { _vf58__8dActor_cFv = 0x8001D1C0; _vf5C__8dActor_cFv = 0x8001D1B0; + __ct__9StateBaseFPCc = 0x8015F7C0; + __dt__9StateBaseFv = 0x8015F800; + isInvalid__9StateBaseFv = 0x8015F840; + isEqualNotUsedForSomeReason__9StateBaseFP9StateBase = 0x8015F850; + isEqual__9StateBaseFP9StateBase = 0x8015F8C0; + isNotEqual__9StateBaseFP9StateBase = 0x8015F8D0; + getName__9StateBaseFv = 0x8015F920; + getID__9StateBaseFv = 0x8015F930; + __ct__7PhysicsFv = 0x8007F7A0; setup__7PhysicsFP8dActor_cPQ27Physics4InfoUcUcP7Point2d = 0x8007FB10; addToList__7PhysicsFv = 0x8007F900; @@ -586,6 +606,7 @@ SECTIONS { strncpy = 0x802E19F8; strcmp = 0x802E1AB4; sprintf = 0x802E17DC; + strrchr = 0x802E1C40; wcslen = 0x802E441C; @@ -976,12 +997,14 @@ SECTIONS { SomeWipeClass = 0x8042A440; QueryGlobal5758 = 0x800B3B50; + .text : { FILL (0) __text_start = . ; *(.init) *(.text) + __ctor_loc = . ; *(.ctors) *(.dtors) *(.rodata) diff --git a/kamek_ntsc2.x b/kamek_ntsc2.x index 2303c80..570578d 100644 --- a/kamek_ntsc2.x +++ b/kamek_ntsc2.x @@ -101,6 +101,9 @@ SECTIONS { __construct_new_array = 0x802DC7E0; __destroy_new_array = 0x802DCB10; + __register_global_object = 0x802DC780; + __ptmf_scall = 0x802DCBFC; + setup__13FunctionChainFPPFPv_bUs = 0x8015F600; @@ -144,12 +147,19 @@ SECTIONS { downMove_DiffEnd_End__15daEnBlockMain_cFv = 0x800232E0; blockInit__15daEnBlockMain_cFf = 0x80021690; blockUpdate__15daEnBlockMain_cFv = 0x800217B0; + blockResult__15daEnBlockMain_cFv = 0x800212C0; PhysicsCallback1__15daEnBlockMain_c = 0x80021180; PhysicsCallback2__15daEnBlockMain_c = 0x80021170; PhysicsCallback3__15daEnBlockMain_c = 0x800211A0; OPhysicsCallback1__15daEnBlockMain_c = 0x80020BF0; OPhysicsCallback2__15daEnBlockMain_c = 0x80020E70; OPhysicsCallback3__15daEnBlockMain_c = 0x80021010; + StateID_UpMove__15daEnBlockMain_c = 0x80352A34; + StateID_DownMove__15daEnBlockMain_c = 0x80352A74; + StateID_DownMoveEnd__15daEnBlockMain_c = 0x80352AB4; + StateID_UpMove_Diff__15daEnBlockMain_c = 0x80352AF4; + StateID_DownMove_Diff__15daEnBlockMain_c = 0x80352B34; + StateID_DownMove_DiffEnd__15daEnBlockMain_c = 0x80352B74; __ct__5dEn_cFv = 0x80094E80; afterCreate__5dEn_cFi = 0x800951D0; @@ -160,7 +170,7 @@ SECTIONS { _vf8C__5dEn_cFPv = 0x80097D30; _vfCC__5dEn_cFP7Point2d = 0x800973F0; _vfD0__5dEn_cFP7Point2d = 0x800974F0; - doStateChange__5dEn_cFPv = 0x800A7DF0; + doStateChange__5dEn_cFP9StateBase = 0x800A7DF0; preSpriteCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095CE0; prePlayerCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095D30; preYoshiCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095F50; @@ -303,6 +313,7 @@ SECTIONS { _vfC0__13dStageActor_cFv = 0x80065B60; _vfC4__13dStageActor_cFv = 0x80065B70; _vfC8__13dStageActor_cFP7Point2d = 0x80065CC0; + checkZoneBoundaries__13dStageActor_cFUi = 0x80064F50; __ct__8dScene_cFv = 0x800E19B0; __dt__8dScene_cFv = 0x800E1A20; @@ -336,6 +347,15 @@ SECTIONS { _vf58__8dActor_cFv = 0x8001D1C0; _vf5C__8dActor_cFv = 0x8001D1B0; + __ct__9StateBaseFPCc = 0x8015F7C0; + __dt__9StateBaseFv = 0x8015F800; + isInvalid__9StateBaseFv = 0x8015F840; + isEqualNotUsedForSomeReason__9StateBaseFP9StateBase = 0x8015F850; + isEqual__9StateBaseFP9StateBase = 0x8015F8C0; + isNotEqual__9StateBaseFP9StateBase = 0x8015F8D0; + getName__9StateBaseFv = 0x8015F920; + getID__9StateBaseFv = 0x8015F930; + __ct__7PhysicsFv = 0x8007F7A0; setup__7PhysicsFP8dActor_cPQ27Physics4InfoUcUcP7Point2d = 0x8007FB10; addToList__7PhysicsFv = 0x8007F900; @@ -586,6 +606,7 @@ SECTIONS { strncpy = 0x802E19F8; strcmp = 0x802E1AB4; sprintf = 0x802E17DC; + strrchr = 0x802E1C40; wcslen = 0x802E441C; @@ -976,12 +997,14 @@ SECTIONS { SomeWipeClass = 0x8042A440; QueryGlobal5758 = 0x800B3B50; + .text : { FILL (0) __text_start = . ; *(.init) *(.text) + __ctor_loc = . ; *(.ctors) *(.dtors) *(.rodata) diff --git a/kamek_pal.x b/kamek_pal.x index b4666bc..07293c0 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -101,6 +101,9 @@ SECTIONS { __construct_new_array = 0x802DCAD0;
__destroy_new_array = 0x802DCE00;
+ __register_global_object = 0x802DCA70;
+ __ptmf_scall = 0x802DCEEC;
+
setup__13FunctionChainFPPFPv_bUs = 0x8015F740;
@@ -144,12 +147,19 @@ SECTIONS { downMove_DiffEnd_End__15daEnBlockMain_cFv = 0x800232E0;
blockInit__15daEnBlockMain_cFf = 0x80021690;
blockUpdate__15daEnBlockMain_cFv = 0x800217B0;
+ blockResult__15daEnBlockMain_cFv = 0x800212C0;
PhysicsCallback1__15daEnBlockMain_c = 0x80021180;
PhysicsCallback2__15daEnBlockMain_c = 0x80021170;
PhysicsCallback3__15daEnBlockMain_c = 0x800211A0;
OPhysicsCallback1__15daEnBlockMain_c = 0x80020BF0;
OPhysicsCallback2__15daEnBlockMain_c = 0x80020E70;
OPhysicsCallback3__15daEnBlockMain_c = 0x80021010;
+ StateID_UpMove__15daEnBlockMain_c = 0x80352D34;
+ StateID_DownMove__15daEnBlockMain_c = 0x80352D74;
+ StateID_DownMoveEnd__15daEnBlockMain_c = 0x80352DB4;
+ StateID_UpMove_Diff__15daEnBlockMain_c = 0x80352DF4;
+ StateID_DownMove_Diff__15daEnBlockMain_c = 0x80352E34;
+ StateID_DownMove_DiffEnd__15daEnBlockMain_c = 0x80352E74;
__ct__5dEn_cFv = 0x80094E80;
afterCreate__5dEn_cFi = 0x800951D0;
@@ -160,7 +170,7 @@ SECTIONS { _vf8C__5dEn_cFPv = 0x80097D30;
_vfCC__5dEn_cFP7Point2d = 0x800973F0;
_vfD0__5dEn_cFP7Point2d = 0x800974F0;
- doStateChange__5dEn_cFPv = 0x800A7DF0;
+ doStateChange__5dEn_cFP9StateBase = 0x800A7DF0;
preSpriteCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095CE0;
prePlayerCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095D30;
preYoshiCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0x80095F50;
@@ -303,6 +313,7 @@ SECTIONS { _vfC0__13dStageActor_cFv = 0x80065B60;
_vfC4__13dStageActor_cFv = 0x80065B70;
_vfC8__13dStageActor_cFP7Point2d = 0x80065CC0;
+ checkZoneBoundaries__13dStageActor_cFUi = 0x80064F50;
__ct__8dScene_cFv = 0x800E1AA0;
__dt__8dScene_cFv = 0x800E1B10;
@@ -336,6 +347,15 @@ SECTIONS { _vf58__8dActor_cFv = 0x8001D1C0;
_vf5C__8dActor_cFv = 0x8001D1B0;
+ __ct__9StateBaseFPCc = 0x8015F900;
+ __dt__9StateBaseFv = 0x8015F940;
+ isInvalid__9StateBaseFv = 0x8015F980;
+ isEqualNotUsedForSomeReason__9StateBaseFP9StateBase = 0x8015F990;
+ isEqual__9StateBaseFP9StateBase = 0x8015FA00;
+ isNotEqual__9StateBaseFP9StateBase = 0x8015FA10;
+ getName__9StateBaseFv = 0x8015FA60;
+ getID__9StateBaseFv = 0x8015FA70;
+
__ct__7PhysicsFv = 0x8007F7A0;
setup__7PhysicsFP8dActor_cPQ27Physics4InfoUcUcP7Point2d = 0x8007FB10;
addToList__7PhysicsFv = 0x8007F900;
@@ -586,6 +606,7 @@ SECTIONS { strncpy = 0x802E1CE8;
strcmp = 0x802E1DA4;
sprintf = 0x802E1ACC;
+ strrchr = 0x802E1F30;
wcslen = 0x802E470C;
@@ -976,12 +997,14 @@ SECTIONS { SomeWipeClass = 0x8042A720;
QueryGlobal5758 = 0x800B3B50;
+
.text : {
FILL (0)
__text_start = . ;
*(.init)
*(.text)
+ __ctor_loc = . ;
*(.ctors)
*(.dtors)
*(.rodata)
diff --git a/kamek_pal2.x b/kamek_pal2.x index 4f76bfd..49bd37f 100644 --- a/kamek_pal2.x +++ b/kamek_pal2.x @@ -101,6 +101,9 @@ SECTIONS { __construct_new_array = 0xDEADBEEF; __destroy_new_array = 0xDEADBEEF; + __register_global_object = 0xDEADBEEF; + __ptmf_scall = 0xDEADBEEF; + setup__13FunctionChainFPPFPv_bUs = 0xDEADBEEF; @@ -144,12 +147,19 @@ SECTIONS { downMove_DiffEnd_End__15daEnBlockMain_cFv = 0xDEADBEEF; blockInit__15daEnBlockMain_cFf = 0xDEADBEEF; blockUpdate__15daEnBlockMain_cFv = 0xDEADBEEF; + blockResult__15daEnBlockMain_cFv = 0xDEADBEEF; PhysicsCallback1__15daEnBlockMain_c = 0xDEADBEEF; PhysicsCallback2__15daEnBlockMain_c = 0xDEADBEEF; PhysicsCallback3__15daEnBlockMain_c = 0xDEADBEEF; OPhysicsCallback1__15daEnBlockMain_c = 0xDEADBEEF; OPhysicsCallback2__15daEnBlockMain_c = 0xDEADBEEF; OPhysicsCallback3__15daEnBlockMain_c = 0xDEADBEEF; + StateID_UpMove__15daEnBlockMain_c = 0xDEADBEEF; + StateID_DownMove__15daEnBlockMain_c = 0xDEADBEEF; + StateID_DownMoveEnd__15daEnBlockMain_c = 0xDEADBEEF; + StateID_UpMove_Diff__15daEnBlockMain_c = 0xDEADBEEF; + StateID_DownMove_Diff__15daEnBlockMain_c = 0xDEADBEEF; + StateID_DownMove_DiffEnd__15daEnBlockMain_c = 0xDEADBEEF; __ct__5dEn_cFv = 0xDEADBEEF; afterCreate__5dEn_cFi = 0xDEADBEEF; @@ -160,7 +170,7 @@ SECTIONS { _vf8C__5dEn_cFPv = 0xDEADBEEF; _vfCC__5dEn_cFP7Point2d = 0xDEADBEEF; _vfD0__5dEn_cFP7Point2d = 0xDEADBEEF; - doStateChange__5dEn_cFPv = 0xDEADBEEF; + doStateChange__5dEn_cFP9StateBase = 0xDEADBEEF; preSpriteCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0xDEADBEEF; prePlayerCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0xDEADBEEF; preYoshiCollision__5dEn_cFP13ActivePhysicsP13ActivePhysics = 0xDEADBEEF; @@ -303,6 +313,7 @@ SECTIONS { _vfC0__13dStageActor_cFv = 0xDEADBEEF; _vfC4__13dStageActor_cFv = 0xDEADBEEF; _vfC8__13dStageActor_cFP7Point2d = 0xDEADBEEF; + checkZoneBoundaries__13dStageActor_cFUi = 0xDEADBEEF; __ct__8dScene_cFv = 0xDEADBEEF; __dt__8dScene_cFv = 0xDEADBEEF; @@ -336,6 +347,15 @@ SECTIONS { _vf58__8dActor_cFv = 0xDEADBEEF; _vf5C__8dActor_cFv = 0xDEADBEEF; + __ct__9StateBaseFPCc = 0xDEADBEEF; + __dt__9StateBaseFv = 0xDEADBEEF; + isInvalid__9StateBaseFv = 0xDEADBEEF; + isEqualNotUsedForSomeReason__9StateBaseFP9StateBase = 0xDEADBEEF; + isEqual__9StateBaseFP9StateBase = 0xDEADBEEF; + isNotEqual__9StateBaseFP9StateBase = 0xDEADBEEF; + getName__9StateBaseFv = 0xDEADBEEF; + getID__9StateBaseFv = 0xDEADBEEF; + __ct__7PhysicsFv = 0xDEADBEEF; setup__7PhysicsFP8dActor_cPQ27Physics4InfoUcUcP7Point2d = 0xDEADBEEF; addToList__7PhysicsFv = 0xDEADBEEF; @@ -586,6 +606,7 @@ SECTIONS { strncpy = 0xDEADBEEF; strcmp = 0xDEADBEEF; sprintf = 0xDEADBEEF; + strrchr = 0xDEADBEEF; wcslen = 0xDEADBEEF; @@ -976,12 +997,14 @@ SECTIONS { SomeWipeClass = 0xDEADBEEF; QueryGlobal5758 = 0xDEADBEEF; + .text : { FILL (0) __text_start = . ; *(.init) *(.text) + __ctor_loc = . ; *(.ctors) *(.dtors) *(.rodata) diff --git a/prolog.yaml b/prolog.yaml new file mode 100644 index 0000000..ce7200d --- /dev/null +++ b/prolog.yaml @@ -0,0 +1,9 @@ +--- +source_files: [../src/prolog.S] +hooks: + - name: Prolog + type: branch_insn + branch_type: b + src_addr_pal: 0x8015BC70 + target_func: 'Prolog' + diff --git a/src/prolog.S b/src/prolog.S new file mode 100644 index 0000000..1a988ec --- /dev/null +++ b/src/prolog.S @@ -0,0 +1,65 @@ +.text +.align 4 +.set sp, 1 + +.extern __ctor_loc +.extern OSReport + +.global Prolog +Prolog: + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + stw r31, 0xC(sp) + stw r30, 0x8(sp) + # -- Go! + + li r30, 0 + + lis r31, __ctor_loc@h + ori r31, r31, __ctor_loc@l + + lis r3, PMsg@h + ori r3, r3, PMsg@l + mr r4, r31 + crclr 4*cr1+eq + bl OSReport + + b startLoop + +loop: + mtctr r12 + bctrl + addi r31, r31, 4 + addi r30, r30, 1 +startLoop: + lwz r12, 0(r31) + cmpwi r12, 0 + bne loop + + lis r3, PMsg2@h + ori r3, r3, PMsg2@l + mr r4, r30 + crclr 4*cr1+eq + bl OSReport + + # -- Done + li r3, 1 + lwz r31, 0xC(sp) + lwz r30, 0x8(sp) + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + +.data +PMsg: + .string "Newer Super Mario Bros. Wii - Hacks by Treeki 2009-2011\n.ctors: %p\n" + +PMsg2: + .string "%d inits called\n" + +.align 4 + + diff --git a/src/testblock.cpp b/src/testblock.cpp index 45d2ef7..93ba8ea 100644 --- a/src/testblock.cpp +++ b/src/testblock.cpp @@ -5,6 +5,8 @@ class daEnTestBlock_c : public daEnBlockMain_c { public: + typedef State<daEnTestBlock_c> State; + TileRenderer tile; Physics::Info physicsInfo; @@ -12,9 +14,25 @@ public: int onDelete(); int onExecute(); + void calledWhenUpMoveExecutes(); + void calledWhenDownMoveExecutes(); + + void wait_Begin(); + void wait_Execute(); + void wait_End(); + + void blockWasHit(bool isDown); + + static State StateID_Wait; static daEnTestBlock_c *build(); }; +daEnTestBlock_c::State daEnTestBlock_c::StateID_Wait( + "daEnTestBlock_c::StateID_Wait", + &daEnTestBlock_c::wait_Begin, + &daEnTestBlock_c::wait_Execute, + &daEnTestBlock_c::wait_End); + int daEnTestBlock_c::onCreate() { blockInit(pos.y); @@ -42,6 +60,12 @@ int daEnTestBlock_c::onCreate() { tile.y = -(16 + pos.y); tile.tileNumber = 0x30; + //OSReport("Sanity Checks... _414=%x\n", offsetof(dEn_c,_414)); + //OSReport("acState=%x\n", offsetof(dActorMultiState_c,acState)); + //OSReport("_530=%x\n", offsetof(dEn_c,_530)); + + doStateChange(&daEnTestBlock_c::StateID_Wait); + return true; } @@ -57,6 +81,7 @@ int daEnTestBlock_c::onDelete() { int daEnTestBlock_c::onExecute() { + acState.execute(); physics.update(); blockUpdate(); @@ -64,7 +89,9 @@ int daEnTestBlock_c::onExecute() { tile.setVars(scale.x); // now check zone bounds based on state - // todo + if (acState.getCurrentState()->isEqual(&StateID_Wait)) { + checkZoneBoundaries(0); + } return true; } @@ -81,3 +108,57 @@ daEnTestBlock_c *daEnTestBlock_c::build() { return c; } + +void daEnTestBlock_c::blockWasHit(bool isDown) { + OSReport("I'm a block, and I was hit.\n"); + + //This code makes the block unhittable + //physicsInfo.otherCallback1 = 0; + //physicsInfo.otherCallback2 = 0; + //physicsInfo.otherCallback3 = 0; + + physics.setup(this, &physicsInfo, 3, currentLayerID); + //physics.flagsMaybe &= ~0x200; + physics.addToList(); + + doStateChange(&StateID_Wait); +} + + + +void daEnTestBlock_c::calledWhenUpMoveExecutes() { + if (initialY >= pos.y) + blockWasHit(false); +} + +void daEnTestBlock_c::calledWhenDownMoveExecutes() { + if (initialY <= pos.y) + blockWasHit(true); +} + + + +void daEnTestBlock_c::wait_Begin() { +} + +void daEnTestBlock_c::wait_End() { +} + +void daEnTestBlock_c::wait_Execute() { + int result = blockResult(); + + if (result == 0) + return; + + if (result == 1) { + doStateChange(&daEnBlockMain_c::StateID_UpMove); + anotherFlag = 2; + isGroundPound = false; + } else { + doStateChange(&daEnBlockMain_c::StateID_DownMove); + anotherFlag = 1; + isGroundPound = true; + } +} + + |