Document Battle Pyramid Bag

This commit is contained in:
GriffinR 2021-04-22 18:49:54 -04:00
parent f823cd224f
commit 8c820878bf
13 changed files with 595 additions and 521 deletions

View file

@ -3,48 +3,72 @@
#include "list_menu.h"
struct PyramidBagResources
enum {
PYRAMIDBAG_LOC_FIELD,
PYRAMIDBAG_LOC_BATTLE,
PYRAMIDBAG_LOC_PARTY,
PYRAMIDBAG_LOC_CHOOSE_TOSS,
PYRAMIDBAG_LOC_PREV,
};
enum {
PBAG_SPRITE_BAG,
PBAG_SPRITE_ITEM_ICON,
PBAG_SPRITE_ITEM_ICON_ALT,
PBAG_SPRITE_SWAP_LINE_START, // Swap line consists of 8 sprites
PBAG_SPRITE_SWAP_LINE_2,
PBAG_SPRITE_SWAP_LINE_3,
PBAG_SPRITE_SWAP_LINE_4,
PBAG_SPRITE_SWAP_LINE_5,
PBAG_SPRITE_SWAP_LINE_6,
PBAG_SPRITE_SWAP_LINE_7,
PBAG_SPRITE_SWAP_LINE_END,
PBAG_SPRITE_COUNT
};
#define NUM_SWAP_LINE_SPRITES (1 + PBAG_SPRITE_SWAP_LINE_END - PBAG_SPRITE_SWAP_LINE_START)
struct PyramidBagMenu
{
void (*callback2)(void);
u8 tilemapBuffer[0x800];
u8 itemsSpriteIds[PYRAMID_BAG_ITEMS_COUNT + 1];
void (*exitCallback)(void);
u8 tilemapBuffer[BG_SCREEN_SIZE];
u8 spriteIds[PBAG_SPRITE_COUNT];
u8 windowIds[5];
u8 unk814;
u8 unk815;
u8 toSwapPos;
bool8 isAltIcon; // Two item icons loaded at a time. Tracks which to show next
u8 scrollIndicatorsTaskId;
const u8 *menuActionIds;
u8 filler81C[0x820 - 0x81C];
u8 unused1[4];
u8 menuActionsCount;
u8 listMenuCount;
u8 listMenuMaxShown;
struct ListMenuItem bagListItems[PYRAMID_BAG_ITEMS_COUNT + 1];
u8 itemStrings[PYRAMID_BAG_ITEMS_COUNT + 1][ITEM_NAME_LENGTH + 10];
s16 state;
u8 filler986[0x98C - 0x986];
u8 unused2[4];
};
struct PyramidBagCursorData
struct PyramidBagMenuState
{
void (*callback)(void);
u8 unk4;
u8 location;
u16 cursorPosition;
u16 scrollPosition;
};
extern struct PyramidBagResources *gPyramidBagResources;
extern struct PyramidBagCursorData gPyramidBagCursorData;
extern struct PyramidBagMenu *gPyramidBagMenu;
extern struct PyramidBagMenuState gPyramidBagMenuState;
void InitBattlePyramidBagCursorPosition(void);
void CB2_PyramidBagMenuFromStartMenu(void);
void CB2_ReturnToPyramidBagMenu(void);
void sub_81C5924(void);
void sub_81C59BC(void);
void UpdatePyramidBagList(void);
void UpdatePyramidBagCursorPos(void);
void sub_81C4EFC(void);
void GoToBattlePyramidBagMenu(u8 a0, void (*callback)(void));
void Task_CloseBattlePyramidBagMessage(u8 taskId);
void TryStoreHeldItemsInPyramidBag(void);
void ChooseItemsToTossFromPyramidBag(void);
void CloseBattlePyramidBagAndSetCallback(u8 taskId);
void CloseBattlePyramidBag(u8 taskId);
void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId));
#endif // GUARD_BATTLE_PYRAMID_BAG_H

View file

@ -90,8 +90,8 @@ void *malloc_and_decompress(const void *src, u32 *sizeOut);
u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode);
void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress);
void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8);
void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8);
u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos);
void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8);
u8 InitMenuActionGrid(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos);
u8 ChangeListMenuCursorPosition(s8 deltaX, s8 deltaY);
u8 GetStartMenuWindowId(void);
void ListMenuLoadStdPalAt(u8, u8);

View file

@ -29,7 +29,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1);
u8 GetLRKeysPressed(void);
u8 GetLRKeysPressedAndHeld(void);
bool8 sub_8122148(u16 itemId);
bool8 itemid_80BF6D8_mail_related(u16 itemId);
bool8 IsWritingMailAllowed(u16 itemId);
bool8 MenuHelpers_LinkSomething(void);
bool8 MenuHelpers_CallLinkSomething(void);
void sub_812220C(struct ItemSlot *slots, u8 count, u8 *arg2, u8 *usedSlotsCount, u8 maxUsedSlotsCount);

View file

@ -982,7 +982,8 @@ extern const u8 gText_RibbonsVar1[];
extern const u8 gText_OneDash[];
extern const u8 gText_TwoDashes[];
extern const u8 *const gReturnToXStringsTable2[];
extern const u8 *const gBagMenu_ReturnToStrings[];
extern const u8 *const gPyramidBagMenu_ReturnToStrings[];
extern const u8 gText_NumPlayerLink[];
extern const u8 gText_ConfirmLinkWhenPlayersReady[];

File diff suppressed because it is too large Load diff

View file

@ -820,7 +820,7 @@ bool8 RemovePyramidBagItem(u16 itemId, u16 count)
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
i = gPyramidBagCursorData.cursorPosition + gPyramidBagCursorData.scrollPosition;
i = gPyramidBagMenuState.cursorPosition + gPyramidBagMenuState.scrollPosition;
if (items[i] == itemId && quantities[i] >= count)
{
quantities[i] -= count;

View file

@ -509,7 +509,6 @@ EWRAM_DATA u16 gSpecialVar_ItemId = 0;
static EWRAM_DATA struct TempWallyStruct *sTempWallyBag = 0;
extern u8 *const gPocketNamesStringsTable[];
extern u8* gReturnToXStringsTable[];
extern const u8 EventScript_SelectWithoutRegisteredItem[];
extern const u16 gUnknown_0860F074[];
@ -530,7 +529,7 @@ void CB2_BagMenuFromBattle(void)
if (!InBattlePyramid())
GoToBagMenu(ITEMMENULOCATION_BATTLE, POCKETS_COUNT, CB2_SetUpReshowBattleScreenAfterMenu2);
else
GoToBattlePyramidBagMenu(1, CB2_SetUpReshowBattleScreenAfterMenu2);
GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_BATTLE, CB2_SetUpReshowBattleScreenAfterMenu2);
}
// Choosing berry to plant
@ -947,7 +946,7 @@ void BagMenu_PrintDescription(int itemIndex)
}
else
{
StringCopy(gStringVar1, gReturnToXStringsTable[gBagPositionStruct.location]);
StringCopy(gStringVar1, gBagMenu_ReturnToStrings[gBagPositionStruct.location]);
StringExpandPlaceholders(gStringVar4, gText_ReturnToVar1);
str = gStringVar4;
}
@ -1458,7 +1457,7 @@ void sub_81AC590(u8 taskId)
gTasks[taskId].func = Task_BagMenu_HandleInput;
}
void OpenContextMenu(u8 unused)
static void OpenContextMenu(u8 unused)
{
switch (gBagPositionStruct.location)
{
@ -1604,8 +1603,8 @@ void sub_81ACAF8(u8 a)
void sub_81ACB54(u8 a, u8 b, u8 c)
{
sub_8198DBC(a, 7, 8, 1, 0x38, b, c, sItemMenuActions, gBagMenu->contextMenuItemsPtr);
sub_8199944(a, 0x38, b, c, 0);
PrintMenuActionGrid(a, 7, 8, 1, 0x38, b, c, sItemMenuActions, gBagMenu->contextMenuItemsPtr);
InitMenuActionGrid(a, 0x38, b, c, 0);
}
void Task_ItemContext_FieldOrBattle(u8 taskId)
@ -1850,7 +1849,7 @@ void ItemMenu_Register(u8 taskId)
void ItemMenu_Give(u8 taskId)
{
BagMenu_RemoveSomeWindow();
if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId))
if (!IsWritingMailAllowed(gSpecialVar_ItemId))
{
DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350);
}
@ -1925,7 +1924,7 @@ void CB2_ReturnToBagMenuPocket(void)
void Task_ItemContext_FieldGive(u8 taskId)
{
if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId))
if (!IsWritingMailAllowed(gSpecialVar_ItemId))
{
DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350);
}

View file

@ -109,8 +109,8 @@ static void SetUpItemUseCallback(u8 taskId)
}
else
{
gPyramidBagResources->callback2 = sItemUseCallbacks[type];
CloseBattlePyramidBagAndSetCallback(taskId);
gPyramidBagMenu->exitCallback = sItemUseCallbacks[type];
CloseBattlePyramidBag(taskId);
}
}
@ -822,8 +822,8 @@ static void RemoveUsedItem(void)
}
else
{
sub_81C5924();
sub_81C59BC();
UpdatePyramidBagList();
UpdatePyramidBagCursorPos();
}
}
@ -943,7 +943,7 @@ void ItemUseInBattle_PokeBall(u8 taskId)
if (!InBattlePyramid())
Task_FadeAndCloseBagMenu(taskId);
else
CloseBattlePyramidBagAndSetCallback(taskId);
CloseBattlePyramidBag(taskId);
}
else if (!InBattlePyramid())
{
@ -960,7 +960,7 @@ static void Task_CloseStatIncreaseMessage(u8 taskId)
if (!InBattlePyramid())
Task_FadeAndCloseBagMenu(taskId);
else
CloseBattlePyramidBagAndSetCallback(taskId);
CloseBattlePyramidBag(taskId);
}
}
@ -1005,8 +1005,8 @@ static void ItemUseInBattle_ShowPartyMenu(u8 taskId)
}
else
{
gPyramidBagResources->callback2 = ChooseMonForInBattleItem;
CloseBattlePyramidBagAndSetCallback(taskId);
gPyramidBagMenu->exitCallback = ChooseMonForInBattleItem;
CloseBattlePyramidBag(taskId);
}
}
@ -1039,7 +1039,7 @@ void ItemUseInBattle_Escape(u8 taskId)
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, gStringVar4, Task_FadeAndCloseBagMenu);
else
DisplayItemMessageInBattlePyramid(taskId, gStringVar4, CloseBattlePyramidBagAndSetCallback);
DisplayItemMessageInBattlePyramid(taskId, gStringVar4, CloseBattlePyramidBag);
}
else
{

View file

@ -1241,7 +1241,7 @@ void sub_8198D54(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struc
sub_8198C94(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a3, a4, a5, strs);
}
void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8)
void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *strs, const u8 *strIds)
{
u8 i;
u8 j;
@ -1256,13 +1256,13 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u
printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING);
printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING);
for (i = 0; i < itemCount2; i++)
for (i = 0; i < verticalCount; i++)
{
for (j = 0; j < itemCount; j++)
for (j = 0; j < horizontalCount; j++)
{
printer.currentChar = strs[a8[(itemCount * i) + j]].text;
printer.x = (a4 * j) + left;
printer.y = (GetFontAttribute(fontId, 1) * i) + top;
printer.currentChar = strs[strIds[(horizontalCount * i) + j]].text;
printer.x = (optionWidth * j) + left;
printer.y = (GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT) * i) + top;
printer.currentX = printer.x;
printer.currentY = printer.y;
AddTextPrinter(&printer, 0xFF, NULL);
@ -1272,9 +1272,10 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u
CopyWindowToVram(windowId, 2);
}
void sub_8198EF8(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *strs, const u8 *a8)
// Unused
static void PrintMenuActionGrid_TopLeft(u8 windowId, u8 fontId, u8 optionWidth, u8 unused, u8 horizontalCount, u8 verticalCount, const struct MenuAction *strs, const u8 *strIds)
{
sub_8198DBC(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a4, a5, strs, a8);
PrintMenuActionGrid(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, optionWidth, horizontalCount, verticalCount, strs, strIds);
}
u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, u8 a6, u8 a7, u8 numChoices, u8 a9)
@ -1701,7 +1702,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M
CopyWindowToVram(windowId, 2);
}
u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos)
u8 InitMenuActionGrid(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos)
{
s32 pos;

View file

@ -287,7 +287,7 @@ bool8 sub_8122148(u16 itemId)
return FALSE;
}
bool8 itemid_80BF6D8_mail_related(u16 itemId)
bool8 IsWritingMailAllowed(u16 itemId)
{
if (IsUpdateLinkStateCBActive() != TRUE && InUnionRoom() != TRUE)
return TRUE;

View file

@ -3020,7 +3020,7 @@ static void CB2_SelectBagItemToGive(void)
if (InBattlePyramid() == FALSE)
GoToBagMenu(ITEMMENULOCATION_PARTY, POCKETS_COUNT, CB2_GiveHoldItem);
else
GoToBattlePyramidBagMenu(2, CB2_GiveHoldItem);
GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_PARTY, CB2_GiveHoldItem);
}
static void CB2_GiveHoldItem(void)
@ -4203,7 +4203,7 @@ static void CB2_ReturnToBagMenu(void)
if (InBattlePyramid() == FALSE)
GoToBagMenu(ITEMMENULOCATION_LAST, POCKETS_COUNT, NULL);
else
GoToBattlePyramidBagMenu(4, gPyramidBagCursorData.callback);
GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_PREV, gPyramidBagMenuState.callback);
}
static void Task_SetSacredAshCB(u8 taskId)

View file

@ -279,7 +279,7 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, bool8 ignore
gTasks[taskId].tWindowId = CreateWindowFromRect(left, top, columnCount * newWidth, rowCount * 2);
SetStandardWindowBorderStyle(gTasks[taskId].tWindowId, 0);
PrintMenuGridTable(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, sMultichoiceLists[multichoiceId].list);
sub_8199944(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, 0);
InitMenuActionGrid(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, 0);
CopyWindowToVram(gTasks[taskId].tWindowId, 3);
return TRUE;
}

View file

@ -1,5 +1,6 @@
#include "global.h"
#include "strings.h"
#include "battle_pyramid_bag.h"
ALIGNED(4)
const u8 gText_ExpandedPlaceholder_Empty[] = _("");
@ -252,7 +253,7 @@ const u8 gText_ThePokemonList[] = _("the POKéMON LIST");
const u8 gText_TheShop[] = _("the shop");
const u8 gText_ThePC[] = _("the PC");
const u8 *const gReturnToXStringsTable[] =
const u8 *const gBagMenu_ReturnToStrings[] =
{
gText_TheField,
gText_TheBattle,
@ -268,12 +269,12 @@ const u8 *const gReturnToXStringsTable[] =
gText_ThePC
};
const u8 *const gReturnToXStringsTable2[] =
const u8 *const gPyramidBagMenu_ReturnToStrings[] =
{
gText_TheField,
gText_TheBattle,
gText_ThePokemonList,
gText_TheField
[PYRAMIDBAG_LOC_FIELD] = gText_TheField,
[PYRAMIDBAG_LOC_BATTLE] = gText_TheBattle,
[PYRAMIDBAG_LOC_PARTY] = gText_ThePokemonList,
[PYRAMIDBAG_LOC_CHOOSE_TOSS] = gText_TheField
};
const u8 gText_ReturnToVar1[] = _("Return to\n{STR_VAR_1}.");