diff --git a/include/common.h b/include/common.h index 4fcf2be6..ff4e027a 100644 --- a/include/common.h +++ b/include/common.h @@ -119,7 +119,7 @@ u32 CheckKinstoneFused(u32); void sub_0801E1EC(u32, u32, u32); void sub_0801DD58(u32, u32); void sub_0801E1B8(u32, u32); -void sub_0801E738(u32); +void AddKinstoneToBag(u32); void sub_0801DFB4(struct Entity_*, u32, u32, u32); u32 sub_0801E00C(void); bool32 sub_0801E810(u32); diff --git a/src/common.c b/src/common.c index 8a2e3058..45a413e1 100644 --- a/src/common.c +++ b/src/common.c @@ -36,7 +36,7 @@ void ResetScreenRegs(void); void MessageFromFusionTarget(u32); void sub_0801E24C(s32, s32); void sub_0801E290(u32, u32, u32); -s32 sub_0801E8B0(u32); +s32 GetIndexInKinstoneBag(u32); extern u32 sub_0807CB24(u32, u32); @@ -71,7 +71,7 @@ extern const GfxItem* gGfxGroups[]; extern const u32 gUnk_080C9460[]; -void sub_0801E82C(void); +void SortKinstoneBag(void); extern void* GetRoomProperty(u32, u32, u32); @@ -767,13 +767,13 @@ void sub_0801E6C8(u32 kinstoneId) { } } -void sub_0801E738(u32 param_1) { +void AddKinstoneToBag(u32 kinstoneId) { s32 index; s32 tmp; - sub_0801E82C(); - if (param_1 - 0x65 < 0x11) { - index = sub_0801E8B0(param_1); + SortKinstoneBag(); // sometimes called just for this function + if (kinstoneId - 0x65 < 0x11) { + index = GetIndexInKinstoneBag(kinstoneId); if (index < 0) { index = 0; while (gSave.kinstoneTypes[index] != 0) { @@ -781,7 +781,7 @@ void sub_0801E738(u32 param_1) { } } if ((u32)index < 0x12) { - gSave.kinstoneTypes[index] = param_1; + gSave.kinstoneTypes[index] = kinstoneId; tmp = gSave.kinstoneAmounts[index] + 1; if (tmp > 99) { tmp = 99; @@ -791,8 +791,8 @@ void sub_0801E738(u32 param_1) { } } -void sub_0801E798(u32 a1) { - s32 idx = sub_0801E8B0(a1); +void RemoveKinstoneFromBag(u32 kinstoneId) { + s32 idx = GetIndexInKinstoneBag(kinstoneId); if (idx >= 0) { s32 next = gSave.kinstoneAmounts[idx] - 1; if (next <= 0) { @@ -803,12 +803,12 @@ void sub_0801E798(u32 a1) { } } -u32 sub_0801E7D0(u32 a1) { - s32 tmp = sub_0801E8B0(a1); - if (tmp < 0) { +u32 GetAmountInKinstoneBag(u32 kinstoneId) { + s32 index = GetIndexInKinstoneBag(kinstoneId); + if (index < 0) { return 0; } - return gSave.kinstoneAmounts[tmp]; + return gSave.kinstoneAmounts[index]; } u32 CheckKinstoneFused(u32 kinstoneId) { @@ -825,7 +825,7 @@ bool32 sub_0801E810(u32 kinstoneId) { return ReadBit(&gSave.unk24E, kinstoneId); } -void sub_0801E82C(void) { +void SortKinstoneBag(void) { #ifdef NON_MATCHING u32 r5; @@ -889,11 +889,11 @@ code0_2: #endif } -s32 sub_0801E8B0(u32 idx) { +s32 GetIndexInKinstoneBag(u32 kinstoneId) { u32 i; - for (i = 0; i < 18; ++i) { - if (idx == gSave.kinstoneTypes[i]) + for (i = 0; i < 0x12; ++i) { + if (kinstoneId == gSave.kinstoneTypes[i]) return i; } return -1; diff --git a/src/itemUtils.c b/src/itemUtils.c index 57857c4f..72cd7608 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -114,7 +114,7 @@ u32 GiveItem(Item item, u32 param_2) { gSave.dungeonItems[gArea.dungeon_idx] |= metaData->unk2; break; case 0xd: - sub_0801E738(0x72); + AddKinstoneToBag(0x72); break; case 0x12: if (item == ITEM_BOOMERANG) { @@ -174,7 +174,7 @@ u32 GiveItem(Item item, u32 param_2) { SoundReq(SFX_103); break; case 0x0f: - sub_0801E738(param_2); + AddKinstoneToBag(param_2); break; case 0x10: gSave.stats.walletType++; diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index 11673e00..e30c3adf 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -28,7 +28,7 @@ extern void sub_080A3B74(void); extern u32 sub_080A3B48(void); extern void sub_0805ECEC(u32, u32, u32, u32); extern void sub_0801E6C8(u32); -extern void sub_0801E798(u32); +extern void RemoveKinstoneFromBag(u32); extern WStruct* sub_0805F2C8(void); extern void sub_0805F300(WStruct*); extern u32 sub_0805F76C(u8*, WStruct*); @@ -151,7 +151,7 @@ void KinstoneMenu_Type0(void) { gScreen.bg3.updated = 1; KinstoneMenu_080A4528(); sub_080A4398(); - sub_0801E738(0); + AddKinstoneToBag(0); sub_080A70AC((void*)gUnk_081280DC); SetMenuType(1); SetFade(FADE_BLACK_WHITE | FADE_INSTANT, 8); @@ -609,7 +609,7 @@ void KinstoneMenu_080A4468(void) { gUnk_03003DF0.unk_2 = 0; gUnk_03003DF0.unk_4[3] = 0; sub_0801E6C8(gFuseInfo.kinstoneId); - sub_0801E798(gKinstoneMenu.unk2a); + RemoveKinstoneFromBag(gKinstoneMenu.unk2a); } u32 KinstoneMenu_080A4494(void) { diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index cb76bee0..3af4f5eb 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -1281,7 +1281,7 @@ void PauseMenu_Screen_7(void) { void sub_080A6024(void) { sub_080A70AC((KeyButtonLayout*)&gUnk_08128D60); - sub_0801E738(0); + AddKinstoneToBag(0); sub_080A4398(); SetMenuType(1); } diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 37f9ef3f..f3f9b323 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -13,7 +13,7 @@ extern void (*const gUnk_08111B98[])(Entity*); static const u16 sKinstonePrices[]; -extern u32 sub_0801E7D0(u32); +extern u32 GetAmountInKinstoneBag(u32); void GoronMerchant(Entity* this) { if ((this->flags & ENT_SCRIPTED) != 0) { @@ -132,7 +132,7 @@ static u32 GoronMerchant_GetSalePrice(Entity* this) { void GoronMerchant_TryToBuyKinstone(Entity* this, ScriptExecutionContext* context) { s32 salePrice = GoronMerchant_GetSalePrice(this); if (salePrice <= gSave.stats.rupees) { - if (sub_0801E7D0(gRoomVars.shopItemType2) < 99) { + if (GetAmountInKinstoneBag(gRoomVars.shopItemType2) < 99) { ModRupees(-salePrice); InitItemGetSequence(0x5c, gRoomVars.shopItemType2, 0); gRoomVars.shopItemType = 0; diff --git a/src/playerUtils.c b/src/playerUtils.c index 47ed9c10..30d37295 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -1089,7 +1089,7 @@ bool32 sub_080782C0(void) { } } if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && ((u8)(gUnk_03003DF0.unk_4[3] - 1) < 100)) { - sub_0801E738(0); + AddKinstoneToBag(0); if (gSave.kinstoneAmounts[0] != 0) { gUnk_03003DF0.unk_2 = gUnk_03003DF0.unk_4[3]; *(u8*)(*(int*)(gUnk_03003DF0.unk_4 + 8) + 0x39) = 2;