diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-10-03 12:55:15 -0500 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-10-03 12:55:15 -0500 |
commit | 34efbdba59b460a2f565c25a5ff20efb8d1077a0 (patch) | |
tree | c1729468fd611f9523e3a2bf492363e34c2fb879 /src | |
parent | c1365802c73376609e53b97440ae037b14f6324f (diff) | |
parent | 21d8492ded507f8f09bc28919b8d351b86fa0dd0 (diff) | |
download | kamek-34efbdba59b460a2f565c25a5ff20efb8d1077a0.tar.gz kamek-34efbdba59b460a2f565c25a5ff20efb8d1077a0.zip |
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
Diffstat (limited to 'src')
-rw-r--r-- | src/fileselect.S | 53 | ||||
-rw-r--r-- | src/flipblock.cpp | 182 | ||||
-rw-r--r-- | src/koopatlas/hud.cpp | 40 | ||||
-rw-r--r-- | src/randomcrap.S | 20 |
4 files changed, 279 insertions, 16 deletions
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 diff --git a/src/flipblock.cpp b/src/flipblock.cpp new file mode 100644 index 0000000..a9db0fa --- /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 = 7; + physics.removeFromList(); +} +void daEnFlipBlock_c::executeState_Flipping() { + if (isGroundPound) + rot.x += 0x800; + else + rot.x -= 0x800; + + 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/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 7046e77..bcfab17 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -490,21 +490,25 @@ 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 + }; + + bool starVisibility[3]; + starVisibility[0] = false; dLevelInfo_c *linfo = &dScKoopatlas_c::instance->levelInfo; - dLevelInfo_c::entry_s *lastLevel = linfo->searchByDisplayNum(save->newerWorldID, lastLevelID); - bool lastComplete = false; + dLevelInfo_c::entry_s *lastLevel = linfo->searchByDisplayNum(save->newerWorldID, lastLevelIDs[save->newerWorldID]); 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); @@ -514,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; } 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 |