diff options
author | DizzyEggg <jajkodizzy@wp.pl> | 2018-04-29 14:21:59 +0200 |
---|---|---|
committer | DizzyEggg <jajkodizzy@wp.pl> | 2018-04-29 14:21:59 +0200 |
commit | fd40e93cb5fe4eb43551ae1a8f584e86bcc7ecf1 (patch) | |
tree | f11f19ec5a47723dd02f35d48d5935d5c5c08579 /src/item.c | |
parent | 25c669e36b8d23a24da567007bda1210ad9ce97e (diff) |
clear item, save and load save files
Diffstat (limited to 'src/item.c')
-rw-r--r-- | src/item.c | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/src/item.c b/src/item.c index a6e89a8e5..01166f5d6 100644 --- a/src/item.c +++ b/src/item.c @@ -8,6 +8,8 @@ #include "malloc.h" #include "secret_base.h" #include "item_menu.h" +#include "strings.h" +#include "load_save.h" // These constants are used in gItems enum @@ -20,40 +22,34 @@ enum POCKET_KEY_ITEMS, }; -extern void ApplyNewEncryptionKeyToHword(u16 *hword, u32 newKey); extern bool8 InBattlePyramid(void); - -extern const u8 gText_PokeBalls[]; -extern const u8 gText_Berries[]; -extern const u8 gText_Berry[]; - +extern u16 gUnknown_0203CF30[]; extern const struct Item gItems[]; // this file's functions - static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count); static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count); -static bool8 AddPyramidBagItem(u16 itemId, u16 count); -static bool8 RemovePyramidBagItem(u16 itemId, u16 count); -// code +// EWRAM variables +EWRAM_DATA struct BagPocket gBagPockets[POCKETS_COUNT] = {0}; -u16 GetBagItemQuantity(u16 *quantity) +// code +static u16 GetBagItemQuantity(u16 *quantity) { return gSaveBlock2Ptr->encryptionKey ^ *quantity; } -void SetBagItemQuantity(u16 *quantity, u16 newValue) +static void SetBagItemQuantity(u16 *quantity, u16 newValue) { *quantity = newValue ^ gSaveBlock2Ptr->encryptionKey; } -u16 GetPCItemQuantity(u16 *quantity) +static u16 GetPCItemQuantity(u16 *quantity) { return *quantity; } -void SetPCItemQuantity(u16 *quantity, u16 newValue) +static void SetPCItemQuantity(u16 *quantity, u16 newValue) { *quantity = newValue; } @@ -91,26 +87,26 @@ void SetBagItemsPointers(void) gBagPockets[BERRIES_POCKET].capacity = BAG_BERRIES_COUNT; } -void CopyItemName(u16 itemId, u8 *string) +void CopyItemName(u16 itemId, u8 *dst) { - StringCopy(string, ItemId_GetName(itemId)); + StringCopy(dst, ItemId_GetName(itemId)); } -void CopyItemNameHandlePlural(u16 itemId, u8 *string, u32 quantity) +void CopyItemNameHandlePlural(u16 itemId, u8 *dst, u32 quantity) { if (itemId == ITEM_POKE_BALL) { if (quantity < 2) - StringCopy(string, ItemId_GetName(ITEM_POKE_BALL)); + StringCopy(dst, ItemId_GetName(ITEM_POKE_BALL)); else - StringCopy(string, gText_PokeBalls); + StringCopy(dst, gText_PokeBalls); } else { if (itemId >= ITEM_CHERI_BERRY && itemId <= ITEM_ENIGMA_BERRY) - GetBerryCountString(string, gBerries[itemId - ITEM_CHERI_BERRY].name, quantity); + GetBerryCountString(dst, gBerries[itemId - ITEM_CHERI_BERRY].name, quantity); else - StringCopy(string, ItemId_GetName(itemId)); + StringCopy(dst, ItemId_GetName(itemId)); } } @@ -157,12 +153,12 @@ bool8 CheckBagHasItem(u16 itemId, u16 count) if (gBagPockets[pocket].itemSlots[i].itemId == itemId) { u16 quantity; - //Does this item slot contain enough of the item? + // Does this item slot contain enough of the item? quantity = GetBagItemQuantity(&gBagPockets[pocket].itemSlots[i].quantity); if (quantity >= count) return TRUE; count -= quantity; - //Does this item slot and all previous slots contain enough of the item? + // Does this item slot and all previous slots contain enough of the item? if (count == 0) return TRUE; } @@ -901,7 +897,7 @@ static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count) return FALSE; } -static bool8 AddPyramidBagItem(u16 itemId, u16 count) +bool8 AddPyramidBagItem(u16 itemId, u16 count) { u16 i; @@ -974,9 +970,7 @@ static bool8 AddPyramidBagItem(u16 itemId, u16 count) } } -extern u16 gUnknown_0203CF30[]; - -static bool8 RemovePyramidBagItem(u16 itemId, u16 count) +bool8 RemovePyramidBagItem(u16 itemId, u16 count) { u16 i; @@ -1077,7 +1071,6 @@ const u8 *ItemId_GetDescription(u16 itemId) return gItems[SanitizeItemId(itemId)].description; } - u8 ItemId_GetImportance(u16 itemId) { return gItems[SanitizeItemId(itemId)].importance; |