Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Constant for 3 Main Bag Pockets #668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions include/constants/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@
#define UNION_ROOM_KB_ROW_COUNT 10
#define GIFT_RIBBONS_COUNT 11

#define POCKET_ITEMS 1
#define POCKET_KEY_ITEMS 2
#define POCKET_POKE_BALLS 3
#define POCKET_TM_CASE 4
#define POCKET_BERRY_POUCH 5
#define NUM_BAG_POCKETS 5
#define POCKET_ITEMS 1
#define POCKET_KEY_ITEMS 2
#define POCKET_POKE_BALLS 3
#define POCKET_TM_CASE 4
#define POCKET_BERRY_POUCH 5
#define NUM_BAG_POCKETS 5
#define NUM_BAG_POCKETS_NO_CASES 3 // number of pockets without considering TM case or berry pouch

// Contests
#define CONTEST_CATEGORIES_COUNT 5
Expand Down
4 changes: 2 additions & 2 deletions include/item_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ struct BagStruct
u8 location;
bool8 bagOpen;
u16 pocket;
u16 itemsAbove[3];
u16 cursorPos[3];
u16 itemsAbove[NUM_BAG_POCKETS_NO_CASES];
u16 cursorPos[NUM_BAG_POCKETS_NO_CASES];
};

extern struct BagStruct gBagMenuState;
Expand Down
2 changes: 1 addition & 1 deletion src/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void ClearBag(void)
{
u16 i;

for (i = 0; i < 5; i++)
for (i = 0; i < NUM_BAG_POCKETS; i++)
{
ClearItemSlots(gBagPockets[i].itemSlots, gBagPockets[i].capacity);
}
Expand Down
20 changes: 10 additions & 10 deletions src/item_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct BagMenuAlloc
u16 contextMenuSelectedItem;
u8 pocketScrollArrowsTask;
u8 pocketSwitchArrowsTask;
u8 nItems[3];
u8 maxShowed[3];
u8 nItems[NUM_BAG_POCKETS_NO_CASES];
u8 maxShowed[NUM_BAG_POCKETS_NO_CASES];
u8 data[4];
};

Expand All @@ -57,8 +57,8 @@ struct BagSlots
struct ItemSlot bagPocket_Items[BAG_ITEMS_COUNT];
struct ItemSlot bagPocket_KeyItems[BAG_KEYITEMS_COUNT];
struct ItemSlot bagPocket_PokeBalls[BAG_POKEBALLS_COUNT];
u16 itemsAbove[3];
u16 cursorPos[3];
u16 itemsAbove[NUM_BAG_POCKETS_NO_CASES];
u16 cursorPos[NUM_BAG_POCKETS_NO_CASES];
u16 registeredItem;
u16 pocket;
};
Expand Down Expand Up @@ -832,7 +832,7 @@ void ResetBagCursorPositions(void)
u8 i;
gBagMenuState.pocket = POCKET_ITEMS - 1;
gBagMenuState.bagOpen = FALSE;
for (i = 0; i < 3; i++)
for (i = 0; i < NUM_BAG_POCKETS_NO_CASES; i++)
{
gBagMenuState.itemsAbove[i] = 0;
gBagMenuState.cursorPos[i] = 0;
Expand All @@ -857,7 +857,7 @@ void PocketCalculateInitialCursorPosAndItemsAbove(u8 pocketId)
static void CalculateInitialCursorPosAndItemsAbove(void)
{
u8 i;
for (i = 0; i < 3; i++)
for (i = 0; i < NUM_BAG_POCKETS_NO_CASES; i++)
{
PocketCalculateInitialCursorPosAndItemsAbove(i);
}
Expand All @@ -868,7 +868,7 @@ static void UpdatePocketScrollPositions(void)
u8 i;
u8 j;

for (i = 0; i < 3; i++)
for (i = 0; i < NUM_BAG_POCKETS_NO_CASES; i++)
{
if (gBagMenuState.itemsAbove[i] > 3)
{
Expand Down Expand Up @@ -1011,7 +1011,7 @@ void Pocket_CalculateNItemsAndMaxShowed(u8 pocketId)
static void All_CalculateNItemsAndMaxShowed(void)
{
u8 i;
for (i = 0; i < 3; i++)
for (i = 0; i < NUM_BAG_POCKETS_NO_CASES; i++)
Pocket_CalculateNItemsAndMaxShowed(i);
}

Expand Down Expand Up @@ -2067,7 +2067,7 @@ static void BackUpPlayerBag(void)
memcpy(sBackupPlayerBag->bagPocket_PokeBalls, gSaveBlock1Ptr->bagPocket_PokeBalls, BAG_POKEBALLS_COUNT * sizeof(struct ItemSlot));
sBackupPlayerBag->registeredItem = gSaveBlock1Ptr->registeredItem;
sBackupPlayerBag->pocket = gBagMenuState.pocket;
for (i = 0; i < 3; i++)
for (i = 0; i < NUM_BAG_POCKETS_NO_CASES; i++)
{
sBackupPlayerBag->itemsAbove[i] = gBagMenuState.itemsAbove[i];
sBackupPlayerBag->cursorPos[i] = gBagMenuState.cursorPos[i];
Expand All @@ -2087,7 +2087,7 @@ static void RestorePlayerBag(void)
memcpy(gSaveBlock1Ptr->bagPocket_PokeBalls, sBackupPlayerBag->bagPocket_PokeBalls, BAG_POKEBALLS_COUNT * sizeof(struct ItemSlot));
gSaveBlock1Ptr->registeredItem = sBackupPlayerBag->registeredItem;
gBagMenuState.pocket = sBackupPlayerBag->pocket;
for (i = 0; i < 3; i++)
for (i = 0; i < NUM_BAG_POCKETS_NO_CASES; i++)
{
gBagMenuState.itemsAbove[i] = sBackupPlayerBag->itemsAbove[i];
gBagMenuState.cursorPos[i] = sBackupPlayerBag->cursorPos[i];
Expand Down