diff options
| author | Roman971 <32455037+Roman971@users.noreply.github.com> | 2021-05-03 01:15:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-02 19:15:16 -0400 |
| commit | a53e084cd236c36da5fca25c07da18ac83a7dbab (patch) | |
| tree | ccc0625dd7cc356d595d08caf06943af1c4efb4f /src | |
| parent | 4e9f40cb139ab66313fd24282fb9ef2060db5eed (diff) | |
Decompile the pause menu aka. ovl_kaleido_scope (+ minor changes) (#803)
* Decompile ovl_kaleido_scope + minor cleanups
* Add a common header for ovl_kaleido_scope
* Start cleaning up and documenting kaleido_scope (+ some interface docs)
* Improve and fix some kaleido_scope non matchings
* Match KaleidoSetup_Init
* Extract icon_item_fra/ger_static files
* Add more documentation and matches to kaleido_scope
* Improve the z_kaleido_collect.c non matching
* Rename z_kaleido_8081EFF0.c to z_kaleido_prompt.c
* Update most kaleido variables to be static
* Improve GS flag macros
* Improve z_lmap_mark.c and extract z_lmap_mark_data.c with a script
* Various minor fixes and improvements
* Minor fixes and review changes
* Review changes part 2
* Rename gSetTileCustom to gDPSetTileCustom
* Review changes part 3
Diffstat (limited to 'src')
36 files changed, 8140 insertions, 539 deletions
diff --git a/src/code/code_80097A00.c b/src/code/code_80097A00.c index a11da6948..6200083ca 100644 --- a/src/code/code_80097A00.c +++ b/src/code/code_80097A00.c @@ -30,11 +30,11 @@ u16 gUpgradeCapacities[][4] = { { 0, 20, 30, 40 }, // Deku Nut Upgrades }; -u32 gGoldSkullFlgMask[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }; -u32 gGoldSkullFlgShift[] = { 0, 8, 16, 24 }; +u32 gGsFlagsMask[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }; +u32 gGsFlagsShift[] = { 0, 8, 16, 24 }; // TODO: use symbols for these icon textures once textures are properly in C -u32 gItemIcons[] = { +void* gItemIcons[] = { 0x08000000, 0x08001000, 0x08002000, 0x08003000, 0x08004000, 0x08005000, 0x08006000, 0x08007000, 0x08008000, 0x08009000, 0x0800A000, 0x0800B000, 0x0800C000, 0x0800D000, 0x0800E000, 0x0800F000, 0x08010000, 0x08011000, 0x08012000, 0x08013000, 0x08014000, 0x08015000, 0x08016000, 0x08017000, 0x08018000, 0x08019000, 0x0801A000, @@ -95,7 +95,7 @@ u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { } Player_SetEquipmentData(globalCtx, player); - globalCtx->pauseCtx.unk_238 = 10; + globalCtx->pauseCtx.cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; } return sp26; diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 76888438d..55850d5b0 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -145,7 +145,7 @@ void FlagSet_Update(GlobalContext* globalCtx) { } if (CHECK_BTN_ALL(input->press.button, BTN_L)) { - globalCtx->pauseCtx.flag = 0; + globalCtx->pauseCtx.debugState = 0; } CLOSE_DISPS(gfxCtx, "../flg_set.c", 241); diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index e1bdcc61c..5362d43d5 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -3119,7 +3119,7 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->globalCtx != NULL)) { pauseState = dynaRaycast->globalCtx->pauseCtx.state != 0; if (pauseState == 0) { - pauseState = dynaRaycast->globalCtx->pauseCtx.flag != 0; + pauseState = dynaRaycast->globalCtx->pauseCtx.debugState != 0; } if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & 2)) { curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform; diff --git a/src/code/z_construct.c b/src/code/z_construct.c index 7191a5ab4..21428f3d4 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -7,7 +7,7 @@ void func_80110990(GlobalContext* globalCtx) { void func_801109B0(GlobalContext* globalCtx) { InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; u32 parameterSize; - u16 do_actionOffset; + u16 doActionOffset; u8 temp; gSaveContext.unk_1422 = 0; @@ -40,72 +40,72 @@ void func_801109B0(GlobalContext* globalCtx) { DmaMgr_SendRequest1(interfaceCtx->parameterSegment, (u32)_parameter_staticSegmentRomStart, parameterSize, "../z_construct.c", 162); - interfaceCtx->do_actionSegment = GameState_Alloc(&globalCtx->state, 0x480, "../z_construct.c", 166); + interfaceCtx->doActionSegment = GameState_Alloc(&globalCtx->state, 0x480, "../z_construct.c", 166); // Translates to: "DO Action Texture Initialization" osSyncPrintf("DOアクション テクスチャ初期=%x\n", 0x480); - osSyncPrintf("parameter->do_actionSegment=%x\n", interfaceCtx->do_actionSegment); + osSyncPrintf("parameter->do_actionSegment=%x\n", interfaceCtx->doActionSegment); - ASSERT(interfaceCtx->do_actionSegment != NULL, "parameter->do_actionSegment != NULL", "../z_construct.c", 169); + ASSERT(interfaceCtx->doActionSegment != NULL, "parameter->do_actionSegment != NULL", "../z_construct.c", 169); if (gSaveContext.language == 0) { - do_actionOffset = 0; + doActionOffset = 0; } else if (gSaveContext.language == 1) { - do_actionOffset = 0x2B80; + doActionOffset = 0x2B80; } else { - do_actionOffset = 0x5700; + doActionOffset = 0x5700; } - DmaMgr_SendRequest1(interfaceCtx->do_actionSegment, (u32)_do_action_staticSegmentRomStart + do_actionOffset, 0x300, + DmaMgr_SendRequest1(interfaceCtx->doActionSegment, (u32)_do_action_staticSegmentRomStart + doActionOffset, 0x300, "../z_construct.c", 174); if (gSaveContext.language == 0) { - do_actionOffset = 0x480; + doActionOffset = 0x480; } else if (gSaveContext.language == 1) { - do_actionOffset = 0x3000; + doActionOffset = 0x3000; } else { - do_actionOffset = 0x5B80; + doActionOffset = 0x5B80; } - DmaMgr_SendRequest1((void*)((u32)interfaceCtx->do_actionSegment + 0x300), - (u32)_do_action_staticSegmentRomStart + do_actionOffset, 0x180, "../z_construct.c", 178); + DmaMgr_SendRequest1(interfaceCtx->doActionSegment + 0x300, (u32)_do_action_staticSegmentRomStart + doActionOffset, + 0x180, "../z_construct.c", 178); - interfaceCtx->icon_itemSegment = GameState_Alloc(&globalCtx->state, 0x4000, "../z_construct.c", 190); + interfaceCtx->iconItemSegment = GameState_Alloc(&globalCtx->state, 0x4000, "../z_construct.c", 190); // Translates to: "Icon Item Texture Initialization = %x" osSyncPrintf("アイコンアイテム テクスチャ初期=%x\n", 0x4000); - osSyncPrintf("parameter->icon_itemSegment=%x\n", interfaceCtx->icon_itemSegment); + osSyncPrintf("parameter->icon_itemSegment=%x\n", interfaceCtx->iconItemSegment); - ASSERT(interfaceCtx->icon_itemSegment != NULL, "parameter->icon_itemSegment != NULL", "../z_construct.c", 193); + ASSERT(interfaceCtx->iconItemSegment != NULL, "parameter->icon_itemSegment != NULL", "../z_construct.c", 193); osSyncPrintf("Register_Item[%x, %x, %x, %x]\n", gSaveContext.equips.buttonItems[0], gSaveContext.equips.buttonItems[1], gSaveContext.equips.buttonItems[2], gSaveContext.equips.buttonItems[3]); if (gSaveContext.equips.buttonItems[0] < 0xF0) { - DmaMgr_SendRequest1(interfaceCtx->icon_itemSegment, + DmaMgr_SendRequest1(interfaceCtx->iconItemSegment, _icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[0] * 0x1000, 0x1000, "../z_construct.c", 198); } else if (gSaveContext.equips.buttonItems[0] != 0xFF) { - DmaMgr_SendRequest1(interfaceCtx->icon_itemSegment, + DmaMgr_SendRequest1(interfaceCtx->iconItemSegment, _icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[0] * 0x1000, 0x1000, "../z_construct.c", 203); } if (gSaveContext.equips.buttonItems[1] < 0xF0) { - DmaMgr_SendRequest1((void*)((u32)interfaceCtx->icon_itemSegment + 0x1000), + DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x1000, _icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[1] * 0x1000, 0x1000, "../z_construct.c", 209); } if (gSaveContext.equips.buttonItems[2] < 0xF0) { - DmaMgr_SendRequest1((void*)((u32)interfaceCtx->icon_itemSegment + 0x2000), + DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x2000, _icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[2] * 0x1000, 0x1000, "../z_construct.c", 214); } if (gSaveContext.equips.buttonItems[3] < 0xF0) { - DmaMgr_SendRequest1((void*)((u32)interfaceCtx->icon_itemSegment + 0x3000), + DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x3000, _icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[3] * 0x1000, 0x1000, "../z_construct.c", 219); } diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 028846a59..2a2229f27 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -57,10 +57,11 @@ void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx); void Cutscene_DrawDebugInfo(GlobalContext* globalCtx, Gfx** dlist, CutsceneContext* csCtx) { GfxPrint printer; - u8 pad2[8]; + s32 pad[2]; GfxPrint_Init(&printer); GfxPrint_Open(&printer, *dlist); + GfxPrint_SetPos(&printer, 22, 25); GfxPrint_SetColor(&printer, 255, 255, 55, 32); GfxPrint_Printf(&printer, "%s", "FLAME "); @@ -69,6 +70,7 @@ void Cutscene_DrawDebugInfo(GlobalContext* globalCtx, Gfx** dlist, CutsceneConte GfxPrint_SetColor(&printer, 50, 255, 255, 60); GfxPrint_SetPos(&printer, 4, 26); GfxPrint_Printf(&printer, "%s", "SKIP=(START) or (Cursole Right)"); + *dlist = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); } diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 194b5988b..ba73331af 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -7,77 +7,85 @@ _ovl_##name##SegmentEnd, 0, #name, \ } -KaleidoManagerOvl gKaleidoMgrOverlayTable[] = { +KaleidoMgrOverlay gKaleidoMgrOverlayTable[] = { KALEIDO_OVERLAY(kaleido_scope), KALEIDO_OVERLAY(player_actor), }; void* sKaleidoAreaPtr = NULL; -KaleidoManagerOvl* gKaleidoMgrCurOvl = NULL; -u32 D_8012D1E0 = 0; +KaleidoMgrOverlay* gKaleidoMgrCurOvl = NULL; +u8 gBossMarkState = 0; -void KaleidoManager_LoadOvl(KaleidoManagerOvl* ovl) { +void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl) { LogUtils_CheckNullPointer("KaleidoArea_allocp", sKaleidoAreaPtr, "../z_kaleido_manager.c", 99); + ovl->loadedRamAddr = sKaleidoAreaPtr; Overlay_Load(ovl->vromStart, ovl->vromEnd, ovl->vramStart, ovl->vramEnd, ovl->loadedRamAddr); + osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf("OVL(k):Seg:%08x-%08x Ram:%08x-%08x Off:%08x %s\n", ovl->vramStart, ovl->vramEnd, ovl->loadedRamAddr, - ((u32)ovl->loadedRamAddr + ovl->vramEnd) - (u32)ovl->vramStart, + (u32)ovl->loadedRamAddr + (u32)ovl->vramEnd - (u32)ovl->vramStart, (u32)ovl->vramStart - (u32)ovl->loadedRamAddr, ovl->name); osSyncPrintf(VT_RST); - ovl->off = (u32)ovl->loadedRamAddr - (u32)ovl->vramStart; + + ovl->offset = (u32)ovl->loadedRamAddr - (u32)ovl->vramStart; gKaleidoMgrCurOvl = ovl; } -void KaleidoManager_ClearOvl(KaleidoManagerOvl* ovl) { - if (ovl->loadedRamAddr) { - ovl->off = 0; - bzero(ovl->loadedRamAddr, ovl->vramEnd - (u32)ovl->vramStart); +void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) { + if (ovl->loadedRamAddr != NULL) { + ovl->offset = 0; + bzero(ovl->loadedRamAddr, (u32)ovl->vramEnd - (u32)ovl->vramStart); ovl->loadedRamAddr = NULL; gKaleidoMgrCurOvl = NULL; } } void KaleidoManager_Init(GlobalContext* globalCtx) { - s32 largestOvl = 0; - s32 vramSize; - u32 idx; - - for (idx = 0; idx < ARRAY_COUNT(gKaleidoMgrOverlayTable); idx++) { - vramSize = gKaleidoMgrOverlayTable[idx].vramEnd - (u32)gKaleidoMgrOverlayTable[idx].vramStart; - if (largestOvl < vramSize) { - largestOvl = vramSize; + s32 largestSize = 0; + s32 size; + u32 i; + + for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { + size = (u32)gKaleidoMgrOverlayTable[i].vramEnd - (u32)gKaleidoMgrOverlayTable[i].vramStart; + if (size > largestSize) { + largestSize = size; } } + osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("KaleidoArea の最大サイズは %d バイトを確保します\n", largestOvl); + osSyncPrintf("KaleidoArea の最大サイズは %d バイトを確保します\n", largestSize); osSyncPrintf(VT_RST); - sKaleidoAreaPtr = GameState_Alloc(&globalCtx->state, largestOvl, "../z_kaleido_manager.c", 150); + + sKaleidoAreaPtr = GameState_Alloc(&globalCtx->state, largestSize, "../z_kaleido_manager.c", 150); LogUtils_CheckNullPointer("KaleidoArea_allocp", sKaleidoAreaPtr, "../z_kaleido_manager.c", 151); + osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("KaleidoArea %08x - %08x\n", sKaleidoAreaPtr, (u32)sKaleidoAreaPtr + largestOvl); + osSyncPrintf("KaleidoArea %08x - %08x\n", sKaleidoAreaPtr, (u32)sKaleidoAreaPtr + largestSize); osSyncPrintf(VT_RST); + gKaleidoMgrCurOvl = 0; } void KaleidoManager_Destroy() { - if (gKaleidoMgrCurOvl) { + if (gKaleidoMgrCurOvl != NULL) { KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); gKaleidoMgrCurOvl = NULL; } + sKaleidoAreaPtr = NULL; } // NOTE: this function looks messed up and probably doesn't work like how the devs wanted it to work void* KaleidoManager_GetRamAddr(void* vram) { - KaleidoManagerOvl* iter = gKaleidoMgrCurOvl; - KaleidoManagerOvl* ovl = iter; - u32 idx; + KaleidoMgrOverlay* iter = gKaleidoMgrCurOvl; + KaleidoMgrOverlay* ovl = iter; + u32 i; if (ovl == NULL) { iter = &gKaleidoMgrOverlayTable[0]; - for (idx = 0; idx != ARRAY_COUNT(gKaleidoMgrOverlayTable); idx++) { - if ((u32)vram >= (u32)iter->vramStart && (u32)iter->vramEnd >= (u32)vram) { + for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { + if (((u32)vram >= (u32)iter->vramStart) && ((u32)iter->vramEnd >= (u32)vram)) { KaleidoManager_LoadOvl(iter); ovl = iter; goto KaleidoManager_GetRamAddr_end; @@ -90,9 +98,9 @@ void* KaleidoManager_GetRamAddr(void* vram) { } KaleidoManager_GetRamAddr_end: - if (ovl == NULL || (u32)vram < (u32)ovl->vramStart || (u32)vram >= (u32)ovl->vramEnd) { + if ((ovl == NULL) || ((u32)vram < (u32)ovl->vramStart) || ((u32)vram >= (u32)ovl->vramEnd)) { return NULL; } - return (void*)((u32)vram + ovl->off); + return (void*)((u32)vram + ovl->offset); } diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 7f6345944..9ab95a831 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,35 +1,38 @@ #include "global.h" #include "vt.h" -void (*sKaleidoScopeUpdateFunc)(GlobalContext*); -void (*sKaleidoScopeDrawFunc)(GlobalContext*); -f32 D_80161398; +void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); +void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); +f32 gBossMarkScale; u32 D_8016139C; -void* D_801613A0; +PauseMapMarksData* gLoadedPauseMarkDataTable; -extern void KaleidoScope_Update(GlobalContext*); -extern void KaleidoScope_Draw(GlobalContext*); +extern void KaleidoScope_Update(GlobalContext* globalCtx); +extern void KaleidoScope_Draw(GlobalContext* globalCtx); void KaleidoScopeCall_LoadPlayer() { - KaleidoManagerOvl* playerActorOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_PLAYER_ACTOR]; + KaleidoMgrOverlay* playerActorOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_PLAYER_ACTOR]; if (gKaleidoMgrCurOvl != playerActorOvl) { - if (gKaleidoMgrCurOvl) { + if (gKaleidoMgrCurOvl != NULL) { osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("カレイド領域 強制排除\n"); // Kaleido area forced exclusion + osSyncPrintf("カレイド領域 強制排除\n"); // "Kaleido area forced exclusion" osSyncPrintf(VT_RST); + KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); } + osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("プレイヤーアクター搬入\n"); // Player actor import + osSyncPrintf("プレイヤーアクター搬入\n"); // "Player actor import" osSyncPrintf(VT_RST); + KaleidoManager_LoadOvl(playerActorOvl); } } void KaleidoScopeCall_Init(GlobalContext* globalCtx) { - // Kaleidoscope replacement construct - osSyncPrintf("カレイド・スコープ入れ替え コンストラクト \n"); + osSyncPrintf("カレイド・スコープ入れ替え コンストラクト \n"); // "Kaleidoscope replacement construction" + sKaleidoScopeUpdateFunc = KaleidoManager_GetRamAddr(KaleidoScope_Update); sKaleidoScopeDrawFunc = KaleidoManager_GetRamAddr(KaleidoScope_Draw); @@ -37,20 +40,21 @@ void KaleidoScopeCall_Init(GlobalContext* globalCtx) { LOG_ADDRESS("kaleido_scope_move_func", sKaleidoScopeUpdateFunc, "../z_kaleido_scope_call.c", 99); LOG_ADDRESS("kaleido_scope_draw", KaleidoScope_Draw, "../z_kaleido_scope_call.c", 100); LOG_ADDRESS("kaleido_scope_draw_func", sKaleidoScopeDrawFunc, "../z_kaleido_scope_call.c", 101); + KaleidoSetup_Init(globalCtx); } void KaleidoScopeCall_Destroy(GlobalContext* globalCtx) { - // Kaleidoscope replacement destruction - osSyncPrintf("カレイド・スコープ入れ替え デストラクト \n"); + osSyncPrintf("カレイド・スコープ入れ替え デストラクト \n"); // "Kaleidoscope replacement destruction" + KaleidoSetup_Destroy(globalCtx); } void KaleidoScopeCall_Update(GlobalContext* globalCtx) { - KaleidoManagerOvl* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; + KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; PauseContext* pauseCtx = &globalCtx->pauseCtx; - if (pauseCtx->state != 0 || pauseCtx->flag != 0) { + if ((pauseCtx->state != 0) || (pauseCtx->debugState != 0)) { if (pauseCtx->state == 1) { if (ShrinkWindow_GetCurrentVal() == 0) { HREG(80) = 7; @@ -67,8 +71,9 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) { pauseCtx->unk_1E4 = 0; pauseCtx->unk_1EC = 0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; - } else if (pauseCtx->state == 2 || pauseCtx->state == 9) { + } else if ((pauseCtx->state == 2) || (pauseCtx->state == 9)) { osSyncPrintf("PR_KAREIDOSCOPE_MODE=%d\n", R_PAUSE_MENU_MODE); + if (R_PAUSE_MENU_MODE >= 3) { pauseCtx->state++; } @@ -76,22 +81,27 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) { if (gKaleidoMgrCurOvl != kaleidoScopeOvl) { if (gKaleidoMgrCurOvl != NULL) { osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("カレイド領域 プレイヤー 強制排除\n"); // Kaleid Zone Player Forced Elimination + osSyncPrintf("カレイド領域 プレイヤー 強制排除\n"); // "Kaleido area Player Forced Elimination" osSyncPrintf(VT_RST); + KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); } + osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("カレイド領域 カレイドスコープ搬入\n"); // Kaleid area Kaleidoscope loading + osSyncPrintf("カレイド領域 カレイドスコープ搬入\n"); // "Kaleido area Kaleidoscope loading" osSyncPrintf(VT_RST); + KaleidoManager_LoadOvl(kaleidoScopeOvl); } if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { sKaleidoScopeUpdateFunc(globalCtx); - if (globalCtx->pauseCtx.state == 0 && globalCtx->pauseCtx.flag == 0) { + + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("カレイド領域 カレイドスコープ排出\n"); // Kaleid area Kaleidoscope emission + osSyncPrintf("カレイド領域 カレイドスコープ排出\n"); // "Kaleido area Kaleidoscope Emission" osSyncPrintf(VT_RST); + KaleidoManager_ClearOvl(kaleidoScopeOvl); KaleidoScopeCall_LoadPlayer(); } @@ -101,11 +111,11 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) { } void KaleidoScopeCall_Draw(GlobalContext* globalCtx) { - KaleidoManagerOvl* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; + KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; if (R_PAUSE_MENU_MODE >= 3) { - if ((globalCtx->pauseCtx.state >= 4 && globalCtx->pauseCtx.state < 8) || - (globalCtx->pauseCtx.state >= 11 && globalCtx->pauseCtx.state < 19)) { + if (((globalCtx->pauseCtx.state >= 4) && (globalCtx->pauseCtx.state <= 7)) || + ((globalCtx->pauseCtx.state >= 11) && (globalCtx->pauseCtx.state <= 18))) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { sKaleidoScopeDrawFunc(globalCtx); } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index b63fc1441..adc829d01 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,48 +1,18 @@ #include "global.h" -s16 sKaleidoSetupKscpPos0[] = { - 2, - 3, - 0, - 1, -}; -f32 sKaleidoSetupEyeX0[] = { - 0.0f, - 64.0f, - 0.0f, - -64.0f, -}; -f32 sKaleidoSetupEyeZ0[] = { - -64.0f, - 0.0f, - 64.0f, - 0.0f, -}; - -s16 sKaleidoSetupKscpPos1[] = { - 1, - 2, - 3, - 0, -}; -f32 sKaleidoSetupEyeX1[] = { - -64.0f, - 0.0f, - 64.0f, - 0.0f, -}; -f32 sKaleidoSetupEyeZ1[] = { - 0.0f, - -64.0f, - 0.0f, - 64.0f, -}; +s16 sKaleidoSetupKscpPos0[] = { PAUSE_QUEST, PAUSE_EQUIP, PAUSE_ITEM, PAUSE_MAP }; +f32 sKaleidoSetupEyeX0[] = { 0.0f, 64.0f, 0.0f, -64.0f }; +f32 sKaleidoSetupEyeZ0[] = { -64.0f, 0.0f, 64.0f, 0.0f }; + +s16 sKaleidoSetupKscpPos1[] = { PAUSE_MAP, PAUSE_QUEST, PAUSE_EQUIP, PAUSE_ITEM }; +f32 sKaleidoSetupEyeX1[] = { -64.0f, 0.0f, 64.0f, 0.0f }; +f32 sKaleidoSetupEyeZ1[] = { 0.0f, -64.0f, 0.0f, 64.0f }; void KaleidoSetup_Update(GlobalContext* globalCtx) { PauseContext* pauseCtx = &globalCtx->pauseCtx; Input* input = &globalCtx->state.input[0]; - if (pauseCtx->state == 0 && pauseCtx->flag == 0 && globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE && + if (pauseCtx->state == 0 && pauseCtx->debugState == 0 && globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE && globalCtx->sceneLoadFlag == 0 && globalCtx->transitionMode == 0 && gSaveContext.cutsceneIndex < 0xFFF0 && gSaveContext.nextCutsceneIndex < 0xFFF0 && !Gameplay_InCsMode(globalCtx) && globalCtx->shootingGalleryStatus <= 1 && gSaveContext.unk_13F0 != 8 && gSaveContext.unk_13F0 != 9 && @@ -50,54 +20,59 @@ void KaleidoSetup_Update(GlobalContext* globalCtx) { if (CHECK_BTN_ALL(input->cur.button, BTN_L) && CHECK_BTN_ALL(input->press.button, BTN_CUP)) { if (BREG(0)) { - pauseCtx->flag = 3; + pauseCtx->debugState = 3; } } else if (CHECK_BTN_ALL(input->press.button, BTN_START)) { gSaveContext.unk_13EE = gSaveContext.unk_13EA; - WREG(16) = -0xAF; - WREG(17) = 0x9B; + + WREG(16) = -175; + WREG(17) = 155; + pauseCtx->unk_1EA = 0; pauseCtx->unk_1E4 = 1; + if (ZREG(48) == 0) { - pauseCtx->eye.x = sKaleidoSetupEyeX0[pauseCtx->kscpPos]; - pauseCtx->eye.z = sKaleidoSetupEyeZ0[pauseCtx->kscpPos]; - pauseCtx->kscpPos = sKaleidoSetupKscpPos0[pauseCtx->kscpPos]; + pauseCtx->eye.x = sKaleidoSetupEyeX0[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupEyeZ0[pauseCtx->pageIndex]; + pauseCtx->pageIndex = sKaleidoSetupKscpPos0[pauseCtx->pageIndex]; } else { - pauseCtx->eye.x = sKaleidoSetupEyeX1[pauseCtx->kscpPos]; - pauseCtx->eye.z = sKaleidoSetupEyeZ1[pauseCtx->kscpPos]; - pauseCtx->kscpPos = sKaleidoSetupKscpPos1[pauseCtx->kscpPos]; + pauseCtx->eye.x = sKaleidoSetupEyeX1[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupEyeZ1[pauseCtx->pageIndex]; + pauseCtx->pageIndex = sKaleidoSetupKscpPos1[pauseCtx->pageIndex]; } - pauseCtx->mode = (u16)(pauseCtx->kscpPos * 2) + 1; // cast required + pauseCtx->mode = (u16)(pauseCtx->pageIndex * 2) + 1; pauseCtx->state = 1; + osSyncPrintf("Mode=%d eye.x=%f, eye.z=%f kscp_pos=%d\n", pauseCtx->mode, pauseCtx->eye.x, - pauseCtx->eye.z, pauseCtx->kscpPos); + pauseCtx->eye.z, pauseCtx->pageIndex); } if (pauseCtx->state == 1) { - WREG(2) = -0x1860; + WREG(2) = -6240; R_UPDATE_RATE = 2; + if (ShrinkWindow_GetVal()) { ShrinkWindow_SetVal(0); } + func_800F64E0(1); } } } -#ifdef NON_MATCHING -// regalloc differences void KaleidoSetup_Init(GlobalContext* globalCtx) { PauseContext* pauseCtx = &globalCtx->pauseCtx; + u64 temp = 0; // Necessary to match pauseCtx->state = 0; - pauseCtx->flag = 0; - pauseCtx->unk_208 = 0; + pauseCtx->debugState = 0; + pauseCtx->alpha = 0; pauseCtx->unk_1EA = 0; pauseCtx->unk_1E4 = 0; pauseCtx->mode = 0; - pauseCtx->kscpPos = 0; - pauseCtx->unk_218 = 0; + pauseCtx->pageIndex = PAUSE_ITEM; + pauseCtx->unk_1F4 = 160.0f; pauseCtx->unk_1F8 = 160.0f; pauseCtx->unk_1FC = 160.0f; @@ -106,38 +81,41 @@ void KaleidoSetup_Init(GlobalContext* globalCtx) { pauseCtx->unk_1F0 = 936.0f; pauseCtx->eye.x = pauseCtx->eye.y = 0.0f; pauseCtx->unk_204 = -314.0f; - pauseCtx->unk_21A = VREG(30) + 3; - pauseCtx->unk_21C = 0; - pauseCtx->unk_21E = 1; - pauseCtx->unk_220 = 10; - pauseCtx->unk_222 = 0; - pauseCtx->unk_22C = 0; - pauseCtx->unk_224 = 0; - pauseCtx->unk_22E = 0; - pauseCtx->unk_226 = 0; - pauseCtx->unk_230 = 0; - pauseCtx->unk_228 = 1; - pauseCtx->unk_232 = 0; - pauseCtx->unk_23E = 999; - pauseCtx->unk_240 = VREG(30) + 3; - pauseCtx->unk_242 = 999; - pauseCtx->unk_244 = 59; - pauseCtx->unk_246 = 0; - pauseCtx->unk_248 = VREG(30) + 3; - pauseCtx->unk_24A = 0; - pauseCtx->unk_24C = pauseCtx->unk_21E; - pauseCtx->unk_25A = -40; - pauseCtx->unk_25C = 0; - pauseCtx->unk_25E = 0; - pauseCtx->unk_260 = 4; + + pauseCtx->cursorPoint[PAUSE_ITEM] = 0; + pauseCtx->cursorPoint[PAUSE_MAP] = VREG(30) + 3; + pauseCtx->cursorPoint[PAUSE_QUEST] = 0; + pauseCtx->cursorPoint[PAUSE_EQUIP] = 1; + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 10; + + pauseCtx->cursorX[PAUSE_ITEM] = 0; + pauseCtx->cursorY[PAUSE_ITEM] = 0; + pauseCtx->cursorX[PAUSE_MAP] = 0; + pauseCtx->cursorY[PAUSE_MAP] = 0; + pauseCtx->cursorX[PAUSE_QUEST] = temp; + pauseCtx->cursorY[PAUSE_QUEST] = temp; + pauseCtx->cursorX[PAUSE_EQUIP] = 1; + pauseCtx->cursorY[PAUSE_EQUIP] = 0; + + pauseCtx->cursorItem[PAUSE_ITEM] = PAUSE_ITEM_NONE; + pauseCtx->cursorItem[PAUSE_MAP] = VREG(30) + 3; + pauseCtx->cursorItem[PAUSE_QUEST] = PAUSE_ITEM_NONE; + pauseCtx->cursorItem[PAUSE_EQUIP] = ITEM_SWORD_KOKIRI; + + pauseCtx->cursorSlot[PAUSE_ITEM] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = VREG(30) + 3; + pauseCtx->cursorSlot[PAUSE_QUEST] = 0; + pauseCtx->cursorSlot[PAUSE_EQUIP] = pauseCtx->cursorPoint[PAUSE_EQUIP]; + + pauseCtx->infoPanelOffsetY = -40; + pauseCtx->nameDisplayTimer = 0; + pauseCtx->nameColorSet = 0; + pauseCtx->cursorColorSet = 4; pauseCtx->unk_264 = -1; - pauseCtx->unk_238 = 0; + pauseCtx->cursorSpecialPos = 0; View_Init(&pauseCtx->view, globalCtx->state.gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Init.s") -#endif void KaleidoSetup_Destroy(GlobalContext* globalCtx) { } diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index d5610f1c2..2a1d6b987 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,7 +1,7 @@ #include "global.h" #include "textures/parameter_static/parameter_static.h" -/* +/** * These are the colors for the hearts in the interface. The prim color is the red color of the heart * for the base hearts, while the prim color for the double defense hearts is the white outline. The * env color for the base hearts is the purple-ish outline, while the env color for the double defense @@ -24,7 +24,7 @@ #define HEARTS_DD_ENV_G 0 #define HEARTS_DD_ENV_B 0 -/* +/** * The burn and drown colors listed here are unused. Prerelease footage of the game confirms that at one * point in development the orange color was to be used while taking damage from hot environments. * Based on this, we can assume that the blue heart color was to be used while drowning. @@ -55,8 +55,8 @@ static s16 sHeartsPrimColors[3][3] = { static s16 sHeartsEnvColors[3][3] = { { HEARTS_ENV_R, HEARTS_ENV_G, HEARTS_ENV_B }, - { HEARTS_BURN_ENV_R, HEARTS_BURN_ENV_G }, - { HEARTS_DROWN_ENV_R, HEARTS_DROWN_ENV_G, HEARTS_DROWN_ENV_B }, + { HEARTS_BURN_ENV_R, HEARTS_BURN_ENV_G }, // unused + { HEARTS_DROWN_ENV_R, HEARTS_DROWN_ENV_G, HEARTS_DROWN_ENV_B }, // unused }; static s16 sHeartsPrimFactors[3][3] = { @@ -152,10 +152,10 @@ static s16 sHeartsDDEnvFactors[3][3] = { }; // Current colors for the double defense hearts -s16 sHeartsDDPrim[3]; -s16 sHeartsDDEnv[3]; -s16 sBeatingHeartsDDPrim[2][3]; -s16 sBeatingHeartsDDEnv[2][3]; +s16 sBeatingHeartsDDPrim[3]; +s16 sBeatingHeartsDDEnv[3]; +s16 sHeartsDDPrim[2][3]; +s16 sHeartsDDEnv[2][3]; void HealthMeter_Init(GlobalContext* globalCtx) { InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; @@ -181,13 +181,13 @@ void HealthMeter_Init(GlobalContext* globalCtx) { interfaceCtx->heartsEnvG[1] = HEARTS_ENV_G; interfaceCtx->heartsEnvB[1] = HEARTS_ENV_B; - sBeatingHeartsDDPrim[0][0] = sBeatingHeartsDDPrim[1][0] = HEARTS_DD_PRIM_R; - sBeatingHeartsDDPrim[0][1] = sBeatingHeartsDDPrim[1][1] = HEARTS_DD_PRIM_G; - sBeatingHeartsDDPrim[0][2] = sBeatingHeartsDDPrim[1][2] = HEARTS_DD_PRIM_B; + sHeartsDDPrim[0][0] = sHeartsDDPrim[1][0] = HEARTS_DD_PRIM_R; + sHeartsDDPrim[0][1] = sHeartsDDPrim[1][1] = HEARTS_DD_PRIM_G; + sHeartsDDPrim[0][2] = sHeartsDDPrim[1][2] = HEARTS_DD_PRIM_B; - sBeatingHeartsDDEnv[0][0] = sBeatingHeartsDDEnv[1][0] = HEARTS_DD_ENV_R; - sBeatingHeartsDDEnv[0][1] = sBeatingHeartsDDEnv[1][1] = HEARTS_DD_ENV_G; - sBeatingHeartsDDEnv[0][2] = sBeatingHeartsDDEnv[1][2] = HEARTS_DD_ENV_B; + sHeartsDDEnv[0][0] = sHeartsDDEnv[1][0] = HEARTS_DD_ENV_R; + sHeartsDDEnv[0][1] = sHeartsDDEnv[1][1] = HEARTS_DD_ENV_G; + sHeartsDDEnv[0][2] = sHeartsDDEnv[1][2] = HEARTS_DD_ENV_B; } void HealthMeter_Update(GlobalContext* globalCtx) { @@ -253,37 +253,37 @@ void HealthMeter_Update(GlobalContext* globalCtx) { interfaceCtx->beatingHeartEnv[1] = (u8)(gFactor + HEARTS_ENV_G) & 0xFF; interfaceCtx->beatingHeartEnv[2] = (u8)(bFactor + HEARTS_ENV_B) & 0xFF; - sBeatingHeartsDDPrim[0][0] = HEARTS_DD_PRIM_R; - sBeatingHeartsDDPrim[0][1] = HEARTS_DD_PRIM_G; - sBeatingHeartsDDPrim[0][2] = HEARTS_DD_PRIM_B; + sHeartsDDPrim[0][0] = HEARTS_DD_PRIM_R; + sHeartsDDPrim[0][1] = HEARTS_DD_PRIM_G; + sHeartsDDPrim[0][2] = HEARTS_DD_PRIM_B; - sBeatingHeartsDDEnv[0][0] = HEARTS_DD_ENV_R; - sBeatingHeartsDDEnv[0][1] = HEARTS_DD_ENV_G; - sBeatingHeartsDDEnv[0][2] = HEARTS_DD_ENV_B; + sHeartsDDEnv[0][0] = HEARTS_DD_ENV_R; + sHeartsDDEnv[0][1] = HEARTS_DD_ENV_G; + sHeartsDDEnv[0][2] = HEARTS_DD_ENV_B; - sBeatingHeartsDDPrim[1][0] = sHeartsDDPrimColors[ddType][0]; - sBeatingHeartsDDPrim[1][1] = sHeartsDDPrimColors[ddType][1]; - sBeatingHeartsDDPrim[1][2] = sHeartsDDPrimColors[ddType][2]; + sHeartsDDPrim[1][0] = sHeartsDDPrimColors[ddType][0]; + sHeartsDDPrim[1][1] = sHeartsDDPrimColors[ddType][1]; + sHeartsDDPrim[1][2] = sHeartsDDPrimColors[ddType][2]; - sBeatingHeartsDDEnv[1][0] = sHeartsDDEnvColors[ddType][0]; - sBeatingHeartsDDEnv[1][1] = sHeartsDDEnvColors[ddType][1]; - sBeatingHeartsDDEnv[1][2] = sHeartsDDEnvColors[ddType][2]; + sHeartsDDEnv[1][0] = sHeartsDDEnvColors[ddType][0]; + sHeartsDDEnv[1][1] = sHeartsDDEnvColors[ddType][1]; + sHeartsDDEnv[1][2] = sHeartsDDEnvColors[ddType][2]; rFactor = sHeartsDDPrimFactors[ddType][0] * ddFactor; gFactor = sHeartsDDPrimFactors[ddType][1] * ddFactor; bFactor = sHeartsDDPrimFactors[ddType][2] * ddFactor; - sHeartsDDPrim[0] = (u8)(rFactor + HEARTS_DD_PRIM_R) & 0xFF; - sHeartsDDPrim[1] = (u8)(gFactor + HEARTS_DD_PRIM_G) & 0xFF; - sHeartsDDPrim[2] = (u8)(bFactor + HEARTS_DD_PRIM_B) & 0xFF; + sBeatingHeartsDDPrim[0] = (u8)(rFactor + HEARTS_DD_PRIM_R) & 0xFF; + sBeatingHeartsDDPrim[1] = (u8)(gFactor + HEARTS_DD_PRIM_G) & 0xFF; + sBeatingHeartsDDPrim[2] = (u8)(bFactor + HEARTS_DD_PRIM_B) & 0xFF; rFactor = sHeartsDDEnvFactors[ddType][0] * ddFactor; gFactor = sHeartsDDEnvFactors[ddType][1] * ddFactor; bFactor = sHeartsDDEnvFactors[ddType][2] * ddFactor; - sHeartsDDEnv[0] = (u8)(rFactor + HEARTS_DD_ENV_R) & 0xFF; - sHeartsDDEnv[1] = (u8)(gFactor + HEARTS_DD_ENV_G) & 0xFF; - sHeartsDDEnv[2] = (u8)(bFactor + HEARTS_DD_ENV_B) & 0xFF; + sBeatingHeartsDDEnv[0] = (u8)(rFactor + HEARTS_DD_ENV_R) & 0xFF; + sBeatingHeartsDDEnv[1] = (u8)(gFactor + HEARTS_DD_ENV_G) & 0xFF; + sBeatingHeartsDDEnv[2] = (u8)(bFactor + HEARTS_DD_ENV_B) & 0xFF; } s32 func_80078E18(GlobalContext* globalCtx) { @@ -329,7 +329,7 @@ u64* sHeartTextures[] = { gHUDHeartThreeQuarterTex, gHUDHeartThreeQuarterTex, gHUDHeartThreeQuarterTex, gHUDHeartThreeQuarterTex, }; -u64* sDDHeartTextures[] = { +u64* sHeartDDTextures[] = { gHUDDefenseHeartFullTex, gHUDDefenseHeartQuarterTex, gHUDDefenseHeartQuarterTex, gHUDDefenseHeartQuarterTex, gHUDDefenseHeartQuarterTex, gHUDDefenseHeartQuarterTex, gHUDDefenseHeartHalfTex, gHUDDefenseHeartHalfTex, gHUDDefenseHeartHalfTex, @@ -351,7 +351,7 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { f32 temp4; InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - Vtx* sp154 = interfaceCtx->vtx_12C; + Vtx* sp154 = interfaceCtx->beatingHeartVtx; s32 curHeartFraction = gSaveContext.health % 0x10; s16 totalHeartCount = gSaveContext.healthCapacity / 0x10; s16 fullHeartCount = gSaveContext.health / 0x10; @@ -424,43 +424,41 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { if (curColorSet != 4) { curColorSet = 4; gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sBeatingHeartsDDPrim[0][0], sBeatingHeartsDDPrim[0][1], - sBeatingHeartsDDPrim[0][2], interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, sBeatingHeartsDDEnv[0][0], sBeatingHeartsDDEnv[0][1], - sBeatingHeartsDDEnv[0][2], 255); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[0][0], sHeartsDDPrim[0][1], sHeartsDDPrim[0][2], + interfaceCtx->healthAlpha); + gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[0][0], sHeartsDDEnv[0][1], sHeartsDDEnv[0][2], 255); } } else if (i == fullHeartCount) { if (curColorSet != 5) { curColorSet = 5; gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[0], sHeartsDDPrim[1], sHeartsDDPrim[2], - interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[0], sHeartsDDEnv[1], sHeartsDDEnv[2], 0xFF); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sBeatingHeartsDDPrim[0], sBeatingHeartsDDPrim[1], + sBeatingHeartsDDPrim[2], interfaceCtx->healthAlpha); + gDPSetEnvColor(OVERLAY_DISP++, sBeatingHeartsDDEnv[0], sBeatingHeartsDDEnv[1], + sBeatingHeartsDDEnv[2], 255); } } else if (i > fullHeartCount) { if (curColorSet != 6) { curColorSet = 6; gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sBeatingHeartsDDPrim[0][0], sBeatingHeartsDDPrim[0][1], - sBeatingHeartsDDPrim[0][2], interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, sBeatingHeartsDDEnv[0][0], sBeatingHeartsDDEnv[0][1], - sBeatingHeartsDDEnv[0][2], 255); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[0][0], sHeartsDDPrim[0][1], sHeartsDDPrim[0][2], + interfaceCtx->healthAlpha); + gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[0][0], sHeartsDDEnv[0][1], sHeartsDDEnv[0][2], 255); } } else { if (curColorSet != 7) { curColorSet = 7; gDPPipeSync(OVERLAY_DISP++); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sBeatingHeartsDDPrim[1][0], sBeatingHeartsDDPrim[1][1], - sBeatingHeartsDDPrim[1][2], interfaceCtx->healthAlpha); - gDPSetEnvColor(OVERLAY_DISP++, sBeatingHeartsDDEnv[1][0], sBeatingHeartsDDEnv[1][1], - sBeatingHeartsDDEnv[1][2], 255); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[1][0], sHeartsDDPrim[1][1], sHeartsDDPrim[1][2], + interfaceCtx->healthAlpha); + gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[1][0], sHeartsDDEnv[1][1], sHeartsDDEnv[1][2], 255); } } if (i < fullHeartCount) { heartBgImg = gHUDDefenseHeartFullTex; } else if (i == fullHeartCount) { - heartBgImg = sDDHeartTextures[curHeartFraction]; + heartBgImg = sHeartDDTextures[curHeartFraction]; } else { heartBgImg = gHUDDefenseHeartEmptyTex; } @@ -545,8 +543,8 @@ void HealthMeter_HandleCriticalAlarm(GlobalContext* globalCtx) { if (interfaceCtx->unk_22A <= 0) { interfaceCtx->unk_22A = 0; interfaceCtx->unk_22C = 0; - if (!Player_InCsMode(globalCtx) && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && - HealthMeter_IsCritical() && !Gameplay_InCsMode(globalCtx)) { + if (!Player_InCsMode(globalCtx) && (globalCtx->pauseCtx.state == 0) && + (globalCtx->pauseCtx.debugState == 0) && HealthMeter_IsCritical() && !Gameplay_InCsMode(globalCtx)) { func_80078884(NA_SE_SY_HITPOINT_ALARM); } } diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index d50e093e5..6fa9d2f20 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -20,20 +20,20 @@ void Map_SavePlayerInitialInfo(GlobalContext* globalCtx) { void Map_SetPaletteData(GlobalContext* globalCtx, s16 room) { s32 mapIndex = gSaveContext.mapIndex; InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - s16 paletteNum = gMapData->roomPalette[mapIndex][room]; + s16 paletteIndex = gMapData->roomPalette[mapIndex][room]; if (interfaceCtx->mapRoomNum == room) { - interfaceCtx->mapPaletteNum = paletteNum; + interfaceCtx->mapPaletteIndex = paletteIndex; } osSyncPrintf(VT_FGCOL(YELLOW)); // Translates to: "PALETE Set" - osSyncPrintf("PALETEセット 【 i=%x : room=%x 】Room_Inf[%d][4]=%x ( map_palete_no = %d )\n", paletteNum, - room, mapIndex, gSaveContext.sceneFlags[mapIndex].rooms, interfaceCtx->mapPaletteNum); + osSyncPrintf("PALETEセット 【 i=%x : room=%x 】Room_Inf[%d][4]=%x ( map_palete_no = %d )\n", paletteIndex, + room, mapIndex, gSaveContext.sceneFlags[mapIndex].rooms, interfaceCtx->mapPaletteIndex); osSyncPrintf(VT_RST); - interfaceCtx->unk_140[paletteNum * 2] = 2; - interfaceCtx->unk_140[paletteNum * 2 + 1] = 0xBF; + interfaceCtx->mapPalette[paletteIndex * 2] = 2; + interfaceCtx->mapPalette[paletteIndex * 2 + 1] = 0xBF; } void Map_SetFloorPalettesData(GlobalContext* globalCtx, s16 floor) { @@ -43,13 +43,13 @@ void Map_SetFloorPalettesData(GlobalContext* globalCtx, s16 floor) { s16 i; for (i = 0; i < 16; i++) { - interfaceCtx->unk_140[i] = 0; - interfaceCtx->unk_140[i + 16] = 0; + interfaceCtx->mapPalette[i] = 0; + interfaceCtx->mapPalette[i + 16] = 0; } if (CHECK_DUNGEON_ITEM(DUNGEON_MAP, mapIndex)) { - interfaceCtx->unk_140[30] = 0; - interfaceCtx->unk_140[31] = 1; + interfaceCtx->mapPalette[30] = 0; + interfaceCtx->mapPalette[31] = 1; } switch (globalCtx->sceneNum) { @@ -397,7 +397,7 @@ void Minimap_Draw(GlobalContext* globalCtx) { if (CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, mapIndex)) { Minimap_DrawCompassIcons(globalCtx); // Draw icons for the player spawn and current position func_80094520(globalCtx->state.gfxCtx); - MapMark_DrawConditionally(globalCtx); + MapMark_Draw(globalCtx); } } @@ -510,7 +510,7 @@ void Map_Update(GlobalContext* globalCtx) { s16 floor; s16 i; - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0)) { + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { switch (globalCtx->sceneNum) { case SCENE_YDAN: case SCENE_DDAN: @@ -522,11 +522,11 @@ void Map_Update(GlobalContext* globalCtx) { case SCENE_HAKADAN: case SCENE_HAKADANCH: case SCENE_ICE_DOUKUTO: - interfaceCtx->unk_140[30] = 0; + interfaceCtx->mapPalette[30] = 0; if (CHECK_DUNGEON_ITEM(DUNGEON_MAP, mapIndex)) { - interfaceCtx->unk_140[31] = 1; + interfaceCtx->mapPalette[31] = 1; } else { - interfaceCtx->unk_140[31] = 0; + interfaceCtx->mapPalette[31] = 0; } for (floor = 0; floor < 8; floor++) { diff --git a/src/code/z_map_mark.c b/src/code/z_map_mark.c index 885458677..4c976f8e6 100644 --- a/src/code/z_map_mark.c +++ b/src/code/z_map_mark.c @@ -74,7 +74,7 @@ void MapMark_ClearPointers(GlobalContext* globalCtx) { sLoadedMarkDataTable = NULL; } -void MapMark_Draw(GlobalContext* globalCtx) { +void MapMark_DrawForDungeon(GlobalContext* globalCtx) { InterfaceContext* interfaceCtx; MapMarkIconData* mapMarkIconData; MapMarkPoint* markPoint; @@ -86,7 +86,7 @@ void MapMark_Draw(GlobalContext* globalCtx) { interfaceCtx = &globalCtx->interfaceCtx; - if (gMapData != NULL && globalCtx->interfaceCtx.mapRoomNum >= gMapData->dgnMinimapCount[dungeon]) { + if ((gMapData != NULL) && (globalCtx->interfaceCtx.mapRoomNum >= gMapData->dgnMinimapCount[dungeon])) { // Translates to: "ROOM NUMBER EXCEEDED, YIKES %d/%d MapMarkDraw PROCESSING INTERRUPTED" osSyncPrintf(VT_COL(RED, WHITE) "部屋番号がオーバーしてるで,ヤバイで %d/%d \nMapMarkDraw の処理を中断します\n", VT_RST, globalCtx->interfaceCtx.mapRoomNum, gMapData->dgnMinimapCount[dungeon]); @@ -107,7 +107,7 @@ void MapMark_Draw(GlobalContext* globalCtx) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->minimapAlpha); gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, interfaceCtx->minimapAlpha); - markPoint = mapMarkIconData->points; + markPoint = &mapMarkIconData->points[0]; for (i = 0; i < mapMarkIconData->count; i++) { if ((mapMarkIconData->markType != MAP_MARK_CHEST) || !Flags_GetTreasure(globalCtx, markPoint->chestFlag)) { markInfo = &sMapMarkInfoTable[mapMarkIconData->markType]; @@ -131,7 +131,7 @@ void MapMark_Draw(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_map_mark.c", 339); } -void MapMark_DrawConditionally(GlobalContext* globalCtx) { +void MapMark_Draw(GlobalContext* globalCtx) { switch (globalCtx->sceneNum) { case SCENE_YDAN: case SCENE_DDAN: @@ -148,6 +148,7 @@ void MapMark_DrawConditionally(GlobalContext* globalCtx) { case SCENE_BDAN_BOSS: case SCENE_MORIBOSSROOM: case SCENE_FIRE_BS: - MapMark_Draw(globalCtx); + MapMark_DrawForDungeon(globalCtx); + break; } } diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index d3fc173de..47aed90f6 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1251,7 +1251,7 @@ void Interface_LoadItemIcon1(GlobalContext* globalCtx, u16 button) { InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); - DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, (u32)interfaceCtx->icon_itemSegment + button * 0x1000, + DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->iconItemSegment + button * 0x1000, (u32)_icon_item_staticSegmentRomStart + (gSaveContext.equips.buttonItems[button] * 0x1000), 0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1171); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); @@ -1261,7 +1261,7 @@ void Interface_LoadItemIcon2(GlobalContext* globalCtx, u16 button) { InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); - DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_180, (u32)interfaceCtx->icon_itemSegment + button * 0x1000, + DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_180, interfaceCtx->iconItemSegment + button * 0x1000, (u32)_icon_item_staticSegmentRomStart + (gSaveContext.equips.buttonItems[button] * 0x1000), 0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1193); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); @@ -1998,7 +1998,7 @@ void Inventory_UpdateBottleItem(GlobalContext* globalCtx, u8 item, u8 button) { Interface_LoadItemIcon1(globalCtx, button); - globalCtx->pauseCtx.unk_23E = item; + globalCtx->pauseCtx.cursorItem[PAUSE_ITEM] = item; gSaveContext.buttonStatus[button] = BTN_ENABLED; } @@ -2053,12 +2053,12 @@ void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 a if ((action != 0x0A) && (action != 0x27) && (action != 0x44)) { osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); - DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, (u32)interfaceCtx->do_actionSegment + (arg2 * 0x180), + DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->doActionSegment + (arg2 * 0x180), (u32)_do_action_staticSegmentRomStart + (action * 0x180), 0x180, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 2145); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); } else { - gSegments[7] = VIRTUAL_TO_PHYSICAL(interfaceCtx->do_actionSegment); + gSegments[7] = VIRTUAL_TO_PHYSICAL(interfaceCtx->doActionSegment); func_80086D5C(SEGMENTED_TO_VIRTUAL(sDoActionTextures[arg2]), 0x180 / 4); } } @@ -2114,7 +2114,7 @@ void Interface_LoadActionLabelB(GlobalContext* globalCtx, u16 action) { interfaceCtx->unk_1FC = action; osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); - DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, (u32)interfaceCtx->do_actionSegment + 0x180, + DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->doActionSegment + 0x180, (u32)_do_action_staticSegmentRomStart + (action * 0x180), 0x180, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 2228); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); @@ -2452,7 +2452,7 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { break; case 7: - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && (msgCtx->msgMode == 0) && + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (msgCtx->msgMode == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx)) { if ((gSaveContext.magic == 0) || ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) || @@ -2668,7 +2668,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, R_B_BTN_COLOR(0), R_B_BTN_COLOR(1), R_B_BTN_COLOR(2), interfaceCtx->bAlpha); gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); - OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, &D_02000A00[0], 32, 32, R_ITEM_BTN_X(0), R_ITEM_BTN_Y(0), + OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, D_02000A00[0], 32, 32, R_ITEM_BTN_X(0), R_ITEM_BTN_Y(0), R_ITEM_BTN_WIDTH(0), R_ITEM_BTN_WIDTH(0), R_ITEM_BTN_DD(0) * 2, R_ITEM_BTN_DD(0) * 2); // C-Left Button Color & Texture @@ -2694,7 +2694,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { G_TX_RENDERTILE, 0, 0, R_ITEM_BTN_DD(3) * 2, R_ITEM_BTN_DD(3) * 2); if ((pauseCtx->state < 8) || (pauseCtx->state >= 18)) { - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.flag != 0)) { + if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { // Start Button Texture, Color & Label gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 120, 120, interfaceCtx->startAlpha); @@ -2707,7 +2707,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, (u32)interfaceCtx->do_actionSegment + 0x300, G_IM_FMT_IA, 48, 16, 0, + gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->doActionSegment + 0x300, G_IM_FMT_IA, 48, 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); @@ -2721,7 +2721,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { } } - if (interfaceCtx->naviCalling && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && + if (interfaceCtx->naviCalling && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (globalCtx->csCtx.state == CS_STATE_IDLE)) { if (!sCUpInvisible) { // C-Up Button Texture, Color & Label (Navi Text) @@ -2777,7 +2777,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { interfaceCtx->cRightAlpha); } - OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, &D_02000A00[temp + 1], 0x20, 0x20, R_ITEM_BTN_X(temp), + OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, D_02000A00[temp + 1], 0x20, 0x20, R_ITEM_BTN_X(temp), R_ITEM_BTN_Y(temp), R_ITEM_BTN_WIDTH(temp), R_ITEM_BTN_WIDTH(temp), R_ITEM_BTN_DD(temp) * 2, R_ITEM_BTN_DD(temp) * 2); } @@ -2847,11 +2847,11 @@ void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { } if (i != 0) { - OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, &D_020035C0[i], 8, 8, R_ITEM_AMMO_X(button), + OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, D_020035C0[i], 8, 8, R_ITEM_AMMO_X(button), R_ITEM_AMMO_Y(button), 8, 8, 1024, 1024); } - OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, &D_020035C0[ammo], 8, 8, R_ITEM_AMMO_X(button) + 6, + OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, D_020035C0[ammo], 8, 8, R_ITEM_AMMO_X(button) + 6, R_ITEM_AMMO_Y(button), 8, 8, 1024, 1024); } @@ -2871,9 +2871,9 @@ void Interface_DrawActionButton(GlobalContext* globalCtx) { gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_parameter.c", 3177), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPVertex(OVERLAY_DISP++, interfaceCtx->vtx_128, 4, 0); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[0], 4, 0); - gDPLoadTextureBlock(OVERLAY_DISP++, &D_02000A00[0], G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, + gDPLoadTextureBlock(OVERLAY_DISP++, D_02000A00[0], G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 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(OVERLAY_DISP++, 0, 2, 3, 1, 0); @@ -2885,101 +2885,104 @@ void Interface_InitVertices(GlobalContext* globalCtx) { InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; s16 i; - interfaceCtx->vtx_128 = Graph_Alloc(globalCtx->state.gfxCtx, 8 * sizeof(Vtx)); + interfaceCtx->actionVtx = Graph_Alloc(globalCtx->state.gfxCtx, 8 * sizeof(Vtx)); // clang-format off - interfaceCtx->vtx_128[0].v.ob[0] = - interfaceCtx->vtx_128[2].v.ob[0] = -14; - interfaceCtx->vtx_128[1].v.ob[0] = - interfaceCtx->vtx_128[3].v.ob[0] = interfaceCtx->vtx_128[0].v.ob[0] + 28; - - interfaceCtx->vtx_128[0].v.ob[1] = - interfaceCtx->vtx_128[1].v.ob[1] = 14; - interfaceCtx->vtx_128[2].v.ob[1] = - interfaceCtx->vtx_128[3].v.ob[1] = interfaceCtx->vtx_128[0].v.ob[1] - 28; - - interfaceCtx->vtx_128[4].v.ob[0] = - interfaceCtx->vtx_128[6].v.ob[0] = -(XREG(21) / 2); - interfaceCtx->vtx_128[5].v.ob[0] = - interfaceCtx->vtx_128[7].v.ob[0] = interfaceCtx->vtx_128[4].v.ob[0] + XREG(21); - - interfaceCtx->vtx_128[4].v.ob[1] = - interfaceCtx->vtx_128[5].v.ob[1] = XREG(28) / 2; - interfaceCtx->vtx_128[6].v.ob[1] = - interfaceCtx->vtx_128[7].v.ob[1] = interfaceCtx->vtx_128[4].v.ob[1] - XREG(28); + interfaceCtx->actionVtx[0].v.ob[0] = + interfaceCtx->actionVtx[2].v.ob[0] = -14; + interfaceCtx->actionVtx[1].v.ob[0] = + interfaceCtx->actionVtx[3].v.ob[0] = interfaceCtx->actionVtx[0].v.ob[0] + 28; + + interfaceCtx->actionVtx[0].v.ob[1] = + interfaceCtx->actionVtx[1].v.ob[1] = 14; + interfaceCtx->actionVtx[2].v.ob[1] = + interfaceCtx->actionVtx[3].v.ob[1] = interfaceCtx->actionVtx[0].v.ob[1] - 28; + + interfaceCtx->actionVtx[4].v.ob[0] = + interfaceCtx->actionVtx[6].v.ob[0] = -(XREG(21) / 2); + interfaceCtx->actionVtx[5].v.ob[0] = + interfaceCtx->actionVtx[7].v.ob[0] = interfaceCtx->actionVtx[4].v.ob[0] + XREG(21); + + interfaceCtx->actionVtx[4].v.ob[1] = + interfaceCtx->actionVtx[5].v.ob[1] = XREG(28) / 2; + interfaceCtx->actionVtx[6].v.ob[1] = + interfaceCtx->actionVtx[7].v.ob[1] = interfaceCtx->actionVtx[4].v.ob[1] - XREG(28); for (i = 0; i < 8; i += 4) { - interfaceCtx->vtx_128[i].v.ob[2] = interfaceCtx->vtx_128[i+1].v.ob[2] = - interfaceCtx->vtx_128[i+2].v.ob[2] = interfaceCtx->vtx_128[i+3].v.ob[2] = 0; - - interfaceCtx->vtx_128[i].v.flag = interfaceCtx->vtx_128[i+1].v.flag = - interfaceCtx->vtx_128[i+2].v.flag = interfaceCtx->vtx_128[i+3].v.flag = 0; - - interfaceCtx->vtx_128[i].v.tc[0] = interfaceCtx->vtx_128[i].v.tc[1] = - interfaceCtx->vtx_128[i+1].v.tc[1] = interfaceCtx->vtx_128[i+2].v.tc[0] = 0; - interfaceCtx->vtx_128[i+1].v.tc[0] = interfaceCtx->vtx_128[i+2].v.tc[1] = - interfaceCtx->vtx_128[i+3].v.tc[0] = interfaceCtx->vtx_128[i+3].v.tc[1] = 1024; - - interfaceCtx->vtx_128[i].v.cn[0] = interfaceCtx->vtx_128[i+1].v.cn[0] = - interfaceCtx->vtx_128[i+2].v.cn[0] = interfaceCtx->vtx_128[i+3].v.cn[0] = - interfaceCtx->vtx_128[i].v.cn[1] = interfaceCtx->vtx_128[i+1].v.cn[1] = - interfaceCtx->vtx_128[i+2].v.cn[1] = interfaceCtx->vtx_128[i+3].v.cn[1] = - interfaceCtx->vtx_128[i].v.cn[2] = interfaceCtx->vtx_128[i+1].v.cn[2] = - interfaceCtx->vtx_128[i+2].v.cn[2] = interfaceCtx->vtx_128[i+3].v.cn[2] = 0xFF; - - interfaceCtx->vtx_128[i].v.cn[3] = interfaceCtx->vtx_128[i+1].v.cn[3] = - interfaceCtx->vtx_128[i+2].v.cn[3] = interfaceCtx->vtx_128[i+3].v.cn[3] = 0xFF; + interfaceCtx->actionVtx[i].v.ob[2] = interfaceCtx->actionVtx[i+1].v.ob[2] = + interfaceCtx->actionVtx[i+2].v.ob[2] = interfaceCtx->actionVtx[i+3].v.ob[2] = 0; + + interfaceCtx->actionVtx[i].v.flag = interfaceCtx->actionVtx[i+1].v.flag = + interfaceCtx->actionVtx[i+2].v.flag = interfaceCtx->actionVtx[i+3].v.flag = 0; + + interfaceCtx->actionVtx[i].v.tc[0] = interfaceCtx->actionVtx[i].v.tc[1] = + interfaceCtx->actionVtx[i+1].v.tc[1] = interfaceCtx->actionVtx[i+2].v.tc[0] = 0; + interfaceCtx->actionVtx[i+1].v.tc[0] = interfaceCtx->actionVtx[i+2].v.tc[1] = + interfaceCtx->actionVtx[i+3].v.tc[0] = interfaceCtx->actionVtx[i+3].v.tc[1] = 1024; + + interfaceCtx->actionVtx[i].v.cn[0] = interfaceCtx->actionVtx[i+1].v.cn[0] = + interfaceCtx->actionVtx[i+2].v.cn[0] = interfaceCtx->actionVtx[i+3].v.cn[0] = + interfaceCtx->actionVtx[i].v.cn[1] = interfaceCtx->actionVtx[i+1].v.cn[1] = + interfaceCtx->actionVtx[i+2].v.cn[1] = interfaceCtx->actionVtx[i+3].v.cn[1] = + interfaceCtx->actionVtx[i].v.cn[2] = interfaceCtx->actionVtx[i+1].v.cn[2] = + interfaceCtx->actionVtx[i+2].v.cn[2] = interfaceCtx->actionVtx[i+3].v.cn[2] = 255; + + interfaceCtx->actionVtx[i].v.cn[3] = interfaceCtx->actionVtx[i+1].v.cn[3] = + interfaceCtx->actionVtx[i+2].v.cn[3] = interfaceCtx->actionVtx[i+3].v.cn[3] = 255; } - interfaceCtx->vtx_128[5].v.tc[0] = interfaceCtx->vtx_128[7].v.tc[0] = 1536; - interfaceCtx->vtx_128[6].v.tc[1] = interfaceCtx->vtx_128[7].v.tc[1] = 512; + interfaceCtx->actionVtx[5].v.tc[0] = interfaceCtx->actionVtx[7].v.tc[0] = 1536; + interfaceCtx->actionVtx[6].v.tc[1] = interfaceCtx->actionVtx[7].v.tc[1] = 512; - interfaceCtx->vtx_12C = Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Vtx)); + interfaceCtx->beatingHeartVtx = Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Vtx)); - interfaceCtx->vtx_12C[0].v.ob[0] = interfaceCtx->vtx_12C[2].v.ob[0] = -8; - interfaceCtx->vtx_12C[1].v.ob[0] = interfaceCtx->vtx_12C[3].v.ob[0] = 8; - interfaceCtx->vtx_12C[0].v.ob[1] = interfaceCtx->vtx_12C[1].v.ob[1] = 8; - interfaceCtx->vtx_12C[2].v.ob[1] = interfaceCtx->vtx_12C[3].v.ob[1] = -8; + interfaceCtx->beatingHeartVtx[0].v.ob[0] = interfaceCtx->beatingHeartVtx[2].v.ob[0] = -8; + interfaceCtx->beatingHeartVtx[1].v.ob[0] = interfaceCtx->beatingHeartVtx[3].v.ob[0] = 8; + interfaceCtx->beatingHeartVtx[0].v.ob[1] = interfaceCtx->beatingHeartVtx[1].v.ob[1] = 8; + interfaceCtx->beatingHeartVtx[2].v.ob[1] = interfaceCtx->beatingHeartVtx[3].v.ob[1] = -8; - interfaceCtx->vtx_12C[0].v.ob[2] = interfaceCtx->vtx_12C[1].v.ob[2] = - interfaceCtx->vtx_12C[2].v.ob[2] = interfaceCtx->vtx_12C[3].v.ob[2] = 0; + interfaceCtx->beatingHeartVtx[0].v.ob[2] = interfaceCtx->beatingHeartVtx[1].v.ob[2] = + interfaceCtx->beatingHeartVtx[2].v.ob[2] = interfaceCtx->beatingHeartVtx[3].v.ob[2] = 0; - interfaceCtx->vtx_12C[0].v.flag = interfaceCtx->vtx_12C[1].v.flag = - interfaceCtx->vtx_12C[2].v.flag = interfaceCtx->vtx_12C[3].v.flag = 0; + interfaceCtx->beatingHeartVtx[0].v.flag = interfaceCtx->beatingHeartVtx[1].v.flag = + interfaceCtx->beatingHeartVtx[2].v.flag = interfaceCtx->beatingHeartVtx[3].v.flag = 0; - interfaceCtx->vtx_12C[0].v.tc[0] = interfaceCtx->vtx_12C[0].v.tc[1] = - interfaceCtx->vtx_12C[1].v.tc[1] = interfaceCtx->vtx_12C[2].v.tc[0] = 0; - interfaceCtx->vtx_12C[1].v.tc[0] = interfaceCtx->vtx_12C[2].v.tc[1] = - interfaceCtx->vtx_12C[3].v.tc[0] = interfaceCtx->vtx_12C[3].v.tc[1] = 512; + interfaceCtx->beatingHeartVtx[0].v.tc[0] = interfaceCtx->beatingHeartVtx[0].v.tc[1] = + interfaceCtx->beatingHeartVtx[1].v.tc[1] = interfaceCtx->beatingHeartVtx[2].v.tc[0] = 0; + interfaceCtx->beatingHeartVtx[1].v.tc[0] = interfaceCtx->beatingHeartVtx[2].v.tc[1] = + interfaceCtx->beatingHeartVtx[3].v.tc[0] = interfaceCtx->beatingHeartVtx[3].v.tc[1] = 512; - interfaceCtx->vtx_12C[0].v.cn[0] = interfaceCtx->vtx_12C[1].v.cn[0] = - interfaceCtx->vtx_12C[2].v.cn[0] = interfaceCtx->vtx_12C[3].v.cn[0] = - interfaceCtx->vtx_12C[0].v.cn[1] = interfaceCtx->vtx_12C[1].v.cn[1] = - interfaceCtx->vtx_12C[2].v.cn[1] = interfaceCtx->vtx_12C[3].v.cn[1] = - interfaceCtx->vtx_12C[0].v.cn[2] = interfaceCtx->vtx_12C[1].v.cn[2] = - interfaceCtx->vtx_12C[2].v.cn[2] = interfaceCtx->vtx_12C[3].v.cn[2] = - interfaceCtx->vtx_12C[0].v.cn[3] = interfaceCtx->vtx_12C[1].v.cn[3] = - interfaceCtx->vtx_12C[2].v.cn[3] = interfaceCtx->vtx_12C[3].v.cn[3] = 0xFF; + interfaceCtx->beatingHeartVtx[0].v.cn[0] = interfaceCtx->beatingHeartVtx[1].v.cn[0] = + interfaceCtx->beatingHeartVtx[2].v.cn[0] = interfaceCtx->beatingHeartVtx[3].v.cn[0] = + interfaceCtx->beatingHeartVtx[0].v.cn[1] = interfaceCtx->beatingHeartVtx[1].v.cn[1] = + interfaceCtx->beatingHeartVtx[2].v.cn[1] = interfaceCtx->beatingHeartVtx[3].v.cn[1] = + interfaceCtx->beatingHeartVtx[0].v.cn[2] = interfaceCtx->beatingHeartVtx[1].v.cn[2] = + interfaceCtx->beatingHeartVtx[2].v.cn[2] = interfaceCtx->beatingHeartVtx[3].v.cn[2] = + interfaceCtx->beatingHeartVtx[0].v.cn[3] = interfaceCtx->beatingHeartVtx[1].v.cn[3] = + interfaceCtx->beatingHeartVtx[2].v.cn[3] = interfaceCtx->beatingHeartVtx[3].v.cn[3] = 255; // clang-format on } void func_8008A8B8(GlobalContext* globalCtx, s32 topY, s32 bottomY, s32 leftX, s32 rightX) { InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - Vec3f sp40; - Vec3f sp34; - Vec3f sp28; - - sp40.x = sp40.y = sp40.z = 0.0f; - sp34.x = sp34.y = 0.0f; - sp34.z = -1.0f; - sp28.x = sp28.z = 0.0f; - sp28.y = 1.0f; - func_800AA358(&interfaceCtx->view, &sp40, &sp34, &sp28); + Vec3f eye; + Vec3f lookAt; + Vec3f up; + + eye.x = eye.y = eye.z = 0.0f; + lookAt.x = lookAt.y = 0.0f; + lookAt.z = -1.0f; + up.x = up.z = 0.0f; + up.y = 1.0f; + + func_800AA358(&interfaceCtx->view, &eye, &lookAt, &up); + interfaceCtx->viewport.topY = topY; interfaceCtx->viewport.bottomY = bottomY; interfaceCtx->viewport.leftX = leftX; interfaceCtx->viewport.rightX = rightX; View_SetViewport(&interfaceCtx->view, &interfaceCtx->viewport); + func_800AA460(&interfaceCtx->view, 60.0f, 10.0f, 60.0f); func_800AB560(&interfaceCtx->view); } @@ -2989,9 +2992,9 @@ void func_8008A994(InterfaceContext* interfaceCtx) { func_800AB2C4(&interfaceCtx->view); } -s16 sMagicArrowEffectsR[] = { 0xFF, 0x64, 0xFF }; -s16 sMagicArrowEffectsG[] = { 0x00, 0x64, 0xFF }; -s16 sMagicArrowEffectsB[] = { 0x00, 0xFF, 0x64 }; +s16 sMagicArrowEffectsR[] = { 255, 100, 255 }; +s16 sMagicArrowEffectsG[] = { 0, 100, 255 }; +s16 sMagicArrowEffectsB[] = { 0, 255, 100 }; s16 sTimerDigitLeftPos[] = { 16, 25, 34, 42, 51 }; s16 sDigitWidth[] = { 9, 9, 8, 9, 9 }; @@ -3039,11 +3042,11 @@ void Interface_Draw(GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3405); gSPSegment(OVERLAY_DISP++, 0x02, interfaceCtx->parameterSegment); - gSPSegment(OVERLAY_DISP++, 0x07, interfaceCtx->do_actionSegment); - gSPSegment(OVERLAY_DISP++, 0x08, interfaceCtx->icon_itemSegment); + gSPSegment(OVERLAY_DISP++, 0x07, interfaceCtx->doActionSegment); + gSPSegment(OVERLAY_DISP++, 0x08, interfaceCtx->iconItemSegment); gSPSegment(OVERLAY_DISP++, 0x0B, interfaceCtx->mapSegment); - if (pauseCtx->flag == 0) { + if (pauseCtx->debugState == 0) { Interface_InitVertices(globalCtx); func_8008A994(interfaceCtx); HealthMeter_Draw(globalCtx); @@ -3093,12 +3096,12 @@ void Interface_Draw(GlobalContext* globalCtx) { phi_s2 = 42; if (interfaceCtx->counterDigits[2] != 0) { - OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, &D_02003040[interfaceCtx->counterDigits[2]], 8, 16, + OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, D_02003040[interfaceCtx->counterDigits[2]], 8, 16, phi_s2, 190, 8, 16, 1024, 1024); phi_s2 = 50; } - OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, &D_02003040[interfaceCtx->counterDigits[3]], 8, 16, + OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, D_02003040[interfaceCtx->counterDigits[3]], 8, 16, phi_s2, 190, 8, 16, 1024, 1024); } @@ -3146,7 +3149,7 @@ void Interface_Draw(GlobalContext* globalCtx) { phi_s1 = sRupeeDigitsCount[CUR_UPG_VALUE(UPG_WALLET)]; for (phi_s3 = 0; phi_s3 < phi_s1; phi_s3++, phi_s0++, phi_s2 += 8) { - OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, &D_02003040[interfaceCtx->counterDigits[phi_s0]], 8, 16, phi_s2, + OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, D_02003040[interfaceCtx->counterDigits[phi_s0]], 8, 16, phi_s2, 206, 8, 16, 1024, 1024); } @@ -3168,7 +3171,7 @@ void Interface_Draw(GlobalContext* globalCtx) { if (interfaceCtx->unk_1FA == 0) { // B Button Icon & possibly Ammo Count if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { - Interface_DrawItemIconTexture(globalCtx, (void*)(u32)interfaceCtx->icon_itemSegment, 0); + Interface_DrawItemIconTexture(globalCtx, interfaceCtx->iconItemSegment, 0); if ((player->stateFlags1 & 0x00800000) || (globalCtx->shootingGalleryStatus > 1) || ((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38))) { @@ -3185,7 +3188,7 @@ void Interface_Draw(GlobalContext* globalCtx) { PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, (u32)interfaceCtx->do_actionSegment + 0x180, G_IM_FMT_IA, 48, 16, 0, + gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->doActionSegment + 0x180, G_IM_FMT_IA, 48, 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); @@ -3202,7 +3205,7 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[1] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cLeftAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - Interface_DrawItemIconTexture(globalCtx, (void*)((u32)interfaceCtx->icon_itemSegment + 0x1000), 1); + Interface_DrawItemIconTexture(globalCtx, interfaceCtx->iconItemSegment + 0x1000, 1); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -3215,7 +3218,7 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[2] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cDownAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - Interface_DrawItemIconTexture(globalCtx, (void*)((u32)interfaceCtx->icon_itemSegment + 0x2000), 2); + Interface_DrawItemIconTexture(globalCtx, interfaceCtx->iconItemSegment + 0x2000, 2); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -3228,7 +3231,7 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[3] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cRightAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - Interface_DrawItemIconTexture(globalCtx, (void*)((u32)interfaceCtx->icon_itemSegment + 0x3000), 3); + Interface_DrawItemIconTexture(globalCtx, interfaceCtx->iconItemSegment + 0x3000, 3); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -3255,12 +3258,12 @@ void Interface_Draw(GlobalContext* globalCtx) { Matrix_RotateX(interfaceCtx->unk_1F4 / 10000.0f, MTXMODE_APPLY); gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_parameter.c", 3701), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPVertex(OVERLAY_DISP++, &interfaceCtx->vtx_128[4], 4, 0); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[4], 4, 0); if ((interfaceCtx->unk_1EC < 2) || (interfaceCtx->unk_1EC == 3)) { - Interface_DrawActionLabel(globalCtx->state.gfxCtx, (void*)(u32)interfaceCtx->do_actionSegment); + Interface_DrawActionLabel(globalCtx->state.gfxCtx, interfaceCtx->doActionSegment); } else { - Interface_DrawActionLabel(globalCtx->state.gfxCtx, (void*)((u32)interfaceCtx->do_actionSegment + 0x180)); + Interface_DrawActionLabel(globalCtx->state.gfxCtx, interfaceCtx->doActionSegment + 0x180); } gDPPipeSync(OVERLAY_DISP++); @@ -3269,45 +3272,45 @@ void Interface_Draw(GlobalContext* globalCtx) { if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 3)) { // Inventory Equip Effects - gSPSegment(OVERLAY_DISP++, 0x08, pauseCtx->unk_128); + gSPSegment(OVERLAY_DISP++, 0x08, pauseCtx->iconItemSegment); func_80094A14(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gSPMatrix(OVERLAY_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); - pauseCtx->vtx_168[16].v.ob[0] = pauseCtx->vtx_168[18].v.ob[0] = pauseCtx->unk_254 / 10; - pauseCtx->vtx_168[17].v.ob[0] = pauseCtx->vtx_168[19].v.ob[0] = - pauseCtx->vtx_168[16].v.ob[0] + WREG(90) / 10; - pauseCtx->vtx_168[16].v.ob[1] = pauseCtx->vtx_168[17].v.ob[1] = pauseCtx->unk_256 / 10; - pauseCtx->vtx_168[18].v.ob[1] = pauseCtx->vtx_168[19].v.ob[1] = - pauseCtx->vtx_168[16].v.ob[1] - WREG(90) / 10; + pauseCtx->cursorVtx[16].v.ob[0] = pauseCtx->cursorVtx[18].v.ob[0] = pauseCtx->equipAnimX / 10; + pauseCtx->cursorVtx[17].v.ob[0] = pauseCtx->cursorVtx[19].v.ob[0] = + pauseCtx->cursorVtx[16].v.ob[0] + WREG(90) / 10; + pauseCtx->cursorVtx[16].v.ob[1] = pauseCtx->cursorVtx[17].v.ob[1] = pauseCtx->equipAnimY / 10; + pauseCtx->cursorVtx[18].v.ob[1] = pauseCtx->cursorVtx[19].v.ob[1] = + pauseCtx->cursorVtx[16].v.ob[1] - WREG(90) / 10; - if (pauseCtx->unk_24E < 0xBF) { + if (pauseCtx->equipTargetItem < 0xBF) { // Normal Equip (icon goes from the inventory slot to the C button when equipping it) - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, pauseCtx->unk_258); - gSPVertex(OVERLAY_DISP++, &pauseCtx->vtx_168[16], 4, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, pauseCtx->equipAnimAlpha); + gSPVertex(OVERLAY_DISP++, &pauseCtx->cursorVtx[16], 4, 0); - gDPLoadTextureBlock(OVERLAY_DISP++, gItemIcons[pauseCtx->unk_24E], G_IM_FMT_RGBA, G_IM_SIZ_32b, 32, 32, - 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); + gDPLoadTextureBlock(OVERLAY_DISP++, gItemIcons[pauseCtx->equipTargetItem], G_IM_FMT_RGBA, G_IM_SIZ_32b, + 32, 32, 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); } else { // Magic Arrow Equip Effect - phi_s3_2 = pauseCtx->unk_24E - 0xBF; + phi_s3_2 = pauseCtx->equipTargetItem - 0xBF; gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sMagicArrowEffectsR[phi_s3_2], sMagicArrowEffectsG[phi_s3_2], - sMagicArrowEffectsB[phi_s3_2], pauseCtx->unk_258); - - if ((pauseCtx->unk_258 > 0) && (pauseCtx->unk_258 < 0xFF)) { - phi_s3_2 = (pauseCtx->unk_258 / 8) / 2; - pauseCtx->vtx_168[16].v.ob[0] = pauseCtx->vtx_168[18].v.ob[0] = - pauseCtx->vtx_168[16].v.ob[0] - phi_s3_2; - pauseCtx->vtx_168[17].v.ob[0] = pauseCtx->vtx_168[19].v.ob[0] = - pauseCtx->vtx_168[16].v.ob[0] + phi_s3_2 * 2 + 32; - pauseCtx->vtx_168[16].v.ob[1] = pauseCtx->vtx_168[17].v.ob[1] = - pauseCtx->vtx_168[16].v.ob[1] + phi_s3_2; - pauseCtx->vtx_168[18].v.ob[1] = pauseCtx->vtx_168[19].v.ob[1] = - pauseCtx->vtx_168[16].v.ob[1] - phi_s3_2 * 2 - 32; + sMagicArrowEffectsB[phi_s3_2], pauseCtx->equipAnimAlpha); + + if ((pauseCtx->equipAnimAlpha > 0) && (pauseCtx->equipAnimAlpha < 255)) { + phi_s3_2 = (pauseCtx->equipAnimAlpha / 8) / 2; + pauseCtx->cursorVtx[16].v.ob[0] = pauseCtx->cursorVtx[18].v.ob[0] = + pauseCtx->cursorVtx[16].v.ob[0] - phi_s3_2; + pauseCtx->cursorVtx[17].v.ob[0] = pauseCtx->cursorVtx[19].v.ob[0] = + pauseCtx->cursorVtx[16].v.ob[0] + phi_s3_2 * 2 + 32; + pauseCtx->cursorVtx[16].v.ob[1] = pauseCtx->cursorVtx[17].v.ob[1] = + pauseCtx->cursorVtx[16].v.ob[1] + phi_s3_2; + pauseCtx->cursorVtx[18].v.ob[1] = pauseCtx->cursorVtx[19].v.ob[1] = + pauseCtx->cursorVtx[16].v.ob[1] - phi_s3_2 * 2 - 32; } - gSPVertex(OVERLAY_DISP++, &pauseCtx->vtx_168[16], 4, 0); + gSPVertex(OVERLAY_DISP++, &pauseCtx->cursorVtx[16], 4, 0); gDPLoadTextureBlock(OVERLAY_DISP++, D_080895C0, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 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); @@ -3318,7 +3321,7 @@ void Interface_Draw(GlobalContext* globalCtx) { func_80094520(globalCtx->state.gfxCtx); - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0)) { + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { if (gSaveContext.minigameState != 1) { // Carrots rendering if the action corresponds to riding a horse if (interfaceCtx->unk_1EE == 8) { @@ -3364,7 +3367,7 @@ void Interface_Draw(GlobalContext* globalCtx) { for (phi_s3 = 0; phi_s3 < 4; phi_s3++) { if (sHBAScoreDigits[phi_s3] != 0 || (phi_s0 != 0) || (phi_s3 >= 3)) { OVERLAY_DISP = - Gfx_TextureI8(OVERLAY_DISP, &D_02003040[sHBAScoreDigits[phi_s3]], 8, 16, phi_s1, + Gfx_TextureI8(OVERLAY_DISP, D_02003040[sHBAScoreDigits[phi_s3]], 8, 16, phi_s1, ZREG(15) - 2, sDigitWidth[0], VREG(42), VREG(43) * 2, VREG(43) * 2); phi_s1 += 9; phi_s0++; @@ -3413,7 +3416,7 @@ void Interface_Draw(GlobalContext* globalCtx) { } } - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (msgCtx->msgMode == 0) && !(player->stateFlags2 & 0x01000000) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx) && (gSaveContext.minigameState != 1) && @@ -3779,7 +3782,7 @@ void Interface_Draw(GlobalContext* globalCtx) { } for (phi_s3 = 0; phi_s3 < 5; phi_s3++) { - OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, &D_02003040[sTimerDigits[phi_s3]], 8, 16, + OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, D_02003040[sTimerDigits[phi_s3]], 8, 16, gSaveContext.timerX[sp274] + sTimerDigitLeftPos[phi_s3], gSaveContext.timerY[sp274], sDigitWidth[phi_s3], VREG(42), VREG(43) * 2, VREG(43) * 2); @@ -3788,7 +3791,7 @@ void Interface_Draw(GlobalContext* globalCtx) { } } - if (pauseCtx->flag == 3) { + if (pauseCtx->debugState == 3) { FlagSet_Update(globalCtx); } @@ -3832,7 +3835,7 @@ void Interface_Update(GlobalContext* globalCtx) { osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language); } - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0)) { + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { if ((gSaveContext.minigameState == 1) || (gSaveContext.sceneSetupIndex < 4) || ((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.sceneSetupIndex == 4))) { if ((msgCtx->msgMode == 0) || ((msgCtx->msgMode != 0) && (globalCtx->sceneNum == SCENE_BOWLING))) { @@ -3974,7 +3977,7 @@ void Interface_Update(GlobalContext* globalCtx) { HealthMeter_Update(globalCtx); - if ((gSaveContext.timer1State >= 3) && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && + if ((gSaveContext.timer1State >= 3) && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (msgCtx->msgMode == 0) && !(player->stateFlags2 & 0x01000000) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx)) {} @@ -4055,7 +4058,7 @@ void Interface_Update(GlobalContext* globalCtx) { WREG(7) = interfaceCtx->unk_1F4; - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.flag == 0) && (msgCtx->msgMode == 0) && + if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (msgCtx->msgMode == 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (globalCtx->transitionMode == 0) && ((globalCtx->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(globalCtx))) { diff --git a/src/code/z_play.c b/src/code/z_play.c index b9545f4df..ee7567911 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -778,7 +778,7 @@ void Gameplay_Update(GlobalContext* globalCtx) { LOG_NUM("1", 1, "../z_play.c", 3551); } - sp80 = (globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.flag != 0); + sp80 = (globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0); if (1 && HREG(63)) { LOG_NUM("1", 1, "../z_play.c", 3555); @@ -903,7 +903,7 @@ void Gameplay_Update(GlobalContext* globalCtx) { if (globalCtx->unk_1242B != 0) { if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) { - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.flag != 0)) { + if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { // Translates to: "Changing viewpoint is prohibited due to the kaleidoscope" osSyncPrintf(VT_FGCOL(CYAN) "カレイドスコープ中につき視点変更を禁止しております\n" VT_RST); } else if (Player_InCsMode(globalCtx)) { @@ -928,7 +928,7 @@ void Gameplay_Update(GlobalContext* globalCtx) { LOG_NUM("1", 1, "../z_play.c", 3716); } - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.flag != 0)) { + if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { if (1 && HREG(63)) { LOG_NUM("1", 1, "../z_play.c", 3721); } @@ -1031,7 +1031,7 @@ skip: } void Gameplay_DrawOverlayElements(GlobalContext* globalCtx) { - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.flag != 0)) { + if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { KaleidoScopeCall_Draw(globalCtx); } diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index cb5782207..2c4ff37e8 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1367,7 +1367,7 @@ u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { SkelAnime_InitLink(globalCtx, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.linkAge], &gPlayerAnim_003238, 9, ptr, ptr, PLAYER_LIMB_MAX); - return size + 0x8890; + return size + 0x8800 + 0x90; } u8 D_801261F8[] = { 2, 2, 5 }; @@ -1412,7 +1412,7 @@ s32 func_80091880(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return 0; } -void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime* arg3, Vec3f* pos, Vec3s* rot, +void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots, s32 width, s32 height, Vec3f* eye, Vec3f* at, f32 fovy, void* img1, void* img2) { static Vp viewport = { 128, 224, 511, 0, 128, 224, 511, 0 }; @@ -1503,8 +1503,8 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime gSPSegment(POLY_OPA_DISP++, 0x0C, gCullBackDList); - func_8008F470(globalCtx, arg3->skeleton, arg3->jointTable, arg3->dListCount, 0, tunic, boots, 0, func_80091880, - NULL, &sp12C); + func_8008F470(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, tunic, boots, 0, + func_80091880, NULL, &sp12C); gSPEndDisplayList(POLY_OPA_DISP++); gSPEndDisplayList(POLY_XLU_DISP++); @@ -1515,8 +1515,8 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 3288); } -void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* arg2, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, - s32 tunic, s32 shield, s32 boots) { +void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, + s32 sword, s32 tunic, s32 shield, s32 boots) { static Vec3f eye = { 0.0f, 0.0f, -400.0f }; static Vec3f at = { 0.0f, 0.0f, 0.0f }; Vec3s* destTable; @@ -1543,12 +1543,12 @@ void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* arg2, Vec3f } srcTable = SEGMENTED_TO_VIRTUAL(srcTable); - destTable = arg2->jointTable; - for (i = 0; i < arg2->limbCount; i++) { + destTable = skelAnime->jointTable; + for (i = 0; i < skelAnime->limbCount; i++) { *destTable++ = *srcTable++; } - func_80091A24(globalCtx, segment + 0x3800, segment + 0x8800, arg2, pos, rot, scale, sword, tunic, shield, boots, 64, - 112, &eye, &at, 60.0f, globalCtx->state.gfxCtx->curFrameBuffer, + func_80091A24(globalCtx, segment + 0x3800, segment + 0x8800, skelAnime, pos, rot, scale, sword, tunic, shield, + boots, 64, 112, &eye, &at, 60.0f, globalCtx->state.gfxCtx->curFrameBuffer, globalCtx->state.gfxCtx->curFrameBuffer + 0x1C00); } diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 82ff5b776..a287a9c08 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -27,7 +27,7 @@ void Sample_Draw(SampleContext* this) { gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_LOAD); } - POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, 0xFF, 0xFF, 0xFF, 0, 0, 0); + POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, 255, 255, 255, 0, 0, 0); func_80093D18(gfxCtx); gDPSetCycleType(POLY_OPA_DISP++, G_CYC_1CYCLE); @@ -54,24 +54,24 @@ void Sample_SetupView(SampleContext* this) { View_Init(view, gfxCtx); SET_FULLSCREEN_VIEWPORT(view); - func_800AA460(view, 60, 10, 12800); + func_800AA460(view, 60.0f, 10.0f, 12800.0f); { - Vec3f v1; - Vec3f v2; - Vec3f v3; - - v1.x = 0; - v1.y = 0; - v2.x = 0; - v2.y = 0; - v2.z = 0; - v3.x = 0; - v3.z = 0; - v1.z = 3000; - v3.y = 1; - - func_800AA358(view, &v1, &v2, &v3); + Vec3f eye; + Vec3f lookAt; + Vec3f up; + + eye.x = 0.0f; + eye.y = 0.0f; + eye.z = 3000.0f; + lookAt.x = 0.0f; + lookAt.y = 0.0f; + lookAt.z = 0.0f; + up.x = 0.0f; + up.z = 0.0f; + up.y = 1.0f; + + func_800AA358(view, &eye, &lookAt, &up); } } diff --git a/src/code/z_sram.c b/src/code/z_sram.c index a3134526b..f1adce270 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -451,7 +451,7 @@ void Sram_OpenSave(SramContext* sramCtx) { * Write the contents of the Save Context to a main and backup slot in SRAM. * Note: The whole Save Context is written even though only the `save` substruct is read back later */ -void Sram_WriteSave(s32 unused) { +void Sram_WriteSave(SramContext* sramCtx) { u16 offset; u16 checksum; u16 j; diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 6b6e24701..21a325da3 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -222,7 +222,7 @@ u32 func_809EF70C(EnDns* this) { } u32 func_809EF73C(EnDns* this) { - if (INV_CONTENT(SLOT_SLINGSHOT) == ITEM_NONE) { + if (INV_CONTENT(ITEM_SLINGSHOT) == ITEM_NONE) { return 3; } if (AMMO(ITEM_SLINGSHOT) >= CUR_CAPACITY(UPG_BULLET_BAG)) { diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index db8dd4e3e..0fc2b3dde 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -677,12 +677,8 @@ void func_80A7D460(EnInsect* this, GlobalContext* globalCtx) { if (sp3A == 2 && (this->unk_314 & 0x10) && !(this->unk_314 & 0x80)) { if (this->unk_32A >= 15) { if (this->soilActor != NULL) { - temp_a0 = ((this->soilActor->actor.params >> 8) & 0x1F) - 1; - temp_a1 = temp_a0 & 3; - - if ((((gSaveContext.gsFlags[temp_a0 >> 2] & gGoldSkullFlgMask[temp_a1]) >> - gGoldSkullFlgShift[temp_a1]) & - (this->soilActor->actor.params & 0xFF)) == 0) { + if (!(GET_GS_FLAGS(((this->soilActor->actor.params >> 8) & 0x1F) - 1) & + (this->soilActor->actor.params & 0xFF))) { func_80078884(NA_SE_SY_TRE_BOX_APPEAR); } } diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 217ea77d6..0b7a0ae89 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -330,8 +330,8 @@ void EnMag_DrawImageRGBA32(Gfx** gfxp, s16 centerX, s16 centerY, u8* source, u32 textureCount += 1; } - gSetTileCustom(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_32b, width, textureHeight, 0, G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPSetTileCustom(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_32b, width, textureHeight, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); remainingSize -= textureSize; @@ -344,8 +344,6 @@ void EnMag_DrawImageRGBA32(Gfx** gfxp, s16 centerX, s16 centerY, u8* source, u32 gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + (s32)width) << 2, (rectTop + textureHeight) << 2, G_TX_RENDERTILE, 0, 0, 1024, 1024); - if (1) {} - curTexture += textureSize; rectTop += textureHeight; @@ -354,8 +352,9 @@ void EnMag_DrawImageRGBA32(Gfx** gfxp, s16 centerX, s16 centerY, u8* source, u32 textureHeight = remainingSize / (s32)(width << 2); remainingSize -= textureSize; - gSetTileCustom(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_32b, width, textureHeight, 0, G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPSetTileCustom(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_32b, width, textureHeight, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); } } else { remainingSize -= textureSize; diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.h b/src/overlays/actors/ovl_En_Mag/z_en_mag.h index 8962dd8f9..875be7250 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.h +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.h @@ -42,17 +42,4 @@ typedef enum { /* 0x04 */ MAG_STATE_POST_DISPLAY } EnMagGlobalState; -#define gSetTileCustom(pkt, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ - do { \ - gDPPipeSync(pkt); \ - gDPTileSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width)*siz##_TILE_BYTES) + 7) >> 3, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, \ - masks, shifts); \ - gDPTileSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width)*siz##_TILE_BYTES) + 7) >> 3, 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \ - cms, masks, shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ - } while (0); - #endif diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.c b/src/overlays/actors/ovl_En_Si/z_en_si.c index 199f3a2e1..50c4f30be 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -126,16 +126,11 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { void func_80AFB950(EnSi* this, GlobalContext* globalCtx) { Player* player = PLAYER; - s32 temp; - s16 params; if (func_8010BDBC(&globalCtx->msgCtx) != 2) { player->actor.freezeTimer = 10; } else { - params = this->actor.params; - temp = (params & 0x1F00) >> 8; - gSaveContext.gsFlags[temp >> 2] |= (params & 0xFF) << gGoldSkullFlgShift[temp & 3]; - + SET_GS_FLAGS((this->actor.params & 0x1F00) >> 8, this->actor.params & 0xFF); Actor_Kill(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index ba3acabca..e37514d80 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -237,10 +237,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { } // Check to see if this gold skull token has already been retrieved. - if (((gSaveContext.gsFlags[((thisx->params & 0x1F00) >> 8) >> 2] & - gGoldSkullFlgMask[((thisx->params & 0x1F00) >> 8) & 3]) >> - gGoldSkullFlgShift[((thisx->params & 0x1F00) >> 8) & 3]) & - (thisx->params & 0xFF)) { + if (GET_GS_FLAGS((thisx->params & 0x1F00) >> 8) & (thisx->params & 0xFF)) { Actor_Kill(&this->actor); return; } diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c index 556b3e17b..929ca3cb7 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -164,7 +164,7 @@ void ShotSun_UpdateHyliaSun(ShotSun* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { func_80078884(NA_SE_SY_CORRECT_CHIME); osSyncPrintf(VT_FGCOL(CYAN) "SHOT_SUN HIT!!!!!!!\n" VT_RST); - if (INV_CONTENT(SLOT_ARROW_FIRE) == ITEM_NONE) { + if (INV_CONTENT(ITEM_ARROW_FIRE) == ITEM_NONE) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_ETCETERA, 700.0f, -800.0f, 7261.0f, 0, 0, 0, 7); globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(D_02007020); if (1) {} diff --git a/src/overlays/actors/ovl_kaleido_scope/overlay.cfg b/src/overlays/actors/ovl_kaleido_scope/overlay.cfg index ab8a87d93..d9bc0eb65 100644 --- a/src/overlays/actors/ovl_kaleido_scope/overlay.cfg +++ b/src/overlays/actors/ovl_kaleido_scope/overlay.cfg @@ -4,5 +4,7 @@ z_kaleido_debug.c z_kaleido_equipment.c z_kaleido_item.c z_kaleido_map_PAL.c +z_kaleido_prompt.c z_kaleido_scope_PAL.c -z_lmap_mark.c
\ No newline at end of file +z_lmap_mark.c +z_lmap_mark_data.c
\ No newline at end of file diff --git a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_collect.c index c6040820d..05a183d63 100644 --- a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_collect.c @@ -1,3 +1,733 @@ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80813820.s") +#include "z_kaleido_scope.h" +#include "textures/parameter_static/parameter_static.h" +#include "textures/icon_item_static/icon_item_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80815CC8.s") +#ifdef NON_MATCHING +// many non matching issues but should be functionally equivalent +void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { + static s16 D_8082A070[][4] = { + { 255, 0, 0, 255 }, + { 255, 70, 0, 150 }, + { 255, 70, 0, 150 }, + { 255, 0, 0, 255 }, + }; + static s16 D_8082A090[][3] = { + { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + { 0, 60, 0 }, { 90, 0, 0 }, { 0, 40, 110 }, { 80, 40, 0 }, { 70, 0, 90 }, { 90, 90, 0 }, + }; + static s16 D_8082A0D8[] = { 255, 255, 255, 255, 255, 255 }; + static s16 D_8082A0E4[] = { 255, 255, 255, 255, 255, 255 }; + static s16 D_8082A0F0[] = { 150, 150, 150, 150, 150, 150 }; + static s16 D_8082A0FC = 20; + static s16 D_8082A100 = 0; + static s16 D_8082A104 = 0; + static s16 D_8082A108 = 0; + static s16 D_8082A10C = 0; + static s16 D_8082A110 = 0; + static s16 D_8082A114 = 20; + static s16 D_8082A118 = 0; + static s16 D_8082A11C = 0; + static s16 D_8082A120 = 0; + static u8 D_8082A124[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }; + static void* D_8082A130[] = { + gHUDButtonATex, gHUDButtonCDownTex, gHUDButtonCRightTex, gHUDButtonCLeftTex, gHUDButtonCUpTex, + }; + static u16 D_8082A144[] = { + 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, + }; + static s16 D_8082A150[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }; + static s16 D_8082A164[] = { + 150, 255, 100, 255, 255, 255, 255, 255, 255, 255, 255, 255, + }; + static s16 D_8082A17C[] = { + 255, 80, 150, 160, 100, 240, 255, 255, 255, 255, 255, 255, + }; + static s16 D_8082A194[] = { + 100, 40, 255, 0, 255, 100, 255, 255, 255, 255, 255, 255, + }; + static s8 D_8082A1AC[][4] = { + { 0x05, 0x01, 0x05, 0xFE }, { 0x00, 0x02, 0x02, 0xFE }, { 0xFF, 0x13, 0x03, 0x01 }, { 0x04, 0x02, 0x11, 0x02 }, + { 0x05, 0x03, 0x18, 0x05 }, { 0xFF, 0xFF, 0x04, 0x00 }, { 0x0C, 0xFF, 0xFD, 0x07 }, { 0x0D, 0xFF, 0x06, 0x08 }, + { 0x0E, 0xFF, 0x07, 0x09 }, { 0x0F, 0xFF, 0x08, 0x0A }, { 0x10, 0xFF, 0x09, 0x0B }, { 0x11, 0xFF, 0x0A, 0x12 }, + { 0x17, 0x06, 0xFD, 0x0D }, { 0x17, 0x07, 0x0C, 0x0E }, { 0x17, 0x08, 0x0D, 0x0F }, { 0x18, 0x09, 0x0E, 0x10 }, + { 0x18, 0x0A, 0x0F, 0x11 }, { 0x18, 0x0B, 0x10, 0x03 }, { 0x02, 0xFF, 0x0B, 0x13 }, { 0x02, 0xFF, 0x12, 0x14 }, + { 0x02, 0xFF, 0x13, 0xFE }, { 0xFF, 0x17, 0xFD, 0x16 }, { 0xFF, 0x17, 0x15, 0x18 }, { 0x15, 0x0C, 0xFD, 0x18 }, + { 0xFF, 0x10, 0x16, 0x04 }, { 0x00, 0x00, 0x00, 0x00 }, + }; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + Input* input = &globalCtx->state.input[0]; + s16 sp226; + s16 sp224; + s16 sp222; + s16 sp220; + s16 phi_s0; + s16 phi_s3; + s16 sp21A; + s16 sp218; + s16 sp216; + s16 phi_s6; + s16 phi_v1; + s16 phi_a2; + s16 phi_s0_2; + s16 sp208[3]; + + OPEN_DISPS(gfxCtx, "../z_kaleido_collect.c", 248); + + if ((!pauseCtx->unk_1E4 || (pauseCtx->unk_1E4 == 5) || (pauseCtx->unk_1E4 == 8)) && + (pauseCtx->pageIndex == PAUSE_QUEST)) { + pauseCtx->cursorColorSet = 0; + + if (pauseCtx->cursorSpecialPos == 0) { + pauseCtx->nameColorSet = 0; + + if ((pauseCtx->state != 6) || ((pauseCtx->stickRelX == 0) && (pauseCtx->stickRelY == 0))) { + sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; + } else { + phi_s3 = pauseCtx->cursorPoint[PAUSE_QUEST]; + + if (pauseCtx->stickRelX < -30) { + phi_s0 = D_8082A1AC[phi_s3][2]; + if (phi_s0 == -3) { + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); + pauseCtx->unk_1E4 = 0; + } else { + while (phi_s0 >= 0) { + if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) { + break; + } + phi_s0 = D_8082A1AC[phi_s0][2]; + } + } + } else if (pauseCtx->stickRelX > 30) { + phi_s0 = D_8082A1AC[phi_s3][3]; + if (phi_s0 == -2) { + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); + pauseCtx->unk_1E4 = 0; + } else { + while (phi_s0 >= 0) { + if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) { + break; + } + phi_s0 = D_8082A1AC[phi_s0][3]; + } + } + } + + if (pauseCtx->stickRelY < -30) { + phi_s0 = D_8082A1AC[phi_s3][1]; + while (phi_s0 >= 0) { + if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) { + break; + } + phi_s0 = D_8082A1AC[phi_s0][1]; + } + } else if (pauseCtx->stickRelY > 30) { + phi_s0 = D_8082A1AC[phi_s3][0]; + while (phi_s0 >= 0) { + if ((s16)KaleidoScope_UpdateQuestStatusPoint(pauseCtx, phi_s0) != 0) { + break; + } + phi_s0 = D_8082A1AC[phi_s0][0]; + } + } + + if (phi_s3 != pauseCtx->cursorPoint[PAUSE_QUEST]) { + pauseCtx->unk_1E4 = 0; + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + + if (pauseCtx->cursorPoint[PAUSE_QUEST] != 0x18) { + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + if (pauseCtx->cursorPoint[PAUSE_QUEST] < 6) { + phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x66; + osSyncPrintf("000 ccc=%d\n", phi_s0_2); + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] < 0x12) { + phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x54; + osSyncPrintf("111 ccc=%d\n", phi_s0_2); + } else { + phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x5A; + osSyncPrintf("222 ccc=%d (%d, %d, %d)\n", phi_s0_2, pauseCtx->cursorPoint[PAUSE_QUEST], + 0x12, 0x6C); + } + } else { + phi_s0_2 = PAUSE_ITEM_NONE; + osSyncPrintf("999 ccc=%d (%d, %d)\n", PAUSE_ITEM_NONE, pauseCtx->cursorPoint[PAUSE_QUEST], + 0x18); + } + } else { + if ((gSaveContext.inventory.questItems & 0xF0000000) != 0) { + phi_s0_2 = 0x72; + } else { + phi_s0_2 = PAUSE_ITEM_NONE; + } + osSyncPrintf("888 ccc=%d (%d, %d, %x)\n", phi_s0_2, pauseCtx->cursorPoint[PAUSE_QUEST], 0x72, + gSaveContext.inventory.questItems & 0xF0000000); + } + + sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = phi_s0_2; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216; + } + + KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); + + if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->cursorSpecialPos == 0)) { + if ((sp216 >= 6) && (sp216 < 0x12)) { + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; + pauseCtx->unk_264 = D_80153960[sp216]; + D_8082A120 = 10; + + for (phi_s3 = 0; phi_s3 < 8; phi_s3++) { + D_8082A124[phi_s3] = 0xFF; + D_8082A150[phi_s3] = 0; + } + + D_8082A11C = 0; + func_800ED858(1); + func_800ECC04((1 << pauseCtx->unk_264) + 0x8000); + pauseCtx->unk_194 = func_800EE3F8(); + pauseCtx->unk_194->unk_02 = 0; + pauseCtx->unk_194->unk_01 = 0xFF; + VREG(21) = -62; + VREG(22) = -56; + VREG(23) = -49; + VREG(24) = -46; + VREG(25) = -41; + pauseCtx->unk_1E4 = 8; + func_800ED858(0); + } + } + } else if (pauseCtx->unk_1E4 == 5) { + if ((pauseCtx->stickRelX != 0) || (pauseCtx->stickRelY != 0)) { + pauseCtx->unk_1E4 = 0; + func_800ED858(0); + } + } else if (pauseCtx->unk_1E4 == 8) { + if (CHECK_BTN_ALL(input->press.button, BTN_A) && (sp216 >= 6) && (sp216 < 0x12)) { + pauseCtx->unk_1E4 = 9; + D_8082A120 = 10; + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickRelX > 30) { + pauseCtx->cursorPoint[PAUSE_QUEST] = 0x15; + pauseCtx->nameDisplayTimer = 0; + pauseCtx->cursorSpecialPos = 0; + sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; + KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x5A; + } else { + phi_s0_2 = PAUSE_ITEM_NONE; + } + sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = phi_s0_2; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216; + } + } else { + if (pauseCtx->stickRelX < -30) { + pauseCtx->cursorPoint[PAUSE_QUEST] = 0; + pauseCtx->nameDisplayTimer = 0; + pauseCtx->cursorSpecialPos = 0; + sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; + KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + if (pauseCtx->cursorPoint[PAUSE_QUEST] < 6) { + phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x66; + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] < 0xC) { + phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x4E; + } else { + phi_s0_2 = pauseCtx->cursorPoint[PAUSE_QUEST] + 0x69; + } + } else { + phi_s0_2 = PAUSE_ITEM_NONE; + } + sp216 = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = phi_s0_2; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = sp216; + } + } + + } else { + if (pauseCtx->unk_1E4 == 9) { + pauseCtx->cursorColorSet = 8; + D_8082A120--; + + if (D_8082A120 == 0) { + for (phi_s3 = 0; phi_s3 < 8; phi_s3++) { + D_8082A124[phi_s3] = 0xFF; + D_8082A150[phi_s3] = 0; + } + + D_8082A11C = 0; + VREG(21) = -62; + VREG(22) = -56; + VREG(23) = -49; + VREG(24) = -46; + VREG(25) = -41; + phi_s6 = pauseCtx->cursorSlot[PAUSE_QUEST]; + func_800ED858(1); + func_800ED858(1); + pauseCtx->unk_264 = D_80153960[phi_s6]; + func_800ED93C(pauseCtx->unk_264 + 1, 1); + pauseCtx->unk_1E4 = 2; + pauseCtx->unk_194 = func_800EE3F8(); + pauseCtx->unk_194->unk_02 = 0; + sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; + KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 4, pauseCtx->questVtx); + } + } else { + sp216 = pauseCtx->cursorSlot[PAUSE_QUEST]; + KaleidoScope_SetCursorVtx(pauseCtx, sp216 * 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); + + D_8082A0FC--; + + for (sp218 = sp21A = 0; sp218 < 6; sp218++, sp21A += 4) { + if ((D_8082A100 != 1) && (D_8082A100 != 3)) { + phi_v1 = (D_8082A100 != 0) ? sp218 + 6 : sp218; + + if (D_8082A0FC != 0) { + sp226 = ABS(D_8082A0D8[sp218] - D_8082A090[phi_v1][0]) / D_8082A0FC; + sp224 = ABS(D_8082A0E4[sp218] - D_8082A090[phi_v1][1]) / D_8082A0FC; + sp222 = ABS(D_8082A0F0[sp218] - D_8082A090[phi_v1][2]) / D_8082A0FC; + if (D_8082A0D8[sp218] >= D_8082A090[phi_v1][0]) { + D_8082A0D8[sp218] -= sp226; + } else { + D_8082A0D8[sp218] += sp226; + } + if (D_8082A0E4[sp218] >= D_8082A090[phi_v1][1]) { + D_8082A0E4[sp218] -= sp224; + } else { + D_8082A0E4[sp218] += sp224; + } + if (D_8082A0F0[sp218] >= D_8082A090[phi_v1][2]) { + D_8082A0F0[sp218] -= sp222; + } else { + D_8082A0F0[sp218] += sp222; + } + } else { + D_8082A0D8[sp218] = D_8082A090[phi_v1][0]; + D_8082A0E4[sp218] = D_8082A090[phi_v1][1]; + D_8082A0F0[sp218] = D_8082A090[phi_v1][2]; + } + } + + if (CHECK_QUEST_ITEM(sp218)) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, D_8082A0D8[sp218], D_8082A0E4[sp218], D_8082A0F0[sp218], 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + + KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_MEDALLION_FOREST + sp218], 24, 24, 0); + } + } + + if (D_8082A0FC == 0) { + D_8082A0FC = ZREG(61 + D_8082A100); + D_8082A100++; + if (D_8082A100 >= 4) { + D_8082A100 = 0; + } + } + + 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++, gSongNoteTex, 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); + if (1) {} + + for (sp218 = 0; sp218 < 12; sp218++, sp21A += 4) { + if (CHECK_QUEST_ITEM(sp218 + 6)) { + if ((sp218 + 6) == sp216) { + pauseCtx->questVtx[sp21A + 0].v.ob[0] = pauseCtx->questVtx[sp21A + 2].v.ob[0] = + pauseCtx->questVtx[sp21A + 0].v.ob[0] - 2; + + pauseCtx->questVtx[sp21A + 1].v.ob[0] = pauseCtx->questVtx[sp21A + 3].v.ob[0] = + pauseCtx->questVtx[sp21A + 1].v.ob[0] + 4; + + pauseCtx->questVtx[sp21A + 0].v.ob[1] = pauseCtx->questVtx[sp21A + 1].v.ob[1] = + pauseCtx->questVtx[sp21A + 0].v.ob[1] + 2; + + pauseCtx->questVtx[sp21A + 2].v.ob[1] = pauseCtx->questVtx[sp21A + 3].v.ob[1] = + pauseCtx->questVtx[sp21A + 2].v.ob[1] - 4; + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_8082A164[sp218], D_8082A17C[sp218], D_8082A194[sp218], + pauseCtx->alpha); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + for (sp218 = 0; sp218 < 3; sp218++, sp21A += 4) { + if (CHECK_QUEST_ITEM(sp218 + 0x12)) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_KOKIRI_EMERALD + sp218], 24, 24, 0); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + for (sp218 = 0; sp218 < 3; sp218++, sp21A += 4) { + if (CHECK_QUEST_ITEM(sp218 + 0x15)) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gItemIcons[ITEM_STONE_OF_AGONY + sp218], 24, 24, 0); + } + } + + sp226 = ABS(D_8082A104 - D_8082A070[D_8082A118][0]) / D_8082A114; + sp224 = ABS(D_8082A108 - D_8082A070[D_8082A118][1]) / D_8082A114; + sp222 = ABS(D_8082A10C - D_8082A070[D_8082A118][2]) / D_8082A114; + sp220 = ABS(D_8082A110 - D_8082A070[D_8082A118][3]) / D_8082A114; + if (D_8082A104 >= D_8082A070[D_8082A118][0]) { + D_8082A104 -= sp226; + } else { + D_8082A104 += sp226; + } + if (D_8082A108 >= D_8082A070[D_8082A118][1]) { + D_8082A108 -= sp224; + } else { + D_8082A108 += sp224; + } + if (D_8082A10C >= D_8082A070[D_8082A118][2]) { + D_8082A10C -= sp222; + } else { + D_8082A10C += sp222; + } + if (D_8082A110 >= D_8082A070[D_8082A118][3]) { + D_8082A110 -= sp220; + } else { + D_8082A110 += sp220; + } + + D_8082A114--; + if (D_8082A114 == 0) { + D_8082A104 = D_8082A070[D_8082A118][0]; + D_8082A108 = D_8082A070[D_8082A118][1]; + D_8082A10C = D_8082A070[D_8082A118][2]; + D_8082A110 = D_8082A070[D_8082A118][3]; + D_8082A114 = ZREG(24 + D_8082A118); + if (++D_8082A118 >= 4) { + D_8082A118 = 0; + } + } + + if ((gSaveContext.inventory.questItems >> 0x1C) != 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 == 0x12)) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_8082A070[0][0], D_8082A070[0][1], D_8082A070[0][2], + pauseCtx->alpha); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_8082A104, D_8082A108, D_8082A10C, D_8082A110); + } + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8( + POLY_OPA_DISP, gItemIcons[0x79 + (((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> 0x1C)], + 48, 48, 0); + } + + if (pauseCtx->state == 6) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + sp21A += 4; + if ((pauseCtx->cursorSpecialPos == 0) && (sp216 >= 6) && (sp216 < 0x12)) { + if ((pauseCtx->unk_1E4 < 3) || (pauseCtx->unk_1E4 == 5) || (pauseCtx->unk_1E4 == 8)) { + if (pauseCtx->cursorItem[pauseCtx->pageIndex] != PAUSE_ITEM_NONE) { + pauseCtx->cursorColorSet = 8; + if ((pauseCtx->unk_1E4 >= 2) && (pauseCtx->unk_1E4 < 7)) { + pauseCtx->cursorColorSet = 0; + } + } + } + } + + if (pauseCtx->unk_1E4 == 2) { + pauseCtx->unk_194 = func_800EE3F8(); + + if (pauseCtx->unk_194->unk_02 != 0) { + if (D_8082A11C == (pauseCtx->unk_194->unk_02 - 1)) { + D_8082A124[pauseCtx->unk_194->unk_02 - 1] = pauseCtx->unk_194->unk_00; + D_8082A11C++; + } + + for (sp218 = 0; sp218 < 8; sp218++, sp21A += 4) { + if (D_8082A124[sp218] == 0xFF) { + break; + } + + if (D_8082A150[sp218] != 255) { + D_8082A150[sp218] += VREG(50); + if (D_8082A150[sp218] >= 255) { + D_8082A150[sp218] = 255; + } + } + + pauseCtx->questVtx[sp21A + 0].v.ob[1] = pauseCtx->questVtx[sp21A + 1].v.ob[1] = + VREG(21 + D_8082A124[sp218]); + + pauseCtx->questVtx[sp21A + 2].v.ob[1] = pauseCtx->questVtx[sp21A + 3].v.ob[1] = + pauseCtx->questVtx[sp21A + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (D_8082A124[sp218] == 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 255, 150, D_8082A150[sp218]); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, D_8082A150[sp218]); + } + + gDPSetEnvColor(POLY_OPA_DISP++, 10, 10, 10, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + + gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[D_8082A124[sp218]], G_IM_FMT_IA, G_IM_SIZ_8b, 16, + 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); + if (1) {} + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + } + } else if (((pauseCtx->unk_1E4 >= 4) && (pauseCtx->unk_1E4 <= 6)) || (pauseCtx->unk_1E4 == 8)) { + phi_a2 = pauseCtx->unk_264; + + sp226 = D_80131C00[phi_a2][0]; + sp218 = sp21A; + + for (phi_s3 = 0; phi_s3 < sp226; phi_s3++, sp21A += 4) { + pauseCtx->questVtx[sp21A + 0].v.ob[1] = pauseCtx->questVtx[sp21A + 1].v.ob[1] = + VREG(21 + D_80131C00[phi_a2][phi_s3 + 1]); + + pauseCtx->questVtx[sp21A + 2].v.ob[1] = pauseCtx->questVtx[sp21A + 3].v.ob[1] = + pauseCtx->questVtx[sp21A + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (pauseCtx->unk_1E4 == 8) { + if (D_80131C00[phi_a2][phi_s3 + 1] == 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 255, 150, 200); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, 200); + } + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 150, 150, 150, 150); + } + + gDPSetEnvColor(POLY_OPA_DISP++, 10, 10, 10, 0); + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + + gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[D_80131C00[phi_a2][phi_s3 + 1]], G_IM_FMT_IA, + G_IM_SIZ_8b, 16, 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); + if (1) {} + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + + if (pauseCtx->unk_1E4 != 8) { + pauseCtx->unk_194 = func_800EE3D4(); + + if (pauseCtx->unk_194->unk_02 != 0) { + if (D_8082A11C == (pauseCtx->unk_194->unk_02 - 1)) { + if ((pauseCtx->unk_194->unk_00 >= 0) && (pauseCtx->unk_194->unk_00 < 5)) { + D_8082A124[pauseCtx->unk_194->unk_02 - 1] = pauseCtx->unk_194->unk_00; + D_8082A124[pauseCtx->unk_194->unk_02] = 0xFF; + D_8082A11C++; + } + } + } + + for (phi_s3 = 0, sp21A = sp218 + 32; phi_s3 < 8; phi_s3++, sp21A += 4) { + if (D_8082A124[phi_s3] == 0xFF) { + break; + } + + if (D_8082A150[phi_s3] != 255) { + D_8082A150[phi_s3] += VREG(50); + if (D_8082A150[phi_s3] >= 255) { + D_8082A150[phi_s3] = 255; + } + } + pauseCtx->questVtx[sp21A + 0].v.ob[1] = pauseCtx->questVtx[sp21A + 1].v.ob[1] = + VREG(21 + D_8082A124[phi_s3]); + + pauseCtx->questVtx[sp21A + 2].v.ob[1] = pauseCtx->questVtx[sp21A + 3].v.ob[1] = + pauseCtx->questVtx[sp21A + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (D_8082A124[phi_s3] == 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 255, 150, D_8082A150[phi_s3]); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, D_8082A150[phi_s3]); + } + + gDPSetEnvColor(POLY_OPA_DISP++, 10, 10, 10, 0); + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[sp21A], 4, 0); + + gDPLoadTextureBlock(POLY_OPA_DISP++, D_8082A130[D_8082A124[phi_s3]], G_IM_FMT_IA, G_IM_SIZ_8b, 16, + 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); + if (1) {} + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + + if (pauseCtx->unk_1E4 == 4) { + for (phi_s3 = 0; phi_s3 < 8; phi_s3++) { + D_8082A124[phi_s3] = 0xFF; + D_8082A150[phi_s3] = 0; + } + + D_8082A11C = 0; + func_800ED858(1); + func_800ECC04((1 << pauseCtx->unk_264) + 0x8000); + pauseCtx->unk_194 = func_800EE3F8(); + pauseCtx->unk_194->unk_02 = 0; + pauseCtx->unk_194->unk_01 = 0xFE; + pauseCtx->unk_1E4 = 5; + } + } + } + } + + if (CHECK_QUEST_ITEM(QUEST_SKULL_TOKEN)) { + 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); + + sp208[0] = sp208[1] = 0; + sp208[2] = gSaveContext.inventory.gsTokens; + + while (sp208[2] >= 100) { + sp208[0]++; + sp208[2] -= 100; + } + + while (sp208[2] >= 10) { + sp208[1]++; + sp208[2] -= 10; + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[164], 24, 0); + + for (phi_s3 = 0, sp21A = 0; phi_s3 < 2; phi_s3++) { + if (phi_s3 == 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, pauseCtx->alpha); + } else if (gSaveContext.inventory.gsTokens == 100) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 50, 50, pauseCtx->alpha); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + } + + phi_s0 = 0; + for (sp218 = 0; sp218 < 3; sp218++, sp21A += 4) { + if ((sp218 >= 2) || (sp208[sp218] != 0) || (phi_s0 != 0)) { + gDPLoadTextureBlock(POLY_OPA_DISP++, D_02003040[sp208[sp218]], 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); + if (1) {} + + gSP1Quadrangle(POLY_OPA_DISP++, sp21A, sp21A + 2, sp21A + 3, sp21A + 1, 0); + + phi_s0 = 1; + } + } + } + } + + CLOSE_DISPS(gfxCtx, "../z_kaleido_collect.c", 863); +} +#else +static s16 D_8082A070[][4] = { + { 255, 0, 0, 255 }, + { 255, 70, 0, 150 }, + { 255, 70, 0, 150 }, + { 255, 0, 0, 255 }, +}; +static s16 D_8082A090[][3] = { + { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, + { 0, 60, 0 }, { 90, 0, 0 }, { 0, 40, 110 }, { 80, 40, 0 }, { 70, 0, 90 }, { 90, 90, 0 }, +}; +static s16 D_8082A0D8[] = { 255, 255, 255, 255, 255, 255 }; +static s16 D_8082A0E4[] = { 255, 255, 255, 255, 255, 255 }; +static s16 D_8082A0F0[] = { 150, 150, 150, 150, 150, 150 }; +static s16 D_8082A0FC = 20; +static s16 D_8082A100 = 0; +static s16 D_8082A104 = 0; +static s16 D_8082A108 = 0; +static s16 D_8082A10C = 0; +static s16 D_8082A110 = 0; +static s16 D_8082A114 = 20; +static s16 D_8082A118 = 0; +static s16 D_8082A11C = 0; +static s16 D_8082A120 = 0; +static u8 D_8082A124[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +static void* D_8082A130[] = { + gHUDButtonATex, gHUDButtonCDownTex, gHUDButtonCRightTex, gHUDButtonCLeftTex, gHUDButtonCUpTex, +}; +static u16 D_8082A144[] = { + 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, 0xFFCC, +}; +static s16 D_8082A150[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +static s16 D_8082A164[] = { + 150, 255, 100, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; +static s16 D_8082A17C[] = { + 255, 80, 150, 160, 100, 240, 255, 255, 255, 255, 255, 255, +}; +static s16 D_8082A194[] = { + 100, 40, 255, 0, 255, 100, 255, 255, 255, 255, 255, 255, +}; +static s8 D_8082A1AC[][4] = { + { 0x05, 0x01, 0x05, 0xFE }, { 0x00, 0x02, 0x02, 0xFE }, { 0xFF, 0x13, 0x03, 0x01 }, { 0x04, 0x02, 0x11, 0x02 }, + { 0x05, 0x03, 0x18, 0x05 }, { 0xFF, 0xFF, 0x04, 0x00 }, { 0x0C, 0xFF, 0xFD, 0x07 }, { 0x0D, 0xFF, 0x06, 0x08 }, + { 0x0E, 0xFF, 0x07, 0x09 }, { 0x0F, 0xFF, 0x08, 0x0A }, { 0x10, 0xFF, 0x09, 0x0B }, { 0x11, 0xFF, 0x0A, 0x12 }, + { 0x17, 0x06, 0xFD, 0x0D }, { 0x17, 0x07, 0x0C, 0x0E }, { 0x17, 0x08, 0x0D, 0x0F }, { 0x18, 0x09, 0x0E, 0x10 }, + { 0x18, 0x0A, 0x0F, 0x11 }, { 0x18, 0x0B, 0x10, 0x03 }, { 0x02, 0xFF, 0x0B, 0x13 }, { 0x02, 0xFF, 0x12, 0x14 }, + { 0x02, 0xFF, 0x13, 0xFE }, { 0xFF, 0x17, 0xFD, 0x16 }, { 0xFF, 0x17, 0x15, 0x18 }, { 0x15, 0x0C, 0xFD, 0x18 }, + { 0xFF, 0x10, 0x16, 0x04 }, { 0x00, 0x00, 0x00, 0x00 }, +}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/KaleidoScope_DrawQuestStatus.s") +#endif + +s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s32 point) { + pauseCtx->cursorPoint[PAUSE_QUEST] = point; + + return 1; +} diff --git a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_debug.c index 04a2d4d37..23fc35af4 100644 --- a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_debug.c @@ -1,5 +1,647 @@ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80815CE0.s") +#include "z_kaleido_scope.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80815FD4.s") +// Positions of each input section in the editor +static u16 sSectionPositions[][2] = { + { 64, 15 }, { 144, 15 }, { 170, 15 }, { 78, 35 }, { 104, 35 }, { 130, 35 }, { 156, 35 }, { 182, 35 }, + { 208, 35 }, { 78, 50 }, { 104, 50 }, { 130, 50 }, { 156, 50 }, { 182, 50 }, { 208, 50 }, { 78, 65 }, + { 104, 65 }, { 130, 65 }, { 156, 65 }, { 182, 65 }, { 208, 65 }, { 78, 80 }, { 104, 80 }, { 130, 80 }, + { 156, 80 }, { 182, 80 }, { 208, 80 }, { 78, 98 }, { 88, 98 }, { 98, 98 }, { 108, 98 }, { 118, 98 }, + { 128, 98 }, { 138, 98 }, { 148, 98 }, { 158, 98 }, { 168, 98 }, { 178, 98 }, { 188, 98 }, { 198, 98 }, + { 208, 98 }, { 218, 98 }, { 228, 98 }, { 238, 98 }, { 78, 115 }, { 90, 115 }, { 102, 115 }, { 114, 115 }, + { 126, 115 }, { 138, 115 }, { 150, 115 }, { 162, 115 }, { 202, 115 }, { 214, 115 }, { 226, 115 }, { 238, 115 }, + { 78, 132 }, { 90, 132 }, { 102, 132 }, { 114, 132 }, { 126, 132 }, { 138, 132 }, { 150, 132 }, { 162, 132 }, + { 174, 132 }, { 186, 132 }, { 198, 132 }, { 210, 132 }, { 78, 149 }, { 90, 149 }, { 102, 149 }, { 114, 149 }, + { 126, 149 }, { 138, 149 }, { 78, 166 }, { 90, 166 }, { 102, 166 }, { 114, 166 }, { 126, 166 }, { 138, 166 }, + { 150, 166 }, { 162, 166 }, { 174, 166 }, { 186, 166 }, { 198, 166 }, { 210, 166 }, { 210, 149 }, { 222, 149 }, + { 234, 149 }, { 78, 185 }, { 90, 185 }, { 145, 185 }, { 210, 185 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_808161AC.s") +// First section of each row in the editor (starting from the top) +static u16 sRowFirstSections[] = { + 0x00, 0x03, 0x1B, 0x2C, 0x34, 0x38, 0x44, 0x4A, 0x56, 0x59, 0x5C, +}; + +// Maximum value of each upgrade type +static u8 sMaxUpgradeValues[] = { + 3, 3, 3, 2, 2, 3, 3, 3, +}; + +// Item ID corresponding to each slot, aside from bottles and trade items +static s16 sSlotItems[] = { + ITEM_STICK, ITEM_NUT, ITEM_BOMB, ITEM_BOW, ITEM_ARROW_FIRE, ITEM_DINS_FIRE, + ITEM_SLINGSHOT, ITEM_OCARINA_FAIRY, ITEM_BOMBCHU, ITEM_HOOKSHOT, ITEM_ARROW_ICE, ITEM_FARORES_WIND, + ITEM_BOOMERANG, ITEM_LENS, ITEM_BEAN, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NAYRUS_LOVE, +}; + +void KaleidoScope_DrawDebugEditorText(Gfx** gfxp) { + GfxPrint printer; + s32 pad[2]; + + GfxPrint_Init(&printer); + GfxPrint_Open(&printer, *gfxp); + + GfxPrint_SetPos(&printer, 4, 2); + GfxPrint_SetColor(&printer, 255, 60, 0, 255); + GfxPrint_Printf(&printer, "%s", "\x8Cルピー"); // "Rupee" + GfxPrint_SetPos(&printer, 15, 2); + GfxPrint_Printf(&printer, "%s", "\x8Cハート"); // "Heart" + GfxPrint_SetPos(&printer, 26, 3); + GfxPrint_Printf(&printer, "%s", "/4"); + GfxPrint_SetPos(&printer, 4, 5); + GfxPrint_Printf(&printer, "%s", "\x8Cアイテム"); // "Item" + GfxPrint_SetPos(&printer, 4, 13); + GfxPrint_Printf(&printer, "%s", "KEY"); + GfxPrint_SetPos(&printer, 4, 15); + GfxPrint_Printf(&printer, "%s", "\x8Dソウビ"); // "Equipment" + GfxPrint_SetPos(&printer, 23, 14); + GfxPrint_Printf(&printer, "%s", "\x8Cケン"); // "Sword" + GfxPrint_SetPos(&printer, 23, 15); + GfxPrint_Printf(&printer, "%s", "\x8Cタテ"); // "Shield" + GfxPrint_SetPos(&printer, 4, 17); + GfxPrint_Printf(&printer, "%s", "MAP"); + GfxPrint_SetPos(&printer, 4, 19); + GfxPrint_Printf(&printer, "%s", "\x8Dフウイン"); // "Seal" + GfxPrint_SetPos(&printer, 20, 19); + GfxPrint_Printf(&printer, "%s", "\x8Dセイレイセキ"); // "Spiritual Stone" + GfxPrint_SetPos(&printer, 4, 21); + GfxPrint_Printf(&printer, "%s", "\x8Cオカリナ"); // "Ocarina" + GfxPrint_SetPos(&printer, 4, 24); + GfxPrint_Printf(&printer, "%s", "\x8Cコレクト"); // "Collect" + GfxPrint_SetPos(&printer, 14, 24); + GfxPrint_Printf(&printer, "%s", "\x8Cキンスタ"); // "Skulltula" + GfxPrint_SetPos(&printer, 23, 24); + GfxPrint_Printf(&printer, "%s", "\x8Cカケラ"); // "Gold Token" + GfxPrint_SetPos(&printer, 28, 24); + GfxPrint_Printf(&printer, "%s", "/4"); + + *gfxp = GfxPrint_Close(&printer); + GfxPrint_Destroy(&printer); +} + +void KaleidoScope_DrawDigit(GlobalContext* globalCtx, s32 digit, s32 rectLeft, s32 rectTop) { + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_debug.c", 208); + + gDPLoadTextureBlock(POLY_OPA_DISP++, D_02003040[digit], G_IM_FMT_I, G_IM_SIZ_8b, 8, 16, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + gSPTextureRectangle(POLY_OPA_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + 8) << 2, (rectTop + 16) << 2, + G_TX_RENDERTILE, 0, 0, 1024, 1024); + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_debug.c", 220); +} + +void KaleidoScope_DrawDebugEditor(GlobalContext* globalCtx) { + static s16 curSection = 0; + static s16 curRow = 0; + static s32 prevDBtnInput = 0; + static s32 heldDBtnTimer = 0; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + Input* input = &globalCtx->state.input[0]; + Gfx* gfx; + Gfx* gfxRef; + s16 spD8[4]; + s16 slot; + s16 i; + s16 j; + s16 x; + s16 y; + s32 dBtnInput = input->cur.button & (BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT); + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_debug.c", 402); + + pauseCtx->stickRelX = input->rel.stick_x; + pauseCtx->stickRelY = input->rel.stick_y; + + func_800944C4(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 220); + gDPFillRectangle(POLY_OPA_DISP++, 24, 12, 298, 228); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + + gfxRef = POLY_OPA_DISP; + gfx = Graph_GfxPlusOne(gfxRef); + gSPDisplayList(OVERLAY_DISP++, gfx); + + KaleidoScope_DrawDebugEditorText(&gfx); + + gSPEndDisplayList(gfx++); + Graph_BranchDlist(gfxRef, gfx); + POLY_OPA_DISP = gfx; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + // Current Health Quarter (X / 4) + KaleidoScope_DrawDigit(globalCtx, (gSaveContext.health % 0x10) / 4, 194, 15); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + // Rupees + spD8[0] = spD8[1] = spD8[2] = 0; + spD8[3] = gSaveContext.rupees; + while (spD8[3] >= 1000) { + spD8[0]++; + spD8[3] -= 1000; + } + + while (spD8[3] >= 100) { + spD8[1]++; + spD8[3] -= 100; + } + + while (spD8[3] >= 10) { + spD8[2]++; + spD8[3] -= 10; + } + + for (i = 0, x = 68; i < 4; i++, x += 10) { + KaleidoScope_DrawDigit(globalCtx, spD8[i], x, 15); + } + + // Health capacity + spD8[2] = 0; + spD8[3] = gSaveContext.healthCapacity / 0x10; + while (spD8[3] >= 10) { + spD8[2]++; + spD8[3] -= 10; + } + + KaleidoScope_DrawDigit(globalCtx, spD8[2], 146, 15); + KaleidoScope_DrawDigit(globalCtx, spD8[3], 156, 15); + + // Health + spD8[2] = 0; + spD8[3] = gSaveContext.health / 0x10; + while (spD8[3] >= 10) { + spD8[2]++; + spD8[3] -= 10; + } + + KaleidoScope_DrawDigit(globalCtx, spD8[2], 172, 15); + KaleidoScope_DrawDigit(globalCtx, spD8[3], 182, 15); + + // Inventory + for (slot = 0, i = 0, y = 35; i < 4; i++, y += 15) { + for (j = 0, x = 78; j < 6; j++, slot++, x += 26) { + spD8[2] = 0; + + if ((slot <= SLOT_BOW) || (slot == SLOT_SLINGSHOT) || (slot == SLOT_BOMBCHU) || (slot == SLOT_BEAN)) { + spD8[3] = AMMO(gAmmoItems[slot]); + } else if (slot == SLOT_OCARINA) { + spD8[3] = gSaveContext.inventory.items[slot]; + } else { + spD8[3] = gSaveContext.inventory.items[slot]; + } + + if (spD8[3] != ITEM_NONE) { + while (spD8[3] >= 10) { + spD8[2]++; + spD8[3] -= 10; + } + } else { + spD8[2] = spD8[3] = 0; + } + + KaleidoScope_DrawDigit(globalCtx, spD8[2], x, y); + KaleidoScope_DrawDigit(globalCtx, spD8[3], x + 10, y); + } + } + + // Keys + for (spD8[1] = 78, i = 0; i < 17; i++) { + spD8[2] = 0; + + if ((spD8[3] = gSaveContext.inventory.dungeonKeys[i]) >= 0) { + while (spD8[3] >= 10) { + spD8[2]++; + spD8[3] -= 10; + } + } else { + spD8[2] = spD8[3] = 0; + } + + KaleidoScope_DrawDigit(globalCtx, spD8[3], spD8[1], 98); + spD8[1] += 10; + } + + // Upgrades + for (spD8[1] = 78, i = 0; i < 8; i++, spD8[1] += 12) { + KaleidoScope_DrawDigit(globalCtx, CUR_UPG_VALUE(i), spD8[1], 115); + } + + // Equipment + for (spD8[1] = 202, i = 0; i < 4; i++, spD8[1] += 12) { + KaleidoScope_DrawDigit(globalCtx, ALL_EQUIP_VALUE(i), spD8[1], 115); + } + + // Dungeon Items + for (spD8[1] = 78, i = 0; i < 12; i++, spD8[1] += 12) { + spD8[2] = gSaveContext.inventory.dungeonItems[i] & gEquipMasks[0]; + KaleidoScope_DrawDigit(globalCtx, spD8[2], spD8[1], 132); + } + + // Medallions + for (spD8[1] = 78, i = 0; i < 6; i++, spD8[1] += 12) { + spD8[2] = 0; + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST + i)) { + spD8[2] = 1; + } + KaleidoScope_DrawDigit(globalCtx, spD8[2], spD8[1], 149); + } + + // Spiritual Stones + for (spD8[1] = 210, i = 0; i < 3; i++, spD8[1] += 12) { + spD8[2] = 0; + if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD + i)) { + spD8[2] = 1; + } + KaleidoScope_DrawDigit(globalCtx, spD8[2], spD8[1], 149); + } + + // Songs + for (spD8[1] = 78, i = 0; i < 12; i++, spD8[1] += 12) { + spD8[2] = 0; + if (CHECK_QUEST_ITEM(QUEST_SONG_MINUET + i)) { + spD8[2] = 1; + } + KaleidoScope_DrawDigit(globalCtx, spD8[2], spD8[1], 166); + } + + // Other Quest Items + for (spD8[1] = 78, i = 0; i < 2; i++, spD8[1] += 12) { + spD8[2] = 0; + if (CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY + i)) { + spD8[2] = 1; + } + KaleidoScope_DrawDigit(globalCtx, spD8[2], spD8[1], 185); + } + + // GS Tokens + spD8[3] = gSaveContext.inventory.gsTokens; + spD8[1] = 0; + spD8[2] = 0; + while (spD8[3] >= 100) { + spD8[1]++; + spD8[3] -= 100; + } + + while (spD8[3] >= 10) { + spD8[2]++; + spD8[3] -= 10; + } + + KaleidoScope_DrawDigit(globalCtx, spD8[1], 145, 185); + KaleidoScope_DrawDigit(globalCtx, spD8[2], 155, 185); + KaleidoScope_DrawDigit(globalCtx, spD8[3], 165, 185); + + // Heart Pieces (X / 4) + KaleidoScope_DrawDigit(globalCtx, ((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> 0x1C, 210, + 185); + + // Handles navigating the menu to different sections with the D-Pad + // When the same direction is held, registers the input periodically based on a timer + if (dBtnInput == prevDBtnInput) { + heldDBtnTimer--; + if (heldDBtnTimer < 0) { + heldDBtnTimer = 1; + } else { + dBtnInput ^= prevDBtnInput; + } + } else { + prevDBtnInput = dBtnInput; + heldDBtnTimer = 16; + } + + if (dBtnInput & BTN_DDOWN) { + if ((u32)++curRow > 10) { + curRow = 0; + } + curSection = sRowFirstSections[curRow]; + } else if (dBtnInput & BTN_DUP) { + if (--curRow < 0) { + curRow = 22; + } + curSection = sRowFirstSections[curRow]; + } else if (dBtnInput & BTN_DLEFT) { + if (--curSection < 0) { + curSection = 0x5C; + } + } else if (dBtnInput & BTN_DRIGHT) { + if (++curSection > 0x5C) { + curSection = 0; + } + } + + // Handles the logic to change values based on the selected section + switch (curSection) { + case 0: + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + gSaveContext.rupees -= 100; + if (gSaveContext.rupees < 0) { + gSaveContext.rupees = 0; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + gSaveContext.rupees += 100; + if (gSaveContext.rupees >= 9999) { + gSaveContext.rupees = 9999; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.rupees--; + if (gSaveContext.rupees < 0) { + gSaveContext.rupees = 0; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.rupees++; + if (gSaveContext.rupees >= 9999) { + gSaveContext.rupees = 9999; + } + } + break; + + case 1: + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.healthCapacity -= 0x10; + if (gSaveContext.healthCapacity < 0x30) { + gSaveContext.healthCapacity = 0x30; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.healthCapacity += 0x10; + if (gSaveContext.healthCapacity >= 0x140) { + gSaveContext.healthCapacity = 0x140; + } + } + break; + + case 2: + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + Health_ChangeBy(globalCtx, -4); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + Health_ChangeBy(globalCtx, 4); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Health_ChangeBy(globalCtx, -0x10); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + Health_ChangeBy(globalCtx, 0x10); + } + break; + + case 0x5C: + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if ((((gSaveContext.inventory.questItems & 0xF0000000) & 0xF0000000) >> 0x1C) != 0) { + gSaveContext.inventory.questItems -= 0x10000000; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if ((gSaveContext.inventory.questItems & 0xF0000000) <= 0x40000000) { + gSaveContext.inventory.questItems += 0x10000000; + } + } + break; + + default: + if (curSection < 0x1B) { + i = curSection - 3; + if ((i <= SLOT_BOW) || (i == SLOT_SLINGSHOT) || (i == SLOT_BOMBCHU) || (i == SLOT_BEAN)) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Inventory_DeleteItem(gAmmoItems[i], SLOT(gAmmoItems[i])); + AMMO(gAmmoItems[i]) = 0; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (i != gSaveContext.inventory.items[SLOT(gAmmoItems[i])]) { + gSaveContext.inventory.items[SLOT(gAmmoItems[i])] = gAmmoItems[i]; + } + gSaveContext.inventory.ammo[SLOT(gAmmoItems[i])]++; + if (gSaveContext.inventory.ammo[SLOT(gAmmoItems[i])] > 99) { + gSaveContext.inventory.ammo[SLOT(gAmmoItems[i])] = 99; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.inventory.ammo[SLOT(gAmmoItems[i])]--; + if (gSaveContext.inventory.ammo[SLOT(gAmmoItems[i])] < 0) { + gSaveContext.inventory.ammo[SLOT(gAmmoItems[i])] = 0; + } + } + } else if (i == SLOT_OCARINA) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Inventory_DeleteItem(ITEM_OCARINA_FAIRY, SLOT(ITEM_OCARINA_FAIRY)); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_OCARINA_FAIRY; + } else if ((gSaveContext.inventory.items[i] >= ITEM_OCARINA_FAIRY) && + (gSaveContext.inventory.items[i] < ITEM_OCARINA_TIME)) { + gSaveContext.inventory.items[i]++; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_OCARINA_TIME; + } else if ((gSaveContext.inventory.items[i] > ITEM_OCARINA_FAIRY) && + (gSaveContext.inventory.items[i] <= ITEM_OCARINA_TIME)) { + gSaveContext.inventory.items[i]--; + } + } + } else if (i == SLOT_HOOKSHOT) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Inventory_DeleteItem(ITEM_HOOKSHOT, SLOT(ITEM_HOOKSHOT)); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_HOOKSHOT; + } else if ((gSaveContext.inventory.items[i] >= ITEM_HOOKSHOT) && + (gSaveContext.inventory.items[i] < ITEM_LONGSHOT)) { + gSaveContext.inventory.items[i]++; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_LONGSHOT; + } else if ((gSaveContext.inventory.items[i] > ITEM_HOOKSHOT) && + (gSaveContext.inventory.items[i] <= ITEM_LONGSHOT)) { + gSaveContext.inventory.items[i]--; + } + } + } else if (i == SLOT_TRADE_ADULT) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Inventory_DeleteItem(ITEM_POCKET_EGG, SLOT(ITEM_POCKET_EGG)); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_POCKET_EGG; + } else if ((gSaveContext.inventory.items[i] >= ITEM_POCKET_EGG) && + (gSaveContext.inventory.items[i] < ITEM_CLAIM_CHECK)) { + gSaveContext.inventory.items[i]++; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_CLAIM_CHECK; + } else if ((gSaveContext.inventory.items[i] > ITEM_POCKET_EGG) && + (gSaveContext.inventory.items[i] <= ITEM_CLAIM_CHECK)) { + gSaveContext.inventory.items[i]--; + } + } + } else if (i == SLOT_TRADE_CHILD) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Inventory_DeleteItem(ITEM_WEIRD_EGG, SLOT(ITEM_WEIRD_EGG)); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_WEIRD_EGG; + } else if ((gSaveContext.inventory.items[i] >= ITEM_WEIRD_EGG) && + (gSaveContext.inventory.items[i] < ITEM_SOLD_OUT)) { + gSaveContext.inventory.items[i]++; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_SOLD_OUT; + } else if ((gSaveContext.inventory.items[i] > ITEM_WEIRD_EGG) && + (gSaveContext.inventory.items[i] <= ITEM_SOLD_OUT)) { + gSaveContext.inventory.items[i]--; + } + } + } else if ((i >= SLOT_BOTTLE_1) && (i <= SLOT_BOTTLE_4)) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + Inventory_DeleteItem(ITEM_BOTTLE + i - SLOT_BOTTLE_1, SLOT(ITEM_BOTTLE) + i - SLOT_BOTTLE_1); + } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_BOTTLE; + } else if ((gSaveContext.inventory.items[i] >= ITEM_BOTTLE) && + (gSaveContext.inventory.items[i] <= ITEM_MILK_HALF)) { + gSaveContext.inventory.items[i]++; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_POE; + } else if ((gSaveContext.inventory.items[i] >= ITEM_POTION_RED) && + (gSaveContext.inventory.items[i] <= ITEM_POE)) { + gSaveContext.inventory.items[i]--; + } + } + } else if (i < 0x1B) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (i == SLOT_TRADE_ADULT) { + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = ITEM_BEAN; + } else { + Inventory_DeleteItem(ITEM_BEAN, SLOT(ITEM_BEAN)); + } + } else { + j = sSlotItems[i]; + osSyncPrintf("i=%d j=%d\n", i, j); + if (gSaveContext.inventory.items[i] == ITEM_NONE) { + gSaveContext.inventory.items[i] = j; + } else { + Inventory_DeleteItem(j, i); + } + } + } + } + } else if (curSection < 0x2C) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + i = curSection - 0x1B; + gSaveContext.inventory.dungeonKeys[i]--; + if (gSaveContext.inventory.dungeonKeys[i] < 0) { + gSaveContext.inventory.dungeonKeys[i] = -1; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + i = curSection - 0x1B; + if (gSaveContext.inventory.dungeonKeys[i] < 0) { + gSaveContext.inventory.dungeonKeys[i] = 1; + } else { + gSaveContext.inventory.dungeonKeys[i]++; + if (gSaveContext.inventory.dungeonKeys[i] >= 9) { + gSaveContext.inventory.dungeonKeys[i] = 9; + } + } + } + } else { + if (curSection < 0x38) { + i = curSection - 0x2C; + if ((curSection >= 0x2C) && (curSection < 0x34)) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || + CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (CUR_UPG_VALUE(i) != 0) { + Inventory_ChangeUpgrade(i, CUR_UPG_VALUE(i) - 1); + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (CUR_UPG_VALUE(i) < sMaxUpgradeValues[i]) { + Inventory_ChangeUpgrade(i, CUR_UPG_VALUE(i) + 1); + } + } + } else { + i = curSection - 0x34; + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.inventory.equipment ^= (1 << gEquipShifts[i]); + } + if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + gSaveContext.inventory.equipment ^= (2 << gEquipShifts[i]); + } + if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.inventory.equipment ^= (4 << gEquipShifts[i]); + } + if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + gSaveContext.inventory.equipment ^= (8 << gEquipShifts[i]); + } + } + } else if (curSection < 0x44) { + i = curSection - 0x38; + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.inventory.dungeonItems[i] ^= 4; + } + if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + gSaveContext.inventory.dungeonItems[i] ^= 2; + } + if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.inventory.dungeonItems[i] ^= 1; + } + } else if (curSection == 0x5B) { + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.inventory.gsTokens++; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + gSaveContext.inventory.gsTokens--; + if (gSaveContext.inventory.gsTokens <= 0) { + gSaveContext.inventory.gsTokens = 0; + } + } + } else if (curSection < 0x5C) { + i = curSection - 0x44; + if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + gSaveContext.inventory.questItems ^= gBitFlags[i]; + } + } + } + break; + } + + // Draws a highlight on the selected section + gDPPipeSync(POLY_OPA_DISP++); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 200, 120); + + if (curSection == 0) { + gDPFillRectangle(POLY_OPA_DISP++, sSectionPositions[curSection][0], sSectionPositions[curSection][1], + sSectionPositions[curSection][0] + 45, sSectionPositions[curSection][1] + 16); + } else if ((curSection >= 0x1B) || (curSection == 0x5B)) { + gDPFillRectangle(POLY_OPA_DISP++, sSectionPositions[curSection][0] - 2, sSectionPositions[curSection][1], + sSectionPositions[curSection][0] + 14, sSectionPositions[curSection][1] + 16); + } else { + gDPFillRectangle(POLY_OPA_DISP++, sSectionPositions[curSection][0] - 4, sSectionPositions[curSection][1], + sSectionPositions[curSection][0] + 24, sSectionPositions[curSection][1] + 16); + } + + // Handles exiting the inventory editor with the L button + // The editor is opened with `debugState` set to 1, and becomes closable after a frame once `debugState` is set to 2 + if (pauseCtx->debugState == 1) { + pauseCtx->debugState = 2; + } else if ((pauseCtx->debugState == 2) && CHECK_BTN_ALL(input->press.button, BTN_L)) { + pauseCtx->debugState = 0; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_debug.c", 861); +} diff --git a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_equipment.c b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_equipment.c index db33f335d..b43922a46 100644 --- a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_equipment.c @@ -1,6 +1,595 @@ +#include "z_kaleido_scope.h" +#include "textures/icon_item_static/icon_item_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80817D50.s") +static u8 sChildUpgrades[] = { UPG_BULLET_BAG, UPG_BOMB_BAG, UPG_STRENGTH, UPG_SCALE }; +static u8 sAdultUpgrades[] = { UPG_QUIVER, UPG_BOMB_BAG, UPG_STRENGTH, UPG_SCALE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081819C.s") +static u8 sChildUpgradeItemBases[] = { ITEM_BULLET_BAG_30, ITEM_BOMB_BAG_20, ITEM_BRACELET, ITEM_SCALE_SILVER }; +static u8 sAdultUpgradeItemBases[] = { ITEM_QUIVER_30, ITEM_BOMB_BAG_20, ITEM_BRACELET, ITEM_SCALE_SILVER }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80818340.s") +static u8 sUpgradeItemOffsets[] = { 0x00, 0x03, 0x06, 0x09 }; + +static u8 sEquipmentItemOffsets[] = { + 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0x04, 0x05, 0x00, 0x06, 0x07, 0x08, 0x00, 0x09, 0x0A, 0x0B, +}; + +static s16 sEquipTimer = 0; + +void KaleidoScope_DrawEquipmentImage(GlobalContext* globalCtx, void* source, u32 width, u32 height) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + u8* curTexture; + s32 vtxIndex; + s32 textureCount; + s32 textureHeight; + s32 remainingSize; + s32 textureSize; + s32 pad; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_equipment.c", 68); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + curTexture = source; + remainingSize = width * height * 2; + textureHeight = 4096 / (width * 2); + textureSize = width * textureHeight * 2; + textureCount = remainingSize / textureSize; + if ((remainingSize % textureSize) != 0) { + textureCount += 1; + } + + vtxIndex = 80; + + gDPSetTileCustom(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, textureHeight, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + remainingSize -= textureSize; + + for (i = 0; i < textureCount; i++) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->equipVtx[vtxIndex], 4, 0); + + gDPSetTextureImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, curTexture); + + gDPLoadSync(POLY_OPA_DISP++); + gDPLoadTile(POLY_OPA_DISP++, G_TX_LOADTILE, 0, 0, (width - 1) << 2, (textureHeight - 1) << 2); + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + curTexture += textureSize; + + if ((remainingSize - textureSize) < 0) { + if (remainingSize > 0) { + textureHeight = remainingSize / (s32)(width * 2); + remainingSize -= textureSize; + + gDPSetTileCustom(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, textureHeight, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + } + } else { + remainingSize -= textureSize; + } + + vtxIndex += 4; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_equipment.c", 122); +} + +void KaleidoScope_DrawPlayerWork(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + Vec3f pos; + Vec3s rot; + f32 scale; + + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + pos.x = 2.0f; + pos.y = -130.0f; + pos.z = -150.0f; + scale = 0.046f; + } else if (CUR_EQUIP_VALUE(EQUIP_SWORD) != 2) { + pos.x = 25.0f; + pos.y = -228.0f; + pos.z = 60.0f; + scale = 0.056f; + } else { + pos.x = 20.0f; + pos.y = -180.0f; + pos.z = -40.0f; + scale = 0.047f; + } + + rot.y = 32300; + rot.x = rot.z = 0; + func_8009214C(globalCtx, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime, &pos, &rot, scale, + CUR_EQUIP_VALUE(EQUIP_SWORD), CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1, CUR_EQUIP_VALUE(EQUIP_SHIELD), + CUR_EQUIP_VALUE(EQUIP_BOOTS) - 1); +} + +void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + Input* input = &globalCtx->state.input[0]; + u16 i; + u16 j; + u16 k; + u16 bit; + u16 temp; + u16 point; + u16 rowStart; + u16 pad; + s16 cursorMoveResult; + u16 cursorItem; + u16 cursorSlot; + s16 cursorPoint; + s16 cursorX; + s16 cursorY; + volatile s16 oldCursorPoint; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_equipment.c", 219); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, ZREG(39), ZREG(40), ZREG(41), pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, ZREG(43), ZREG(44), ZREG(45), 0); + + for (i = 0, j = 64; i < 4; i++, j += 4) { + if (CUR_EQUIP_VALUE(i) != 0) { + gDPPipeSync(POLY_OPA_DISP++); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->equipVtx[j], 4, 0); + + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, D_02000A00[1], 32, 32, 0); + } + } + + if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_EQUIP]; + pauseCtx->cursorColorSet = 0; + + if (pauseCtx->cursorSpecialPos == 0) { + pauseCtx->nameColorSet = 0; + + cursorItem = pauseCtx->cursorItem[PAUSE_EQUIP]; + if ((cursorItem >= ITEM_SWORD_KOKIRI) && (cursorItem <= ITEM_BOOTS_HOVER)) { + pauseCtx->cursorColorSet = 8; + } + + cursorPoint = pauseCtx->cursorPoint[PAUSE_EQUIP]; + cursorX = pauseCtx->cursorX[PAUSE_EQUIP]; + cursorY = pauseCtx->cursorY[PAUSE_EQUIP]; + + cursorMoveResult = 0; + while (cursorMoveResult == 0) { + if (pauseCtx->stickRelX < -30) { + if (pauseCtx->cursorX[PAUSE_EQUIP] != 0) { + pauseCtx->cursorX[PAUSE_EQUIP] -= 1; + pauseCtx->cursorPoint[PAUSE_EQUIP] -= 1; + + if (pauseCtx->cursorX[PAUSE_EQUIP] == 0) { + if (pauseCtx->cursorY[PAUSE_EQUIP] == 0) { + if (CUR_UPG_VALUE(UPG_BULLET_BAG) != 0) { + cursorMoveResult = 1; + } + } else { + if (CUR_UPG_VALUE(pauseCtx->cursorY[PAUSE_EQUIP]) != 0) { + cursorMoveResult = 1; + } + } + } else { + if (gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & gSaveContext.inventory.equipment) { + cursorMoveResult = 2; + } + } + } else { + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorY[PAUSE_EQUIP] += 1; + + if (pauseCtx->cursorY[PAUSE_EQUIP] >= 4) { + pauseCtx->cursorY[PAUSE_EQUIP] = 0; + } + + pauseCtx->cursorPoint[PAUSE_EQUIP] = + pauseCtx->cursorX[PAUSE_EQUIP] + (pauseCtx->cursorY[PAUSE_EQUIP] * 4); + + if (pauseCtx->cursorPoint[PAUSE_EQUIP] >= 16) { + pauseCtx->cursorPoint[PAUSE_EQUIP] = pauseCtx->cursorX[PAUSE_EQUIP]; + } + + if (cursorY == pauseCtx->cursorY[PAUSE_EQUIP]) { + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); + cursorMoveResult = 3; + } + } + } else if (pauseCtx->stickRelX > 30) { + if (pauseCtx->cursorX[PAUSE_EQUIP] < 3) { + pauseCtx->cursorX[PAUSE_EQUIP] += 1; + pauseCtx->cursorPoint[PAUSE_EQUIP] += 1; + + if (pauseCtx->cursorX[PAUSE_EQUIP] == 0) { + if (CUR_UPG_VALUE(pauseCtx->cursorY[PAUSE_EQUIP]) != 0) { + cursorMoveResult = 1; + } + } else { + if (gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & gSaveContext.inventory.equipment) { + cursorMoveResult = 2; + } + } + } else { + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorY[PAUSE_EQUIP] += 1; + + if (pauseCtx->cursorY[PAUSE_EQUIP] >= 4) { + pauseCtx->cursorY[PAUSE_EQUIP] = 0; + } + + pauseCtx->cursorPoint[PAUSE_EQUIP] = + pauseCtx->cursorX[PAUSE_EQUIP] + (pauseCtx->cursorY[PAUSE_EQUIP] * 4); + + if (pauseCtx->cursorPoint[PAUSE_EQUIP] >= 16) { + pauseCtx->cursorPoint[PAUSE_EQUIP] = pauseCtx->cursorX[PAUSE_EQUIP]; + } + + if (cursorY == pauseCtx->cursorY[PAUSE_EQUIP]) { + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); + cursorMoveResult = 3; + } + } + } else { + cursorMoveResult = 4; + } + } + + cursorPoint = pauseCtx->cursorPoint[PAUSE_EQUIP]; + cursorY = pauseCtx->cursorY[PAUSE_EQUIP]; + + if (cursorMoveResult) {} + + cursorMoveResult = 0; + while (cursorMoveResult == 0) { + if (pauseCtx->stickRelY > 30) { + if (pauseCtx->cursorY[PAUSE_EQUIP] != 0) { + pauseCtx->cursorY[PAUSE_EQUIP] -= 1; + pauseCtx->cursorPoint[PAUSE_EQUIP] -= 4; + + if (pauseCtx->cursorX[PAUSE_EQUIP] == 0) { + if (pauseCtx->cursorY[PAUSE_EQUIP] == 0) { + if (CUR_UPG_VALUE(UPG_BULLET_BAG) != 0) { + cursorMoveResult = 1; + } + } else if (CUR_UPG_VALUE(pauseCtx->cursorY[PAUSE_EQUIP]) != 0) { + cursorMoveResult = 1; + } + } else if (gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & + gSaveContext.inventory.equipment) { + cursorMoveResult = 2; + } + } else { + pauseCtx->cursorY[PAUSE_EQUIP] = cursorY; + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + cursorMoveResult = 3; + } + } else if (pauseCtx->stickRelY < -30) { + if (pauseCtx->cursorY[PAUSE_EQUIP] < 3) { + pauseCtx->cursorY[PAUSE_EQUIP] += 1; + pauseCtx->cursorPoint[PAUSE_EQUIP] += 4; + + if (pauseCtx->cursorX[PAUSE_EQUIP] == 0) { + if (CUR_UPG_VALUE(pauseCtx->cursorY[PAUSE_EQUIP]) != 0) { + cursorMoveResult = 1; + } + } else if (gBitFlags[pauseCtx->cursorPoint[PAUSE_EQUIP] - 1] & + gSaveContext.inventory.equipment) { + cursorMoveResult = 2; + } + } else { + pauseCtx->cursorY[PAUSE_EQUIP] = cursorY; + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + cursorMoveResult = 3; + } + } else { + cursorMoveResult = 4; + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickRelX > 30) { + pauseCtx->nameDisplayTimer = 0; + pauseCtx->cursorSpecialPos = 0; + + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + + cursorPoint = cursorX = cursorY = 0; + while (true) { + if (cursorX == 0) { + if (cursorY == 0) { + if (CUR_UPG_VALUE(UPG_BULLET_BAG) != 0) { + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorY[PAUSE_EQUIP] = cursorY; + break; + } + } else if (CUR_UPG_VALUE(cursorY) != 0) { + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorY[PAUSE_EQUIP] = cursorY; + break; + } + } else if (gBitFlags[cursorPoint - 1] & gSaveContext.inventory.equipment) { + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorY[PAUSE_EQUIP] = cursorY; + break; + } + + cursorY = cursorY + 1; + cursorPoint = cursorPoint + 4; + if (cursorY < 4) { + continue; + } + + cursorY = 0; + cursorPoint = cursorX + 1; + cursorX = cursorPoint; + if (cursorX < 4) { + continue; + } + + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } + } else { + if (pauseCtx->stickRelX < -30) { + pauseCtx->nameDisplayTimer = 0; + pauseCtx->cursorSpecialPos = 0; + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + + cursorPoint = cursorX = 3; + cursorY = 0; + while (true) { + if (cursorX == 0) { + if (CUR_UPG_VALUE(cursorY) != 0) { + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorY[PAUSE_EQUIP] = cursorY; + break; + } + } else if (gBitFlags[cursorPoint - 1] & gSaveContext.inventory.equipment) { + pauseCtx->cursorPoint[PAUSE_EQUIP] = cursorPoint; + pauseCtx->cursorX[PAUSE_EQUIP] = cursorX; + pauseCtx->cursorY[PAUSE_EQUIP] = cursorY; + break; + } + + cursorY = cursorY + 1; + cursorPoint = cursorPoint + 4; + if (cursorY < 4) { + continue; + } + + cursorY = 0; + cursorPoint = cursorX - 1; + cursorX = cursorPoint; + if (cursorX >= 0) { + continue; + } + + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } + } + + if (pauseCtx->cursorX[PAUSE_EQUIP] == 0) { + pauseCtx->cursorColorSet = 0; + + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + if ((pauseCtx->cursorY[PAUSE_EQUIP] == 0) && (CUR_UPG_VALUE(UPG_BULLET_BAG) != 0)) { + cursorItem = ITEM_BULLET_BAG_30 + CUR_UPG_VALUE(UPG_BULLET_BAG) - 1; + } else { + cursorItem = ITEM_QUIVER_30 + sUpgradeItemOffsets[pauseCtx->cursorY[PAUSE_EQUIP]] + + CUR_UPG_VALUE(pauseCtx->cursorY[PAUSE_EQUIP]) - 1; + osSyncPrintf("H_arrowcase_1 + non_equip_item_table = %d\n", cursorItem); + } + } else { + if ((pauseCtx->cursorY[PAUSE_EQUIP] == 0) && (CUR_UPG_VALUE(UPG_QUIVER) == 0)) { + cursorItem = ITEM_BULLET_BAG_30 + CUR_UPG_VALUE(UPG_BULLET_BAG) - 1; + } else { + cursorItem = ITEM_QUIVER_30 + sUpgradeItemOffsets[pauseCtx->cursorY[PAUSE_EQUIP]] + + CUR_UPG_VALUE(pauseCtx->cursorY[PAUSE_EQUIP]) - 1; + osSyncPrintf("大人 H_arrowcase_1 + non_equip_item_table = %d\n", cursorItem); + } + } + } else { + cursorItem = ITEM_SWORD_KOKIRI + sEquipmentItemOffsets[pauseCtx->cursorPoint[PAUSE_EQUIP]]; + osSyncPrintf("ccc=%d\n", cursorItem); + + if (pauseCtx->cursorSpecialPos == 0) { + pauseCtx->cursorColorSet = 8; + } + } + + if ((pauseCtx->cursorY[PAUSE_EQUIP] == 0) && (pauseCtx->cursorX[PAUSE_EQUIP] == 3)) { + if (gSaveContext.bgsFlag != 0) { + cursorItem = ITEM_HEART_PIECE_2; + } else if (gBitFlags[3] & gSaveContext.inventory.equipment) { + cursorItem = ITEM_SWORD_KNIFE; + } + } + + cursorSlot = pauseCtx->cursorPoint[PAUSE_EQUIP]; + + pauseCtx->cursorItem[PAUSE_EQUIP] = cursorItem; + pauseCtx->cursorSlot[PAUSE_EQUIP] = cursorSlot; + + osSyncPrintf("kscope->select_name[Display_Equipment] = %d\n", pauseCtx->cursorItem[PAUSE_EQUIP]); + + if (!((gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == 9) || + (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == + ((void)0, gSaveContext.linkAge)))) { + pauseCtx->nameColorSet = 1; + } + + if (pauseCtx->cursorItem[PAUSE_EQUIP] == ITEM_BRACELET) { + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + pauseCtx->nameColorSet = 0; + } else { + pauseCtx->nameColorSet = 1; + } + } + + if ((pauseCtx->cursorX[PAUSE_EQUIP] == 0) && (pauseCtx->cursorY[PAUSE_EQUIP] == 0)) { + if (LINK_AGE_IN_YEARS != YEARS_CHILD) { + if ((cursorItem >= ITEM_BULLET_BAG_30) && (cursorItem <= ITEM_BULLET_BAG_50)) { + pauseCtx->nameColorSet = 1; + } else { + pauseCtx->nameColorSet = 0; + } + } else { + pauseCtx->nameColorSet = 0; + } + } + + KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->equipVtx); + + if ((pauseCtx->cursorSpecialPos == 0) && (cursorItem != PAUSE_ITEM_NONE) && (pauseCtx->state == 6) && + (pauseCtx->unk_1E4 == 0) && CHECK_BTN_ALL(input->press.button, BTN_A) && + (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { + + if ((gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == 9) || + (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == + ((void)0, gSaveContext.linkAge))) { + Inventory_ChangeEquipment(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP]); + + if (pauseCtx->cursorY[PAUSE_EQUIP] == 0) { + gSaveContext.infTable[29] = 0; + gSaveContext.equips.buttonItems[0] = cursorItem; + + if ((pauseCtx->cursorX[PAUSE_EQUIP] == 3) && (gSaveContext.bgsFlag != 0)) { + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; + gSaveContext.swordHealth = 8; + } else { + if (gSaveContext.equips.buttonItems[0] == ITEM_HEART_PIECE_2) { + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; + } + if ((gSaveContext.equips.buttonItems[0] == ITEM_SWORD_BGS) && (gSaveContext.bgsFlag == 0) && + (gBitFlags[3] & gSaveContext.inventory.equipment)) { + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KNIFE; + } + } + + Interface_LoadItemIcon1(globalCtx, 0); + } + + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pauseCtx->unk_1E4 = 7; + sEquipTimer = 10; + } else { + Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_EQUIP]) { + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } else if ((pauseCtx->unk_1E4 == 7) && (pauseCtx->pageIndex == PAUSE_EQUIP)) { + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_EQUIP] * 4, pauseCtx->equipVtx); + pauseCtx->cursorColorSet = 8; + + sEquipTimer--; + if (sEquipTimer == 0) { + pauseCtx->unk_1E4 = 0; + } + } + + for (rowStart = 0, i = 0, point = 4; i < 4; i++, rowStart += 4, point += 16) { + + for (k = 0, temp = rowStart + 1, bit = rowStart, j = point; k < 3; k++, bit++, j += 4, temp++) { + + if ((gBitFlags[bit] & gSaveContext.inventory.equipment) && (pauseCtx->cursorSpecialPos == 0)) { + if ((gEquipAgeReqs[i][k + 1] == 9) || (gEquipAgeReqs[i][k + 1] == ((void)0, gSaveContext.linkAge))) { + if (temp == cursorSlot) { + pauseCtx->equipVtx[j].v.ob[0] = pauseCtx->equipVtx[j + 2].v.ob[0] = + pauseCtx->equipVtx[j].v.ob[0] - 2; + pauseCtx->equipVtx[j + 1].v.ob[0] = pauseCtx->equipVtx[j + 3].v.ob[0] = + pauseCtx->equipVtx[j + 1].v.ob[0] + 4; + pauseCtx->equipVtx[j].v.ob[1] = pauseCtx->equipVtx[j + 1].v.ob[1] = + pauseCtx->equipVtx[j].v.ob[1] + 2; + pauseCtx->equipVtx[j + 2].v.ob[1] = pauseCtx->equipVtx[j + 3].v.ob[1] = + pauseCtx->equipVtx[j + 2].v.ob[1] - 4; + } + } + } + } + } + + func_800949A8(globalCtx->state.gfxCtx); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + for (rowStart = 0, j = 0, temp = 0, i = 0; i < 4; i++, rowStart += 4, j += 16) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->equipVtx[j], 16, 0); + + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + point = CUR_UPG_VALUE(sChildUpgrades[i]); + if (1) {} + if ((point != 0) && (CUR_UPG_VALUE(sChildUpgrades[i]) != 0)) { + KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, + gItemIcons[sChildUpgradeItemBases[i] + point - 1], 32, 32, 0); + } + } else { + if ((i == 0) && (CUR_UPG_VALUE(sAdultUpgrades[i]) == 0)) { + KaleidoScope_DrawQuadTextureRGBA32( + globalCtx->state.gfxCtx, + gItemIcons[sChildUpgradeItemBases[i] + CUR_UPG_VALUE(sChildUpgrades[i]) - 1], 32, 32, 0); + } else if (CUR_UPG_VALUE(sAdultUpgrades[i]) != 0) { + KaleidoScope_DrawQuadTextureRGBA32( + globalCtx->state.gfxCtx, + gItemIcons[sAdultUpgradeItemBases[i] + CUR_UPG_VALUE(sAdultUpgrades[i]) - 1], 32, 32, 0); + } + } + + for (k = 0, bit = rowStart, point = 4; k < 3; k++, point += 4, temp++, bit++) { + + if (((u32)i == 0) && (k == 2) && (gSaveContext.bgsFlag != 0)) { + KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gBiggoronSwordIconTex, 32, 32, point); + } else if ((i == 0) && (k == 2) && (gBitFlags[bit + 1] & gSaveContext.inventory.equipment)) { + KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gBrokenGiantsKnifeIconTex, 32, 32, point); + } else if (gBitFlags[bit] & gSaveContext.inventory.equipment) { + KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[ITEM_SWORD_KOKIRI + temp], 32, + 32, point); + } + } + } + + KaleidoScope_DrawPlayerWork(globalCtx); + + if ((pauseCtx->unk_1E4 == 7) && (sEquipTimer == 10)) { + KaleidoScope_SetupPlayerPreRender(globalCtx); + } + + if ((pauseCtx->unk_1E4 == 7) && (sEquipTimer == 9)) { + //! @bug: This function shouldn't take any arguments + KaleidoScope_ProcessPlayerPreRender(globalCtx); + } + + gSPSegment(POLY_OPA_DISP++, 0x07, pauseCtx->playerSegment); + gSPSegment(POLY_OPA_DISP++, 0x08, pauseCtx->iconItemSegment); + gSPSegment(POLY_OPA_DISP++, 0x09, pauseCtx->iconItem24Segment); + gSPSegment(POLY_OPA_DISP++, 0x0A, pauseCtx->nameSegment); + gSPSegment(POLY_OPA_DISP++, 0x0B, globalCtx->interfaceCtx.mapSegment); + gSPSegment(POLY_OPA_DISP++, 0x0C, pauseCtx->iconItemAltSegment); + + func_800949A8(globalCtx->state.gfxCtx); + KaleidoScope_DrawEquipmentImage(globalCtx, pauseCtx->playerSegment, 64, 112); + + if (gUpgradeMasks[0]) {} + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_equipment.c", 609); +} diff --git a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_item.c index fb8243ba1..f1167099a 100644 --- a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_item.c @@ -1,9 +1,809 @@ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_808198A0.s") +#include "z_kaleido_scope.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80819E14.s") +u8 gAmmoItems[] = { + ITEM_STICK, ITEM_NUT, ITEM_BOMB, ITEM_BOW, ITEM_NONE, ITEM_NONE, ITEM_SLINGSHOT, ITEM_NONE, + ITEM_BOMBCHU, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_BEAN, ITEM_NONE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80819E40.s") +static s16 sEquipState = 0; +static s16 sEquipAnimTimer = 0; +static s16 sEquipMoveTimer = 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80819E6C.s") +static s16 sAmmoVtxOffset[] = { + 0, 2, 4, 6, 99, 99, 8, 99, 99, 10, 99, 99, 99, 99, 99, 99, 12, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081AD44.s") +void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item) { + s16 ammo; + s16 i; + + OPEN_DISPS(gfxCtx, "../z_kaleido_item.c", 69); + + ammo = AMMO(item); + + gDPPipeSync(POLY_OPA_DISP++); + + if (!((gSlotAgeReqs[SLOT(item)] == 9) || gSlotAgeReqs[SLOT(item)] == ((void)0, gSaveContext.linkAge))) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 100, 100, pauseCtx->alpha); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (ammo == 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 130, 130, 130, pauseCtx->alpha); + } else if ((item == ITEM_BOMB && AMMO(item) == CUR_CAPACITY(UPG_BOMB_BAG)) || + (item == ITEM_BOW && AMMO(item) == CUR_CAPACITY(UPG_QUIVER)) || + (item == ITEM_SLINGSHOT && AMMO(item) == CUR_CAPACITY(UPG_BULLET_BAG)) || + (item == ITEM_STICK && AMMO(item) == CUR_CAPACITY(UPG_STICKS)) || + (item == ITEM_NUT && AMMO(item) == CUR_CAPACITY(UPG_NUTS)) || (item == ITEM_BOMBCHU && ammo == 50) || + (item == ITEM_BEAN && ammo == 15)) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 120, 255, 0, pauseCtx->alpha); + } + } + + for (i = 0; ammo >= 10; i++) { + ammo -= 10; + } + + gDPPipeSync(POLY_OPA_DISP++); + + if (i != 0) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[item] + 27) * 4], 4, 0); + + gDPLoadTextureBlock(POLY_OPA_DISP++, D_020035C0[i], G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 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++, 0, 2, 3, 1, 0); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[item] + 28) * 4], 4, 0); + + gDPLoadTextureBlock(POLY_OPA_DISP++, D_020035C0[ammo], G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 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++, 0, 2, 3, 1, 0); + + CLOSE_DISPS(gfxCtx, "../z_kaleido_item.c", 116); +} + +void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx) { + pauseCtx->cursorVtx[0].v.ob[0] = vtx[index].v.ob[0]; + pauseCtx->cursorVtx[0].v.ob[1] = vtx[index].v.ob[1]; +} + +void KaleidoScope_SetItemCursorVtx(PauseContext* pauseCtx) { + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_ITEM] * 4, pauseCtx->itemVtx); +} + +static s16 sMagicArrowEffectsR[] = { 255, 100, 255 }; +static s16 sMagicArrowEffectsG[] = { 0, 100, 255 }; +static s16 sMagicArrowEffectsB[] = { 0, 255, 100 }; + +void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[0]; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + u16 i; + u16 j; + u16 cursorItem; + u16 cursorSlot; + u16 index; + s16 cursorPoint; + s16 cursorX; + s16 cursorY; + s16 oldCursorPoint; + s16 moveCursorResult; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_item.c", 234); + + func_800949A8(globalCtx->state.gfxCtx); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + pauseCtx->cursorColorSet = 0; + pauseCtx->nameColorSet = 0; + + if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + moveCursorResult = 0; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + + cursorItem = pauseCtx->cursorItem[PAUSE_ITEM]; + cursorSlot = pauseCtx->cursorSlot[PAUSE_ITEM]; + + if (pauseCtx->cursorSpecialPos == 0) { + pauseCtx->cursorColorSet = 4; + + if (cursorItem == PAUSE_ITEM_NONE) { + pauseCtx->stickRelX = 40; + } + + if (ABS(pauseCtx->stickRelX) > 30) { + cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + cursorX = pauseCtx->cursorX[PAUSE_ITEM]; + cursorY = pauseCtx->cursorY[PAUSE_ITEM]; + + osSyncPrintf("now=%d ccc=%d\n", cursorPoint, cursorItem); + + // Seem necessary to match + if (pauseCtx->cursorX[PAUSE_ITEM]) {} + if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]) {} + + while (moveCursorResult == 0) { + if (pauseCtx->stickRelX < -30) { + if (pauseCtx->cursorX[PAUSE_ITEM] != 0) { + pauseCtx->cursorX[PAUSE_ITEM] -= 1; + pauseCtx->cursorPoint[PAUSE_ITEM] -= 1; + + if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE) { + moveCursorResult = 1; + } + } else { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM] += 1; + + if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { + pauseCtx->cursorY[PAUSE_ITEM] = 0; + } + + pauseCtx->cursorPoint[PAUSE_ITEM] = + pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); + + if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; + } + + if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); + + moveCursorResult = 2; + } + } + } else if (pauseCtx->stickRelX > 30) { + if (pauseCtx->cursorX[PAUSE_ITEM] < 5) { + pauseCtx->cursorX[PAUSE_ITEM] += 1; + pauseCtx->cursorPoint[PAUSE_ITEM] += 1; + + if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE) { + moveCursorResult = 1; + } + } else { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM] += 1; + + if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { + pauseCtx->cursorY[PAUSE_ITEM] = 0; + } + + pauseCtx->cursorPoint[PAUSE_ITEM] = + pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); + + if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; + } + + if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); + + moveCursorResult = 2; + } + } + } + } + + if (moveCursorResult == 1) { + cursorItem = gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } + + osSyncPrintf("【X cursor=%d(%) (cur_xpt=%d)(ok_fg=%d)(ccc=%d)(key_angle=%d)】 ", + pauseCtx->cursorPoint[PAUSE_ITEM], pauseCtx->cursorX[PAUSE_ITEM], moveCursorResult, + cursorItem, pauseCtx->cursorSpecialPos); + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickRelX > 30) { + pauseCtx->nameDisplayTimer = 0; + pauseCtx->cursorSpecialPos = 0; + + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + + cursorPoint = cursorX = cursorY = 0; + while (true) { + if (gSaveContext.inventory.items[cursorPoint] != ITEM_NONE) { + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + moveCursorResult = 1; + break; + } + + cursorY = cursorY + 1; + cursorPoint = cursorPoint + 6; + if (cursorY < 4) { + continue; + } + + cursorY = 0; + cursorPoint = cursorX + 1; + cursorX = cursorPoint; + if (cursorX < 6) { + continue; + } + + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } + } else { + if (pauseCtx->stickRelX < -30) { + pauseCtx->nameDisplayTimer = 0; + pauseCtx->cursorSpecialPos = 0; + + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + + cursorPoint = cursorX = 5; + cursorY = 0; + while (true) { + if (gSaveContext.inventory.items[cursorPoint] != ITEM_NONE) { + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + moveCursorResult = 1; + break; + } + + cursorY = cursorY + 1; + cursorPoint = cursorPoint + 6; + if (cursorY < 4) { + continue; + } + + cursorY = 0; + cursorPoint = cursorX - 1; + cursorX = cursorPoint; + if (cursorX >= 0) { + continue; + } + + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + if (cursorItem != PAUSE_ITEM_NONE) { + if (ABS(pauseCtx->stickRelY) > 30) { + moveCursorResult = 0; + + cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + cursorY = pauseCtx->cursorY[PAUSE_ITEM]; + while (moveCursorResult == 0) { + if (pauseCtx->stickRelY > 30) { + if (pauseCtx->cursorY[PAUSE_ITEM] != 0) { + pauseCtx->cursorY[PAUSE_ITEM] -= 1; + pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; + + if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE) { + moveCursorResult = 1; + } + } else { + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + + moveCursorResult = 2; + } + } else if (pauseCtx->stickRelY < -30) { + if (pauseCtx->cursorY[PAUSE_ITEM] < 3) { + pauseCtx->cursorY[PAUSE_ITEM] += 1; + pauseCtx->cursorPoint[PAUSE_ITEM] += 6; + + if (gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != ITEM_NONE) { + moveCursorResult = 1; + } + } else { + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + + moveCursorResult = 2; + } + } + } + + cursorPoint = PAUSE_ITEM; + osSyncPrintf("【Y cursor=%d(%) (cur_ypt=%d)(ok_fg=%d)(ccc=%d)】 ", + pauseCtx->cursorPoint[cursorPoint], pauseCtx->cursorY[PAUSE_ITEM], moveCursorResult, + cursorItem); + } + } + + cursorSlot = pauseCtx->cursorPoint[PAUSE_ITEM]; + + pauseCtx->cursorColorSet = 4; + + if (moveCursorResult == 1) { + cursorItem = gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } else if (moveCursorResult != 2) { + cursorItem = gSaveContext.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } + + pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; + pauseCtx->cursorSlot[PAUSE_ITEM] = cursorSlot; + + if (!((gSlotAgeReqs[cursorSlot] == 9) || (gSlotAgeReqs[cursorSlot] == ((void)0, gSaveContext.linkAge)))) { + pauseCtx->nameColorSet = 1; + } + + if (cursorItem != PAUSE_ITEM_NONE) { + index = cursorSlot * 4; // required to match? + KaleidoScope_SetCursorVtx(pauseCtx, index, pauseCtx->itemVtx); + + if ((pauseCtx->debugState == 0) && (pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { + if (CHECK_BTN_ANY(input->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { + if (((gSlotAgeReqs[cursorSlot] == 9) || + (gSlotAgeReqs[cursorSlot] == ((void)0, gSaveContext.linkAge))) && + (cursorItem != ITEM_SOLD_OUT)) { + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + pauseCtx->equipTargetCBtn = 0; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + pauseCtx->equipTargetCBtn = 1; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + pauseCtx->equipTargetCBtn = 2; + } + + pauseCtx->equipTargetItem = cursorItem; + pauseCtx->equipTargetSlot = cursorSlot; + pauseCtx->unk_1E4 = 3; + pauseCtx->equipAnimX = pauseCtx->itemVtx[index].v.ob[0] * 10; + pauseCtx->equipAnimY = pauseCtx->itemVtx[index].v.ob[1] * 10; + pauseCtx->equipAnimAlpha = 255; + sEquipAnimTimer = 0; + sEquipState = 3; + sEquipMoveTimer = 10; + if ((pauseCtx->equipTargetItem == ITEM_ARROW_FIRE) || + (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) || + (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT)) { + index = 0; + if (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) { + index = 1; + } + if (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT) { + index = 2; + } + Audio_PlaySoundGeneral(NA_SE_SY_SET_FIRE_ARROW + index, &D_801333D4, 4, &D_801333E0, + &D_801333E0, &D_801333E8); + pauseCtx->equipTargetItem = 0xBF + index; + sEquipState = 0; + pauseCtx->equipAnimAlpha = 0; + sEquipMoveTimer = 6; + } else { + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } else { + Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } + } + } + } else { + pauseCtx->cursorVtx[0].v.ob[0] = pauseCtx->cursorVtx[2].v.ob[0] = pauseCtx->cursorVtx[1].v.ob[0] = + pauseCtx->cursorVtx[3].v.ob[0] = 0; + + pauseCtx->cursorVtx[0].v.ob[1] = pauseCtx->cursorVtx[1].v.ob[1] = pauseCtx->cursorVtx[2].v.ob[1] = + pauseCtx->cursorVtx[3].v.ob[1] = -200; + } + } else { + pauseCtx->cursorItem[PAUSE_ITEM] = PAUSE_ITEM_NONE; + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_ITEM]) { + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } else if ((pauseCtx->unk_1E4 == 3) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->itemVtx); + pauseCtx->cursorColorSet = 4; + } + + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + for (i = 0, j = 24 * 4; i < 3; i++, j += 4) { + if (gSaveContext.equips.buttonItems[i + 1] != ITEM_NONE) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j], 4, 0); + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, D_02000A00[1], 32, 32, 0); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + for (i = j = 0; i < 24; i++, j += 4) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (gSaveContext.inventory.items[i] != ITEM_NONE) { + if ((pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && (pauseCtx->cursorSpecialPos == 0)) { + if ((gSlotAgeReqs[i] == 9) || (gSlotAgeReqs[i] == ((void)0, gSaveContext.linkAge))) { + if ((sEquipState == 2) && (i == 3)) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sMagicArrowEffectsR[pauseCtx->equipTargetItem - 0xBF], + sMagicArrowEffectsG[pauseCtx->equipTargetItem - 0xBF], + sMagicArrowEffectsB[pauseCtx->equipTargetItem - 0xBF], pauseCtx->alpha); + + pauseCtx->itemVtx[j + 0].v.ob[0] = pauseCtx->itemVtx[j + 2].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] - 2; + + pauseCtx->itemVtx[j + 1].v.ob[0] = pauseCtx->itemVtx[j + 3].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] + 32; + + pauseCtx->itemVtx[j + 0].v.ob[1] = pauseCtx->itemVtx[j + 1].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] + 2; + + pauseCtx->itemVtx[j + 2].v.ob[1] = pauseCtx->itemVtx[j + 3].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] - 32; + } else if (i == cursorSlot) { + pauseCtx->itemVtx[j + 0].v.ob[0] = pauseCtx->itemVtx[j + 2].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] - 2; + + pauseCtx->itemVtx[j + 1].v.ob[0] = pauseCtx->itemVtx[j + 3].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] + 32; + + pauseCtx->itemVtx[j + 0].v.ob[1] = pauseCtx->itemVtx[j + 1].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] + 2; + + pauseCtx->itemVtx[j + 2].v.ob[1] = pauseCtx->itemVtx[j + 3].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] - 32; + } + } + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j + 0], 4, 0); + KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[gSaveContext.inventory.items[i]], 32, + 32, 0); + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + KaleidoScope_DrawCursor(globalCtx, PAUSE_ITEM); + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + for (i = 0; i < 15; i++) { + if ((gAmmoItems[i] != ITEM_NONE) && (gSaveContext.inventory.items[i] != ITEM_NONE)) { + KaleidoScope_DrawAmmoCount(pauseCtx, globalCtx->state.gfxCtx, gSaveContext.inventory.items[i]); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_item.c", 516); +} + +static s16 sCButtonPosX[] = { 660, 900, 1140 }; +static s16 sCButtonPosY[] = { 1100, 920, 1100 }; + +void KaleidoScope_UpdateItemEquip(GlobalContext* globalCtx) { + static s16 D_8082A488 = 0; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + Vtx* bowItemVtx; + u16 offsetX; + u16 offsetY; + + if (sEquipState == 0) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + sEquipState++; + } + sEquipAnimTimer = 5; + return; + } + + if (sEquipState == 2) { + D_8082A488--; + + if (D_8082A488 == 0) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + sEquipMoveTimer = 6; + WREG(90) = 320; + WREG(87) = WREG(91); + sEquipState++; + Audio_PlaySoundGeneral(NA_SE_SY_SYNTH_MAGIC_ARROW, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + return; + } + + if (sEquipState == 1) { + bowItemVtx = &pauseCtx->itemVtx[12]; + offsetX = ABS(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sEquipMoveTimer; + offsetY = ABS(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sEquipMoveTimer; + } else { + offsetX = ABS(pauseCtx->equipAnimX - sCButtonPosX[pauseCtx->equipTargetCBtn]) / sEquipMoveTimer; + offsetY = ABS(pauseCtx->equipAnimY - sCButtonPosY[pauseCtx->equipTargetCBtn]) / sEquipMoveTimer; + } + + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipAnimAlpha < 254)) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + } + sEquipAnimTimer = 5; + return; + } + + if (sEquipAnimTimer == 0) { + WREG(90) -= WREG(87) / sEquipMoveTimer; + WREG(87) -= WREG(87) / sEquipMoveTimer; + + if (sEquipState == 1) { + if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[12].v.ob[0] * 10)) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[12].v.ob[1] * 10)) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } else { + if (pauseCtx->equipAnimX >= sCButtonPosX[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= sCButtonPosY[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } + + sEquipMoveTimer--; + + if (sEquipMoveTimer == 0) { + if (sEquipState == 1) { + sEquipState++; + D_8082A488 = 4; + return; + } + + osSyncPrintf("\n================================\n"); + + if (pauseCtx->equipTargetCBtn == 0) { + + if (pauseCtx->equipTargetSlot == gSaveContext.equips.cButtonSlots[1]) { + if (gSaveContext.equips.buttonItems[1] != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1) && + ((gSaveContext.equips.buttonItems[1] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[1] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[1] <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + gSaveContext.equips.buttonItems[2] = gSaveContext.equips.buttonItems[1]; + gSaveContext.equips.cButtonSlots[1] = gSaveContext.equips.cButtonSlots[0]; + Interface_LoadItemIcon2(globalCtx, 2); + } + } else { + gSaveContext.equips.buttonItems[2] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[1] = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == gSaveContext.equips.cButtonSlots[2]) { + if (gSaveContext.equips.buttonItems[1] != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1) && + ((gSaveContext.equips.buttonItems[1] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[1] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[1] <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + gSaveContext.equips.buttonItems[3] = gSaveContext.equips.buttonItems[1]; + gSaveContext.equips.cButtonSlots[2] = gSaveContext.equips.cButtonSlots[0]; + Interface_LoadItemIcon2(globalCtx, 3); + } + } else { + gSaveContext.equips.buttonItems[3] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[2] = SLOT_NONE; + } + } + + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1)) { + if ((gSaveContext.equips.buttonItems[1] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[1] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[1] <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((gSaveContext.equips.buttonItems[2] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[2] <= ITEM_BOW_ARROW_LIGHT)) { + gSaveContext.equips.buttonItems[2] = gSaveContext.equips.buttonItems[1]; + gSaveContext.equips.cButtonSlots[1] = gSaveContext.equips.cButtonSlots[0]; + Interface_LoadItemIcon2(globalCtx, 2); + } else if ((gSaveContext.equips.buttonItems[3] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[3] <= ITEM_BOW_ARROW_LIGHT)) { + gSaveContext.equips.buttonItems[3] = gSaveContext.equips.buttonItems[1]; + gSaveContext.equips.cButtonSlots[2] = gSaveContext.equips.cButtonSlots[0]; + Interface_LoadItemIcon2(globalCtx, 3); + } + } + + gSaveContext.equips.buttonItems[1] = pauseCtx->equipTargetItem; + gSaveContext.equips.cButtonSlots[0] = pauseCtx->equipTargetSlot; + Interface_LoadItemIcon1(globalCtx, 1); + + osSyncPrintf("C左sl_item_no=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetItem, + gSaveContext.equips.buttonItems[1], gSaveContext.equips.buttonItems[2], + gSaveContext.equips.buttonItems[3]); + osSyncPrintf("C左sl_number=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetSlot, + gSaveContext.equips.cButtonSlots[0], gSaveContext.equips.cButtonSlots[1], + gSaveContext.equips.cButtonSlots[2]); + } else if (pauseCtx->equipTargetCBtn == 1) { + osSyncPrintf("C下sl_item_no=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetItem, + gSaveContext.equips.buttonItems[1], gSaveContext.equips.buttonItems[2], + gSaveContext.equips.buttonItems[3]); + osSyncPrintf("C下sl_number=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetSlot, + gSaveContext.equips.cButtonSlots[0], gSaveContext.equips.cButtonSlots[1], + gSaveContext.equips.cButtonSlots[2]); + + if (pauseCtx->equipTargetSlot == gSaveContext.equips.cButtonSlots[0]) { + if (gSaveContext.equips.buttonItems[2] != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1) && + ((gSaveContext.equips.buttonItems[2] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[2] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[2] <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + gSaveContext.equips.buttonItems[1] = gSaveContext.equips.buttonItems[2]; + gSaveContext.equips.cButtonSlots[0] = gSaveContext.equips.cButtonSlots[1]; + Interface_LoadItemIcon2(globalCtx, 1); + } + } else { + gSaveContext.equips.buttonItems[1] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[0] = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == gSaveContext.equips.cButtonSlots[2]) { + if (gSaveContext.equips.buttonItems[2] != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1) && + ((gSaveContext.equips.buttonItems[2] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[2] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[2] <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + gSaveContext.equips.buttonItems[3] = gSaveContext.equips.buttonItems[2]; + gSaveContext.equips.cButtonSlots[2] = gSaveContext.equips.cButtonSlots[1]; + Interface_LoadItemIcon2(globalCtx, 3); + } + } else { + gSaveContext.equips.buttonItems[3] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[2] = SLOT_NONE; + } + } + + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1)) { + if ((gSaveContext.equips.buttonItems[2] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[2] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[2] <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((gSaveContext.equips.buttonItems[1] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[1] <= ITEM_BOW_ARROW_LIGHT)) { + gSaveContext.equips.buttonItems[1] = gSaveContext.equips.buttonItems[2]; + Interface_LoadItemIcon2(globalCtx, 1); + } else if ((gSaveContext.equips.buttonItems[3] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[3] <= ITEM_BOW_ARROW_LIGHT)) { + gSaveContext.equips.buttonItems[3] = gSaveContext.equips.buttonItems[2]; + Interface_LoadItemIcon2(globalCtx, 3); + } + } + + gSaveContext.equips.buttonItems[2] = pauseCtx->equipTargetItem; + gSaveContext.equips.cButtonSlots[1] = pauseCtx->equipTargetSlot; + Interface_LoadItemIcon1(globalCtx, 2); + + osSyncPrintf("C下sl_item_no=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetItem, + gSaveContext.equips.buttonItems[1], gSaveContext.equips.buttonItems[2], + gSaveContext.equips.buttonItems[3]); + osSyncPrintf("C下sl_number=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetSlot, + gSaveContext.equips.cButtonSlots[0], gSaveContext.equips.cButtonSlots[1], + gSaveContext.equips.cButtonSlots[2]); + } else { + osSyncPrintf("C右sl_item_no=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetItem, + gSaveContext.equips.buttonItems[1], gSaveContext.equips.buttonItems[2], + gSaveContext.equips.buttonItems[3]); + osSyncPrintf("C右sl_number=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetSlot, + gSaveContext.equips.cButtonSlots[0], gSaveContext.equips.cButtonSlots[1], + gSaveContext.equips.cButtonSlots[2]); + + if (pauseCtx->equipTargetSlot == gSaveContext.equips.cButtonSlots[0]) { + if (gSaveContext.equips.buttonItems[3] != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1) && + ((gSaveContext.equips.buttonItems[3] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[3] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[3] <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + gSaveContext.equips.buttonItems[1] = gSaveContext.equips.buttonItems[3]; + gSaveContext.equips.cButtonSlots[0] = gSaveContext.equips.cButtonSlots[2]; + Interface_LoadItemIcon2(globalCtx, 1); + } + } else { + gSaveContext.equips.buttonItems[1] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[0] = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == gSaveContext.equips.cButtonSlots[1]) { + if (gSaveContext.equips.buttonItems[3] != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1) && + ((gSaveContext.equips.buttonItems[3] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[3] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[3] <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + gSaveContext.equips.buttonItems[2] = gSaveContext.equips.buttonItems[3]; + gSaveContext.equips.cButtonSlots[1] = gSaveContext.equips.cButtonSlots[2]; + Interface_LoadItemIcon2(globalCtx, 2); + } + } else { + gSaveContext.equips.buttonItems[2] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[1] = SLOT_NONE; + } + } + + if ((pauseCtx->equipTargetItem >= 0xBF) && (pauseCtx->equipTargetItem <= 0xC1)) { + if ((gSaveContext.equips.buttonItems[3] == ITEM_BOW) || + ((gSaveContext.equips.buttonItems[3] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[3] <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xBF - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((gSaveContext.equips.buttonItems[1] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[1] <= ITEM_BOW_ARROW_LIGHT)) { + gSaveContext.equips.buttonItems[1] = gSaveContext.equips.buttonItems[3]; + Interface_LoadItemIcon2(globalCtx, 1); + } else if ((gSaveContext.equips.buttonItems[2] >= ITEM_BOW_ARROW_FIRE) && + (gSaveContext.equips.buttonItems[2] <= ITEM_BOW_ARROW_LIGHT)) { + gSaveContext.equips.buttonItems[2] = gSaveContext.equips.buttonItems[3]; + Interface_LoadItemIcon2(globalCtx, 2); + } + } + + gSaveContext.equips.buttonItems[3] = pauseCtx->equipTargetItem; + gSaveContext.equips.cButtonSlots[2] = pauseCtx->equipTargetSlot; + Interface_LoadItemIcon1(globalCtx, 3); + + osSyncPrintf("C右sl_item_no=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetItem, + gSaveContext.equips.buttonItems[1], gSaveContext.equips.buttonItems[2], + gSaveContext.equips.buttonItems[3]); + osSyncPrintf("C右sl_number=%d (1)=%d (2)=%d (3)=%d\n", pauseCtx->equipTargetSlot, + gSaveContext.equips.cButtonSlots[0], gSaveContext.equips.cButtonSlots[1], + gSaveContext.equips.cButtonSlots[2]); + } + + pauseCtx->unk_1E4 = 0; + sEquipMoveTimer = 10; + WREG(90) = 320; + WREG(87) = WREG(91); + } + } else { + sEquipAnimTimer--; + if (sEquipAnimTimer == 0) { + pauseCtx->equipAnimAlpha = 255; + } + } +} diff --git a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_map_PAL.c b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_map_PAL.c index c83ca5730..ace4eb8c3 100644 --- a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_map_PAL.c +++ b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_map_PAL.c @@ -1,5 +1,731 @@ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081BB10.s") +#include "z_kaleido_scope.h" +#include "textures/icon_item_24_static/icon_item_24_static.h" +#include "textures/icon_item_nes_static/icon_item_nes_static.h" +#include "textures/icon_item_ger_static/icon_item_ger_static.h" +#include "textures/icon_item_fra_static/icon_item_fra_static.h" +#include "textures/icon_item_field_static/icon_item_field_static.h" +#include "textures/icon_item_dungeon_static/icon_item_dungeon_static.h" +#include "textures/icon_item_nes_static/icon_item_nes_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081D398.s") +void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { + static void* dungeonItemTexs[] = { + gBossKeyIconTex, + gCompassIconTex, + gDungeonMapIconTex, + }; + static void* dungeonTitleTexs[] = { + gPauseDekuTitleENGTex, gPauseDodongoTitleENGTex, gPauseJabuTitleENGTex, gPauseForestTitleENGTex, + gPauseFireTitleENGTex, gPauseWaterTitleENGTex, gPauseSpiritTitleENGTex, gPauseShadowTitleENGTex, + gPauseBotWTitleENGTex, gPauseIceCavernTitleENGTex, + }; + static void* floorIconTexs[] = { + gDungeonMapBlankFloorButtonTex, gDungeonMap8FButtonTex, gDungeonMap7FButtonTex, gDungeonMap6FButtonTex, + gDungeonMap5FButtonTex, gDungeonMap4FButtonTex, gDungeonMap3FButtonTex, gDungeonMap2FButtonTex, + gDungeonMap1FButtonTex, gDungeonMapB1ButtonTex, gDungeonMapB2ButtonTex, gDungeonMapB3ButtonTex, + gDungeonMapB4ButtonTex, gDungeonMapB5ButtonTex, gDungeonMapB6ButtonTex, gDungeonMapB7ButtonTex, + gDungeonMapB8ButtonTex, + }; + static u16 mapBgPulseColors[][3] = { + { 0 / 8, 80 / 8, 255 / 8 }, + { 0 / 8, 200 / 8, 140 / 8 }, + }; + static s16 mapBgPulseR = 0 / 8; + static s16 mapBgPulseG = 200 / 8; + static s16 mapBgPulseB = 140 / 8; + static u16 mapBgPulseTimer = 20; + static u16 mapBgPulseStage = 0; + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 i; + s16 j; + s16 oldCursorPoint; + s16 stepR; + s16 stepG; + s16 stepB; + u16 rgba16; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081EFF0.s") + OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 123); + + if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { + pauseCtx->cursorColorSet = 0; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MAP]; + + if (pauseCtx->cursorSpecialPos == 0) { + if (pauseCtx->stickRelX > 30) { + if (pauseCtx->cursorX[PAUSE_MAP] != 0) { + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); + } else { + pauseCtx->cursorX[PAUSE_MAP] = 1; + pauseCtx->cursorPoint[PAUSE_MAP] = 0; + if (!CHECK_DUNGEON_ITEM(DUNGEON_KEY_BOSS, gSaveContext.mapIndex)) { + pauseCtx->cursorPoint[PAUSE_MAP]++; + if (!CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, gSaveContext.mapIndex)) { + pauseCtx->cursorPoint[PAUSE_MAP]++; + if (!CHECK_DUNGEON_ITEM(DUNGEON_MAP, gSaveContext.mapIndex)) { + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); + } + } + } + } + } else if (pauseCtx->stickRelX < -30) { + if (pauseCtx->cursorX[PAUSE_MAP] == 0) { + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); + } else { + pauseCtx->cursorX[PAUSE_MAP] = 0; + pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot; + osSyncPrintf("kscope->cursor_point=%d\n", pauseCtx->cursorPoint[PAUSE_MAP]); + R_MAP_TEX_INDEX = + R_MAP_TEX_INDEX_BASE + + gMapData->floorTexIndexOffset[gSaveContext.mapIndex][pauseCtx->cursorPoint[PAUSE_MAP] - 3]; + KaleidoScope_UpdateDungeonMap(globalCtx); + } + } + + if (pauseCtx->cursorPoint[PAUSE_MAP] < 3) { + if (pauseCtx->stickRelY > 30) { + if (pauseCtx->cursorPoint[PAUSE_MAP] != 0) { + for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 1; i >= 0; i--) { + if (CHECK_DUNGEON_ITEM(i, gSaveContext.mapIndex)) { + pauseCtx->cursorPoint[PAUSE_MAP] = i; + break; + } + } + } + } else { + if (pauseCtx->stickRelY < -30) { + if (pauseCtx->cursorPoint[PAUSE_MAP] != 2) { + for (i = pauseCtx->cursorPoint[PAUSE_MAP] + 1; i < 3; i++) { + if (CHECK_DUNGEON_ITEM(i, gSaveContext.mapIndex)) { + pauseCtx->cursorPoint[PAUSE_MAP] = i; + break; + } + } + } + } + } + } else { + if (pauseCtx->stickRelY > 30) { + if (pauseCtx->cursorPoint[PAUSE_MAP] >= 4) { + for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 3 - 1; i >= 0; i--) { + if ((gSaveContext.sceneFlags[gSaveContext.mapIndex].floors & gBitFlags[i]) || + (CHECK_DUNGEON_ITEM(DUNGEON_MAP, gSaveContext.mapIndex) && + (gMapData->floorID[interfaceCtx->unk_25A][i] != 0))) { + pauseCtx->cursorPoint[PAUSE_MAP] = i + 3; + break; + } + } + } + } else if (pauseCtx->stickRelY < -30) { + if (pauseCtx->cursorPoint[PAUSE_MAP] != 10) { + for (i = pauseCtx->cursorPoint[PAUSE_MAP] - 3 + 1; i < 11; i++) { + if ((gSaveContext.sceneFlags[gSaveContext.mapIndex].floors & gBitFlags[i]) || + (CHECK_DUNGEON_ITEM(DUNGEON_MAP, gSaveContext.mapIndex) && + (gMapData->floorID[interfaceCtx->unk_25A][i] != 0))) { + pauseCtx->cursorPoint[PAUSE_MAP] = i + 3; + break; + } + } + } + } + + i = R_MAP_TEX_INDEX; + R_MAP_TEX_INDEX = + R_MAP_TEX_INDEX_BASE + + gMapData->floorTexIndexOffset[gSaveContext.mapIndex][pauseCtx->cursorPoint[PAUSE_MAP] - 3]; + pauseCtx->dungeonMapSlot = pauseCtx->cursorPoint[PAUSE_MAP]; + if (i != R_MAP_TEX_INDEX) { + KaleidoScope_UpdateDungeonMap(globalCtx); + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickRelX > 30) { + pauseCtx->nameDisplayTimer = 0; + pauseCtx->cursorSpecialPos = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot; + pauseCtx->cursorX[PAUSE_MAP] = 0; + j = 72 + (pauseCtx->cursorSlot[PAUSE_MAP] * 4); + KaleidoScope_SetCursorVtx(pauseCtx, j, pauseCtx->mapPageVtx); + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } else { + if (pauseCtx->stickRelX < -30) { + pauseCtx->nameDisplayTimer = 0; + pauseCtx->cursorSpecialPos = 0; + pauseCtx->cursorX[PAUSE_MAP] = 1; + pauseCtx->cursorPoint[PAUSE_MAP] = 0; + if (!CHECK_DUNGEON_ITEM(DUNGEON_KEY_BOSS, gSaveContext.mapIndex)) { + pauseCtx->cursorPoint[PAUSE_MAP]++; + if (!CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, gSaveContext.mapIndex)) { + pauseCtx->cursorPoint[PAUSE_MAP]++; + if (!CHECK_DUNGEON_ITEM(DUNGEON_MAP, gSaveContext.mapIndex)) { + pauseCtx->cursorX[PAUSE_MAP] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = + pauseCtx->dungeonMapSlot; + R_MAP_TEX_INDEX = + R_MAP_TEX_INDEX_BASE + + gMapData + ->floorTexIndexOffset[gSaveContext.mapIndex][pauseCtx->cursorPoint[PAUSE_MAP] - 3]; + KaleidoScope_UpdateDungeonMap(globalCtx); + } + } + } else { + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP]; + } + + osSyncPrintf("kscope->cursor_point====%d\n", pauseCtx->cursorPoint[PAUSE_MAP]); + j = 72 + (pauseCtx->cursorSlot[PAUSE_MAP] * 4); + KaleidoScope_SetCursorVtx(pauseCtx, j, pauseCtx->mapPageVtx); + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_MAP]) { + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + if (pauseCtx->cursorPoint[PAUSE_MAP] < 3) { + pauseCtx->cursorItem[PAUSE_MAP] = ITEM_KEY_BOSS + pauseCtx->cursorPoint[PAUSE_MAP]; + } else { + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + } + + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP]; + + j = 72 + (pauseCtx->cursorSlot[PAUSE_MAP] * 4); + KaleidoScope_SetCursorVtx(pauseCtx, j, pauseCtx->mapPageVtx); + + if (pauseCtx->cursorX[PAUSE_MAP] == 0) { + pauseCtx->mapPageVtx[j + 0].v.ob[0] = pauseCtx->mapPageVtx[j + 2].v.ob[0] = + pauseCtx->mapPageVtx[j + 0].v.ob[0] - 2; + pauseCtx->mapPageVtx[j + 1].v.ob[0] = pauseCtx->mapPageVtx[j + 3].v.ob[0] = + pauseCtx->mapPageVtx[j + 1].v.ob[0] + 4; + pauseCtx->mapPageVtx[j + 0].v.ob[1] = pauseCtx->mapPageVtx[j + 1].v.ob[1] = + pauseCtx->mapPageVtx[j + 0].v.ob[1] + 2; + pauseCtx->mapPageVtx[j + 2].v.ob[1] = pauseCtx->mapPageVtx[j + 3].v.ob[1] = + pauseCtx->mapPageVtx[j + 2].v.ob[1] - 4; + } + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[68], 16, 0); + + gDPLoadTextureBlock(POLY_OPA_DISP++, dungeonTitleTexs[gSaveContext.mapIndex], G_IM_FMT_IA, G_IM_SIZ_8b, 96, 16, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + for (i = 0, j = 4; i < 3; i++, j += 4) { + if (CHECK_DUNGEON_ITEM(i, gSaveContext.mapIndex)) { + gDPLoadTextureBlock(POLY_OPA_DISP++, dungeonItemTexs[i], G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 24, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 200, pauseCtx->alpha); + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[84], 32, 0); + + for (i = j = 0; i < 8; i++, j += 4) { + if ((gSaveContext.sceneFlags[gSaveContext.mapIndex].floors & gBitFlags[i]) || + CHECK_DUNGEON_ITEM(DUNGEON_MAP, gSaveContext.mapIndex)) { + if (i != (pauseCtx->dungeonMapSlot - 3)) { + gDPLoadTextureBlock(POLY_OPA_DISP++, floorIconTexs[gMapData->floorID[interfaceCtx->unk_25A][i]], + G_IM_FMT_IA, G_IM_SIZ_8b, 24, 16, 0, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + } + } + } + + j = (pauseCtx->dungeonMapSlot - 3) * 4; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 150, 150, 255, pauseCtx->alpha); + + gDPLoadTextureBlock(POLY_OPA_DISP++, + floorIconTexs[gMapData->floorID[interfaceCtx->unk_25A][pauseCtx->dungeonMapSlot - 3]], + G_IM_FMT_IA, G_IM_SIZ_8b, 24, 16, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + + pauseCtx->mapPageVtx[124].v.ob[0] = pauseCtx->mapPageVtx[126].v.ob[0] = pauseCtx->mapPageVtx[124].v.ob[0] + 2; + pauseCtx->mapPageVtx[125].v.ob[0] = pauseCtx->mapPageVtx[127].v.ob[0] = pauseCtx->mapPageVtx[124].v.ob[0] + 19; + pauseCtx->mapPageVtx[124].v.ob[1] = pauseCtx->mapPageVtx[125].v.ob[1] = pauseCtx->mapPageVtx[124].v.ob[1] - 2; + pauseCtx->mapPageVtx[126].v.ob[1] = pauseCtx->mapPageVtx[127].v.ob[1] = pauseCtx->mapPageVtx[124].v.ob[1] - 19; + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[116], 12, 0); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + pauseCtx->mapPageVtx[116].v.ob[1] = pauseCtx->mapPageVtx[117].v.ob[1] = pauseCtx->offsetY - (VREG(30) * 14) + 49; + pauseCtx->mapPageVtx[118].v.ob[1] = pauseCtx->mapPageVtx[119].v.ob[1] = pauseCtx->mapPageVtx[116].v.ob[1] - 16; + + gDPLoadTextureBlock(POLY_OPA_DISP++, gDungeonMapLinkHeadTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 16, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + if (CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, gSaveContext.mapIndex) && + (gMapData->skullFloorIconY[gSaveContext.mapIndex] != -99)) { + pauseCtx->mapPageVtx[120].v.ob[1] = pauseCtx->mapPageVtx[121].v.ob[1] = + gMapData->skullFloorIconY[gSaveContext.mapIndex] + pauseCtx->offsetY; + pauseCtx->mapPageVtx[122].v.ob[1] = pauseCtx->mapPageVtx[123].v.ob[1] = pauseCtx->mapPageVtx[120].v.ob[1] - 16; + + gDPLoadTextureBlock(POLY_OPA_DISP++, gDungeonMapSkullTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 16, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, 4, 6, 7, 5, 0); + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (GET_GS_FLAGS(gSaveContext.mapIndex) == gAreaGsFlags[gSaveContext.mapIndex]) { + KaleidoScope_DrawQuadTextureRGBA32(gfxCtx, gGoldSkulltulaIconTex, 24, 24, 8); + } + + if ((globalCtx->sceneNum >= SCENE_YDAN) && (globalCtx->sceneNum <= SCENE_TAKARAYA)) { + stepR = (mapBgPulseR - mapBgPulseColors[mapBgPulseStage][0]) / mapBgPulseTimer; + stepG = (mapBgPulseG - mapBgPulseColors[mapBgPulseStage][1]) / mapBgPulseTimer; + stepB = (mapBgPulseB - mapBgPulseColors[mapBgPulseStage][2]) / mapBgPulseTimer; + mapBgPulseR -= stepR; + mapBgPulseG -= stepG; + mapBgPulseB -= stepB; + + rgba16 = ((mapBgPulseR & 0x1F) << 11) | ((mapBgPulseG & 0x1F) << 6) | ((mapBgPulseB & 0x1F) << 1) | 1; + interfaceCtx->mapPalette[28] = (rgba16 & 0xFF00) >> 8; + interfaceCtx->mapPalette[29] = rgba16 & 0xFF; + + mapBgPulseTimer--; + if (mapBgPulseTimer == 0) { + mapBgPulseStage ^= 1; + mapBgPulseTimer = 20; + } + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + gDPLoadTLUT_pal16(POLY_OPA_DISP++, 0, interfaceCtx->mapPalette); + gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16); + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[60], 8, 0); + + gDPLoadTextureBlock_4b(POLY_OPA_DISP++, interfaceCtx->mapSegment, G_IM_FMT_CI, 48, 85, 0, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + gDPLoadTextureBlock_4b(POLY_OPA_DISP++, interfaceCtx->mapSegment + 0x800, G_IM_FMT_CI, 48, 85, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, 4, 6, 7, 5, 0); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + + CLOSE_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 388); +} + +void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { + static void* cloudTexs[] = { + gWorldMapCloud16Tex, gWorldMapCloud15Tex, gWorldMapCloud14Tex, gWorldMapCloud13Tex, + gWorldMapCloud12Tex, gWorldMapCloud11Tex, gWorldMapCloud10Tex, gWorldMapCloud9Tex, + gWorldMapCloud8Tex, gWorldMapCloud7Tex, gWorldMapCloud6Tex, gWorldMapCloud5Tex, + gWorldMapCloud4Tex, gWorldMapCloud3Tex, gWorldMapCloud2Tex, gWorldMapCloud1Tex, + }; + static u16 cloudFlagNums[] = { + 0x05, 0x00, 0x13, 0x0E, 0x0F, 0x01, 0x02, 0x10, 0x12, 0x03, 0x07, 0x08, 0x09, 0x0C, 0x0B, 0x06, + }; + static s16 pointPulsePrimColor[] = { 0, 0, 255 }; + static s16 pointPrimColors[][3] = { + { 0, 0, 255 }, + { 255, 255, 0 }, + }; + static s16 pointPulseEnvColor[] = { 255, 255, 0 }; + static s16 pointEnvColors[][3] = { + { 255, 255, 0 }, + { 0, 0, 255 }, + }; + static s16 pointPulseStage = 1; + static s16 pointPulseTimer = 20; + static s16 D_8082A5B8[] = { 64, 64, 64, 28 }; + static s16 areaBoxPosX[] = { + -41, 19, 44, 40, 49, 51, -49, 83, 80, -67, 50, -109, -76, -86, -10, -6, 19, 24, 11, -17, 37, -6, + }; + static s16 areaBoxWidths[] = { + 96, 32, 32, 48, 48, 32, 48, 32, 32, 32, 16, 32, 32, 16, 32, 32, 32, 32, 32, 32, 16, 32, + }; + static s16 areaBoxPosY[] = { + 30, 36, 35, 26, 7, 11, -31, 30, 38, 23, 2, 42, 40, 32, 38, 50, 57, 58, 56, 12, 36, 50, + }; + static s16 areaBoxHeights[] = { + 59, 19, 13, 19, 38, 17, 38, 17, 13, 26, 16, 26, 26, 16, 19, 17, 26, 13, 17, 17, 16, 17, + }; + static void* areaBoxTexs[] = { + gWorldMapAreaBox7Tex, gWorldMapAreaBox1Tex, gWorldMapAreaBox4Tex, gWorldMapAreaBox6Tex, gWorldMapAreaBox2Tex, + gWorldMapAreaBox3Tex, gWorldMapAreaBox2Tex, gWorldMapAreaBox3Tex, gWorldMapAreaBox4Tex, gWorldMapAreaBox5Tex, + gWorldMapAreaBox8Tex, gWorldMapAreaBox5Tex, gWorldMapAreaBox5Tex, gWorldMapAreaBox8Tex, gWorldMapAreaBox1Tex, + gWorldMapAreaBox3Tex, gWorldMapAreaBox5Tex, gWorldMapAreaBox4Tex, gWorldMapAreaBox3Tex, gWorldMapAreaBox3Tex, + gWorldMapAreaBox8Tex, gWorldMapAreaBox3Tex, + }; + static void* currentPosTitleTexs[] = { + gPauseCurrentPositionENGTex, + gPauseCurrentPositionGERTex, + gPauseCurrentPositionFRATex, + }; + static u16 D_8082A6D4 = 0; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 i; + s16 j; + s16 t; + s16 k; + s16 oldCursorPoint; + s16 stepR; + s16 stepG; + s16 stepB; + + OPEN_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 556); + + if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0) && (pauseCtx->pageIndex == PAUSE_MAP)) { + pauseCtx->cursorColorSet = 0; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + + if (pauseCtx->cursorSpecialPos == 0) { + if (pauseCtx->stickRelX > 30) { + D_8082A6D4 = 0; + + do { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]++; + if (pauseCtx->cursorPoint[PAUSE_WORLD_MAP] > 11) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 11; + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } while (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]] == 0); + } else if (pauseCtx->stickRelX < -30) { + D_8082A6D4 = 0; + + do { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]--; + if (pauseCtx->cursorPoint[PAUSE_WORLD_MAP] < 0) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 0; + KaleidoScope_MoveCursorToSpecialPos(globalCtx, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } while (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]] == 0); + } else { + D_8082A6D4++; + } + + pauseCtx->cursorItem[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP] + 0x1F; + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MAP] * 4, pauseCtx->mapPageVtx); + } else { + pauseCtx->cursorItem[PAUSE_MAP] = gSaveContext.worldMapArea + 0x18; + if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickRelX > 30) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 0; + pauseCtx->cursorSpecialPos = 0; + + while (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]] == 0) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]++; + } + + pauseCtx->cursorItem[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP] + 0x1F; + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MAP] * 4, pauseCtx->mapPageVtx); + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + D_8082A6D4 = 0; + } + } else { + if (pauseCtx->stickRelX < -30) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 11; + pauseCtx->cursorSpecialPos = 0; + + while (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]] == 0) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]--; + } + + pauseCtx->cursorItem[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP] + 0x1F; + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MAP] * 4, pauseCtx->mapPageVtx); + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + D_8082A6D4 = 0; + } + } + } + + if (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]] == 0) { + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_WORLD_MAP]) { + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + if (HREG(15) == 0) { + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); + + gDPLoadTLUT_pal256(POLY_OPA_DISP++, gWorldMapImageTLUT); + gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[188], 32, 0); + + for (j = t = i = 0; i < 8; i++, t++, j += 4) { + gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + t * 216 * 9, G_IM_FMT_CI, G_IM_SIZ_8b, 216, 9, + 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + + if (1) {} + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[220], 28, 0); + + for (j = i = 0; i < 6; i++, t++, j += 4) { + gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + t * 216 * 9, G_IM_FMT_CI, G_IM_SIZ_8b, 216, 9, + 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + } + + gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + t * 216 * 9, G_IM_FMT_CI, G_IM_SIZ_8b, 216, 2, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + } else if (HREG(15) == 1) { + Gfx* sp1CC = POLY_OPA_DISP; + void* mapImage = gWorldMapImageTex; + + // gSPLoadUcodeL(sp1CC++, rspS2DEX)? + gSPLoadUcodeEx(sp1CC++, OS_K0_TO_PHYSICAL(D_80113070), OS_K0_TO_PHYSICAL(D_801579A0), 0x800); + + func_8009638C(&sp1CC, mapImage, gWorldMapImageTLUT, 216, 128, G_IM_FMT_CI, G_IM_SIZ_8b, 0x8000, 256, + HREG(13) / 100.0f, HREG(14) / 100.0f); + + // gSPLoadUcode(sp1CC++, SysUcode_GetUCode(), SysUcode_GetUCodeData())? + gSPLoadUcodeEx(sp1CC++, SysUcode_GetUCode(), SysUcode_GetUCodeData(), 0x800); + + POLY_OPA_DISP = sp1CC; + } + + if (HREG(15) == 2) { + HREG(15) = 1; + HREG(14) = 6100; + HREG(13) = 5300; + } + + if (ZREG(38) == 0) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + + func_800949A8(gfxCtx); + + gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, + PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 235, 235, 235, pauseCtx->alpha); + + for (k = 0; k < 15; k += 8) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[60 + k * 4], 32, 0); + + for (j = i = 0; i < 8; i++, j += 4) { + if (!(gSaveContext.worldMapAreaData & gBitFlags[cloudFlagNums[k + i]])) { + gDPLoadTextureBlock_4b(POLY_OPA_DISP++, cloudTexs[k + i], G_IM_FMT_I, D_8082AAEC[k + i], + D_8082AB2C[k + i], 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + + if (1) {} + } + } + } + } + + if (gSaveContext.worldMapArea < 22) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); + + pauseCtx->mapPageVtx[172].v.ob[0] = pauseCtx->mapPageVtx[174].v.ob[0] = + areaBoxPosX[((void)0, gSaveContext.worldMapArea)]; + + pauseCtx->mapPageVtx[173].v.ob[0] = pauseCtx->mapPageVtx[175].v.ob[0] = + pauseCtx->mapPageVtx[172].v.ob[0] + areaBoxWidths[((void)0, gSaveContext.worldMapArea)]; + + pauseCtx->mapPageVtx[172].v.ob[1] = pauseCtx->mapPageVtx[173].v.ob[1] = + areaBoxPosY[((void)0, gSaveContext.worldMapArea)] + pauseCtx->offsetY; + + pauseCtx->mapPageVtx[174].v.ob[1] = pauseCtx->mapPageVtx[175].v.ob[1] = + pauseCtx->mapPageVtx[172].v.ob[1] - areaBoxHeights[((void)0, gSaveContext.worldMapArea)]; + + pauseCtx->mapPageVtx[173].v.tc[0] = pauseCtx->mapPageVtx[175].v.tc[0] = + areaBoxWidths[((void)0, gSaveContext.worldMapArea)] << 5; + + pauseCtx->mapPageVtx[174].v.tc[1] = pauseCtx->mapPageVtx[175].v.tc[1] = + areaBoxHeights[((void)0, gSaveContext.worldMapArea)] << 5; + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[172], 4, 0); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 255, 255, pauseCtx->alpha); + + gDPLoadTextureBlock_4b(POLY_OPA_DISP++, areaBoxTexs[((void)0, (gSaveContext.worldMapArea))], G_IM_FMT_IA, + areaBoxWidths[((void)0, (gSaveContext.worldMapArea))], + areaBoxHeights[((void)0, (gSaveContext.worldMapArea))], 0, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + } + + stepR = ABS(pointPulsePrimColor[0] - pointPrimColors[pointPulseStage][0]) / pointPulseTimer; + stepG = ABS(pointPulsePrimColor[1] - pointPrimColors[pointPulseStage][1]) / pointPulseTimer; + stepB = ABS(pointPulsePrimColor[2] - pointPrimColors[pointPulseStage][2]) / pointPulseTimer; + if (pointPulsePrimColor[0] >= pointPrimColors[pointPulseStage][0]) { + pointPulsePrimColor[0] -= stepR; + } else { + pointPulsePrimColor[0] += stepR; + } + if (pointPulsePrimColor[1] >= pointPrimColors[pointPulseStage][1]) { + pointPulsePrimColor[1] -= stepG; + } else { + pointPulsePrimColor[1] += stepG; + } + if (pointPulsePrimColor[2] >= pointPrimColors[pointPulseStage][2]) { + pointPulsePrimColor[2] -= stepB; + } else { + pointPulsePrimColor[2] += stepB; + } + + stepR = ABS(pointPulseEnvColor[0] - pointEnvColors[pointPulseStage][0]) / pointPulseTimer; + stepG = ABS(pointPulseEnvColor[1] - pointEnvColors[pointPulseStage][1]) / pointPulseTimer; + stepB = ABS(pointPulseEnvColor[2] - pointEnvColors[pointPulseStage][2]) / pointPulseTimer; + if (pointPulseEnvColor[0] >= pointEnvColors[pointPulseStage][0]) { + pointPulseEnvColor[0] -= stepR; + } else { + pointPulseEnvColor[0] += stepR; + } + if (pointPulseEnvColor[1] >= pointEnvColors[pointPulseStage][1]) { + pointPulseEnvColor[1] -= stepG; + } else { + pointPulseEnvColor[1] += stepG; + } + if (pointPulseEnvColor[2] >= pointEnvColors[pointPulseStage][2]) { + pointPulseEnvColor[2] -= stepB; + } else { + pointPulseEnvColor[2] += stepB; + } + + pointPulseTimer--; + if (pointPulseTimer == 0) { + pointPulsePrimColor[0] = pointPrimColors[pointPulseStage][0]; + pointPulsePrimColor[1] = pointPrimColors[pointPulseStage][1]; + pointPulsePrimColor[2] = pointPrimColors[pointPulseStage][2]; + pointPulseEnvColor[0] = pointEnvColors[pointPulseStage][0]; + pointPulseEnvColor[1] = pointEnvColors[pointPulseStage][1]; + pointPulseEnvColor[2] = pointEnvColors[pointPulseStage][2]; + pointPulseStage ^= 1; + pointPulseTimer = 20; + } + + func_800949A8(gfxCtx); + + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + gDPLoadTextureBlock(POLY_OPA_DISP++, gWorldMapDotTex, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0, G_TX_WRAP | G_TX_NOMIRROR, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + for (j = i = 0; i < 12; i++, t++, j += 4) { + if (pauseCtx->worldMapPoints[i] != 0) { + gDPPipeSync(POLY_OPA_DISP++); + + if (pauseCtx->worldMapPoints[i] == 1) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pointPrimColors[0][0], pointPrimColors[0][1], + pointPrimColors[0][2], pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, pointEnvColors[0][0], pointEnvColors[0][1], pointEnvColors[0][2], 0); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, pointPulsePrimColor[0], pointPulsePrimColor[1], + pointPulsePrimColor[2], pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, pointPulseEnvColor[0], pointPulseEnvColor[1], pointPulseEnvColor[2], 0); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[124 + i * 4], 4, 0); + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + KaleidoScope_DrawCursor(globalCtx, PAUSE_MAP); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[176], 16, 0); + + if (pauseCtx->tradeQuestLocation != 0xFF) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, pointPulsePrimColor[0], 0, pauseCtx->alpha); + + gDPLoadTextureBlock(POLY_OPA_DISP++, gWorldMapArrowTex, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + + if (gSaveContext.worldMapArea < 22) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 150, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, pauseCtx->nameSegment + 0x400, 80, 32, 4); + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, + PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, pauseCtx->alpha); + + gDPLoadTextureBlock_4b(POLY_OPA_DISP++, currentPosTitleTexs[gSaveContext.language], G_IM_FMT_I, 64, 8, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSP1Quadrangle(POLY_OPA_DISP++, 8, 10, 11, 9, 0); + + gDPPipeSync(POLY_OPA_DISP++); + + CLOSE_DISPS(gfxCtx, "../z_kaleido_map_PAL.c", 874); +} diff --git a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_prompt.c b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_prompt.c new file mode 100644 index 000000000..c16404fb2 --- /dev/null +++ b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_prompt.c @@ -0,0 +1,34 @@ +#include "z_kaleido_scope.h" + +static s16 D_8082A6E0[] = { 100, 255 }; + +void KaleidoScope_UpdatePrompt(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + Input* input = &globalCtx->state.input[0]; + s8 relStickX = input->rel.stick_x; + s16 step; + + if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC == 1)) || (pauseCtx->state == 0xE) || (pauseCtx->state == 0x10)) { + if ((pauseCtx->promptChoice == 0) && (relStickX >= 30)) { + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pauseCtx->promptChoice = 4; + } else if ((pauseCtx->promptChoice != 0) && (relStickX <= -30)) { + Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pauseCtx->promptChoice = 0; + } + + step = ABS(VREG(61) - D_8082A6E0[VREG(62)]) / VREG(63); + if (VREG(61) >= D_8082A6E0[VREG(62)]) { + VREG(61) -= step; + } else { + VREG(61) += step; + } + + VREG(63)--; + if (VREG(63) == 0) { + VREG(61) = D_8082A6E0[VREG(62)]; + VREG(63) = VREG(60) + VREG(62); + VREG(62) ^= 1; + } + } +} diff --git a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_scope.h new file mode 100644 index 000000000..7b2eb579a --- /dev/null +++ b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_scope.h @@ -0,0 +1,36 @@ +#ifndef _Z_KALEIDO_SCOPE_H_ +#define _Z_KALEIDO_SCOPE_H_ + +#include "ultra64.h" +#include "global.h" + +extern u8 gAmmoItems[]; +extern s16 D_8082AAEC[]; +extern s16 D_8082AB2C[]; +extern u8 gSlotAgeReqs[]; +extern u8 gEquipAgeReqs[][4]; +extern u8 gAreaGsFlags[]; + +void KaleidoScope_DrawQuestStatus(GlobalContext* globalCtx, GraphicsContext* gfxCtx); +s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s32 point); +void KaleidoScope_DrawDebugEditor(GlobalContext* globalCtx); +void KaleidoScope_DrawPlayerWork(GlobalContext* globalCtx); +void KaleidoScope_DrawEquipment(GlobalContext* globalCtx); +void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx); +void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx); +void KaleidoScope_UpdateItemEquip(GlobalContext* globalCtx); +void KaleidoScope_DrawDungeonMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx); +void KaleidoScope_DrawWorldMap(GlobalContext* globalCtx, GraphicsContext* gfxCtx); +void KaleidoScope_UpdatePrompt(GlobalContext* globalCtx); +Gfx* KaleidoScope_QuadTextureIA4(Gfx* gfx, void* texture, s16 width, s16 height, u16 point); +Gfx* KaleidoScope_QuadTextureIA8(Gfx* gfx, void* texture, s16 width, s16 height, u16 point); +void KaleidoScope_MoveCursorToSpecialPos(GlobalContext* globalCtx, u16 specialPos); +void KaleidoScope_DrawQuadTextureRGBA32(GraphicsContext* gfxCtx, void* texture, u16 width, u16 height, u16 point); +void KaleidoScope_ProcessPlayerPreRender(); +void KaleidoScope_SetupPlayerPreRender(GlobalContext* globalCtx); +void KaleidoScope_DrawCursor(GlobalContext* globalCtx, u16 pageIndex); +void KaleidoScope_UpdateDungeonMap(GlobalContext* globalCtx); + +void PauseMapMark_Draw(GlobalContext* globalCtx); + +#endif diff --git a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 20b780598..9ae1a1d38 100644 --- a/src/overlays/actors/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/src/overlays/actors/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -1,44 +1,2259 @@ -#include "global.h" +#include "z_kaleido_scope.h" +#include "textures/icon_item_static/icon_item_static.h" +#include "textures/icon_item_24_static/icon_item_24_static.h" +#include "textures/icon_item_nes_static/icon_item_nes_static.h" +#include "textures/icon_item_ger_static/icon_item_ger_static.h" +#include "textures/icon_item_fra_static/icon_item_fra_static.h" +#include "textures/icon_item_gameover_static/icon_item_gameover_static.h" +#include "vt.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081F1F0.s") +static void* sEquipmentFRATexs[] = { + gPauseEquipment00FRATex, gPauseEquipment01Tex, gPauseEquipment02Tex, gPauseEquipment03Tex, gPauseEquipment04Tex, + gPauseEquipment10FRATex, gPauseEquipment11Tex, gPauseEquipment12Tex, gPauseEquipment13Tex, gPauseEquipment14Tex, + gPauseEquipment20FRATex, gPauseEquipment21Tex, gPauseEquipment22Tex, gPauseEquipment23Tex, gPauseEquipment24Tex, +}; +static void* sSelectItemFRATexs[] = { + gPauseSelectItem00FRATex, gPauseSelectItem01Tex, gPauseSelectItem02Tex, gPauseSelectItem03Tex, + gPauseSelectItem04Tex, gPauseSelectItem10FRATex, gPauseSelectItem11Tex, gPauseSelectItem12Tex, + gPauseSelectItem13Tex, gPauseSelectItem14Tex, gPauseSelectItem20FRATex, gPauseSelectItem21Tex, + gPauseSelectItem22Tex, gPauseSelectItem23Tex, gPauseSelectItem24Tex, +}; +static void* sMapFRATexs[] = { + gPauseMap00Tex, gPauseMap01Tex, gPauseMap02Tex, gPauseMap03Tex, gPauseMap04Tex, + gPauseMap10FRATex, gPauseMap11Tex, gPauseMap12Tex, gPauseMap13Tex, gPauseMap14Tex, + gPauseMap20Tex, gPauseMap21Tex, gPauseMap22Tex, gPauseMap23Tex, gPauseMap24Tex, +}; +static void* sQuestStatusFRATexs[] = { + gPauseQuestStatus00Tex, gPauseQuestStatus01Tex, gPauseQuestStatus02Tex, gPauseQuestStatus03Tex, + gPauseQuestStatus04Tex, gPauseQuestStatus10FRATex, gPauseQuestStatus11Tex, gPauseQuestStatus12Tex, + gPauseQuestStatus13Tex, gPauseQuestStatus14Tex, gPauseQuestStatus20Tex, gPauseQuestStatus21Tex, + gPauseQuestStatus22Tex, gPauseQuestStatus23Tex, gPauseQuestStatus24Tex, +}; +static void* sSaveFRATexs[] = { + gPauseSave00FRATex, gPauseSave01Tex, gPauseSave02Tex, gPauseSave03Tex, gPauseSave04Tex, + gPauseSave10FRATex, gPauseSave11Tex, gPauseSave12Tex, gPauseSave13Tex, gPauseSave14Tex, + gPauseSave20FRATex, gPauseSave21Tex, gPauseSave22Tex, gPauseSave23Tex, gPauseSave24Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081F2FC.s") +static void* sEquipmentGERTexs[] = { + gPauseEquipment00GERTex, gPauseEquipment01Tex, gPauseEquipment02Tex, gPauseEquipment03Tex, gPauseEquipment04Tex, + gPauseEquipment10GERTex, gPauseEquipment11Tex, gPauseEquipment12Tex, gPauseEquipment13Tex, gPauseEquipment14Tex, + gPauseEquipment20GERTex, gPauseEquipment21Tex, gPauseEquipment22Tex, gPauseEquipment23Tex, gPauseEquipment24Tex, +}; +static void* sSelectItemGERTexs[] = { + gPauseSelectItem00GERTex, gPauseSelectItem01Tex, gPauseSelectItem02Tex, gPauseSelectItem03Tex, + gPauseSelectItem04Tex, gPauseSelectItem10GERTex, gPauseSelectItem11Tex, gPauseSelectItem12Tex, + gPauseSelectItem13Tex, gPauseSelectItem14Tex, gPauseSelectItem20GERTex, gPauseSelectItem21Tex, + gPauseSelectItem22Tex, gPauseSelectItem23Tex, gPauseSelectItem24Tex, +}; +static void* sMapGERTexs[] = { + gPauseMap00Tex, gPauseMap01Tex, gPauseMap02Tex, gPauseMap03Tex, gPauseMap04Tex, + gPauseMap10GERTex, gPauseMap11Tex, gPauseMap12Tex, gPauseMap13Tex, gPauseMap14Tex, + gPauseMap20Tex, gPauseMap21Tex, gPauseMap22Tex, gPauseMap23Tex, gPauseMap24Tex, +}; +static void* sQuestStatusGERTexs[] = { + gPauseQuestStatus00Tex, gPauseQuestStatus01Tex, gPauseQuestStatus02Tex, gPauseQuestStatus03Tex, + gPauseQuestStatus04Tex, gPauseQuestStatus10GERTex, gPauseQuestStatus11Tex, gPauseQuestStatus12Tex, + gPauseQuestStatus13Tex, gPauseQuestStatus14Tex, gPauseQuestStatus20Tex, gPauseQuestStatus21Tex, + gPauseQuestStatus22Tex, gPauseQuestStatus23Tex, gPauseQuestStatus24Tex, +}; +static void* sSaveGERTexs[] = { + gPauseSave00Tex, gPauseSave01Tex, gPauseSave02Tex, gPauseSave03Tex, gPauseSave04Tex, + gPauseSave10GERTex, gPauseSave11Tex, gPauseSave12Tex, gPauseSave13Tex, gPauseSave14Tex, + gPauseSave20GERTex, gPauseSave21Tex, gPauseSave22Tex, gPauseSave23Tex, gPauseSave24Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081F334.s") +static void* sEquipmentENGTexs[] = { + gPauseEquipment00Tex, gPauseEquipment01Tex, gPauseEquipment02Tex, gPauseEquipment03Tex, gPauseEquipment04Tex, + gPauseEquipment10ENGTex, gPauseEquipment11Tex, gPauseEquipment12Tex, gPauseEquipment13Tex, gPauseEquipment14Tex, + gPauseEquipment20Tex, gPauseEquipment21Tex, gPauseEquipment22Tex, gPauseEquipment23Tex, gPauseEquipment24Tex, +}; +static void* sSelectItemENGTexs[] = { + gPauseSelectItem00ENGTex, gPauseSelectItem01Tex, gPauseSelectItem02Tex, gPauseSelectItem03Tex, + gPauseSelectItem04Tex, gPauseSelectItem10ENGTex, gPauseSelectItem11Tex, gPauseSelectItem12Tex, + gPauseSelectItem13Tex, gPauseSelectItem14Tex, gPauseSelectItem20ENGTex, gPauseSelectItem21Tex, + gPauseSelectItem22Tex, gPauseSelectItem23Tex, gPauseSelectItem24Tex, +}; +static void* sMapENGTexs[] = { + gPauseMap00Tex, gPauseMap01Tex, gPauseMap02Tex, gPauseMap03Tex, gPauseMap04Tex, + gPauseMap10ENGTex, gPauseMap11Tex, gPauseMap12Tex, gPauseMap13Tex, gPauseMap14Tex, + gPauseMap20Tex, gPauseMap21Tex, gPauseMap22Tex, gPauseMap23Tex, gPauseMap24Tex, +}; +static void* sQuestStatusENGTexs[] = { + gPauseQuestStatus00ENGTex, gPauseQuestStatus01Tex, gPauseQuestStatus02Tex, gPauseQuestStatus03Tex, + gPauseQuestStatus04Tex, gPauseQuestStatus10ENGTex, gPauseQuestStatus11Tex, gPauseQuestStatus12Tex, + gPauseQuestStatus13Tex, gPauseQuestStatus14Tex, gPauseQuestStatus20ENGTex, gPauseQuestStatus21Tex, + gPauseQuestStatus22Tex, gPauseQuestStatus23Tex, gPauseQuestStatus24Tex, +}; +static void* sSaveENGTexs[] = { + gPauseSave00Tex, gPauseSave01Tex, gPauseSave02Tex, gPauseSave03Tex, gPauseSave04Tex, + gPauseSave10ENGTex, gPauseSave11Tex, gPauseSave12Tex, gPauseSave13Tex, gPauseSave14Tex, + gPauseSave20Tex, gPauseSave21Tex, gPauseSave22Tex, gPauseSave23Tex, gPauseSave24Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081F50C.s") +static void* sGameOverTexs[] = { + gPauseSave00Tex, gPauseSave01Tex, gPauseSave02Tex, gPauseSave03Tex, gPauseSave04Tex, + gPauseGameOver10Tex, gPauseSave11Tex, gPauseSave12Tex, gPauseSave13Tex, gPauseSave14Tex, + gPauseSave20Tex, gPauseSave21Tex, gPauseSave22Tex, gPauseSave23Tex, gPauseSave24Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081F6E4.s") +static void* sEquipmentTexs[] = { + sEquipmentENGTexs, + sEquipmentGERTexs, + sEquipmentFRATexs, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081F81C.s") +static void* sSelectItemTexs[] = { + sSelectItemENGTexs, + sSelectItemGERTexs, + sSelectItemFRATexs, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081F87C.s") +static void* sMapTexs[] = { + sMapENGTexs, + sMapGERTexs, + sMapFRATexs, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081FABC.s") +static void* sQuestStatusTexs[] = { + sQuestStatusENGTexs, + sQuestStatusGERTexs, + sQuestStatusFRATexs, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081FB7C.s") +static void* sSaveTexs[] = { + sSaveENGTexs, + sSaveGERTexs, + sSaveFRATexs, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081FCF4.s") +s16 D_8082AAEC[] = { + 32, 112, 32, 48, 32, 32, 32, 48, 32, 64, 32, 48, 48, 48, 48, 64, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 80, 64, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8081FE30.s") +s16 D_8082AB2C[] = { + 24, 72, 13, 22, 19, 20, 19, 27, 14, 26, 22, 21, 49, 32, 45, 60, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 32, 8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8082018C.s") +static u8 D_8082AB6C[][5] = { + { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, + { BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_DISABLED }, + { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED }, + { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, + { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED }, + { BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_DISABLED }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80820434.s") +static s16 D_8082AB8C = 0; +static s16 D_8082AB90 = 0; +static s16 D_8082AB94 = 0; +static s16 D_8082AB98 = 255; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80821C10.s") +static s16 D_8082AB9C = 255; +static s16 D_8082ABA0 = 0; +static s16 D_8082ABA4 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80823548.s") +static s16 sInDungeonScene = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_808237B4.s") +static f32 D_8082ABAC[] = { + -4.0f, 4.0f, 4.0f, 4.0f, 4.0f, -4.0f, -4.0f, -4.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80823994.s") +static f32 D_8082ABCC[] = { + -4.0f, -4.0f, -4.0f, 4.0f, 4.0f, 4.0f, 4.0f, -4.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80823A0C.s") +static u16 D_8082ABEC[] = { + PAUSE_MAP, PAUSE_EQUIP, PAUSE_QUEST, PAUSE_ITEM, PAUSE_EQUIP, PAUSE_MAP, PAUSE_ITEM, PAUSE_QUEST, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8082409C.s") +u8 gSlotAgeReqs[] = { + 1, 9, 9, 0, 0, 9, 1, 9, 9, 0, 0, 9, 1, 9, 1, 0, 0, 9, 9, 9, 9, 9, 0, 1, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80825C14.s") +u8 gEquipAgeReqs[][4] = { + { 0, 1, 0, 0 }, + { 9, 1, 9, 0 }, + { 0, 9, 0, 0 }, + { 9, 9, 0, 0 }, +}; + +u8 gItemAgeReqs[] = { + 1, 9, 9, 0, 0, 9, 1, 9, 9, 9, 0, 0, 0, 9, 1, 9, 1, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 1, 9, 0, 9, 0, 0, 9, 0, 0, 1, 1, 1, 0, 0, 0, 9, 9, 9, 1, 0, 0, 9, 9, 0, +}; + +u8 gAreaGsFlags[] = { + 0x0F, 0x1F, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x07, 0x07, 0x03, + 0x0F, 0x07, 0x0F, 0x0F, 0xFF, 0xFF, 0xFF, 0x1F, 0x0F, 0x03, 0x0F, +}; + +static void* sCursorTexs[] = { + gPauseMenuCursorTopLeftTex, + gPauseMenuCursorTopRightTex, + gPauseMenuCursorBottomLeftTex, + gPauseMenuCursorBottomRightTex, +}; + +static s16 sCursorColors[][3] = { + { 255, 255, 255 }, + { 255, 255, 0 }, + { 0, 255, 50 }, +}; + +static void* sSavePromptTexs[] = { + gPauseSavePromptENGTex, + gPauseSavePromptGERTex, + gPauseSavePromptFRATex, +}; + +static void* sSaveConfirmationTexs[] = { + gPauseSaveConfirmationENGTex, + gPauseSaveConfirmationGERTex, + gPauseSaveConfirmationFRATex, +}; + +static void* sContinuePromptTexs[] = { + gContinuePlayingENGTex, + gContinuePlayingGERTex, + gContinuePlayingFRATex, +}; + +static void* sPromptChoiceTexs[][2] = { + { gPauseYesENGTex, gPauseNoENGTex }, + { gPauseYesGERTex, gPauseNoGERTex }, + { gPauseYesFRATex, gPauseNoFRATex }, +}; + +static u8 D_808321A8[5]; +static PreRenderContext sPlayerPreRenderCtx; +static void* sPreRenderCvg; + +void KaleidoScope_SetupPlayerPreRender(GlobalContext* globalCtx) { + Gfx* gfx; + Gfx* gfxRef; + void* fbuf; + + fbuf = globalCtx->state.gfxCtx->curFrameBuffer; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 496); + + gfxRef = POLY_OPA_DISP; + gfx = Graph_GfxPlusOne(gfxRef); + gSPDisplayList(WORK_DISP++, gfx); + + PreRender_SetValues(&sPlayerPreRenderCtx, 64, 112, fbuf, NULL); + func_800C1F20(&sPlayerPreRenderCtx, &gfx); + func_800C20B4(&sPlayerPreRenderCtx, &gfx); + + gSPEndDisplayList(gfx++); + Graph_BranchDlist(gfxRef, gfx); + POLY_OPA_DISP = gfx; + + SREG(33) |= 1; + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 509); +} + +void KaleidoScope_ProcessPlayerPreRender(void) { + Sleep_Msec(50); + PreRender_Calc(&sPlayerPreRenderCtx); + PreRender_Destroy(&sPlayerPreRenderCtx); +} + +Gfx* KaleidoScope_QuadTextureIA4(Gfx* gfx, void* texture, s16 width, s16 height, u16 point) { + gDPLoadTextureBlock_4b(gfx++, texture, G_IM_FMT_IA, width, height, 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(gfx++, point, point + 2, point + 3, point + 1, 0); + + return gfx; +} + +Gfx* KaleidoScope_QuadTextureIA8(Gfx* gfx, void* texture, s16 width, s16 height, u16 point) { + gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 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(gfx++, point, point + 2, point + 3, point + 1, 0); + + return gfx; +} + +void KaleidoScope_OverridePalIndexCI4(u8* texture, s32 size, s32 targetIndex, s32 newIndex) { + s32 i; + + targetIndex &= 0xF; + newIndex &= 0xF; + + if ((size == 0) || (targetIndex == newIndex) || (texture == NULL)) { + return; + } + + for (i = 0; i < size; i++) { + s32 index1; + s32 index2; + + index1 = index2 = texture[i]; + + index1 = (index1 >> 4) & 0xF; + index2 = index2 & 0xF; + + if (index1 == targetIndex) { + index1 = newIndex; + } + + if (index2 == targetIndex) { + index2 = newIndex; + } + + texture[i] = (index1 << 4) | index2; + } +} + +void KaleidoScope_MoveCursorToSpecialPos(GlobalContext* globalCtx, u16 specialPos) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + + pauseCtx->cursorSpecialPos = specialPos; + pauseCtx->pageSwitchTimer = 0; + + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); +} + +void KaleidoScope_DrawQuadTextureRGBA32(GraphicsContext* gfxCtx, void* texture, u16 width, u16 height, u16 point) { + OPEN_DISPS(gfxCtx, "../z_kaleido_scope_PAL.c", 748); + + gDPLoadTextureBlock(POLY_OPA_DISP++, texture, G_IM_FMT_RGBA, G_IM_SIZ_32b, width, height, 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++, point, point + 2, point + 3, point + 1, 0); + + CLOSE_DISPS(gfxCtx, "../z_kaleido_scope_PAL.c", 758); +} + +void KaleidoScope_SetDefaultCursor(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 s; + s16 i; + + switch (pauseCtx->pageIndex) { + case PAUSE_ITEM: + s = pauseCtx->cursorSlot[PAUSE_ITEM]; + if (gSaveContext.inventory.items[s] == ITEM_NONE) { + i = s + 1; + while (true) { + if (gSaveContext.inventory.items[i] != ITEM_NONE) { + break; + } + i++; + if (i >= 24) { + i = 0; + } + if (i == s) { + pauseCtx->cursorItem[PAUSE_ITEM] = pauseCtx->namedItem = PAUSE_ITEM_NONE; + return; + } + } + pauseCtx->cursorItem[PAUSE_ITEM] = gSaveContext.inventory.items[i]; + pauseCtx->cursorSlot[PAUSE_ITEM] = i; + } + break; + case PAUSE_MAP: + case PAUSE_QUEST: + case PAUSE_EQUIP: + break; + } +} + +void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) { + pauseCtx->unk_1E4 = 1; + pauseCtx->unk_1EA = 0; + + if (!pt) { + pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; + Audio_PlaySoundGeneral(NA_SE_SY_WIN_SCROLL_LEFT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_RIGHT; + } else { + pauseCtx->mode = pauseCtx->pageIndex * 2; + Audio_PlaySoundGeneral(NA_SE_SY_WIN_SCROLL_RIGHT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; + } + + gSaveContext.buttonStatus[1] = D_8082AB6C[pauseCtx->pageIndex + pt][1]; + gSaveContext.buttonStatus[2] = D_8082AB6C[pauseCtx->pageIndex + pt][2]; + gSaveContext.buttonStatus[3] = D_8082AB6C[pauseCtx->pageIndex + pt][3]; + gSaveContext.buttonStatus[4] = D_8082AB6C[pauseCtx->pageIndex + pt][4]; + + osSyncPrintf("kscope->kscp_pos+pt = %d\n", pauseCtx->pageIndex + pt); + + gSaveContext.unk_13EA = 0; + Interface_ChangeAlpha(50); +} + +void KaleidoScope_HandlePageToggles(PauseContext* pauseCtx, Input* input) { + if ((pauseCtx->debugState == 0) && CHECK_BTN_ALL(input->press.button, BTN_L)) { + pauseCtx->debugState = 1; + return; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_R)) { + KaleidoScope_SwitchPage(pauseCtx, 2); + return; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { + KaleidoScope_SwitchPage(pauseCtx, 0); + return; + } + + if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickRelX < -30) { + pauseCtx->pageSwitchTimer++; + if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) { + KaleidoScope_SwitchPage(pauseCtx, 0); + } + } else { + pauseCtx->pageSwitchTimer = -1; + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) { + if (pauseCtx->stickRelX > 30) { + pauseCtx->pageSwitchTimer++; + if ((pauseCtx->pageSwitchTimer >= 10) || (pauseCtx->pageSwitchTimer == 0)) { + KaleidoScope_SwitchPage(pauseCtx, 2); + } + } else { + pauseCtx->pageSwitchTimer = -1; + } + } +} + +void KaleidoScope_DrawCursor(GlobalContext* globalCtx, u16 pageIndex) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + u16 temp; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 955); + + temp = pauseCtx->unk_1E4; + + if ((((pauseCtx->unk_1E4 == 0) || (temp == 8)) && (pauseCtx->state == 6)) || + ((pauseCtx->pageIndex == PAUSE_QUEST) && ((temp < 3) || (temp == 5) || (temp == 8)))) { + + if (pauseCtx->pageIndex == pageIndex) { + s16 i; + s16 j; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sCursorColors[pauseCtx->cursorColorSet >> 2][0], + sCursorColors[pauseCtx->cursorColorSet >> 2][1], + sCursorColors[pauseCtx->cursorColorSet >> 2][2], 255); + gDPSetEnvColor(POLY_OPA_DISP++, D_8082AB8C, D_8082AB90, D_8082AB94, 255); + gSPVertex(POLY_OPA_DISP++, pauseCtx->cursorVtx, 16, 0); + + for (i = j = 0; i < 4; i++, j += 4) { + gDPLoadTextureBlock_4b(POLY_OPA_DISP++, sCursorTexs[i], G_IM_FMT_IA, 16, 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++, j, j + 2, j + 3, j + 1, 0); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 985); +} + +Gfx* KaleidoScope_DrawPageSections(Gfx* gfx, Vtx* vertices, void** textures) { + s32 i; + s32 j; + + gSPVertex(gfx++, vertices, 32, 0); + + i = 0; + j = 0; + while (j < 32) { + gDPPipeSync(gfx++); + gDPLoadTextureBlock(gfx++, textures[i], G_IM_FMT_IA, G_IM_SIZ_8b, 80, 32, 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(gfx++, j, j + 2, j + 3, j + 1, 0); + + if (1) {} + + j += 4; + i++; + } + + gSPVertex(gfx++, vertices + 32, 28, 0); + + j = 0; + while (j < 28) { + gDPPipeSync(gfx++); + gDPLoadTextureBlock(gfx++, textures[i], G_IM_FMT_IA, G_IM_SIZ_8b, 80, 32, 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(gfx++, j, j + 2, j + 3, j + 1, 0); + + if (1) {} + + j += 4; + i++; + } + + return gfx; +} + +void KaleidoScope_DrawPages(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { + static s16 D_8082ACF4[][3] = { + { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 255, 255, 0 }, { 0, 0, 0 }, + { 0, 0, 0 }, { 255, 255, 0 }, { 0, 255, 50 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 255, 50 }, + }; + static s16 D_8082AD3C = 20; + static s16 D_8082AD40 = 0; + static s16 D_8082AD44 = 0; + static s16 D_8082AD48 = 0; + static s16 D_8082AD4C = 0; + static s16 D_8082AD50 = 0; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 stepR; + s16 stepG; + s16 stepB; + + OPEN_DISPS(gfxCtx, "../z_kaleido_scope_PAL.c", 1100); + + if ((pauseCtx->state < 8) || (pauseCtx->state > 0x11)) { + if (pauseCtx->state != 7) { + stepR = ABS(D_8082AB8C - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][0]) / D_8082AD3C; + stepG = ABS(D_8082AB90 - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][1]) / D_8082AD3C; + stepB = ABS(D_8082AB94 - D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][2]) / D_8082AD3C; + if (D_8082AB8C >= D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][0]) { + D_8082AB8C -= stepR; + } else { + D_8082AB8C += stepR; + } + if (D_8082AB90 >= D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][1]) { + D_8082AB90 -= stepG; + } else { + D_8082AB90 += stepG; + } + if (D_8082AB94 >= D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][2]) { + D_8082AB94 -= stepB; + } else { + D_8082AB94 += stepB; + } + + D_8082AD3C--; + if (D_8082AD3C == 0) { + D_8082AB8C = D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][0]; + D_8082AB90 = D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][1]; + D_8082AB94 = D_8082ACF4[pauseCtx->cursorColorSet + D_8082AD40][2]; + D_8082AD3C = ZREG(28 + D_8082AD40); + D_8082AD40++; + if (D_8082AD40 >= 4) { + D_8082AD40 = 0; + } + } + + if (pauseCtx->stickRelX < -30) { + if (D_8082AD4C == -1) { + if (--D_8082AD44 < 0) { + D_8082AD44 = XREG(6); + } else { + pauseCtx->stickRelX = 0; + } + } else { + D_8082AD44 = XREG(8); + D_8082AD4C = -1; + } + } else if (pauseCtx->stickRelX > 30) { + if (D_8082AD4C == 1) { + if (--D_8082AD44 < 0) { + D_8082AD44 = XREG(6); + } else { + pauseCtx->stickRelX = 0; + } + } else { + D_8082AD44 = XREG(8); + D_8082AD4C = 1; + } + } else { + D_8082AD4C = 0; + } + + if (pauseCtx->stickRelY < -30) { + if (D_8082AD50 == -1) { + if (--D_8082AD48 < 0) { + D_8082AD48 = XREG(6); + } else { + pauseCtx->stickRelY = 0; + } + } else { + D_8082AD48 = XREG(8); + D_8082AD50 = -1; + } + } else if (pauseCtx->stickRelY > 30) { + if (D_8082AD50 == 1) { + if (--D_8082AD48 < 0) { + D_8082AD48 = XREG(6); + } else { + pauseCtx->stickRelY = 0; + } + } else { + D_8082AD48 = XREG(8); + D_8082AD50 = 1; + } + } else { + D_8082AD50 = 0; + } + } + + if (pauseCtx->pageIndex) { // pageIndex != PAUSE_ITEM + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + + Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, -(f32)WREG(3) / 100.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX(-pauseCtx->unk_1F4 / 100.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1173), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, + sSelectItemTexs[gSaveContext.language]); + + KaleidoScope_DrawItemSelect(globalCtx); + } + + if (pauseCtx->pageIndex != PAUSE_EQUIP) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + + Matrix_Translate(-(f32)WREG(3) / 100.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateZ(pauseCtx->unk_1F8 / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(1.57f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1196), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->equipPageVtx, + sEquipmentTexs[gSaveContext.language]); + + KaleidoScope_DrawEquipment(globalCtx); + } + + if (pauseCtx->pageIndex != PAUSE_QUEST) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + + Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, (f32)WREG(3) / 100.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX(pauseCtx->unk_200 / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(3.14f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1220), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, + sQuestStatusTexs[gSaveContext.language]); + + KaleidoScope_DrawQuestStatus(globalCtx, gfxCtx); + } + + if (pauseCtx->pageIndex != PAUSE_MAP) { + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + + Matrix_Translate((f32)WREG(3) / 100.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateZ(-pauseCtx->unk_1FC / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(-1.57f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1243), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapTexs[gSaveContext.language]); + + if (sInDungeonScene) { + KaleidoScope_DrawDungeonMap(globalCtx, gfxCtx); + func_800949A8(gfxCtx); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + if (CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, gSaveContext.mapIndex)) { + PauseMapMark_Draw(globalCtx); + } + } else { + KaleidoScope_DrawWorldMap(globalCtx, gfxCtx); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + + switch (pauseCtx->pageIndex) { + case PAUSE_ITEM: + Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, -(f32)WREG(3) / 100.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX(-pauseCtx->unk_1F4 / 100.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1281), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, + sSelectItemTexs[gSaveContext.language]); + + KaleidoScope_DrawItemSelect(globalCtx); + break; + + case PAUSE_MAP: + Matrix_Translate((f32)WREG(3) / 100.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateZ(-pauseCtx->unk_1FC / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(-1.57f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1303), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapTexs[gSaveContext.language]); + + if (sInDungeonScene) { + KaleidoScope_DrawDungeonMap(globalCtx, gfxCtx); + func_800949A8(gfxCtx); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + if (pauseCtx->cursorSpecialPos == 0) { + KaleidoScope_DrawCursor(globalCtx, PAUSE_MAP); + } + + if (CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, gSaveContext.mapIndex)) { + PauseMapMark_Draw(globalCtx); + } + } else { + KaleidoScope_DrawWorldMap(globalCtx, gfxCtx); + } + break; + + case PAUSE_QUEST: + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + + Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, (f32)WREG(3) / 100.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX(pauseCtx->unk_200 / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(3.14f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1343), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, + sQuestStatusTexs[gSaveContext.language]); + + KaleidoScope_DrawQuestStatus(globalCtx, gfxCtx); + + if (pauseCtx->cursorSpecialPos == 0) { + KaleidoScope_DrawCursor(globalCtx, PAUSE_QUEST); + } + break; + + case PAUSE_EQUIP: + Matrix_Translate(-(f32)WREG(3) / 100.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateZ(pauseCtx->unk_1F8 / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(1.57f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1367), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->equipPageVtx, + sEquipmentTexs[gSaveContext.language]); + + KaleidoScope_DrawEquipment(globalCtx); + + if (pauseCtx->cursorSpecialPos == 0) { + KaleidoScope_DrawCursor(globalCtx, PAUSE_EQUIP); + } + break; + } + } + + func_800949A8(gfxCtx); + + if ((pauseCtx->state == 7) || ((pauseCtx->state >= 8) && (pauseCtx->state < 0x12))) { + KaleidoScope_UpdatePrompt(globalCtx); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + + if (!pauseCtx->pageIndex) { // pageIndex == PAUSE_ITEM + pauseCtx->unk_1F4 = pauseCtx->unk_204 + 314.0f; + + Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, -pauseCtx->unk_1F0 / 10.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX(-pauseCtx->unk_204 / 100.0f, MTXMODE_APPLY); + } else if (pauseCtx->pageIndex == PAUSE_MAP) { + pauseCtx->unk_1FC = pauseCtx->unk_204 + 314.0f; + + Matrix_Translate(pauseCtx->unk_1F0 / 10.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateZ(-pauseCtx->unk_204 / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(-1.57f, MTXMODE_APPLY); + } else if (pauseCtx->pageIndex == PAUSE_QUEST) { + pauseCtx->unk_200 = pauseCtx->unk_204 + 314.0f; + + Matrix_Translate(0.0f, (f32)WREG(2) / 100.0f, pauseCtx->unk_1F0 / 10.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateX(pauseCtx->unk_204 / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(3.14f, MTXMODE_APPLY); + } else { + pauseCtx->unk_1F8 = pauseCtx->unk_204 + 314.0f; + + Matrix_Translate(-pauseCtx->unk_1F0 / 10.0f, (f32)WREG(2) / 100.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateZ(pauseCtx->unk_204 / 100.0f, MTXMODE_APPLY); + Matrix_RotateY(1.57f, MTXMODE_APPLY); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx, "../z_kaleido_scope_PAL.c", 1424), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if ((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11)) { + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, sGameOverTexs); + } else { + POLY_OPA_DISP = + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->saveVtx, sSaveTexs[gSaveContext.language]); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->saveVtx[60], 32, 0); + + if (((pauseCtx->state == 7) && (pauseCtx->unk_1EC < 4)) || (pauseCtx->state == 0xE)) { + POLY_OPA_DISP = + KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sSavePromptTexs[gSaveContext.language], 152, 16, 0); + + gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, + 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 255, 100, VREG(61)); + + if (pauseCtx->promptChoice == 0) { + gSPDisplayList(POLY_OPA_DISP++, gPromptCursorLeftDL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gPromptCursorRightDL); + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + POLY_OPA_DISP = + KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sPromptChoiceTexs[gSaveContext.language][0], 48, 16, 12); + + POLY_OPA_DISP = + KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sPromptChoiceTexs[gSaveContext.language][1], 48, 16, 16); + } else if ((pauseCtx->state != 7) || (pauseCtx->unk_1EC < 4)) { + if ((pauseCtx->state != 0xF) && ((pauseCtx->state == 0x10) || (pauseCtx->state == 0x11))) { + POLY_OPA_DISP = + KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sContinuePromptTexs[gSaveContext.language], 152, 16, 0); + + gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, + TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 255, 100, VREG(61)); + + if (pauseCtx->promptChoice == 0) { + gSPDisplayList(POLY_OPA_DISP++, gPromptCursorLeftDL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gPromptCursorRightDL); + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + POLY_OPA_DISP = + KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sPromptChoiceTexs[gSaveContext.language][0], 48, 16, 12); + + POLY_OPA_DISP = + KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, sPromptChoiceTexs[gSaveContext.language][1], 48, 16, 16); + } + } + + 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 != 0x10) && (pauseCtx->state != 0x11)) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + } + } + + CLOSE_DISPS(gfxCtx, "../z_kaleido_scope_PAL.c", 1577); +} + +void KaleidoScope_DrawInfoPanel(GlobalContext* globalCtx) { + static void* D_8082AD54[3] = { + gPauseToEquipENGTex, + gPauseToEquipGERTex, + gPauseToEquipFRATex, + }; + static void* D_8082AD60[3] = { + gPauseToDecideENGTex, + gPauseToDecideGERTex, + gPauseToDecideFRATex, + }; + static void* D_8082AD6C[3] = { + gPauseToPlayMelodyENGTex, + gPauseToPlayMelodyGERTex, + gPauseToPlayMelodyFRATex, + }; + static void* D_8082AD78[][3] = { + { gPauseToEquipmentENGTex, gPauseToEquipmentGERTex, gPauseToEquipmentFRATex }, + { gPauseToSelectItemENGTex, gPauseToSelectItemGERTex, gPauseToSelectItemFRATex }, + { gPauseToMapENGTex, gPauseToMapGERTex, gPauseToMapFRATex }, + { gPauseToQuestStatusENGTex, gPauseToQuestStatusGERTex, gPauseToQuestStatusFRATex }, + }; + static void* D_8082ADA8[][3] = { + { gPauseToMapENGTex, gPauseToMapGERTex, gPauseToMapFRATex }, + { gPauseToQuestStatusENGTex, gPauseToQuestStatusGERTex, gPauseToQuestStatusFRATex }, + { gPauseToEquipmentENGTex, gPauseToEquipmentGERTex, gPauseToEquipmentFRATex }, + { gPauseToSelectItemENGTex, gPauseToSelectItemGERTex, gPauseToSelectItemFRATex }, + }; + static u16 D_8082ADD8[3] = { 56, 88, 80 }; + static u16 D_8082ADE0[3] = { 64, 88, 72 }; + static u16 D_8082ADE8[3] = { 80, 104, 112 }; + static s16 D_8082ADF0[][4] = { + { 180, 210, 255, 220 }, + { 100, 100, 150, 220 }, + }; + static s16 D_8082AE00 = 20; + static s16 D_8082AE04 = 0; + static s16 D_8082AE08[] = { + 10, 16, 16, 17, 12, 13, 18, 17, 17, 19, 13, 21, 20, 21, 14, 15, 15, 15, 11, 14, + }; + static s16 D_8082AE30[] = { + 21, 20, 19, 18, 11, 14, 10, 15, 16, 13, 12, 17, + }; + static s16 D_808321A0; + static s16 D_808321A2; + static s16 D_808321A4; + static s16 D_808321A6; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 stepR; + s16 stepG; + s16 stepB; + s16 stepA; + s16 temp; + s16 i; + s16 j; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 1676); + + stepR = ABS(D_808321A0 - D_8082ADF0[D_8082AE04][0]) / D_8082AE00; + stepG = ABS(D_808321A2 - D_8082ADF0[D_8082AE04][1]) / D_8082AE00; + stepB = ABS(D_808321A4 - D_8082ADF0[D_8082AE04][2]) / D_8082AE00; + stepA = ABS(D_808321A6 - D_8082ADF0[D_8082AE04][3]) / D_8082AE00; + if (D_808321A0 >= D_8082ADF0[D_8082AE04][0]) { + D_808321A0 -= stepR; + } else { + D_808321A0 += stepR; + } + if (D_808321A2 >= D_8082ADF0[D_8082AE04][1]) { + D_808321A2 -= stepG; + } else { + D_808321A2 += stepG; + } + if (D_808321A4 >= D_8082ADF0[D_8082AE04][2]) { + D_808321A4 -= stepB; + } else { + D_808321A4 += stepB; + } + if (D_808321A6 >= D_8082ADF0[D_8082AE04][3]) { + D_808321A6 -= stepA; + } else { + D_808321A6 += stepA; + } + + D_8082AE00--; + if (D_8082AE00 == 0) { + D_808321A0 = D_8082ADF0[D_8082AE04][0]; + D_808321A2 = D_8082ADF0[D_8082AE04][1]; + D_808321A4 = D_8082ADF0[D_8082AE04][2]; + D_808321A6 = D_8082ADF0[D_8082AE04][3]; + D_8082AE00 = ZREG(28); + D_8082AE04 ^= 1; + } + + temp = pauseCtx->infoPanelOffsetY - 76; + for (j = 0, i = 0; i < 7; i++, j += 4) { + pauseCtx->infoPanelVtx[j + 0].v.ob[0] = pauseCtx->infoPanelVtx[j + 2].v.ob[0] = -72; + + pauseCtx->infoPanelVtx[j + 1].v.ob[0] = pauseCtx->infoPanelVtx[j + 3].v.ob[0] = 0; + + pauseCtx->infoPanelVtx[j + 0].v.ob[1] = pauseCtx->infoPanelVtx[j + 1].v.ob[1] = temp; + + pauseCtx->infoPanelVtx[j + 2].v.ob[1] = pauseCtx->infoPanelVtx[j + 3].v.ob[1] = temp - 24; + + pauseCtx->infoPanelVtx[j + 0].v.ob[2] = pauseCtx->infoPanelVtx[j + 1].v.ob[2] = + pauseCtx->infoPanelVtx[j + 2].v.ob[2] = pauseCtx->infoPanelVtx[j + 3].v.ob[2] = 0; + + pauseCtx->infoPanelVtx[j + 0].v.flag = pauseCtx->infoPanelVtx[j + 1].v.flag = + pauseCtx->infoPanelVtx[j + 2].v.flag = pauseCtx->infoPanelVtx[j + 3].v.flag = 0; + + pauseCtx->infoPanelVtx[j + 0].v.tc[0] = pauseCtx->infoPanelVtx[j + 0].v.tc[1] = + pauseCtx->infoPanelVtx[j + 1].v.tc[1] = pauseCtx->infoPanelVtx[j + 2].v.tc[0] = 0; + + pauseCtx->infoPanelVtx[j + 1].v.tc[0] = pauseCtx->infoPanelVtx[j + 3].v.tc[0] = 0x900; + + pauseCtx->infoPanelVtx[j + 2].v.tc[1] = pauseCtx->infoPanelVtx[j + 3].v.tc[1] = 0x300; + + pauseCtx->infoPanelVtx[j + 0].v.cn[0] = pauseCtx->infoPanelVtx[j + 2].v.cn[0] = + pauseCtx->infoPanelVtx[j + 0].v.cn[1] = pauseCtx->infoPanelVtx[j + 2].v.cn[1] = + pauseCtx->infoPanelVtx[j + 0].v.cn[2] = pauseCtx->infoPanelVtx[j + 2].v.cn[2] = + pauseCtx->infoPanelVtx[j + 1].v.cn[0] = pauseCtx->infoPanelVtx[j + 3].v.cn[0] = + pauseCtx->infoPanelVtx[j + 1].v.cn[1] = pauseCtx->infoPanelVtx[j + 3].v.cn[1] = + pauseCtx->infoPanelVtx[j + 1].v.cn[2] = pauseCtx->infoPanelVtx[j + 3].v.cn[2] = 200; + + pauseCtx->infoPanelVtx[j + 0].v.cn[3] = pauseCtx->infoPanelVtx[j + 2].v.cn[3] = + pauseCtx->infoPanelVtx[j + 1].v.cn[3] = pauseCtx->infoPanelVtx[j + 3].v.cn[3] = pauseCtx->alpha; + } + + pauseCtx->infoPanelVtx[4].v.ob[0] = pauseCtx->infoPanelVtx[6].v.ob[0] = pauseCtx->infoPanelVtx[0].v.ob[0] + 72; + + pauseCtx->infoPanelVtx[5].v.ob[0] = pauseCtx->infoPanelVtx[7].v.ob[0] = pauseCtx->infoPanelVtx[4].v.ob[0] + 72; + + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) && (pauseCtx->unk_1E4 == 0)) { + pauseCtx->infoPanelVtx[8].v.ob[0] = pauseCtx->infoPanelVtx[10].v.ob[0] = WREG(16); + + pauseCtx->infoPanelVtx[9].v.ob[0] = pauseCtx->infoPanelVtx[11].v.ob[0] = pauseCtx->infoPanelVtx[8].v.ob[0] + 24; + + pauseCtx->infoPanelVtx[8].v.ob[1] = pauseCtx->infoPanelVtx[9].v.ob[1] = WREG(18); + + pauseCtx->infoPanelVtx[10].v.ob[1] = pauseCtx->infoPanelVtx[11].v.ob[1] = + pauseCtx->infoPanelVtx[8].v.ob[1] - 32; + } else { + pauseCtx->infoPanelVtx[8].v.ob[0] = pauseCtx->infoPanelVtx[10].v.ob[0] = WREG(16) + 3; + + pauseCtx->infoPanelVtx[9].v.ob[0] = pauseCtx->infoPanelVtx[11].v.ob[0] = pauseCtx->infoPanelVtx[8].v.ob[0] + 18; + + pauseCtx->infoPanelVtx[8].v.ob[1] = pauseCtx->infoPanelVtx[9].v.ob[1] = WREG(18) - 3; + + pauseCtx->infoPanelVtx[10].v.ob[1] = pauseCtx->infoPanelVtx[11].v.ob[1] = + pauseCtx->infoPanelVtx[8].v.ob[1] - 26; + } + + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) && (pauseCtx->unk_1E4 == 0)) { + pauseCtx->infoPanelVtx[12].v.ob[0] = pauseCtx->infoPanelVtx[14].v.ob[0] = WREG(17); + + pauseCtx->infoPanelVtx[13].v.ob[0] = pauseCtx->infoPanelVtx[15].v.ob[0] = + pauseCtx->infoPanelVtx[12].v.ob[0] + 24; + + pauseCtx->infoPanelVtx[12].v.ob[1] = pauseCtx->infoPanelVtx[13].v.ob[1] = WREG(18); + + pauseCtx->infoPanelVtx[14].v.ob[1] = pauseCtx->infoPanelVtx[15].v.ob[1] = + pauseCtx->infoPanelVtx[12].v.ob[1] - 32; + } else { + pauseCtx->infoPanelVtx[12].v.ob[0] = pauseCtx->infoPanelVtx[14].v.ob[0] = WREG(17) + 3; + + pauseCtx->infoPanelVtx[13].v.ob[0] = pauseCtx->infoPanelVtx[15].v.ob[0] = + pauseCtx->infoPanelVtx[12].v.ob[0] + 18; + + pauseCtx->infoPanelVtx[12].v.ob[1] = pauseCtx->infoPanelVtx[13].v.ob[1] = WREG(18) - 3; + + pauseCtx->infoPanelVtx[14].v.ob[1] = pauseCtx->infoPanelVtx[15].v.ob[1] = + pauseCtx->infoPanelVtx[12].v.ob[1] - 26; + } + + pauseCtx->infoPanelVtx[9].v.tc[0] = pauseCtx->infoPanelVtx[11].v.tc[0] = pauseCtx->infoPanelVtx[13].v.tc[0] = + pauseCtx->infoPanelVtx[15].v.tc[0] = 0x300; + + pauseCtx->infoPanelVtx[10].v.tc[1] = pauseCtx->infoPanelVtx[11].v.tc[1] = pauseCtx->infoPanelVtx[14].v.tc[1] = + pauseCtx->infoPanelVtx[15].v.tc[1] = 0x400; + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + Matrix_Translate(0.0f, 0.0f, -144.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 1755), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 90, 100, 130, 255); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->infoPanelVtx[0], 16, 0); + + gSPDisplayList(POLY_OPA_DISP++, gItemNamePanelDL); + + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) && (pauseCtx->unk_1E4 == 0)) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_808321A0, D_808321A2, D_808321A4, D_808321A6); + } + + gSPDisplayList(POLY_OPA_DISP++, gLButtonIconDL); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 210, 255, 220); + + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) && (pauseCtx->unk_1E4 == 0)) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, D_808321A0, D_808321A2, D_808321A4, D_808321A6); + } + + gSPDisplayList(POLY_OPA_DISP++, gRButtonIconDL); + + if (pauseCtx->cursorSpecialPos != 0) { + j = (pauseCtx->cursorSpecialPos * 4) - 32; + pauseCtx->cursorVtx[0].v.ob[0] = pauseCtx->infoPanelVtx[j].v.ob[0]; + pauseCtx->cursorVtx[0].v.ob[1] = pauseCtx->infoPanelVtx[j].v.ob[1]; + KaleidoScope_DrawCursor(globalCtx, pauseCtx->pageIndex); + } + + temp = pauseCtx->infoPanelOffsetY - 80; + pauseCtx->infoPanelVtx[16].v.ob[1] = pauseCtx->infoPanelVtx[17].v.ob[1] = temp; + + pauseCtx->infoPanelVtx[18].v.ob[1] = pauseCtx->infoPanelVtx[19].v.ob[1] = pauseCtx->infoPanelVtx[16].v.ob[1] - 16; + + pauseCtx->infoPanelVtx[18].v.tc[1] = pauseCtx->infoPanelVtx[19].v.tc[1] = 0x200; + + 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++, 20, 30, 40, 0); + + if ((pauseCtx->state == 6) && (pauseCtx->namedItem != PAUSE_ITEM_NONE) && (pauseCtx->nameDisplayTimer < WREG(89)) && + (!pauseCtx->unk_1E4 || (pauseCtx->unk_1E4 == 2) || ((pauseCtx->unk_1E4 >= 4) && (pauseCtx->unk_1E4 <= 7)) || + (pauseCtx->unk_1E4 == 8)) && + (pauseCtx->cursorSpecialPos == 0)) { + if (!pauseCtx->unk_1E4 || (pauseCtx->unk_1E4 == 2) || ((pauseCtx->unk_1E4 >= 4) && (pauseCtx->unk_1E4 <= 7)) || + (pauseCtx->unk_1E4 == 8)) { + pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = -63; + + pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + 128; + + pauseCtx->infoPanelVtx[17].v.tc[0] = pauseCtx->infoPanelVtx[19].v.tc[0] = 0x1000; + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->infoPanelVtx[16], 4, 0); + + if (pauseCtx->nameColorSet == 1) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 70, 70, 70, 255); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + } + + POLY_OPA_DISP = KaleidoScope_QuadTextureIA4(POLY_OPA_DISP, pauseCtx->nameSegment, 128, 16, 0); + } + + if (pauseCtx->pageIndex == PAUSE_MAP) { + if (YREG(7) != 0) { + osSyncPrintf(VT_FGCOL(YELLOW)); + osSyncPrintf("キンスタ数(%d) Get_KIN_STA=%x (%x) (%x)\n", YREG(6), GET_GS_FLAGS(YREG(6)), + gAreaGsFlags[YREG(6)], gSaveContext.gsFlags[YREG(6) >> 2]); + osSyncPrintf(VT_RST); + + YREG(7) = 0; + SET_GS_FLAGS(D_8082AE30[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]], + gAreaGsFlags[D_8082AE30[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]]); + } + } + + if ((pauseCtx->pageIndex == PAUSE_MAP) && !sInDungeonScene) { + if (GET_GS_FLAGS(D_8082AE30[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]) == + gAreaGsFlags[D_8082AE30[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]]) { + + pauseCtx->infoPanelVtx[24].v.ob[0] = pauseCtx->infoPanelVtx[26].v.ob[0] = -74; + + pauseCtx->infoPanelVtx[25].v.ob[0] = pauseCtx->infoPanelVtx[27].v.ob[0] = + pauseCtx->infoPanelVtx[24].v.ob[0] + 19; + + pauseCtx->infoPanelVtx[24].v.ob[1] = pauseCtx->infoPanelVtx[25].v.ob[1] = + pauseCtx->infoPanelVtx[24].v.ob[1] - 2; + + pauseCtx->infoPanelVtx[26].v.ob[1] = pauseCtx->infoPanelVtx[27].v.ob[1] = + pauseCtx->infoPanelVtx[24].v.ob[1] - 19; + + pauseCtx->infoPanelVtx[25].v.tc[0] = pauseCtx->infoPanelVtx[27].v.tc[0] = 0x300; + + gDPPipeSync(POLY_OPA_DISP++); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->infoPanelVtx[24], 4, 0); + + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gGoldSkulltulaIconTex, 24, 24, 0); + } + } + } else if ((pauseCtx->unk_1E4 < 3) || (pauseCtx->unk_1E4 == 7) || (pauseCtx->unk_1E4 == 8)) { + pauseCtx->infoPanelVtx[20].v.ob[1] = pauseCtx->infoPanelVtx[21].v.ob[1] = temp; + + pauseCtx->infoPanelVtx[22].v.ob[1] = pauseCtx->infoPanelVtx[23].v.ob[1] = + pauseCtx->infoPanelVtx[20].v.ob[1] - 16; + + pauseCtx->infoPanelVtx[22].v.tc[1] = pauseCtx->infoPanelVtx[23].v.tc[1] = 0x200; + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->infoPanelVtx[16], 8, 0); + + if (pauseCtx->state == 7) { + pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = WREG(61 + gSaveContext.language); + + pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + 24; + + pauseCtx->infoPanelVtx[20].v.ob[0] = pauseCtx->infoPanelVtx[22].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + WREG(52 + gSaveContext.language); + + pauseCtx->infoPanelVtx[21].v.ob[0] = pauseCtx->infoPanelVtx[23].v.ob[0] = + pauseCtx->infoPanelVtx[20].v.ob[0] + D_8082ADE0[gSaveContext.language]; + + pauseCtx->infoPanelVtx[17].v.tc[0] = pauseCtx->infoPanelVtx[19].v.tc[0] = 0x300; + + pauseCtx->infoPanelVtx[21].v.tc[0] = pauseCtx->infoPanelVtx[23].v.tc[0] = D_8082ADE0[gSaveContext.language] + << 5; + + gSPDisplayList(POLY_OPA_DISP++, gAButtonIconDL); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, D_8082AD60[gSaveContext.language], + D_8082ADE0[gSaveContext.language], 16, 4); + } else if (pauseCtx->cursorSpecialPos != 0) { + if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 0)) { + pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = -63; + + pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + 128; + + pauseCtx->infoPanelVtx[17].v.tc[0] = pauseCtx->infoPanelVtx[19].v.tc[0] = 0x1000; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 200, 0, 255); + + if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8( + POLY_OPA_DISP, D_8082AD78[pauseCtx->pageIndex][gSaveContext.language], 128, 16, 0); + } else { + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8( + POLY_OPA_DISP, D_8082ADA8[pauseCtx->pageIndex][gSaveContext.language], 128, 16, 0); + } + } + } else { + if (!pauseCtx->pageIndex) { // pageIndex == PAUSE_ITEM + pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = + WREG(49 + gSaveContext.language); + + pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + 48; + + pauseCtx->infoPanelVtx[20].v.ob[0] = pauseCtx->infoPanelVtx[22].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + WREG(58 + gSaveContext.language); + + pauseCtx->infoPanelVtx[21].v.ob[0] = pauseCtx->infoPanelVtx[23].v.ob[0] = + pauseCtx->infoPanelVtx[20].v.ob[0] + D_8082ADD8[gSaveContext.language]; + + pauseCtx->infoPanelVtx[17].v.tc[0] = pauseCtx->infoPanelVtx[19].v.tc[0] = 0x600; + + pauseCtx->infoPanelVtx[21].v.tc[0] = pauseCtx->infoPanelVtx[23].v.tc[0] = + D_8082ADD8[gSaveContext.language] << 5; + + gSPDisplayList(POLY_OPA_DISP++, gCButtonIconsDL); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, D_8082AD54[gSaveContext.language], + D_8082ADD8[gSaveContext.language], 16, 4); + } else if ((pauseCtx->pageIndex == PAUSE_MAP) && sInDungeonScene) { + + } else if ((pauseCtx->pageIndex == PAUSE_QUEST) && (pauseCtx->cursorSlot[PAUSE_QUEST] >= 6) && + (pauseCtx->cursorSlot[PAUSE_QUEST] <= 0x11)) { + if (pauseCtx->namedItem != PAUSE_ITEM_NONE) { + pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = + WREG(55 + gSaveContext.language); + + pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + 24; + + pauseCtx->infoPanelVtx[20].v.ob[0] = pauseCtx->infoPanelVtx[22].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + WREG(52 + gSaveContext.language); + + if (gSaveContext.language == 1) { + pauseCtx->infoPanelVtx[20].v.ob[0] = pauseCtx->infoPanelVtx[22].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] - 99; + } + + pauseCtx->infoPanelVtx[21].v.ob[0] = pauseCtx->infoPanelVtx[23].v.ob[0] = + pauseCtx->infoPanelVtx[20].v.ob[0] + D_8082ADE8[gSaveContext.language]; + + pauseCtx->infoPanelVtx[17].v.tc[0] = pauseCtx->infoPanelVtx[19].v.tc[0] = 0x300; + + pauseCtx->infoPanelVtx[21].v.tc[0] = pauseCtx->infoPanelVtx[23].v.tc[0] = + D_8082ADE8[gSaveContext.language] << 5; + + gSPDisplayList(POLY_OPA_DISP++, gAButtonIconDL); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, D_8082AD6C[gSaveContext.language], + D_8082ADE8[gSaveContext.language], 16, 4); + } + } else if (pauseCtx->pageIndex == PAUSE_EQUIP) { + pauseCtx->infoPanelVtx[16].v.ob[0] = pauseCtx->infoPanelVtx[18].v.ob[0] = + WREG(64 + gSaveContext.language); + + pauseCtx->infoPanelVtx[17].v.ob[0] = pauseCtx->infoPanelVtx[19].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + 24; + + pauseCtx->infoPanelVtx[20].v.ob[0] = pauseCtx->infoPanelVtx[22].v.ob[0] = + pauseCtx->infoPanelVtx[16].v.ob[0] + WREG(52 + gSaveContext.language); + + pauseCtx->infoPanelVtx[21].v.ob[0] = pauseCtx->infoPanelVtx[23].v.ob[0] = + pauseCtx->infoPanelVtx[20].v.ob[0] + D_8082ADD8[gSaveContext.language]; + + pauseCtx->infoPanelVtx[17].v.tc[0] = pauseCtx->infoPanelVtx[19].v.tc[0] = 0x300; + + pauseCtx->infoPanelVtx[21].v.tc[0] = pauseCtx->infoPanelVtx[23].v.tc[0] = + D_8082ADD8[gSaveContext.language] << 5; + + gSPDisplayList(POLY_OPA_DISP++, gAButtonIconDL); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, D_8082AD54[gSaveContext.language], + D_8082ADD8[gSaveContext.language], 16, 4); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 2032); +} + +void KaleidoScope_UpdateNamePanel(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + u16 sp2A; + + if ((pauseCtx->namedItem != pauseCtx->cursorItem[pauseCtx->pageIndex]) || + ((pauseCtx->pageIndex == PAUSE_MAP) && (pauseCtx->cursorSpecialPos != 0))) { + + pauseCtx->namedItem = pauseCtx->cursorItem[pauseCtx->pageIndex]; + sp2A = pauseCtx->namedItem; + + osCreateMesgQueue(&pauseCtx->loadQueue, &pauseCtx->loadMsg, 1); + + if (pauseCtx->namedItem != PAUSE_ITEM_NONE) { + if ((pauseCtx->pageIndex == PAUSE_MAP) && !sInDungeonScene) { + if (gSaveContext.language) { + sp2A += 12; + } + if (gSaveContext.language == 2) { + sp2A += 12; + } + + DmaMgr_SendRequest1(pauseCtx->nameSegment, (u32)_map_name_staticSegmentRomStart + (sp2A * 0x400), 0x400, + "../z_kaleido_scope_PAL.c", 2093); + } else { + osSyncPrintf("zoom_name=%d\n", pauseCtx->namedItem); + + if (gSaveContext.language) { + sp2A += 123; + } + if (gSaveContext.language == 2) { + sp2A += 123; + } + + osSyncPrintf("J_N=%d point=%d\n", gSaveContext.language, sp2A); + + DmaMgr_SendRequest1(pauseCtx->nameSegment, (u32)_item_name_staticSegmentRomStart + (sp2A * 0x400), + 0x400, "../z_kaleido_scope_PAL.c", 2120); + } + + pauseCtx->nameDisplayTimer = 0; + } + } else if (pauseCtx->nameColorSet == 0) { + if (((pauseCtx->pageIndex == PAUSE_QUEST) && (pauseCtx->cursorSlot[PAUSE_QUEST] >= 6) && + (pauseCtx->cursorSlot[PAUSE_QUEST] <= 0x11) && (pauseCtx->unk_1E4 == 8)) || + (pauseCtx->pageIndex == PAUSE_ITEM) || + ((pauseCtx->pageIndex == PAUSE_EQUIP) && (pauseCtx->cursorX[PAUSE_EQUIP] != 0))) { + if (pauseCtx->namedItem != ITEM_SOLD_OUT) { + pauseCtx->nameDisplayTimer++; + if (pauseCtx->nameDisplayTimer > WREG(88)) { + pauseCtx->nameDisplayTimer = 0; + } + } + } else { + pauseCtx->nameDisplayTimer = 0; + } + } else { + pauseCtx->nameDisplayTimer = 0; + } +} + +void func_808237B4(GlobalContext* globalCtx, Input* input) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s32 cond = false; + s32 mode; + + if (ZREG(13) && !CHECK_BTN_ALL(input->press.button, BTN_L)) { + cond = true; + } + + if (!cond) { + mode = pauseCtx->mode; + pauseCtx->eye.x += D_8082ABAC[mode]; + pauseCtx->eye.z += D_8082ABCC[mode]; + + if (pauseCtx->unk_1EA < 32) { + WREG(16) -= WREG(25) / WREG(6); + WREG(17) -= WREG(26) / WREG(6); + } else { + WREG(16) += WREG(25) / WREG(6); + WREG(17) += WREG(26) / WREG(6); + } + + pauseCtx->unk_1EA += 4; + + if (pauseCtx->unk_1EA == 64) { + pauseCtx->unk_1EA = 0; + pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; + pauseCtx->unk_1E4 = 0; + } + } +} + +void KaleidoScope_SetView(PauseContext* pauseCtx, f32 x, f32 y, f32 z) { + Vec3f eye; + Vec3f lookAt; + Vec3f up; + + eye.x = x; + eye.y = y; + eye.z = z; + lookAt.x = lookAt.y = lookAt.z = 0.0f; + up.x = up.z = 0.0f; + up.y = 1.0f; + + func_800AA358(&pauseCtx->view, &eye, &lookAt, &up); + func_800AAA50(&pauseCtx->view, 127); +} + +static u8 D_8082AE48[][4] = { + { 10, 70, 70, 10 }, { 10, 90, 90, 10 }, { 80, 140, 140, 80 }, + { 80, 120, 120, 80 }, { 80, 140, 140, 80 }, { 50, 110, 110, 50 }, +}; +static u8 D_8082AE60[][4] = { + { 50, 100, 100, 50 }, { 50, 100, 100, 50 }, { 40, 60, 60, 40 }, + { 80, 120, 120, 80 }, { 40, 60, 60, 40 }, { 50, 110, 110, 50 }, +}; +static u8 D_8082AE78[][4] = { + { 80, 130, 130, 80 }, { 40, 60, 60, 40 }, { 30, 60, 60, 30 }, + { 50, 70, 70, 50 }, { 30, 60, 60, 30 }, { 50, 110, 110, 50 }, +}; + +static s16 D_8082AE90[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AE94[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AE98[] = { + 0xFFDC, 0x000C, 0xFFEE, 0x0046, 0x0046, 0x0046, 0xFFA8, 0xFFA8, 0xFFA8, + 0xFFA8, 0xFFA8, 0xFFA8, 0xFFA8, 0xFFA8, 0xFF96, 0xFFC2, 0xFFD8, 0x0000, +}; +static s16 D_8082AEBC[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AEC0[] = { + 0x002F, 0xFFCF, 0xFFEF, 0xFFF1, 0xFFF7, 0x0018, 0x002B, 0x000E, 0x0009, 0x0026, 0x0052, + 0x0047, 0xFFB4, 0xFFA9, 0xFF94, 0xFFCA, 0xFFA3, 0xFFBD, 0xFFC8, 0xFFDF, 0xFFF6, 0x0001, + 0x000E, 0x0018, 0x0023, 0x003A, 0x004A, 0x0059, 0x0000, 0xFFC6, 0x0013, 0x001C, +}; +static s16 D_8082AF00[] = { + 0xFFB4, 0xFFC6, 0x000A, 0xFFC6, 0x000A, 0x0000, +}; +static s16 D_8082AF0C[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AF10[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AF14[] = { + 0x0030, 0x0030, 0x0060, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0010, 0x0010, 0x0018, 0x0000, +}; +static s16 D_8082AF38[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AF3C[] = { + 0x0098, 0x0030, 0x0030, 0x0030, 0x0030, 0x0000, +}; +static s16 D_8082AF48[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AF4C[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AF50[] = { + 0x001C, 0x001C, 0x002E, 0x001C, 0xFFFE, 0xFFE0, 0x0032, 0x0024, 0x0016, + 0x0008, 0xFFFA, 0xFFEC, 0xFFDE, 0xFFD0, 0x0012, 0x0012, 0x0032, 0x0000, +}; +static s16 D_8082AF74[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AF78[] = { + 0x000F, 0x0028, 0x000B, 0x002D, 0x0034, 0x0025, 0x0024, 0x0039, 0x0036, 0x0021, 0x001F, + 0x002D, 0x0020, 0x002A, 0x0031, 0xFFF6, 0x001F, 0x001B, 0x000F, 0xFFCF, 0x0008, 0x0026, + 0x0007, 0x002F, 0x001E, 0x0001, 0xFFF7, 0x0019, 0x0000, 0x0001, 0xFFE0, 0xFFE6, +}; +static s16 D_8082AFB8[] = { + 0x0024, 0x000A, 0x000A, 0xFFFA, 0xFFFA, 0x0000, +}; +static s16 D_8082AFC4[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AFC8[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AFCC[] = { + 0x0055, 0x0055, 0x0010, 0x0018, 0x0018, 0x0018, 0x0010, 0x0010, 0x0010, + 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0018, 0x0000, +}; +static s16 D_8082AFF0[] = { + 0x0000, + 0x0000, +}; +static s16 D_8082AFF4[] = { + 0x0010, 0x0030, 0x0030, 0x0010, 0x0010, 0x0000, +}; + +static s16* D_8082B000[] = { + D_8082AE90, D_8082AE94, D_8082AE98, D_8082AEBC, D_8082AEC0, D_8082AF00, +}; + +static s16* D_8082B018[] = { + D_8082AF0C, D_8082AF10, D_8082AF14, D_8082AF38, D_8082AAEC, D_8082AF3C, +}; + +static s16* D_8082B030[] = { + D_8082AF48, D_8082AF4C, D_8082AF50, D_8082AF74, D_8082AF78, D_8082AFB8, +}; + +static s16* D_8082B048[] = { + D_8082AFC4, D_8082AFC8, D_8082AFCC, D_8082AFF0, D_8082AB2C, D_8082AFF4, +}; + +static s16 D_8082B060[] = { + 0xFFC6, 0x000B, 0x001E, 0x001E, 0x000F, 0x0026, 0xFFC2, 0x003C, 0x003D, 0xFFB2, 0xFED4, + 0xFFAA, 0xFFBF, 0xFED4, 0xFED4, 0xFFEB, 0x000E, 0x000D, 0x0014, 0xFFDE, 0xFED4, 0x0000, +}; + +static s16 D_8082B08C[] = { + 0x0059, 0x0014, 0x000E, 0x0023, 0x0020, 0x0011, 0x0032, 0x0010, 0x0015, 0x0014, 0xFFFF, + 0x0020, 0x0010, 0xFFFF, 0xFFFF, 0x0013, 0x0013, 0x0015, 0x0010, 0x0014, 0xFFFF, 0x0000, +}; + +static s16 D_8082B0B8[] = { + 0x0001, 0x000F, 0x0014, 0x0009, 0xFFE2, 0xFFEF, 0xFFDE, 0x000F, 0x001E, 0x0001, 0xFED4, + 0x002A, 0x0007, 0xFED4, 0xFED4, 0x0018, 0x0024, 0x0035, 0x0025, 0xFFF3, 0xFED4, 0x0000, +}; + +static s16 D_8082B0E4[] = { + 0x0024, 0x000F, 0x0010, 0x0017, 0x0017, 0x0010, 0x0018, 0x000D, 0x0011, 0x0012, 0x0001, + 0x0019, 0x000D, 0x0001, 0x0001, 0x000D, 0x0015, 0x000F, 0x000D, 0x000C, 0x0001, 0x0000, +}; + +s16 func_80823A0C(GlobalContext* globalCtx, Vtx* vtx, s16 arg2, s16 arg3) { + static s16 D_8082B110 = 0; + static s16 D_8082B114 = 1; + static s16 D_8082B118 = 0; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16* ptr1; + s16* ptr2; + s16* ptr3; + s16* ptr4; + s16 phi_s2; + s16 phi_t0; + s16 phi_a1; + s16 phi_a2; + s16 phi_t3; + s16 phi_t1; + + phi_t0 = -200; + + for (phi_t1 = 0, phi_t3 = 0; phi_t3 < 3; phi_t3++) { + phi_t0 += 80; + + for (phi_a1 = 80, phi_a2 = 0; phi_a2 < 5; phi_a2++, phi_t1 += 4, phi_a1 -= 32) { + vtx[phi_t1 + 0].v.ob[0] = vtx[phi_t1 + 2].v.ob[0] = phi_t0; + + vtx[phi_t1 + 1].v.ob[0] = vtx[phi_t1 + 3].v.ob[0] = vtx[phi_t1 + 0].v.ob[0] + 80; + + vtx[phi_t1 + 0].v.ob[1] = vtx[phi_t1 + 1].v.ob[1] = phi_a1 + pauseCtx->offsetY; + + vtx[phi_t1 + 2].v.ob[1] = vtx[phi_t1 + 3].v.ob[1] = vtx[phi_t1 + 0].v.ob[1] - 32; + + vtx[phi_t1 + 0].v.ob[2] = vtx[phi_t1 + 1].v.ob[2] = vtx[phi_t1 + 2].v.ob[2] = vtx[phi_t1 + 3].v.ob[2] = 0; + + vtx[phi_t1 + 0].v.flag = 0; + vtx[phi_t1 + 1].v.flag = 0; + vtx[phi_t1 + 2].v.flag = 0; + vtx[phi_t1 + 3].v.flag = 0; + + vtx[phi_t1 + 0].v.tc[0] = vtx[phi_t1 + 0].v.tc[1] = vtx[phi_t1 + 1].v.tc[1] = vtx[phi_t1 + 2].v.tc[0] = 0; + + vtx[phi_t1 + 1].v.tc[0] = vtx[phi_t1 + 3].v.tc[0] = 0xA00; + + vtx[phi_t1 + 2].v.tc[1] = vtx[phi_t1 + 3].v.tc[1] = 0x400; + + vtx[phi_t1 + 0].v.cn[0] = vtx[phi_t1 + 2].v.cn[0] = D_8082AE48[arg2][phi_t3 + 0]; + + vtx[phi_t1 + 0].v.cn[1] = vtx[phi_t1 + 2].v.cn[1] = D_8082AE60[arg2][phi_t3 + 0]; + + vtx[phi_t1 + 0].v.cn[2] = vtx[phi_t1 + 2].v.cn[2] = D_8082AE78[arg2][phi_t3 + 0]; + + vtx[phi_t1 + 1].v.cn[0] = vtx[phi_t1 + 3].v.cn[0] = D_8082AE48[arg2][phi_t3 + 1]; + + vtx[phi_t1 + 1].v.cn[1] = vtx[phi_t1 + 3].v.cn[1] = D_8082AE60[arg2][phi_t3 + 1]; + + vtx[phi_t1 + 1].v.cn[2] = vtx[phi_t1 + 3].v.cn[2] = D_8082AE78[arg2][phi_t3 + 1]; + + vtx[phi_t1 + 0].v.cn[3] = vtx[phi_t1 + 2].v.cn[3] = vtx[phi_t1 + 1].v.cn[3] = vtx[phi_t1 + 3].v.cn[3] = + pauseCtx->alpha; + } + } + + phi_s2 = phi_t1; + + if (arg3 != 0) { + ptr1 = D_8082B000[arg2]; + ptr2 = D_8082B018[arg2]; + ptr3 = D_8082B030[arg2]; + ptr4 = D_8082B048[arg2]; + + for (phi_t3 = 0; phi_t3 < arg3; phi_t3++, phi_t1 += 4) { + vtx[phi_t1 + 2].v.ob[0] = vtx[phi_t1 + 0].v.ob[0] = ptr1[phi_t3]; + + vtx[phi_t1 + 1].v.ob[0] = vtx[phi_t1 + 3].v.ob[0] = vtx[phi_t1 + 0].v.ob[0] + ptr2[phi_t3]; + + if (!((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11))) { + vtx[phi_t1 + 0].v.ob[1] = vtx[phi_t1 + 1].v.ob[1] = ptr3[phi_t3] + pauseCtx->offsetY; + } else { + vtx[phi_t1 + 0].v.ob[1] = vtx[phi_t1 + 1].v.ob[1] = YREG(60 + phi_t3) + pauseCtx->offsetY; + } + + vtx[phi_t1 + 2].v.ob[1] = vtx[phi_t1 + 3].v.ob[1] = vtx[phi_t1 + 0].v.ob[1] - ptr4[phi_t3]; + + vtx[phi_t1 + 0].v.ob[2] = vtx[phi_t1 + 1].v.ob[2] = vtx[phi_t1 + 2].v.ob[2] = vtx[phi_t1 + 3].v.ob[2] = 0; + + vtx[phi_t1 + 0].v.flag = vtx[phi_t1 + 1].v.flag = vtx[phi_t1 + 2].v.flag = vtx[phi_t1 + 3].v.flag = 0; + + vtx[phi_t1 + 0].v.tc[0] = vtx[phi_t1 + 0].v.tc[1] = vtx[phi_t1 + 1].v.tc[1] = vtx[phi_t1 + 2].v.tc[0] = 0; + + vtx[phi_t1 + 1].v.tc[0] = vtx[phi_t1 + 3].v.tc[0] = ptr2[phi_t3] << 5; + + vtx[phi_t1 + 2].v.tc[1] = vtx[phi_t1 + 3].v.tc[1] = ptr4[phi_t3] << 5; + + vtx[phi_t1 + 0].v.cn[0] = vtx[phi_t1 + 2].v.cn[0] = vtx[phi_t1 + 0].v.cn[1] = vtx[phi_t1 + 2].v.cn[1] = + vtx[phi_t1 + 0].v.cn[2] = vtx[phi_t1 + 2].v.cn[2] = vtx[phi_t1 + 1].v.cn[0] = vtx[phi_t1 + 3].v.cn[0] = + vtx[phi_t1 + 1].v.cn[1] = vtx[phi_t1 + 3].v.cn[1] = vtx[phi_t1 + 1].v.cn[2] = + vtx[phi_t1 + 3].v.cn[2] = 255; + + vtx[phi_t1 + 0].v.cn[3] = vtx[phi_t1 + 2].v.cn[3] = vtx[phi_t1 + 1].v.cn[3] = vtx[phi_t1 + 3].v.cn[3] = + pauseCtx->alpha; + } + + if (arg2 == 4) { + phi_t1 -= 12; + + phi_t3 = gSaveContext.worldMapArea; + + vtx[phi_t1 + 0].v.ob[0] = vtx[phi_t1 + 2].v.ob[0] = D_8082B060[phi_t3]; + + if (phi_t3) {} + + vtx[phi_t1 + 1].v.ob[0] = vtx[phi_t1 + 3].v.ob[0] = vtx[phi_t1 + 0].v.ob[0] + D_8082B08C[phi_t3]; + + vtx[phi_t1 + 0].v.ob[1] = vtx[phi_t1 + 1].v.ob[1] = D_8082B0B8[phi_t3] + pauseCtx->offsetY; + + vtx[phi_t1 + 2].v.ob[1] = vtx[phi_t1 + 3].v.ob[1] = vtx[phi_t1 + 0].v.ob[1] - D_8082B0E4[phi_t3]; + + phi_t1 += 12; + + if (pauseCtx->tradeQuestLocation != 0xFF) { + if (D_8082B114 == 0) { + D_8082B118++; + switch (D_8082B118) { + case 1: + D_8082B110 = 3; + D_8082B114 = 8; + break; + case 2: + D_8082B110 = 0; + D_8082B114 = 6; + D_8082B118 = 0; + break; + } + } else { + D_8082B114--; + } + + phi_t3 = phi_s2 + (pauseCtx->tradeQuestLocation * 4) + 64; + phi_a2 = phi_s2 + 116; + + vtx[phi_a2 + 0].v.ob[0] = vtx[phi_a2 + 2].v.ob[0] = vtx[phi_t3 + 0].v.ob[0]; + + vtx[phi_a2 + 1].v.ob[0] = vtx[phi_a2 + 3].v.ob[0] = vtx[phi_a2 + 0].v.ob[0] + 8; + + vtx[phi_a2 + 0].v.ob[1] = vtx[phi_a2 + 1].v.ob[1] = vtx[phi_t3 + 0].v.ob[1] - D_8082B110 + 10; + + vtx[phi_a2 + 0].v.ob[2] = vtx[phi_a2 + 1].v.ob[2] = vtx[phi_a2 + 2].v.ob[2] = vtx[phi_a2 + 3].v.ob[2] = + 0; + + vtx[phi_a2 + 2].v.ob[1] = vtx[phi_a2 + 3].v.ob[1] = vtx[phi_a2 + 0].v.ob[1] - 8; + + vtx[phi_a2 + 0].v.flag = vtx[phi_a2 + 1].v.flag = vtx[phi_a2 + 2].v.flag = vtx[phi_a2 + 3].v.flag = 0; + + vtx[phi_t1].v.tc[0] = vtx[phi_t1].v.tc[1] = vtx[phi_a2 + 1].v.tc[1] = vtx[phi_a2 + 2].v.tc[0] = 0; + + vtx[phi_a2 + 1].v.tc[0] = vtx[phi_a2 + 3].v.tc[0] = 0x100; + + vtx[phi_a2 + 2].v.tc[1] = vtx[phi_a2 + 3].v.tc[1] = 0x100; + + vtx[phi_a2 + 0].v.cn[0] = vtx[phi_a2 + 2].v.cn[0] = vtx[phi_a2 + 0].v.cn[1] = vtx[phi_a2 + 2].v.cn[1] = + vtx[phi_a2 + 0].v.cn[2] = vtx[phi_a2 + 2].v.cn[2] = vtx[phi_a2 + 1].v.cn[0] = + vtx[phi_a2 + 3].v.cn[0] = vtx[phi_a2 + 1].v.cn[1] = vtx[phi_a2 + 3].v.cn[1] = + vtx[phi_a2 + 1].v.cn[2] = vtx[phi_a2 + 3].v.cn[2] = 255; + + vtx[phi_a2 + 0].v.cn[3] = vtx[phi_a2 + 2].v.cn[3] = vtx[phi_a2 + 1].v.cn[3] = vtx[phi_a2 + 3].v.cn[3] = + pauseCtx->alpha; + } + } + } + + return phi_t1; +} + +static s16 D_8082B11C[] = { 0, 4, 8, 12, 24, 32, 56 }; + +static s16 D_8082B12C[] = { -114, 12, 44, 76 }; + +static u8 D_8082B134[] = { 1, 5, 9, 13 }; + +static s16 D_8082B138[] = { + 74, 74, 46, 18, 18, 46, -108, -90, -72, -54, -36, -18, -108, -90, -72, -54, + -36, -18, 20, 46, 72, -110, -86, -110, -54, -98, -86, -74, -62, -50, -38, -26, + -14, -98, -86, -74, -62, -50, -38, -26, -14, -88, -81, -72, -90, -83, -74, +}; + +static s16 D_8082B198[] = { + 38, 6, -12, 6, 38, 56, -20, -20, -20, -20, -20, -20, 2, 2, 2, 2, 2, 2, -46, -46, -46, 58, 58, 34, + 58, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, 34, 34, 34, 36, 36, 36, +}; + +static s16 D_8082B1F8[] = { + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 48, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, +}; + +void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 phi_t1; + s16 phi_t2; + s16 phi_t2_2; + s16 phi_t3; + s16 phi_t4; + s16 phi_t5; + + pauseCtx->offsetY = 0; + + if ((pauseCtx->state == 4) || (pauseCtx->state >= 0x12) || + ((pauseCtx->state == 7) && ((pauseCtx->unk_1EC == 2) || (pauseCtx->unk_1EC == 5))) || + ((pauseCtx->state >= 8) && (pauseCtx->state <= 0xD))) { + pauseCtx->offsetY = 80; + } + + pauseCtx->itemPageVtx = Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); + func_80823A0C(globalCtx, pauseCtx->itemPageVtx, 0, 0); + + pauseCtx->equipPageVtx = Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); + func_80823A0C(globalCtx, pauseCtx->equipPageVtx, 1, 0); + + if (!sInDungeonScene) { + pauseCtx->mapPageVtx = Graph_Alloc(gfxCtx, 248 * sizeof(Vtx)); + phi_t3 = func_80823A0C(globalCtx, pauseCtx->mapPageVtx, 4, 32); + + for (phi_t2 = 0, phi_t5 = 58; phi_t2 < 15; phi_t2++, phi_t3 += 4, phi_t5 -= 9) { + pauseCtx->mapPageVtx[phi_t3 + 2].v.ob[0] = -108; + pauseCtx->mapPageVtx[phi_t3 + 0].v.ob[0] = pauseCtx->mapPageVtx[phi_t3 + 2].v.ob[0]; + + pauseCtx->mapPageVtx[phi_t3 + 1].v.ob[0] = pauseCtx->mapPageVtx[phi_t3 + 3].v.ob[0] = + pauseCtx->mapPageVtx[phi_t3 + 0].v.ob[0] + 216; + + pauseCtx->mapPageVtx[phi_t3 + 0].v.ob[1] = pauseCtx->mapPageVtx[phi_t3 + 1].v.ob[1] = + phi_t5 + pauseCtx->offsetY; + + pauseCtx->mapPageVtx[phi_t3 + 2].v.ob[1] = pauseCtx->mapPageVtx[phi_t3 + 3].v.ob[1] = + pauseCtx->mapPageVtx[phi_t3 + 0].v.ob[1] - 9; + + pauseCtx->mapPageVtx[phi_t3 + 0].v.ob[2] = pauseCtx->mapPageVtx[phi_t3 + 1].v.ob[2] = + pauseCtx->mapPageVtx[phi_t3 + 2].v.ob[2] = pauseCtx->mapPageVtx[phi_t3 + 3].v.ob[2] = 0; + + pauseCtx->mapPageVtx[phi_t3 + 0].v.flag = pauseCtx->mapPageVtx[phi_t3 + 1].v.flag = + pauseCtx->mapPageVtx[phi_t3 + 2].v.flag = pauseCtx->mapPageVtx[phi_t3 + 3].v.flag = 0; + + pauseCtx->mapPageVtx[phi_t3 + 0].v.tc[0] = pauseCtx->mapPageVtx[phi_t3 + 0].v.tc[1] = + pauseCtx->mapPageVtx[phi_t3 + 1].v.tc[1] = pauseCtx->mapPageVtx[phi_t3 + 2].v.tc[0] = 0; + + pauseCtx->mapPageVtx[phi_t3 + 1].v.tc[0] = pauseCtx->mapPageVtx[phi_t3 + 3].v.tc[0] = 0x1B00; + + pauseCtx->mapPageVtx[phi_t3 + 2].v.tc[1] = pauseCtx->mapPageVtx[phi_t3 + 3].v.tc[1] = 0x120; + + pauseCtx->mapPageVtx[phi_t3 + 0].v.cn[0] = pauseCtx->mapPageVtx[phi_t3 + 2].v.cn[0] = + pauseCtx->mapPageVtx[phi_t3 + 0].v.cn[1] = pauseCtx->mapPageVtx[phi_t3 + 2].v.cn[1] = + pauseCtx->mapPageVtx[phi_t3 + 0].v.cn[2] = pauseCtx->mapPageVtx[phi_t3 + 2].v.cn[2] = + pauseCtx->mapPageVtx[phi_t3 + 1].v.cn[0] = pauseCtx->mapPageVtx[phi_t3 + 3].v.cn[0] = + pauseCtx->mapPageVtx[phi_t3 + 1].v.cn[1] = pauseCtx->mapPageVtx[phi_t3 + 3].v.cn[1] = + pauseCtx->mapPageVtx[phi_t3 + 1].v.cn[2] = pauseCtx->mapPageVtx[phi_t3 + 3].v.cn[2] = + pauseCtx->mapPageVtx[phi_t3 + 0].v.cn[3] = + pauseCtx->mapPageVtx[phi_t3 + 2].v.cn[3] = + pauseCtx->mapPageVtx[phi_t3 + 1].v.cn[3] = + pauseCtx->mapPageVtx[phi_t3 + 3].v.cn[3] = pauseCtx->alpha; + } + + pauseCtx->mapPageVtx[phi_t3 - 2].v.ob[1] = pauseCtx->mapPageVtx[phi_t3 - 1].v.ob[1] = + pauseCtx->mapPageVtx[phi_t3 - 4].v.ob[1] - 2; + + pauseCtx->mapPageVtx[phi_t3 - 2].v.tc[1] = pauseCtx->mapPageVtx[phi_t3 - 1].v.tc[1] = 0x40; + } else { + pauseCtx->mapPageVtx = Graph_Alloc(gfxCtx, 128 * sizeof(Vtx)); + func_80823A0C(globalCtx, pauseCtx->mapPageVtx, 2, 17); + } + + pauseCtx->questPageVtx = Graph_Alloc(gfxCtx, 60 * sizeof(Vtx)); + func_80823A0C(globalCtx, pauseCtx->questPageVtx, 3, 0); + + pauseCtx->cursorVtx = Graph_Alloc(gfxCtx, 20 * sizeof(Vtx)); + + for (phi_t2 = 0; phi_t2 < 20; phi_t2++) { + pauseCtx->cursorVtx[phi_t2].v.ob[0] = pauseCtx->cursorVtx[phi_t2].v.ob[1] = + pauseCtx->cursorVtx[phi_t2].v.ob[2] = 0; + + pauseCtx->cursorVtx[phi_t2].v.flag = 0; + + pauseCtx->cursorVtx[phi_t2].v.tc[0] = pauseCtx->cursorVtx[phi_t2].v.tc[1] = 0; + + pauseCtx->cursorVtx[phi_t2].v.cn[0] = pauseCtx->cursorVtx[phi_t2].v.cn[1] = + pauseCtx->cursorVtx[phi_t2].v.cn[2] = pauseCtx->cursorVtx[phi_t2].v.cn[3] = 255; + } + + pauseCtx->cursorVtx[1].v.tc[0] = pauseCtx->cursorVtx[2].v.tc[1] = pauseCtx->cursorVtx[3].v.tc[0] = + pauseCtx->cursorVtx[3].v.tc[1] = pauseCtx->cursorVtx[5].v.tc[0] = pauseCtx->cursorVtx[6].v.tc[1] = + pauseCtx->cursorVtx[7].v.tc[0] = pauseCtx->cursorVtx[7].v.tc[1] = pauseCtx->cursorVtx[9].v.tc[0] = + pauseCtx->cursorVtx[10].v.tc[1] = pauseCtx->cursorVtx[11].v.tc[0] = pauseCtx->cursorVtx[11].v.tc[1] = + pauseCtx->cursorVtx[13].v.tc[0] = pauseCtx->cursorVtx[14].v.tc[1] = + pauseCtx->cursorVtx[15].v.tc[0] = pauseCtx->cursorVtx[15].v.tc[1] = 0x200; + + pauseCtx->cursorVtx[17].v.tc[0] = pauseCtx->cursorVtx[18].v.tc[1] = pauseCtx->cursorVtx[19].v.tc[0] = + pauseCtx->cursorVtx[19].v.tc[1] = 0x400; + + pauseCtx->itemVtx = Graph_Alloc(gfxCtx, 164 * sizeof(Vtx)); + + for (phi_t4 = 0, phi_t2 = 0, phi_t5 = 58; phi_t4 < 4; phi_t4++, phi_t5 -= 32) { + for (phi_t1 = -96, phi_t3 = 0; phi_t3 < 6; phi_t3++, phi_t2 += 4, phi_t1 += 32) { + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 2].v.ob[0] = phi_t1 + 2; + + pauseCtx->itemVtx[phi_t2 + 1].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[0] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] + 0x1C; + + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 1].v.ob[1] = + phi_t5 + pauseCtx->offsetY - 2; + + pauseCtx->itemVtx[phi_t2 + 2].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[1] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1] - 0x1C; + + pauseCtx->itemVtx[phi_t2 + 0].v.ob[2] = pauseCtx->itemVtx[phi_t2 + 1].v.ob[2] = + pauseCtx->itemVtx[phi_t2 + 2].v.ob[2] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[2] = 0; + + pauseCtx->itemVtx[phi_t2 + 0].v.flag = pauseCtx->itemVtx[phi_t2 + 1].v.flag = + pauseCtx->itemVtx[phi_t2 + 2].v.flag = pauseCtx->itemVtx[phi_t2 + 3].v.flag = 0; + + pauseCtx->itemVtx[phi_t2 + 0].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 0].v.tc[1] = + pauseCtx->itemVtx[phi_t2 + 1].v.tc[1] = pauseCtx->itemVtx[phi_t2 + 2].v.tc[0] = 0; + + pauseCtx->itemVtx[phi_t2 + 1].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 2].v.tc[1] = + pauseCtx->itemVtx[phi_t2 + 3].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 3].v.tc[1] = 0x400; + + pauseCtx->itemVtx[phi_t2 + 0].v.cn[0] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[0] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[0] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[0] = + pauseCtx->itemVtx[phi_t2 + 0].v.cn[1] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[1] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[1] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[1] = + pauseCtx->itemVtx[phi_t2 + 0].v.cn[2] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[2] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[2] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[2] = 255; + + pauseCtx->itemVtx[phi_t2 + 0].v.cn[3] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[3] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[3] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[3] = 255; + } + } + + for (phi_t3 = 1; phi_t3 < 4; phi_t3++, phi_t2 += 4) { + if (gSaveContext.equips.cButtonSlots[phi_t3 - 1] != ITEM_NONE) { + phi_t4 = gSaveContext.equips.cButtonSlots[phi_t3 - 1] * 4; + + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 2].v.ob[0] = + pauseCtx->itemVtx[phi_t4].v.ob[0] - 2; + + pauseCtx->itemVtx[phi_t2 + 1].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[0] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] + 32; + + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 1].v.ob[1] = + pauseCtx->itemVtx[phi_t4].v.ob[1] + 2; + + pauseCtx->itemVtx[phi_t2 + 2].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[1] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1] - 32; + + pauseCtx->itemVtx[phi_t2 + 0].v.ob[2] = pauseCtx->itemVtx[phi_t2 + 1].v.ob[2] = + pauseCtx->itemVtx[phi_t2 + 2].v.ob[2] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[2] = 0; + + pauseCtx->itemVtx[phi_t2 + 0].v.flag = pauseCtx->itemVtx[phi_t2 + 1].v.flag = + pauseCtx->itemVtx[phi_t2 + 2].v.flag = pauseCtx->itemVtx[phi_t2 + 3].v.flag = 0; + + pauseCtx->itemVtx[phi_t2 + 0].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 0].v.tc[1] = + pauseCtx->itemVtx[phi_t2 + 1].v.tc[1] = pauseCtx->itemVtx[phi_t2 + 2].v.tc[0] = 0; + + pauseCtx->itemVtx[phi_t2 + 1].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 2].v.tc[1] = + pauseCtx->itemVtx[phi_t2 + 3].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 3].v.tc[1] = 0x400; + + pauseCtx->itemVtx[phi_t2 + 0].v.cn[0] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[0] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[0] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[0] = + pauseCtx->itemVtx[phi_t2 + 0].v.cn[1] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[1] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[1] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[1] = + pauseCtx->itemVtx[phi_t2 + 0].v.cn[2] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[2] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[2] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[2] = 255; + + pauseCtx->itemVtx[phi_t2 + 0].v.cn[3] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[3] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[3] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[3] = pauseCtx->alpha; + } else { + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 2].v.ob[0] = -300; + + pauseCtx->itemVtx[phi_t2 + 1].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[0] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] + 32; + + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 1].v.ob[1] = 300; + + pauseCtx->itemVtx[phi_t2 + 2].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[1] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1] - 32; + } + } + + for (phi_t2 = 108, phi_t3 = 0; phi_t3 < 7; phi_t3++) { + phi_t4 = D_8082B11C[phi_t3]; + + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 2].v.ob[0] = + pauseCtx->itemVtx[phi_t4].v.ob[0]; + + pauseCtx->itemVtx[phi_t2 + 1].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[0] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] + 8; + + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 1].v.ob[1] = + pauseCtx->itemVtx[phi_t4].v.ob[1] - 22; + + pauseCtx->itemVtx[phi_t2 + 2].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[1] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1] - 8; + + pauseCtx->itemVtx[phi_t2 + 4].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 6].v.ob[0] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] + 6; + + pauseCtx->itemVtx[phi_t2 + 5].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 7].v.ob[0] = + pauseCtx->itemVtx[phi_t2 + 4].v.ob[0] + 8; + + pauseCtx->itemVtx[phi_t2 + 4].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 5].v.ob[1] = + pauseCtx->itemVtx[phi_t2 + 0].v.ob[1]; + + pauseCtx->itemVtx[phi_t2 + 6].v.ob[1] = pauseCtx->itemVtx[phi_t2 + 7].v.ob[1] = + pauseCtx->itemVtx[phi_t2 + 4].v.ob[1] - 8; + + for (phi_t4 = 0; phi_t4 < 2; phi_t4++, phi_t2 += 4) { + pauseCtx->itemVtx[phi_t2 + 0].v.ob[2] = pauseCtx->itemVtx[phi_t2 + 1].v.ob[2] = + pauseCtx->itemVtx[phi_t2 + 2].v.ob[2] = pauseCtx->itemVtx[phi_t2 + 3].v.ob[2] = 0; + + pauseCtx->itemVtx[phi_t2 + 0].v.flag = pauseCtx->itemVtx[phi_t2 + 1].v.flag = + pauseCtx->itemVtx[phi_t2 + 2].v.flag = pauseCtx->itemVtx[phi_t2 + 3].v.flag = 0; + + pauseCtx->itemVtx[phi_t2 + 0].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 0].v.tc[1] = + pauseCtx->itemVtx[phi_t2 + 1].v.tc[1] = pauseCtx->itemVtx[phi_t2 + 2].v.tc[0] = 0; + + pauseCtx->itemVtx[phi_t2 + 1].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 2].v.tc[1] = + pauseCtx->itemVtx[phi_t2 + 3].v.tc[0] = pauseCtx->itemVtx[phi_t2 + 3].v.tc[1] = 0x100; + + pauseCtx->itemVtx[phi_t2 + 0].v.cn[0] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[0] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[0] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[0] = + pauseCtx->itemVtx[phi_t2 + 0].v.cn[1] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[1] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[1] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[1] = + pauseCtx->itemVtx[phi_t2 + 0].v.cn[2] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[2] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[2] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[2] = 255; + + pauseCtx->itemVtx[phi_t2 + 0].v.cn[3] = pauseCtx->itemVtx[phi_t2 + 1].v.cn[3] = + pauseCtx->itemVtx[phi_t2 + 2].v.cn[3] = pauseCtx->itemVtx[phi_t2 + 3].v.cn[3] = pauseCtx->alpha; + } + } + + pauseCtx->equipVtx = Graph_Alloc(gfxCtx, 112 * sizeof(Vtx)); + + for (phi_t4 = 0, phi_t2 = 0, phi_t5 = 58; phi_t2 < 4; phi_t2++, phi_t5 -= 32) { + for (phi_t3 = 0; phi_t3 < 4; phi_t3++, phi_t4 += 4) { + pauseCtx->equipVtx[phi_t4 + 0].v.ob[0] = pauseCtx->equipVtx[phi_t4 + 2].v.ob[0] = D_8082B12C[phi_t3] + 2; + + pauseCtx->equipVtx[phi_t4 + 1].v.ob[0] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[0] = + pauseCtx->equipVtx[phi_t4 + 0].v.ob[0] + 28; + + pauseCtx->equipVtx[phi_t4 + 0].v.ob[1] = pauseCtx->equipVtx[phi_t4 + 1].v.ob[1] = + phi_t5 + pauseCtx->offsetY - 2; + + pauseCtx->equipVtx[phi_t4 + 2].v.ob[1] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[1] = + pauseCtx->equipVtx[phi_t4 + 0].v.ob[1] - 28; + + pauseCtx->equipVtx[phi_t4 + 0].v.ob[2] = pauseCtx->equipVtx[phi_t4 + 1].v.ob[2] = + pauseCtx->equipVtx[phi_t4 + 2].v.ob[2] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[2] = 0; + + pauseCtx->equipVtx[phi_t4 + 0].v.flag = pauseCtx->equipVtx[phi_t4 + 1].v.flag = + pauseCtx->equipVtx[phi_t4 + 2].v.flag = pauseCtx->equipVtx[phi_t4 + 3].v.flag = 0; + + pauseCtx->equipVtx[phi_t4 + 0].v.tc[0] = pauseCtx->equipVtx[phi_t4 + 0].v.tc[1] = + pauseCtx->equipVtx[phi_t4 + 1].v.tc[1] = pauseCtx->equipVtx[phi_t4 + 2].v.tc[0] = 0; + + pauseCtx->equipVtx[phi_t4 + 1].v.tc[0] = pauseCtx->equipVtx[phi_t4 + 2].v.tc[1] = + pauseCtx->equipVtx[phi_t4 + 3].v.tc[0] = pauseCtx->equipVtx[phi_t4 + 3].v.tc[1] = 0x400; + + pauseCtx->equipVtx[phi_t4 + 0].v.cn[0] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[0] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[0] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[0] = + pauseCtx->equipVtx[phi_t4 + 0].v.cn[1] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[1] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[1] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[1] = + pauseCtx->equipVtx[phi_t4 + 0].v.cn[2] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[2] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[2] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[2] = 255; + + pauseCtx->equipVtx[phi_t4 + 0].v.cn[3] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[3] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[3] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[3] = pauseCtx->alpha; + } + } + + for (phi_t3 = 0; phi_t3 < 4; phi_t3++, phi_t4 += 4) { + if (CUR_EQUIP_VALUE(phi_t3) != 0) { + phi_t2 = (CUR_EQUIP_VALUE(phi_t3) + D_8082B134[phi_t3] - 1) * 4; + + pauseCtx->equipVtx[phi_t4 + 0].v.ob[0] = pauseCtx->equipVtx[phi_t4 + 2].v.ob[0] = + pauseCtx->equipVtx[phi_t2].v.ob[0] - 2; + + pauseCtx->equipVtx[phi_t4 + 1].v.ob[0] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[0] = + pauseCtx->equipVtx[phi_t4 + 0].v.ob[0] + 32; + + pauseCtx->equipVtx[phi_t4 + 0].v.ob[1] = pauseCtx->equipVtx[phi_t4 + 1].v.ob[1] = + pauseCtx->equipVtx[phi_t2].v.ob[1] + 2; + + pauseCtx->equipVtx[phi_t4 + 2].v.ob[1] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[1] = + pauseCtx->equipVtx[phi_t4 + 0].v.ob[1] - 32; + + pauseCtx->equipVtx[phi_t4 + 0].v.ob[2] = pauseCtx->equipVtx[phi_t4 + 1].v.ob[2] = + pauseCtx->equipVtx[phi_t4 + 2].v.ob[2] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[2] = 0; + + pauseCtx->equipVtx[phi_t4 + 0].v.flag = pauseCtx->equipVtx[phi_t4 + 1].v.flag = + pauseCtx->equipVtx[phi_t4 + 2].v.flag = pauseCtx->equipVtx[phi_t4 + 3].v.flag = 0; + + pauseCtx->equipVtx[phi_t4 + 0].v.tc[0] = pauseCtx->equipVtx[phi_t4 + 0].v.tc[1] = + pauseCtx->equipVtx[phi_t4 + 1].v.tc[1] = pauseCtx->equipVtx[phi_t4 + 2].v.tc[0] = 0; + + pauseCtx->equipVtx[phi_t4 + 1].v.tc[0] = pauseCtx->equipVtx[phi_t4 + 2].v.tc[1] = + pauseCtx->equipVtx[phi_t4 + 3].v.tc[0] = pauseCtx->equipVtx[phi_t4 + 3].v.tc[1] = 0x400; + + pauseCtx->equipVtx[phi_t4 + 0].v.cn[0] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[0] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[0] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[0] = + pauseCtx->equipVtx[phi_t4 + 0].v.cn[1] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[1] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[1] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[1] = + pauseCtx->equipVtx[phi_t4 + 0].v.cn[2] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[2] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[2] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[2] = 255; + + pauseCtx->equipVtx[phi_t4 + 0].v.cn[3] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[3] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[3] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[3] = pauseCtx->alpha; + } + } + + phi_t1 = 112; + phi_t5 = 50; + while (true) { + pauseCtx->equipVtx[phi_t4 + 0].v.ob[0] = pauseCtx->equipVtx[phi_t4 + 2].v.ob[0] = -64; + + pauseCtx->equipVtx[phi_t4 + 1].v.ob[0] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[0] = + pauseCtx->equipVtx[phi_t4 + 0].v.ob[0] + 64; + + pauseCtx->equipVtx[phi_t4 + 0].v.ob[1] = pauseCtx->equipVtx[phi_t4 + 1].v.ob[1] = phi_t5 + pauseCtx->offsetY; + + pauseCtx->equipVtx[phi_t4 + 2].v.ob[1] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[1] = + pauseCtx->equipVtx[phi_t4 + 0].v.ob[1] - 32; + + pauseCtx->equipVtx[phi_t4 + 0].v.ob[2] = pauseCtx->equipVtx[phi_t4 + 1].v.ob[2] = + pauseCtx->equipVtx[phi_t4 + 2].v.ob[2] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[2] = 0; + + pauseCtx->equipVtx[phi_t4 + 0].v.flag = pauseCtx->equipVtx[phi_t4 + 1].v.flag = + pauseCtx->equipVtx[phi_t4 + 2].v.flag = pauseCtx->equipVtx[phi_t4 + 3].v.flag = 0; + + pauseCtx->equipVtx[phi_t4 + 0].v.tc[0] = pauseCtx->equipVtx[phi_t4 + 0].v.tc[1] = + pauseCtx->equipVtx[phi_t4 + 1].v.tc[1] = pauseCtx->equipVtx[phi_t4 + 2].v.tc[0] = 0; + + pauseCtx->equipVtx[phi_t4 + 1].v.tc[0] = pauseCtx->equipVtx[phi_t4 + 3].v.tc[0] = 0x800; + + pauseCtx->equipVtx[phi_t4 + 2].v.tc[1] = pauseCtx->equipVtx[phi_t4 + 3].v.tc[1] = 0x400; + + pauseCtx->equipVtx[phi_t4 + 0].v.cn[0] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[0] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[0] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[0] = + pauseCtx->equipVtx[phi_t4 + 0].v.cn[1] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[1] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[1] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[1] = + pauseCtx->equipVtx[phi_t4 + 0].v.cn[2] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[2] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[2] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[2] = 255; + + pauseCtx->equipVtx[phi_t4 + 0].v.cn[3] = pauseCtx->equipVtx[phi_t4 + 1].v.cn[3] = + pauseCtx->equipVtx[phi_t4 + 2].v.cn[3] = pauseCtx->equipVtx[phi_t4 + 3].v.cn[3] = pauseCtx->alpha; + + phi_t1 -= 32; + phi_t5 -= 32; + if (phi_t1 < 0) { + pauseCtx->equipVtx[phi_t4 + 2].v.ob[1] = pauseCtx->equipVtx[phi_t4 + 3].v.ob[1] = + pauseCtx->equipVtx[phi_t4 + 0].v.ob[1] - 0x10; + + pauseCtx->equipVtx[phi_t4 + 2].v.tc[1] = pauseCtx->equipVtx[phi_t4 + 3].v.tc[1] = 0x200; + break; + } + + phi_t4 += 4; + } + + pauseCtx->questVtx = Graph_Alloc(gfxCtx, 188 * sizeof(Vtx)); + + for (phi_t4 = 0, phi_t3 = 0; phi_t3 < 47; phi_t3++, phi_t4 += 4) { + phi_t2_2 = D_8082B1F8[phi_t3]; + + if ((phi_t3 < 6) || (phi_t3 >= 41)) { + pauseCtx->questVtx[phi_t4 + 0].v.ob[0] = pauseCtx->questVtx[phi_t4 + 2].v.ob[0] = D_8082B138[phi_t3]; + + pauseCtx->questVtx[phi_t4 + 1].v.ob[0] = pauseCtx->questVtx[phi_t4 + 3].v.ob[0] = + pauseCtx->questVtx[phi_t4 + 0].v.ob[0] + D_8082B1F8[phi_t3]; + + pauseCtx->questVtx[phi_t4 + 0].v.ob[1] = pauseCtx->questVtx[phi_t4 + 1].v.ob[1] = + D_8082B198[phi_t3] + pauseCtx->offsetY; + + pauseCtx->questVtx[phi_t4 + 2].v.ob[1] = pauseCtx->questVtx[phi_t4 + 3].v.ob[1] = + pauseCtx->questVtx[phi_t4 + 0].v.ob[1] - D_8082B1F8[phi_t3]; + + if (phi_t3 >= 41) { + pauseCtx->questVtx[phi_t4 + 1].v.ob[0] = pauseCtx->questVtx[phi_t4 + 3].v.ob[0] = + pauseCtx->questVtx[phi_t4 + 0].v.ob[0] + 8; + + pauseCtx->questVtx[phi_t4 + 0].v.ob[1] = pauseCtx->questVtx[phi_t4 + 1].v.ob[1] = + D_8082B198[phi_t3] + pauseCtx->offsetY - 6; + + pauseCtx->questVtx[phi_t4 + 2].v.ob[1] = pauseCtx->questVtx[phi_t4 + 3].v.ob[1] = + pauseCtx->questVtx[phi_t4 + 0].v.ob[1] - 16; + + phi_t2_2 = 8; + } + } else { + if ((phi_t3 >= 6) && (phi_t3 <= 17)) { + phi_t2_2 = 16; + } + + pauseCtx->questVtx[phi_t4 + 0].v.ob[0] = pauseCtx->questVtx[phi_t4 + 2].v.ob[0] = D_8082B138[phi_t3] + 2; + + pauseCtx->questVtx[phi_t4 + 1].v.ob[0] = pauseCtx->questVtx[phi_t4 + 3].v.ob[0] = + pauseCtx->questVtx[phi_t4 + 0].v.ob[0] + phi_t2_2 - 4; + + pauseCtx->questVtx[phi_t4 + 0].v.ob[1] = pauseCtx->questVtx[phi_t4 + 1].v.ob[1] = + D_8082B198[phi_t3] + pauseCtx->offsetY - 2; + + pauseCtx->questVtx[phi_t4 + 2].v.ob[1] = pauseCtx->questVtx[phi_t4 + 3].v.ob[1] = + pauseCtx->questVtx[phi_t4 + 0].v.ob[1] - D_8082B1F8[phi_t3] + 4; + } + + pauseCtx->questVtx[phi_t4 + 0].v.ob[2] = pauseCtx->questVtx[phi_t4 + 1].v.ob[2] = + pauseCtx->questVtx[phi_t4 + 2].v.ob[2] = pauseCtx->questVtx[phi_t4 + 3].v.ob[2] = 0; + + pauseCtx->questVtx[phi_t4 + 0].v.flag = pauseCtx->questVtx[phi_t4 + 1].v.flag = + pauseCtx->questVtx[phi_t4 + 2].v.flag = pauseCtx->questVtx[phi_t4 + 3].v.flag = 0; + + pauseCtx->questVtx[phi_t4 + 0].v.tc[0] = pauseCtx->questVtx[phi_t4 + 0].v.tc[1] = + pauseCtx->questVtx[phi_t4 + 1].v.tc[1] = pauseCtx->questVtx[phi_t4 + 2].v.tc[0] = 0; + + pauseCtx->questVtx[phi_t4 + 1].v.tc[0] = pauseCtx->questVtx[phi_t4 + 3].v.tc[0] = phi_t2_2 << 5; + pauseCtx->questVtx[phi_t4 + 2].v.tc[1] = pauseCtx->questVtx[phi_t4 + 3].v.tc[1] = D_8082B1F8[phi_t3] << 5; + + pauseCtx->questVtx[phi_t4 + 0].v.cn[0] = pauseCtx->questVtx[phi_t4 + 1].v.cn[0] = + pauseCtx->questVtx[phi_t4 + 2].v.cn[0] = pauseCtx->questVtx[phi_t4 + 3].v.cn[0] = + pauseCtx->questVtx[phi_t4 + 0].v.cn[1] = pauseCtx->questVtx[phi_t4 + 1].v.cn[1] = + pauseCtx->questVtx[phi_t4 + 2].v.cn[1] = pauseCtx->questVtx[phi_t4 + 3].v.cn[1] = + pauseCtx->questVtx[phi_t4 + 0].v.cn[2] = pauseCtx->questVtx[phi_t4 + 1].v.cn[2] = + pauseCtx->questVtx[phi_t4 + 2].v.cn[2] = pauseCtx->questVtx[phi_t4 + 3].v.cn[2] = 255; + + pauseCtx->questVtx[phi_t4 + 0].v.cn[3] = pauseCtx->questVtx[phi_t4 + 1].v.cn[3] = + pauseCtx->questVtx[phi_t4 + 2].v.cn[3] = pauseCtx->questVtx[phi_t4 + 3].v.cn[3] = pauseCtx->alpha; + } + + pauseCtx->infoPanelVtx = Graph_Alloc(gfxCtx, 28 * sizeof(Vtx)); + + pauseCtx->saveVtx = Graph_Alloc(gfxCtx, 80 * sizeof(Vtx)); + func_80823A0C(globalCtx, pauseCtx->saveVtx, 5, 5); +} + +void KaleidoScope_DrawGameOver(GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx, "../z_kaleido_scope_PAL.c", 3122); + + func_800944C4(gfxCtx); + + gDPSetCycleType(POLY_OPA_DISP++, G_CYC_2CYCLE); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_XLU_SURF2); + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, 0, 0, 0, TEXEL0, PRIMITIVE, ENVIRONMENT, + COMBINED, ENVIRONMENT, COMBINED, 0, PRIMITIVE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 80, D_8082AB8C, D_8082AB90, D_8082AB94, D_8082AB98); + gDPSetEnvColor(POLY_OPA_DISP++, D_8082AB9C, D_8082ABA0, D_8082ABA4, 255); + + VREG(89) -= 2; + + gDPLoadMultiBlock(POLY_OPA_DISP++, gGameOverP1Tex, 0, 0, G_IM_FMT_IA, G_IM_SIZ_8b, 64, 32, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gDPLoadMultiBlock(POLY_OPA_DISP++, gGameOverMaskTex, 256, 1, G_IM_FMT_IA, G_IM_SIZ_8b, 64, 32, 0, + G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, 5, G_TX_NOLOD, G_TX_NOLOD); + + gDPSetTileSize(POLY_OPA_DISP++, 1, 0, VREG(89) & 0x7F, 252, (VREG(89) & 0x7F) + 0x7C); + + gSPTextureRectangle(POLY_OPA_DISP++, VREG(87) << 2, VREG(88) << 2, (VREG(87) + 64) << 2, (VREG(88) + 32) << 2, + G_TX_RENDERTILE, 0, 0, 1024, 1024); + + gDPLoadMultiBlock(POLY_OPA_DISP++, gGameOverP2Tex, 0, 0, G_IM_FMT_IA, G_IM_SIZ_8b, 64, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSPTextureRectangle(POLY_OPA_DISP++, (VREG(87) + 64) << 2, VREG(88) << 2, (VREG(87) + 128) << 2, + (VREG(88) + 32) << 2, G_TX_RENDERTILE, 0, 0, 1024, 1024); + + gDPLoadMultiBlock(POLY_OPA_DISP++, gGameOverP3Tex, 0, 0, G_IM_FMT_IA, G_IM_SIZ_8b, 64, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + gSPTextureRectangle(POLY_OPA_DISP++, (VREG(87) + 128) << 2, VREG(88) << 2, (VREG(87) + 192) << 2, + (VREG(88) + 32) << 2, G_TX_RENDERTILE, 0, 0, 1024, 1024); + + CLOSE_DISPS(gfxCtx, "../z_kaleido_scope_PAL.c", 3169); +} void KaleidoScope_Draw(GlobalContext* globalCtx) { Input* input = &globalCtx->state.input[0]; @@ -47,50 +2262,1215 @@ void KaleidoScope_Draw(GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 3188); - pauseCtx->inputX = input->rel.stick_x; - pauseCtx->inputY = input->rel.stick_y; + pauseCtx->stickRelX = input->rel.stick_x; + pauseCtx->stickRelY = input->rel.stick_y; gSPSegment(POLY_OPA_DISP++, 0x02, interfaceCtx->parameterSegment); - gSPSegment(POLY_OPA_DISP++, 0x07, pauseCtx->unk_13C); - gSPSegment(POLY_OPA_DISP++, 0x08, pauseCtx->unk_128); - gSPSegment(POLY_OPA_DISP++, 0x09, pauseCtx->unk_12C); - gSPSegment(POLY_OPA_DISP++, 0x0A, pauseCtx->unk_138); - gSPSegment(POLY_OPA_DISP++, 0x0C, pauseCtx->unk_130); - gSPSegment(POLY_OPA_DISP++, 0x0D, pauseCtx->unk_134); - - if (pauseCtx->flag == 0) { - func_80823994(pauseCtx, pauseCtx->eye.x, pauseCtx->eye.y, pauseCtx->eye.z); - func_800949A8(globalCtx->state.gfxCtx); - func_8082409C(globalCtx, globalCtx->state.gfxCtx); - func_80820434(globalCtx, globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x07, pauseCtx->playerSegment); + gSPSegment(POLY_OPA_DISP++, 0x08, pauseCtx->iconItemSegment); + gSPSegment(POLY_OPA_DISP++, 0x09, pauseCtx->iconItem24Segment); + gSPSegment(POLY_OPA_DISP++, 0x0A, pauseCtx->nameSegment); + gSPSegment(POLY_OPA_DISP++, 0x0C, pauseCtx->iconItemAltSegment); + gSPSegment(POLY_OPA_DISP++, 0x0D, pauseCtx->iconItemLangSegment); + + if (pauseCtx->debugState == 0) { + KaleidoScope_SetView(pauseCtx, pauseCtx->eye.x, pauseCtx->eye.y, pauseCtx->eye.z); + func_800949A8(globalCtx->state.gfxCtx); + KaleidoScope_InitVertices(globalCtx, globalCtx->state.gfxCtx); + KaleidoScope_DrawPages(globalCtx, globalCtx->state.gfxCtx); + func_800949A8(globalCtx->state.gfxCtx); gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - func_80823994(pauseCtx, 0.0f, 0.0f, 64.0f); - if (pauseCtx->state < 8 || 17 < pauseCtx->state) { - func_80821C10(globalCtx); + KaleidoScope_SetView(pauseCtx, 0.0f, 0.0f, 64.0f); + + if (!((pauseCtx->state >= 8) && (pauseCtx->state <= 0x11))) { + KaleidoScope_DrawInfoPanel(globalCtx); } } - if (pauseCtx->state > 10 && pauseCtx->state <= 17) { - func_80825C14(globalCtx); + + if ((pauseCtx->state >= 0xB) && (pauseCtx->state <= 0x11)) { + KaleidoScope_DrawGameOver(globalCtx); } - if (pauseCtx->flag == 1 || pauseCtx->flag == 2) { - func_808161AC(globalCtx); + + if ((pauseCtx->debugState == 1) || (pauseCtx->debugState == 2)) { + KaleidoScope_DrawDebugEditor(globalCtx); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 3254); } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8082650C.s") +void KaleidoScope_GrayOutTextureRGBA32(u32* texture, u16 pixelCount) { + u32 rgb; + u16 gray; + u16 i; + + for (i = 0; i < pixelCount; i++) { + if ((texture[i] & 0xFFFFFF00) != 0) { + rgb = texture[i] >> 8; + gray = ((((rgb & 0xFF0000) >> 16) + ((rgb & 0xFF00) >> 7) + (rgb & 0xFF)) / 7) & 0xFF; + + rgb = gray; + rgb <<= 8; + rgb |= gray; + rgb <<= 8; + rgb |= gray; + + texture[i] = (rgb << 8) | (texture[i] & 0xFF); + } + } +} + +void func_808265BC(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + + pauseCtx->eye.x += D_8082ABAC[pauseCtx->mode] * ZREG(46); + pauseCtx->eye.z += D_8082ABCC[pauseCtx->mode] * ZREG(46); + pauseCtx->unk_1EA += 4 * ZREG(46); + + if (pauseCtx->unk_1EA == (64 * ZREG(47))) { + func_80084BF4(globalCtx, 1); + gSaveContext.buttonStatus[0] = D_8082AB6C[pauseCtx->pageIndex][0]; + gSaveContext.buttonStatus[1] = D_8082AB6C[pauseCtx->pageIndex][1]; + gSaveContext.buttonStatus[2] = D_8082AB6C[pauseCtx->pageIndex][2]; + gSaveContext.buttonStatus[3] = D_8082AB6C[pauseCtx->pageIndex][3]; + gSaveContext.buttonStatus[4] = D_8082AB6C[pauseCtx->pageIndex][4]; + pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; + pauseCtx->unk_1E4 = 0; + pauseCtx->state++; + pauseCtx->alpha = 255; + Interface_LoadActionLabelB(globalCtx, 0xE); + } else if (pauseCtx->unk_1EA == 64) { + pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; + pauseCtx->mode = (u16)(pauseCtx->pageIndex * 2) + 1; + } +} + +void KaleidoScope_UpdateCursorSize(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s32 temp1; + s32 temp2; + s32 temp3; + s32 temp4; + + if (pauseCtx->cursorSpecialPos == 0) { + temp1 = -1; + temp2 = 1; + temp3 = 14; + temp4 = 14; + if (pauseCtx->pageIndex == PAUSE_MAP) { + if (!sInDungeonScene) { + temp1 = -6; + temp2 = 6; + temp3 = 4; + temp4 = 4; + } else if (pauseCtx->cursorSlot[pauseCtx->pageIndex] >= 3) { + temp1 = -6; + temp2 = 5; + temp4 = 7; + temp3 = 19; + } else { + temp1 = -3; + temp2 = 3; + temp3 = 13; + temp4 = 13; + } + } else if (pauseCtx->pageIndex == PAUSE_QUEST) { + temp1 = -4; + temp2 = 4; + temp3 = 12; + temp4 = 12; + if (pauseCtx->cursorSlot[pauseCtx->pageIndex] == 0x18) { + temp1 = -2; + temp2 = 2; + temp3 = 32; + temp4 = 32; + } else if (pauseCtx->cursorSlot[pauseCtx->pageIndex] == 0x17) { + temp1 = -4; + temp2 = 4; + temp4 = 13; + temp3 = 34; + } else if (pauseCtx->cursorSlot[pauseCtx->pageIndex] < 6) { + temp1 = -1; + temp2 = 1; + temp3 = 10; + temp4 = 10; + } else if ((pauseCtx->cursorSlot[pauseCtx->pageIndex] >= 6) && + (pauseCtx->cursorSlot[pauseCtx->pageIndex] < 0x12)) { + temp1 = -5; + temp2 = 3; + temp3 = 8; + temp4 = 8; + } + } + } else { + temp1 = -4; + temp2 = 4; + temp3 = 16; + temp4 = 16; + } + + pauseCtx->cursorVtx[0].v.ob[0] = pauseCtx->cursorVtx[2].v.ob[0] = pauseCtx->cursorVtx[0].v.ob[0] + temp1; + pauseCtx->cursorVtx[1].v.ob[0] = pauseCtx->cursorVtx[3].v.ob[0] = pauseCtx->cursorVtx[0].v.ob[0] + 16; + pauseCtx->cursorVtx[0].v.ob[1] = pauseCtx->cursorVtx[1].v.ob[1] = pauseCtx->cursorVtx[0].v.ob[1] + temp2; + pauseCtx->cursorVtx[2].v.ob[1] = pauseCtx->cursorVtx[3].v.ob[1] = pauseCtx->cursorVtx[0].v.ob[1] - 16; + + pauseCtx->cursorVtx[4].v.ob[0] = pauseCtx->cursorVtx[6].v.ob[0] = pauseCtx->cursorVtx[0].v.ob[0] + temp3; + pauseCtx->cursorVtx[5].v.ob[0] = pauseCtx->cursorVtx[7].v.ob[0] = pauseCtx->cursorVtx[4].v.ob[0] + 16; + pauseCtx->cursorVtx[4].v.ob[1] = pauseCtx->cursorVtx[5].v.ob[1] = pauseCtx->cursorVtx[0].v.ob[1]; + pauseCtx->cursorVtx[6].v.ob[1] = pauseCtx->cursorVtx[7].v.ob[1] = pauseCtx->cursorVtx[4].v.ob[1] - 16; + + pauseCtx->cursorVtx[8].v.ob[0] = pauseCtx->cursorVtx[10].v.ob[0] = pauseCtx->cursorVtx[0].v.ob[0]; + pauseCtx->cursorVtx[9].v.ob[0] = pauseCtx->cursorVtx[11].v.ob[0] = pauseCtx->cursorVtx[8].v.ob[0] + 16; + pauseCtx->cursorVtx[8].v.ob[1] = pauseCtx->cursorVtx[9].v.ob[1] = pauseCtx->cursorVtx[0].v.ob[1] - temp4; + pauseCtx->cursorVtx[10].v.ob[1] = pauseCtx->cursorVtx[11].v.ob[1] = pauseCtx->cursorVtx[8].v.ob[1] - 16; + + pauseCtx->cursorVtx[12].v.ob[0] = pauseCtx->cursorVtx[14].v.ob[0] = pauseCtx->cursorVtx[0].v.ob[0] + temp3; + pauseCtx->cursorVtx[13].v.ob[0] = pauseCtx->cursorVtx[15].v.ob[0] = pauseCtx->cursorVtx[12].v.ob[0] + 16; + pauseCtx->cursorVtx[12].v.ob[1] = pauseCtx->cursorVtx[13].v.ob[1] = pauseCtx->cursorVtx[0].v.ob[1] - temp4; + pauseCtx->cursorVtx[14].v.ob[1] = pauseCtx->cursorVtx[15].v.ob[1] = pauseCtx->cursorVtx[12].v.ob[1] - 16; +} + +void KaleidoScope_LoadDungeonMap(GlobalContext* globalCtx) { + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + s32 pad; + + DmaMgr_SendRequest1(interfaceCtx->mapSegment, (u32)_map_48x85_staticSegmentRomStart + (R_MAP_TEX_INDEX * 2040), + 2040, "../z_kaleido_scope_PAL.c", 3467); + + DmaMgr_SendRequest1(interfaceCtx->mapSegment + 0x800, + (u32)_map_48x85_staticSegmentRomStart + ((R_MAP_TEX_INDEX + 1) * 2040), 2040, + "../z_kaleido_scope_PAL.c", 3471); +} + +void KaleidoScope_UpdateDungeonMap(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + + osSyncPrintf("MAP DMA = %d\n", globalCtx->interfaceCtx.mapPaletteIndex); + + KaleidoScope_LoadDungeonMap(globalCtx); + Map_SetFloorPalettesData(globalCtx, pauseCtx->dungeonMapSlot - 3); + + if ((globalCtx->sceneNum >= SCENE_YDAN) && (globalCtx->sceneNum <= SCENE_TAKARAYA)) { + if ((VREG(30) + 3) == pauseCtx->cursorPoint[PAUSE_MAP]) { + KaleidoScope_OverridePalIndexCI4(interfaceCtx->mapSegment, 2040, interfaceCtx->mapPaletteIndex, 14); + } + } + + if ((globalCtx->sceneNum >= SCENE_YDAN) && (globalCtx->sceneNum <= SCENE_TAKARAYA)) { + if ((VREG(30) + 3) == pauseCtx->cursorPoint[PAUSE_MAP]) { + KaleidoScope_OverridePalIndexCI4(interfaceCtx->mapSegment + 0x800, 2040, interfaceCtx->mapPaletteIndex, 14); + } + } +} + +void KaleidoScope_Update(GlobalContext* globalCtx) { + static s16 D_8082B258 = 0; + static s16 D_8082B25C = 10; + static s16 D_8082B260 = 0; + PauseContext* pauseCtx = &globalCtx->pauseCtx; + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + GameOverContext* gameOverCtx = &globalCtx->gameOverCtx; + Player* player = PLAYER; + Input* input = &globalCtx->state.input[0]; + u32 size; + u32 size0; + u32 size1; + u32 size2; + u16 i; + s16 stepR; + s16 stepG; + s16 stepB; + s16 stepA; + s32 pad; + + if ((R_PAUSE_MENU_MODE >= 3) && (((pauseCtx->state >= 4) && (pauseCtx->state <= 7)) || + ((pauseCtx->state >= 0xA) && (pauseCtx->state <= 0x12)))) { + + if ((!pauseCtx->unk_1E4 || (pauseCtx->unk_1E4 == 8)) && (pauseCtx->state == 6)) { + pauseCtx->stickRelX = input->rel.stick_x; + pauseCtx->stickRelY = input->rel.stick_y; + KaleidoScope_UpdateCursorSize(globalCtx); + KaleidoScope_HandlePageToggles(pauseCtx, input); + } else if ((pauseCtx->pageIndex == PAUSE_QUEST) && ((pauseCtx->unk_1E4 < 3) || (pauseCtx->unk_1E4 == 5))) { + KaleidoScope_UpdateCursorSize(globalCtx); + } + + if (pauseCtx->state == 6) { + KaleidoScope_UpdateNamePanel(globalCtx); + } + } + + switch (pauseCtx->state) { + case 3: + D_808321A8[0] = gSaveContext.buttonStatus[0]; + D_808321A8[1] = gSaveContext.buttonStatus[1]; + D_808321A8[2] = gSaveContext.buttonStatus[2]; + D_808321A8[3] = gSaveContext.buttonStatus[3]; + D_808321A8[4] = gSaveContext.buttonStatus[4]; + + pauseCtx->cursorX[PAUSE_MAP] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot = + VREG(30) + 3; + + WREG(16) = -175; + WREG(17) = 155; + + pauseCtx->unk_204 = -314.0f; + + pauseCtx->playerSegment = (void*)(((u32)globalCtx->objectCtx.spaceStart + 0x30) & ~0x3F); + + size1 = func_80091738(globalCtx, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime); + osSyncPrintf("プレイヤー size1=%x\n", size1); + + pauseCtx->iconItemSegment = (void*)(((u32)pauseCtx->playerSegment + size1 + 0xF) & ~0xF); + + size0 = (u32)_icon_item_staticSegmentRomEnd - (u32)_icon_item_staticSegmentRomStart; + osSyncPrintf("icon_item size0=%x\n", size0); + DmaMgr_SendRequest1(pauseCtx->iconItemSegment, (u32)_icon_item_staticSegmentRomStart, size0, + "../z_kaleido_scope_PAL.c", 3662); + + gSegments[8] = VIRTUAL_TO_PHYSICAL(pauseCtx->iconItemSegment); + + for (i = 0; i < ARRAY_COUNTU(gItemAgeReqs); i++) { + if ((gItemAgeReqs[i] != 9) && (gItemAgeReqs[i] != ((void)0, gSaveContext.linkAge))) { + KaleidoScope_GrayOutTextureRGBA32(SEGMENTED_TO_VIRTUAL(gItemIcons[i]), 0x400); + } + } + + pauseCtx->iconItem24Segment = (void*)(((u32)pauseCtx->iconItemSegment + size0 + 0xF) & ~0xF); + + size = (u32)_icon_item_24_staticSegmentRomEnd - (u32)_icon_item_24_staticSegmentRomStart; + osSyncPrintf("icon_item24 size=%x\n", size); + DmaMgr_SendRequest1(pauseCtx->iconItem24Segment, (u32)_icon_item_24_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 3675); + + pauseCtx->iconItemAltSegment = (void*)(((u32)pauseCtx->iconItem24Segment + size + 0xF) & ~0xF); + + switch (globalCtx->sceneNum) { + case SCENE_YDAN: + case SCENE_DDAN: + case SCENE_BDAN: + case SCENE_BMORI1: + case SCENE_HIDAN: + case SCENE_MIZUSIN: + case SCENE_JYASINZOU: + case SCENE_HAKADAN: + case SCENE_HAKADANCH: + case SCENE_ICE_DOUKUTO: + case SCENE_YDAN_BOSS: + case SCENE_DDAN_BOSS: + case SCENE_BDAN_BOSS: + case SCENE_MORIBOSSROOM: + case SCENE_FIRE_BS: + case SCENE_MIZUSIN_BS: + case SCENE_JYASINBOSS: + case SCENE_HAKADAN_BS: + sInDungeonScene = true; + size2 = (u32)_icon_item_dungeon_staticSegmentRomEnd - (u32)_icon_item_dungeon_staticSegmentRomStart; + osSyncPrintf("icon_item_dungeon dungeon-size2=%x\n", size2); + DmaMgr_SendRequest1(pauseCtx->iconItemAltSegment, (u32)_icon_item_dungeon_staticSegmentRomStart, + size2, "../z_kaleido_scope_PAL.c", 3712); + + interfaceCtx->mapPalette[28] = 6; + interfaceCtx->mapPalette[29] = 99; + KaleidoScope_UpdateDungeonMap(globalCtx); + break; + + default: + sInDungeonScene = false; + size2 = (u32)_icon_item_field_staticSegmentRomEnd - (u32)_icon_item_field_staticSegmentRomStart; + osSyncPrintf("icon_item_field field-size2=%x\n", size2); + DmaMgr_SendRequest1(pauseCtx->iconItemAltSegment, (u32)_icon_item_field_staticSegmentRomStart, + size2, "../z_kaleido_scope_PAL.c", 3726); + break; + } + + pauseCtx->iconItemLangSegment = (void*)(((u32)pauseCtx->iconItemAltSegment + size2 + 0xF) & ~0xF); + + if (gSaveContext.language == 0) { + size = (u32)_icon_item_nes_staticSegmentRomEnd - (u32)_icon_item_nes_staticSegmentRomStart; + osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); + DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, _icon_item_nes_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 3739); + } else if (gSaveContext.language == 1) { + size = (u32)_icon_item_ger_staticSegmentRomEnd - (u32)_icon_item_ger_staticSegmentRomStart; + osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); + DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (u32)_icon_item_ger_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 3746); + } else { + size = (u32)_icon_item_fra_staticSegmentRomEnd - (u32)_icon_item_fra_staticSegmentRomStart; + osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); + DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (u32)_icon_item_fra_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 3753); + } + + pauseCtx->nameSegment = (void*)(((u32)pauseCtx->iconItemLangSegment + size + 0xF) & ~0xF); + + osSyncPrintf("サイズ=%x\n", size2 + size1 + size0 + size); + osSyncPrintf("item_name I_N_PT=%x\n", 0x800); + Interface_SetDoAction(globalCtx, 6); + osSyncPrintf("サイズ=%x\n", size2 + size1 + size0 + size + 0x800); + + if (((void)0, gSaveContext.worldMapArea) < 22) { + if (gSaveContext.language == 0) { + DmaMgr_SendRequest1(pauseCtx->nameSegment + 0x400, + (u32)_map_name_staticSegmentRomStart + + (((void)0, gSaveContext.worldMapArea) * 0xA00) + 0x9000, + 0xA00, "../z_kaleido_scope_PAL.c", 3776); + } else if (gSaveContext.language == 1) { + DmaMgr_SendRequest1(pauseCtx->nameSegment + 0x400, + (u32)_map_name_staticSegmentRomStart + + (((void)0, gSaveContext.worldMapArea) * 0xA00) + 0x16C00, + 0xA00, "../z_kaleido_scope_PAL.c", 3780); + } else { + DmaMgr_SendRequest1(pauseCtx->nameSegment + 0x400, + (u32)_map_name_staticSegmentRomStart + + (((void)0, gSaveContext.worldMapArea) * 0xA00) + 0x24800, + 0xA00, "../z_kaleido_scope_PAL.c", 3784); + } + } + + sPreRenderCvg = (void*)(((u32)pauseCtx->nameSegment + 0x400 + 0xA00 + 0xF) & ~0xF); + + PreRender_Init(&sPlayerPreRenderCtx); + PreRender_SetValuesSave(&sPlayerPreRenderCtx, 64, 112, pauseCtx->playerSegment, NULL, sPreRenderCvg); + + KaleidoScope_DrawPlayerWork(globalCtx); + KaleidoScope_SetupPlayerPreRender(globalCtx); + + for (i = 0; i < ARRAY_COUNT(pauseCtx->worldMapPoints); i++) { + pauseCtx->worldMapPoints[i] = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_808265BC.s") + if (CHECK_QUEST_ITEM(QUEST_GERUDO_CARD)) { + pauseCtx->worldMapPoints[0] = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_808267AC.s") + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { + pauseCtx->worldMapPoints[0] = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80826AEC.s") + if (INV_CONTENT(ITEM_LONGSHOT) == ITEM_LONGSHOT) { + pauseCtx->worldMapPoints[1] = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80826BA8.s") + if (CHECK_QUEST_ITEM(QUEST_GERUDO_CARD)) { + pauseCtx->worldMapPoints[1] = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/KaleidoScope_Update.s") + if (gSaveContext.eventChkInf[11] & 4) { + pauseCtx->worldMapPoints[2] = 1; + } + + if (INV_CONTENT(ITEM_LONGSHOT) == ITEM_LONGSHOT) { + pauseCtx->worldMapPoints[2] = 2; + } + + if (CHECK_QUEST_ITEM(QUEST_GERUDO_CARD)) { + pauseCtx->worldMapPoints[2] = 1; + } + + if (CUR_UPG_VALUE(UPG_SCALE)) { + pauseCtx->worldMapPoints[3] = 1; + } + + if (CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1)) { + pauseCtx->worldMapPoints[3] = 2; + } + + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_WATER)) { + pauseCtx->worldMapPoints[3] = 1; + } + + if (gSaveContext.eventChkInf[0] & 0x200) { + pauseCtx->worldMapPoints[4] = 1; + } + + if (INV_CONTENT(ITEM_OCARINA_FAIRY) != ITEM_NONE) { + pauseCtx->worldMapPoints[4] = 2; + } + + if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { + pauseCtx->worldMapPoints[4] = 1; + } + + if (gSaveContext.eventChkInf[6] & 0x400) { + pauseCtx->worldMapPoints[4] = 2; + } + + if (gSaveContext.eventChkInf[1] & 0x100) { + pauseCtx->worldMapPoints[4] = 1; + } + + if (gSaveContext.eventChkInf[0] & 0x200) { + pauseCtx->worldMapPoints[5] = 2; + } + + if (gSaveContext.eventChkInf[4] & 1) { + pauseCtx->worldMapPoints[5] = 1; + } + + if (INV_CONTENT(ITEM_OCARINA_TIME) == ITEM_OCARINA_TIME) { + pauseCtx->worldMapPoints[5] = 2; + } + + if (gSaveContext.eventChkInf[4] & 0x20) { + pauseCtx->worldMapPoints[5] = 1; + } + + if (INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT) { + pauseCtx->worldMapPoints[5] = 2; + } + + if (gSaveContext.eventChkInf[0] & 0x200) { + pauseCtx->worldMapPoints[6] = 1; + } + + if (gSaveContext.eventChkInf[4] & 1) { + pauseCtx->worldMapPoints[7] = 2; + } + + if (gSaveContext.eventChkInf[2] & 0x20) { + pauseCtx->worldMapPoints[7] = 1; + } + + if (INV_CONTENT(ITEM_HOOKSHOT) == ITEM_HOOKSHOT) { + pauseCtx->worldMapPoints[7] = 2; + } + + if (gSaveContext.eventChkInf[4] & 0x200) { + pauseCtx->worldMapPoints[7] = 1; + } + + if (gBitFlags[1] & gSaveContext.worldMapAreaData) { + pauseCtx->worldMapPoints[8] = 1; + } + + if (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY)) { + pauseCtx->worldMapPoints[8] = 2; + } + + if (CHECK_QUEST_ITEM(QUEST_SONG_SUN)) { + pauseCtx->worldMapPoints[8] = 1; + } + + if (gSaveContext.eventChkInf[4] & 0x20) { + pauseCtx->worldMapPoints[8] = 2; + } + + if (INV_CONTENT(ITEM_HOOKSHOT) == ITEM_HOOKSHOT) { + pauseCtx->worldMapPoints[8] = 1; + } + + if (CHECK_QUEST_ITEM(QUEST_SONG_STORMS)) { + pauseCtx->worldMapPoints[8] = 2; + } + + if (gSaveContext.eventChkInf[6] & 0x80) { + pauseCtx->worldMapPoints[8] = 1; + } + + if (gSaveContext.eventChkInf[10] & 0x400) { + pauseCtx->worldMapPoints[8] = 2; + } + + if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW)) { + pauseCtx->worldMapPoints[8] = 1; + } + + if (gBitFlags[10] & gSaveContext.worldMapAreaData) { + pauseCtx->worldMapPoints[9] = 1; + } + + if (gSaveContext.eventChkInf[0] & 0x8000) { + pauseCtx->worldMapPoints[9] = 2; + } + + if (CHECK_QUEST_ITEM(QUEST_SONG_SARIA)) { + pauseCtx->worldMapPoints[9] = 1; + } + + if (INV_CONTENT(ITEM_HOOKSHOT) == ITEM_HOOKSHOT) { + pauseCtx->worldMapPoints[9] = 2; + } + + if (gSaveContext.eventChkInf[4] & 0x100) { + pauseCtx->worldMapPoints[9] = 1; + } + + pauseCtx->worldMapPoints[10] = 2; + + if (gSaveContext.eventChkInf[0] & 0x200) { + pauseCtx->worldMapPoints[10] = 1; + } + + if (gSaveContext.eventChkInf[6] & 0x4000) { + pauseCtx->worldMapPoints[10] = 2; + } + + if (gSaveContext.eventChkInf[0] & 0x8000) { + pauseCtx->worldMapPoints[10] = 1; + } + + if (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY)) { + pauseCtx->worldMapPoints[11] = 1; + } + + if (gSaveContext.eventChkInf[2] & 0x20) { + pauseCtx->worldMapPoints[11] = 2; + } + + if (gSaveContext.eventChkInf[3] & 0x80) { + pauseCtx->worldMapPoints[11] = 1; + } + + if (INV_CONTENT(ITEM_HOOKSHOT) == ITEM_HOOKSHOT) { + pauseCtx->worldMapPoints[11] = 2; + } + + if (CHECK_OWNED_EQUIP(EQUIP_BOOTS, 1)) { + pauseCtx->worldMapPoints[11] = 1; + } + + pauseCtx->tradeQuestLocation = 0xFF; + + i = INV_CONTENT(ITEM_TRADE_ADULT); + if (LINK_AGE_IN_YEARS == YEARS_ADULT) { + if ((i <= ITEM_POCKET_CUCCO) || (i == ITEM_ODD_MUSHROOM)) { + pauseCtx->tradeQuestLocation = 8; + } + if ((i == ITEM_COJIRO) || (i == ITEM_ODD_POTION)) { + pauseCtx->tradeQuestLocation = 9; + } + if (i == ITEM_SAW) { + pauseCtx->tradeQuestLocation = 2; + } + if ((i == ITEM_SWORD_BROKEN) || (i == ITEM_EYEDROPS)) { + pauseCtx->tradeQuestLocation = 7; + } + if (i == ITEM_PRESCRIPTION) { + pauseCtx->tradeQuestLocation = 11; + } + if (i == ITEM_FROG) { + pauseCtx->tradeQuestLocation = 3; + } + if ((i == ITEM_CLAIM_CHECK) && (gSaveContext.bgsFlag == 0)) { + pauseCtx->tradeQuestLocation = 7; + } + } + + pauseCtx->state = 4; + break; + + case 4: + if (pauseCtx->unk_1F4 == 160.0f) { + KaleidoScope_SetDefaultCursor(globalCtx); + KaleidoScope_ProcessPlayerPreRender(); + } + + pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 -= 160.0f / WREG(6); + pauseCtx->infoPanelOffsetY += 40 / WREG(6); + interfaceCtx->startAlpha += 255 / WREG(6); + WREG(16) += WREG(25) / WREG(6); + WREG(17) += WREG(26) / WREG(6); + XREG(5) += 150 / WREG(6); + pauseCtx->alpha += (u16)(255 / (WREG(6) + WREG(4))); + + if (pauseCtx->unk_1F4 == 0) { + interfaceCtx->startAlpha = 255; + WREG(2) = 0; + pauseCtx->state = 5; + } + + func_808265BC(globalCtx); + break; + + case 5: + pauseCtx->alpha += (u16)(255 / (WREG(6) + WREG(4))); + func_808265BC(globalCtx); + if (pauseCtx->state == 6) { + KaleidoScope_UpdateNamePanel(globalCtx); + } + break; + + case 6: + switch (pauseCtx->unk_1E4) { + case 0: + if (CHECK_BTN_ALL(input->press.button, BTN_START)) { + Interface_SetDoAction(globalCtx, 10); + pauseCtx->state = 0x12; + WREG(2) = -6240; + func_800F64E0(0); + } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + pauseCtx->mode = 0; + pauseCtx->promptChoice = 0; + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = + gSaveContext.buttonStatus[3] = BTN_DISABLED; + gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.unk_13EA = 0; + Interface_ChangeAlpha(50); + pauseCtx->unk_1EC = 0; + pauseCtx->state = 7; + } + break; + + case 1: + func_808237B4(globalCtx, globalCtx->state.input); + break; + + case 2: + pauseCtx->unk_194 = func_800EE3F8(); + if (pauseCtx->unk_194->unk_01 == 0) { + pauseCtx->unk_1E4 = 4; + func_800ED858(0); + } + break; + + case 3: + KaleidoScope_UpdateItemEquip(globalCtx); + break; + + case 4: + break; + + case 5: + pauseCtx->unk_194 = func_800EE3D4(); + + if (CHECK_BTN_ALL(input->press.button, BTN_START)) { + func_800ED858(0); + Interface_SetDoAction(globalCtx, 10); + pauseCtx->state = 0x12; + WREG(2) = -6240; + func_800F64E0(0); + pauseCtx->unk_1E4 = 0; + break; + } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + func_800ED858(0); + pauseCtx->unk_1E4 = 0; + pauseCtx->mode = 0; + pauseCtx->promptChoice = 0; + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = + gSaveContext.buttonStatus[3] = BTN_DISABLED; + gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.unk_13EA = 0; + Interface_ChangeAlpha(50); + pauseCtx->unk_1EC = 0; + pauseCtx->state = 7; + } else if (pauseCtx->unk_194->unk_01 == pauseCtx->unk_264) { + Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + D_8082B258 = 0; + D_8082B25C = 30; + pauseCtx->unk_1E4 = 6; + } else if (pauseCtx->unk_194->unk_01 == 0xFF) { + Audio_PlaySoundGeneral(NA_SE_SY_OCARINA_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + D_8082B258 = 4; + D_8082B25C = 20; + pauseCtx->unk_1E4 = 6; + } + break; + + case 6: + D_8082B25C--; + if (D_8082B25C == 0) { + pauseCtx->unk_1E4 = D_8082B258; + if (pauseCtx->unk_1E4 == 0) { + func_800ED858(0); + } + } + break; + + case 7: + break; + + case 8: + if (CHECK_BTN_ALL(input->press.button, BTN_START)) { + func_800ED858(0); + Interface_SetDoAction(globalCtx, 10); + pauseCtx->state = 0x12; + WREG(2) = -6240; + func_800F64E0(0); + pauseCtx->unk_1E4 = 0; + } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + func_800ED858(0); + pauseCtx->unk_1E4 = 0; + pauseCtx->mode = 0; + pauseCtx->promptChoice = 0; + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = + gSaveContext.buttonStatus[3] = BTN_DISABLED; + gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.unk_13EA = 0; + Interface_ChangeAlpha(50); + pauseCtx->unk_1EC = 0; + pauseCtx->state = 7; + } + break; + + case 9: + break; + + default: + pauseCtx->unk_1E4 = 0; + break; + } + break; + + case 7: + switch (pauseCtx->unk_1EC) { + case 0: + pauseCtx->unk_204 -= 314.0f / WREG(6); + WREG(16) -= WREG(25) / WREG(6); + WREG(17) -= WREG(26) / WREG(6); + if (pauseCtx->unk_204 <= -628.0f) { + pauseCtx->unk_204 = -628.0f; + pauseCtx->unk_1EC = 1; + } + break; + + case 1: + if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + if (pauseCtx->promptChoice != 0) { + Interface_SetDoAction(globalCtx, 10); + gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = + gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.unk_13EA = 0; + Interface_ChangeAlpha(50); + pauseCtx->unk_1EC = 2; + WREG(2) = -6240; + YREG(8) = pauseCtx->unk_204; + func_800F64E0(0); + } else { + Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + Gameplay_SaveSceneFlags(globalCtx); + gSaveContext.savedSceneNum = globalCtx->sceneNum; + Sram_WriteSave(&globalCtx->sramCtx); + pauseCtx->unk_1EC = 4; + D_8082B25C = 3; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_START) || + CHECK_BTN_ALL(input->press.button, BTN_B)) { + Interface_SetDoAction(globalCtx, 10); + pauseCtx->unk_1EC = 2; + WREG(2) = -6240; + YREG(8) = pauseCtx->unk_204; + func_800F64E0(0); + gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = + gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.unk_13EA = 0; + Interface_ChangeAlpha(50); + } + break; + + case 4: + if (CHECK_BTN_ALL(input->press.button, BTN_B) || CHECK_BTN_ALL(input->press.button, BTN_A) || + CHECK_BTN_ALL(input->press.button, BTN_START) || (--D_8082B25C == 0)) { + Interface_SetDoAction(globalCtx, 10); + gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = + gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.unk_13EA = 0; + Interface_ChangeAlpha(50); + pauseCtx->unk_1EC = 5; + WREG(2) = -6240; + YREG(8) = pauseCtx->unk_204; + func_800F64E0(0); + } + break; + + case 3: + case 6: + pauseCtx->unk_204 += 314.0f / WREG(6); + WREG(16) += WREG(25) / WREG(6); + WREG(17) += WREG(26) / WREG(6); + if (pauseCtx->unk_204 >= -314.0f) { + pauseCtx->state = 6; + pauseCtx->unk_1EC = 0; + pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 0.0f; + pauseCtx->unk_204 = -314.0f; + } + break; + + case 2: + case 5: + if (pauseCtx->unk_204 != (YREG(8) + 160.0f)) { + pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 += + 160.0f / WREG(6); + pauseCtx->unk_204 += 160.0f / WREG(6); + pauseCtx->infoPanelOffsetY -= 40 / WREG(6); + WREG(16) -= WREG(25) / WREG(6); + WREG(17) -= WREG(26) / WREG(6); + XREG(5) -= 150 / WREG(6); + pauseCtx->alpha -= (u16)(255 / WREG(6)); + if (pauseCtx->unk_204 == (YREG(8) + 160.0f)) { + pauseCtx->alpha = 0; + } + } else { + pauseCtx->debugState = 0; + pauseCtx->state = 0x13; + pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = 160.0f; + pauseCtx->namedItem = PAUSE_ITEM_NONE; + pauseCtx->unk_1E4 = 0; + pauseCtx->unk_204 = -434.0f; + } + break; + } + break; + + case 0xA: + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot = + VREG(30) + 3; + WREG(16) = -175; + WREG(17) = 155; + pauseCtx->unk_204 = -434.0f; + Interface_ChangeAlpha(1); + + pauseCtx->iconItemSegment = (void*)(((u32)globalCtx->objectCtx.spaceStart + 0x30) & ~0x3F); + size0 = (u32)_icon_item_staticSegmentRomEnd - (u32)_icon_item_staticSegmentRomStart; + osSyncPrintf("icon_item size0=%x\n", size0); + DmaMgr_SendRequest1(pauseCtx->iconItemSegment, (u32)_icon_item_staticSegmentRomStart, size0, + "../z_kaleido_scope_PAL.c", 4356); + + pauseCtx->iconItem24Segment = (void*)(((u32)pauseCtx->iconItemSegment + size0 + 0xF) & ~0xF); + size = (u32)_icon_item_24_staticSegmentRomEnd - (u32)_icon_item_24_staticSegmentRomStart; + osSyncPrintf("icon_item24 size=%x\n", size); + DmaMgr_SendRequest1(pauseCtx->iconItem24Segment, (u32)_icon_item_24_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 4363); + + pauseCtx->iconItemAltSegment = (void*)(((u32)pauseCtx->iconItem24Segment + size + 0xF) & ~0xF); + size2 = (u32)_icon_item_gameover_staticSegmentRomEnd - (u32)_icon_item_gameover_staticSegmentRomStart; + osSyncPrintf("icon_item_dungeon gameover-size2=%x\n", size2); + DmaMgr_SendRequest1(pauseCtx->iconItemAltSegment, (u32)_icon_item_gameover_staticSegmentRomStart, size2, + "../z_kaleido_scope_PAL.c", 4370); + + pauseCtx->iconItemLangSegment = (void*)(((u32)pauseCtx->iconItemAltSegment + size2 + 0xF) & ~0xF); + + if (gSaveContext.language == 0) { + size = (u32)_icon_item_nes_staticSegmentRomEnd - (u32)_icon_item_nes_staticSegmentRomStart; + osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); + DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (u32)_icon_item_nes_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 4379); + } else if (gSaveContext.language == 1) { + size = (u32)_icon_item_ger_staticSegmentRomEnd - (u32)_icon_item_ger_staticSegmentRomStart; + osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); + DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (u32)_icon_item_ger_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 4386); + } else { + size = (u32)_icon_item_fra_staticSegmentRomEnd - (u32)_icon_item_fra_staticSegmentRomStart; + osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); + DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (u32)_icon_item_fra_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 4393); + } + + D_8082AB8C = 255; + D_8082AB90 = 130; + D_8082AB94 = 0; + D_8082AB98 = 0; + D_8082AB9C = 30; + D_8082ABA0 = 0; + D_8082ABA4 = 0; + D_8082B260 = 30; + VREG(88) = 98; + pauseCtx->promptChoice = 0; + pauseCtx->state++; + break; + + case 0xB: + stepR = ABS(D_8082AB8C - 30) / D_8082B260; + stepG = ABS(D_8082AB90) / D_8082B260; + stepB = ABS(D_8082AB94) / D_8082B260; + stepA = ABS(D_8082AB98 - 255) / D_8082B260; + if (D_8082AB8C >= 30) { + D_8082AB8C -= stepR; + } else { + D_8082AB8C += stepR; + } + if (D_8082AB90 >= 0) { + D_8082AB90 -= stepG; + } else { + D_8082AB90 += stepG; + } + if (D_8082AB94 >= 0) { + D_8082AB94 -= stepB; + } else { + D_8082AB94 += stepB; + } + if (D_8082AB98 >= 255) { + D_8082AB98 -= stepA; + } else { + D_8082AB98 += stepA; + } + + stepR = ABS(D_8082AB9C - 255) / D_8082B260; + stepG = ABS(D_8082ABA0 - 130) / D_8082B260; + stepB = ABS(D_8082ABA4) / D_8082B260; + if (D_8082AB9C >= 255) { + D_8082AB9C -= stepR; + } else { + D_8082AB9C += stepR; + } + if (D_8082ABA0 >= 130) { + D_8082ABA0 -= stepG; + } else { + D_8082ABA0 += stepG; + } + if (D_8082ABA4 >= 0) { + D_8082ABA4 -= stepB; + } else { + D_8082ABA4 += stepB; + } + + D_8082B260--; + if (D_8082B260 == 0) { + D_8082AB8C = 30; + D_8082AB90 = 0; + D_8082AB94 = 0; + D_8082AB98 = 255; + + D_8082AB9C = 255; + D_8082ABA0 = 130; + D_8082ABA4 = 0; + + pauseCtx->state++; + D_8082B260 = 40; + } + break; + + case 0xC: + D_8082B260--; + if (D_8082B260 == 0) { + pauseCtx->state = 0xD; + } + break; + + case 0xD: + pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 = pauseCtx->unk_204 -= + 160.0f / WREG(6); + pauseCtx->infoPanelOffsetY += 40 / WREG(6); + interfaceCtx->startAlpha += 255 / WREG(6); + VREG(88) -= 3; + WREG(16) += WREG(25) / WREG(6); + WREG(17) += WREG(26) / WREG(6); + XREG(5) += 150 / WREG(6); + pauseCtx->alpha += (u16)(255 / (WREG(6) + WREG(4))); + if (pauseCtx->unk_204 < -628.0f) { + pauseCtx->unk_204 = -628.0f; + interfaceCtx->startAlpha = 255; + VREG(88) = 66; + WREG(2) = 0; + pauseCtx->alpha = 255; + pauseCtx->state = 0xE; + gSaveContext.deaths++; + if (gSaveContext.deaths > 999) { + gSaveContext.deaths = 999; + } + } + osSyncPrintf("kscope->angle_s = %f\n", pauseCtx->unk_204); + break; + + case 0xE: + if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + if (pauseCtx->promptChoice != 0) { + pauseCtx->promptChoice = 0; + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + pauseCtx->state = 0x10; + gameOverCtx->state++; + } else { + Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + pauseCtx->promptChoice = 0; + Gameplay_SaveSceneFlags(globalCtx); + gSaveContext.savedSceneNum = globalCtx->sceneNum; + Sram_WriteSave(&globalCtx->sramCtx); + pauseCtx->state = 0xF; + D_8082B25C = 3; + } + } + break; + + case 0xF: + D_8082B25C--; + if (D_8082B25C == 0) { + pauseCtx->state = 0x10; + gameOverCtx->state++; + } else if ((D_8082B25C <= 80) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START))) { + pauseCtx->state = 0x10; + gameOverCtx->state++; + func_800F64E0(0); + } + break; + + case 0x10: + if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START)) { + if (pauseCtx->promptChoice == 0) { + Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + Gameplay_SaveSceneFlags(globalCtx); + + switch (gSaveContext.entranceIndex) { + case 0x0000: + case 0x0004: + case 0x0028: + case 0x0169: + case 0x0165: + case 0x0010: + case 0x0082: + case 0x0037: + case 0x041B: + case 0x0008: + case 0x0088: + case 0x0486: + case 0x0098: + case 0x0467: + case 0x0179: + break; + case 0x040F: + gSaveContext.entranceIndex = 0x0000; + break; + case 0x040B: + gSaveContext.entranceIndex = 0x0004; + break; + case 0x0301: + gSaveContext.entranceIndex = 0x0028; + break; + case 0x000C: + gSaveContext.entranceIndex = 0x0169; + break; + case 0x0305: + gSaveContext.entranceIndex = 0x0165; + break; + case 0x0417: + gSaveContext.entranceIndex = 0x0010; + break; + case 0x008D: + gSaveContext.entranceIndex = 0x0082; + break; + case 0x0413: + gSaveContext.entranceIndex = 0x0037; + break; + case 0x041F: + gSaveContext.entranceIndex = 0x041B; + break; + } + } else { + Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } + + pauseCtx->state = 0x11; + } + break; + + case 0x11: + if (interfaceCtx->unk_244 != 255) { + interfaceCtx->unk_244 += 10; + if (interfaceCtx->unk_244 >= 255) { + interfaceCtx->unk_244 = 255; + pauseCtx->state = 0; + R_UPDATE_RATE = 3; + R_PAUSE_MENU_MODE = 0; + func_800981B8(&globalCtx->objectCtx); + func_800418D0(&globalCtx->colCtx, globalCtx); + if (pauseCtx->promptChoice == 0) { + Gameplay_TriggerRespawn(globalCtx); + gSaveContext.respawnFlag = -2; + gSaveContext.nextTransition = 2; + gSaveContext.health = 0x30; + Audio_SetBGM(0xF000000A); + gSaveContext.healthAccumulator = 0; + gSaveContext.unk_13F0 = 0; + gSaveContext.unk_13F2 = 0; + osSyncPrintf(VT_FGCOL(YELLOW)); + osSyncPrintf("MAGIC_NOW=%d ", gSaveContext.magic); + osSyncPrintf("Z_MAGIC_NOW_NOW=%d → ", gSaveContext.unk_13F6); + gSaveContext.unk_13F4 = 0; + gSaveContext.unk_13F6 = gSaveContext.magic; + gSaveContext.magicLevel = gSaveContext.magic = 0; + osSyncPrintf("MAGIC_NOW=%d ", gSaveContext.magic); + osSyncPrintf("Z_MAGIC_NOW_NOW=%d\n", gSaveContext.unk_13F6); + osSyncPrintf(VT_RST); + } else { + globalCtx->state.running = 0; + SET_NEXT_GAMESTATE(&globalCtx->state, Opening_Init, OpeningContext); + } + } + } + break; + + case 0x12: + if (pauseCtx->unk_1F4 != 160.0f) { + pauseCtx->unk_1F4 = pauseCtx->unk_1F8 = pauseCtx->unk_1FC = pauseCtx->unk_200 += 160.0f / WREG(6); + pauseCtx->infoPanelOffsetY -= 40 / WREG(6); + interfaceCtx->startAlpha -= 255 / WREG(6); + WREG(16) -= WREG(25) / WREG(6); + WREG(17) -= WREG(26) / WREG(6); + XREG(5) -= 150 / WREG(6); + pauseCtx->alpha -= (u16)(255 / WREG(6)); + if (pauseCtx->unk_1F4 == 160.0f) { + pauseCtx->alpha = 0; + } + } else { + pauseCtx->debugState = 0; + pauseCtx->state = 0x13; + pauseCtx->unk_200 = 160.0f; + pauseCtx->unk_1FC = 160.0f; + pauseCtx->unk_1F8 = 160.0f; + pauseCtx->unk_1F4 = 160.0f; + pauseCtx->namedItem = PAUSE_ITEM_NONE; + globalCtx->interfaceCtx.startAlpha = 0; + } + break; + + case 0x13: + pauseCtx->state = 0; + R_UPDATE_RATE = 3; + R_PAUSE_MENU_MODE = 0; + func_800981B8(&globalCtx->objectCtx); + func_800418D0(&globalCtx->colCtx, globalCtx); + + switch (globalCtx->sceneNum) { + case SCENE_YDAN: + case SCENE_DDAN: + case SCENE_BDAN: + case SCENE_BMORI1: + case SCENE_HIDAN: + case SCENE_MIZUSIN: + case SCENE_JYASINZOU: + case SCENE_HAKADAN: + case SCENE_HAKADANCH: + case SCENE_ICE_DOUKUTO: + case SCENE_YDAN_BOSS: + case SCENE_DDAN_BOSS: + case SCENE_BDAN_BOSS: + case SCENE_MORIBOSSROOM: + case SCENE_FIRE_BS: + case SCENE_MIZUSIN_BS: + case SCENE_JYASINBOSS: + case SCENE_HAKADAN_BS: + Map_InitData(globalCtx, globalCtx->interfaceCtx.mapRoomNum); + break; + } + + gSaveContext.buttonStatus[0] = D_808321A8[0]; + gSaveContext.buttonStatus[1] = D_808321A8[1]; + gSaveContext.buttonStatus[2] = D_808321A8[2]; + gSaveContext.buttonStatus[3] = D_808321A8[3]; + gSaveContext.buttonStatus[4] = D_808321A8[4]; + interfaceCtx->unk_1FA = interfaceCtx->unk_1FC = 0; + osSyncPrintf(VT_FGCOL(YELLOW)); + osSyncPrintf("i=%d LAST_TIME_TYPE=%d\n", i, gSaveContext.unk_13EE); + gSaveContext.unk_13EA = 0; + Interface_ChangeAlpha(gSaveContext.unk_13EE); + player->targetActor = NULL; + Player_SetEquipmentData(globalCtx, player); + osSyncPrintf(VT_RST); + break; + } +} diff --git a/src/overlays/actors/ovl_kaleido_scope/z_lmap_mark.c b/src/overlays/actors/ovl_kaleido_scope/z_lmap_mark.c index 420e3a424..9eaad57d9 100644 --- a/src/overlays/actors/ovl_kaleido_scope/z_lmap_mark.c +++ b/src/overlays/actors/ovl_kaleido_scope/z_lmap_mark.c @@ -1,7 +1,168 @@ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80829960.s") +#include "z_kaleido_scope.h" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80829990.s") +typedef struct { + /* 0x00 */ void* texture; + /* 0x04 */ u32 imageFormat; + /* 0x08 */ u32 imageSize; + /* 0x0C */ u32 textureWidth; + /* 0x10 */ u32 textureHeight; + /* 0x14 */ u32 rectWidth; + /* 0x18 */ u32 rectHeight; + /* 0x1C */ u32 dsdx; + /* 0x20 */ u32 dtdy; +} PauseMapMarkInfo; // size = 0x24 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_808299A0.s") +static PauseMapMarkInfo sMapMarkInfoTable[] = { + { D_02002580, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 32, 32, 1024, 1024 }, // Chest Icon + { D_02002900, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 32, 32, 1024, 1024 }, // Boss Skull Icon +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8082A00C.s") +static const u32 sBaseImageSizes[] = { 0, 1, 2, 3 }; +static const u32 sLoadBlockImageSizes[] = { 2, 2, 2, 3 }; +static const u32 sIncrImageSizes[] = { 3, 1, 0, 0 }; +static const u32 sShiftImageSizes[] = { 2, 1, 0, 0 }; +static const u32 sBytesImageSizes[] = { 0, 1, 2, 4 }; +static const u32 sLineBytesImageSizes[] = { 0, 1, 2, 2 }; + +#define G_IM_SIZ_MARK sBaseImageSizes[markInfo->imageSize] +#define G_IM_SIZ_MARK_LOAD_BLOCK sLoadBlockImageSizes[markInfo->imageSize] +#define G_IM_SIZ_MARK_INCR sIncrImageSizes[markInfo->imageSize] +#define G_IM_SIZ_MARK_SHIFT sShiftImageSizes[markInfo->imageSize] +#define G_IM_SIZ_MARK_BYTES sBytesImageSizes[markInfo->imageSize] +#define G_IM_SIZ_MARK_LINE_BYTES sLineBytesImageSizes[markInfo->imageSize] + +extern PauseMapMarksData gPauseMapMarkDataTable[]; + +void PauseMapMark_Init(GlobalContext* globalCtx) { + gBossMarkState = 0; + gBossMarkScale = 1.0f; + gLoadedPauseMarkDataTable = gPauseMapMarkDataTable; +} + +void PauseMapMark_Clear(GlobalContext* globalCtx) { + gLoadedPauseMarkDataTable = NULL; +} + +void PauseMapMark_DrawForDungeon(GlobalContext* globalCtx) { + PauseMapMarkData* mapMarkData; + PauseMapMarkPoint* markPoint; + PauseMapMarkInfo* markInfo; + f32 scale; + s32 i = 0; + + mapMarkData = &gLoadedPauseMarkDataTable[R_MAP_TEX_INDEX >> 1][i]; + + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_lmap_mark.c", 182); + + while (true) { + if (mapMarkData->markType == PAUSE_MAP_MARK_NONE) { + break; + } + + if ((mapMarkData->markType == PAUSE_MAP_MARK_BOSS) && (globalCtx->sceneNum >= SCENE_YDAN_BOSS) && + (globalCtx->sceneNum <= SCENE_GANON_FINAL)) { + if (gBossMarkState == 0) { + Math_ApproachF(&gBossMarkScale, 1.5f, 1.0f, 0.041f); + if (gBossMarkScale == 1.5f) { + gBossMarkState = 1; + } + } else { + Math_ApproachF(&gBossMarkScale, 1.0f, 1.0f, 0.041f); + if (gBossMarkScale == 1.0f) { + gBossMarkState = 0; + } + } + scale = gBossMarkScale; + } else { + scale = 1.0f; + } + + Matrix_Push(); + + if ((globalCtx->pauseCtx.state == 4) || (globalCtx->pauseCtx.state >= 0x12)) { + Matrix_Translate(-36.0f, 101.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_Translate(-36.0f, 21.0f, 0.0f, MTXMODE_APPLY); + } + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + markPoint = &mapMarkData->points[0]; + for (i = 0; i < mapMarkData->count; i++) { + s32 display; + + if (mapMarkData->markType == PAUSE_MAP_MARK_CHEST) { + if (Flags_GetTreasure(globalCtx, markPoint->chestFlag)) { + display = false; + } else { + switch (globalCtx->sceneNum) { + case SCENE_YDAN_BOSS: + case SCENE_DDAN_BOSS: + case SCENE_BDAN_BOSS: + case SCENE_MORIBOSSROOM: + case SCENE_FIRE_BS: + case SCENE_MIZUSIN_BS: + case SCENE_JYASINBOSS: + case SCENE_HAKADAN_BS: + display = false; + break; + default: + display = true; + break; + } + } + } else { + display = true; + } + + if (display) { + markInfo = &sMapMarkInfoTable[mapMarkData->markType]; + + gDPPipeSync(POLY_OPA_DISP++); + gDPLoadTextureBlock(POLY_OPA_DISP++, markInfo->texture, markInfo->imageFormat, G_IM_SIZ_MARK, + markInfo->textureWidth, markInfo->textureHeight, 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); + + Matrix_Push(); + Matrix_Translate(GREG(92) + markPoint->x, GREG(93) + markPoint->y, 0.0f, MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_lmap_mark.c", 272), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Matrix_Pop(); + + gSPVertex(POLY_OPA_DISP++, mapMarkData->vtx, mapMarkData->vtxCount, 0); + gSP1Quadrangle(POLY_OPA_DISP++, 1, 3, 2, 0, 0); + } + + markPoint++; + } + + mapMarkData++; + Matrix_Pop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_lmap_mark.c", 286); +} + +void PauseMapMark_Draw(GlobalContext* globalCtx) { + PauseMapMark_Init(globalCtx); + + switch (globalCtx->sceneNum) { + case SCENE_YDAN: + case SCENE_DDAN: + case SCENE_BDAN: + case SCENE_BMORI1: + case SCENE_HIDAN: + case SCENE_MIZUSIN: + case SCENE_JYASINZOU: + case SCENE_HAKADAN: + case SCENE_HAKADANCH: + case SCENE_ICE_DOUKUTO: + PauseMapMark_DrawForDungeon(globalCtx); + break; + } + + PauseMapMark_Clear(globalCtx); +} diff --git a/src/overlays/actors/ovl_kaleido_scope/z_lmap_mark_data.c b/src/overlays/actors/ovl_kaleido_scope/z_lmap_mark_data.c new file mode 100644 index 000000000..df96fc876 --- /dev/null +++ b/src/overlays/actors/ovl_kaleido_scope/z_lmap_mark_data.c @@ -0,0 +1,531 @@ +#include "z_kaleido_scope.h" + +static const Vtx sMarkBossVtx[] = { + VTX(-4, 4, 0, 0, 0, 255, 255, 255, 255), + VTX(-4, -4, 0, 0, 256, 255, 255, 255, 255), + VTX(4, 4, 0, 256, 0, 255, 255, 255, 255), + VTX(4, -4, 0, 256, 256, 255, 255, 255, 255), +}; + +static const Vtx sMarkChestVtx[] = { + VTX(-4, 4, 0, 0, 0, 255, 255, 255, 255), + VTX(-4, -4, 0, 0, 256, 255, 255, 255, 255), + VTX(4, 4, 0, 256, 0, 255, 255, 255, 255), + VTX(4, -4, 0, 256, 256, 255, 255, 255, 255), +}; + +PauseMapMarksData gPauseMapMarkDataTable[] = { + // Deku Tree map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 2, 40.0f, -33.0f }, + { 6, 49.0f, -42.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Deku Tree map 1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 1, 48.0f, -63.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Deku Tree map 2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 3, 84.0f, -39.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Deku Tree map 3 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 0, 46.0f, -59.0f }, + { 4, 77.0f, -26.0f }, + { 5, 65.0f, -61.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Deku Tree map 4 + { + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 55.0f, 0.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Dodongo's Cavern map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 2, 55.0f, -36.0f }, + { 3, 54.0f, -51.0f }, + { 5, 13.0f, -61.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Dodongo's Cavern map 1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 0, 47.0f, -40.0f }, + { 1, 51.0f, -3.0f }, + { 4, 47.0f, -47.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 23.0f, -25.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Jabu-Jabu's Belly map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 5, + { + { 3, 48.0f, -68.0f }, + { 5, 50.0f, -66.0f }, + { 7, 55.0f, -50.0f }, + { 9, 58.0f, 1.0f }, + { 10, 62.0f, -45.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 65.0f, -37.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Jabu-Jabu's Belly map 1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 6, + { + { 0, 37.0f, -49.0f }, + { 1, 65.0f, -38.0f }, + { 2, 52.0f, -48.0f }, + { 4, 46.0f, -36.0f }, + { 6, 59.0f, -41.0f }, + { 8, 52.0f, -26.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Forest Temple map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 6, + { + { 3, 53.0f, -64.0f }, + { 5, 65.0f, -9.0f }, + { 12, 49.0f, -1.0f }, + { 13, 40.0f, 0.0f }, + { 14, 18.0f, -2.0f }, + { 15, 59.0f, 0.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Forest Temple map 1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 4, + { + { 0, 49.0f, -1.0f }, + { 1, 71.0f, -13.0f }, + { 2, 11.0f, -25.0f }, + { 6, 84.0f, -16.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Forest Temple map 2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 9, 65.0f, -30.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Forest Temple map 3 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 11, 41.0f, -24.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 50.0f, -11.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 5, 24.0f, -40.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 1 + { + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 3, 75.0f, -47.0f }, + { 6, 72.0f, -51.0f }, + { 8, 65.0f, -12.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 3 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 11, 78.0f, -35.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Fire Temple map 4 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 5, + { + { 1, 67.0f, -58.0f }, + { 2, 48.0f, -30.0f }, + { 4, 63.0f, -14.0f }, + { 7, 36.0f, -45.0f }, + { 12, 47.0f, -26.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 26.0f, -34.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Water Temple map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 2, 88.0f, -60.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 62.0f, -23.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Water Temple map 1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 0, 88.0f, -60.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Water Temple map 2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 1, 88.0f, -60.0f }, + { 5, 49.0f, -43.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Water Temple map 3 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 6, 75.0f, -65.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Spirit Temple map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 18, 46.0f, -30.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Spirit Temple map 1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 5, + { + { 1, 23.0f, -33.0f }, + { 2, 56.0f, -11.0f }, + { 5, 83.0f, -25.0f }, + { 24, 84.0f, -39.0f }, + { 25, 74.0f, -37.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 47.0f, 0.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Spirit Temple map 2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 5, + { + { 3, 46.0f, -20.0f }, + { 6, 28.0f, -19.0f }, + { 12, 25.0f, -25.0f }, + { 15, 50.0f, -13.0f }, + { 28, 48.0f, -29.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Spirit Temple map 3 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 9, + { + { 0, 14.0f, -24.0f }, + { 4, 55.0f, -14.0f }, + { 7, 78.0f, -2.0f }, + { 8, 14.0f, -16.0f }, + { 26, 42.0f, -43.0f }, + { 27, 50.0f, -43.0f }, + { 29, 25.0f, -35.0f }, + { 30, 42.0f, -36.0f }, + { 31, 50.0f, -36.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Shadow Temple map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 1, 41.0f, -17.0f }, + { 7, 27.0f, -24.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Shadow Temple map 1 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 2, 81.0f, -20.0f }, + { 3, 74.0f, -37.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Shadow Temple map 2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 12, 96.0f, -51.0f }, + { 16, 46.0f, -42.0f }, + { 22, 96.0f, -55.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Shadow Temple map 3 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 12, + { + { 4, 43.0f, -66.0f }, + { 5, 37.0f, -66.0f }, + { 6, 33.0f, -72.0f }, + { 8, 85.0f, -18.0f }, + { 9, 61.0f, -42.0f }, + { 10, 15.0f, -4.0f }, + { 11, 25.0f, -4.0f }, + { 13, 19.0f, -29.0f }, + { 14, 78.0f, -15.0f }, + { 15, 60.0f, -70.0f }, + { 21, 92.0f, -29.0f }, + { 20, 87.0f, -20.0f }, + } }, + { PAUSE_MAP_MARK_BOSS, + 23, + sMarkBossVtx, + 4, + 1, + { + { -1, 31.0f, -45.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Bottom of the Well map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 2, + { + { 2, 84.0f, -38.0f }, + { 3, 57.0f, -18.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Bottom of the Well map 1 + { + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Bottom of the Well map 2 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 1, + { + { 1, 72.0f, -32.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, + // Ice Cavern map 0 + { + { PAUSE_MAP_MARK_CHEST, + 23, + sMarkChestVtx, + 4, + 3, + { + { 0, 66.0f, -2.0f }, + { 1, 77.0f, -46.0f }, + { 2, 27.0f, -45.0f }, + } }, + { PAUSE_MAP_MARK_NONE, 0, NULL, 0, 0, { 0 } }, + }, +}; diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 5d32f2891..b8315e759 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -275,13 +275,13 @@ void Select_UpdateMenu(SelectContext* this) { this->unk_224 = 0x14; this->unk_22C = 1; Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_220 = SREG(30); + this->unk_220 = R_UPDATE_RATE; } } if (CHECK_BTN_ALL(controller1->cur.button, BTN_DUP) && this->unk_224 == 0) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_220 = SREG(30) * 3; + this->unk_220 = R_UPDATE_RATE * 3; } if (CHECK_BTN_ALL(controller1->press.button, BTN_DDOWN)) { @@ -292,24 +292,24 @@ void Select_UpdateMenu(SelectContext* this) { this->unk_228 = 0x14; this->unk_230 = 1; Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_220 = -SREG(30); + this->unk_220 = -R_UPDATE_RATE; } } if (CHECK_BTN_ALL(controller1->cur.button, BTN_DDOWN) && (this->unk_228 == 0)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_220 = -SREG(30) * 3; + this->unk_220 = -R_UPDATE_RATE * 3; } if (CHECK_BTN_ALL(controller1->press.button, BTN_DLEFT) || CHECK_BTN_ALL(controller1->cur.button, BTN_DLEFT)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_220 = SREG(30); + this->unk_220 = R_UPDATE_RATE; } if (CHECK_BTN_ALL(controller1->press.button, BTN_DRIGHT) || CHECK_BTN_ALL(controller1->cur.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - this->unk_220 = -SREG(30); + this->unk_220 = -R_UPDATE_RATE; } } @@ -616,7 +616,7 @@ void Select_Init(GameState* thisx) { this->unk_20C = dREG(81); this->unk_1DC = dREG(82); } - SREG(30) = 1; + R_UPDATE_RATE = 1; this->staticSegment = GameState_Alloc(&this->state, size, "../z_select.c", 1114); DmaMgr_SendRequest1(this->staticSegment, _z_select_staticSegmentRomStart, size, "../z_select.c", 1115); diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index c6a367be5..2ef7c6441 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -40,24 +40,20 @@ void Title_Calc(TitleContext* this) { } void Title_SetupView(TitleContext* this, f32 x, f32 y, f32 z) { - View* view; - Vec3f v1; - Vec3f v2; - Vec3f v3; - - view = &this->view; - v3.z = 0; - v3.x = 0; - v2.z = 0; - v2.y = 0; - v2.x = 0; - v1.x = x; - v1.y = y; - v1.z = z; - v3.y = 1.0; + View* view = &this->view; + Vec3f eye; + Vec3f lookAt; + Vec3f up; + + eye.x = x; + eye.y = y; + eye.z = z; + up.x = up.z = 0.0f; + lookAt.x = lookAt.y = lookAt.z = 0.0f; + up.y = 1.0f; func_800AA460(view, 30.0f, 10.0f, 12800.0f); - func_800AA358(view, &v1, &v2, &v3); + func_800AA358(view, &eye, &lookAt, &up); func_800AAA50(view, 0xF); } |
