From 75a6ba7c6b3e8efa6a31557869a411c53287461e Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 13 Apr 2022 09:08:07 +1000 Subject: [PATCH] Match another 2 functions --- include/functions.h | 4 +-- src/code/z_parameter.c | 51 ++++++++++++++++++++++++++++++++-- tools/disasm/functions.txt | 4 +-- tools/sizes/code_functions.csv | 4 +-- 4 files changed, 55 insertions(+), 8 deletions(-) diff --git a/include/functions.h b/include/functions.h index e8348f5a3..cee24d215 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1919,11 +1919,11 @@ u8 Item_CheckObtainability(u8 arg0); void Inventory_DeleteItem(s16 arg0, s16 arg1); // void Inventory_UnequipItem(void); // void Inventory_ReplaceItem(void); -// void func_80114CA0(void); +// void Inventory_UpdateDeitySwordEquip(void); s32 Inventory_HasEmptyBottle(void); s32 Inventory_HasItemInBottle(u8 itemId); // void func_80114FD0(void); -// void func_80115130(void); +// void Inventory_ConsumeFairy(void); // void Inventory_UpdateItem(void); // void func_801153C8(void); // void Interface_LoadActionLabel(void); diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 1ed1f0cba..e830bf0a3 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2071,7 +2071,32 @@ s32 Inventory_ReplaceItem(GlobalContext* globalCtx, u8 oldItem, u8 newItem) { return false; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80114CA0.s") +void Inventory_UpdateDeitySwordEquip(GlobalContext* globalCtx) { + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + u8 btn; + + if (CUR_FORM == 0) { + interfaceCtx->unk_21C = 0; + interfaceCtx->unk_21E = 0; + if ((((gSaveContext.save.playerForm > 0) && (gSaveContext.save.playerForm < 4)) ? 1 : gSaveContext.save.playerForm >> 1) == 0) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_DEITY; + } else { + if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_SWORD_DEITY) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == 0) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_NONE; + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = GET_CUR_EQUIP_VALUE(EQUIP_SWORD) + ITEM_SWORD_KOKIRI - 1; + } + } + } + } + + for (btn = 0; btn < 1; btn++) { + if ((GET_CUR_FORM_BTN_ITEM(btn) != ITEM_NONE) && (GET_CUR_FORM_BTN_ITEM(btn) != ITEM_UNK_FD)) { + Interface_LoadItemIconImpl(globalCtx, btn); + } + } +} s32 Inventory_HasEmptyBottle(void) { s32 slot; @@ -2109,7 +2134,29 @@ void Inventory_UpdateBottleItem(GlobalContext* globalCtx, u8 item, u8 btn) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115130.s") +s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { + u8 bottleSlot = SLOT(ITEM_FAIRY); + u8 btn; + u8 i; + + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_FAIRY) { + for (btn = 1; btn < 4; btn++) { + if (GET_CUR_FORM_BTN_ITEM(btn) == ITEM_FAIRY) { + SET_CUR_FORM_BTN_ITEM(btn, ITEM_BOTTLE); + Interface_LoadItemIconImpl(globalCtx, btn); + bottleSlot = GET_CUR_FORM_BTN_SLOT(btn); + i = 0; + break; + } + } + gSaveContext.save.inventory.items[bottleSlot + i] = ITEM_BOTTLE; + return true; + } + } + + return false; +} /** * Only used to equip spring water when hot sprint water timer runs out diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fb76c370a..7cbc92ecc 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2118,11 +2118,11 @@ 0x801149A0:("Inventory_DeleteItem",), 0x80114A9C:("Inventory_UnequipItem",), 0x80114B84:("Inventory_ReplaceItem",), - 0x80114CA0:("func_80114CA0",), + 0x80114CA0:("Inventory_UpdateDeitySwordEquip",), 0x80114E90:("Inventory_HasEmptyBottle",), 0x80114F2C:("Inventory_HasItemInBottle",), 0x80114FD0:("Inventory_UpdateBottleItem",), - 0x80115130:("func_80115130",), + 0x80115130:("Inventory_ConsumeFairy",), 0x801152B8:("Inventory_UpdateItem",), 0x801153C8:("func_801153C8",), 0x80115428:("Interface_LoadActionLabel",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 04d7cb4fd..a3a8c92d6 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1632,11 +1632,11 @@ asm/non_matchings/code/z_parameter/Item_CheckObtainability.s,Item_CheckObtainabi asm/non_matchings/code/z_parameter/Inventory_DeleteItem.s,Inventory_DeleteItem,0x801149A0,0x3F asm/non_matchings/code/z_parameter/Inventory_UnequipItem.s,Inventory_UnequipItem,0x80114A9C,0x3A asm/non_matchings/code/z_parameter/Inventory_ReplaceItem.s,Inventory_ReplaceItem,0x80114B84,0x47 -asm/non_matchings/code/z_parameter/func_80114CA0.s,func_80114CA0,0x80114CA0,0x7C +asm/non_matchings/code/z_parameter/Inventory_UpdateDeitySwordEquip.s,Inventory_UpdateDeitySwordEquip,0x80114CA0,0x7C asm/non_matchings/code/z_parameter/Inventory_HasEmptyBottle.s,Inventory_HasEmptyBottle,0x80114E90,0x27 asm/non_matchings/code/z_parameter/Inventory_HasItemInBottle.s,Inventory_HasItemInBottle,0x80114F2C,0x29 asm/non_matchings/code/z_parameter/Inventory_UpdateBottleItem.s,Inventory_UpdateBottleItem,0x80114FD0,0x58 -asm/non_matchings/code/z_parameter/func_80115130.s,func_80115130,0x80115130,0x62 +asm/non_matchings/code/z_parameter/Inventory_ConsumeFairy.s,Inventory_ConsumeFairy,0x80115130,0x62 asm/non_matchings/code/z_parameter/Inventory_UpdateItem.s,Inventory_UpdateItem,0x801152B8,0x44 asm/non_matchings/code/z_parameter/func_801153C8.s,func_801153C8,0x801153C8,0x18 asm/non_matchings/code/z_parameter/Interface_LoadActionLabel.s,Interface_LoadActionLabel,0x80115428,0x41