summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-10-03 12:55:15 -0500
committerColin Noga <Tempus@chronometry.ca>2012-10-03 12:55:15 -0500
commit34efbdba59b460a2f565c25a5ff20efb8d1077a0 (patch)
treec1729468fd611f9523e3a2bf492363e34c2fb879
parentc1365802c73376609e53b97440ae037b14f6324f (diff)
parent21d8492ded507f8f09bc28919b8d351b86fa0dd0 (diff)
downloadkamek-34efbdba59b460a2f565c25a5ff20efb8d1077a0.tar.gz
kamek-34efbdba59b460a2f565c25a5ff20efb8d1077a0.zip
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
-rw-r--r--NewerProjectKP.yaml1
-rw-r--r--bugfixes.yaml5
-rw-r--r--fileselect.yaml1
-rw-r--r--flipblock.yaml18
-rwxr-xr-xinclude/game.h12
-rw-r--r--kamek_pal.x2
-rw-r--r--src/fileselect.S53
-rw-r--r--src/flipblock.cpp182
-rw-r--r--src/koopatlas/hud.cpp40
-rw-r--r--src/randomcrap.S20
-rw-r--r--tools/UsedProfileAndSpriteList.txt5
11 files changed, 313 insertions, 26 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/bugfixes.yaml b/bugfixes.yaml
index 3af6148..2d7721b 100644
--- a/bugfixes.yaml
+++ b/bugfixes.yaml
@@ -155,8 +155,5 @@ hooks:
target_func: 'ReturnNone'
- - {name: AlwaysDrawPictureFontWhite1, type: patch, addr_pal: 0x800E596C, data: '3800FFFF'}
- - {name: AlwaysDrawPictureFontWhite2, type: patch, addr_pal: 0x800E5974, data: '3800FFFF'}
- - {name: AlwaysDrawPictureFontWhite3, type: patch, addr_pal: 0x800E597C, data: '3800FFFF'}
- - {name: AlwaysDrawPictureFontWhite4, type: patch, addr_pal: 0x800E5984, data: '3800FFFF'}
+ - {name: AlwaysDrawPictureFontWhite, type: branch_insn, branch_type: b, src_addr_pal: 0x800E596C, target_func: 'TextWriterCrap'}
diff --git a/fileselect.yaml b/fileselect.yaml
index eb8c107..67bc621 100644
--- a/fileselect.yaml
+++ b/fileselect.yaml
@@ -148,6 +148,7 @@ hooks:
- {name: DFNiceWorldName, type: branch_insn, branch_type: bl, src_addr_pal: 0x8077DA10, target_func: 'DFNiceWorldName'}
- {name: DefaultSavefileInfo, type: branch_insn, branch_type: b, src_addr_pal: 0x800CE100, target_func: 'DefaultSavefileInfo'}
+ - {name: FixUpExistingSavefile, type: branch_insn, branch_type: b, src_addr_pal: 0x800CF900, target_func: 'FixUpExistingSavefile'}
# - {name: FSDebugStates, type: add_func_pointer, src_addr_pal: 0x80943E38, target_func: 'FSDebugStates'}
diff --git a/flipblock.yaml b/flipblock.yaml
new file mode 100644
index 0000000..38b6b7b
--- /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 00000008 FFFFFFF8 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/include/game.h b/include/game.h
index 91dd77a..1e0c484 100755
--- a/include/game.h
+++ b/include/game.h
@@ -170,7 +170,7 @@ bool IsWideScreen();
// All of these are set by "SetWorldCompleteionBitfield" (I didn't name it)
// at 801028D0. It's called by ScStage so it doesn't depend on Nintendo maps.
-#define SAVE_BIT_EXISTS_MAYBE 1
+#define SAVE_BIT_NEW 1
// Controls whether you can QUICK SAVE or not.
// Set if 8-Castle is complete.
@@ -190,6 +190,8 @@ bool IsWideScreen();
// Set when, well... EVERYTHING is done.
#define SAVE_BIT_EVERYTHING_TRULY_DONE 0x20
+#define SAVE_BIT_NO_SUPER_GUIDE 0x40
+
class SaveFirstBlock {
public:
@@ -243,9 +245,11 @@ public:
GXColor fsTextColours[2]; // 0x720
GXColor fsHintColours[2]; // 0x728
GXColor hudTextColours[2]; // 0x730
- s16 hudHintH, hudHintS, hudHintL; // 0x738
- u8 currentMapMusic; // 0x73E
- u8 newerWorldID; // 0x73F
+ s16 hudHintH; // 0x738
+ s8 hudHintS, hudHintL; // 0x73A
+ u8 currentMapMusic; // 0x73C
+ u8 newerWorldID; // 0x73D
+ // Pretty much full up here...
};
};
u8 toad_location[10]; // 0x742
diff --git a/kamek_pal.x b/kamek_pal.x
index 78ff6bf..fa1273b 100644
--- a/kamek_pal.x
+++ b/kamek_pal.x
@@ -1,6 +1,7 @@
SECTIONS {
/* Scrolling is annoying, clown car goes here! */
+ TextWriterCrapContinue = 0x800E598C;
StockWMInit_LoadEffects__FPv = 0x80926B10;
CleanUpEffectThings__Fv = 0x80093520;
@@ -986,6 +987,7 @@ SECTIONS {
ArchiveHeap = 0x8042A72C;
DVDClass = 0x8042A318;
GameMgrP = 0x8042A25C;
+ SaveFileBuffer = 0x8035DFC0;
SaveFileInstance = 0x8042A320;
SaveHandlerInstance = 0x8042A298;
RemoconMng = 0x8042A230;
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
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