diff options
Diffstat (limited to '')
-rw-r--r-- | NewerProject.yaml | 1 | ||||
-rw-r--r-- | eventblock.yaml | 7 | ||||
-rw-r--r-- | src/eventblock.cpp | 164 | ||||
-rw-r--r-- | src/testblock.cpp | 2 |
4 files changed, 174 insertions, 0 deletions
diff --git a/NewerProject.yaml b/NewerProject.yaml index ff05041..ee2ee77 100644 --- a/NewerProject.yaml +++ b/NewerProject.yaml @@ -23,3 +23,4 @@ modules: - processed/compression.yaml
# - processed/actorlog.yaml
- processed/testblock.yaml
+ - processed/eventblock.yaml
diff --git a/eventblock.yaml b/eventblock.yaml new file mode 100644 index 0000000..8a96a66 --- /dev/null +++ b/eventblock.yaml @@ -0,0 +1,7 @@ +--- +source_files: [../src/eventblock.cpp] +hooks: + - name: BuildEventBlock + type: add_func_pointer + src_addr_pal: 0x80970DB8 + target_func: 'daEnEventBlock_c::build(void)' diff --git a/src/eventblock.cpp b/src/eventblock.cpp new file mode 100644 index 0000000..ad4e5e8 --- /dev/null +++ b/src/eventblock.cpp @@ -0,0 +1,164 @@ +#include <common.h> +#include <game.h> + +// Patches MIST_INTERMITTENT (sprite 239) + +class daEnEventBlock_c : public daEnBlockMain_c { +public: + typedef State<daEnEventBlock_c> State; + + TileRenderer tile; + Physics::Info physicsInfo; + + u8 eventNum; + + int onCreate(); + 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 daEnEventBlock_c *build(); +}; + +daEnEventBlock_c::State daEnEventBlock_c::StateID_Wait( + "daEnEventBlock_c::StateID_Wait", + &daEnEventBlock_c::wait_Begin, + &daEnEventBlock_c::wait_Execute, + &daEnEventBlock_c::wait_End); + + +int daEnEventBlock_c::onCreate() { + blockInit(pos.y); + + physicsInfo.x1 = -8; + physicsInfo.y1 = 16; + physicsInfo.x2 = 8; + physicsInfo.y2 = 0; + + physicsInfo.otherCallback1 = &daEnBlockMain_c::OPhysicsCallback1; + physicsInfo.otherCallback2 = &daEnBlockMain_c::OPhysicsCallback2; + physicsInfo.otherCallback3 = &daEnBlockMain_c::OPhysicsCallback3; + + physics.setup(this, &physicsInfo, 3, currentLayerID); + physics.flagsMaybe = 0x260; + physics.callback1 = &daEnBlockMain_c::PhysicsCallback1; + physics.callback2 = &daEnBlockMain_c::PhysicsCallback2; + physics.callback3 = &daEnBlockMain_c::PhysicsCallback3; + physics.addToList(); + + TileRenderer::List *list = dBgGm_c::instance->getTileRendererList(0); + list->add(&tile); + + tile.x = pos.x - 8; + tile.y = -(16 + pos.y); + tile.tileNumber = 0x97; + + eventNum = (settings & 0xFF) - 1; + doStateChange(&daEnEventBlock_c::StateID_Wait); + + return true; +} + + +int daEnEventBlock_c::onDelete() { + TileRenderer::List *list = dBgGm_c::instance->getTileRendererList(0); + list->remove(&tile); + + physics.removeFromList(); + + return true; +} + + +int daEnEventBlock_c::onExecute() { + acState.execute(); + physics.update(); + blockUpdate(); + + tile.setPosition(pos.x-8, -(16+pos.y), pos.z); + tile.setVars(scale.x); + + tile.tileNumber = (dFlagMgr_c::instance->active(eventNum) ? 0x96 : 0x97); + + // now check zone bounds based on state + if (acState.getCurrentState()->isEqual(&StateID_Wait)) { + checkZoneBoundaries(0); + } + + return true; +} + + +daEnEventBlock_c *daEnEventBlock_c::build() { + OSReport("Creating EventBlock\n"); + + void *buffer = AllocFromGameHeap1(sizeof(daEnEventBlock_c)); + daEnEventBlock_c *c = new(buffer) daEnEventBlock_c; + + OSReport("Created EventBlock @ %p\n", c); + + return c; +} + + +void daEnEventBlock_c::blockWasHit(bool isDown) { + pos.y = initialY; + + if (dFlagMgr_c::instance->active(eventNum)) + dFlagMgr_c::instance->set(eventNum, 0, false, false, false); + else + dFlagMgr_c::instance->set(eventNum, 0, true, false, false); + + physics.setup(this, &physicsInfo, 3, currentLayerID); + physics.addToList(); + + doStateChange(&StateID_Wait); +} + + + +void daEnEventBlock_c::calledWhenUpMoveExecutes() { + if (initialY >= pos.y) + blockWasHit(false); +} + +void daEnEventBlock_c::calledWhenDownMoveExecutes() { + if (initialY <= pos.y) + blockWasHit(true); +} + + + +void daEnEventBlock_c::wait_Begin() { +} + +void daEnEventBlock_c::wait_End() { +} + +void daEnEventBlock_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; + } +} + + diff --git a/src/testblock.cpp b/src/testblock.cpp index 93ba8ea..73f3adb 100644 --- a/src/testblock.cpp +++ b/src/testblock.cpp @@ -112,6 +112,8 @@ daEnTestBlock_c *daEnTestBlock_c::build() { void daEnTestBlock_c::blockWasHit(bool isDown) { OSReport("I'm a block, and I was hit.\n"); + pos.y = initialY; + //This code makes the block unhittable //physicsInfo.otherCallback1 = 0; //physicsInfo.otherCallback2 = 0; |