From fd06827e2b4072ef5298cce03760cda942cf3ef0 Mon Sep 17 00:00:00 2001 From: rozlette Date: Wed, 22 Jun 2022 21:24:20 -0500 Subject: [PATCH] DPad items --- .../assets/ship_of_harkinian/buttons/dpad.bin | Bin 0 -> 2048 bytes libultraship/libultraship/SohImGuiImpl.cpp | 3 + soh/include/macros.h | 4 + soh/include/z64.h | 4 + soh/include/z64interface.h | 15 + soh/include/z64save.h | 6 +- soh/soh/SaveManager.cpp | 20 +- soh/src/code/z_construct.c | 46 +- soh/src/code/z_game_over.c | 5 +- soh/src/code/z_parameter.c | 444 ++++++++++++++---- soh/src/code/z_sram.c | 4 +- .../actors/ovl_player_actor/z_player.c | 73 ++- .../ovl_file_choose/z_file_choose.c | 10 +- .../overlays/gamestates/ovl_select/z_select.c | 5 +- .../ovl_kaleido_scope/z_kaleido_equipment.c | 8 +- .../misc/ovl_kaleido_scope/z_kaleido_item.c | 259 ++-------- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 83 ++-- 17 files changed, 582 insertions(+), 407 deletions(-) create mode 100644 OTRExporter/assets/ship_of_harkinian/buttons/dpad.bin diff --git a/OTRExporter/assets/ship_of_harkinian/buttons/dpad.bin b/OTRExporter/assets/ship_of_harkinian/buttons/dpad.bin new file mode 100644 index 0000000000000000000000000000000000000000..2e25b6686db321be41c6f61ae62cbe39e1e70dad GIT binary patch literal 2048 zcmcK4%}x_h6bJB|@?kKDNi`xx> zbisWDUV?Pzqp(JIfB$!;rLzF^#xOUTPG|0K&N(yZju5xA9R>2SR6NU3i05NR0kbF{ zhU|6;S>#Z}GWX+cF>G>&%$H@v5yd3;38Ww(zMA;ilQ}#_n0J_l<@pmMuPj#&Vu*T4 z$5$raQVB#bMHiqh8T+J4Q(JWRsBL4PR!h_idgfQY{*UdZY|UAy%9OEdbYx7S-j=5 zDq{^B_{hD^+|v%4*oTCJUEXU8b)H|w$e9?>cSzLoc!_a5!wde-BaJ+-`t<>|L)qYy zs9=>*a+uXM)wG{(y~Y!S@SNTH3Q4!_vM+X5>!|OUUjd7p716%c^Vg+?&ASQxmrA3XTAAa%rl6GoHfbL==%BA8?KT# zb6R9>W#(Ar6Y}&yr*2OdSzD4dPO{eErMC{}{z2QUtEWR4)c#P{KNb#L=&E`nfHB7R z$DZ)!`{r==g$QfUZ9$xhpZ?KzzU#}}T|ejk>pVWCx^~-Ed+z(zb?eL-&1n7asn6_| zuFe{JM>XAEv)GYYu0+%LJL(fV)vcRae@D#n-%@pI{oNX**55HRzp1L!OX$Neb=25z zs0ww8ofhQ?8T*y*dG@5mzSjDV_TR33*;iZ$#>6k0-uNx1u9$YysTpxBesspMn7L`{ H|6Kb6%B2|A literal 0 HcmV?d00001 diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 41e8b9a81..52a1a52c3 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -776,9 +776,12 @@ namespace SohImGui { if (ImGui::BeginMenu("Controller")) { + // TODO mutual exclusions -- gDpadEquips and gDpadPauseName cause conflicts, but nothing stops a user from selecting both + // There should be some system to prevent conclifting enhancements from being selected EnhancementCheckbox("D-pad Support on Pause and File Select", "gDpadPauseName"); EnhancementCheckbox("D-pad Support in Ocarina and Text Choice", "gDpadOcarinaText"); EnhancementCheckbox("D-pad Support for Browsing Shop Items", "gDpadShop"); + EnhancementCheckbox("D-pad as Equip Items", "gDpadEquips"); ImGui::Separator(); diff --git a/soh/include/macros.h b/soh/include/macros.h index 7392274d9..b794b1777 100644 --- a/soh/include/macros.h +++ b/soh/include/macros.h @@ -76,6 +76,10 @@ ? gSaveContext.equips.buttonItems[(button) + 1] \ : ITEM_NONE) +#define DPAD_ITEM(button) ((gSaveContext.buttonStatus[(button) + 5] != BTN_DISABLED) \ + ? gSaveContext.equips.buttonItems[(button) + 4] \ + : ITEM_NONE) + #define CHECK_BTN_ALL(state, combo) (~((state) | ~(combo)) == 0) #define CHECK_BTN_ANY(state, combo) (((state) & (combo)) != 0) diff --git a/soh/include/z64.h b/soh/include/z64.h index 28dc235dc..c7978aa6e 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -705,6 +705,10 @@ typedef struct { /* 0x024C */ u16 cDownAlpha; /* 0x024E */ u16 cRightAlpha; /* 0x0250 */ u16 healthAlpha; // also max C-Up alpha + /* 0x024E */ u16 dpadUpAlpha; + /* 0x024E */ u16 dpadDownAlpha; + /* 0x024E */ u16 dpadLeftAlpha; + /* 0x024E */ u16 dpadRightAlpha; /* 0x0252 */ u16 magicAlpha; // also Rupee and Key counters alpha /* 0x0254 */ u16 minimapAlpha; /* 0x0256 */ s16 startAlpha; diff --git a/soh/include/z64interface.h b/soh/include/z64interface.h index de3913aba..3e3935a22 100644 --- a/soh/include/z64interface.h +++ b/soh/include/z64interface.h @@ -22,6 +22,21 @@ #define C_UP_BUTTON_X 254 #define C_UP_BUTTON_Y 16 +#define DPAD_UP_X 279 +#define DPAD_UP_Y 47 + +#define DPAD_DOWN_X 279 +#define DPAD_DOWN_Y 79 + +#define DPAD_LEFT_X 263 +#define DPAD_LEFT_Y 63 + +#define DPAD_RIGHT_X 295 +#define DPAD_RIGHT_Y 63 + +#define DPAD_X 271 +#define DPAD_Y 55 + /** * 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 diff --git a/soh/include/z64save.h b/soh/include/z64save.h index a284dbf56..daf316e0a 100644 --- a/soh/include/z64save.h +++ b/soh/include/z64save.h @@ -5,8 +5,8 @@ #include "z64math.h" typedef struct { - /* 0x00 */ u8 buttonItems[4]; - /* 0x04 */ u8 cButtonSlots[3]; + /* 0x00 */ u8 buttonItems[8]; + /* 0x04 */ u8 cButtonSlots[7]; /* 0x08 */ u16 equipment; } ItemEquips; // size = 0x0A @@ -125,7 +125,7 @@ typedef struct { /* 0x13DA */ s16 timerY[2]; /* 0x13E0 */ u8 seqId; /* 0x13E1 */ u8 natureAmbienceId; - /* 0x13E2 */ u8 buttonStatus[5]; + /* 0x13E2 */ u8 buttonStatus[9]; /* 0x13E7 */ u8 unk_13E7; // alpha related /* 0x13E8 */ u16 unk_13E8; // alpha type? /* 0x13EA */ u16 unk_13EA; // also alpha type? diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index b65da18fc..e4e7fbbdc 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -278,11 +278,11 @@ void SaveManager::InitFileDebug() { gSaveContext.savedSceneNum = 0x51; // Equipment - static std::array sButtonItems = { ITEM_SWORD_MASTER, ITEM_BOW, ITEM_BOMB, ITEM_OCARINA_FAIRY }; + static std::array sButtonItems = { ITEM_SWORD_MASTER, ITEM_BOW, ITEM_BOMB, ITEM_OCARINA_FAIRY, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE }; for (int button = 0; button < ARRAY_COUNT(gSaveContext.equips.buttonItems); button++) { gSaveContext.equips.buttonItems[button] = sButtonItems[button]; } - static std::array sCButtonSlots = { SLOT_BOW, SLOT_BOMB, SLOT_OCARINA }; + static std::array sCButtonSlots = { SLOT_BOW, SLOT_BOMB, SLOT_OCARINA, SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }; for (int button = 0; button < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); button++) { gSaveContext.equips.cButtonSlots[button] = sCButtonSlots[button]; } @@ -493,19 +493,23 @@ void SaveManager::LoadBaseVersion1() { SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum); SaveManager::Instance->LoadStruct("childEquips", []() { SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) { - SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i]); + SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i], + static_cast(ITEM_NONE)); }); SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) { - SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i]); + SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i], + static_cast(SLOT_NONE)); }); SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment); }); SaveManager::Instance->LoadStruct("adultEquips", []() { SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) { - SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i]); + SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i], + static_cast(ITEM_NONE)); }); SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) { - SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i]); + SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i], + static_cast(SLOT_NONE)); }); SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment); }); @@ -513,10 +517,10 @@ void SaveManager::LoadBaseVersion1() { SaveManager::Instance->LoadData("savedSceneNum", gSaveContext.savedSceneNum); SaveManager::Instance->LoadStruct("equips", []() { SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.equips.buttonItems), [](size_t i) { - SaveManager::Instance->LoadData("", gSaveContext.equips.buttonItems[i]); + SaveManager::Instance->LoadData("", gSaveContext.equips.buttonItems[i], static_cast(ITEM_NONE)); }); SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.equips.cButtonSlots), [](size_t i) { - SaveManager::Instance->LoadData("", gSaveContext.equips.cButtonSlots[i]); + SaveManager::Instance->LoadData("", gSaveContext.equips.cButtonSlots[i], static_cast(SLOT_NONE)); }); SaveManager::Instance->LoadData("equipment", gSaveContext.equips.equipment); }); diff --git a/soh/src/code/z_construct.c b/soh/src/code/z_construct.c index c74d3c14c..0bdf4a9d4 100644 --- a/soh/src/code/z_construct.c +++ b/soh/src/code/z_construct.c @@ -25,8 +25,9 @@ void func_801109B0(GlobalContext* globalCtx) { interfaceCtx->minimapAlpha = 0; interfaceCtx->unk_260 = 0; interfaceCtx->unk_244 = interfaceCtx->aAlpha = interfaceCtx->bAlpha = interfaceCtx->cLeftAlpha = - interfaceCtx->cDownAlpha = interfaceCtx->cRightAlpha = interfaceCtx->healthAlpha = interfaceCtx->startAlpha = - interfaceCtx->magicAlpha = 0; + interfaceCtx->cDownAlpha = interfaceCtx->cRightAlpha = interfaceCtx->dpadUpAlpha = interfaceCtx->dpadDownAlpha = + interfaceCtx->dpadLeftAlpha = interfaceCtx->dpadRightAlpha = interfaceCtx->healthAlpha = + interfaceCtx->startAlpha = interfaceCtx->magicAlpha = 0; parameterSize = (uintptr_t)_parameter_staticSegmentRomEnd - (uintptr_t)_parameter_staticSegmentRomStart; @@ -73,7 +74,8 @@ void func_801109B0(GlobalContext* globalCtx) { //DmaMgr_SendRequest1(interfaceCtx->doActionSegment + 0x300, (uintptr_t)_do_action_staticSegmentRomStart + doActionOffset, //0x180, "../z_construct.c", 178); - interfaceCtx->iconItemSegment = GameState_Alloc(&globalCtx->state, 0x4000, "../z_construct.c", 190); + interfaceCtx->iconItemSegment = GameState_Alloc( + &globalCtx->state, 0x1000 * ARRAY_COUNT(gSaveContext.equips.buttonItems), "../z_construct.c", 190); // "Icon Item Texture Initialization = %x" osSyncPrintf("アイコンアイテム テクスチャ初期=%x\n", 0x4000); @@ -85,32 +87,18 @@ void func_801109B0(GlobalContext* globalCtx) { gSaveContext.equips.buttonItems[1], gSaveContext.equips.buttonItems[2], gSaveContext.equips.buttonItems[3]); - if (gSaveContext.equips.buttonItems[0] < 0xF0) { - 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->iconItemSegment, - _icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[0] * 0x1000, 0x1000, - "../z_construct.c", 203); - } - - if (gSaveContext.equips.buttonItems[1] < 0xF0) { - 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(interfaceCtx->iconItemSegment + 0x2000, - _icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[2] * 0x1000, 0x1000, - "../z_construct.c", 214); - } - - if (gSaveContext.equips.buttonItems[3] < 0xF0) { - DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x3000, - _icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[3] * 0x1000, 0x1000, - "../z_construct.c", 219); + for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.equips.buttonItems); buttonIndex++) { + if (gSaveContext.equips.buttonItems[buttonIndex] < 0xF0) { + DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x1000 * buttonIndex, + _icon_item_staticSegmentRomStart + + gSaveContext.equips.buttonItems[buttonIndex] * 0x1000, + 0x1000, "../z_construct.c", 198); + } else if (buttonIndex == 0 && gSaveContext.equips.buttonItems[buttonIndex] != 0xFF) { + DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x1000 * buttonIndex, + _icon_item_staticSegmentRomStart + + gSaveContext.equips.buttonItems[buttonIndex] * 0x1000, + 0x1000, "../z_construct.c", 203); + } } osSyncPrintf("EVENT=%d\n", ((void)0, gSaveContext.timer1State)); diff --git a/soh/src/code/z_game_over.c b/soh/src/code/z_game_over.c index 3605c5bd6..ff488aae4 100644 --- a/soh/src/code/z_game_over.c +++ b/soh/src/code/z_game_over.c @@ -68,8 +68,9 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.eventInf[1] = 0; gSaveContext.eventInf[2] = 0; gSaveContext.eventInf[3] = 0; - gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = - gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; + for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) { + gSaveContext.buttonStatus[buttonIndex] = BTN_ENABLED; + } gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = 0; Environment_InitGameOverLights(globalCtx); diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index f53e35b7c..4bc07fb75 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -15,6 +15,10 @@ #define DO_ACTION_TEX_HEIGHT 16 #define DO_ACTION_TEX_SIZE ((DO_ACTION_TEX_WIDTH * DO_ACTION_TEX_HEIGHT) / 2) // (sizeof(gCheckDoActionENGTex)) +// The button statuses include the A button when most things are only the equip item buttons +// So, when indexing into it with a item button index, we need to adjust +#define BUTTON_STATUS_INDEX(button) ((button) >= 4) ? ((button) + 1) : (button) + s16 Top_HUD_Margin = 0; s16 Left_HUD_Margin = 0; s16 Right_HUD_Margin = 0; @@ -257,6 +261,46 @@ void func_80082644(GlobalContext* globalCtx, s16 alpha) { interfaceCtx->aAlpha = alpha; } } + + if (gSaveContext.buttonStatus[5] == BTN_DISABLED) { + if (interfaceCtx->dpadUpAlpha != 70) { + interfaceCtx->dpadUpAlpha = 70; + } + } else { + if (interfaceCtx->dpadUpAlpha != 255) { + interfaceCtx->dpadUpAlpha = alpha; + } + } + + if (gSaveContext.buttonStatus[6] == BTN_DISABLED) { + if (interfaceCtx->dpadDownAlpha != 70) { + interfaceCtx->dpadDownAlpha = 70; + } + } else { + if (interfaceCtx->dpadDownAlpha != 255) { + interfaceCtx->dpadDownAlpha = alpha; + } + } + + if (gSaveContext.buttonStatus[7] == BTN_DISABLED) { + if (interfaceCtx->dpadLeftAlpha != 70) { + interfaceCtx->dpadLeftAlpha = 70; + } + } else { + if (interfaceCtx->dpadLeftAlpha != 255) { + interfaceCtx->dpadLeftAlpha = alpha; + } + } + + if (gSaveContext.buttonStatus[8] == BTN_DISABLED) { + if (interfaceCtx->dpadRightAlpha != 70) { + interfaceCtx->dpadRightAlpha = 70; + } + } else { + if (interfaceCtx->dpadRightAlpha != 255) { + interfaceCtx->dpadRightAlpha = alpha; + } + } } void func_8008277C(GlobalContext* globalCtx, s16 maxAlpha, s16 alpha) { @@ -286,6 +330,22 @@ void func_8008277C(GlobalContext* globalCtx, s16 maxAlpha, s16 alpha) { if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > maxAlpha)) { interfaceCtx->cRightAlpha = maxAlpha; } + + if ((interfaceCtx->dpadUpAlpha != 0) && (interfaceCtx->dpadUpAlpha > maxAlpha)) { + interfaceCtx->dpadUpAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadDownAlpha != 0) && (interfaceCtx->dpadDownAlpha > maxAlpha)) { + interfaceCtx->dpadDownAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadLeftAlpha != 0) && (interfaceCtx->dpadLeftAlpha > maxAlpha)) { + interfaceCtx->dpadLeftAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadRightAlpha != 0) && (interfaceCtx->dpadRightAlpha > maxAlpha)) { + interfaceCtx->dpadRightAlpha = maxAlpha; + } } void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { @@ -324,6 +384,22 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->cRightAlpha = maxAlpha; } + if ((interfaceCtx->dpadUpAlpha != 0) && (interfaceCtx->dpadUpAlpha > maxAlpha)) { + interfaceCtx->dpadUpAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadDownAlpha != 0) && (interfaceCtx->dpadDownAlpha > maxAlpha)) { + interfaceCtx->dpadDownAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadLeftAlpha != 0) && (interfaceCtx->dpadLeftAlpha > maxAlpha)) { + interfaceCtx->dpadLeftAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadRightAlpha != 0) && (interfaceCtx->dpadRightAlpha > maxAlpha)) { + interfaceCtx->dpadRightAlpha = maxAlpha; + } + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > maxAlpha)) { interfaceCtx->healthAlpha = maxAlpha; } @@ -380,6 +456,22 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->cRightAlpha = maxAlpha; } + if ((interfaceCtx->dpadUpAlpha != 0) && (interfaceCtx->dpadUpAlpha > maxAlpha)) { + interfaceCtx->dpadUpAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadDownAlpha != 0) && (interfaceCtx->dpadDownAlpha > maxAlpha)) { + interfaceCtx->dpadDownAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadLeftAlpha != 0) && (interfaceCtx->dpadLeftAlpha > maxAlpha)) { + interfaceCtx->dpadLeftAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadRightAlpha != 0) && (interfaceCtx->dpadRightAlpha > maxAlpha)) { + interfaceCtx->dpadRightAlpha = maxAlpha; + } + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > maxAlpha)) { interfaceCtx->healthAlpha = maxAlpha; } @@ -503,6 +595,22 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->cRightAlpha = maxAlpha; } + if ((interfaceCtx->dpadUpAlpha != 0) && (interfaceCtx->dpadUpAlpha > maxAlpha)) { + interfaceCtx->dpadUpAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadDownAlpha != 0) && (interfaceCtx->dpadDownAlpha > maxAlpha)) { + interfaceCtx->dpadDownAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadLeftAlpha != 0) && (interfaceCtx->dpadLeftAlpha > maxAlpha)) { + interfaceCtx->dpadLeftAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadRightAlpha != 0) && (interfaceCtx->dpadRightAlpha > maxAlpha)) { + interfaceCtx->dpadRightAlpha = maxAlpha; + } + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > maxAlpha)) { interfaceCtx->minimapAlpha = maxAlpha; } @@ -533,6 +641,22 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->cRightAlpha = maxAlpha; } + if ((interfaceCtx->dpadUpAlpha != 0) && (interfaceCtx->dpadUpAlpha > maxAlpha)) { + interfaceCtx->dpadUpAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadDownAlpha != 0) && (interfaceCtx->dpadDownAlpha > maxAlpha)) { + interfaceCtx->dpadDownAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadLeftAlpha != 0) && (interfaceCtx->dpadLeftAlpha > maxAlpha)) { + interfaceCtx->dpadLeftAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadRightAlpha != 0) && (interfaceCtx->dpadRightAlpha > maxAlpha)) { + interfaceCtx->dpadRightAlpha = maxAlpha; + } + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > maxAlpha)) { interfaceCtx->healthAlpha = maxAlpha; } @@ -571,6 +695,22 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->cRightAlpha = maxAlpha; } + if ((interfaceCtx->dpadUpAlpha != 0) && (interfaceCtx->dpadUpAlpha > maxAlpha)) { + interfaceCtx->dpadUpAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadDownAlpha != 0) && (interfaceCtx->dpadDownAlpha > maxAlpha)) { + interfaceCtx->dpadDownAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadLeftAlpha != 0) && (interfaceCtx->dpadLeftAlpha > maxAlpha)) { + interfaceCtx->dpadLeftAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadRightAlpha != 0) && (interfaceCtx->dpadRightAlpha > maxAlpha)) { + interfaceCtx->dpadRightAlpha = maxAlpha; + } + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > maxAlpha)) { interfaceCtx->minimapAlpha = maxAlpha; } @@ -609,6 +749,22 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->cRightAlpha = maxAlpha; } + if ((interfaceCtx->dpadUpAlpha != 0) && (interfaceCtx->dpadUpAlpha > maxAlpha)) { + interfaceCtx->dpadUpAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadDownAlpha != 0) && (interfaceCtx->dpadDownAlpha > maxAlpha)) { + interfaceCtx->dpadDownAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadLeftAlpha != 0) && (interfaceCtx->dpadLeftAlpha > maxAlpha)) { + interfaceCtx->dpadLeftAlpha = maxAlpha; + } + + if ((interfaceCtx->dpadRightAlpha != 0) && (interfaceCtx->dpadRightAlpha > maxAlpha)) { + interfaceCtx->dpadRightAlpha = maxAlpha; + } + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > maxAlpha)) { interfaceCtx->magicAlpha = maxAlpha; } @@ -664,6 +820,8 @@ void func_80083108(GlobalContext* globalCtx) { if (gSaveContext.buttonStatus[0] == BTN_DISABLED) { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_ENABLED; } if ((gSaveContext.equips.buttonItems[0] != ITEM_SLINGSHOT) && @@ -694,6 +852,8 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_DISABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_DISABLED; Interface_ChangeAlpha(6); } @@ -739,6 +899,8 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_DISABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_DISABLED; Interface_ChangeAlpha(50); } else { if (gSaveContext.buttonStatus[0] == BTN_ENABLED) { @@ -747,6 +909,8 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_DISABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_DISABLED; Interface_ChangeAlpha(50); } } else if (msgCtx->msgMode == MSGMODE_NONE) { @@ -757,36 +921,36 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.buttonStatus[0] = BTN_DISABLED; - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] >= ITEM_SHIELD_DEKU) && (gSaveContext.equips.buttonItems[i] <= ITEM_BOOTS_HOVER)) { // Equipment on c-buttons is always enabled - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } else if (func_8008F2F8(globalCtx) == 2) { if ((gSaveContext.equips.buttonItems[i] != ITEM_HOOKSHOT) && (gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT)) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } else { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } else { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } } @@ -801,6 +965,10 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.buttonStatus[1] = BTN_DISABLED; gSaveContext.buttonStatus[2] = BTN_DISABLED; gSaveContext.buttonStatus[3] = BTN_DISABLED; + gSaveContext.buttonStatus[5] = BTN_DISABLED; + gSaveContext.buttonStatus[6] = BTN_DISABLED; + gSaveContext.buttonStatus[7] = BTN_DISABLED; + gSaveContext.buttonStatus[8] = BTN_DISABLED; gSaveContext.unk_13EA = 0; Interface_ChangeAlpha(50); } @@ -838,20 +1006,20 @@ void func_80083108(GlobalContext* globalCtx) { sp28 = 0; } - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] != ITEM_OCARINA_FAIRY) && (gSaveContext.equips.buttonItems[i] != ITEM_OCARINA_TIME)) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } else { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } @@ -907,154 +1075,154 @@ void func_80083108(GlobalContext* globalCtx) { } if (interfaceCtx->restrictions.bottles != 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } } } else if (interfaceCtx->restrictions.bottles == 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } } if (interfaceCtx->restrictions.tradeItems != 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((CVar_GetS32("gMMBunnyHood", 0) != 0) && (gSaveContext.equips.buttonItems[i] >= ITEM_MASK_KEATON) && (gSaveContext.equips.buttonItems[i] <= ITEM_MASK_TRUTH)) { - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } else if ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK)) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } } } else if (interfaceCtx->restrictions.tradeItems == 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK)) { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } } if (interfaceCtx->restrictions.hookshot != 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] == ITEM_HOOKSHOT) || (gSaveContext.equips.buttonItems[i] == ITEM_LONGSHOT)) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } } } else if (interfaceCtx->restrictions.hookshot == 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] == ITEM_HOOKSHOT) || (gSaveContext.equips.buttonItems[i] == ITEM_LONGSHOT)) { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } } if (interfaceCtx->restrictions.ocarina != 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_FAIRY) || (gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_TIME)) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } } } else if (interfaceCtx->restrictions.ocarina == 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_FAIRY) || (gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_TIME)) { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } } if (interfaceCtx->restrictions.farores != 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_FARORES_WIND) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; osSyncPrintf("***(i=%d)*** ", i); } } } else if (interfaceCtx->restrictions.farores == 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_FARORES_WIND) { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } } if (interfaceCtx->restrictions.dinsNayrus != 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] == ITEM_DINS_FIRE) || (gSaveContext.equips.buttonItems[i] == ITEM_NAYRUS_LOVE)) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } } } else if (interfaceCtx->restrictions.dinsNayrus == 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] == ITEM_DINS_FIRE) || (gSaveContext.equips.buttonItems[i] == ITEM_NAYRUS_LOVE)) { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } } if (interfaceCtx->restrictions.all != 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] != ITEM_OCARINA_FAIRY) && (gSaveContext.equips.buttonItems[i] != ITEM_OCARINA_TIME) && !((gSaveContext.equips.buttonItems[i] >= ITEM_BOTTLE) && @@ -1063,22 +1231,22 @@ void func_80083108(GlobalContext* globalCtx) { (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK))) { if ((globalCtx->sceneNum != SCENE_TAKARAYA) || (gSaveContext.equips.buttonItems[i] != ITEM_LENS)) { - if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_DISABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_DISABLED; } else { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } } } else if (interfaceCtx->restrictions.all == 0) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if ((gSaveContext.equips.buttonItems[i] != ITEM_DINS_FIRE) && (gSaveContext.equips.buttonItems[i] != ITEM_HOOKSHOT) && (gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT) && @@ -1090,11 +1258,11 @@ void func_80083108(GlobalContext* globalCtx) { (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) && !((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK))) { - if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_DISABLED) { sp28 = 1; } - gSaveContext.buttonStatus[i] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; } } } @@ -1196,7 +1364,7 @@ void Inventory_SwapAgeEquipment(void) { u16 temp; if (LINK_AGE_IN_YEARS == YEARS_CHILD) { - for (i = 0; i < 4; i++) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (i != 0) { gSaveContext.childEquips.buttonItems[i] = gSaveContext.equips.buttonItems[i]; } else { @@ -1225,8 +1393,18 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.cButtonSlots[1] = SLOT_BOMB; gSaveContext.equips.cButtonSlots[2] = SLOT_OCARINA; gSaveContext.equips.equipment = 0x1122; + + // Set the dpad to nothing + gSaveContext.equips.buttonItems[4] = ITEM_NONE; + gSaveContext.equips.buttonItems[5] = ITEM_NONE; + gSaveContext.equips.buttonItems[6] = ITEM_NONE; + gSaveContext.equips.buttonItems[7] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[3] = SLOT_NONE; + gSaveContext.equips.cButtonSlots[4] = SLOT_NONE; + gSaveContext.equips.cButtonSlots[5] = SLOT_NONE; + gSaveContext.equips.cButtonSlots[6] = SLOT_NONE; } else { - for (i = 0; i < 4; i++) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { gSaveContext.equips.buttonItems[i] = gSaveContext.adultEquips.buttonItems[i]; if (i != 0) { @@ -1246,7 +1424,7 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.equipment = gSaveContext.adultEquips.equipment; } } else { - for (i = 0; i < 4; i++) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { gSaveContext.adultEquips.buttonItems[i] = gSaveContext.equips.buttonItems[i]; if (i != 0) { @@ -1257,7 +1435,7 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.adultEquips.equipment = gSaveContext.equips.equipment; if (gSaveContext.childEquips.buttonItems[0] != ITEM_NONE) { - for (i = 0; i < 4; i++) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { gSaveContext.equips.buttonItems[i] = gSaveContext.childEquips.buttonItems[i]; if (i != 0) { @@ -1353,10 +1531,14 @@ void func_80084BF4(GlobalContext* globalCtx, u16 flag) { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_ENABLED; Interface_ChangeAlpha(7); } else { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_ENABLED; func_80083108(globalCtx); } } @@ -1565,7 +1747,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { return ITEM_NONE; } else if (item == ITEM_LONGSHOT) { INV_CONTENT(item) = item; - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_HOOKSHOT) { gSaveContext.equips.buttonItems[i] = ITEM_LONGSHOT; Interface_LoadItemIcon1(globalCtx, i); @@ -1699,7 +1881,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { return ITEM_NONE; } else if (item == ITEM_OCARINA_TIME) { INV_CONTENT(ITEM_OCARINA_TIME) = ITEM_OCARINA_TIME; - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_FAIRY) { gSaveContext.equips.buttonItems[i] = ITEM_OCARINA_TIME; Interface_LoadItemIcon1(globalCtx, i); @@ -1781,18 +1963,13 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { gSaveContext.equips.cButtonSlots[0], gSaveContext.equips.cButtonSlots[1], gSaveContext.equips.cButtonSlots[2], temp + i, item); - if ((temp + i) == gSaveContext.equips.cButtonSlots[0]) { - gSaveContext.equips.buttonItems[1] = item; - Interface_LoadItemIcon2(globalCtx, 1); - gSaveContext.buttonStatus[1] = BTN_ENABLED; - } else if ((temp + i) == gSaveContext.equips.cButtonSlots[1]) { - gSaveContext.equips.buttonItems[2] = item; - Interface_LoadItemIcon2(globalCtx, 2); - gSaveContext.buttonStatus[2] = BTN_ENABLED; - } else if ((temp + i) == gSaveContext.equips.cButtonSlots[2]) { - gSaveContext.equips.buttonItems[3] = item; - Interface_LoadItemIcon1(globalCtx, 3); - gSaveContext.buttonStatus[3] = BTN_ENABLED; + for (int buttonIndex = 1; buttonIndex < ARRAY_COUNT(gSaveContext.equips.buttonItems); buttonIndex++) { + if ((temp + i) == gSaveContext.equips.cButtonSlots[buttonIndex - 1]) { + gSaveContext.equips.buttonItems[buttonIndex] = item; + Interface_LoadItemIcon2(globalCtx, buttonIndex); + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(buttonIndex)] = BTN_ENABLED; + break; + } } gSaveContext.inventory.items[temp + i] = item; @@ -1816,7 +1993,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { INV_CONTENT(item) = item; if (temp != ITEM_NONE) { - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (temp == gSaveContext.equips.buttonItems[i]) { if (item != ITEM_SOLD_OUT) { gSaveContext.equips.buttonItems[i] = item; @@ -1978,7 +2155,7 @@ void Inventory_DeleteItem(u16 item, u16 invSlot) { osSyncPrintf("\nItem_Register(%d)\n", invSlot, gSaveContext.inventory.items[invSlot]); - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == item) { gSaveContext.equips.buttonItems[i] = ITEM_NONE; gSaveContext.equips.cButtonSlots[i - 1] = SLOT_NONE; @@ -1993,7 +2170,7 @@ s32 Inventory_ReplaceItem(GlobalContext* globalCtx, u16 oldItem, u16 newItem) { if (gSaveContext.inventory.items[i] == oldItem) { gSaveContext.inventory.items[i] = newItem; osSyncPrintf("アイテム消去(%d)\n", i); // "Item Purge (%d)" - for (i = 1; i < 4; i++) { + for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == oldItem) { gSaveContext.equips.buttonItems[i] = newItem; Interface_LoadItemIcon1(globalCtx, i); @@ -2056,7 +2233,7 @@ void Inventory_UpdateBottleItem(GlobalContext* globalCtx, u8 item, u8 button) { Interface_LoadItemIcon1(globalCtx, button); globalCtx->pauseCtx.cursorItem[PAUSE_ITEM] = item; - gSaveContext.buttonStatus[button] = BTN_ENABLED; + gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(button)] = BTN_ENABLED; } s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { @@ -2066,7 +2243,7 @@ s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { for (i = 0; i < 4; i++) { if (gSaveContext.inventory.items[bottleSlot + i] == ITEM_FAIRY) { - for (j = 1; j < 4; j++) { + for (j = 1; j < ARRAY_COUNT(gSaveContext.equips.buttonItems); j++) { if (gSaveContext.equips.buttonItems[j] == ITEM_FAIRY) { gSaveContext.equips.buttonItems[j] = ITEM_BOTTLE; Interface_LoadItemIcon1(globalCtx, j); @@ -2577,10 +2754,15 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx)) { + bool hasLens = false; + for (int buttonIndex = 1; buttonIndex < (CVar_GetS32("gDpadEquips", 0) != 0) ? ARRAY_COUNT(gSaveContext.equips.buttonItems) : 4; buttonIndex++) { + if (gSaveContext.equips.buttonItems[buttonIndex] == ITEM_LENS) { + hasLens = true; + break; + } + } if ((gSaveContext.magic == 0) || ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) || - ((gSaveContext.equips.buttonItems[1] != ITEM_LENS) && - (gSaveContext.equips.buttonItems[2] != ITEM_LENS) && - (gSaveContext.equips.buttonItems[3] != ITEM_LENS)) || + !hasLens || (globalCtx->actorCtx.unk_03 == 0)) { globalCtx->actorCtx.unk_03 = 0; Audio_PlaySoundGeneral(NA_SE_SY_GLASSMODE_OFF, &D_801333D4, 4, &D_801333E0, &D_801333E0, @@ -3011,10 +3193,20 @@ void Interface_DrawItemIconTexture(GlobalContext* globalCtx, void* texture, s16 gDPLoadTextureBlock(OVERLAY_DISP++, texture, 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); - gSPWideTextureRectangle(OVERLAY_DISP++, OTRGetRectDimensionFromRightEdge(R_ITEM_ICON_X(button)+Right_HUD_Margin) << 2, R_ITEM_ICON_Y(button)+(Top_HUD_Margin*-1) << 2, - (OTRGetRectDimensionFromRightEdge(R_ITEM_ICON_X(button)+Right_HUD_Margin) + R_ITEM_ICON_WIDTH(button)) << 2, - (R_ITEM_ICON_Y(button)+(Top_HUD_Margin*-1) + R_ITEM_ICON_WIDTH(button)) << 2, G_TX_RENDERTILE, 0, 0, - R_ITEM_ICON_DD(button) << 1, R_ITEM_ICON_DD(button) << 1); + // These are moved from registers since there was not room for the dpad data. They are static anyways. + static int16_t sItemIconX[] = { B_BUTTON_X, C_LEFT_BUTTON_X, C_DOWN_BUTTON_X, C_RIGHT_BUTTON_X, + DPAD_UP_X, DPAD_DOWN_X, DPAD_LEFT_X, DPAD_RIGHT_X }; + static int16_t sItemIconY[] = { B_BUTTON_Y, C_LEFT_BUTTON_Y, C_DOWN_BUTTON_Y, C_RIGHT_BUTTON_Y, + DPAD_UP_Y, DPAD_DOWN_Y, DPAD_LEFT_Y, DPAD_RIGHT_Y }; + static int16_t sItemIconWidth[] = { 30, 24, 24, 24, 16, 16, 16, 16 }; + static int16_t sItemIconDD[] = { 550, 680, 680, 680, 1024, 1024, 1024, 1024 }; + + gSPWideTextureRectangle( + OVERLAY_DISP++, OTRGetRectDimensionFromRightEdge(sItemIconX[button] + Right_HUD_Margin) << 2, + sItemIconY[button] + (Top_HUD_Margin * -1) << 2, + (OTRGetRectDimensionFromRightEdge(sItemIconX[button] + Right_HUD_Margin) + sItemIconWidth[button]) << 2, + (sItemIconY[button] + (Top_HUD_Margin * -1) + sItemIconWidth[button]) << 2, G_TX_RENDERTILE, 0, 0, + sItemIconDD[button] << 1, sItemIconDD[button] << 1); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3094); } @@ -3030,6 +3222,11 @@ void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { s16 i; s16 ammo; + static int16_t sItemAmmoX[] = { B_BUTTON_X + 2, C_LEFT_BUTTON_X + 1, C_DOWN_BUTTON_X + 1, C_RIGHT_BUTTON_X + 1, + DPAD_UP_X, DPAD_DOWN_X, DPAD_LEFT_X, DPAD_RIGHT_X }; + static int16_t sItemAmmoY[] = { B_BUTTON_Y + 18, C_LEFT_BUTTON_Y + 17, C_DOWN_BUTTON_Y + 17, C_RIGHT_BUTTON_Y + 17, + DPAD_UP_Y + 11, DPAD_DOWN_Y + 11, DPAD_LEFT_Y + 11, DPAD_RIGHT_Y + 11 }; + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3105); i = gSaveContext.equips.buttonItems[button]; @@ -3074,11 +3271,13 @@ void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { if (i != 0) { OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, (u8*)_gAmmoDigit0Tex[i], 8, 8, - OTRGetRectDimensionFromRightEdge(R_ITEM_AMMO_X(button)+Right_HUD_Margin), R_ITEM_AMMO_Y(button)+(Top_HUD_Margin*-1), 8, 8, 1 << 10, 1 << 10); + OTRGetRectDimensionFromRightEdge(sItemAmmoX[button] + Right_HUD_Margin), + sItemAmmoY[button] + (Top_HUD_Margin * -1), 8, 8, 1 << 10, 1 << 10); } OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, (u8*)_gAmmoDigit0Tex[ammo], 8, 8, - OTRGetRectDimensionFromRightEdge(R_ITEM_AMMO_X(button)+Right_HUD_Margin) + 6, R_ITEM_AMMO_Y(button)+(Top_HUD_Margin*-1), 8, 8, 1 << 10, 1 << 10); + OTRGetRectDimensionFromRightEdge(sItemAmmoX[button] + Right_HUD_Margin) + 6, + sItemAmmoY[button] + (Top_HUD_Margin * -1), 8, 8, 1 << 10, 1 << 10); } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3158); @@ -3513,6 +3712,67 @@ void Interface_Draw(GlobalContext* globalCtx) { Interface_DrawAmmoCount(globalCtx, 3, interfaceCtx->cRightAlpha); } + if (CVar_GetS32("gDpadEquips", 0) != 0) { + // DPad is only greyed-out when all 4 DPad directions are too + uint16_t dpadAlpha = + MAX(MAX(MAX(interfaceCtx->dpadUpAlpha, interfaceCtx->dpadDownAlpha), interfaceCtx->dpadLeftAlpha), + interfaceCtx->dpadRightAlpha); + + // Draw DPad + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, dpadAlpha); + gDPLoadTextureBlock(OVERLAY_DISP++, ResourceMgr_LoadFileRaw("assets/ship_of_harkinian/buttons/dpad.bin"), + G_IM_FMT_IA, G_IM_SIZ_16b, 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); + gSPWideTextureRectangle(OVERLAY_DISP++, OTRGetRectDimensionFromRightEdge(DPAD_X) << 2, DPAD_Y << 2, + (OTRGetRectDimensionFromRightEdge(DPAD_X) + 32) << 2, (DPAD_Y + 32) << 2, + G_TX_RENDERTILE, 0, 0, (1 << 10), (1 << 10)); + + // DPad-Up Button Icon & Ammo Count + if (gSaveContext.equips.buttonItems[4] < 0xF0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->dpadUpAlpha); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); + Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[4]], 4); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + Interface_DrawAmmoCount(globalCtx, 4, interfaceCtx->dpadUpAlpha); + } + + // DPad-Down Button Icon & Ammo Count + if (gSaveContext.equips.buttonItems[5] < 0xF0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->dpadDownAlpha); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); + Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[5]], 5); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + Interface_DrawAmmoCount(globalCtx, 5, interfaceCtx->dpadDownAlpha); + } + + // DPad-Left Button Icon & Ammo Count + if (gSaveContext.equips.buttonItems[6] < 0xF0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->dpadLeftAlpha); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); + Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[6]], 6); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + Interface_DrawAmmoCount(globalCtx, 6, interfaceCtx->dpadLeftAlpha); + } + + // DPad-Right Button Icon & Ammo Count + if (gSaveContext.equips.buttonItems[7] < 0xF0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->dpadRightAlpha); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); + Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[7]], 7); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + Interface_DrawAmmoCount(globalCtx, 7, interfaceCtx->dpadRightAlpha); + } + } + // A Button func_80094A14(globalCtx->state.gfxCtx); const f32 rABtnX = OTRGetDimensionFromRightEdge(R_A_BTN_X+Right_HUD_Margin); @@ -3690,7 +3950,7 @@ void Interface_Draw(GlobalContext* globalCtx) { globalCtx->nextEntranceIndex = spoilingItemEntrances[svar1]; INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; - for (svar2 = 1; svar2 < 4; svar2++) { + for (svar2 = 1; svar2 < ARRAY_COUNT(gSaveContext.equips.buttonItems); svar2++) { if (gSaveContext.equips.buttonItems[svar2] == gSpoilingItems[svar1]) { gSaveContext.equips.buttonItems[svar2] = gSpoilingItemReverts[svar1]; Interface_LoadItemIcon1(globalCtx, svar2); diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 597a33dd9..fed4ae3d5 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -147,7 +147,7 @@ void Sram_OpenSave() { INV_CONTENT(ITEM_LETTER_ZELDA) = ITEM_CHICKEN; - for (j = 1; j < 4; j++) { + for (j = 1; j < ARRAY_COUNT(gSaveContext.equips.buttonItems); j++) { if (gSaveContext.equips.buttonItems[j] == ITEM_LETTER_ZELDA) { gSaveContext.equips.buttonItems[j] = ITEM_CHICKEN; } @@ -166,7 +166,7 @@ void Sram_OpenSave() { if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[i]) { INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i]; - for (j = 1; j < 4; j++) { + for (j = 1; j < ARRAY_COUNT(gSaveContext.equips.buttonItems); j++) { if (gSaveContext.equips.buttonItems[j] == gSpoilingItems[i]) { gSaveContext.equips.buttonItems[j] = gSpoilingItemReverts[i]; } diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index e66d234df..4c147ec27 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -1057,7 +1057,7 @@ static LinkAnimationHeader* D_80854378[] = { static u8 D_80854380[2] = { 0x18, 0x19 }; static u8 D_80854384[2] = { 0x1A, 0x1B }; -static u16 D_80854388[] = { BTN_B, BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; +static u16 D_80854388[] = { BTN_B, BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT, BTN_DUP, BTN_DDOWN, BTN_DLEFT, BTN_DRIGHT }; static u8 sMagicSpellCosts[] = { 12, 24, 24, 12, 24, 12 }; @@ -1862,7 +1862,7 @@ s32 func_80833C98(s32 item1, s32 actionParam) { } s32 func_80833CDC(GlobalContext* globalCtx, s32 index) { - if (index >= 4) { + if (index >= ((CVar_GetS32("gDpadEquips", 0) != 0) ? 8 : 4)) { return ITEM_NONE; } else if (globalCtx->bombchuBowlingStatus != 0) { @@ -1877,9 +1877,18 @@ s32 func_80833CDC(GlobalContext* globalCtx, s32 index) { else if (index == 2) { return C_BTN_ITEM(1); } - else { + else if (index == 3) { return C_BTN_ITEM(2); } + else if (index == 4) { + return DPAD_ITEM(0); + } else if (index == 5) { + return DPAD_ITEM(1); + } else if (index == 6) { + return DPAD_ITEM(2); + } else if (index == 7) { + return DPAD_ITEM(3); + } } void func_80833DF8(Player* this, GlobalContext* globalCtx) { @@ -1890,16 +1899,29 @@ void func_80833DF8(Player* this, GlobalContext* globalCtx) { if (this->currentMask != PLAYER_MASK_NONE) { if (CVar_GetS32("gMMBunnyHood", 0) != 0) { s32 maskItem = this->currentMask - PLAYER_MASK_KEATON + ITEM_MASK_KEATON; + bool hasOnDpad = false; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + for (int buttonIndex = 4; buttonIndex < 8; buttonIndex++) { + hasOnDpad |= gSaveContext.equips.buttonItems[buttonIndex] == maskItem; + } + } if (gSaveContext.equips.buttonItems[0] != maskItem && gSaveContext.equips.buttonItems[1] != maskItem && - gSaveContext.equips.buttonItems[2] != maskItem && gSaveContext.equips.buttonItems[3] != maskItem) { + gSaveContext.equips.buttonItems[2] != maskItem && gSaveContext.equips.buttonItems[3] != maskItem && + !hasOnDpad) { this->currentMask = PLAYER_MASK_NONE; func_808328EC(this, NA_SE_PL_CHANGE_ARMS); } } else { maskActionParam = this->currentMask - 1 + PLAYER_AP_MASK_KEATON; + bool hasOnDpad = false; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + for (int buttonIndex = 0; buttonIndex < 4; buttonIndex++) { + hasOnDpad |= func_80833C98(DPAD_ITEM(buttonIndex), maskActionParam); + } + } if (!func_80833C98(C_BTN_ITEM(0), maskActionParam) && !func_80833C98(C_BTN_ITEM(1), maskActionParam) && - !func_80833C98(C_BTN_ITEM(2), maskActionParam)) { + !func_80833C98(C_BTN_ITEM(2), maskActionParam) && hasOnDpad) { this->currentMask = PLAYER_MASK_NONE; } } @@ -1907,8 +1929,14 @@ void func_80833DF8(Player* this, GlobalContext* globalCtx) { if (!(this->stateFlags1 & (PLAYER_STATE1_11 | PLAYER_STATE1_29)) && !func_8008F128(this)) { if (this->itemActionParam >= PLAYER_AP_FISHING_POLE) { + bool hasOnDpad = false; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + for (int buttonIndex = 0; buttonIndex < 4; buttonIndex++) { + hasOnDpad |= func_80833C50(this, DPAD_ITEM(buttonIndex)); + } + } if (!func_80833C50(this, B_BTN_ITEM) && !func_80833C50(this, C_BTN_ITEM(0)) && - !func_80833C50(this, C_BTN_ITEM(1)) && !func_80833C50(this, C_BTN_ITEM(2))) { + !func_80833C50(this, C_BTN_ITEM(1)) && !func_80833C50(this, C_BTN_ITEM(2)) && !hasOnDpad) { func_80835F44(globalCtx, this, ITEM_NONE); return; } @@ -2296,9 +2324,12 @@ s32 func_80834E44(GlobalContext* globalCtx) { } s32 func_80834E7C(GlobalContext* globalCtx) { + u16 buttonsToCheck = BTN_A | BTN_B | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; + } return (globalCtx->shootingGalleryStatus != 0) && - ((globalCtx->shootingGalleryStatus < 0) || - CHECK_BTN_ANY(sControlInput->cur.button, BTN_A | BTN_B | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)); + ((globalCtx->shootingGalleryStatus < 0) || CHECK_BTN_ANY(sControlInput->cur.button, buttonsToCheck)); } s32 func_80834EB8(Player* this, GlobalContext* globalCtx) { @@ -6292,8 +6323,12 @@ s32 func_8083EAF0(Player* this, Actor* actor) { } s32 func_8083EB44(Player* this, GlobalContext* globalCtx) { + u16 buttonsToCheck = BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; + } if ((this->stateFlags1 & PLAYER_STATE1_11) && (this->heldActor != NULL) && - CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + CHECK_BTN_ANY(sControlInput->press.button, buttonsToCheck)) { if (!func_80835644(globalCtx, this, this->heldActor)) { if (!func_8083EAF0(this, this->heldActor)) { func_80835C58(globalCtx, this, func_808464B0, 1); @@ -8362,8 +8397,12 @@ void func_8084411C(Player* this, GlobalContext* globalCtx) { if (this->stateFlags1 & PLAYER_STATE1_11) { Actor* heldActor = this->heldActor; + u16 buttonsToCheck = BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; + } if (!func_80835644(globalCtx, this, heldActor) && (heldActor->id == ACTOR_EN_NIW) && - CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + CHECK_BTN_ANY(sControlInput->press.button, buttonsToCheck)) { func_8084409C(globalCtx, this, this->linearVelocity + 2.0f, this->actor.velocity.y + 2.0f); } } @@ -9161,6 +9200,10 @@ void func_80846260(Player* this, GlobalContext* globalCtx) { return; } + u16 buttonsToCheck = BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; + } if (this->unk_850 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 27.0f)) { Actor* interactRangeActor = this->interactRangeActor; @@ -9176,8 +9219,7 @@ void func_80846260(Player* this, GlobalContext* globalCtx) { return; } - } - else if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { + } else if (CHECK_BTN_ANY(sControlInput->press.button, buttonsToCheck)) { func_80835C58(globalCtx, this, func_80846358, 1); func_80832264(globalCtx, this, &gPlayerAnim_0032B8); } @@ -11259,13 +11301,16 @@ void func_8084B1D8(Player* this, GlobalContext* globalCtx) { func_80836670(this, globalCtx); } + u16 buttonsToCheck = BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; + } if ((this->csMode != 0) || (this->unk_6AD == 0) || (this->unk_6AD >= 4) || func_80833B54(this) || (this->unk_664 != NULL) || !func_8083AD4C(globalCtx, this) || (((this->unk_6AD == 2) && (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_R) || func_80833B2C(this) || (!func_8002DD78(this) && !func_808334B4(this)))) || ((this->unk_6AD == 1) && - CHECK_BTN_ANY(sControlInput->press.button, - BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)))) { + CHECK_BTN_ANY(sControlInput->press.button, buttonsToCheck)))) { func_8083C148(this, globalCtx); func_80078884(NA_SE_SY_CAMERA_ZOOM_UP); } diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 60e8c2a6b..ee65f3f56 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1503,8 +1503,9 @@ void FileChoose_LoadGame(GameState* thisx) { gSaveContext.nextDayTime = 0xFFFF; gSaveContext.unk_13C3 = 0; - gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = - gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; + for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) { + gSaveContext.buttonStatus[buttonIndex] = BTN_ENABLED; + } gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = gSaveContext.unk_13F4 = 0; @@ -1936,8 +1937,9 @@ void FileChoose_InitContext(GameState* thisx) { Environment_UpdateSkybox(NULL, SKYBOX_NORMAL_SKY, &this->envCtx, &this->skyboxCtx); - gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = - gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; + for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) { + gSaveContext.buttonStatus[buttonIndex] = BTN_ENABLED; + } } void FileChoose_Destroy(GameState* thisx) { diff --git a/soh/src/overlays/gamestates/ovl_select/z_select.c b/soh/src/overlays/gamestates/ovl_select/z_select.c index c4a467d63..43cb479c7 100644 --- a/soh/src/overlays/gamestates/ovl_select/z_select.c +++ b/soh/src/overlays/gamestates/ovl_select/z_select.c @@ -25,8 +25,9 @@ void Select_LoadGame(SelectContext* this, s32 entranceIndex) { gSaveContext.unk_13F4 = 0; gSaveContext.magicLevel = gSaveContext.magic; } - gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = - gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; + for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) { + gSaveContext.buttonStatus[buttonIndex] = BTN_ENABLED; + } gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = 0; Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); gSaveContext.entranceIndex = entranceIndex; diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 4b1528962..650be8b62 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -490,9 +490,13 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { KaleidoScope_SetCursorVtx(pauseCtx, cursorSlot * 4, pauseCtx->equipVtx); + u16 buttonsToCheck = BTN_A | BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; + } + if ((pauseCtx->cursorSpecialPos == 0) && (cursorItem != PAUSE_ITEM_NONE) && (pauseCtx->state == 6) && - (pauseCtx->unk_1E4 == 0) && - CHECK_BTN_ANY(input->press.button, BTN_A | BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT) && + (pauseCtx->unk_1E4 == 0) && CHECK_BTN_ANY(input->press.button, buttonsToCheck) && (pauseCtx->cursorX[PAUSE_EQUIP] != 0)) { if ((gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == 9) || diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index a317c6fc3..ed452aad3 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -50,7 +50,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, gDPPipeSync(POLY_KAL_DISP++); if (i != 0) { - gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[item] + 27) * 4], 4, 0); + gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[item] + 31) * 4], 4, 0); gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[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, @@ -59,7 +59,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, gSP1Quadrangle(POLY_KAL_DISP++, 0, 2, 3, 1, 0); } - gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[item] + 28) * 4], 4, 0); + gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[item] + 32) * 4], 4, 0); gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[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, @@ -347,7 +347,11 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { 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)) { + u16 buttonsToCheck = BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT; + if (CVar_GetS32("gDpadEquips", 0) != 0) { + buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; + } + if (CHECK_BTN_ANY(input->press.button, buttonsToCheck)) { if (((gSlotAgeReqs[cursorSlot] == 9) || (gSlotAgeReqs[cursorSlot] == ((void)0, gSaveContext.linkAge))) && (cursorItem != ITEM_SOLD_OUT) && (cursorItem != ITEM_NONE)) { @@ -384,7 +388,7 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_KAL_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); gDPSetEnvColor(POLY_KAL_DISP++, 0, 0, 0, 0); - for (i = 0, j = 24 * 4; i < 3; i++, j += 4) { + for (i = 0, j = 24 * 4; i < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); i++, j += 4) { if ((gSaveContext.equips.buttonItems[i + 1] != ITEM_NONE) && !((gSaveContext.equips.buttonItems[i + 1] >= ITEM_SHIELD_DEKU) && (gSaveContext.equips.buttonItems[i + 1] <= ITEM_BOOTS_HOVER))) { @@ -474,6 +478,16 @@ void KaleidoScope_SetupItemEquip(GlobalContext* globalCtx, u16 item, u16 slot, s pauseCtx->equipTargetCBtn = 1; } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { pauseCtx->equipTargetCBtn = 2; + } else if (CVar_GetS32("gDpadEquips", 0) != 0) { + if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) { + pauseCtx->equipTargetCBtn = 3; + } else if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) { + pauseCtx->equipTargetCBtn = 4; + } else if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { + pauseCtx->equipTargetCBtn = 5; + } else if (CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { + pauseCtx->equipTargetCBtn = 6; + } } pauseCtx->equipTargetItem = item; @@ -504,8 +518,9 @@ void KaleidoScope_SetupItemEquip(GlobalContext* globalCtx, u16 item, u16 slot, s } } -static s16 sCButtonPosX[] = { 66, 90, 114 }; -static s16 sCButtonPosY[] = { 110, 92, 110 }; +// TODO update for final positions +static s16 sCButtonPosX[] = { 66, 90, 114, 110, 110, 86, 134 }; +static s16 sCButtonPosY[] = { 110, 92, 110, 76, 44, 62, 62 }; void KaleidoScope_UpdateItemEquip(GlobalContext* globalCtx) { static s16 D_8082A488 = 0; @@ -598,223 +613,35 @@ void KaleidoScope_UpdateItemEquip(GlobalContext* globalCtx) { 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 the item is on another button already, swap the two + uint16_t targetButtonIndex = pauseCtx->equipTargetCBtn + 1; + for (uint16_t otherSlotIndex = 0; otherSlotIndex < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); + otherSlotIndex++) { + uint16_t otherButtonIndex = otherSlotIndex + 1; + if (otherSlotIndex == pauseCtx->equipTargetCBtn) { + continue; } - 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); - } + if (pauseCtx->equipTargetSlot == gSaveContext.equips.cButtonSlots[otherSlotIndex]) { + // Assign the other button to the target's current item + if (gSaveContext.equips.buttonItems[targetButtonIndex] != ITEM_NONE) { + gSaveContext.equips.buttonItems[otherButtonIndex] = + gSaveContext.equips.buttonItems[targetButtonIndex]; + gSaveContext.equips.cButtonSlots[otherSlotIndex] = + gSaveContext.equips.cButtonSlots[pauseCtx->equipTargetCBtn]; + Interface_LoadItemIcon2(globalCtx, otherButtonIndex); } 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; + gSaveContext.equips.buttonItems[otherButtonIndex] = ITEM_NONE; + gSaveContext.equips.cButtonSlots[otherSlotIndex] = SLOT_NONE; } + break; // Assume there is only one possible pre-existing equip } - - 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]); } + gSaveContext.equips.buttonItems[targetButtonIndex] = pauseCtx->equipTargetItem; + gSaveContext.equips.cButtonSlots[pauseCtx->equipTargetCBtn] = pauseCtx->equipTargetSlot; + Interface_LoadItemIcon1(globalCtx, targetButtonIndex); + pauseCtx->unk_1E4 = 0; sEquipMoveTimer = 10; WREG(90) = 320; diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index c7fa45964..be4d038ae 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -695,13 +695,13 @@ 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, }; -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 }, +static u8 D_8082AB6C[][ARRAY_COUNT(gSaveContext.buttonStatus)] = { + { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED }, + { BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_DISABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED }, + { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED }, + { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED }, + { BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_ENABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED, BTN_DISABLED }, + { BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_DISABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED, BTN_ENABLED }, }; static s16 D_8082AB8C = 0; @@ -786,7 +786,7 @@ static void* sPromptChoiceTexs[][2] = { { gPauseYesFRATex, gPauseNoFRATex }, }; -static u8 D_808321A8[5]; +static u8 sButtonStatusSave[ARRAY_COUNT(gSaveContext.buttonStatus)]; static PreRender sPlayerPreRender; static void* sPreRenderCvg; extern int fbTest; @@ -911,16 +911,19 @@ void KaleidoScope_SwitchPage(PauseContext* pauseCtx, u8 pt) { 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]; + for (int buttonIndex = 1; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) { + gSaveContext.buttonStatus[buttonIndex] = D_8082AB6C[pauseCtx->pageIndex + pt][buttonIndex]; + } if ((CVar_GetS32("gAssignableTunicsAndBoots", 0) != 0) && (D_8082ABEC[pauseCtx->mode] == PAUSE_EQUIP)) { gSaveContext.buttonStatus[1] = BTN_ENABLED; gSaveContext.buttonStatus[2] = BTN_ENABLED; gSaveContext.buttonStatus[3] = BTN_ENABLED; - gSaveContext.buttonStatus[4] = BTN_ENABLED; + // A-Button is already enabled + gSaveContext.buttonStatus[5] = BTN_ENABLED; + gSaveContext.buttonStatus[6] = BTN_ENABLED; + gSaveContext.buttonStatus[7] = BTN_ENABLED; + gSaveContext.buttonStatus[8] = BTN_ENABLED; } osSyncPrintf("kscope->kscp_pos+pt = %d\n", pauseCtx->pageIndex + pt); @@ -2586,7 +2589,8 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx 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)); + // 24 items, 7 "item selected" backgrounds, 14 ammo digits (2 each for 7 items) -- then 4 vertices for each + pauseCtx->itemVtx = Graph_Alloc(gfxCtx, (24 + 7 + 14) * 4 * 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) { @@ -2625,8 +2629,9 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx } } - for (phi_t3 = 1; phi_t3 < 4; phi_t3++, phi_t2 += 4) { - if (gSaveContext.equips.cButtonSlots[phi_t3 - 1] != ITEM_NONE) { + for (phi_t3 = 1; phi_t3 < ARRAY_COUNT(gSaveContext.equips.buttonItems); phi_t3++, phi_t2 += 4) { + if (gSaveContext.equips.cButtonSlots[phi_t3 - 1] != ITEM_NONE && + ((phi_t3 < 4) || (CVar_GetS32("gDpadEquips", 0) != 0))) { 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] = @@ -2675,7 +2680,7 @@ void KaleidoScope_InitVertices(GlobalContext* globalCtx, GraphicsContext* gfxCtx } } - for (phi_t2 = 108, phi_t3 = 0; phi_t3 < 7; phi_t3++) { + for (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] = @@ -3068,11 +3073,10 @@ void func_808265BC(GlobalContext* globalCtx) { 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]; + + for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) { + gSaveContext.buttonStatus[buttonIndex] = D_8082AB6C[pauseCtx->pageIndex][buttonIndex]; + } pauseCtx->pageIndex = D_8082ABEC[pauseCtx->mode]; @@ -3080,7 +3084,11 @@ void func_808265BC(GlobalContext* globalCtx) { gSaveContext.buttonStatus[1] = BTN_ENABLED; gSaveContext.buttonStatus[2] = BTN_ENABLED; gSaveContext.buttonStatus[3] = BTN_ENABLED; - gSaveContext.buttonStatus[4] = BTN_ENABLED; + // A-Button is already enabled + gSaveContext.buttonStatus[5] = BTN_ENABLED; + gSaveContext.buttonStatus[6] = BTN_ENABLED; + gSaveContext.buttonStatus[7] = BTN_ENABLED; + gSaveContext.buttonStatus[8] = BTN_ENABLED; } pauseCtx->unk_1E4 = 0; @@ -3246,11 +3254,9 @@ void KaleidoScope_Update(GlobalContext* 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]; + for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) { + sButtonStatusSave[buttonIndex] = gSaveContext.buttonStatus[buttonIndex]; + } pauseCtx->cursorX[PAUSE_MAP] = 0; pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->dungeonMapSlot = @@ -3649,6 +3655,8 @@ void KaleidoScope_Update(GlobalContext* globalCtx) gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_DISABLED; gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_DISABLED; gSaveContext.unk_13EA = 0; Interface_ChangeAlpha(50); pauseCtx->unk_1EC = 0; @@ -3695,6 +3703,8 @@ void KaleidoScope_Update(GlobalContext* globalCtx) gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_DISABLED; gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_DISABLED; gSaveContext.unk_13EA = 0; Interface_ChangeAlpha(50); pauseCtx->unk_1EC = 0; @@ -3744,6 +3754,8 @@ void KaleidoScope_Update(GlobalContext* globalCtx) gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_DISABLED; gSaveContext.buttonStatus[4] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_DISABLED; gSaveContext.unk_13EA = 0; Interface_ChangeAlpha(50); pauseCtx->unk_1EC = 0; @@ -3778,6 +3790,8 @@ void KaleidoScope_Update(GlobalContext* globalCtx) Interface_SetDoAction(globalCtx, DO_ACTION_NONE); gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_ENABLED; gSaveContext.unk_13EA = 0; Interface_ChangeAlpha(50); pauseCtx->unk_1EC = 2; @@ -3802,6 +3816,8 @@ void KaleidoScope_Update(GlobalContext* globalCtx) func_800F64E0(0); gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_ENABLED; gSaveContext.unk_13EA = 0; Interface_ChangeAlpha(50); } @@ -3813,6 +3829,8 @@ void KaleidoScope_Update(GlobalContext* globalCtx) Interface_SetDoAction(globalCtx, DO_ACTION_NONE); gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_ENABLED; + gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = + gSaveContext.buttonStatus[8] = BTN_ENABLED; gSaveContext.unk_13EA = 0; Interface_ChangeAlpha(50); pauseCtx->unk_1EC = 5; @@ -4202,11 +4220,10 @@ void KaleidoScope_Update(GlobalContext* globalCtx) 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]; + for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) { + gSaveContext.buttonStatus[buttonIndex] = sButtonStatusSave[buttonIndex]; + } + interfaceCtx->unk_1FA = interfaceCtx->unk_1FC = 0; osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("i=%d LAST_TIME_TYPE=%d\n", i, gSaveContext.unk_13EE);