summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorfig02 <fig02srl@gmail.com>2021-03-28 19:50:46 -0400
committerGitHub <noreply@github.com>2021-03-28 19:50:46 -0400
commit1639417327f7d6b47abad29946706a54bc005af0 (patch)
treef8a86a95cbe79df2ce2bbd6b3b4c5f0ea453504e /src/code
parent187d2d1500b82658b97b23650dcc91434e33ae17 (diff)
code_80110450 (game over) OK* (#739)
* OK (sort of) * remove hack * clean up comments
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_80110450.c7
-rw-r--r--src/code/z_en_item00.c2
-rw-r--r--src/code/z_frame_advance.c2
-rw-r--r--src/code/z_game_over.c150
-rw-r--r--src/code/z_kaleido_setup.c4
-rw-r--r--src/code/z_kankyo.c6
-rw-r--r--src/code/z_parameter.c15
-rw-r--r--src/code/z_play.c15
8 files changed, 173 insertions, 28 deletions
diff --git a/src/code/code_80110450.c b/src/code/code_80110450.c
deleted file mode 100644
index 828d757a2..000000000
--- a/src/code/code_80110450.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "global.h"
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80110450/func_80110450.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80110450/func_80110460.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80110450/func_801104C8.s")
diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c
index c17f00b3f..3a3c45427 100644
--- a/src/code/z_en_item00.c
+++ b/src/code/z_en_item00.c
@@ -519,7 +519,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
}
}
- if (globalCtx->unk_10A20 != 0) {
+ if (globalCtx->gameOverCtx.state != GAMEOVER_INACTIVE) {
return;
}
diff --git a/src/code/z_frame_advance.c b/src/code/z_frame_advance.c
index caf33fafb..c8a2c64ff 100644
--- a/src/code/z_frame_advance.c
+++ b/src/code/z_frame_advance.c
@@ -24,6 +24,6 @@ s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input) {
frameAdvCtx->timer = 0;
return true;
}
-
+
return false;
}
diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c
new file mode 100644
index 000000000..c978b69cf
--- /dev/null
+++ b/src/code/z_game_over.c
@@ -0,0 +1,150 @@
+#include "global.h"
+
+void GameOver_Init(GlobalContext* globalCtx) {
+ globalCtx->gameOverCtx.state = GAMEOVER_INACTIVE;
+}
+
+void GameOver_FadeInLights(GlobalContext* globalCtx) {
+ GameOverContext* gameOverCtx = &globalCtx->gameOverCtx;
+
+ if ((gameOverCtx->state >= GAMEOVER_DEATH_WAIT_GROUND && gameOverCtx->state < GAMEOVER_REVIVE_START) ||
+ (gameOverCtx->state >= GAMEOVER_REVIVE_RUMBLE && gameOverCtx->state < GAMEOVER_REVIVE_FADE_OUT)) {
+ Kankyo_FadeInGameOverLights(globalCtx);
+ }
+}
+
+// This variable has the same problem as z_message's data going to rodata.
+// A fix for this is planned, and will be taken care of with z_message.
+// For now this variable is externed from z_message's rodata.s file.
+extern s16 D_80153D80; // todo: rename to `timer` and make this in function static (after rodata issue is resolved)
+
+void GameOver_Update(GlobalContext* globalCtx) {
+ GameOverContext* gameOverCtx = &globalCtx->gameOverCtx;
+ s16 i;
+ s16 j;
+ s32 v90;
+ s32 v91;
+ s32 v92;
+
+ switch (gameOverCtx->state) {
+ case GAMEOVER_DEATH_START:
+ func_80106CCC(globalCtx);
+
+ gSaveContext.timer1State = 0;
+ gSaveContext.timer2State = 0;
+ gSaveContext.eventInf[1] &= ~1;
+
+ // search inventory for spoiling items and revert if necessary
+ for (i = 0; i < ARRAY_COUNT(gSpoilingItems); i++) {
+ if (INV_CONTENT(ITEM_POCKET_EGG) == gSpoilingItems[i]) {
+ INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i];
+
+ // search c buttons for the found spoiling item and revert if necessary
+ for (j = 1; j < ARRAY_COUNT(gSaveContext.equips.buttonItems); j++) {
+ if (gSaveContext.equips.buttonItems[j] == gSpoilingItems[i]) {
+ gSaveContext.equips.buttonItems[j] = gSpoilingItemReverts[i];
+ Interface_LoadItemIcon1(globalCtx, j);
+ }
+ }
+ }
+ }
+
+ // restore "temporary B" to the B Button if not a sword item
+ if (gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI &&
+ gSaveContext.equips.buttonItems[0] != ITEM_SWORD_MASTER &&
+ gSaveContext.equips.buttonItems[0] != ITEM_SWORD_BGS &&
+ gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE) {
+
+ if (gSaveContext.buttonStatus[0] != BTN_ENABLED) {
+ gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0];
+ } else {
+ gSaveContext.equips.buttonItems[0] = ITEM_NONE;
+ }
+ }
+
+ gSaveContext.nayrusLoveTimer = 2000;
+ gSaveContext.naviTimer = 0;
+ gSaveContext.seqIndex = 0xFF;
+ gSaveContext.nightSeqIndex = 0xFF;
+ gSaveContext.eventInf[0] = 0;
+ gSaveContext.eventInf[1] = 0;
+ gSaveContext.eventInf[2] = 0;
+ gSaveContext.eventInf[3] = 0;
+ gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] =
+ gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED;
+ gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = 0;
+
+ Kankyo_InitGameOverLights(globalCtx);
+ D_80153D80 = 20;
+ if (1) {}
+ v90 = VREG(90);
+ v91 = VREG(91);
+ v92 = VREG(92);
+
+ func_800AA000(0.0f, ((v90 > 0x64) ? 0xFF : (v90 * 0xFF) / 0x64), (CLAMP_MAX(v91 * 3, 0xFF)),
+ ((v92 > 0x64) ? 0xFF : (v92 * 0xFF) / 0x64));
+
+ gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND;
+ break;
+
+ case GAMEOVER_DEATH_WAIT_GROUND:
+ break;
+
+ case GAMEOVER_DEATH_DELAY_MENU:
+ D_80153D80--;
+
+ if (D_80153D80 == 0) {
+ globalCtx->pauseCtx.state = 8;
+ gameOverCtx->state++;
+ func_800AA15C();
+ }
+ break;
+
+ case GAMEOVER_REVIVE_START:
+ gameOverCtx->state++;
+ D_80153D80 = 0;
+ Kankyo_InitGameOverLights(globalCtx);
+ ShrinkWindow_SetVal(0x20);
+ return;
+
+ case GAMEOVER_REVIVE_RUMBLE:
+ D_80153D80 = 50;
+ gameOverCtx->state++;
+ if (1) {}
+
+ v90 = VREG(90);
+ v91 = VREG(91);
+ v92 = VREG(92);
+
+ func_800AA000(0.0f, ((v90 > 0x64) ? 0xFF : (v90 * 0xFF) / 0x64), (CLAMP_MAX(v91 * 3, 0xFF)),
+ ((v92 > 0x64) ? 0xFF : (v92 * 0xFF) / 0x64));
+ break;
+
+ case GAMEOVER_REVIVE_WAIT_GROUND:
+ D_80153D80--;
+
+ if (D_80153D80 == 0) {
+ D_80153D80 = 64;
+ gameOverCtx->state++;
+ }
+ break;
+
+ case GAMEOVER_REVIVE_WAIT_FAIRY:
+ D_80153D80--;
+
+ if (D_80153D80 == 0) {
+ D_80153D80 = 50;
+ gameOverCtx->state++;
+ }
+ break;
+
+ case GAMEOVER_REVIVE_FADE_OUT:
+ Kankyo_FadeOutGameOverLights(globalCtx);
+ D_80153D80--;
+
+ if (D_80153D80 == 0) {
+ gameOverCtx->state = GAMEOVER_INACTIVE;
+ }
+ break;
+ }
+}
diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c
index 779aa71ec..b63fc1441 100644
--- a/src/code/z_kaleido_setup.c
+++ b/src/code/z_kaleido_setup.c
@@ -42,8 +42,8 @@ void KaleidoSetup_Update(GlobalContext* globalCtx) {
PauseContext* pauseCtx = &globalCtx->pauseCtx;
Input* input = &globalCtx->state.input[0];
- if (pauseCtx->state == 0 && pauseCtx->flag == 0 && globalCtx->unk_10A20 == 0 && globalCtx->sceneLoadFlag == 0 &&
- globalCtx->transitionMode == 0 && gSaveContext.cutsceneIndex < 0xFFF0 &&
+ if (pauseCtx->state == 0 && pauseCtx->flag == 0 && globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE &&
+ globalCtx->sceneLoadFlag == 0 && globalCtx->transitionMode == 0 && gSaveContext.cutsceneIndex < 0xFFF0 &&
gSaveContext.nextCutsceneIndex < 0xFFF0 && !Gameplay_InCsMode(globalCtx) &&
globalCtx->shootingGalleryStatus <= 1 && gSaveContext.unk_13F0 != 8 && gSaveContext.unk_13F0 != 9 &&
(globalCtx->sceneNum != SCENE_BOWLING || !Flags_GetSwitch(globalCtx, 0x38))) {
diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c
index eccb1a799..baab19ec7 100644
--- a/src/code/z_kankyo.c
+++ b/src/code/z_kankyo.c
@@ -54,11 +54,11 @@ f32 func_800746DC() {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_80075E68.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_80075F14.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_InitGameOverLights.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800760F4.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_FadeInGameOverLights.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800763A8.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_FadeOutGameOverLights.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800766C4.s")
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c
index 51039feb3..c16001cf1 100644
--- a/src/code/z_parameter.c
+++ b/src/code/z_parameter.c
@@ -2453,8 +2453,8 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) {
case 7:
if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && (msgCtx->msgMode == 0) &&
- (globalCtx->unk_10A20 == 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->transitionMode == 0) &&
- !Gameplay_InCsMode(globalCtx)) {
+ (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (globalCtx->sceneLoadFlag == 0) &&
+ (globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx)) {
if ((gSaveContext.magic == 0) || ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) ||
((gSaveContext.equips.buttonItems[1] != ITEM_LENS) &&
(gSaveContext.equips.buttonItems[2] != ITEM_LENS) &&
@@ -3414,8 +3414,9 @@ void Interface_Draw(GlobalContext* globalCtx) {
}
}
- if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && (globalCtx->unk_10A20 == 0) &&
- (msgCtx->msgMode == 0) && !(player->stateFlags2 & 0x01000000) && (globalCtx->sceneLoadFlag == 0) &&
+ if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) &&
+ (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (msgCtx->msgMode == 0) &&
+ !(player->stateFlags2 & 0x01000000) && (globalCtx->sceneLoadFlag == 0) &&
(globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx) && (gSaveContext.minigameState != 1) &&
(globalCtx->shootingGalleryStatus <= 1) &&
!((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38))) {
@@ -3836,7 +3837,7 @@ void Interface_Update(GlobalContext* globalCtx) {
if ((gSaveContext.minigameState == 1) || (gSaveContext.sceneSetupIndex < 4) ||
((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.sceneSetupIndex == 4))) {
if ((msgCtx->msgMode == 0) || ((msgCtx->msgMode != 0) && (globalCtx->sceneNum == SCENE_BOWLING))) {
- if (globalCtx->unk_10A20 == 0) {
+ if (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) {
func_80083108(globalCtx);
}
}
@@ -4056,8 +4057,8 @@ void Interface_Update(GlobalContext* globalCtx) {
WREG(7) = interfaceCtx->unk_1F4;
if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && (msgCtx->msgMode == 0) &&
- (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_10A20 == 0) && (globalCtx->transitionMode == 0) &&
- ((globalCtx->csCtx.state == 0) || !Player_InCsMode(globalCtx))) {
+ (globalCtx->sceneLoadFlag == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) &&
+ (globalCtx->transitionMode == 0) && ((globalCtx->csCtx.state == 0) || !Player_InCsMode(globalCtx))) {
if ((gSaveContext.magicAcquired != 0) && (gSaveContext.magicLevel == 0)) {
gSaveContext.magicLevel = gSaveContext.doubleMagic + 1;
gSaveContext.unk_13F0 = 8;
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 528e2e0b6..513f754bb 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -229,7 +229,7 @@ void Gameplay_Init(GameState* thisx) {
Sram_Init(globalCtx, &globalCtx->sramCtx);
func_80112098(globalCtx);
func_80110F68(globalCtx);
- func_80110450(globalCtx);
+ GameOver_Init(globalCtx);
func_8006BA00(globalCtx);
Effect_InitContext(globalCtx);
EffectSs_InitInfo(globalCtx, 0x55);
@@ -771,7 +771,8 @@ void Gameplay_Update(GlobalContext* globalCtx) {
LOG_NUM("1", 1, "../z_play.c", 3542);
}
- if ((gSaveContext.gameMode == 0) && (globalCtx->msgCtx.msgMode == 0) && (globalCtx->unk_10A20 == 0)) {
+ if ((gSaveContext.gameMode == 0) && (globalCtx->msgCtx.msgMode == 0) &&
+ (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE)) {
KaleidoSetup_Update(globalCtx);
}
@@ -935,12 +936,12 @@ void Gameplay_Update(GlobalContext* globalCtx) {
}
KaleidoScopeCall_Update(globalCtx);
- } else if (globalCtx->unk_10A20 != 0) {
+ } else if (globalCtx->gameOverCtx.state != GAMEOVER_INACTIVE) {
if (1 && HREG(63)) {
LOG_NUM("1", 1, "../z_play.c", 3727);
}
- func_801104C8(globalCtx);
+ GameOver_Update(globalCtx);
} else {
if (1 && HREG(63)) {
LOG_NUM("1", 1, "../z_play.c", 3733);
@@ -1028,7 +1029,7 @@ skip:
}
func_80070C24(globalCtx, &globalCtx->envCtx, &globalCtx->lightCtx, &globalCtx->pauseCtx, &globalCtx->msgCtx,
- &globalCtx->unk_10A20, globalCtx->state.gfxCtx);
+ &globalCtx->gameOverCtx, globalCtx->state.gfxCtx);
}
void Gameplay_DrawOverlayElements(GlobalContext* globalCtx) {
@@ -1042,8 +1043,8 @@ void Gameplay_DrawOverlayElements(GlobalContext* globalCtx) {
func_8010F58C(globalCtx);
- if (globalCtx->unk_10A20 != 0) {
- func_80110460(globalCtx);
+ if (globalCtx->gameOverCtx.state != GAMEOVER_INACTIVE) {
+ GameOver_FadeInLights(globalCtx);
}
}