diff --git a/include/functions.h b/include/functions.h index 300dffa21..7400f844f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1968,7 +1968,7 @@ void func_8010A33C(GlobalContext* globalCtx, s16 param_2); // void func_8010A410(void); // void func_8010A430(void); void func_8010A54C(GlobalContext* globalCtx); -// void func_8010A580(void); +// void Map_Update(void); // void func_8010A760(void); // void func_8010A7CC(void); // void func_8010A814(void); @@ -2098,7 +2098,7 @@ void func_80115D5C(GameState* gamestate); // void func_80115DB4(void); // void func_80116088(void); // void func_80116114(void); -// void func_80116348(void); +// void Interface_UpdateMagicBar(void); // void Interface_DrawMagicBar(void); // void func_80116FD8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_801170B8(void); diff --git a/include/z64.h b/include/z64.h index d82513897..0ca115d9a 100644 --- a/include/z64.h +++ b/include/z64.h @@ -750,7 +750,7 @@ typedef struct { typedef struct { /* 0x00 */ u16 unk_0; - /* 0x02 */ u16 unk_2; + /* 0x02 */ u16 timeIncrement; /* 0x04 */ f32 unk_4; /* 0x08 */ f32 unk_8; /* 0x0C */ f32 unk_C; @@ -898,14 +898,16 @@ typedef struct { /* 0x11F10 */ s32 unk11F10; /* 0x11F14 */ UNK_TYPE1 pad11F14[0xE]; /* 0x11F22 */ u8 unk11F22; - /* 0x11F23 */ UNK_TYPE1 pad11F23[0xFD]; + /* 0x11F23 */ UNK_TYPE1 pad11F23[0xE3]; + /* 0x11F23 */ s16 unk12006; + /* 0x12007 */ UNK_TYPE1 pad12007[0x18]; /* 0x12020 */ u8 unk12020; /* 0x12021 */ u8 choiceIndex; /* 0x12022 */ u8 unk12022; /* 0x12023 */ u8 unk12023; /* 0x12024 */ UNK_TYPE1 unk12024[0x6]; - /* 0x1202A */ u16 unk1202A; - /* 0x1202C */ UNK_TYPE1 pad1202C[0x2]; + /* 0x1202A */ u16 ocarinaMode; + /* 0x1202C */ u16 ocarinaAction; /* 0x1202E */ u16 unk1202E; /* 0x12030 */ UNK_TYPE1 pad12030[0x14]; /* 0x12044 */ s16 unk12044; diff --git a/include/z64item.h b/include/z64item.h index d912169f2..8aa0b45a3 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -8,7 +8,8 @@ typedef enum { /* 0x0 */ EQUIP_SWORD, - /* 0x1 */ EQUIP_SHIELD + /* 0x1 */ EQUIP_SHIELD, + /* 0x2 */ EQUIP_TUNIC // Remnant of OoT } EquipmentType; typedef enum { diff --git a/include/z64save.h b/include/z64save.h index 9d15efe01..c8d15d4de 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -189,7 +189,7 @@ typedef struct { /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" /* 0x3F55 */ u8 nextTransition; // "next_wipe" /* 0x3F56 */ s16 worldMapArea; // "area_type" - /* 0x3F58 */ s16 unk_3F58; // "sunmoon_flag" + /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" /* 0x3F5A */ s16 healthAccumulator; // "life_mode" /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" /* 0x3F60 */ u8 screenScaleFlag; // "framescale_flag" @@ -217,4 +217,11 @@ typedef enum { /* 0xFF */ BTN_DISABLED = 0xFF } ButtonStatus; +typedef enum { + /* 0 */ SUNSSONG_INACTIVE, + /* 1 */ SUNSSONG_START, // the suns ocarina effect signals that the song has finished playing + /* 2 */ SUNSSONG_SPEED_TIME, // suns was played where time passes, speed up the advancement of time + /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads +} SunsSongState; + #endif diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 079117fd4..27a83c68a 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -28,4 +28,4 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A54C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/func_8010A580.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_exp/Map_Update.s") diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 92eaa3f25..9e6a18e9e 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2,6 +2,9 @@ #include "misc/parameter_static/parameter_static.h" void func_801663C4(u8* arg0, u8* arg1, u32 arg2); +void Map_Update(GlobalContext* globalCtx); +s16 func_801242DC(GlobalContext*); // s32 func_8008F2F8 (OoT) + extern Gfx D_0E0002E0[]; // Display List extern u8 D_801ABAB0[]; extern u8 D_801E3BB0[]; @@ -139,12 +142,11 @@ s32 D_801BF888[] = { 0x00000000, }; +// sMinigameScoreTier s16 D_801BF88C = 0; -s32 D_801BF890[] = { - 0x00000000, - 0x00000000, -}; +// sMinigameScoreDigits +u16 D_801BF890[] = { 0, 0, 0, 0 }; s32 D_801BF898[] = { 0x00000000, @@ -169,9 +171,7 @@ s32 D_801BF8B0[] = { 0x00010007, 0x00070007, 0x00070008, 0x00080009, 0x00090000, }; -s32 D_801BF8DC[] = { - 0x00000000, -}; +s16 D_801BF8DC = 0; s16 D_801BF8E0 = 0; @@ -1602,6 +1602,7 @@ void func_8010F1A8(GlobalContext* globalCtx, s16 maxAlpha) { // oot func_80083108 #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80110038.s") +void func_80111CB4(GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80111CB4.s") void func_801129E4(GlobalContext* globalCtx) { @@ -1950,7 +1951,8 @@ void func_80116088(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116114.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116348.s") +void Interface_UpdateMagicBar(GlobalContext* globalCtx); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_UpdateMagicBar.s") void Interface_DrawMagicBar(GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_DrawMagicBar.s") @@ -2037,10 +2039,13 @@ void func_8011B4E0(GlobalContext* globalCtx, s16 arg1) { interfaceCtx->unk_28A[0] = 1; } +void func_8011B5C0(GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B5C0.s") +void func_8011B9E0(GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B9E0.s") +void func_8011BF70(GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011BF70.s") void func_8011C4C4(GlobalContext* globalCtx); @@ -2069,6 +2074,7 @@ void func_8011C808(GlobalContext* globalCtx) { void func_8011CA64(GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011CA64.s") +void func_8011E3B4(GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E3B4.s") void func_8011E730(GlobalContext* globalCtx); @@ -2335,7 +2341,7 @@ void Interface_Draw(GlobalContext* globalCtx) { gDPPipeSync(OVERLAY_DISP++); - if (gSaveContext.save.playerData.rupees == CAPACITY(UPG_WALLET, CUR_UPG_VALUE(UPG_WALLET))) { + if (gSaveContext.save.playerData.rupees == CUR_CAPACITY(UPG_WALLET)) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 255, 0, interfaceCtx->magicAlpha); } else if (gSaveContext.save.playerData.rupees != 0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); @@ -2546,15 +2552,464 @@ void Interface_AllocStory(GlobalContext* globalCtx) { Interface_LoadStory(globalCtx, 0); } -s32 D_801BFD94[] = { - 0x00000000, -}; -s32 D_801BFD98[] = { - 0x00000000, - 0x00000000, -}; +// Is Matching: Need to work out D_801BFD98 conflicting with Player_Lib +#ifdef NON_MATCHING +void Interface_Update(GlobalContext* globalCtx) { + static u8 D_801BFD94 = 0; + static s16 D_801BFD98 = 0; + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + s16 alpha; // sp32 + s16 alpha1; // sp30 + u16 action; + s16 health; + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { + if (globalCtx->gameOverCtx.state == 0) { + func_80111CB4(globalCtx); + } + } + + switch (gSaveContext.unk_3F20) { + case 0x1: + case 0x2: + case 0x8: + alpha = 255 - (gSaveContext.unk_3F24 << 5); + if (alpha < 0) { + alpha = 0; + } + + func_8010F1A8(globalCtx, alpha); + health = 2; // Fake + gSaveContext.unk_3F24 += health; + if (alpha == 0) { + gSaveContext.unk_3F20 = 0; + } + break; + case 0x3: + case 0x4: + case 0x5: + case 0x6: + case 0x7: + case 0x9: + case 0xA: + case 0xB: + case 0xC: + case 0xD: + case 0xE: + case 0xF: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + alpha = 255 - (gSaveContext.unk_3F24 << 5); + if (alpha < 0) { + alpha = 0; + } + + func_8010F1A8(globalCtx, alpha); + gSaveContext.unk_3F24++; + if (alpha == 0) { + gSaveContext.unk_3F20 = 0; + } + break; + + case 0x32: + alpha = 255 - (gSaveContext.unk_3F24 << 5); + if (alpha < 0) { + alpha = 0; + } + + alpha1 = 255 - alpha; + if (alpha1 >= 255) { + alpha1 = 255; + } + + func_8010EF9C(globalCtx, alpha1); + + if (gSaveContext.buttonStatus[5] == 0xFF) { + if (interfaceCtx->startAlpha != 70) { + interfaceCtx->startAlpha = 70; + } + } else { + if (interfaceCtx->startAlpha != 255) { + interfaceCtx->startAlpha = alpha1; + } + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = alpha1; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = alpha1; + } + + if (globalCtx->sceneNum == SCENE_SPOT00) { + if (interfaceCtx->minimapAlpha < 170) { + interfaceCtx->minimapAlpha = alpha1; + } else { + interfaceCtx->minimapAlpha = 170; + } + } else if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = alpha1; + } + + gSaveContext.unk_3F24++; + + if (alpha1 == 255) { + gSaveContext.unk_3F20 = 0; + } + break; + + case 0x34: + gSaveContext.unk_3F20 = 1; + func_8010F1A8(globalCtx, 0); + gSaveContext.unk_3F20 = 0; + default: + break; + + } + + Map_Update(globalCtx); + + if (gSaveContext.healthAccumulator != 0) { + gSaveContext.healthAccumulator -= 4; + gSaveContext.save.playerData.health += 4; + + if ((gSaveContext.save.playerData.health & 0xF) < 4) { + play_sound(NA_SE_SY_HP_RECOVER); + } + + // TODO: Missing s16 cast + health = gSaveContext.save.playerData.health; + if (health >= gSaveContext.save.playerData.healthCapacity) { + gSaveContext.save.playerData.health = gSaveContext.save.playerData.healthCapacity; + gSaveContext.healthAccumulator = 0; + } + } + + LifeMeter_UpdateSizeAndBeep(globalCtx); + D_801BF8DC = func_801242DC(globalCtx); + + if (D_801BF8DC == 1) { + if (CUR_EQUIP_VALUE_VOID(EQUIP_TUNIC) == 2) { + D_801BF8DC = 0; + } + } else if ((func_801242DC(globalCtx) >= 2) && (func_801242DC(globalCtx) < 5)) { + if (CUR_EQUIP_VALUE_VOID(EQUIP_TUNIC) == 3) { + D_801BF8DC = 0; + } + } + + LifeMeter_UpdateColors(globalCtx); + + if (gSaveContext.rupeeAccumulator != 0) { + if (gSaveContext.rupeeAccumulator > 0) { + if (gSaveContext.save.playerData.rupees < CUR_CAPACITY(UPG_WALLET)) { + gSaveContext.rupeeAccumulator--; + gSaveContext.save.playerData.rupees++; + play_sound(NA_SE_SY_RUPY_COUNT); + } else { + // Max rupees + gSaveContext.save.playerData.rupees = CUR_CAPACITY(UPG_WALLET); + gSaveContext.rupeeAccumulator = 0; + } + } else if (gSaveContext.save.playerData.rupees != 0) { + if (gSaveContext.rupeeAccumulator <= -50) { + gSaveContext.rupeeAccumulator += 10; + gSaveContext.save.playerData.rupees -= 10; + if (gSaveContext.save.playerData.rupees < 0) { + gSaveContext.save.playerData.rupees = 0; + } + play_sound(NA_SE_SY_RUPY_COUNT); + } else { + gSaveContext.rupeeAccumulator++; + gSaveContext.save.playerData.rupees--; + play_sound(NA_SE_SY_RUPY_COUNT); + } + } else { + gSaveContext.rupeeAccumulator = 0; + } + + } + + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { + if (interfaceCtx->unk_286 != 0) { + if (interfaceCtx->unk_288 == 1) { + func_8011B5C0(globalCtx); + } else if (interfaceCtx->unk_288 == 2) { + func_8011B9E0(globalCtx); + } else if (interfaceCtx->unk_288 == 3) { + func_8011BF70(globalCtx); + } + } + } + + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { + if (interfaceCtx->unk_280) { + switch (interfaceCtx->unk_280) { + case 1: + case 3: + case 5: + case 7: + interfaceCtx->unk_282 = 255; + interfaceCtx->unk_284 = 100; + interfaceCtx->unk_280++; + if (interfaceCtx->unk_280 == 8) { + interfaceCtx->unk_284 = 160; + play_sound(NA_SE_SY_START_SHOT); + } else { + play_sound(NA_SE_SY_WARNING_COUNT_E); + } + break; + case 2: + case 4: + case 6: + interfaceCtx->unk_282 -= 10; + interfaceCtx->unk_284 += 3; + if (interfaceCtx->unk_282 < 22) { + interfaceCtx->unk_280++; + } + break; + case 8: + interfaceCtx->unk_282 += -10; + if (interfaceCtx->unk_282 <= 150) { + interfaceCtx->unk_280 = 0x1E; + } + break; + case 20: + interfaceCtx->unk_282 = 0; + interfaceCtx->unk_280++; + break; + case 21: + interfaceCtx->unk_282++; + if (interfaceCtx->unk_282 >= 18) { + interfaceCtx->unk_280 = 30; + } + break; + } + } + } + + switch (interfaceCtx->unk_210) { + case 1: + interfaceCtx->unk_218 += 10466.667f; + if (interfaceCtx->unk_218 >= 15700.0f) { + interfaceCtx->unk_218 = -15700.0f; + interfaceCtx->unk_210 = 2; + + if ((msgCtx->unk11F22 != 0) && (msgCtx->unk12006 == 0x26)) { + gGameInfo->data[0x55F] = -14; + } else { + gGameInfo->data[0x55F] = 0; + } + } + break; + case 2: + interfaceCtx->unk_218 += 10466.667f; + if (interfaceCtx->unk_218 >= 0.0f) { + interfaceCtx->unk_218 = 0.0f; + interfaceCtx->unk_210 = 0; + interfaceCtx->unk_212 = interfaceCtx->unk_214; + action = interfaceCtx->unk_212; + if ((action == DO_ACTION_MAX) || (action == DO_ACTION_MAX + 1)) { + action = DO_ACTION_NONE; + } + Interface_LoadActionLabel(&globalCtx->interfaceCtx, action, 0); + } + break; + case 3: + interfaceCtx->unk_218 += 10466.667f; + if (interfaceCtx->unk_218 >= 15700.0f) { + interfaceCtx->unk_218 = -15700.0f; + interfaceCtx->unk_210 = 2; + } + break; + case 4: + interfaceCtx->unk_218 += 10466.667f; + if (interfaceCtx->unk_218 >= 0.0f) { + interfaceCtx->unk_218 = 0.0f; + interfaceCtx->unk_210 = 0; + interfaceCtx->unk_212 = interfaceCtx->unk_214; + action = interfaceCtx->unk_212; + if ((action == DO_ACTION_MAX) || (action == DO_ACTION_MAX + 1)) { + action = DO_ACTION_NONE; + } + + Interface_LoadActionLabel(&globalCtx->interfaceCtx, action, 0); + } + break; + } + + if (!(player->stateFlags1 & 0x200)) { + if (gGameInfo->data[0x544] == 1) { + if (gSaveContext.save.playerData.magicAcquired == 0) { + gSaveContext.save.playerData.magicAcquired = 1; + } + gSaveContext.save.playerData.doubleMagic = 1; + gSaveContext.save.playerData.magic = 0x60; + gSaveContext.save.playerData.magicLevel = 0; + gGameInfo->data[0x544] = 0; + } else if (gGameInfo->data[0x544] == -1) { + if (gSaveContext.save.playerData.magicAcquired == 0) { + gSaveContext.save.playerData.magicAcquired = 1; + } + gSaveContext.save.playerData.doubleMagic = 0; + gSaveContext.save.playerData.magic = 0x30; + gSaveContext.save.playerData.magicLevel = 0; + gGameInfo->data[0x544] = 0; + } + + if (gSaveContext.save.playerData.magicAcquired != 0) { + if (gSaveContext.save.playerData.magicLevel == 0) { + gSaveContext.save.playerData.magicLevel = gSaveContext.save.playerData.doubleMagic + 1; + gSaveContext.unk_3F30 = gSaveContext.save.playerData.magic; + gSaveContext.save.playerData.magic = 0; + gSaveContext.unk_3F28 = 8; + gSaveContext.save.equips.buttonItems[3][0] = ITEM_NUT; + } + } + Interface_UpdateMagicBar(globalCtx); + + func_80116088(); + } + + + if (gSaveContext.unk_3DD0[5] == 0) { + if ((D_801BF8DC == 1) || (D_801BF8DC == 4)) { + if (CUR_FORM != 2) { + if (globalCtx->gameOverCtx.state == 0) { + if ((gSaveContext.save.playerData.health >> 1) != 0) { + gSaveContext.unk_3DD0[5] = 8; + gSaveContext.timerX[5] = 115; + gSaveContext.timerY[5] = 80; + D_801BF8E0 = 1; + gSaveContext.unk_3DD7[5] = 0; + } + } + } + } + } else { + if (((D_801BF8DC == 0) || (D_801BF8DC == 3)) && (gSaveContext.unk_3DD0[5] < 5)) { + gSaveContext.unk_3DD0[5] = 0; + } + } + + if (gSaveContext.minigameState == 1) { + gSaveContext.minigameScore += interfaceCtx->unk_25C; + gSaveContext.unk_3F3C += interfaceCtx->unk_25E; + interfaceCtx->unk_25C = 0; + interfaceCtx->unk_25E = 0; + + if (D_801BF88C == 0) { + if (gSaveContext.minigameScore >= 1000) { + D_801BF88C++; + } + } else if (D_801BF88C == 1) { + if (gSaveContext.minigameScore >= 1500) { + D_801BF88C++; + } + } + + D_801BF890[0] = D_801BF890[1] = 0; + D_801BF890[2] = 0; + D_801BF890[3] = gSaveContext.minigameScore; + + while (D_801BF890[3] >= 1000) { + D_801BF890[0]++; + D_801BF890[3] -= 1000; + } + + while (D_801BF890[3] >= 100) { + D_801BF890[1]++; + D_801BF890[3] -= 100; + } + + while (D_801BF890[3] >= 10) { + D_801BF890[2]++; + D_801BF890[3] -= 10; + } + } + + if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { + // exit out of ocarina mode after suns song finishes playing + if ((msgCtx->ocarinaAction != 0x39) && (gSaveContext.sunsSongState == SUNSSONG_START) ) { + globalCtx->msgCtx.ocarinaMode = 4; + } + + // handle suns song in areas where time moves + if (globalCtx->envCtx.timeIncrement != 0) { + if (gSaveContext.sunsSongState != SUNSSONG_SPEED_TIME) { + D_801BFD94 = false; + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + D_801BFD94 = true; + } + + gSaveContext.sunsSongState = SUNSSONG_SPEED_TIME; + D_801BFD98 = gGameInfo->data[0xF]; + gGameInfo->data[0xF] = 400; + } else if (!D_801BFD94) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + gGameInfo->data[0xF] = D_801BFD98; + globalCtx->msgCtx.ocarinaMode = 4; + } + } else if (gSaveContext.save.time > CLOCK_TIME(18, 0)) { + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + gGameInfo->data[0xF] = D_801BFD98; + globalCtx->msgCtx.ocarinaMode = 4; + } + } else { + gSaveContext.sunsSongState = SUNSSONG_SPECIAL; + } + } + + func_8011E3B4(globalCtx); + + if (interfaceCtx->unk_31A != 0) { + if (interfaceCtx->unk_31A == 1) { + interfaceCtx->storyState = 0; + interfaceCtx->unk_31A = 2; + gGameInfo->data[0x59B] = 0; + } + + Interface_AllocStory(globalCtx); + + if (interfaceCtx->unk_31A == 3) { + interfaceCtx->unk_31A = 0; + interfaceCtx->storyState = 0; + if (interfaceCtx->storySegment != NULL) { + ZeldaArena_Free(interfaceCtx->storySegment); + interfaceCtx->storySegment = NULL; + } + } else if (interfaceCtx->unk_31A == 4) { + interfaceCtx->unk_31A = 2; + } else if (interfaceCtx->unk_31A == 5) { + gGameInfo->data[0x59B] += 10; + if (gGameInfo->data[0x59B] >= 250) { + gGameInfo->data[0x59B] = 255; + interfaceCtx->unk_31A = 2; + } + } else if (interfaceCtx->unk_31A == 6) { + gGameInfo->data[0x59B] -= 10; + if (gGameInfo->data[0x59B] < 0) { + gGameInfo->data[0x59B] = 0; + interfaceCtx->unk_31A = 2; + } + } + } +} +#else +u8 D_801BFD94 = 0; +s16 D_801BFD98 = 0; +s32 D_801BFD9C = 0; #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_Update.s") +#endif void func_80121F94(void) { func_8010A410(); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 7d14ec98b..46c627982 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -388,17 +388,17 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { } if (cmd->timeSettings.unk6 != 0xFF) { - globalCtx->envCtx.unk_2 = cmd->timeSettings.unk6; + globalCtx->envCtx.timeIncrement = cmd->timeSettings.unk6; } else { - globalCtx->envCtx.unk_2 = 0; + globalCtx->envCtx.timeIncrement = 0; } - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.unk_2 != 0)) { - globalCtx->envCtx.unk_2 = 5; + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { + globalCtx->envCtx.timeIncrement = 5; } - if (gSaveContext.unk_3F58 == 0) { - REG(15) = globalCtx->envCtx.unk_2; + if (gSaveContext.sunsSongState == SUNSSONG_INACTIVE) { + REG(15) = globalCtx->envCtx.timeIncrement; } dayTime = gSaveContext.save.time; @@ -408,7 +408,7 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { dayTime = gSaveContext.save.time; globalCtx->envCtx.unk_C = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f; - if (globalCtx->envCtx.unk_2 == 0 && gSaveContext.save.cutscene < 0xFFF0) { + if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) { gSaveContext.environmentTime = gSaveContext.save.time; if (gSaveContext.environmentTime >= 0x2AAA && gSaveContext.environmentTime < 0x4555) { diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 6db3733b8..60fa3ff9e 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -270,7 +270,7 @@ void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { } void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { - if ((globalCtx->msgCtx.unk1202A == 0) || (globalCtx->msgCtx.unk1202A == 4)) { + if ((globalCtx->msgCtx.ocarinaMode == 0) || (globalCtx->msgCtx.ocarinaMode == 4)) { if (D_801BDAA4 != 0) { if (this->flags & EN_COW_FLAG_WONT_GIVE_MILK) { this->flags &= ~EN_COW_FLAG_WONT_GIVE_MILK; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 65df5600b..8de7cd4cb 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -424,7 +424,7 @@ void func_80B3EE8C(EnDai* this, GlobalContext* globalCtx) { void func_80B3EEDC(EnDai* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.unk1202A == 3) && + if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 1)) { func_80B3E5DC(this, 1); this->actionFunc = func_80B3EE8C; diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 5f5a88f20..b2ea32a7e 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -276,7 +276,7 @@ void func_80998040(EnGs* this, GlobalContext* globalCtx) { } void func_8099807C(EnGs* this, GlobalContext* globalCtx) { - switch (globalCtx->msgCtx.unk1202A) { + switch (globalCtx->msgCtx.ocarinaMode) { case 3: switch (globalCtx->msgCtx.unk1202E) { case 7: diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index d4994b38e..1b96d563e 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -362,7 +362,7 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { } else { D_80BD00C8 = false; } - if (globalCtx->msgCtx.unk1202A == 3) { + if (globalCtx->msgCtx.ocarinaMode == 3) { if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { this->unk218 = 3; diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index e1904bcdf..fea4e0a01 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -627,7 +627,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); func_8096FBB8(this, globalCtx); - if (globalCtx->msgCtx.unk1202A == 4) { // song failed + if (globalCtx->msgCtx.ocarinaMode == 4) { // song failed this->unk190 = 0; this->unkCounter1A4 = 0; ActorCutscene_Stop(this->actorCutscenes[0]); @@ -641,7 +641,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); this->actionFunc = EnKakasi_RegularDialogue; - } else if (globalCtx->msgCtx.unk1202A == 3) { // song success + } else if (globalCtx->msgCtx.ocarinaMode == 3) { // song success this->postTeachTimer = 30; this->skelanime.playSpeed = 2.0f; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); @@ -664,7 +664,7 @@ void EnKakasi_PostSongLearnTwirl(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->actorCutscenes[0]); - globalCtx->msgCtx.unk1202A = 4; + globalCtx->msgCtx.ocarinaMode = 4; this->unk190 = 0; this->unkCounter1A4 = 0; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); @@ -1041,9 +1041,9 @@ void EnKakasi_SetupIdleUnderground(EnKakasi* this) { void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { if ((gSaveContext.save.weekEventReg[79] & 0x8) && this->actor.xzDistToPlayer < this->songSummonDist && - (BREG(1) != 0 || globalCtx->msgCtx.unk1202A == 0xD)) { + (BREG(1) != 0 || globalCtx->msgCtx.ocarinaMode == 0xD)) { this->actor.flags &= ~0x8000000; - globalCtx->msgCtx.unk1202A = 4; + globalCtx->msgCtx.ocarinaMode = 4; this->actionFunc = EnKakasi_SetupRiseOutOfGround; } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index be62210ea..a65802a02 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -237,8 +237,8 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnRd* this = THIS; - if (gSaveContext.unk_3F58 != 0) { - gSaveContext.unk_3F58 = 0; + if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -994,7 +994,7 @@ void func_808D64D0(EnRd* this) { this->unk_3D6 = 0xA; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - if (gSaveContext.unk_3F58 != 0) { + if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { this->unk_3E9 = 1; this->unk_3E0 = 600; Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); @@ -1021,7 +1021,7 @@ void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { if (this->unk_3E0 == 0) { this->unk_3E9 = 0; - gSaveContext.unk_3F58 = 0; + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } } } @@ -1060,7 +1060,7 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.unk_3F58 != 0) && (this->actor.shape.rot.x == 0) && (this->unk_3E9 == 0) && + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->actor.shape.rot.x == 0) && (this->unk_3E9 == 0) && (this->unk_3EF != 11) && (this->unk_3EF != 12) && (this->unk_3EF != 1)) { func_808D64D0(this); return; @@ -1171,8 +1171,8 @@ void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { EnRd* this = THIS; func_808D6814(this, globalCtx); - if ((gSaveContext.unk_3F58 != 0) && (this->unk_3E9 == 0)) { - gSaveContext.unk_3F58 = 0; + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->unk_3E9 == 0)) { + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } if ((this->unk_3F0 != 6) && ((this->unk_3EF != 13) || (this->unk_3F0 != 2))) { diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index fdaa29568..13cc6ddfe 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -561,7 +561,7 @@ s32 func_80BA46D8(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA4740(EnToto* this, GlobalContext* globalCtx) { - if (globalCtx->msgCtx.unk1202A == 4) { + if (globalCtx->msgCtx.ocarinaMode == 4) { if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { gSaveContext.save.weekEventReg[56] |= 0x10; } diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 6c3aa8f7e..9ab445247 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1151,7 +1151,7 @@ void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { if (func_800B8718(&this->actor, globalCtx)) { - globalCtx->msgCtx.unk1202A = 4; + globalCtx->msgCtx.ocarinaMode = 4; func_8019B544(0xFFFF); this->actionFunc = func_80B98BF4; this->actor.flags |= 0x10000; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 38cab996b..8ad5dc8c3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2008,7 +2008,7 @@ 0x8010A410:("func_8010A410",), 0x8010A430:("func_8010A430",), 0x8010A54C:("func_8010A54C",), - 0x8010A580:("func_8010A580",), + 0x8010A580:("Map_Update",), 0x8010A760:("func_8010A760",), 0x8010A7CC:("func_8010A7CC",), 0x8010A814:("func_8010A814",), @@ -2139,7 +2139,7 @@ 0x80115DB4:("func_80115DB4",), 0x80116088:("func_80116088",), 0x80116114:("func_80116114",), - 0x80116348:("func_80116348",), + 0x80116348:("Interface_UpdateMagicBar",), 0x80116918:("Interface_DrawMagicBar",), 0x80116FD8:("func_80116FD8",), 0x801170B8:("func_801170B8",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 81e8aea7d..3e2b2daf5 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1522,7 +1522,7 @@ asm/non_matchings/code/z_map_exp/func_8010A33C.s,func_8010A33C,0x8010A33C,0x35 asm/non_matchings/code/z_map_exp/func_8010A410.s,func_8010A410,0x8010A410,0x8 asm/non_matchings/code/z_map_exp/func_8010A430.s,func_8010A430,0x8010A430,0x47 asm/non_matchings/code/z_map_exp/func_8010A54C.s,func_8010A54C,0x8010A54C,0xD -asm/non_matchings/code/z_map_exp/func_8010A580.s,func_8010A580,0x8010A580,0x78 +asm/non_matchings/code/z_map_exp/Map_Update.s,Map_Update,0x8010A580,0x78 asm/non_matchings/code/z_msgevent/func_8010A760.s,func_8010A760,0x8010A760,0x1B asm/non_matchings/code/z_msgevent/func_8010A7CC.s,func_8010A7CC,0x8010A7CC,0x12 asm/non_matchings/code/z_msgevent/func_8010A814.s,func_8010A814,0x8010A814,0x12 @@ -1653,7 +1653,7 @@ asm/non_matchings/code/z_parameter/func_80115D5C.s,func_80115D5C,0x80115D5C,0x16 asm/non_matchings/code/z_parameter/func_80115DB4.s,func_80115DB4,0x80115DB4,0xB5 asm/non_matchings/code/z_parameter/func_80116088.s,func_80116088,0x80116088,0x23 asm/non_matchings/code/z_parameter/func_80116114.s,func_80116114,0x80116114,0x8D -asm/non_matchings/code/z_parameter/func_80116348.s,func_80116348,0x80116348,0x174 +asm/non_matchings/code/z_parameter/Interface_UpdateMagicBar.s,Interface_UpdateMagicBar,0x80116348,0x174 asm/non_matchings/code/z_parameter/Interface_DrawMagicBar.s,Interface_DrawMagicBar,0x80116918,0x1B0 asm/non_matchings/code/z_parameter/func_80116FD8.s,func_80116FD8,0x80116FD8,0x38 asm/non_matchings/code/z_parameter/func_801170B8.s,func_801170B8,0x801170B8,0x12