From 3477f61cf2f983e5851f720386128a4410d9e131 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sun, 13 Mar 2022 17:48:04 -0700 Subject: continue doing some more decomp --- src/kecleon_items_1.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 208 insertions(+), 5 deletions(-) (limited to 'src/kecleon_items_1.c') diff --git a/src/kecleon_items_1.c b/src/kecleon_items_1.c index cd5df5b..e504f81 100644 --- a/src/kecleon_items_1.c +++ b/src/kecleon_items_1.c @@ -99,12 +99,215 @@ extern void sub_8013984(u8 *); extern void sub_801A064(void); extern void sub_801A0D8(void); extern void AddMenuCursorSprite(void *); -extern s32 xxx_count_inv_unk230(); extern u8 sub_801A37C(void); extern u16 gUnknown_203B228; extern u16 gUnknown_203B22A; extern struct UnkTextStruct2 gUnknown_80DB95C; +extern void sub_801A010(void); +extern void sub_801A3DC(void); +extern void sub_801AD34(u32); +extern void PlaySound(u16 songIndex); + +extern void xxx_init_inv_unk250_at_8091A74(u8 index); +extern void xxx_fill_inv_unk250_gaps_8091AA8(void); + +u32 sub_8019D8C(void); + +void sub_8019730(void) +{ + s32 local_8; + + if (sub_80144A4(&local_8) != 0) { + return; + } + if (local_8 != 1) { + gUnknown_203B210->unk28 = local_8; + } + switch(local_8) { + case 2: + if (sub_8019D8C() == 0) { + UpdateKecleonStoreState(5); + } + else if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE) { + UpdateKecleonStoreState(0xA); + } + else { + UpdateKecleonStoreState(0xF); + } + break; + case 3: + if (GetNumberOfFilledInventorySlots() == 0) { + UpdateKecleonStoreState(9); + } + else if (gUnknown_203B210->unk14 == 0) { + UpdateKecleonStoreState(8); + } + else if (gTeamInventory_203B460->teamMoney < 99999) { + UpdateKecleonStoreState(0x17); + } + else + UpdateKecleonStoreState(7); + break; + case 4: + if (GetNumberOfFilledInventorySlots() == 0) + UpdateKecleonStoreState(9); + else if (gUnknown_203B210->unk14 == 0) + UpdateKecleonStoreState(8); + else if (gUnknown_203B210->unk18 + gTeamInventory_203B460->teamMoney > 99999) { + UpdateKecleonStoreState(7); + } + else + UpdateKecleonStoreState(0x1f); + break; + case 7: + UpdateKecleonStoreState(2); + break; + case 1: + UpdateKecleonStoreState(3); + break; + } +} + +void sub_8019850(void) +{ + s32 local_c; + + if (sub_80144A4(&local_c) == 0) { + switch(local_c) + { + case 5: + AddToTeamMoney(-gUnknown_203B210->itemSellPrice); + if (gUnknown_203B210->unk4 != '\0') { + AddHeldItemToInventory(xxx_get_inv_unk230_at_809185C(gUnknown_203B210->unk20)); + xxx_init_unk230_substruct(gUnknown_203B210->unk20); + xxx_fill_unk230_gaps(); + } + else { + AddHeldItemToInventory(xxx_get_unk250_at_8091A90(gUnknown_203B210->unk21)); + xxx_init_inv_unk250_at_8091A74(gUnknown_203B210->unk21); + xxx_fill_inv_unk250_gaps_8091AA8(); + } + PlaySound(0x14c); + UpdateKecleonStoreState(0x11); + break; + case 6: + case 1: + UpdateKecleonStoreState(0x10); + break; + } + } +} + +void sub_80198E8(void) +{ + s32 local_c; + + if (sub_80144A4(&local_c) == 0) { + switch(local_c) + { + case 5: + AddToTeamMoney(gUnknown_203B210->itemSellPrice); + ShiftItemsDownFrom(gUnknown_203B210->unk24); + PlaySound(0x14c); + UpdateKecleonStoreState(0x19); + break; + case 6: + case 1: + UpdateKecleonStoreState(0x18); + break; + } + } +} + +void sub_8019944(void) +{ + s32 slotIndex; + s32 local_10; + struct ItemSlot *itemSlot; + + if (sub_80144A4(&local_10) == 0) { + switch(local_10) + { + case 5: + for(slotIndex = 0; slotIndex < INVENTORY_SIZE; slotIndex++) + { + itemSlot = &gTeamInventory_203B460->teamItems[slotIndex]; + if ((itemSlot->itemFlags & ITEM_FLAG_EXISTS) && CanSellItem(itemSlot->itemIndex)) { + ClearItemSlotAt(slotIndex); + } + } + FillInventoryGaps(); + AddToTeamMoney(gUnknown_203B210->unk18); + PlaySound(0x14c); + UpdateKecleonStoreState(0x20); + break; + case 1: + case 6: + UpdateKecleonStoreState(1); + break; + } + } +} + +void sub_80199CC(void) +{ + u32 uVar2; + struct HeldItem *puVar3; + + if (gUnknown_203B210->unk4 != '\0') { + uVar2 = sub_8019EDC(1); + } + else { + uVar2 = sub_801A2A8(1); + } + + switch(uVar2) + { + case 3: + if (gUnknown_203B210->unk4) { + gUnknown_203B210->unk20 = sub_8019FB0(); + puVar3 = xxx_get_inv_unk230_at_809185C(gUnknown_203B210->unk20); + } + else { + gUnknown_203B210->unk21 = sub_801A37C(); + puVar3 = xxx_get_unk250_at_8091A90(gUnknown_203B210->unk21); + } + xxx_init_itemslot_8090A8C(&gUnknown_203B210->unk1C,puVar3->itemIndex,0); + gUnknown_203B210->unk1C.numItems =puVar3->numItems; + gUnknown_203B210->itemSellPrice = GetStackBuyPrice(&gUnknown_203B210->unk1C); + UpdateKecleonStoreState(0x14); + break; + case 4: + if (gUnknown_203B210->unk4) { + gUnknown_203B210->unk20 = sub_8019FB0(); + puVar3 = xxx_get_inv_unk230_at_809185C(gUnknown_203B210->unk20); + } + else { + gUnknown_203B210->unk21 = sub_801A37C(); + puVar3 = xxx_get_unk250_at_8091A90(gUnknown_203B210->unk21); + } + xxx_init_itemslot_8090A8C(&gUnknown_203B210->unk1C,puVar3->itemIndex,0); + gUnknown_203B210->unk1C.numItems = puVar3->numItems; + gUnknown_203B210->itemSellPrice = GetStackBuyPrice(&gUnknown_203B210->unk1C); + UpdateKecleonStoreState(0x15); + break; + case 2: + if (gUnknown_203B210->unk4) { + sub_801A010(); + } + else { + sub_801A3DC(); + } + UpdateKecleonStoreState(1); + break; + case 1: + sub_801AD34(0); + DrawTeamMoneyBox(1); + break; + } +} + void sub_8019B08(void) { switch(sub_801A6E8(1)) @@ -253,15 +456,15 @@ u32 sub_8019D8C(void) void sub_8019DAC(void) { s32 iVar3; - struct ItemSlot *pbVar4; + struct ItemSlot *itemSlot; s32 iVar5; gUnknown_203B210->unk14 = 0; gUnknown_203B210->unk18 = 0; for(iVar5 = 0; iVar5 < INVENTORY_SIZE; iVar5++){ - pbVar4 = &gTeamInventory_203B460->teamItems[iVar5]; - if (((pbVar4->itemFlags & ITEM_FLAG_EXISTS) != 0) && (CanSellItem(pbVar4->itemIndex))) { - iVar3 = GetStackSellPrice(pbVar4); + itemSlot = &gTeamInventory_203B460->teamItems[iVar5]; + if (((itemSlot->itemFlags & ITEM_FLAG_EXISTS) != 0) && (CanSellItem(itemSlot->itemIndex))) { + iVar3 = GetStackSellPrice(itemSlot); gUnknown_203B210->unk18 += iVar3; gUnknown_203B210->unk14++; } -- cgit v1.2.3 From 46420815f4fd1f374ee48ee447bb42539e1a669c Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sun, 13 Mar 2022 17:58:45 -0700 Subject: code cleanup --- src/kecleon_items_1.c | 51 +++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 34 deletions(-) (limited to 'src/kecleon_items_1.c') diff --git a/src/kecleon_items_1.c b/src/kecleon_items_1.c index e504f81..c3e90b6 100644 --- a/src/kecleon_items_1.c +++ b/src/kecleon_items_1.c @@ -118,34 +118,26 @@ void sub_8019730(void) { s32 local_8; - if (sub_80144A4(&local_8) != 0) { + if (sub_80144A4(&local_8) != 0) return; - } - if (local_8 != 1) { + if (local_8 != 1) gUnknown_203B210->unk28 = local_8; - } switch(local_8) { case 2: - if (sub_8019D8C() == 0) { + if (sub_8019D8C() == 0) UpdateKecleonStoreState(5); - } - else if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE) { + else if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE) UpdateKecleonStoreState(0xA); - } - else { + else UpdateKecleonStoreState(0xF); - } break; case 3: - if (GetNumberOfFilledInventorySlots() == 0) { + if (GetNumberOfFilledInventorySlots() == 0) UpdateKecleonStoreState(9); - } - else if (gUnknown_203B210->unk14 == 0) { + else if (gUnknown_203B210->unk14 == 0) UpdateKecleonStoreState(8); - } - else if (gTeamInventory_203B460->teamMoney < 99999) { + else if (gTeamInventory_203B460->teamMoney < 99999) UpdateKecleonStoreState(0x17); - } else UpdateKecleonStoreState(7); break; @@ -154,9 +146,8 @@ void sub_8019730(void) UpdateKecleonStoreState(9); else if (gUnknown_203B210->unk14 == 0) UpdateKecleonStoreState(8); - else if (gUnknown_203B210->unk18 + gTeamInventory_203B460->teamMoney > 99999) { + else if (gUnknown_203B210->unk18 + gTeamInventory_203B460->teamMoney > 99999) UpdateKecleonStoreState(7); - } else UpdateKecleonStoreState(0x1f); break; @@ -293,12 +284,10 @@ void sub_80199CC(void) UpdateKecleonStoreState(0x15); break; case 2: - if (gUnknown_203B210->unk4) { + if (gUnknown_203B210->unk4) sub_801A010(); - } - else { + else sub_801A3DC(); - } UpdateKecleonStoreState(1); break; case 1: @@ -354,15 +343,12 @@ void sub_8019BBC(void) } switch(menuAction){ case 2: - if (gTeamInventory_203B460->teamMoney == 0) { + if (gTeamInventory_203B460->teamMoney == 0) UpdateKecleonStoreState(0x6); - } - else if (gUnknown_203B210->itemSellPrice > gTeamInventory_203B460->teamMoney) { + else if (gUnknown_203B210->itemSellPrice > gTeamInventory_203B460->teamMoney) UpdateKecleonStoreState(0xC); - } - else { + else UpdateKecleonStoreState(0x16); - } break; case 7: UpdateKecleonStoreState(0x15); @@ -385,15 +371,12 @@ void sub_8019C78(void) switch(menuAction){ case 3: sub_8099690(0); - if (!CanSellItem(gUnknown_203B210->unk1C.itemIndex)) { + if (!CanSellItem(gUnknown_203B210->unk1C.itemIndex)) UpdateKecleonStoreState(0xd); - } - else if (gUnknown_203B210->itemSellPrice + gTeamInventory_203B460->teamMoney > 99999) { + else if (gUnknown_203B210->itemSellPrice + gTeamInventory_203B460->teamMoney > 99999) UpdateKecleonStoreState(0xe); - } - else { + else UpdateKecleonStoreState(0x1e); - } break; case 7: sub_8099690(0); -- cgit v1.2.3