item: through sub_809A584
This commit is contained in:
+1
-1173
File diff suppressed because it is too large
Load Diff
@@ -62,6 +62,7 @@ void FieldObjectInteractionPickBerryTree(void);
|
|||||||
void FieldObjectInteractionRemoveBerryTree(void);
|
void FieldObjectInteractionRemoveBerryTree(void);
|
||||||
u8 PlayerHasBerries(void);
|
u8 PlayerHasBerries(void);
|
||||||
void ResetBerryTreeSparkleFlags(void);
|
void ResetBerryTreeSparkleFlags(void);
|
||||||
|
const struct Berry * sub_809C8A0(u8 berryIdx);
|
||||||
|
|
||||||
extern const struct Berry gBerries[];
|
extern const struct Berry gBerries[];
|
||||||
|
|
||||||
|
|||||||
@@ -76,4 +76,6 @@ enum
|
|||||||
POCKET_BERRY_POUCH,
|
POCKET_BERRY_POUCH,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define NUM_BAG_POCKETS 5
|
||||||
|
|
||||||
#endif //GUARD_CONSTANTS_GLOBAL_H
|
#endif //GUARD_CONSTANTS_GLOBAL_H
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ u16 BagGetItemIdByPocketPosition(u8 a0, u16 a1);
|
|||||||
u16 BagGetQuantityByPocketPosition(u8 a0, u16 a1);
|
u16 BagGetQuantityByPocketPosition(u8 a0, u16 a1);
|
||||||
bool8 itemid_is_unique(u16 itemId);
|
bool8 itemid_is_unique(u16 itemId);
|
||||||
void sub_809A584(struct ItemSlot * slots, u8 capacity);
|
void sub_809A584(struct ItemSlot * slots, u8 capacity);
|
||||||
u16 GetBagItemId(u16 *);
|
u16 GetPcItemQuantity(u16 *);
|
||||||
|
|
||||||
void ItemPcCompaction(void);
|
void ItemPcCompaction(void);
|
||||||
void RemoveItemFromPC(u16 itemId, u16 quantity);
|
void RemoveItemFromPC(u16 itemId, u16 quantity);
|
||||||
|
|||||||
@@ -25,5 +25,6 @@ void MoveSaveBlocks_ResetHeap(void);
|
|||||||
void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey);
|
void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey);
|
||||||
void ApplyNewEncryptionKeyToBagItems(u32 encryptionKey);
|
void ApplyNewEncryptionKeyToBagItems(u32 encryptionKey);
|
||||||
void ApplyNewEncryptionKeyToWord(u32 * word, u32 encryptionKey);
|
void ApplyNewEncryptionKeyToWord(u32 * word, u32 encryptionKey);
|
||||||
|
void ApplyNewEncryptionKeyToHword(u16 * hword, u32 encryptionKey);
|
||||||
|
|
||||||
#endif // GUARD_LOAD_SAVE_H
|
#endif // GUARD_LOAD_SAVE_H
|
||||||
|
|||||||
@@ -164,4 +164,6 @@ extern const u8 gText_ReturnToPC[];
|
|||||||
extern const u8 gUnknown_8416425[];
|
extern const u8 gUnknown_8416425[];
|
||||||
extern const u8 gUnknown_8416451[];
|
extern const u8 gUnknown_8416451[];
|
||||||
|
|
||||||
|
extern const u8 gUnknown_84162BD[];
|
||||||
|
|
||||||
#endif //GUARD_STRINGS_H
|
#endif //GUARD_STRINGS_H
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ SECTIONS {
|
|||||||
asm/map_name_popup.o(.text);
|
asm/map_name_popup.o(.text);
|
||||||
src/item_menu_icons.o(.text);
|
src/item_menu_icons.o(.text);
|
||||||
asm/battle_anim_mon_movement.o(.text);
|
asm/battle_anim_mon_movement.o(.text);
|
||||||
|
src/item.o(.text);
|
||||||
asm/item.o(.text);
|
asm/item.o(.text);
|
||||||
asm/shop.o(.text);
|
asm/shop.o(.text);
|
||||||
src/berry.o(.text);
|
src/berry.o(.text);
|
||||||
|
|||||||
+478
@@ -1,8 +1,486 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "berry.h"
|
||||||
|
#include "event_data.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "item_use.h"
|
#include "item_use.h"
|
||||||
|
#include "load_save.h"
|
||||||
|
#include "string_util.h"
|
||||||
|
#include "strings.h"
|
||||||
#include "constants/hold_effects.h"
|
#include "constants/hold_effects.h"
|
||||||
#include "constants/items.h"
|
#include "constants/items.h"
|
||||||
|
|
||||||
// Item descriptions and data
|
// Item descriptions and data
|
||||||
#include "data/items.h"
|
#include "data/items.h"
|
||||||
|
|
||||||
|
u16 GetBagItemQuantity(u16 * ptr)
|
||||||
|
{
|
||||||
|
return gSaveBlock2Ptr->encryptionKey ^ *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBagItemQuantity(u16 * ptr, u16 value)
|
||||||
|
{
|
||||||
|
*ptr = value ^ gSaveBlock2Ptr->encryptionKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 GetPcItemQuantity(u16 * ptr)
|
||||||
|
{
|
||||||
|
return 0 ^ *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetPcItemQuantity(u16 * ptr, u16 value)
|
||||||
|
{
|
||||||
|
*ptr = value ^ 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyNewEncryptionKeyToBagItems(u32 key)
|
||||||
|
{
|
||||||
|
u32 i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_BAG_POCKETS; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < gBagPockets[i].capacity; j++)
|
||||||
|
{
|
||||||
|
ApplyNewEncryptionKeyToHword(&gBagPockets[i].itemSlots[j].quantity, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyNewEncryptionKeyToBagItems_(u32 key) {
|
||||||
|
ApplyNewEncryptionKeyToBagItems(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sub_8099E44(void)
|
||||||
|
{
|
||||||
|
gBagPockets[POCKET_ITEMS - 1].itemSlots = gSaveBlock1Ptr->bagPocket_Items;
|
||||||
|
gBagPockets[POCKET_ITEMS - 1].capacity = BAG_ITEMS_COUNT;
|
||||||
|
gBagPockets[POCKET_KEY_ITEMS - 1].itemSlots = gSaveBlock1Ptr->bagPocket_KeyItems;
|
||||||
|
gBagPockets[POCKET_KEY_ITEMS - 1].capacity = BAG_KEYITEMS_COUNT;
|
||||||
|
gBagPockets[POCKET_POKE_BALLS - 1].itemSlots = gSaveBlock1Ptr->bagPocket_PokeBalls;
|
||||||
|
gBagPockets[POCKET_POKE_BALLS - 1].capacity = BAG_POKEBALLS_COUNT;
|
||||||
|
gBagPockets[POCKET_TM_CASE - 1].itemSlots = gSaveBlock1Ptr->bagPocket_TMHM;
|
||||||
|
gBagPockets[POCKET_TM_CASE - 1].capacity = BAG_TMHM_COUNT;
|
||||||
|
gBagPockets[POCKET_BERRY_POUCH - 1].itemSlots = gSaveBlock1Ptr->bagPocket_Berries;
|
||||||
|
gBagPockets[POCKET_BERRY_POUCH - 1].capacity = BAG_BERRIES_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CopyItemName(u16 itemId, u8 * dest)
|
||||||
|
{
|
||||||
|
if (itemId == ITEM_ENIGMA_BERRY)
|
||||||
|
{
|
||||||
|
StringCopy(dest, sub_809C8A0(43)->name);
|
||||||
|
StringAppend(dest, gUnknown_84162BD);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StringCopy(dest, ItemId_GetName(itemId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s8 sub_8099ECC(u8 pocketId)
|
||||||
|
{
|
||||||
|
u16 i;
|
||||||
|
|
||||||
|
for (i = 0; i < gBagPockets[pocketId].capacity; i++)
|
||||||
|
{
|
||||||
|
if (gBagPockets[pocketId].itemSlots[i].itemId == ITEM_NONE)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 sub_8099F08(u8 pocketId)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
|
||||||
|
for (i = 0; i < gBagPockets[pocketId - 1].capacity; i++)
|
||||||
|
{
|
||||||
|
if (gBagPockets[pocketId - 1].itemSlots[i].itemId != ITEM_NONE)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 CheckBagHasItem(u16 itemId, u16 count)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
u8 pocket;
|
||||||
|
|
||||||
|
if (ItemId_GetPocket(itemId) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
pocket = ItemId_GetPocket(itemId) - 1;
|
||||||
|
// Check for item slots that contain the item
|
||||||
|
for (i = 0; i < gBagPockets[pocket].capacity; i++)
|
||||||
|
{
|
||||||
|
if (gBagPockets[pocket].itemSlots[i].itemId == itemId)
|
||||||
|
{
|
||||||
|
u16 quantity;
|
||||||
|
// Does this item slot contain enough of the item?
|
||||||
|
quantity = GetBagItemQuantity(&gBagPockets[pocket].itemSlots[i].quantity);
|
||||||
|
if (quantity >= count)
|
||||||
|
return TRUE;
|
||||||
|
// RS and Emerald check whether there is enough of the
|
||||||
|
// item across all stacks.
|
||||||
|
// For whatever reason, FR/LG assume there's only one
|
||||||
|
// stack of the item.
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 sub_8099FAC(void)
|
||||||
|
{
|
||||||
|
u8 itemId;
|
||||||
|
bool8 exists;
|
||||||
|
|
||||||
|
exists = CheckBagHasItem(ITEM_BERRY_POUCH, 1);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
gSpecialVar_Result = FALSE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
for (itemId = ITEM_CHERI_BERRY; itemId <= ITEM_ENIGMA_BERRY; itemId++)
|
||||||
|
{
|
||||||
|
exists = CheckBagHasItem(itemId, 1);
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
gSpecialVar_Result = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gSpecialVar_Result = FALSE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 CheckBagHasSpace(u16 itemId, u16 count)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
u8 pocket;
|
||||||
|
|
||||||
|
if (ItemId_GetPocket(itemId) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
pocket = ItemId_GetPocket(itemId) - 1;
|
||||||
|
// Check for item slots that contain the item
|
||||||
|
for (i = 0; i < gBagPockets[pocket].capacity; i++)
|
||||||
|
{
|
||||||
|
if (gBagPockets[pocket].itemSlots[i].itemId == itemId)
|
||||||
|
{
|
||||||
|
u16 quantity;
|
||||||
|
// Does this stack have room for more??
|
||||||
|
quantity = GetBagItemQuantity(&gBagPockets[pocket].itemSlots[i].quantity);
|
||||||
|
if (quantity + count <= 999)
|
||||||
|
return TRUE;
|
||||||
|
// RS and Emerald check whether there is enough of the
|
||||||
|
// item across all stacks.
|
||||||
|
// For whatever reason, FR/LG assume there's only one
|
||||||
|
// stack of the item.
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub_8099ECC(pocket) != -1)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 AddBagItem(u16 itemId, u16 count)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
u8 pocket;
|
||||||
|
s8 idx;
|
||||||
|
|
||||||
|
if (ItemId_GetPocket(itemId) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
pocket = ItemId_GetPocket(itemId) - 1;
|
||||||
|
for (i = 0; i < gBagPockets[pocket].capacity; i++)
|
||||||
|
{
|
||||||
|
if (gBagPockets[pocket].itemSlots[i].itemId == itemId)
|
||||||
|
{
|
||||||
|
u16 quantity;
|
||||||
|
// Does this stack have room for more??
|
||||||
|
quantity = GetBagItemQuantity(&gBagPockets[pocket].itemSlots[i].quantity);
|
||||||
|
if (quantity + count <= 999)
|
||||||
|
{
|
||||||
|
quantity += count;
|
||||||
|
SetBagItemQuantity(&gBagPockets[pocket].itemSlots[i].quantity, quantity);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
// RS and Emerald check whether there is enough of the
|
||||||
|
// item across all stacks.
|
||||||
|
// For whatever reason, FR/LG assume there's only one
|
||||||
|
// stack of the item.
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pocket == POCKET_TM_CASE - 1 && !CheckBagHasItem(ITEM_TM_CASE, 1))
|
||||||
|
{
|
||||||
|
idx = sub_8099ECC(POCKET_KEY_ITEMS - 1);
|
||||||
|
if (idx == -1)
|
||||||
|
return FALSE;
|
||||||
|
gBagPockets[POCKET_KEY_ITEMS - 1].itemSlots[idx].itemId = ITEM_TM_CASE;
|
||||||
|
SetBagItemQuantity(&gBagPockets[POCKET_KEY_ITEMS - 1].itemSlots[idx].quantity, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pocket == POCKET_BERRY_POUCH - 1 && !CheckBagHasItem(ITEM_BERRY_POUCH, 1))
|
||||||
|
{
|
||||||
|
idx = sub_8099ECC(POCKET_KEY_ITEMS - 1);
|
||||||
|
if (idx == -1)
|
||||||
|
return FALSE;
|
||||||
|
gBagPockets[POCKET_KEY_ITEMS - 1].itemSlots[idx].itemId = ITEM_BERRY_POUCH;
|
||||||
|
SetBagItemQuantity(&gBagPockets[POCKET_KEY_ITEMS - 1].itemSlots[idx].quantity, 1);
|
||||||
|
FlagSet(FLAG_0x847);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemId == ITEM_BERRY_POUCH)
|
||||||
|
FlagSet(FLAG_0x847);
|
||||||
|
|
||||||
|
idx = sub_8099ECC(pocket);
|
||||||
|
if (idx == -1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
gBagPockets[pocket].itemSlots[idx].itemId = itemId;
|
||||||
|
SetBagItemQuantity(&gBagPockets[pocket].itemSlots[idx].quantity, count);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 RemoveBagItem(u16 itemId, u16 count)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
u8 pocket;
|
||||||
|
|
||||||
|
if (ItemId_GetPocket(itemId) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (itemId == ITEM_NONE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
pocket = ItemId_GetPocket(itemId) - 1;
|
||||||
|
// Check for item slots that contain the item
|
||||||
|
for (i = 0; i < gBagPockets[pocket].capacity; i++)
|
||||||
|
{
|
||||||
|
if (gBagPockets[pocket].itemSlots[i].itemId == itemId)
|
||||||
|
{
|
||||||
|
u16 quantity;
|
||||||
|
// Does this item slot contain enough of the item?
|
||||||
|
quantity = GetBagItemQuantity(&gBagPockets[pocket].itemSlots[i].quantity);
|
||||||
|
if (quantity >= count)
|
||||||
|
{
|
||||||
|
quantity -= count;
|
||||||
|
SetBagItemQuantity(&gBagPockets[pocket].itemSlots[i].quantity, quantity);
|
||||||
|
if (quantity == 0)
|
||||||
|
gBagPockets[pocket].itemSlots[i].itemId = ITEM_NONE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
// RS and Emerald check whether there is enough of the
|
||||||
|
// item across all stacks.
|
||||||
|
// For whatever reason, FR/LG assume there's only one
|
||||||
|
// stack of the item.
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 GetPocketByItemId(u16 itemId)
|
||||||
|
{
|
||||||
|
return ItemId_GetPocket(itemId); // wow such important
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClearItemSlots(struct ItemSlot * slots, u8 capacity)
|
||||||
|
{
|
||||||
|
u16 i;
|
||||||
|
|
||||||
|
for (i = 0; i < capacity; i++)
|
||||||
|
{
|
||||||
|
slots[i].itemId = ITEM_NONE;
|
||||||
|
SetBagItemQuantity(&slots[i].quantity, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sub_809A2A4(void)
|
||||||
|
{
|
||||||
|
u16 i;
|
||||||
|
|
||||||
|
for (i = 0; i < PC_ITEMS_COUNT; i++)
|
||||||
|
{
|
||||||
|
gSaveBlock1Ptr->pcItems[i].itemId = ITEM_NONE;
|
||||||
|
SetPcItemQuantity(&gSaveBlock1Ptr->pcItems[i].quantity, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sub_809A2DC(void)
|
||||||
|
{
|
||||||
|
u16 i;
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
ClearItemSlots(gBagPockets[i].itemSlots, gBagPockets[i].capacity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s8 sub_809A304(void)
|
||||||
|
{
|
||||||
|
s8 i;
|
||||||
|
|
||||||
|
for (i = 0; i < PC_ITEMS_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (gSaveBlock1Ptr->pcItems[i].itemId == ITEM_NONE)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 sub_809A33C(void)
|
||||||
|
{
|
||||||
|
u8 count = 0;
|
||||||
|
u8 i;
|
||||||
|
|
||||||
|
for (i = 0; i < PC_ITEMS_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (gSaveBlock1Ptr->pcItems[i].itemId != ITEM_NONE)
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 CheckPCHasItem(u16 itemId, u16 count)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
u16 quantity;
|
||||||
|
|
||||||
|
for (i = 0; i < PC_ITEMS_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (gSaveBlock1Ptr->pcItems[i].itemId == itemId)
|
||||||
|
{
|
||||||
|
quantity = GetPcItemQuantity(&gSaveBlock1Ptr->pcItems[i].quantity);
|
||||||
|
if (quantity >= count)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool8 AddPCItem(u16 itemId, u16 count)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
u16 quantity;
|
||||||
|
s8 idx;
|
||||||
|
|
||||||
|
for (i = 0; i < PC_ITEMS_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (gSaveBlock1Ptr->pcItems[i].itemId == itemId)
|
||||||
|
{
|
||||||
|
quantity = GetPcItemQuantity(&gSaveBlock1Ptr->pcItems[i].quantity);
|
||||||
|
if (quantity + count <= 999)
|
||||||
|
{
|
||||||
|
quantity += count;
|
||||||
|
SetPcItemQuantity(&gSaveBlock1Ptr->pcItems[i].quantity, quantity);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
idx = sub_809A304();
|
||||||
|
if (idx == -1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
gSaveBlock1Ptr->pcItems[idx].itemId = itemId;
|
||||||
|
SetPcItemQuantity(&gSaveBlock1Ptr->pcItems[idx].quantity, count);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoveItemFromPC(u16 itemId, u16 count)
|
||||||
|
{
|
||||||
|
u32 i;
|
||||||
|
u16 quantity;
|
||||||
|
|
||||||
|
if (itemId == ITEM_NONE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < PC_ITEMS_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (gSaveBlock1Ptr->pcItems[i].itemId == itemId)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != PC_ITEMS_COUNT)
|
||||||
|
{
|
||||||
|
quantity = GetPcItemQuantity(&gSaveBlock1Ptr->pcItems[i].quantity) - count;
|
||||||
|
SetPcItemQuantity(&gSaveBlock1Ptr->pcItems[i].quantity, quantity);
|
||||||
|
if (quantity == 0)
|
||||||
|
gSaveBlock1Ptr->pcItems[i].itemId = ITEM_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemPcCompaction(void)
|
||||||
|
{
|
||||||
|
u16 i, j;
|
||||||
|
struct ItemSlot tmp;
|
||||||
|
|
||||||
|
for (i = 0; i < PC_ITEMS_COUNT - 1; i++)
|
||||||
|
{
|
||||||
|
for (j = i + 1; j < PC_ITEMS_COUNT; j++)
|
||||||
|
{
|
||||||
|
if (gSaveBlock1Ptr->pcItems[i].itemId == ITEM_NONE)
|
||||||
|
{
|
||||||
|
tmp = gSaveBlock1Ptr->pcItems[i];
|
||||||
|
gSaveBlock1Ptr->pcItems[i] = gSaveBlock1Ptr->pcItems[j];
|
||||||
|
gSaveBlock1Ptr->pcItems[j] = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sub_809A540(void)
|
||||||
|
{
|
||||||
|
switch (gSaveBlock1Ptr->registeredItem)
|
||||||
|
{
|
||||||
|
case ITEM_MACH_BIKE:
|
||||||
|
gSaveBlock1Ptr->registeredItem = ITEM_ACRO_BIKE;
|
||||||
|
break;
|
||||||
|
case ITEM_ACRO_BIKE:
|
||||||
|
gSaveBlock1Ptr->registeredItem = ITEM_MACH_BIKE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sub_809A578(struct ItemSlot * a, struct ItemSlot * b)
|
||||||
|
{
|
||||||
|
struct ItemSlot c;
|
||||||
|
c = *a;
|
||||||
|
*a = *b;
|
||||||
|
*b = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sub_809A584(struct ItemSlot * slots, u8 capacity)
|
||||||
|
{
|
||||||
|
u16 i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < capacity - 1; i++)
|
||||||
|
{
|
||||||
|
for (j = i + 1; j < capacity; j++)
|
||||||
|
{
|
||||||
|
if (GetBagItemQuantity(&slots[i].quantity) == 0)
|
||||||
|
{
|
||||||
|
sub_809A578(&slots[i], &slots[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -676,7 +676,7 @@ static u16 ItemPc_GetItemIdBySlotId(u16 idx)
|
|||||||
|
|
||||||
static u16 ItemPc_GetItemQuantityBySlotId(u16 idx)
|
static u16 ItemPc_GetItemQuantityBySlotId(u16 idx)
|
||||||
{
|
{
|
||||||
return GetBagItemId(&gSaveBlock1Ptr->pcItems[idx].quantity);
|
return GetPcItemQuantity(&gSaveBlock1Ptr->pcItems[idx].quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ItemPc_CountPcItems(void)
|
static void ItemPc_CountPcItems(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user