From c6c8bdfaf7c5462104290154f815a11f32a6b7cc Mon Sep 17 00:00:00 2001 From: Treeki Date: Mon, 1 Oct 2012 04:23:06 +0200 Subject: fuck I have spent SO LONG on fixing this bug --- src/fileselect.S | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fileselect.S b/src/fileselect.S index 8e9249e..a10a474 100644 --- a/src/fileselect.S +++ b/src/fileselect.S @@ -263,7 +263,54 @@ DSFICopyLoop: blt DSFICopyLoop blr -.align 4 +.extern SaveFileInstance +.extern SaveFileBuffer +.extern GetBlock__8SaveFileFi +.global FixUpExistingSavefile +FixUpExistingSavefile: + stwu r1, -0x10(r1) + mflr r0 + stw r0, 0x14(r1) + stw r31, 0xC(r1) + + li r31, 0 +fixupNextBlock: + lis r3, SaveFileInstance@h + ori r3, r3, SaveFileInstance@l + lwz r3, 0(r3) + mr r4, r31 + bl GetBlock__8SaveFileFi + + lbz r4, 2(r3) + clrlwi. r4, r4, 31 + beq dontFixThisOne + bl DefaultSavefileInfo +dontFixThisOne: + + lis r3, SaveFileBuffer@h + ori r3, r3, SaveFileBuffer@l + addi r3, r3, 0x6A0 + mulli r4, r31, 0x980 + add r3, r3, r4 + lbz r4, 2(r3) + clrlwi. r4, r4, 31 + beq dontFixThisOne2 + bl DefaultSavefileInfo +dontFixThisOne2: + + addi r31, r31, 1 + cmpwi r31, 6 + blt fixupNextBlock + + lwz r31, 0xC(r1) + lwz r0, 0x14(r1) + mtlr r0 + addi r1, r1, 0x10 + blr + + +#.section .ctors,4 +#.long FixUpExistingSavefile .data FSStateDebugStr: .string "State: %s\n" @@ -305,8 +352,10 @@ DefaultSavefileInfoData: .long 0xFFFF99FF,0x1FB423FF .long 0x173714FF,0x3C9135FF .long 0xFFFF99FF,0x1FB423FF -.short 0x75,0x2E,0xB +.short 0x75 +.byte 0x2E,0xB .byte 0,1 +.byte 0,0 DefaultSavefileInfoDataEnd: .long 0 -- cgit v1.2.3 From 6956c9fa2f56c2fa5af8ace0dbe298ab2a6c201b Mon Sep 17 00:00:00 2001 From: Treeki Date: Mon, 1 Oct 2012 04:55:05 +0200 Subject: fix to the last level star on the HUD --- src/koopatlas/hud.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 7046e77..7a1b9a6 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -490,14 +490,15 @@ void dWMHud_c::loadFooterInfo() { // Star 1: all exits complete // Star 2: all star coins obtained - int lastLevelID = 27; // airship - if (save->newerWorldID >= 10) - lastLevelID = 24; // fortress - else if (save->newerWorldID == 8) - lastLevelID = 25; // final castle + static int lastLevelIDs[] = { + -1, /*no world*/ + 27, 27, 27, 27, 27, 27, 27, 25, + -1, /*no end level in W9*/ + 24, 24, 24, 3, 5 + }; dLevelInfo_c *linfo = &dScKoopatlas_c::instance->levelInfo; - dLevelInfo_c::entry_s *lastLevel = linfo->searchByDisplayNum(save->newerWorldID, lastLevelID); + dLevelInfo_c::entry_s *lastLevel = linfo->searchByDisplayNum(save->newerWorldID, lastLevelIDs[save->newerWorldID]); bool lastComplete = false; if (lastLevel) { lastComplete = (save->GetLevelCondition(lastLevel->worldSlot,lastLevel->levelSlot) & COND_NORMAL); -- cgit v1.2.3 From 5c846f6c4e8600b84d7c2971e4d467cda2d7d521 Mon Sep 17 00:00:00 2001 From: Treeki Date: Mon, 1 Oct 2012 05:16:17 +0200 Subject: fixed positioning of HUD stars --- src/koopatlas/hud.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 7a1b9a6..bcfab17 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -497,15 +497,18 @@ void dWMHud_c::loadFooterInfo() { 24, 24, 24, 3, 5 }; + bool starVisibility[3]; + starVisibility[0] = false; + dLevelInfo_c *linfo = &dScKoopatlas_c::instance->levelInfo; dLevelInfo_c::entry_s *lastLevel = linfo->searchByDisplayNum(save->newerWorldID, lastLevelIDs[save->newerWorldID]); - bool lastComplete = false; if (lastLevel) { - lastComplete = (save->GetLevelCondition(lastLevel->worldSlot,lastLevel->levelSlot) & COND_NORMAL); + starVisibility[0] = (save->GetLevelCondition(lastLevel->worldSlot,lastLevel->levelSlot) & COND_NORMAL); } // now calculate the other two - bool haveExits = true, haveCoins = true; + starVisibility[1] = true; + starVisibility[2] = true; dLevelInfo_c::section_s *sect = linfo->getSectionByIndex(save->newerWorldID); @@ -515,17 +518,25 @@ void dWMHud_c::loadFooterInfo() { if (((entry->flags & 0x10) && !(conds & COND_NORMAL)) || ((entry->flags & 0x20) && !(conds & COND_SECRET))) - haveExits = false; + starVisibility[1] = false; if (entry->flags & 2) { if ((conds & COND_COIN_ALL) != COND_COIN_ALL) - haveCoins = false; + starVisibility[2] = false; + } + } + + float startX = Star[0]->trans.x; + for (int i = 0; i < 3; i++) { + Star[i]->SetVisible(starVisibility[i]); + Star[i]->trans.x = startX; + if (starVisibility[i]) { + startX += Star[i]->size.x + 4.0f; } } - Star[0]->SetVisible(lastComplete); - Star[1]->SetVisible(haveExits); - Star[2]->SetVisible(haveCoins); + WorldName->trans.x = startX + 4.0f; + WorldNameS->trans.x = startX + 6.0f; } -- cgit v1.2.3 From b8b7c83fc30e8436de4138809d5691187c74887e Mon Sep 17 00:00:00 2001 From: Treeki Date: Mon, 1 Oct 2012 05:42:48 +0200 Subject: textwriter font is now preserved --- src/randomcrap.S | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/randomcrap.S b/src/randomcrap.S index 36bbde7..ea2b301 100644 --- a/src/randomcrap.S +++ b/src/randomcrap.S @@ -1,4 +1,24 @@ .text +.global TextWriterCrap +.extern TextWriterCrapContinue +TextWriterCrap: + lis r6, 0xFFFF + ori r6, r6, 0xFF00 + lwz r0, 8(r5) + or r0, r0, r6 + stw r0, 0x18(r1) + lwz r0, 0xC(r5) + or r0, r0, r6 + stw r0, 0x1C(r1) + lwz r0, 0x10(r5) + or r0, r0, r6 + stw r0, 0x20(r1) + lwz r0, 0x14(r5) + or r0, r0, r6 + stw r0, 0x24(r1) + + b TextWriterCrapContinue + .global HeapChangeAttempt HeapChangeAttempt: lis 4, 0x8037 -- cgit v1.2.3 From aa0105c53dc74583831c88761e542f1d1baee463 Mon Sep 17 00:00:00 2001 From: Treeki Date: Mon, 1 Oct 2012 23:51:12 +0200 Subject: untested flip block --- src/flipblock.cpp | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 src/flipblock.cpp (limited to 'src') 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 +#include + +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(); +} + -- cgit v1.2.3 From 21d8492ded507f8f09bc28919b8d351b86fa0dd0 Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 2 Oct 2012 00:40:23 +0200 Subject: completed flip block --- src/flipblock.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/flipblock.cpp b/src/flipblock.cpp index c521e87..a9db0fa 100644 --- a/src/flipblock.cpp +++ b/src/flipblock.cpp @@ -159,14 +159,14 @@ void daEnFlipBlock_c::executeState_Wait() { void daEnFlipBlock_c::beginState_Flipping() { - flipsRemaining = 5; + flipsRemaining = 7; physics.removeFromList(); } void daEnFlipBlock_c::executeState_Flipping() { if (isGroundPound) - rot.x += 0x200; + rot.x += 0x800; else - rot.x -= 0x200; + rot.x -= 0x800; if (rot.x == 0) { flipsRemaining--; -- cgit v1.2.3