From f3db0299367c4dd7cf44ab9e12cf6c8b56d598ab Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Wed, 12 Oct 2022 23:39:39 -0400 Subject: [PATCH] z_kaleido_collect.c (1 non-matching) and Mostly Documented (Pause Menu Quest Page) (#1108) * import quest docs * cleanup * eol * temp change to non-eq * more missed stuff * fix questVtx * PR suggestions * adjust comment * missed two * PR Suggestions --- include/functions.h | 2 +- include/regs.h | 3 + include/variables.h | 4 +- include/z64.h | 8 +- include/z64item.h | 10 +- src/code/audio/code_8019AF00.c | 2 +- src/code/code_8012EC80.c | 12 +- src/code/z_demo.c | 2 +- src/code/z_kaleido_setup.c | 4 +- src/code/z_message.c | 2 +- src/code/z_parameter.c | 6 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 4 +- src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c | 6 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 2 +- .../actors/ovl_En_Gakufu/z_en_gakufu.c | 5 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 2 +- .../actors/ovl_En_Time_Tag/z_en_time_tag.c | 2 +- .../ovl_kaleido_scope/z_kaleido_collect.c | 1064 +++++++++++++++-- .../ovl_kaleido_scope/z_kaleido_debug.c | 2 +- .../ovl_kaleido_scope/z_kaleido_item.c | 16 +- .../ovl_kaleido_scope/z_kaleido_map.c | 6 +- .../ovl_kaleido_scope/z_kaleido_mask.c | 14 +- .../ovl_kaleido_scope/z_kaleido_scope.h | 26 +- .../ovl_kaleido_scope/z_kaleido_scope_NES.c | 179 ++- tools/disasm/functions.txt | 8 +- tools/disasm/variables.txt | 62 +- tools/namefixer.py | 1 + 27 files changed, 1262 insertions(+), 192 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0c5948ed8b..1439401fc7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2929,7 +2929,7 @@ void AudioOcarina_StartDefault(u32 ocarinaFlags); u8 func_8019B5AC(void); void AudioOcarina_ResetAndReadInput(void); void AudioOcarina_SetOcarinaDisableTimer(u8 unused, u8 timer); -u32 AudioOcarina_SetInstrument(u8 ocarinaInstrumentId); +void AudioOcarina_SetInstrument(u8 ocarinaInstrumentId); void AudioOcarina_SetPlaybackSong(s8 songIndexPlusOne, u8 playbackState); void AudioOcarina_SetRecordingState(u8 recordingState); OcarinaStaff* AudioOcarina_GetRecordingStaff(void); diff --git a/include/regs.h b/include/regs.h index 4ad6acbfbe..ab31e6d25e 100644 --- a/include/regs.h +++ b/include/regs.h @@ -50,6 +50,9 @@ #define R_PAUSE_WORLD_MAP_YAW YREG(24) #define R_PAUSE_WORLD_MAP_Y_OFFSET YREG(25) #define R_PAUSE_WORLD_MAP_DEPTH YREG(26) +#define R_PAUSE_DBG_QUEST_CURSOR_ON YREG(69) +#define R_PAUSE_DBG_QUEST_CURSOR_X YREG(70) +#define R_PAUSE_DBG_QUEST_CURSOR_Y YREG(71) #define R_MAGIC_FILL_COLOR(i) ZREG(0 + i) #define R_C_BTN_COLOR(i) ZREG(39 + i) #define R_B_BTN_COLOR(i) ZREG(43 + i) diff --git a/include/variables.h b/include/variables.h index e223fe65e7..1719d4c6fb 100644 --- a/include/variables.h +++ b/include/variables.h @@ -924,7 +924,7 @@ extern u8 gUpgradeShifts[8]; extern u16 gUpgradeCapacities[][4]; extern u32 gGsFlagsMask[]; extern u32 gGsFlagsShift[]; -extern void* gItemIcons[]; +extern TexturePtr gItemIcons[]; extern u8 gItemSlots[]; extern s16 gItemPrices[]; extern u16 gSceneIdsPerRegion[11][27]; @@ -973,7 +973,7 @@ extern struct_801C5F44 D_801C5F44[]; // D_801C5F44 extern u8 D_801CFC98; extern s16 D_801CFCA4[9]; // extern UNK_TYPE2 D_801CFCAC; -// extern UNK_TYPE1 D_801CFCB8; +extern s16 gOcarinaSongItemMap[]; // extern UNK_TYPE2 D_801CFCD8; // extern UNK_TYPE2 D_801CFCE4; // extern UNK_TYPE2 D_801CFCF0; diff --git a/include/z64.h b/include/z64.h index dc01a5dc78..da1f883237 100644 --- a/include/z64.h +++ b/include/z64.h @@ -407,7 +407,7 @@ typedef struct { /* 0x1E8 */ OSMesg loadMsg; /* 0x1EC */ u16 state; /* 0x1EE */ u16 debugEditor; - /* 0x1F0 */ u8 unk_1F0; + /* 0x1F0 */ u8 bombersNotebookOpen; /* 0x1F4 */ Vec3f eye; /* 0x200 */ u16 unk_200; /* 0x202 */ u16 mode; @@ -452,7 +452,7 @@ typedef struct { /* 0x298 */ f32 unk_298; /* 0x29C */ s16 promptChoice; // save/continue choice: 0 = yes; 4 = no /* 0x29E */ s16 promptAlpha; - /* 0x2A0 */ s16 unk_2A0; + /* 0x2A0 */ s16 ocarinaSongIndex; /* 0x2A2 */ u8 worldMapPoints[20]; /* 0x2B6 */ u8 unk_2B6; /* 0x2B7 */ u8 unk_2B7; @@ -460,9 +460,9 @@ typedef struct { /* 0x2B9 */ u8 itemDescriptionOn; // helpful description of item given through a message box /* 0x2BA */ s16 equipAnimScale; // scale of item icon while moving being equipped to c-button /* 0x2BC */ s16 equipAnimShrinkRate; // rate the scale is shrinking for the item icon while moving being equipped to c-button - /* 0x2BE */ s16 unk_2BE[5]; + /* 0x2BE */ s16 ocarinaButtonsY[5]; /* 0x2C8 */ u16 unk_2C8; // Uses PauseMenuPage enum for Owl Warp. Never set. - /* 0x2CA */ s16 unk_2CA; // Uses OwlStatueId enum for Owl Warp. Never set. + /* 0x2CA */ s16 unk_2CA; // Uses OwlWarpId enum for Owl Warp. Never set. } PauseContext; // size = 0x2D0 typedef struct { diff --git a/include/z64item.h b/include/z64item.h index 7c6b719ca4..2f17c67c76 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -40,7 +40,7 @@ typedef enum { } UpgradeType; typedef enum { - /* 0x00 */ QUEST_REMAINS_ODOWLA, + /* 0x00 */ QUEST_REMAINS_ODOLWA, /* 0x01 */ QUEST_REMAINS_GOHT, /* 0x02 */ QUEST_REMAINS_GYORG, /* 0x03 */ QUEST_REMAINS_TWINMOLD, @@ -59,8 +59,12 @@ typedef enum { /* 0x10 */ QUEST_SONG_STORMS, /* 0x11 */ QUEST_SONG_SUN, /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, // Obtained Bombers Notebook - /* 0x13 */ QUEST_SKULL_TOKEN, - /* 0x18 */ QUEST_SONG_LULLABY_INTRO = 0x18, + /* 0x13 */ QUEST_QUIVER, + /* 0x14 */ QUEST_BOMB_BAG, + /* 0x15 */ QUEST_SKULL_TOKEN, + /* 0x16 */ QUEST_HEART_PIECE, // for `pauseCtx->cursorPoint[PAUSE_QUEST]` + /* 0x17 */ QUEST_17, // Used in a conditional for quest cursors + /* 0x18 */ QUEST_SONG_LULLABY_INTRO, /* 0x19 */ QUEST_PICTOGRAPH, // A photo from the pictograph box is saved /* 0x1C */ QUEST_HEART_PIECE_COUNT = 0x1C } QuestItem; diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 6d1468d82f..9df12e7fe9 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -2733,7 +2733,7 @@ void AudioOcarina_SetOcarinaDisableTimer(u8 unused, u8 timer) { sOcarinaUnused = unused; } -u32 AudioOcarina_SetInstrument(u8 ocarinaInstrumentId) { +void AudioOcarina_SetInstrument(u8 ocarinaInstrumentId) { if ((sOcarinaInstrumentId != ocarinaInstrumentId) || (ocarinaInstrumentId == OCARINA_INSTRUMENT_DEFAULT)) { Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_SFX) << 24) | ((u32)(1) << 16) | ((u32)(SFX_CHANNEL_OCARINA) << 8) | (u32)(ocarinaInstrumentId)); diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index eb70cfbc8d..fb6f0743d9 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -661,17 +661,17 @@ void Inventory_SetWorldMapCloudVisibility(s16 tingleIndex) { i++; } - if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[0]) { + if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_CLOCK_TOWN]) { gSaveContext.save.worldMapCloudVisibility |= 3; - } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[1]) { + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_WOODFALL]) { gSaveContext.save.worldMapCloudVisibility |= 0x1C; - } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[2]) { + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_SNOWHEAD]) { gSaveContext.save.worldMapCloudVisibility |= 0xE0; - } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[3]) { + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_ROMANI_RANCH]) { gSaveContext.save.worldMapCloudVisibility |= 0x100; - } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[4]) { + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_GREAT_BAY]) { gSaveContext.save.worldMapCloudVisibility |= 0x1E00; - } else if ((*tingleMapSceneIds) == sSceneIdsPerTingleMap[5]) { + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_STONE_TOWER]) { gSaveContext.save.worldMapCloudVisibility |= 0x6000; } } diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 1fa041be18..25b2b471a5 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -990,7 +990,7 @@ void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdText D_801BB160 = CS_TEXTBOX_TYPE_1; D_801BB124 = cmd->base; if (cmd->type == CS_TEXTBOX_TYPE_BOSSES_REMAINS) { - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { if (cmd->textId1 != 0xFFFF) { Message_StartTextbox(play, cmd->textId1, NULL); diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 2f2e3c3881..a096aaabef 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -137,8 +137,8 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->cursorSlot[PAUSE_ITEM] = 0; pauseCtx->cursorSlot[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + (DUNGEON_FLOOR_INDEX_4 - 1); - pauseCtx->cursorColorSet = 2; - pauseCtx->unk_2A0 = -1; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; + pauseCtx->ocarinaSongIndex = -1; pauseCtx->equipAnimScale = 320; pauseCtx->equipAnimShrinkRate = 40; pauseCtx->promptAlpha = 100; diff --git a/src/code/z_message.c b/src/code/z_message.c index de3a81c738..5b35986171 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -329,7 +329,7 @@ void func_80151938(PlayState* play, u16 textId) { } msgCtx->unk1203C = msgCtx->unk1203A; - if (play->pauseCtx.unk_1F0 != 0) { + if (play->pauseCtx.bombersNotebookOpen) { msgCtx->unk12004 = 0x22; msgCtx->unk12006 = 0x15E; func_80149C18(play); diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 4620dd8169..d463edff34 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1172,7 +1172,9 @@ u8 Item_Give(PlayState* play, u8 item) { } if (item == ITEM_SKULL_TOKEN) { - SET_QUEST_ITEM(item - ITEM_SKULL_TOKEN + QUEST_SKULL_TOKEN); + //! @bug: Sets QUEST_QUIVER instead of QUEST_SKULL_TOKEN + // Setting `QUEST_SKULL_TOKEN` will result in misplaced digits on the pause menu - Quest Status page. + SET_QUEST_ITEM(item - ITEM_SKULL_TOKEN + QUEST_QUIVER); Inventory_IncrementSkullTokenCount(play->sceneId); return ITEM_NONE; @@ -1446,7 +1448,7 @@ u8 Item_Give(PlayState* play, u8 item) { return ITEM_NONE; } else if ((item >= ITEM_REMAINS_ODOLWA) && (item <= ITEM_REMAINS_TWINMOLD)) { - SET_QUEST_ITEM(item - ITEM_REMAINS_ODOLWA + QUEST_REMAINS_ODOWLA); + SET_QUEST_ITEM(item - ITEM_REMAINS_ODOLWA + QUEST_REMAINS_ODOLWA); return ITEM_NONE; } else if (item == ITEM_RECOVERY_HEART) { diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 03531bb312..2d384ccf6b 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -75,7 +75,7 @@ void DoorWarp1_SetupAction(DoorWarp1* this, DoorWarp1ActionFunc actionFunc) { s32 func_808B849C(DoorWarp1* this, PlayState* play) { s32 ret = 0; - if ((play->sceneId == SCENE_MITURIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + if ((play->sceneId == SCENE_MITURIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) { ret = 1; } else if ((play->sceneId == SCENE_HAKUGIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { ret = 2; @@ -239,7 +239,7 @@ void func_808B8C48(DoorWarp1* this, PlayState* play) { this->dyna.actor.world.pos.z, 200, 255, 255, 255); Lights_PointNoGlowSetInfo(&this->unk_1F4, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 200, 255, 255, 255); - if (((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_2) && CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) || + if (((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_2) && CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) || ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_3) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) || ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_4) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) || ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_5) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD))) { diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index e8c874df44..c21da42b05 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -41,7 +41,7 @@ static InitChainEntry sInitChain[] = { }; s32 func_80BA15A0(void) { - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && !(gSaveContext.save.weekEventReg[87] & 0x10)) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && !(gSaveContext.save.weekEventReg[87] & 0x10)) { return true; } @@ -61,7 +61,7 @@ s32 func_80BA15A0(void) { } void func_80BA165C(void) { - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) { gSaveContext.save.weekEventReg[87] |= 0x10; } @@ -88,7 +88,7 @@ s32 func_80BA16F4(ElfMsg6* this, PlayState* play) { return true; } - if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) { this->actor.textId = 0x256; return false; } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index d7d3e446e2..508090fd50 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -324,7 +324,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { break; case 2: - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { if (gSaveContext.save.weekEventReg[93] & 4) { if (ActorCutscene_GetCanPlayNext(0xC)) { diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index cc19acb63d..9b4836637c 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -115,9 +115,12 @@ void EnGakufu_ProcessNotes(EnGakufu* this) { songIndex = this->songIndex; ocarinaSongButtons = &gOcarinaSongButtons[songIndex]; + + //! FAKE: + if (1) {} songNumButtons = gOcarinaSongButtons[this->songIndex].numButtons; - for (i = 0; i < songNumButtons; i++) { + for (i = 0; i < (u8)songNumButtons; i++) { this->buttonIndex[i] = ocarinaSongButtons->buttonIndex[i]; } diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 7d2819ff9c..10951f76d3 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -110,7 +110,7 @@ s32 EnGiant_IsImprisoned(EnGiant* this) { case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: case GIANT_TYPE_SWAMP_CLOCK_TOWER_FAILURE: - if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) { return true; } break; diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index 04e44bb168..a8e74ff6ed 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c @@ -91,7 +91,7 @@ void func_80AC9FE4(EnTimeTag* this, PlayState* play) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); this->actionFunc = func_80AC9FD4; gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { gSaveContext.save.weekEventReg[25] |= 2; } diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c index 316ad33554..90a1a0effc 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c @@ -1,103 +1,1003 @@ /* * File: z_kaleido_collect.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu - Quest Status Page */ #include "z_kaleido_scope.h" +#include "interface/parameter_static/parameter_static.h" -extern UNK_TYPE D_02001360; -extern UNK_TYPE D_020044A0; -extern UNK_TYPE D_02004AA0; -extern UNK_TYPE D_0200B998; -extern UNK_TYPE D_08062000; -extern UNK_TYPE D_08064340; -extern UNK_TYPE D_0B000000; -extern UNK_TYPE D_0C000000; -extern UNK_TYPE D_0C006C00; +s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s16 point); -s16 D_8082AED0[] = { 120, 60, 2, 80 }; +extern TexturePtr D_08061000; // gBombersNotebookIconTex +extern TexturePtr D_08062000; // gSongNoteIconTex -s16 D_8082AED8[] = { 20, 4, 20, 10 }; - -s32 D_8082AEE0 = 0; - -s32 D_8082AEE4[] = { 0, 0, 0 }; - -s32 D_8082AEF0[] = { 0, 0, 0, 0, 0 }; - -s16 D_8082AF04[] = { - 255, 0, 0, 255, 255, 70, 0, 150, 255, 70, 0, 150, 255, 0, 0, 255, +s16 sQuestRemainsColorTimerInit[] = { 120, 60, 2, 80 }; +s16 sQuestHpColorTimerInit[] = { 20, 4, 20, 10 }; +s16 sQuestSongPlayedOcarinaButtonsNum = 0; +u8 sQuestSongPlayedOcarinaButtons[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +s16 sQuestSongPlayedOcarinaButtonsAlpha[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +s16 sQuestHpPrimColorTargets[][4] = { + { 255, 0, 0, 255 }, + { 255, 70, 0, 150 }, + { 255, 70, 0, 150 }, + { 255, 0, 0, 255 }, +}; +s16 sQuestRemainsEnvTargets[][3] = { + { 0, 0, 0 }, // QUEST_REMAINS_ODOLWA Target 1 + { 0, 0, 0 }, // QUEST_REMAINS_GOHT Target 1 + { 0, 0, 0 }, // QUEST_REMAINS_GYORG Target 1 + { 0, 0, 0 }, // QUEST_REMAINS_TWINMOLD Target 1 + { 0, 0, 0 }, // Unused + { 0, 0, 0 }, // Unused + { 0, 60, 0 }, // QUEST_REMAINS_ODOLWA Target 2 + { 90, 0, 0 }, // QUEST_REMAINS_GOHT Target 2 + { 0, 40, 110 }, // QUEST_REMAINS_GYORG Target 2 + { 80, 40, 0 }, // QUEST_REMAINS_TWINMOLD Target 2 + { 70, 0, 90 }, // Unused + { 90, 90, 0 }, // Unused +}; +s16 sQuestRemainsEnvRed[] = { + 255, // QUEST_REMAINS_ODOLWA + 255, // QUEST_REMAINS_GOHT + 255, // QUEST_REMAINS_GYORG + 255, // QUEST_REMAINS_TWINMOLD + 255, // Unused + 255, // Unused +}; +s16 sQuestRemainsEnvGreen[] = { + 255, // QUEST_REMAINS_ODOLWA + 255, // QUEST_REMAINS_GOHT + 255, // QUEST_REMAINS_GYORG + 255, // QUEST_REMAINS_TWINMOLD + 255, // Unused + 255, // Unused +}; +s16 sQuestRemainsEnvBlue[] = { + 150, // QUEST_REMAINS_ODOLWA + 150, // QUEST_REMAINS_GOHT + 150, // QUEST_REMAINS_GYORG + 150, // QUEST_REMAINS_TWINMOLD + 150, // Unused + 150, // Unused }; -s16 D_8082AF24[] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x003C, 0x0000, 0x005A, 0x0000, 0x0000, - 0x0000, 0x0028, 0x006E, 0x0050, 0x0028, 0x0000, 0x0046, 0x0000, 0x005A, 0x005A, 0x005A, 0x0000, +#ifdef NON_EQUIVALENT +// TODO: is actually NON_MATCHING, update once `z_kaleido_scope_NES.c` is decompiled +// A single small regalloc at the first `func_8010DC58` for the heart piece count (see `gItemIcons`) +void KaleidoScope_DrawQuestStatus(PlayState* play) { + static s16 sQuestRemainsColorTimer = 20; + static s16 sQuestRemainsColorTimerIndex = 0; + static s16 sQuestHpPrimRed = 0; + static s16 sQuestHpPrimGreen = 0; + static s16 sQuestHpPrimBlue = 0; + static s16 sQuestHpPrimAlpha = 0; + static s16 sQuestHpColorTimer = 20; + static s16 sQuestHpPrimColorTargetIndex = 0; + static TexturePtr sOcarinaButtonTextures[] = { + gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, + }; + static s16 sQuestSongsPrimRed[] = { + 150, // QUEST_SONG_SONATA + 255, // QUEST_SONG_LULLABY + 100, // QUEST_SONG_BOSSA_NOVA + 255, // QUEST_SONG_ELEGY + 255, // QUEST_SONG_OATH + 255, // QUEST_SONG_SARIA + 255, // QUEST_SONG_TIME + 255, // QUEST_SONG_HEALING + 255, // QUEST_SONG_EPONA + 255, // QUEST_SONG_SOARING + 255, // QUEST_SONG_STORMS + 255, // QUEST_SONG_SUN + }; + static s16 sQuestSongsPrimGreen[] = { + 255, // QUEST_SONG_SONATA + 80, // QUEST_SONG_LULLABY + 150, // QUEST_SONG_BOSSA_NOVA + 160, // QUEST_SONG_ELEGY + 100, // QUEST_SONG_OATH + 240, // QUEST_SONG_SARIA + 255, // QUEST_SONG_TIME + 255, // QUEST_SONG_HEALING + 255, // QUEST_SONG_EPONA + 255, // QUEST_SONG_SOARING + 255, // QUEST_SONG_STORMS + 255, // QUEST_SONG_SUN + }; + static s16 sQuestSongsPrimBlue[] = { + 100, // QUEST_SONG_SONATA + 40, // QUEST_SONG_LULLABY + 255, // QUEST_SONG_BOSSA_NOVA + 0, // QUEST_SONG_ELEGY + 255, // QUEST_SONG_OATH + 100, // QUEST_SONG_SARIA + 255, // QUEST_SONG_TIME + 255, // QUEST_SONG_HEALING + 255, // QUEST_SONG_EPONA + 255, // QUEST_SONG_SOARING + 255, // QUEST_SONG_STORMS + 255, // QUEST_SONG_SUN + }; + static TexturePtr sQuestUpgradeTextures[][3] = { + { 0x08053000, 0x08054000, 0x08055000 }, // UPG_QUIVER + { 0x08056000, 0x08057000, 0x08058000 }, // UPG_BOMB_BAG + }; + static u8 sQuestUpgrades[] = { UPG_QUIVER, UPG_BOMB_BAG }; + PauseContext* pauseCtx = &play->pauseCtx; + s16 sp1CA; // colorSetR and numOcarinaButtons + s16 sp1C8; // colorSetG and ocarinaButtonIndex + s16 sp1C6; + s16 sp1C4; + s16 var_v1; + s16 i; + s16 j; + s16 k; + s16 skullTokenDigits[3]; + u16 isDigitDrawn; + + OPEN_DISPS(play->state.gfxCtx); + + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_QUEST] * 4, pauseCtx->questVtx); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + // Draw the Boss Remains icons + sQuestRemainsColorTimer--; + for (i = 0, j = 0; i < 4; i++, j += 4) { + if ((sQuestRemainsColorTimerIndex != 1) && (sQuestRemainsColorTimerIndex != 3)) { + var_v1 = (sQuestRemainsColorTimerIndex != 0) ? (i + 6) : i; + + if (sQuestRemainsColorTimer != 0) { + sp1CA = ABS_ALT(sQuestRemainsEnvRed[i] - sQuestRemainsEnvTargets[var_v1][0]) / sQuestRemainsColorTimer; + sp1C8 = + ABS_ALT(sQuestRemainsEnvGreen[i] - sQuestRemainsEnvTargets[var_v1][1]) / sQuestRemainsColorTimer; + sp1C6 = ABS_ALT(sQuestRemainsEnvBlue[i] - sQuestRemainsEnvTargets[var_v1][2]) / sQuestRemainsColorTimer; + + if (sQuestRemainsEnvRed[i] >= sQuestRemainsEnvTargets[var_v1][0]) { + sQuestRemainsEnvRed[i] -= sp1CA; + } else { + sQuestRemainsEnvRed[i] += sp1CA; + } + if (sQuestRemainsEnvGreen[i] >= sQuestRemainsEnvTargets[var_v1][1]) { + sQuestRemainsEnvGreen[i] -= sp1C8; + } else { + sQuestRemainsEnvGreen[i] += sp1C8; + } + if (sQuestRemainsEnvBlue[i] >= sQuestRemainsEnvTargets[var_v1][2]) { + sQuestRemainsEnvBlue[i] -= sp1C6; + } else { + sQuestRemainsEnvBlue[i] += sp1C6; + } + } else { + sQuestRemainsEnvRed[i] = sQuestRemainsEnvTargets[var_v1][0]; + sQuestRemainsEnvGreen[i] = sQuestRemainsEnvTargets[var_v1][1]; + sQuestRemainsEnvBlue[i] = sQuestRemainsEnvTargets[var_v1][2]; + } + } + + if (CHECK_QUEST_ITEM(i)) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, sQuestRemainsEnvRed[i], sQuestRemainsEnvGreen[i], sQuestRemainsEnvBlue[i], + 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, gItemIcons[ITEM_REMAINS_ODOLWA + i], 32, 32, 0); + } + } + + if (sQuestRemainsColorTimer == 0) { + sQuestRemainsColorTimer = sQuestRemainsColorTimerInit[sQuestRemainsColorTimerIndex]; + if (++sQuestRemainsColorTimerIndex > 3) { + sQuestRemainsColorTimerIndex = 0; + } + } + + // Draw shield + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, gItemIcons[(ITEM_SHIELD_HERO - 1) + GET_CUR_EQUIP_VALUE(1)], + 32, 32, 0); + } + + j += 4; + + // Draw Sword + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_NONE) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, gItemIcons[(ITEM_SWORD_KOKIRI - 1) + GET_CUR_EQUIP_VALUE(0)], + 32, 32, 0); + } + + j += 4; + + // Draw Songs + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + gDPLoadTextureBlock(POLY_OPA_DISP++, &D_08062000, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + for (i = 0; i < 12; i++, j += 4) { + if (CHECK_QUEST_ITEM(i + QUEST_SONG_SONATA) || + ((i == (QUEST_SONG_LULLABY - QUEST_SONG_SONATA)) && !CHECK_QUEST_ITEM(i + QUEST_SONG_SONATA) && + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) { + if ((i + QUEST_SONG_SONATA) == pauseCtx->cursorSlot[PAUSE_QUEST]) { + pauseCtx->questVtx[j + 0].v.ob[0] = pauseCtx->questVtx[j + 2].v.ob[0] = + pauseCtx->questVtx[j + 0].v.ob[0] - 2; + + pauseCtx->questVtx[j + 1].v.ob[0] = pauseCtx->questVtx[j + 3].v.ob[0] = + pauseCtx->questVtx[j + 1].v.ob[0] + 4; + + pauseCtx->questVtx[j + 0].v.ob[1] = pauseCtx->questVtx[j + 1].v.ob[1] = + pauseCtx->questVtx[j + 0].v.ob[1] + 2; + + pauseCtx->questVtx[j + 2].v.ob[1] = pauseCtx->questVtx[j + 3].v.ob[1] = + pauseCtx->questVtx[j + 2].v.ob[1] - 4; + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sQuestSongsPrimRed[i], sQuestSongsPrimGreen[i], + sQuestSongsPrimBlue[i], pauseCtx->alpha); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + } + + // Draw Bombers Notebook + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, &D_08061000, 32, 32, 0); + } + + j += 4; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + // Loop over quest item upgrades + for (i = 0; i < 2; i++, j += 4) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (GET_CUR_UPG_VALUE(sQuestUpgrades[i]) != 0) { + KaleidoScope_DrawTexQuadRGBA32( + play->state.gfxCtx, sQuestUpgradeTextures[i][GET_CUR_UPG_VALUE(sQuestUpgrades[i]) - 1], 32, 32, 0); + } + } + + // Skip over &pauseCtx->questVtx[84], which should be `QUEST_SKULL_TOKEN` + j += 4; + + sp1CA = ABS_ALT(sQuestHpPrimRed - sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][0]) / sQuestHpColorTimer; + sp1C8 = ABS_ALT(sQuestHpPrimGreen - sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][1]) / sQuestHpColorTimer; + sp1C6 = ABS_ALT(sQuestHpPrimBlue - sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][2]) / sQuestHpColorTimer; + sp1C4 = ABS_ALT(sQuestHpPrimAlpha - sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][3]) / sQuestHpColorTimer; + + if (sQuestHpPrimRed >= sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][0]) { + sQuestHpPrimRed -= sp1CA; + } else { + sQuestHpPrimRed += sp1CA; + } + + if (sQuestHpPrimGreen >= sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][1]) { + sQuestHpPrimGreen -= sp1C8; + } else { + sQuestHpPrimGreen += sp1C8; + } + + if (sQuestHpPrimBlue >= sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][2]) { + sQuestHpPrimBlue -= sp1C6; + } else { + sQuestHpPrimBlue += sp1C6; + } + + if (sQuestHpPrimAlpha >= sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][3]) { + sQuestHpPrimAlpha -= sp1C4; + } else { + sQuestHpPrimAlpha += sp1C4; + } + + sQuestHpColorTimer--; + if (sQuestHpColorTimer == 0) { + sQuestHpPrimRed = sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][0]; + sQuestHpPrimGreen = sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][1]; + sQuestHpPrimBlue = sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][2]; + sQuestHpPrimAlpha = sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][3]; + sQuestHpColorTimer = sQuestHpColorTimerInit[sQuestHpPrimColorTargetIndex]; + if (++sQuestHpPrimColorTargetIndex > 3) { + sQuestHpPrimColorTargetIndex = 0; + } + } + + if ((GET_SAVE_INVENTORY_QUEST_ITEMS >> QUEST_HEART_PIECE_COUNT) != 0) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + if ((pauseCtx->state == 4) || (pauseCtx->state == 0x1A)) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sQuestHpPrimColorTargets[0][0], sQuestHpPrimColorTargets[0][1], + sQuestHpPrimColorTargets[0][2], pauseCtx->alpha); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sQuestHpPrimRed, sQuestHpPrimGreen, sQuestHpPrimBlue, + sQuestHpPrimAlpha); + } + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + + POLY_OPA_DISP = func_8010DC58( + POLY_OPA_DISP, + gItemIcons[(0x7A + ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) >> QUEST_HEART_PIECE_COUNT))], 48, 48, 0); + } + + j += 4; + + if (pauseCtx->state == 6) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + if (pauseCtx->unk_200 == 2) { + // Draw ocarina buttons as they are played back + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + + if (pauseCtx->ocarinaStaff->pos != 0) { + if (sQuestSongPlayedOcarinaButtonsNum == (pauseCtx->ocarinaStaff->pos - 1)) { + sQuestSongPlayedOcarinaButtonsNum++; + sQuestSongPlayedOcarinaButtons[pauseCtx->ocarinaStaff->pos - 1] = + pauseCtx->ocarinaStaff->buttonIndex; + } + + for (i = 0, k = 0; i < 8; i++, k += 4, j += 4) { + if (sQuestSongPlayedOcarinaButtons[i] == OCARINA_BTN_INVALID) { + break; + } + + if (sQuestSongPlayedOcarinaButtonsAlpha[i] != 255) { + sQuestSongPlayedOcarinaButtonsAlpha[i] += 50; + if (sQuestSongPlayedOcarinaButtonsAlpha[i] >= 255) { + sQuestSongPlayedOcarinaButtonsAlpha[i] = 255; + } + } + + pauseCtx->questVtx[j + 0].v.ob[1] = pauseCtx->questVtx[j + 1].v.ob[1] = + pauseCtx->ocarinaButtonsY[sQuestSongPlayedOcarinaButtons[i]]; + + pauseCtx->questVtx[j + 2].v.ob[1] = pauseCtx->questVtx[j + 3].v.ob[1] = + pauseCtx->questVtx[j + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (sQuestSongPlayedOcarinaButtons[i] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 150, 255, sQuestSongPlayedOcarinaButtonsAlpha[i]); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, sQuestSongPlayedOcarinaButtonsAlpha[i]); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + + POLY_OPA_DISP = func_8010DC58(POLY_OPA_DISP, + sOcarinaButtonTextures[sQuestSongPlayedOcarinaButtons[i]], 16, 16, 0); + } + } + } else if (((pauseCtx->unk_200 >= 4) && (pauseCtx->unk_200 <= 6)) || (pauseCtx->unk_200 == 8)) { + // Draw the buttons for playing a song + sp1C8 = pauseCtx->ocarinaSongIndex; + sp1CA = gOcarinaSongButtons[sp1C8].numButtons; + + i = j; + + for (k = 0; k < sp1CA; k++, j += 4) { + pauseCtx->questVtx[j + 0].v.ob[1] = pauseCtx->questVtx[j + 1].v.ob[1] = + pauseCtx->ocarinaButtonsY[gOcarinaSongButtons[sp1C8].buttonIndex[k]]; + + pauseCtx->questVtx[j + 2].v.ob[1] = pauseCtx->questVtx[j + 3].v.ob[1] = + pauseCtx->questVtx[j + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (pauseCtx->unk_200 == 8) { + // Draw ocarina buttons colored + if (gOcarinaSongButtons[sp1C8].buttonIndex[k] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 150, 255, 200); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, 200); + } + } else { + // Gray out buttons while reading ocarina song inputs + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 150, 150, 150, 150); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + + POLY_OPA_DISP = func_8010DC58( + POLY_OPA_DISP, sOcarinaButtonTextures[gOcarinaSongButtons[sp1C8].buttonIndex[k]], 16, 16, 0); + } + + if (pauseCtx->unk_200 != 8) { + pauseCtx->ocarinaStaff = AudioOcarina_GetPlayingStaff(); + + // Update ocarina song inputs + if (pauseCtx->ocarinaStaff->pos != 0) { + if (sQuestSongPlayedOcarinaButtonsNum == (pauseCtx->ocarinaStaff->pos - 1)) { + if (pauseCtx->ocarinaStaff->buttonIndex <= OCARINA_BTN_C_UP) { + sQuestSongPlayedOcarinaButtons[pauseCtx->ocarinaStaff->pos - 1] = + pauseCtx->ocarinaStaff->buttonIndex; + sQuestSongPlayedOcarinaButtons[pauseCtx->ocarinaStaff->pos] = OCARINA_BTN_INVALID; + sQuestSongPlayedOcarinaButtonsNum++; + } + } + } + + // Draw the buttons colored as the ocarina song inputs are read from + j = i + 32; + k = 0; + for (; k < 8; k++, j += 4) { + if (sQuestSongPlayedOcarinaButtons[k] == OCARINA_BTN_INVALID) { + continue; + } + + if (sQuestSongPlayedOcarinaButtonsAlpha[k] != 255) { + sQuestSongPlayedOcarinaButtonsAlpha[k] += 50; + if (sQuestSongPlayedOcarinaButtonsAlpha[k] >= 255) { + sQuestSongPlayedOcarinaButtonsAlpha[k] = 255; + } + } + + pauseCtx->questVtx[j + 0].v.ob[1] = pauseCtx->questVtx[j + 1].v.ob[1] = + pauseCtx->ocarinaButtonsY[sQuestSongPlayedOcarinaButtons[k]]; + + pauseCtx->questVtx[j + 2].v.ob[1] = pauseCtx->questVtx[j + 3].v.ob[1] = + pauseCtx->questVtx[j + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (sQuestSongPlayedOcarinaButtons[k] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 150, 255, sQuestSongPlayedOcarinaButtonsAlpha[k]); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, sQuestSongPlayedOcarinaButtonsAlpha[k]); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + + POLY_OPA_DISP = func_8010DC58(POLY_OPA_DISP, + sOcarinaButtonTextures[sQuestSongPlayedOcarinaButtons[k]], 16, 16, 0); + } + + if (pauseCtx->unk_200 == 4) { + for (k = 0; k < 8; k++) { + sQuestSongPlayedOcarinaButtons[k] = OCARINA_BTN_INVALID; + sQuestSongPlayedOcarinaButtonsAlpha[k] = 0; + } + + sQuestSongPlayedOcarinaButtonsNum = 0; + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_StartDefault((1 << pauseCtx->ocarinaSongIndex) | 0x80000000); + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + pauseCtx->ocarinaStaff->pos = 0; + pauseCtx->ocarinaStaff->state = 0xFE; + pauseCtx->unk_200 = 5; + } + } + } + } + + // Draw Skull Token Count + // QUEST_SKULL_TOKEN never properly set, see Item_Give(), + // Vertices not well placed, digits are not aligned and placed in unintended positions + if (CHECK_QUEST_ITEM(QUEST_SKULL_TOKEN) && ((play->sceneId == SCENE_KINSTA1) || (play->sceneId == SCENE_KINDAN2))) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + skullTokenDigits[0] = skullTokenDigits[1] = 0; + skullTokenDigits[2] = Inventory_GetSkullTokenCount(play->sceneId); + + while (skullTokenDigits[2] >= 100) { + skullTokenDigits[0]++; + skullTokenDigits[2] -= 100; + } + + while (skullTokenDigits[2] >= 10) { + skullTokenDigits[1]++; + skullTokenDigits[2] -= 10; + } + + //! @bug: &pauseCtx->questVtx[84] is the questVtx for skull tokens + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[152], 24, 0); + + // Loop over two sets of digits, the first is shadowed, the second is colored + for (k = 0, i = 0; k < 2; k++) { + if (k == 0) { + // shadow + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, pauseCtx->alpha); + } else { + if (Inventory_GetSkullTokenCount(play->sceneId) == 100) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 50, 50, pauseCtx->alpha); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + } + } + + isDigitDrawn = false; + for (j = 0; j < 3; j++, i += 4) { + if ((j >= 2) || (skullTokenDigits[j] != 0) || isDigitDrawn) { + gDPLoadTextureBlock(POLY_OPA_DISP++, ((u8*)gCounterDigit0Tex + (8 * 16 * skullTokenDigits[j])), + G_IM_FMT_I, G_IM_SIZ_8b, 8, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, i, i + 2, i + 3, i + 1, 0); + + isDigitDrawn = true; + } + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} +#else +s16 sQuestRemainsColorTimer = 20; +s16 sQuestRemainsColorTimerIndex = 0; +s16 sQuestHpPrimRed = 0; +s16 sQuestHpPrimGreen = 0; +s16 sQuestHpPrimBlue = 0; +s16 sQuestHpPrimAlpha = 0; +s16 sQuestHpColorTimer = 20; +s16 sQuestHpPrimColorTargetIndex = 0; +TexturePtr sOcarinaButtonTextures[] = { + gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, }; - -s16 D_8082AF6C[] = { - 255, 255, 255, 255, 255, 255, -}; - -s16 D_8082AF78[] = { - 255, 255, 255, 255, 255, 255, -}; - -s16 D_8082AF84[] = { - 150, 150, 150, 150, 150, 150, -}; - -s16 D_8082AF90 = 20; - -s32 D_8082AF94 = 0; - -s32 D_8082AF98 = 0; - -s32 D_8082AF9C = 0; - -s32 D_8082AFA0 = 0; - -s32 D_8082AFA4 = 0; - -s16 D_8082AFA8 = 20; - -s32 D_8082AFAC = 0; - -void* D_8082AFB0[] = { - 0x020024A0, 0x020025A0, 0x020026A0, 0x020027A0, 0x020028A0, -}; - -s16 D_8082AFC4[] = { +s16 sQuestSongsPrimRed[] = { 150, 255, 100, 255, 255, 255, 255, 255, 255, 255, 255, 255, }; - -s16 D_8082AFDC[] = { +s16 sQuestSongsPrimGreen[] = { 255, 80, 150, 160, 100, 240, 255, 255, 255, 255, 255, 255, }; - -s16 D_8082AFF4[] = { 100, 40, 255, 0, 255, 100, 255, 255, 255, 255, 255, 255 }; - -void* D_8082B00C[] = { - 0x08053000, 0x08054000, 0x08055000, 0x08056000, 0x08057000, 0x08058000, +s16 sQuestSongsPrimBlue[] = { + 100, 40, 255, 0, 255, 100, 255, 255, 255, 255, 255, 255, }; - -s16 D_8082B024 = 1; - -s16 D_8082B028 = 0; - -s16 D_8082B02C[] = { - 0xFFFF, 0x0003, 0x0002, 0x0001, 0x0000, 0x0004, 0x0003, 0xFFFE, 0x0000, 0x0005, 0x0016, 0x0003, 0x0000, 0x0004, - 0x0002, 0x0001, 0x0001, 0x0014, 0x0005, 0xFFFE, 0x0002, 0x0013, 0x0010, 0x0004, 0x000C, 0xFFFF, 0xFFFD, 0x0007, - 0x000D, 0xFFFF, 0x0006, 0x0008, 0x000E, 0xFFFF, 0x0007, 0x0009, 0x000F, 0xFFFF, 0x0008, 0x000A, 0x0010, 0xFFFF, - 0x0009, 0x0013, 0x0011, 0xFFFF, 0x000A, 0x0005, 0x0012, 0x0006, 0xFFFD, 0x000D, 0x0012, 0x0007, 0x000C, 0x000E, - 0x0016, 0x0008, 0x000D, 0x000F, 0x0016, 0x0009, 0x000E, 0x0010, 0x0016, 0x000A, 0x000F, 0x0005, 0x0016, 0x000B, - 0x0010, 0x0005, 0xFFFF, 0x000C, 0xFFFD, 0x0016, 0x0005, 0xFFFF, 0x000A, 0x0014, 0x0004, 0xFFFF, 0x0013, 0xFFFE, - 0x0013, 0x000C, 0xFFFD, 0x0016, 0xFFFF, 0x0010, 0x0012, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +TexturePtr sQuestUpgradeTextures[][3] = { + { 0x08053000, 0x08054000, 0x08055000 }, + { 0x08056000, 0x08057000, 0x08058000 }, }; +u8 sQuestUpgrades[] = { UPG_QUIVER, UPG_BOMB_BAG }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawQuestStatus.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808160A0.s") +typedef enum { + /* -3 */ CURSOR_TO_LEFT = -3, // Cursor on the "scroll to left page" position + /* -2 */ CURSOR_TO_RIGHT, // Cursor on the "scroll to right page" position + /* -1 */ CURSOR_NONE // No position in that direction, cursor stays where it is +} CursorPointNext; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80817B5C.s") +typedef struct { + /* 0x0 */ s16 up; + /* 0x2 */ s16 down; + /* 0x4 */ s16 left; + /* 0x6 */ s16 right; +} CursorPointDirection; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80818904.s") +void KaleidoScope_UpdateQuestCursor(PlayState* play) { + static s16 sQuestSongPlaybackDelayTimer = 0; + static CursorPointDirection sCursorPointLinks[] = { + { CURSOR_NONE, QUEST_REMAINS_TWINMOLD, QUEST_REMAINS_GYORG, QUEST_REMAINS_GOHT }, // QUEST_REMAINS_ODOLWA + { QUEST_REMAINS_ODOLWA, QUEST_SHIELD, QUEST_REMAINS_TWINMOLD, CURSOR_TO_RIGHT }, // QUEST_REMAINS_GOHT + { QUEST_REMAINS_ODOLWA, QUEST_SWORD, QUEST_HEART_PIECE, QUEST_REMAINS_TWINMOLD }, // QUEST_REMAINS_GYORG + { QUEST_REMAINS_ODOLWA, QUEST_SHIELD, QUEST_REMAINS_GYORG, QUEST_REMAINS_GOHT }, // QUEST_REMAINS_TWINMOLD + { QUEST_REMAINS_GOHT, QUEST_BOMB_BAG, QUEST_SWORD, CURSOR_TO_RIGHT }, // QUEST_SHIELD + { QUEST_REMAINS_GYORG, QUEST_QUIVER, QUEST_SONG_STORMS, QUEST_SHIELD }, // QUEST_SWORD + { QUEST_SONG_TIME, CURSOR_NONE, CURSOR_TO_LEFT, QUEST_SONG_LULLABY }, // QUEST_SONG_SONATA + { QUEST_SONG_HEALING, CURSOR_NONE, QUEST_SONG_SONATA, QUEST_SONG_BOSSA_NOVA }, // QUEST_SONG_LULLABY + { QUEST_SONG_EPONA, CURSOR_NONE, QUEST_SONG_LULLABY, QUEST_SONG_ELEGY }, // QUEST_SONG_BOSSA_NOVA + { QUEST_SONG_SOARING, CURSOR_NONE, QUEST_SONG_BOSSA_NOVA, QUEST_SONG_OATH }, // QUEST_SONG_ELEGY + { QUEST_SONG_STORMS, CURSOR_NONE, QUEST_SONG_ELEGY, QUEST_QUIVER }, // QUEST_SONG_OATH + { QUEST_SONG_SUN, CURSOR_NONE, QUEST_SONG_OATH, QUEST_SWORD }, // QUEST_SONG_SARIA + { QUEST_BOMBERS_NOTEBOOK, QUEST_SONG_SONATA, CURSOR_TO_LEFT, QUEST_SONG_HEALING }, // QUEST_SONG_TIME + { QUEST_BOMBERS_NOTEBOOK, QUEST_SONG_LULLABY, QUEST_SONG_TIME, QUEST_SONG_EPONA }, // QUEST_SONG_HEALING + { QUEST_HEART_PIECE, QUEST_SONG_BOSSA_NOVA, QUEST_SONG_HEALING, QUEST_SONG_SOARING }, // QUEST_SONG_EPONA + { QUEST_HEART_PIECE, QUEST_SONG_ELEGY, QUEST_SONG_EPONA, QUEST_SONG_STORMS }, // QUEST_SONG_SOARING + { QUEST_HEART_PIECE, QUEST_SONG_OATH, QUEST_SONG_SOARING, QUEST_SWORD }, // QUEST_SONG_STORMS + { QUEST_HEART_PIECE, QUEST_SONG_SARIA, QUEST_SONG_STORMS, QUEST_SWORD }, // QUEST_SONG_SUN + { CURSOR_NONE, QUEST_SONG_TIME, CURSOR_TO_LEFT, QUEST_HEART_PIECE }, // QUEST_BOMBERS_NOTEBOOK + { QUEST_SWORD, CURSOR_NONE, QUEST_SONG_OATH, QUEST_BOMB_BAG }, // QUEST_QUIVER + { QUEST_SHIELD, CURSOR_NONE, QUEST_QUIVER, CURSOR_TO_RIGHT }, // QUEST_BOMB_BAG + { QUEST_QUIVER, QUEST_SONG_TIME, CURSOR_TO_LEFT, QUEST_HEART_PIECE }, // QUEST_SKULL_TOKEN + { CURSOR_NONE, QUEST_SONG_STORMS, QUEST_BOMBERS_NOTEBOOK, QUEST_REMAINS_GYORG }, // QUEST_HEART_PIECE + }; + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s32 pad; + s16 nextCursorPoint; + s16 oldCursorPoint; + s16 i; + u16 cursor; + u16 cursorItem; + + pauseCtx->nameColorSet = PAUSE_NAME_COLOR_SET_WHITE; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + + // != 0 + if ((pauseCtx->state == 6) && (!pauseCtx->unk_200 || (pauseCtx->unk_200 == 5) || (pauseCtx->unk_200 == 8)) && + (pauseCtx->pageIndex == PAUSE_QUEST) && !pauseCtx->itemDescriptionOn) { + if (pauseCtx->cursorSpecialPos == 0) { + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_QUEST]; + + if (pauseCtx->stickAdjX < -30) { + // Move cursor left + if (pauseCtx->unk_200 == 5) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + pauseCtx->unk_298 = 4.0f; + + nextCursorPoint = sCursorPointLinks[oldCursorPoint].left; + if (nextCursorPoint == CURSOR_TO_LEFT) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + pauseCtx->unk_200 = 0; + if (interfaceCtx->unk_212 == 6) { + func_8011552C(play, 0x15); + } + return; + } else { + while (nextCursorPoint > CURSOR_NONE) { + if (KaleidoScope_UpdateQuestStatusPoint(pauseCtx, nextCursorPoint)) { + break; + } + nextCursorPoint = sCursorPointLinks[nextCursorPoint].left; + } + } + } else if (pauseCtx->stickAdjX > 30) { + // Move cursor right + if (pauseCtx->unk_200 == 5) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + pauseCtx->unk_298 = 4.0f; + nextCursorPoint = sCursorPointLinks[oldCursorPoint].right; + + if (nextCursorPoint == CURSOR_TO_RIGHT) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + pauseCtx->unk_200 = 0; + return; + } + + while (nextCursorPoint > CURSOR_NONE) { + if (KaleidoScope_UpdateQuestStatusPoint(pauseCtx, nextCursorPoint)) { + break; + } + nextCursorPoint = sCursorPointLinks[nextCursorPoint].right; + } + } + + if (pauseCtx->stickAdjY < -30) { + // Move cursor down + if (pauseCtx->unk_200 == 5) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + nextCursorPoint = sCursorPointLinks[oldCursorPoint].down; + + while (nextCursorPoint > CURSOR_NONE) { + pauseCtx->unk_298 = 4.0f; + if (KaleidoScope_UpdateQuestStatusPoint(pauseCtx, nextCursorPoint)) { + break; + } + nextCursorPoint = sCursorPointLinks[nextCursorPoint].down; + } + } else if (pauseCtx->stickAdjY > 30) { + // Move cursor up + if (pauseCtx->unk_200 == 5) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + nextCursorPoint = sCursorPointLinks[oldCursorPoint].up; + while (nextCursorPoint > CURSOR_NONE) { + pauseCtx->unk_298 = 4.0f; + if (KaleidoScope_UpdateQuestStatusPoint(pauseCtx, nextCursorPoint)) { + break; + } + nextCursorPoint = sCursorPointLinks[nextCursorPoint].up; + } + } + + // if the cursor point changed + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_QUEST]) { + pauseCtx->unk_200 = 0; + play_sound(NA_SE_SY_CURSOR); + } + + // Update cursor item and slot + if (pauseCtx->cursorPoint[PAUSE_QUEST] != QUEST_HEART_PIECE) { + if (pauseCtx->cursorPoint[PAUSE_QUEST] <= QUEST_REMAINS_TWINMOLD) { + // Boss Remains + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursorItem = ITEM_REMAINS_ODOLWA + pauseCtx->cursorPoint[PAUSE_QUEST]; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_BOMBERS_NOTEBOOK) { + // Bombers Notebook + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursorItem = ITEM_BOMBERS_NOTEBOOK; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_SHIELD) { + // Shield + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { + cursorItem = (ITEM_SHIELD_HERO - EQUIP_TYPE_SHIELD) + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD); + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_SWORD) { + // Sword + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_NONE) { + cursorItem = + (ITEM_SWORD_KOKIRI - EQUIP_VALUE_SWORD_KOKIRI) + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD); + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] <= QUEST_SONG_SUN) { + // Songs + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursorItem = ITEM_WALLET_GIANT + pauseCtx->cursorPoint[PAUSE_QUEST]; + } else if ((pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_SONG_LULLABY) && + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { + cursorItem = ITEM_SONG_LULLABY_INTRO; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_QUIVER) { + // Quiver Upgrade + if (GET_CUR_UPG_VALUE(UPG_QUIVER) != 0) { + cursorItem = (ITEM_QUIVER_30 - 1) + GET_CUR_UPG_VALUE(UPG_QUIVER); + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_BOMB_BAG) { + // Bomb Bag Upgrade + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) != 0) { + cursorItem = (ITEM_BOMB_BAG_20 - 1) + GET_CUR_UPG_VALUE(UPG_BOMB_BAG); + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else { + // Heart Piece Count + if ((GET_SAVE_INVENTORY_QUEST_ITEMS >> QUEST_HEART_PIECE_COUNT) != 0) { + cursorItem = ITEM_HEART_CONTAINER; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } + + cursor = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = cursor; + + if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && + (pauseCtx->cursorSpecialPos == 0)) { + if ((cursor >= QUEST_SONG_SONATA) && (cursor <= QUEST_SONG_SUN)) { + // Handle part of the ocarina songs playback + if ((CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST]) || + ((cursor == QUEST_SONG_LULLABY) && !CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST]) && + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) && + (msgCtx->msgLength == 0)) { + // The cursor is on a learned song + // Set some things up for song playback + + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursor = pauseCtx->cursorSlot[PAUSE_QUEST]; + } else { + cursor = QUEST_BOMB_BAG; + } + + pauseCtx->ocarinaSongIndex = gOcarinaSongItemMap[cursor - QUEST_SONG_SONATA]; + sQuestSongPlaybackDelayTimer = 10; + + for (i = 0; i < 8; i++) { + sQuestSongPlayedOcarinaButtons[i] = OCARINA_BTN_INVALID; + sQuestSongPlayedOcarinaButtonsAlpha[i] = 0; + } + + sQuestSongPlayedOcarinaButtonsNum = 0; + + // Setup the song to receive user input, immediately cancelled below + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_StartDefault((1 << pauseCtx->ocarinaSongIndex) | 0x80000000); + + // Clear the playback staff + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + pauseCtx->ocarinaStaff->pos = 0; + pauseCtx->ocarinaStaff->state = 0xFF; + + pauseCtx->ocarinaButtonsY[OCARINA_BTN_A] = -62; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_DOWN] = -56; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_RIGHT] = -49; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_LEFT] = -46; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_UP] = -41; + + pauseCtx->unk_200 = 8; + + if (interfaceCtx->unk_212 != 6) { + func_8011552C(play, 6); + } + + // Stop receiving input to play a song as mentioned above + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } else { + if (interfaceCtx->unk_212 != 6) { + func_8011552C(play, 6); + } + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } + } else { + if ((cursor == QUEST_BOMBERS_NOTEBOOK) && (pauseCtx->cursorItem[PAUSE_QUEST] != PAUSE_ITEM_NONE)) { + if (interfaceCtx->unk_212 != 6) { + func_8011552C(play, 6); + } + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_BLUE; + } else if (interfaceCtx->unk_212 == 6) { + func_8011552C(play, 0x15); + } + + if ((pauseCtx->cursorItem[PAUSE_QUEST] != PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && (msgCtx->msgLength == 0)) { + if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_BOMBERS_NOTEBOOK) { + play->pauseCtx.bombersNotebookOpen = true; + pauseCtx->unk_200 = 0x10; + play_sound(NA_SE_SY_DECIDE); + } else { + pauseCtx->itemDescriptionOn = true; + if (pauseCtx->cursorYIndex[PAUSE_QUEST] < 2) { + if (pauseCtx->cursorItem[PAUSE_QUEST] < ITEM_REMAINS_ODOLWA) { + func_801514B0(play, 0x1737 + pauseCtx->cursorItem[PAUSE_QUEST], 1); + } else { + func_801514B0(play, 0x173B + pauseCtx->cursorItem[PAUSE_QUEST], 3); + } + } else { + if (pauseCtx->cursorItem[PAUSE_QUEST] < ITEM_REMAINS_ODOLWA) { + func_801514B0(play, 0x1737 + pauseCtx->cursorItem[PAUSE_QUEST], 1); + } else { + func_801514B0(play, 0x173B + pauseCtx->cursorItem[PAUSE_QUEST], 1); + } + } + } + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } + } else if (pauseCtx->unk_200 == 5) { + // Abort reading ocarina song input if the stick is moved + if ((pauseCtx->stickAdjX != 0) || (pauseCtx->stickAdjY != 0)) { + pauseCtx->unk_200 = 0; + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + } else if ((pauseCtx->unk_200 == 8) && CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && + (msgCtx->msgLength == 0) && (cursor >= QUEST_SONG_SONATA) && (cursor <= QUEST_SONG_SUN)) { + pauseCtx->unk_200 = 9; + sQuestSongPlaybackDelayTimer = 10; + } + + if (pauseCtx->cursorSpecialPos == 0) { + if ((pauseCtx->cursorSlot[PAUSE_QUEST] >= 6) && (pauseCtx->cursorSlot[PAUSE_QUEST] < 0x12) && + ((pauseCtx->unk_200 <= 2) || (pauseCtx->unk_200 == 5) || (pauseCtx->unk_200 == 8)) && + (pauseCtx->cursorItem[pauseCtx->pageIndex] != PAUSE_ITEM_NONE)) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_BLUE; + if ((pauseCtx->unk_200 >= 2) && (pauseCtx->unk_200 <= 6)) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + } + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickAdjX > 30) { + if (pauseCtx->unk_200 == 5) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + + func_80821A04(play); + + pauseCtx->cursorPoint[PAUSE_QUEST] = QUEST_BOMBERS_NOTEBOOK; + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + cursorItem = ITEM_BOMBERS_NOTEBOOK; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + + cursor = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = cursor; + } + } else if (pauseCtx->stickAdjX < -30) { + if (pauseCtx->unk_200 == 5) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + + func_80821A04(play); + + pauseCtx->cursorPoint[PAUSE_QUEST] = QUEST_REMAINS_GOHT; + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursorItem = (ITEM_REMAINS_GOHT - 1) + pauseCtx->cursorPoint[PAUSE_QUEST]; + if (pauseCtx->cursorPoint[PAUSE_QUEST] != QUEST_REMAINS_ODOLWA) { + // This condition is always true as `cursorPoint` is set three lines above + cursorItem = ITEM_MASK_GIANT; + } + } else { + cursorItem = PAUSE_ITEM_NONE; + } + + cursor = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = cursor; + } + } else if (pauseCtx->unk_200 == 9) { + // After a short delay, start the playback of the selected song + + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_BLUE; + sQuestSongPlaybackDelayTimer--; + if (sQuestSongPlaybackDelayTimer == 0) { + for (i = 0; i < 8; i++) { + sQuestSongPlayedOcarinaButtons[i] = OCARINA_BTN_INVALID; + sQuestSongPlayedOcarinaButtonsAlpha[i] = 0; + } + sQuestSongPlayedOcarinaButtonsNum = 0; + + pauseCtx->ocarinaButtonsY[OCARINA_BTN_A] = -62; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_DOWN] = -56; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_RIGHT] = -49; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_LEFT] = -46; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_UP] = -41; + + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursor = pauseCtx->cursorSlot[PAUSE_QUEST]; + } else { + cursor = QUEST_BOMB_BAG; + } + + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); + pauseCtx->ocarinaSongIndex = gOcarinaSongItemMap[cursor - QUEST_SONG_SONATA]; + AudioOcarina_SetPlaybackSong(pauseCtx->ocarinaSongIndex + 1, 1); + pauseCtx->unk_200 = 2; + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + pauseCtx->ocarinaStaff->pos = 0; + } + } +} + +s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s16 point) { + pauseCtx->cursorPoint[PAUSE_QUEST] = point; + + return true; +} diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index c1f67b0797..1152db2029 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -472,7 +472,7 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { // Loop over columns (i), (counterDigits[1] stores rectLeft) for (counterDigits[1] = 44, i = 0; i < 4; i++) { counterDigits[2] = 0; - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA + i)) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA + i)) { counterDigits[2] = 1; } KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 112); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index be23b56dec..120a07c0a9 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -306,8 +306,8 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { } gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j + 0], 4, 0); - KaleidoScope_DrawQuadTextureRGBA32(play->state.gfxCtx, - gItemIcons[((void)0, gSaveContext.save.inventory.items[i])], 32, 32, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, + gItemIcons[((void)0, gSaveContext.save.inventory.items[i])], 32, 32, 0); } } @@ -354,8 +354,8 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { s16 moveCursorResult; s16 pad2; - pauseCtx->cursorColorSet = 0; - pauseCtx->nameColorSet = 0; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + pauseCtx->nameColorSet = PAUSE_NAME_COLOR_SET_WHITE; if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && !pauseCtx->itemDescriptionOn) { @@ -367,7 +367,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // Move cursor left/right if (pauseCtx->cursorSpecialPos == 0) { // cursor is currently on a slot - pauseCtx->cursorColorSet = 2; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; if (ABS_ALT(pauseCtx->stickAdjX) > 30) { cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; @@ -561,7 +561,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { } cursorSlot = pauseCtx->cursorPoint[PAUSE_ITEM]; - pauseCtx->cursorColorSet = 2; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; @@ -571,7 +571,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { if (cursorItem == ITEM_NONE) { cursorItem = PAUSE_ITEM_NONE; - pauseCtx->cursorColorSet = 0; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; } if ((cursorItem != (u32)PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { @@ -691,7 +691,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { play_sound(NA_SE_SY_CURSOR); } } else if ((pauseCtx->unk_200 == 3) && (pauseCtx->pageIndex == PAUSE_ITEM)) { - pauseCtx->cursorColorSet = 2; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; } } diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c index 5f4c136e08..823a3d63f2 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c @@ -306,7 +306,7 @@ void KaleidoScope_UpdateDungeonCursor(PlayState* play) { if (pauseCtx->state == 6) { if ((pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { - pauseCtx->cursorColorSet = 0; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MAP]; if (pauseCtx->stickAdjX > 30) { pauseCtx->unk_298 = 4.0f; @@ -826,7 +826,7 @@ void KaleidoScope_UpdateWorldMapCursor(PlayState* play) { s16 oldCursorPoint; if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { - pauseCtx->cursorColorSet = 0; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { @@ -937,7 +937,7 @@ void KaleidoScope_UpdateWorldMapCursor(PlayState* play) { play_sound(NA_SE_SY_CURSOR); } } else if (pauseCtx->state == 0x17) { - pauseCtx->cursorColorSet = 4; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_BLUE; oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; if (pauseCtx->stickAdjX > 30) { diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c index cedcbf8f32..77835026ff 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c @@ -257,7 +257,7 @@ void KaleidoScope_DrawMaskSelect(PlayState* play) { } gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j + 0], 4, 0); - KaleidoScope_DrawQuadTextureRGBA32( + KaleidoScope_DrawTexQuadRGBA32( play->state.gfxCtx, gItemIcons[((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS])], 32, 32, 0); } @@ -285,8 +285,8 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { s16 moveCursorResult; s16 pad2; - pauseCtx->cursorColorSet = 0; - pauseCtx->nameColorSet = 0; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + pauseCtx->nameColorSet = PAUSE_NAME_COLOR_SET_WHITE; if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_MASK) && !pauseCtx->itemDescriptionOn) { @@ -298,7 +298,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { // Move cursor left/right if (pauseCtx->cursorSpecialPos == 0) { // cursor is currently on a slot - pauseCtx->cursorColorSet = 2; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; if (ABS_ALT(pauseCtx->stickAdjX) > 30) { cursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; @@ -497,7 +497,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { } cursorSlot = pauseCtx->cursorPoint[PAUSE_MASK]; - pauseCtx->cursorColorSet = 2; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; @@ -513,7 +513,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { if (cursorItem == ITEM_NONE) { cursorItem = PAUSE_ITEM_NONE; - pauseCtx->cursorColorSet = 0; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; } if ((cursorItem != PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { @@ -614,7 +614,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { play_sound(NA_SE_SY_CURSOR); } } else if ((pauseCtx->unk_200 == 0xF) && (pauseCtx->pageIndex == PAUSE_MASK)) { - pauseCtx->cursorColorSet = 2; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; } } diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h index 72392390b2..14c16ddcd3 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h @@ -30,12 +30,19 @@ typedef enum { } EquipState; typedef enum { - /* 0 */ DEBUG_EDITOR_NONE, - /* 1 */ DEBUG_EDITOR_INVENTORY_INIT, - /* 2 */ DEBUG_EDITOR_INVENTORY, - /* 3 */ DEBUG_EDITOR_EVENTS + /* 0 */ DEBUG_EDITOR_NONE, + /* 1 */ DEBUG_EDITOR_INVENTORY_INIT, + /* 2 */ DEBUG_EDITOR_INVENTORY, + /* 3 */ DEBUG_EDITOR_EVENTS } DebugEditor; +#define PAUSE_NAME_COLOR_SET_WHITE 0 +#define PAUSE_NAME_COLOR_SET_GREY 1 + +#define PAUSE_CURSOR_COLOR_SET_WHITE 0 +#define PAUSE_CURSOR_COLOR_SET_YELLOW 2 +#define PAUSE_CURSOR_COLOR_SET_BLUE 4 + // To be used for Item-Page cursor and Mask-Page cursor typedef enum { /* 0 */ PAUSE_CURSOR_RESULT_NONE, @@ -51,8 +58,8 @@ typedef enum { // NES void KaleidoScope_MoveCursorToSpecialPos(PlayState* play, s16 cursorSpecialPos); -void KaleidoScope_DrawQuadTextureRGBA32(GraphicsContext* gfxCtx, TexturePtr texture, u16 width, u16 height, u16 point); -void KaleidoScope_SetView(PauseContext* pauseCtx, f32 x, f32 y, f32 z); +void KaleidoScope_DrawTexQuadRGBA32(GraphicsContext* gfxCtx, TexturePtr texture, u16 width, u16 height, u16 point); +void KaleidoScope_SetView(PauseContext* pauseCtx, f32 eyeX, f32 eyeY, f32 eyeZ); void func_80821A04(PlayState* play); // Map @@ -61,6 +68,10 @@ void KaleidoScope_UpdateDungeonCursor(PlayState* play); void KaleidoScope_DrawWorldMap(PlayState* play); void KaleidoScope_UpdateWorldMapCursor(PlayState* play); +// Collect +void KaleidoScope_DrawQuestStatus(PlayState* play); +void KaleidoScope_UpdateQuestCursor(PlayState* play); + // Item void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx); void KaleidoScope_DrawItemSelect(PlayState* play); @@ -72,6 +83,9 @@ void KaleidoScope_DrawMaskSelect(PlayState* play); void KaleidoScope_UpdateMaskCursor(PlayState* play); void KaleidoScope_UpdateMaskEquip(PlayState* play); +// Prompt +void KaleidoScope_UpdatePrompt(PlayState* play); + // Debug void KaleidoScope_DrawInventoryEditor(PlayState* play); void KaleidoScope_UpdateInventoryEditor(PlayState* play); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index 6c6754b3d7..a322fda1f3 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -222,30 +222,173 @@ s16 D_8082BB68[] = { 0x000E, 0xFFFE, 0xFFFE, 0xFFEE, 0xFFEE, 0x0000, }; -s16 D_8082BB74[] = { - 0x002D, 0x004E, 0x000A, 0x002D, 0x0050, 0x000B, 0xFF93, 0xFFA9, 0xFFBF, 0xFFD7, 0xFFED, 0xFFEE, 0xFF93, 0xFFA9, - 0xFFBF, 0xFFD7, 0xFFED, 0xFFEE, 0xFF99, 0x0007, 0x0052, 0xFF92, 0xFFCA, 0xFF9E, 0xFFAA, 0xFFB6, 0xFFC2, 0xFFCE, - 0xFFDA, 0xFFE6, 0xFFF2, 0xFF9E, 0xFFAA, 0xFFB6, 0xFFC2, 0xFFCE, 0xFFDA, 0xFFE6, 0xFFF2, 0x0000, +s16 sQuestVtxRectLeft[] = { + 45, // QUEST_REMAINS_ODOLWA + 78, // QUEST_REMAINS_GOHT + 10, // QUEST_REMAINS_GYORG + 45, // QUEST_REMAINS_TWINMOLD + 80, // QUEST_SHIELD + 11, // QUEST_SWORD + -109, // QUEST_SONG_SONATA + -87, // QUEST_SONG_LULLABY + -65, // QUEST_SONG_BOSSA_NOVA + -41, // QUEST_SONG_ELEGY + -19, // QUEST_SONG_OATH + -18, // QUEST_SONG_SARIA + -109, // QUEST_SONG_TIME + -87, // QUEST_SONG_HEALING + -65, // QUEST_SONG_EPONA + -41, // QUEST_SONG_SOARING + -19, // QUEST_SONG_STORMS + -18, // QUEST_SONG_SUN + -103, // QUEST_BOMBERS_NOTEBOOK + 7, // QUEST_QUIVER + 82, // QUEST_BOMB_BAG + -110, // QUEST_SKULL_TOKEN (unused) + -54, // QUEST_HEART_PIECE + -98, // ocarina song button index 0 + -86, // ocarina song button index 1 + -74, // ocarina song button index 2 + -62, // ocarina song button index 3 + -50, // ocarina song button index 4 + -38, // ocarina song button index 5 + -26, // ocarina song button index 6 + -14, // ocarina song button index 7 + -98, // ocarina input button index 0 + -86, // ocarina input button index 1 + -74, // ocarina input button index 2 + -62, // ocarina input button index 3 + -50, // ocarina input button index 4 + -38, // ocarina input button index 5 + -26, // ocarina input button index 6 + -14, // ocarina input button index 7 }; -s16 D_8082BBC4[] = { - 0x003E, 0x002A, 0x002A, 0x0014, 0xFFF7, 0xFFF7, 0xFFEC, 0xFFEC, 0xFFEC, 0xFFEC, 0xFFEC, 0xFFEC, 0x0002, 0x0002, - 0x0002, 0x0002, 0x0002, 0x0002, 0x0036, 0xFFD4, 0xFFD4, 0x0022, 0x003A, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, - 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0x0000, +s16 sQuestVtxRectTop[] = { + 62, // QUEST_REMAINS_ODOLWA + 42, // QUEST_REMAINS_GOHT + 42, // QUEST_REMAINS_GYORG + 20, // QUEST_REMAINS_TWINMOLD + -9, // QUEST_SHIELD + -9, // QUEST_SWORD + -20, // QUEST_SONG_SONATA + -20, // QUEST_SONG_LULLABY + -20, // QUEST_SONG_BOSSA_NOVA + -20, // QUEST_SONG_ELEGY + -20, // QUEST_SONG_OATH + -20, // QUEST_SONG_SARIA + 2, // QUEST_SONG_TIME + 2, // QUEST_SONG_HEALING + 2, // QUEST_SONG_EPONA + 2, // QUEST_SONG_SOARING + 2, // QUEST_SONG_STORMS + 2, // QUEST_SONG_SUN + 54, // QUEST_BOMBERS_NOTEBOOK + -44, // QUEST_QUIVER + -44, // QUEST_BOMB_BAG + 34, // QUEST_SKULL_TOKEN (unused) + 58, // QUEST_HEART_PIECE + -52, // ocarina song button index 0 + -52, // ocarina song button index 1 + -52, // ocarina song button index 2 + -52, // ocarina song button index 3 + -52, // ocarina song button index 4 + -52, // ocarina song button index 5 + -52, // ocarina song button index 6 + -52, // ocarina song button index 7 + -52, // ocarina input button index 0 + -52, // ocarina input button index 1 + -52, // ocarina input button index 2 + -52, // ocarina input button index 3 + -52, // ocarina input button index 4 + -52, // ocarina input button index 5 + -52, // ocarina input button index 6 + -52, // ocarina input button index 7 }; -s16 D_8082BC14[] = { - 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, - 0x0010, 0x0010, 0x0010, 0x0010, 0x0020, 0x0020, 0x0020, 0x0018, 0x0030, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, - 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, +s16 sQuestVtxWidths[] = { + 32, // QUEST_REMAINS_ODOLWA + 32, // QUEST_REMAINS_GOHT + 32, // QUEST_REMAINS_GYORG + 32, // QUEST_REMAINS_TWINMOLD + 32, // QUEST_SHIELD + 32, // QUEST_SWORD + 16, // QUEST_SONG_SONATA + 16, // QUEST_SONG_LULLABY + 16, // QUEST_SONG_BOSSA_NOVA + 16, // QUEST_SONG_ELEGY + 16, // QUEST_SONG_OATH + 16, // QUEST_SONG_SARIA + 16, // QUEST_SONG_TIME + 16, // QUEST_SONG_HEALING + 16, // QUEST_SONG_EPONA + 16, // QUEST_SONG_SOARING + 16, // QUEST_SONG_STORMS + 16, // QUEST_SONG_SUN + 32, // QUEST_BOMBERS_NOTEBOOK + 32, // QUEST_QUIVER + 32, // QUEST_BOMB_BAG + 24, // QUEST_SKULL_TOKEN (unused) + 48, // QUEST_HEART_PIECE + 16, // ocarina song button index 0 + 16, // ocarina song button index 1 + 16, // ocarina song button index 2 + 16, // ocarina song button index 3 + 16, // ocarina song button index 4 + 16, // ocarina song button index 5 + 16, // ocarina song button index 6 + 16, // ocarina song button index 7 + 16, // ocarina input button index 0 + 16, // ocarina input button index 1 + 16, // ocarina input button index 2 + 16, // ocarina input button index 3 + 16, // ocarina input button index 4 + 16, // ocarina input button index 5 + 16, // ocarina input button index 6 + 16, // ocarina input button index 7 }; -s16 D_8082BC64[] = { - 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, - 0x0018, 0x0018, 0x0018, 0x0018, 0x0020, 0x0020, 0x0020, 0x0018, 0x0030, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, - 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, +s16 sQuestVtxHeights[] = { + 32, // QUEST_REMAINS_ODOLWA + 32, // QUEST_REMAINS_GOHT + 32, // QUEST_REMAINS_GYORG + 32, // QUEST_REMAINS_TWINMOLD + 32, // QUEST_SHIELD + 32, // QUEST_SWORD + 24, // QUEST_SONG_SONATA + 24, // QUEST_SONG_LULLABY + 24, // QUEST_SONG_BOSSA_NOVA + 24, // QUEST_SONG_ELEGY + 24, // QUEST_SONG_OATH + 24, // QUEST_SONG_SARIA + 24, // QUEST_SONG_TIME + 24, // QUEST_SONG_HEALING + 24, // QUEST_SONG_EPONA + 24, // QUEST_SONG_SOARING + 24, // QUEST_SONG_STORMS + 24, // QUEST_SONG_SUN + 32, // QUEST_BOMBERS_NOTEBOOK + 32, // QUEST_QUIVER + 32, // QUEST_BOMB_BAG + 24, // QUEST_SKULL_TOKEN (unused) + 48, // QUEST_HEART_PIECE + 16, // ocarina song button index 0 + 16, // ocarina song button index 1 + 16, // ocarina song button index 2 + 16, // ocarina song button index 3 + 16, // ocarina song button index 4 + 16, // ocarina song button index 5 + 16, // ocarina song button index 6 + 16, // ocarina song button index 7 + 16, // ocarina input button index 0 + 16, // ocarina input button index 1 + 16, // ocarina input button index 2 + 16, // ocarina input button index 3 + 16, // ocarina input button index 4 + 16, // ocarina input button index 5 + 16, // ocarina input button index 6 + 16, // ocarina input button index 7 }; - f32 D_8082BCB4[] = { -62.0f, -36.0f, -10.0f, 16.0f, 42.0f, 68.0f, }; @@ -323,7 +466,7 @@ s32 D_8082BEB8[] = { 0, 0 }; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821A04.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawQuadTextureRGBA32.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawTexQuadRGBA32.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821CC4.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e6ace2b97b..77810cc224 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4197,9 +4197,9 @@ 0x80815770:("DayTelop_Noop",), 0x8081577C:("DayTelop_LoadGraphics",), 0x80815820:("DayTelop_Init",), - 0x808160A0:("func_808160A0",), - 0x80817B5C:("func_80817B5C",), - 0x80818904:("func_80818904",), + 0x808160A0:("KaleidoScope_DrawQuestStatus",), + 0x80817B5C:("KaleidoScope_UpdateQuestCursor",), + 0x80818904:("KaleidoScope_UpdateQuestStatusPoint",), 0x80818920:("KaleidoScope_DrawInventoryEditorText",), 0x808190C4:("KaleidoScope_DrawDigit",), 0x80819238:("KaleidoScope_DrawInventoryEditor",), @@ -4223,7 +4223,7 @@ 0x80821958:("func_80821958",), 0x80821984:("KaleidoScope_MoveCursorToSpecialPos",), 0x80821A04:("func_80821A04",), - 0x80821AD4:("KaleidoScope_DrawQuadTextureRGBA32",), + 0x80821AD4:("KaleidoScope_DrawTexQuadRGBA32",), 0x80821CC4:("func_80821CC4",), 0x80821D84:("func_80821D84",), 0x80821F30:("func_80821F30",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index ae80ee3681..4a5017ad5b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2003,7 +2003,7 @@ 0x801CFC98:("D_801CFC98","UNK_TYPE1","",0x1), 0x801CFCA4:("D_801CFCA4","UNK_TYPE2","",0x2), 0x801CFCAC:("D_801CFCAC","UNK_TYPE2","",0x2), - 0x801CFCB8:("D_801CFCB8","UNK_TYPE1","",0x1), + 0x801CFCB8:("gOcarinaSongItemMap","UNK_TYPE1","",0x1), 0x801CFCD8:("D_801CFCD8","UNK_TYPE2","",0x2), 0x801CFCE4:("D_801CFCE4","UNK_TYPE2","",0x2), 0x801CFCF0:("D_801CFCF0","UNK_TYPE2","",0x2), @@ -4660,32 +4660,32 @@ 0x80815FF4:("sDayLeftTextures","TexturePtr","[4]",0x10), 0x80816004:("sDayRightTextures","TexturePtr","[4]",0x10), 0x80816014:("sHoursLeftTextures","TexturePtr","[3]",0xC), - 0x8082AED0:("D_8082AED0","UNK_TYPE1","",0x1), - 0x8082AED8:("D_8082AED8","UNK_TYPE1","",0x1), - 0x8082AEE0:("D_8082AEE0","UNK_TYPE2","",0x2), - 0x8082AEE4:("D_8082AEE4","UNK_TYPE1","",0x1), - 0x8082AEF0:("D_8082AEF0","UNK_TYPE2","",0x2), - 0x8082AF04:("D_8082AF04","UNK_TYPE2","",0x2), - 0x8082AF24:("D_8082AF24","UNK_TYPE1","",0x1), - 0x8082AF6C:("D_8082AF6C","UNK_TYPE2","",0x2), - 0x8082AF78:("D_8082AF78","UNK_TYPE2","",0x2), - 0x8082AF84:("D_8082AF84","UNK_TYPE2","",0x2), - 0x8082AF90:("D_8082AF90","UNK_TYPE2","",0x2), - 0x8082AF94:("D_8082AF94","UNK_TYPE2","",0x2), - 0x8082AF98:("D_8082AF98","UNK_TYPE2","",0x2), - 0x8082AF9C:("D_8082AF9C","UNK_TYPE2","",0x2), - 0x8082AFA0:("D_8082AFA0","UNK_TYPE2","",0x2), - 0x8082AFA4:("D_8082AFA4","UNK_TYPE2","",0x2), - 0x8082AFA8:("D_8082AFA8","UNK_TYPE2","",0x2), - 0x8082AFAC:("D_8082AFAC","UNK_TYPE2","",0x2), - 0x8082AFB0:("D_8082AFB0","UNK_TYPE1","",0x1), - 0x8082AFC4:("D_8082AFC4","UNK_TYPE2","",0x2), - 0x8082AFDC:("D_8082AFDC","UNK_TYPE2","",0x2), - 0x8082AFF4:("D_8082AFF4","s16","[12]",0x18), - 0x8082B00C:("D_8082B00C","void*","[6]",0x18), - 0x8082B024:("D_8082B024","UNK_TYPE1","",0x1), - 0x8082B028:("D_8082B028","UNK_TYPE2","",0x2), - 0x8082B02C:("D_8082B02C","s16","[98]",0xC4), + 0x8082AED0:("sQuestRemainsColorTimerInit","UNK_TYPE1","",0x1), + 0x8082AED8:("sQuestHpColorTimerInit","UNK_TYPE1","",0x1), + 0x8082AEE0:("sQuestSongPlayedOcarinaButtonsNum","UNK_TYPE2","",0x2), + 0x8082AEE4:("sQuestSongPlayedOcarinaButtons","UNK_TYPE1","",0x1), + 0x8082AEF0:("sQuestSongPlayedOcarinaButtonsAlpha","UNK_TYPE2","",0x2), + 0x8082AF04:("sQuestHpPrimColorTargets","UNK_TYPE2","",0x2), + 0x8082AF24:("sQuestRemainsEnvTargets","UNK_TYPE1","",0x1), + 0x8082AF6C:("sQuestRemainsEnvRed","UNK_TYPE2","",0x2), + 0x8082AF78:("sQuestRemainsEnvGreen","UNK_TYPE2","",0x2), + 0x8082AF84:("sQuestRemainsEnvBlue","UNK_TYPE2","",0x2), + 0x8082AF90:("sQuestRemainsColorTimer","UNK_TYPE2","",0x2), + 0x8082AF94:("sQuestRemainsColorTimerIndex","UNK_TYPE2","",0x2), + 0x8082AF98:("sQuestHpPrimRed","UNK_TYPE2","",0x2), + 0x8082AF9C:("sQuestHpPrimGreen","UNK_TYPE2","",0x2), + 0x8082AFA0:("sQuestHpPrimBlue","UNK_TYPE2","",0x2), + 0x8082AFA4:("sQuestHpPrimAlpha","UNK_TYPE2","",0x2), + 0x8082AFA8:("sQuestHpColorTimer","UNK_TYPE2","",0x2), + 0x8082AFAC:("sQuestHpPrimColorTargetIndex","UNK_TYPE2","",0x2), + 0x8082AFB0:("sOcarinaButtonTextures","UNK_TYPE1","",0x1), + 0x8082AFC4:("sQuestSongsPrimRed","UNK_TYPE2","",0x2), + 0x8082AFDC:("sQuestSongsPrimGreen","UNK_TYPE2","",0x2), + 0x8082AFF4:("sQuestSongsPrimBlue","s16","[12]",0x18), + 0x8082B00C:("sQuestUpgradeTextures","void*","[6]",0x18), + 0x8082B024:("sQuestUpgrades","UNK_TYPE1","",0x1), + 0x8082B028:("sQuestSongPlaybackDelayTimer","UNK_TYPE2","",0x2), + 0x8082B02C:("sCursorPointLinks","s16","[98]",0xC4), 0x8082B0F0:("sCurSection","UNK_TYPE2","",0x2), 0x8082B0F4:("sCurRow","UNK_TYPE2","",0x2), 0x8082B0F8:("sSectionPositions","s16","[280]",0x230), @@ -4808,10 +4808,10 @@ 0x8082BB38:("D_8082BB38","UNK_PTR","",0x4), 0x8082BB50:("D_8082BB50","UNK_PTR","",0x4), 0x8082BB68:("D_8082BB68","UNK_TYPE2","",0x2), - 0x8082BB74:("D_8082BB74","UNK_TYPE2","",0x2), - 0x8082BBC4:("D_8082BBC4","UNK_TYPE2","",0x2), - 0x8082BC14:("D_8082BC14","UNK_TYPE2","",0x2), - 0x8082BC64:("D_8082BC64","UNK_TYPE2","",0x2), + 0x8082BB74:("sQuestVtxRectLeft","UNK_TYPE2","",0x2), + 0x8082BBC4:("sQuestVtxRectTop","UNK_TYPE2","",0x2), + 0x8082BC14:("sQuestVtxWidths","UNK_TYPE2","",0x2), + 0x8082BC64:("sQuestVtxHeights","UNK_TYPE2","",0x2), 0x8082BCB4:("D_8082BCB4","UNK_TYPE1","",0x1), 0x8082BCCC:("D_8082BCCC","UNK_TYPE1","",0x1), 0x8082BCDC:("D_8082BCDC","UNK_TYPE1","",0x1), diff --git a/tools/namefixer.py b/tools/namefixer.py index 4f596ecef9..1aed5ead36 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -748,6 +748,7 @@ wordReplace = { "play->actorCtx.unk4": "play->actorCtx.lensMaskSize", "play->nextEntranceIndex": "play->nextEntrance", "play->sceneNum": "play->sceneId", + "play->pauseCtx.unk_1F0": "play->pauseCtx.bombersNotebookOpen", "gSaveContext.unk_3DC8": "gSaveContext.timerOsTime", "gSaveContext.unk_3DD0": "gSaveContext.timerStates",