diff options
-rw-r--r-- | NewerProjectKP.yaml | 1 | ||||
-rw-r--r-- | flipblock.yaml | 18 | ||||
-rw-r--r-- | src/flipblock.cpp | 182 | ||||
-rw-r--r-- | tools/UsedProfileAndSpriteList.txt | 5 |
4 files changed, 204 insertions, 2 deletions
diff --git a/NewerProjectKP.yaml b/NewerProjectKP.yaml index 2f66e32..4da75e1 100644 --- a/NewerProjectKP.yaml +++ b/NewerProjectKP.yaml @@ -4,6 +4,7 @@ modules: - processed/prolog.yaml # - processed/apDebug.yaml # - processed/layoutDebug.yaml + - processed/flipblock.yaml - processed/fileselect.yaml - processed/magicplatform.yaml - processed/cutScene.yaml diff --git a/flipblock.yaml b/flipblock.yaml new file mode 100644 index 0000000..0656091 --- /dev/null +++ b/flipblock.yaml @@ -0,0 +1,18 @@ +--- +source_files: [../src/flipblock.cpp] +hooks: + - name: BuildFlipBlock + type: add_func_pointer + src_addr_pal: 0x80982F34 + target_func: 'daEnFlipBlock_c::build(void)' + - name: UpdateFlipBlockSpriteInfo + type: patch + addr_pal: 0x8030D518 + # -ID- ---- -X Offs- -Y Offs- -RectX1- -RectY1- -RectX2- -RectY2- -1C- -1E- -20- -22- Flag ---- + # Orig 02EB 0000 00000000 00000000 00000000 00000000 00000000 00000000 0000 0000 0000 0000 0000 0000 + data: '0299 0000 00000000 00000000 00000000 00000000 00000100 00000100 0000 0000 0000 0000 0000 0000' + - name: FlipBlockSpriteFileInfo + type: add_func_pointer + src_addr_pal: 0x8031B048 + target_func: 'FlipBlockFileList' + # 0x8031AB4C + sprite num * 0x4 == offset diff --git a/src/flipblock.cpp b/src/flipblock.cpp new file mode 100644 index 0000000..c521e87 --- /dev/null +++ b/src/flipblock.cpp @@ -0,0 +1,182 @@ +#include <common.h> +#include <game.h> + +const char *FlipBlockFileList[] = {"block_rotate", 0}; + +class daEnFlipBlock_c : public daEnBlockMain_c { +public: + Physics::Info physicsInfo; + + int onCreate(); + int onDelete(); + int onExecute(); + int onDraw(); + + void calledWhenUpMoveExecutes(); + void calledWhenDownMoveExecutes(); + + void blockWasHit(bool isDown); + + mHeapAllocator_c allocator; + nw4r::g3d::ResFile resFile; + m3d::mdl_c model; + + int flipsRemaining; + + USING_STATES(daEnFlipBlock_c); + DECLARE_STATE(Wait); + DECLARE_STATE(Flipping); + + static daEnFlipBlock_c *build(); +}; + + +CREATE_STATE(daEnFlipBlock_c, Wait); +CREATE_STATE(daEnFlipBlock_c, Flipping); + + +int daEnFlipBlock_c::onCreate() { + allocator.link(-1, GameHeaps[0], 0, 0x20); + + resFile.data = getResource("block_rotate", "g3d/block_rotate.brres"); + model.setup(resFile.GetResMdl("block_rotate"), &allocator, 0, 1, 0); + SetupTextures_MapObj(&model, 0); + + allocator.unlink(); + + + + blockInit(pos.y); + + physicsInfo.x1 = -8; + physicsInfo.y1 = 8; + physicsInfo.x2 = 8; + physicsInfo.y2 = -8; + + 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(); + + doStateChange(&daEnFlipBlock_c::StateID_Wait); + + return true; +} + + +int daEnFlipBlock_c::onDelete() { + physics.removeFromList(); + + return true; +} + + +int daEnFlipBlock_c::onExecute() { + acState.execute(); + physics.update(); + blockUpdate(); + + // now check zone bounds based on state + if (acState.getCurrentState()->isEqual(&StateID_Wait)) { + checkZoneBoundaries(0); + } + + return true; +} + + +int daEnFlipBlock_c::onDraw() { + matrix.translation(pos.x, pos.y, pos.z); + matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z); + + model.setDrawMatrix(matrix); + model.setScale(&scale); + model.calcWorld(false); + model.scheduleForDrawing(); + + return true; +} + + +daEnFlipBlock_c *daEnFlipBlock_c::build() { + + void *buffer = AllocFromGameHeap1(sizeof(daEnFlipBlock_c)); + daEnFlipBlock_c *c = new(buffer) daEnFlipBlock_c; + + + return c; +} + + +void daEnFlipBlock_c::blockWasHit(bool isDown) { + pos.y = initialY; + + doStateChange(&StateID_Flipping); +} + + + +void daEnFlipBlock_c::calledWhenUpMoveExecutes() { + if (initialY >= pos.y) + blockWasHit(false); +} + +void daEnFlipBlock_c::calledWhenDownMoveExecutes() { + if (initialY <= pos.y) + blockWasHit(true); +} + + + +void daEnFlipBlock_c::beginState_Wait() { +} + +void daEnFlipBlock_c::endState_Wait() { +} + +void daEnFlipBlock_c::executeState_Wait() { + 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; + } +} + + +void daEnFlipBlock_c::beginState_Flipping() { + flipsRemaining = 5; + physics.removeFromList(); +} +void daEnFlipBlock_c::executeState_Flipping() { + if (isGroundPound) + rot.x += 0x200; + else + rot.x -= 0x200; + + if (rot.x == 0) { + flipsRemaining--; + if (flipsRemaining <= 0) { + doStateChange(&StateID_Wait); + } + } +} +void daEnFlipBlock_c::endState_Flipping() { + physics.setup(this, &physicsInfo, 3, currentLayerID); + physics.addToList(); +} + diff --git a/tools/UsedProfileAndSpriteList.txt b/tools/UsedProfileAndSpriteList.txt index 8011339..4f606ed 100644 --- a/tools/UsedProfileAndSpriteList.txt +++ b/tools/UsedProfileAndSpriteList.txt @@ -38,17 +38,18 @@ 250 : KAWANAGARE : Electric Line 251 : SLOW_QUICK_TAG : Topman Boss 273 : WM_KINOBALLOON : Palace Activator +279 : AC_LIFT_ICE_SPRING : Balboa Wrench 282 : EN_WALLINSECT : Mr Sun 283 : WALLINSECT_MGR : Fuzzy Bear 290 : EN_IWAO : Ramboo 302 : EN_GAKE_NOKO : Wrench +319 : WM_GRID : Flip Block 322 : EN_GHOST_JUGEM : Thwomp Boss 324 : SHIP_WINDOW : Podouble 332 : LIFT_TORIDE_ROLL : Effect Video 350 : DUMMY_DOOR_PARENT : Fire Laser 351 : DUMMY_DOOR_CHILD : Shy Guy 410 : AC_BLOCK_GROUP : Mega Goomba -XXX : AC_LIFT_ICE_SPRING : Balboa Wrench @@ -88,6 +89,7 @@ WM_BOSS_IGGY WM_CLOUD WM_DANCE_PAKKUN WM_GHOST +WM_GRID WM_KILLER WM_KILLERBULLET WM_KINOBALLOON @@ -127,7 +129,6 @@ WM_CS_W3_PALM WM_DIRECTOR WM_DOKAN WM_DOKANROUTE -WM_GRID WM_HANACHAN WM_IBARA WM_ISLAND |