diff --git a/docs/tutorial/object_decomp_example.md b/docs/tutorial/object_decomp_example.md index d1cc4738af..f4030be5bf 100644 --- a/docs/tutorial/object_decomp_example.md +++ b/docs/tutorial/object_decomp_example.md @@ -149,7 +149,7 @@ Gfx object_dns_DL_001A50[] = { }; ``` -Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is expecting a texture in segment 8. What kind of texture is it expecting? We can look at the arguments after the `0x08000000`. It's looking for an RBGA16 texture with dimensions of 8x8, so we can define these textures in the XML like so: +Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is expecting a texture in segment 8. What kind of texture is it expecting? We can look at the arguments after the `0x08000000`. It's looking for an RGBA16 texture with dimensions of 8x8, so we can define these textures in the XML like so: ```xml diff --git a/include/functions.h b/include/functions.h index f73f95a96e..05db21f4f8 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1807,13 +1807,13 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b); void OLib_DbCameraVec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); // void func_8010CB80(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -// void func_8010CD98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); +Gfx* func_8010CD98(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); // void func_8010CFBC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14); // void func_8010D2D4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11); // void func_8010D480(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14, UNK_TYPE4 param_15, UNK_TYPE4 param_16); // void func_8010D7D0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); // void func_8010D9F4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14); -// void func_8010DC58(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +Gfx* func_8010DC58(Gfx* displayListHead, void* texture, s16 textureWidth, s16 textureHeight, u16 i); // void func_8010DE38(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); // void func_8010E028(void); // void func_8010E968(void); @@ -1903,7 +1903,7 @@ void func_80122BA4(PlayState* play, struct_80122D44_arg1* arg1, s32 arg2, s32 al void func_80122C20(PlayState* play, struct_80122D44_arg1* arg1); void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1); u8 Player_MaskIdToItemId(s32 maskIdMinusOne); -u8 Player_GetCurMaskItemId(PlayState* play); +s32 Player_GetCurMaskItemId(PlayState* play); void func_80122F28(Player* player); s32 func_80122F9C(PlayState* play); s32 func_80122FCC(PlayState* play); @@ -2402,7 +2402,7 @@ void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_ // void func_8014D7B4(void); void func_80150A84(PlayState* play); void func_80150D08(PlayState* play, u32 uParm2); -// void func_801514B0(void); +void func_801514B0(PlayState* play, u16 arg1, u8 arg2); void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor); void func_80151938(PlayState* play, u16 textId); void func_80151A68(PlayState* play, u16 textId); diff --git a/include/z64.h b/include/z64.h index 197396216e..e161b723f9 100644 --- a/include/z64.h +++ b/include/z64.h @@ -444,15 +444,15 @@ typedef struct { /* 0x22C */ s32 unk_22C; /* 0x230 */ s32 stickRelX; /* 0x234 */ s32 stickRelY; - /* 0x238 */ s16 unk_238[5]; - /* 0x242 */ s16 unk_242[5]; - /* 0x24C */ s16 unk_24C[5]; + /* 0x238 */ s16 cursorPoint[5]; + /* 0x242 */ s16 cursorX[5]; + /* 0x24C */ s16 cursorY[5]; /* 0x256 */ s16 unk_256; - /* 0x258 */ s16 unk_258; - /* 0x25A */ s16 unk_25A; + /* 0x258 */ s16 cursorSpecialPos; + /* 0x25A */ s16 pageSwitchTimer; /* 0x25C */ u16 unk_25C; /* 0x25E */ u16 cursorItem[5]; - /* 0x268 */ u16 unk_268[5]; + /* 0x268 */ u16 cursorSlot[5]; /* 0x272 */ u16 equipTargetItem; /* 0x274 */ u16 equipTargetSlot; /* 0x276 */ u16 equipTargetCBtn; @@ -461,8 +461,8 @@ typedef struct { /* 0x27C */ s16 equipAnimAlpha; /* 0x27E */ s16 unk_27E; /* 0x280 */ u16 unk_280; - /* 0x282 */ u16 unk_282; - /* 0x284 */ s16 unk_284; + /* 0x282 */ u16 nameColorSet; + /* 0x284 */ s16 cursorColorSet; /* 0x286 */ s16 unk_286; /* 0x288 */ f32 unk_288; /* 0x28C */ f32 unk_28C; @@ -476,9 +476,9 @@ typedef struct { /* 0x2B6 */ u8 unk_2B6; /* 0x2B7 */ u8 unk_2B7; /* 0x2B8 */ u8 unk_2B8; - /* 0x2B9 */ u8 unk_2B9; - /* 0x2BA */ s16 unk_2BA; - /* 0x2BC */ s16 unk_2BC; + /* 0x2B9 */ u8 itemDescriptionOn; // helpful description of item given through a message box + /* 0x2BA */ s16 equipAnimScale; // scale of item icon while moving being equipped to c-button + /* 0x2BC */ s16 equipAnimShrinkRate; // rate the scale is shrinking for the item icon while moving being equipped to c-button /* 0x2BE */ s16 unk_2BE[5]; /* 0x2C8 */ u16 unk_2C8; /* 0x2CA */ s16 unk_2CA; diff --git a/include/z64item.h b/include/z64item.h index f683558588..d8a2185cc1 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -285,7 +285,7 @@ typedef enum { /* 0xF2 */ ITEM_F2, /* 0xFD */ ITEM_FD = 0xFD, /* 0xFF */ ITEM_NONE = 0xFF -} ItemID; +} ItemId; #define BOTTLE_FIRST 0 #define BOTTLE_MAX 6 @@ -428,7 +428,7 @@ typedef enum { /* 0xB8 */ GI_TINGLE_MAP_GREAT_BAY, /* 0xB9 */ GI_TINGLE_MAP_STONE_TOWER, /* 0xBA */ GI_MAX -} GetItemID; +} GetItemId; typedef enum { /* 0x00 */ GID_BOTTLE, diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index b054dac74e..50022849e3 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -33,12 +33,12 @@ void func_800F4A10(PlayState* play) { for (i = 9; i >= 0; i--) { if ((gSaveContext.save.playerData.owlActivationFlags >> i) & 1) { pauseCtx->worldMapPoints[i] = 1; - pauseCtx->unk_238[4] = i; + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = i; } } if ((gSaveContext.save.playerData.owlActivationFlags >> 4) & 1) { - pauseCtx->unk_238[4] = 4; + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 4; } } @@ -82,7 +82,7 @@ void KaleidoSetup_Update(PlayState* play) { !(play->actorCtx.flags & ACTORCTX_FLAG_2)) { if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) { gSaveContext.unk_3F26 = gSaveContext.unk_3F22; - pauseCtx->unk_2B9 = 0; + pauseCtx->itemDescriptionOn = false; pauseCtx->state = 1; func_800F4A10(play); pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; @@ -122,23 +122,23 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->unk_20C = 936.0f; pauseCtx->unk_220 = -314.0f; - pauseCtx->unk_238[PAUSE_MAP] = XREG(94) + 3; + pauseCtx->cursorPoint[PAUSE_MAP] = XREG(94) + 3; - pauseCtx->unk_258 = 11; - pauseCtx->unk_25A = 0; + pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_RIGHT; + pauseCtx->pageSwitchTimer = 0; - pauseCtx->cursorItem[PAUSE_ITEM] = 999; + pauseCtx->cursorItem[PAUSE_ITEM] = PAUSE_ITEM_NONE; pauseCtx->cursorItem[PAUSE_MAP] = XREG(94) + 3; - pauseCtx->cursorItem[PAUSE_QUEST] = 999; - pauseCtx->cursorItem[PAUSE_MASK] = 999; + pauseCtx->cursorItem[PAUSE_QUEST] = PAUSE_ITEM_NONE; + pauseCtx->cursorItem[PAUSE_MASK] = PAUSE_ITEM_NONE; - pauseCtx->unk_268[PAUSE_ITEM] = 0; - pauseCtx->unk_268[PAUSE_MAP] = XREG(94) + 3; + pauseCtx->cursorSlot[PAUSE_ITEM] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = XREG(94) + 3; - pauseCtx->unk_284 = 2; + pauseCtx->cursorColorSet = 2; pauseCtx->unk_2A0 = -1; - pauseCtx->unk_2BA = 320; - pauseCtx->unk_2BC = 40; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; pauseCtx->promptAlpha = 100; View_Init(&pauseCtx->view, play->state.gfxCtx); diff --git a/src/code/z_message.c b/src/code/z_message.c index 16e1203d75..f98d3cf3a4 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -270,7 +270,7 @@ void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) { if ((func_8010A0A4(play) != 0) || (play->sceneNum == 0x4F)) { phi_v0 = 0xA; } else { - phi_v0 = pauseCtx->unk_238[PAUSE_WORLD_MAP]; + phi_v0 = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; } temp_s6 = D_801D0250[phi_v0]; diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 9231ca9b92..1ac301f207 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -257,7 +257,7 @@ void Message_LoadAreaTextNES(PlayState* play, s32* offset, f32* arg2, s16* decod if ((func_8010A0A4(play) != 0) || (play->sceneNum == SCENE_SECOM)) { currentArea = 10; } else { - currentArea = play->pauseCtx.unk_238[PAUSE_WORLD_MAP]; + currentArea = play->pauseCtx.cursorPoint[PAUSE_WORLD_MAP]; } stringLimit = D_801D07C4[currentArea]; diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 1566077f1a..8ced31cb77 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -274,7 +274,7 @@ u8 Player_MaskIdToItemId(s32 maskIdMinusOne) { return sMaskItemIds[maskIdMinusOne]; } -u8 Player_GetCurMaskItemId(PlayState* play) { +s32 Player_GetCurMaskItemId(PlayState* play) { Player* player = GET_PLAYER(play); if (player->currentMask != PLAYER_MASK_NONE) { diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 0c00c60404..07de01c120 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -922,11 +922,7 @@ void EnFsn_DeterminePrice(EnFsn* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { itemActionParam = func_80123810(play); if (itemActionParam > PLAYER_AP_NONE) { - if (player->heldItemButton == 0) { - buttonItem = CUR_FORM_EQUIP(player->heldItemButton); - } else { - buttonItem = gSaveContext.save.equips.buttonItems[0][player->heldItemButton]; - } + buttonItem = GET_CUR_FORM_BTN_ITEM(player->heldItemButton); this->price = (buttonItem < ITEM_MOON_TEAR) ? gItemPrices[buttonItem] : 0; if (this->price > 0) { player->actor.textId = 0x29EF; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index 2854b02c6c..9f6a58a860 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -34,10 +34,10 @@ s16 sCurRow = 0; // Geometry of the highlights for the selected section typedef struct { - /* 0 */ s16 screenX; - /* 1 */ s16 screenY; - /* 2 */ s16 width; -} SectionPosition; + /* 0x0 */ s16 screenX; + /* 0x2 */ s16 screenY; + /* 0x4 */ s16 width; +} SectionPosition; // size = 0x6; // clang-format off SectionPosition sSectionPositions[] = { diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index ae2140f2c6..888f715c01 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -1,85 +1,1004 @@ /* * File: z_kaleido_item.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu - Item Page */ #include "z_kaleido_scope.h" +#include "interface/parameter_static/parameter_static.h" -extern UNK_TYPE D_02001360; -extern UNK_TYPE D_020044A0; -extern UNK_TYPE D_02004AA0; -extern UNK_TYPE D_0200B998; -extern UNK_TYPE D_08062000; -extern UNK_TYPE D_08064340; -extern UNK_TYPE D_0B000000; -extern UNK_TYPE D_0C000000; -extern UNK_TYPE D_0C006C00; +typedef enum { + /* 0 */ EQUIP_STATE_MAGIC_ARROW_GROW_ORB, + /* 1 */ EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT, + /* 2 */ EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT, + /* 3 */ EQUIP_STATE_MOVE_TO_C_BTN +} EquipState; -s32 D_8082B3C0 = 0; +s16 sEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB; -s32 D_8082B3C4 = 0; +// Timer to hold magic arrow icon over magic arrow slot before moving when equipping. +s16 sEquipMagicArrowSlotHoldTimer = 0; -s16 D_8082B3C8 = 10; +// Number of frames to move icon from slot to target position when equipping. +s16 sEquipAnimTimer = 10; -u8 D_8082B3CC[5][24] = { +u8 gPlayerFormSlotRestrictions[PLAYER_FORM_MAX][24] = { + // Fierce Deity { - false, false, false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, true, true, true, + false, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + false, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + false, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + false, // SLOT_PICTO_BOX + false, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + false, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, + // Goron { - true, false, false, false, false, true, false, false, false, false, false, true, - true, true, true, false, false, true, true, true, true, true, true, true, + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + true, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, + // Zora { - true, false, false, false, false, true, false, false, false, false, false, true, - false, true, true, false, false, true, true, true, true, true, true, true, + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, + // Deku { - true, false, false, false, false, true, false, false, false, true, false, true, - false, true, true, false, false, true, true, true, true, true, true, true, + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + true, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, + // Human { - true, true, true, true, true, true, true, true, true, true, true, true, - false, true, true, true, true, true, true, true, true, true, true, true, + true, // SLOT_OCARINA + true, // SLOT_BOW + true, // SLOT_ARROW_FIRE + true, // SLOT_ARROW_ICE + true, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + true, // SLOT_BOMB + true, // SLOT_BOMBCHU + true, // SLOT_STICK + true, // SLOT_NUT + true, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + true, // SLOT_HOOKSHOT + true, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 }, }; -s16 D_8082B444[] = { - 0x005F, 0x003E, 0x005F, 0x0080, 0x00A1, 0x00C2, 0x003E, 0x005F, +s16 sAmmoRectLeft[] = { + 95, // SLOT_BOW + 62, // SLOT_BOMB + 95, // SLOT_BOMBCHU + 128, // SLOT_STICK + 161, // SLOT_NUT + 194, // SLOT_MAGIC_BEANS + 62, // SLOT_POWDER_KEG + 95, // SLOT_PICTO_BOX }; -s16 D_8082B454[] = { - 0x0055, 0x0075, 0x0075, 0x0075, 0x0075, 0x0075, 0x0096, 0x0096, 0x00FF, 0x0064, - 0x00FF, 0x0000, 0x0000, 0x0064, 0x00FF, 0x0000, 0x0000, 0x00FF, 0x0064, 0x0000, +s16 sAmmoRectHeight[] = { + 85, // SLOT_BOW + 117, // SLOT_BOMB + 117, // SLOT_BOMBCHU + 117, // SLOT_STICK + 117, // SLOT_NUT + 117, // SLOT_MAGIC_BEANS + 150, // SLOT_POWDER_KEG + 150, // SLOT_PICTO_BOX }; -u8 D_8082B47C[] = { - 0x35, 0x33, 0x34, 0x32, 0xFF, +void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item, u16 ammoIndex) { + s16 ammoUpperDigit; + s16 ammo; + + OPEN_DISPS(gfxCtx); + + if (item == ITEM_PICTO_BOX) { + if (!CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { + ammo = 0; + } else { + ammo = 1; + } + } else { + ammo = AMMO(item); + } + + gDPPipeSync(POLY_OPA_DISP++); + + if (!gPlayerFormSlotRestrictions[((void)0, gSaveContext.save.playerForm)][SLOT(item)]) { + // Ammo item is restricted + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 100, 100, pauseCtx->alpha); + } else { + // Default ammo + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + if (ammo == 0) { + // Out of ammo + 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_STICK) && (AMMO(item) == CUR_CAPACITY(UPG_STICKS))) || + ((item == ITEM_NUT) && (AMMO(item) == CUR_CAPACITY(UPG_NUTS))) || + ((item == ITEM_BOMBCHU) && (AMMO(item) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((item == ITEM_POWDER_KEG) && (ammo == 1)) || ((item == ITEM_PICTO_BOX) && (ammo == 1)) || + ((item == ITEM_MAGIC_BEANS) && (ammo == 20))) { + // Ammo at capacity + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 120, 255, 0, pauseCtx->alpha); + } + } + + // Separate ammo into upper and lower digits + for (ammoUpperDigit = 0; ammo >= 10; ammoUpperDigit++) { + ammo -= 10; + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw upper digit + if (ammoUpperDigit != 0) { + POLY_OPA_DISP = func_8010CD98(POLY_OPA_DISP, ((u8*)gAmmoDigit0Tex + (8 * 8 * ammoUpperDigit)), 8, 8, + sAmmoRectLeft[ammoIndex], sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); + } + + // Draw lower digit + POLY_OPA_DISP = func_8010CD98(POLY_OPA_DISP, ((u8*)gAmmoDigit0Tex + (8 * 8 * ammo)), 8, 8, + sAmmoRectLeft[ammoIndex] + 6, sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); + + CLOSE_DISPS(gfxCtx); +} + +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]; +} + +s16 sMagicArrowEffectsR[] = { 255, 100, 255 }; +s16 sMagicArrowEffectsG[] = { 0, 100, 255 }; +s16 sMagicArrowEffectsB[] = { 0, 255, 100 }; + +void KaleidoScope_DrawItemSelect(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; + u16 i; + u16 j; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C8AC(play->state.gfxCtx); + + // Draw a white box around the items that are equipped on the C buttons + // Loop over c-buttons (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + for (i = 0, j = 24 * 4; i < 3; i++, j += 4) { + if (GET_CUR_FORM_BTN_ITEM(i + 1) != ITEM_NONE) { + if (GET_CUR_FORM_BTN_SLOT(i + 1) < 24) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j], 4, 0); + POLY_OPA_DISP = func_8010DC58(POLY_OPA_DISP, gEquippedItemOutlineTex, 32, 32, 0); + } + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw the item icons + // Loop over slots (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + for (j = 0, i = 0; i < 24; i++, j += 4) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (((void)0, gSaveContext.save.inventory.items[i]) != ITEM_NONE) { + if ((pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && (pauseCtx->cursorSpecialPos == 0) && + gPlayerFormSlotRestrictions[(void)0, gSaveContext.save.playerForm][i]) { + if ((sEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) && (i == SLOT_ARROW_ICE)) { + // Possible bug: + // Supposed to be `SLOT_BOW`, unchanged from OoT, instead increase size of ice arrow icon + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sMagicArrowEffectsR[pauseCtx->equipTargetItem - 0xB5], + sMagicArrowEffectsG[pauseCtx->equipTargetItem - 0xB5], + sMagicArrowEffectsB[pauseCtx->equipTargetItem - 0xB5], 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 == pauseCtx->cursorSlot[PAUSE_ITEM]) { + // Increase the size of the selected item + 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(play->state.gfxCtx, + gItemIcons[((void)0, gSaveContext.save.inventory.items[i])], 32, 32, 0); + } + } + + // Draw the ammo digits + if (pauseCtx->pageIndex == PAUSE_ITEM) { + if ((pauseCtx->state == 6) && ((pauseCtx->unk_200 == 0) || (pauseCtx->unk_200 == 3)) && + (pauseCtx->state != 7) && ((pauseCtx->state < 8) || (pauseCtx->state >= 0x13))) { + func_8012C628(play->state.gfxCtx); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + // Loop over slots (i) and ammoIndex (j) + for (j = 0, i = 0; i < 24; i++) { + if (gAmmoItems[i] != ITEM_NONE) { + if (((void)0, gSaveContext.save.inventory.items[i]) != ITEM_NONE) { + KaleidoScope_DrawAmmoCount(pauseCtx, play->state.gfxCtx, + ((void)0, gSaveContext.save.inventory.items[i]), j); + } + j++; + } + } + func_8012C8AC(play->state.gfxCtx); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +u8 sPlayerFormItems[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_NONE, }; -s16 D_8082B484[] = { - 0x0294, - 0x0384, - 0x0474, - 0x0000, -}; +void KaleidoScope_UpdateItemCursor(PlayState* play) { + s32 pad1; + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + u16 vtxIndex; + u16 cursorItem; + u16 cursorSlot; + u8 magicArrowIndex; + s16 cursorPoint; + s16 cursorX; + s16 cursorY; + s16 oldCursorPoint; + s16 moveCursorResult; + s16 pad2; -s16 D_8082B48C[] = { - 0x044C, - 0x0398, - 0x044C, - 0x0000, -}; + pauseCtx->cursorColorSet = 0; + pauseCtx->nameColorSet = 0; -s32 D_8082B494[] = { 0, 0, 0 }; + if ((pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && (pauseCtx->pageIndex == PAUSE_ITEM) && + !pauseCtx->itemDescriptionOn) { + moveCursorResult = 0; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B240.s") + cursorItem = pauseCtx->cursorItem[PAUSE_ITEM]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B6BC.s") + // Move cursor left/right + if (pauseCtx->cursorSpecialPos == 0) { + // cursor is currently on a slot + pauseCtx->cursorColorSet = 2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B6EC.s") + if (ABS_ALT(pauseCtx->stickRelX) > 30) { + cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + cursorX = pauseCtx->cursorX[PAUSE_ITEM]; + cursorY = pauseCtx->cursorY[PAUSE_ITEM]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081BCA8.s") + // Search for slot to move to + while (moveCursorResult == 0) { + if (pauseCtx->stickRelX < -30) { + // move cursor left + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorX[PAUSE_ITEM] != 0) { + pauseCtx->cursorX[PAUSE_ITEM]--; + pauseCtx->cursorPoint[PAUSE_ITEM]--; + moveCursorResult = 1; + } else { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM]++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081C684.s") + 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(play, PAUSE_CURSOR_PAGE_LEFT); + + moveCursorResult = 2; + } + } + } else if (pauseCtx->stickRelX > 30) { + // move cursor right + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorX[PAUSE_ITEM] <= 4) { + pauseCtx->cursorX[PAUSE_ITEM]++; + pauseCtx->cursorPoint[PAUSE_ITEM]++; + moveCursorResult = 1; + } else { + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM]++; + + 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(play, PAUSE_CURSOR_PAGE_RIGHT); + + moveCursorResult = 2; + } + } + } + } + + if (moveCursorResult == 1) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickRelX > 30) { + func_80821A04(play); + cursorY = 0; + cursorX = 0; + cursorPoint = 0; // top row, left column (SLOT_OCARINA) + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + moveCursorResult = 1; + break; + } + + // move 1 row down and retry + cursorY++; + cursorPoint += 6; + if (cursorY < 4) { + continue; + } + + // move 1 column right and retry + cursorY = 0; + cursorPoint = cursorX + 1; + cursorX = cursorPoint; + if (cursorX < 6) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } + } else { // PAUSE_CURSOR_PAGE_RIGHT + if (pauseCtx->stickRelX < -30) { + func_80821A04(play); + cursorX = 5; + cursorPoint = 5; // top row, right columne (SLOT_TRADE_DEED) + cursorY = 0; + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + pauseCtx->cursorX[PAUSE_ITEM] = cursorX; + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + moveCursorResult = 1; + break; + } + + // move 1 row down and retry + cursorY++; + cursorPoint += 6; + if (cursorY < 4) { + continue; + } + + // move 1 column left and retry + cursorY = 0; + cursorPoint = cursorX - 1; + cursorX = cursorPoint; + if (cursorX >= 0) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + // move cursor up/down + if (ABS_ALT(pauseCtx->stickRelY) > 30) { + moveCursorResult = 0; + + cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + cursorY = pauseCtx->cursorY[PAUSE_ITEM]; + + while (moveCursorResult == 0) { + if (pauseCtx->stickRelY > 30) { + // move cursor up + moveCursorResult = 2; + if (pauseCtx->cursorY[PAUSE_ITEM] != 0) { + pauseCtx->cursorY[PAUSE_ITEM]--; + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; + moveCursorResult = 1; + } else { + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + } + } else if (pauseCtx->stickRelY < -30) { + // move cursor down + moveCursorResult = 2; + if (pauseCtx->cursorY[PAUSE_ITEM] < 3) { + pauseCtx->cursorY[PAUSE_ITEM]++; + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorPoint[PAUSE_ITEM] += 6; + moveCursorResult = 1; + } else { + pauseCtx->cursorY[PAUSE_ITEM] = cursorY; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + } + } + } + } + + cursorSlot = pauseCtx->cursorPoint[PAUSE_ITEM]; + pauseCtx->cursorColorSet = 2; + + if (moveCursorResult == 1) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } else if (moveCursorResult != 2) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } + + if (cursorItem == ITEM_NONE) { + cursorItem = PAUSE_ITEM_NONE; + pauseCtx->cursorColorSet = 0; + } + + if ((cursorItem != (u32)PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.unk_3F22 = 0; + Interface_ChangeAlpha(50); + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.unk_3F22 = 0; + Interface_ChangeAlpha(50); + } + + pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; + pauseCtx->cursorSlot[PAUSE_ITEM] = cursorSlot; + if (cursorItem != PAUSE_ITEM_NONE) { + // Equip item to the C buttons + if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && !pauseCtx->itemDescriptionOn && + (pauseCtx->state == 6) && (pauseCtx->unk_200 == 0) && + CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { + + // Ensure that a transformation mask can not be unequipped while being used + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if (1) {} + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CLEFT)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CDOWN)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CRIGHT)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } + } + + // Ensure that a non-transformation mask can not be unequipped while being used + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CLEFT)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_LEFT; + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CDOWN)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_DOWN; + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CRIGHT)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_RIGHT; + } + + // Equip item to the C buttons + pauseCtx->equipTargetItem = cursorItem; + pauseCtx->equipTargetSlot = cursorSlot; + pauseCtx->unk_200 = 3; + vtxIndex = cursorSlot * 4; + pauseCtx->equipAnimX = pauseCtx->itemVtx[vtxIndex].v.ob[0] * 10; + pauseCtx->equipAnimY = pauseCtx->itemVtx[vtxIndex].v.ob[1] * 10; + pauseCtx->equipAnimAlpha = 255; + sEquipMagicArrowSlotHoldTimer = 0; + sEquipState = EQUIP_STATE_MOVE_TO_C_BTN; + sEquipAnimTimer = 10; + + if ((pauseCtx->equipTargetItem == ITEM_ARROW_FIRE) || + (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) || + (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT)) { + magicArrowIndex = 0; + if (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) { + magicArrowIndex = 1; + } + if (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT) { + magicArrowIndex = 2; + } + play_sound(NA_SE_SY_SET_FIRE_ARROW + magicArrowIndex); + pauseCtx->equipTargetItem = 0xB5 + magicArrowIndex; + pauseCtx->equipAnimAlpha = sEquipState = 0; // EQUIP_STATE_MAGIC_ARROW_GROW_ORB + sEquipAnimTimer = 6; + } else { + play_sound(NA_SE_SY_DECIDE); + } + } else if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (pauseCtx->state == 6) && + (pauseCtx->unk_200 == 0) && CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && + (msgCtx->msgLength == 0)) { + // Give description on item through a message box + pauseCtx->itemDescriptionOn = true; + if (pauseCtx->cursorY[PAUSE_ITEM] < 2) { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 3); + } else { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 1); + } + } + } + } else { + pauseCtx->cursorItem[PAUSE_ITEM] = PAUSE_ITEM_NONE; + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_ITEM]) { + play_sound(NA_SE_SY_CURSOR); + } + } else if ((pauseCtx->unk_200 == 3) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + pauseCtx->cursorColorSet = 2; + } +} + +s16 sCButtonPosX[] = { 660, 900, 1140 }; +s16 sCButtonPosY[] = { 1100, 920, 1100 }; + +void KaleidoScope_UpdateItemEquip(PlayState* play) { + static s16 sEquipMagicArrowBowSlotHoldTimer = 0; + PauseContext* pauseCtx = &play->pauseCtx; + Vtx* bowItemVtx; + u16 offsetX; + u16 offsetY; + + // Grow glowing orb when equipping magic arrows + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_GROW_ORB) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + sEquipState++; + } + // Hover over magic arrow slot when the next state is reached + sEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) { + sEquipMagicArrowBowSlotHoldTimer--; + + if (sEquipMagicArrowBowSlotHoldTimer == 0) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + sEquipAnimTimer = 6; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + sEquipState++; + play_sound(NA_SE_SY_SYNTH_MAGIC_ARROW); + } + return; + } + + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + bowItemVtx = &pauseCtx->itemVtx[4]; + offsetX = ABS_ALT(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sEquipAnimTimer; + } else { + offsetX = ABS_ALT(pauseCtx->equipAnimX - sCButtonPosX[pauseCtx->equipTargetCBtn]) / sEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - sCButtonPosY[pauseCtx->equipTargetCBtn]) / sEquipAnimTimer; + } + + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipAnimAlpha < 254)) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + } + sEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimScale -= pauseCtx->equipAnimShrinkRate / sEquipAnimTimer; + pauseCtx->equipAnimShrinkRate -= pauseCtx->equipAnimShrinkRate / sEquipAnimTimer; + + // Update coordinates of item icon while being equipped + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + // target is the bow slot + if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[4].v.ob[0] * 10)) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[4].v.ob[1] * 10)) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } else { + // target is the c button + 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; + } + } + + sEquipAnimTimer--; + if (sEquipAnimTimer == 0) { + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + sEquipState++; + sEquipMagicArrowBowSlotHoldTimer = 4; + return; + } + + // Equip item onto c buttons + if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_LEFT) { + // Swap if item is already equipped on CDown or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } + + // Equip item on CLeft + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + } else if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_DOWN) { + // Swap if item is already equipped on CLeft or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } + + // Equip item on CDown + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + } else { // (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_RIGHT) + // Swap if item is already equipped on CLeft or CDown. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } + + // Equip item on CRight + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + } + + // Reset params + pauseCtx->unk_200 = 0; + sEquipAnimTimer = 10; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + } + } else { + sEquipMagicArrowSlotHoldTimer--; + if (sEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimAlpha = 255; + } + } +} diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h index b4d2a192fe..19e3c8719c 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h @@ -3,14 +3,25 @@ #include "global.h" +#define PAUSE_ITEM_NONE 999 + +#define PAUSE_CURSOR_PAGE_LEFT 10 +#define PAUSE_CURSOR_PAGE_RIGHT 11 + typedef enum { - /* 0x00 */ PAUSE_ITEM, - /* 0x01 */ PAUSE_MAP, - /* 0x02 */ PAUSE_QUEST, - /* 0x03 */ PAUSE_MASK, - /* 0x04 */ PAUSE_WORLD_MAP + /* 0 */ PAUSE_ITEM, + /* 1 */ PAUSE_MAP, + /* 2 */ PAUSE_QUEST, + /* 3 */ PAUSE_MASK, + /* 4 */ PAUSE_WORLD_MAP } PauseMenuPage; +typedef enum { + /* 0 */ PAUSE_EQUIP_C_LEFT, + /* 1 */ PAUSE_EQUIP_C_DOWN, + /* 2 */ PAUSE_EQUIP_C_RIGHT +} PauseEquipCButton; + typedef enum { /* 0 */ DEBUG_EDITOR_NONE, /* 1 */ DEBUG_EDITOR_INVENTORY_INIT, @@ -21,6 +32,17 @@ typedef enum { #define PAUSE_PROMPT_YES 0 #define PAUSE_PROMPT_NO 4 +// NES +void KaleidoScope_MoveCursorToSpecialPos(PlayState* play, s16 cursorSpecialPos); +void KaleidoScope_DrawQuadTextureRGBA32(GraphicsContext* gfxCtx, void* texture, u16 width, u16 height, u16 point); +void func_80821A04(PlayState* play); + +// Item +void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx); +void KaleidoScope_DrawItemSelect(PlayState* play); +void KaleidoScope_UpdateItemCursor(PlayState* play); +void KaleidoScope_UpdateItemEquip(PlayState* play); + // Debug void KaleidoScope_DrawInventoryEditor(PlayState* play); void KaleidoScope_UpdateInventoryEditor(PlayState* play); diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index 44575f156e..c02ebcad28 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -318,11 +318,11 @@ s32 D_8082BEB8[] = { 0, 0 }; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821958.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821984.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_MoveCursorToSpecialPos.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821A04.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821AD4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawQuadTextureRGBA32.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821CC4.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f2af2a653a..edd85dc514 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4204,11 +4204,11 @@ 0x808190C4:("KaleidoScope_DrawDigit",), 0x80819238:("KaleidoScope_DrawInventoryEditor",), 0x80819F04:("KaleidoScope_UpdateInventoryEditor",), - 0x8081B240:("func_8081B240",), - 0x8081B6BC:("func_8081B6BC",), - 0x8081B6EC:("func_8081B6EC",), - 0x8081BCA8:("func_8081BCA8",), - 0x8081C684:("func_8081C684",), + 0x8081B240:("KaleidoScope_DrawAmmoCount",), + 0x8081B6BC:("KaleidoScope_SetCursorVtx",), + 0x8081B6EC:("KaleidoScope_DrawItemSelect",), + 0x8081BCA8:("KaleidoScope_UpdateItemCursor",), + 0x8081C684:("KaleidoScope_UpdateItemEquip",), 0x8081D240:("func_8081D240",), 0x8081D6DC:("func_8081D6DC",), 0x8081E118:("func_8081E118",), @@ -4221,9 +4221,9 @@ 0x80821900:("func_80821900",), 0x8082192C:("func_8082192C",), 0x80821958:("func_80821958",), - 0x80821984:("func_80821984",), + 0x80821984:("KaleidoScope_MoveCursorToSpecialPos",), 0x80821A04:("func_80821A04",), - 0x80821AD4:("func_80821AD4",), + 0x80821AD4:("KaleidoScope_DrawQuadTextureRGBA32",), 0x80821CC4:("func_80821CC4",), 0x80821D84:("func_80821D84",), 0x80821F30:("func_80821F30",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index f21fc7d98f..82acecd8d7 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4693,16 +4693,16 @@ 0x8082B388:("sRowFirstSections","UNK_TYPE2","",0x2), 0x8082B3AC:("sPrevDBtnInput","UNK_TYPE4","",0x4), 0x8082B3B0:("sHeldDBtnTimer","UNK_TYPE4","",0x4), - 0x8082B3C0:("D_8082B3C0","UNK_TYPE2","",0x2), - 0x8082B3C4:("D_8082B3C4","UNK_TYPE2","",0x2), - 0x8082B3C8:("D_8082B3C8","UNK_TYPE2","",0x2), - 0x8082B3CC:("D_8082B3CC","UNK_TYPE1","",0x1), - 0x8082B444:("D_8082B444","UNK_TYPE1","",0x1), - 0x8082B454:("D_8082B454","UNK_TYPE1","",0x1), - 0x8082B47C:("D_8082B47C","UNK_TYPE1","",0x1), - 0x8082B484:("D_8082B484","UNK_TYPE1","",0x1), - 0x8082B48C:("D_8082B48C","UNK_TYPE1","",0x1), - 0x8082B494:("D_8082B494","UNK_TYPE2","",0x2), + 0x8082B3C0:("sEquipState","UNK_TYPE2","",0x2), + 0x8082B3C4:("sEquipMagicArrowSlotHoldTimer","UNK_TYPE2","",0x2), + 0x8082B3C8:("sEquipAnimTimer","UNK_TYPE2","",0x2), + 0x8082B3CC:("gPlayerFormSlotRestrictions","UNK_TYPE1","",0x1), + 0x8082B444:("sAmmoRectLeft","UNK_TYPE1","",0x1), + 0x8082B454:("sAmmoRectHeight","UNK_TYPE1","",0x1), + 0x8082B47C:("sPlayerFormItems","UNK_TYPE1","",0x1), + 0x8082B484:("sCButtonPosX","UNK_TYPE1","",0x1), + 0x8082B48C:("sCButtonPosY","UNK_TYPE1","",0x1), + 0x8082B494:("sEquipMagicArrowBowSlotHoldTimer","UNK_TYPE2","",0x2), 0x8082B4A0:("D_8082B4A0","UNK_TYPE4","",0x4), 0x8082B4AC:("D_8082B4AC","UNK_TYPE1","",0x1), 0x8082B4BC:("D_8082B4BC","UNK_TYPE1","",0x1),