summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorTharo <17233964+Thar0@users.noreply.github.com>2021-10-24 17:41:50 +0100
committerGitHub <noreply@github.com>2021-10-24 13:41:50 -0300
commitef53ba82614ae64043101360931af2ee2dd11fea (patch)
treed413571c6d26d8806852d5f05ef8b62f9ea4cb3a /src/code
parentb2747aa8b4186034d6621e8e3eccc44d14ec27a7 (diff)
z_game_over.c (#263)
* game over * Fixes * Revert save field rename * Fix comment indent Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com> * Add bss reordering stuff, fix bss reordering in z_scene_proc * Enum uggestions, fix item id * link -> player in enum comments Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com> Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com>
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_game_over.c116
-rw-r--r--src/code/z_kankyo.c6
2 files changed, 116 insertions, 6 deletions
diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c
index 412cb7080..c510c1974 100644
--- a/src/code/z_game_over.c
+++ b/src/code/z_game_over.c
@@ -1,7 +1,117 @@
#include "global.h"
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_game_over/func_801AA610.s")
+void GameOver_Init(GlobalContext* globalCtx) {
+ globalCtx->gameOverCtx.state = GAMEOVER_INACTIVE;
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_game_over/func_801AA624.s")
+void GameOver_FadeLights(GlobalContext* globalCtx) {
+ GameOverContext* gameOverCtx = &globalCtx->gameOverCtx;
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_game_over/func_801AA68C.s")
+ 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);
+ }
+}
+
+static s16 sGameOverTimer = 0;
+
+void GameOver_Update(GlobalContext* globalCtx) {
+ GameOverContext* gameOverCtx = &globalCtx->gameOverCtx;
+ s16 i;
+
+ switch (gameOverCtx->state) {
+ case GAMEOVER_DEATH_START:
+ func_801477B4(globalCtx);
+
+ for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) {
+ gSaveContext.unk_3DD0[i] = 0;
+ }
+
+ gSaveContext.eventInf[1] &= ~1;
+
+ if (CUR_FORM == 0) {
+ if (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI &&
+ CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR &&
+ CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED &&
+ CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_DEITY) {
+
+ if (gSaveContext.buttonStatus[0] != BTN_ENABLED) {
+ CUR_FORM_EQUIP(EQUIP_SLOT_B) = gSaveContext.buttonStatus[0];
+ } else {
+ CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE;
+ }
+ }
+ }
+
+ gSaveContext.unk_3DC0 = 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] = BTN_ENABLED;
+ gSaveContext.buttonStatus[1] = BTN_ENABLED;
+ gSaveContext.buttonStatus[2] = BTN_ENABLED;
+ gSaveContext.buttonStatus[3] = BTN_ENABLED;
+ gSaveContext.buttonStatus[4] = BTN_ENABLED;
+ gSaveContext.unk_3F1E = 0;
+ gSaveContext.unk_3F20 = 0;
+ gSaveContext.unk_3F22 = 0;
+ gSaveContext.unk_3F24 = 0;
+ Kankyo_InitGameOverLights(globalCtx);
+ sGameOverTimer = 20;
+ func_8013ECE0(0.0f, 126, 124, 63);
+ gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND;
+ break;
+ case GAMEOVER_DEATH_FADE_OUT:
+ if (func_801A8A50(1) != 32) {
+ func_80169F78(globalCtx);
+ if (gSaveContext.respawnFlag != -7) {
+ gSaveContext.respawnFlag = -6;
+ }
+ gSaveContext.nextTransition = 2;
+ gSaveContext.health = 48;
+ gameOverCtx->state++;
+ if (gSaveContext.inventory.items[SLOT(ITEM_MASK_DEKU)] == ITEM_MASK_DEKU) {
+ gSaveContext.playerForm = PLAYER_FORM_HUMAN;
+ gSaveContext.equippedMask = PLAYER_MASK_NONE;
+ }
+ func_8013EE24();
+ }
+ break;
+ case GAMEOVER_REVIVE_START:
+ gameOverCtx->state++;
+ sGameOverTimer = 0;
+ Kankyo_InitGameOverLights(globalCtx);
+ ShrinkWindow_SetLetterboxTarget(32);
+ break;
+ case GAMEOVER_REVIVE_RUMBLE:
+ sGameOverTimer = 50;
+ gameOverCtx->state++;
+ func_8013ECE0(0.0f, 126, 124, 63);
+ break;
+ case GAMEOVER_REVIVE_WAIT_GROUND:
+ sGameOverTimer--;
+ if (sGameOverTimer == 0) {
+ sGameOverTimer = 64;
+ gameOverCtx->state++;
+ }
+ break;
+ case GAMEOVER_REVIVE_WAIT_FAIRY:
+ sGameOverTimer--;
+ if (sGameOverTimer == 0) {
+ sGameOverTimer = 50;
+ gameOverCtx->state++;
+ }
+ break;
+ case GAMEOVER_REVIVE_FADE_OUT:
+ Kankyo_FadeOutGameOverLights(globalCtx);
+ sGameOverTimer--;
+ if (sGameOverTimer == 0) {
+ gameOverCtx->state = GAMEOVER_INACTIVE;
+ }
+ break;
+ }
+}
diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c
index 22c96883e..6221e0910 100644
--- a/src/code/z_kankyo.c
+++ b/src/code/z_kankyo.c
@@ -74,11 +74,11 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FBCBC.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FBDEC.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_InitGameOverLights.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FBF3C.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_FadeInGameOverLights.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC158.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_FadeOutGameOverLights.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC3DC.s")