From 028207d6a8cc7bd88afb51cefd8bdd749993b00d Mon Sep 17 00:00:00 2001 From: Aetias Date: Tue, 30 Apr 2024 18:23:19 +0200 Subject: [PATCH] Decomp `ItemManager::HasAllPotions` --- asm/ov00/Item/ItemManager.s | 21 --------------------- include/Item/ItemManager.hpp | 3 ++- src/00_Core/Item/ItemManager.cpp | 13 ++++++++++--- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/asm/ov00/Item/ItemManager.s b/asm/ov00/Item/ItemManager.s index 9b30ee26..7135f5cb 100644 --- a/asm/ov00/Item/ItemManager.s +++ b/asm/ov00/Item/ItemManager.s @@ -2,27 +2,6 @@ .include "ov00/Item/ItemManager.inc" .text - - .global _ZNK11ItemManager13HasAllPotionsEv - arm_func_start _ZNK11ItemManager13HasAllPotionsEv -_ZNK11ItemManager13HasAllPotionsEv: ; 0x020ae598 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - mov r4, #0 -_020ae5a4: - mov r0, r5 - mov r1, r4 - bl _ZNK11ItemManager9HasPotionEj - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, pc} - add r4, r4, #1 - cmp r4, #2 - blt _020ae5a4 - mov r0, #1 - ldmia sp!, {r3, r4, r5, pc} - arm_func_end _ZNK11ItemManager13HasAllPotionsEv - .global _ZNK11ItemManager15HasPurplePotionEv arm_func_start _ZNK11ItemManager15HasPurplePotionEv _ZNK11ItemManager15HasPurplePotionEv: ; 0x020ae5d0 diff --git a/include/Item/ItemManager.hpp b/include/Item/ItemManager.hpp index caaab162..666ae6de 100644 --- a/include/Item/ItemManager.hpp +++ b/include/Item/ItemManager.hpp @@ -21,6 +21,7 @@ extern "C" { #define MAX_HOURGLASS_SECONDS 1500 // 25 minutes #define MAX_AMMO_UPGRADE 2 #define MAX_UNK_0BA 9 +#define MAX_POTIONS 2 typedef s32 FairyId; enum FairyId_ { @@ -207,7 +208,7 @@ private: /* 0b6 */ u16 mBombBagSize; /* 0b8 */ u16 mBombchuBagSize; /* 0ba */ u16 mUnk_0ba; // only between 0 and 9 - /* 0bc */ Potion mPotions[2]; + /* 0bc */ Potion mPotions[MAX_POTIONS]; /* 0be */ unk8 mUnk_0be[2]; // padding? /* 0c0 */ ItemModel *mItemModels[ItemModelId_COUNT]; /* 100 */ ItemModel *mDungeonItemModels[DungeonItemModelId_COUNT]; // non-null in dungeons/caves diff --git a/src/00_Core/Item/ItemManager.cpp b/src/00_Core/Item/ItemManager.cpp index 3aedc0b3..ea9d1f34 100644 --- a/src/00_Core/Item/ItemManager.cpp +++ b/src/00_Core/Item/ItemManager.cpp @@ -653,7 +653,7 @@ THUMB void ItemManager::GiveItem(ItemId id) { } break; case ItemId_RedPotion: { - for (s32 i = 0; i < 2; ++i) { + for (s32 i = 0; i < MAX_POTIONS; ++i) { if (mPotions[i] != Potion_None) continue; this->SetPotion(i, Potion_Red); break; @@ -661,7 +661,7 @@ THUMB void ItemManager::GiveItem(ItemId id) { } break; case ItemId_PurplePotion: { - for (s32 i = 0; i < 2; ++i) { + for (s32 i = 0; i < MAX_POTIONS; ++i) { if (mPotions[i] != Potion_None) continue; this->SetPotion(i, Potion_Purple); break; @@ -669,7 +669,7 @@ THUMB void ItemManager::GiveItem(ItemId id) { } break; case ItemId_YellowPotion: { - for (s32 i = 0; i < 2; ++i) { + for (s32 i = 0; i < MAX_POTIONS; ++i) { if (mPotions[i] != Potion_None) continue; this->SetPotion(i, Potion_Yellow); break; @@ -875,3 +875,10 @@ ARM bool ItemManager::HasPotion(u32 index) const { return false; } } + +ARM bool ItemManager::HasAllPotions() const { + for (s32 i = 0; i < MAX_POTIONS; ++i) { + if (!this->HasPotion(i)) return false; + } + return true; +}