Document item menu

This commit is contained in:
GriffinR 2021-08-03 02:17:01 -04:00
parent d391486247
commit 28a8fe191a
21 changed files with 1268 additions and 1158 deletions

View File

@ -29,7 +29,7 @@ enum {
struct PyramidBagMenu
{
void (*exitCallback)(void);
void (*newScreenCallback)(void);
u8 tilemapBuffer[BG_SCREEN_SIZE];
u8 spriteIds[PBAG_SPRITE_COUNT];
u8 windowIds[5];
@ -49,7 +49,7 @@ struct PyramidBagMenu
struct PyramidBagMenuState
{
void (*callback)(void);
void (*exitCallback)(void);
u8 location;
u16 cursorPosition;
u16 scrollPosition;
@ -64,7 +64,7 @@ void CB2_ReturnToPyramidBagMenu(void);
void UpdatePyramidBagList(void);
void UpdatePyramidBagCursorPos(void);
void sub_81C4EFC(void);
void GoToBattlePyramidBagMenu(u8 a0, void (*callback)(void));
void GoToBattlePyramidBagMenu(u8 location, void (*exitCallback)(void));
void Task_CloseBattlePyramidBagMessage(u8 taskId);
void TryStoreHeldItemsInPyramidBag(void);
void ChooseItemsToTossFromPyramidBag(void);

View File

@ -16,9 +16,4 @@
#define KEYITEMS_POCKET 4
#define POCKETS_COUNT 5
// The TM/HM pocket is the largest pocket, so the maximum amount of items
// in a pocket is its count + 1 for the cancel option
#define MAX_POCKET_ITEMS (BAG_TMHM_COUNT + 1)
#endif // GUARD_ITEM_CONSTANTS_H

View File

@ -199,9 +199,11 @@
#define FIRST_BERRY_INDEX ITEM_CHERI_BERRY
#define LAST_BERRY_INDEX ITEM_ENIGMA_BERRY
#define ITEM_0B0 176
#define ITEM_0B1 177
#define ITEM_0B2 178
#define ITEM_UNUSED_BERRY_1 176
#define ITEM_UNUSED_BERRY_2 177
#define ITEM_UNUSED_BERRY_3 178
#define MAX_BERRY_INDEX ITEM_UNUSED_BERRY_3
// Battle Held items
#define ITEM_BRIGHT_POWDER 179
@ -531,6 +533,6 @@
#define ITEM_B_USE_OTHER 2
// Check if the item is one that can be used on a Pokemon.
#define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= ITEM_0B2)
#define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= MAX_BERRY_INDEX)
#endif // GUARD_CONSTANTS_ITEMS_H

View File

@ -584,9 +584,11 @@ extern const u8 SecretBase_EventScript_ShrubUseSecretPower[];
extern const u8 TrainerHill_EventScript_TrainerBattle[];
// Item Use
extern u8 BerryTree_EventScript_ItemUsePlantBerry[];
extern u8 BerryTree_EventScript_ItemUseWailmerPail[];
extern u8 BattleFrontier_OutsideEast_EventScript_WaterSudowoodo[];
extern const u8 BerryTree_EventScript_ItemUsePlantBerry[];
extern const u8 BerryTree_EventScript_ItemUseWailmerPail[];
extern const u8 BattleFrontier_OutsideEast_EventScript_WaterSudowoodo[];
extern const u8 EventScript_SelectWithoutRegisteredItem[];
// overworld
extern const u8 EventScript_WhiteOut[];

View File

@ -1,107 +1,111 @@
#ifndef GUARD_item_menu_H
#define GUARD_item_menu_H
#ifndef GUARD_ITEM_MENU_H
#define GUARD_ITEM_MENU_H
#include "item.h"
#include "menu_helpers.h"
#define ITEMMENULOCATION_FIELD 0
#define ITEMMENULOCATION_BATTLE 1
#define ITEMMENULOCATION_PARTY 2
#define ITEMMENULOCATION_SHOP 3
#define ITEMMENULOCATION_BERRY_TREE 4
#define ITEMMENULOCATION_BERRY_BLENDER_CRUSH 5
#define ITEMMENULOCATION_ITEMPC 6
#define ITEMMENULOCATION_FAVOR_LADY 7
#define ITEMMENULOCATION_QUIZ_LADY 8
#define ITEMMENULOCATION_APPRENTICE 9
#define ITEMMENULOCATION_WALLY 10
#define ITEMMENULOCATION_PCBOX 11
#define ITEMMENULOCATION_LAST 12
enum {
ITEMMENULOCATION_FIELD,
ITEMMENULOCATION_BATTLE,
ITEMMENULOCATION_PARTY,
ITEMMENULOCATION_SHOP,
ITEMMENULOCATION_BERRY_TREE,
ITEMMENULOCATION_BERRY_BLENDER_CRUSH,
ITEMMENULOCATION_ITEMPC,
ITEMMENULOCATION_FAVOR_LADY,
ITEMMENULOCATION_QUIZ_LADY,
ITEMMENULOCATION_APPRENTICE,
ITEMMENULOCATION_WALLY,
ITEMMENULOCATION_PCBOX,
ITEMMENULOCATION_LAST,
};
#define ITEMMENUACTION_USE 0
#define ITEMMENUACTION_TOSS 1
#define ITEMMENUACTION_REGISTER 2
#define ITEMMENUACTION_GIVE 3
#define ITEMMENUACTION_CANCEL 4
#define ITEMMENUACTION_BATTLE_USE 5
#define ITEMMENUACTION_CHECK 6
#define ITEMMENUACTION_WALK 7
#define ITEMMENUACTION_DESELECT 8
#define ITEMMENUACTION_CHECK_TAG 9
#define ITEMMENUACTION_CONFIRM 10
#define ITEMMENUACTION_SHOW 11
#define ITEMMENUACTION_GIVE_2 12
#define ITEMMENUACTION_CONFIRM_2 13
#define ITEMMENUACTION_DUMMY 14
// Window IDs for the item menu
enum {
ITEMWIN_1x1,
ITEMWIN_1x2,
ITEMWIN_2x2,
ITEMWIN_2x3,
ITEMWIN_MESSAGE,
ITEMWIN_YESNO_LOW,
ITEMWIN_YESNO_HIGH,
ITEMWIN_QUANTITY,
ITEMWIN_QUANTITY_WIDE,
ITEMWIN_MONEY,
ITEMWIN_COUNT
};
// Exported type declarations
struct BagStruct
#define ITEMMENU_SWAP_LINE_LENGTH 8 // Swap line is 8 sprites long
enum {
ITEMMENUSPRITE_BAG,
ITEMMENUSPRITE_BALL,
ITEMMENUSPRITE_ITEM,
ITEMMENUSPRITE_ITEM_ALT, // Need two when selecting new item
ITEMMENUSPRITE_SWAP_LINE,
ITEMMENUSPRITE_COUNT = ITEMMENUSPRITE_SWAP_LINE + ITEMMENU_SWAP_LINE_LENGTH,
};
struct BagPosition
{
void (*bagCallback)(void);
void (*exitCallback)(void);
u8 location;
u8 pocket;
u16 unk6;
u16 pocketSwitchArrowPos;
u16 cursorPosition[POCKETS_COUNT];
u16 scrollPosition[POCKETS_COUNT];
};
extern struct BagStruct gBagPositionStruct;
extern struct BagPosition gBagPosition;
struct BagMenuStruct
struct BagMenu
{
void (*exitCallback)(void);
u8 tilemapBuffer[0x800];
u8 spriteId[12];
u8 windowPointers[10];
u8 itemOriginalLocation;
void (*newScreenCallback)(void);
u8 tilemapBuffer[BG_SCREEN_SIZE];
u8 spriteIds[ITEMMENUSPRITE_COUNT];
u8 windowIds[ITEMWIN_COUNT];
u8 toSwapPos;
u8 pocketSwitchDisabled:4;
u8 itemIconSlot:2;
u8 inhibitItemDescriptionPrint:1;
u8 hideCloseBagText:1;
u8 filler3[2];
u8 unused1[2];
u8 pocketScrollArrowsTask;
u8 pocketSwitchArrowsTask;
const u8* contextMenuItemsPtr;
u8 contextMenuItemsBuffer[4];
u8 contextMenuNumItems;
u8 numItemStacks[POCKETS_COUNT];
u8 numShownItems[6];
u8 numShownItems[POCKETS_COUNT];
s16 graphicsLoadState;
u8 filler4[0xE];
u8 unused2[14];
u8 pocketNameBuffer[32][32];
u8 filler2[4];
u8 unused3[4];
};
extern struct BagMenuStruct *gBagMenu;
// Exported RAM declarations
extern struct BagMenu *gBagMenu;
extern u16 gSpecialVar_ItemId;
// Exported ROM declarations
void CB2_GoToItemDepositMenu(void);
void FavorLadyOpenBagMenu(void);
void QuizLadyOpenBagMenu(void);
void ApprenticeOpenBagMenu(void);
void CB2_BagMenuFromBattle(void);
void SetInitialScrollAndCursorPositions(u8 pocketId);
void UpdatePocketListPosition(u8 pocketId);
void CB2_ReturnToBagMenuPocket(void);
void CB2_BagMenuFromStartMenu(void);
u8 GetItemListPosition(u8 pocketId);
bool8 UseRegisteredKeyItemOnField(void);
void CB2_GoToSellMenu(void);
void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)());
void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *exitCallback)());
void DoWallyTutorialBagMenu(void);
void ResetBagScrollPositions(void);
void ChooseBerryForMachine(void (*exitCallback)(void));
void CB2_ChooseBerry(void);
void Task_FadeAndCloseBagMenu(u8 taskId);
void BagMenu_YesNo(u8, u8, const struct YesNoFuncTable*);
void BagMenu_InitListsMenu(u8 taskId);
void BagMenu_YesNo(u8 taskId, u8 windowType, const struct YesNoFuncTable* funcTable);
void UpdatePocketItemList(u8 pocketId);
void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void ( *callback)(u8 taskId));
void DisplayItemMessageOnField(u8 taskId, const u8 *src, TaskFunc callback);
void CloseItemMessage(u8 taskId);
#endif //GUARD_item_menu_H
#endif //GUARD_ITEM_MENU_H

View File

@ -22,10 +22,4 @@ void FreeBerryTagSpritePalette(void);
u8 CreateSpinningBerrySprite(u8 berryId, u8 x, u8 y, bool8 startAffine);
u8 CreateBerryFlavorCircleSprite(s16 x);
#define TAG_BAG_GFX 100
#define TAG_ROTATING_BALL_GFX 101
#define TAG_BERRY_CHECK_CIRCLE_GFX 10000
#define TAG_BERRY_PIC_TILE 0xFFFF
#define TAG_BERRY_PIC_PAL 0x7544
#endif // GUARD_ITEM_MENU_ICONS_H

View File

@ -28,13 +28,13 @@ void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *templa
bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1);
u8 GetLRKeysPressed(void);
u8 GetLRKeysPressedAndHeld(void);
bool8 sub_8122148(u16 itemId);
bool8 IsHoldingItemAllowed(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);
void sub_812225C(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 numItems);
void sub_8122298(u16 *arg0, u16 *arg1, u8 arg2, u8 arg3, u8 arg4);
void SetCursorScrollWithinListBounds(u16 *scrollOffset, u16 *cursorPos, u8 shownItems, u8 totalItems, u8 maxShownItems);
void LoadListMenuSwapLineGfx(void);
void CreateSwapLineSprites(u8 *spriteIds, u8 count);
void DestroySwapLineSprites(u8 *spriteIds, u8 count);

View File

@ -419,8 +419,8 @@ extern const u8 gText_FirmSlash[];
// item menu screen text
extern const u8 gText_CloseBag[];
extern const u8 gText_ClearTo11Var1Clear5Var2[];
extern const u8 gText_NumberVar1Clear7Var2[];
extern const u8 gText_NumberItem_HM[];
extern const u8 gText_NumberItem_TMBerry[];
extern const u8 gText_xVar1[];
extern const u8 gText_ReturnToVar1[];
extern const u8 gText_SelectorArrow2[];
@ -442,6 +442,7 @@ extern const u8 gText_CantStoreImportantItems[];
extern const u8 gText_DepositedVar2Var1s[];
extern const u8 gText_NoRoomForItems[];
extern const u8 gText_ThreeDashes[];
extern const u8 *const gPocketNamesStringsTable[];
// party menu text
extern const u8 gText_PkmnHPRestoredByVar2[];

View File

@ -411,20 +411,20 @@ static void Task_ChooseItemsToTossFromPyramidBag(u8 taskId)
void CB2_ReturnToPyramidBagMenu(void)
{
GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_PREV, gPyramidBagMenuState.callback);
GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_PREV, gPyramidBagMenuState.exitCallback);
}
void GoToBattlePyramidBagMenu(u8 location, void (*callback)(void))
void GoToBattlePyramidBagMenu(u8 location, void (*exitCallback)(void))
{
gPyramidBagMenu = AllocZeroed(sizeof(*gPyramidBagMenu));
if (location != PYRAMIDBAG_LOC_PREV)
gPyramidBagMenuState.location = location;
if (callback != NULL)
gPyramidBagMenuState.callback = callback;
if (exitCallback != NULL)
gPyramidBagMenuState.exitCallback = exitCallback;
gPyramidBagMenu->exitCallback = NULL;
gPyramidBagMenu->newScreenCallback = NULL;
gPyramidBagMenu->toSwapPos = POS_NONE;
gPyramidBagMenu->scrollIndicatorsTaskId = TASK_NONE;
@ -624,7 +624,7 @@ static void CopyBagItemName(u8 *dst, u16 itemId)
{
ConvertIntToDecimalStringN(gStringVar1, ITEM_TO_BERRY(itemId), STR_CONV_MODE_LEADING_ZEROS, 2);
CopyItemName(itemId, gStringVar2);
StringExpandPlaceholders(dst, gText_NumberVar1Clear7Var2);
StringExpandPlaceholders(dst, gText_NumberItem_TMBerry);
}
else
{
@ -866,10 +866,13 @@ static void Task_ClosePyramidBag(u8 taskId)
if (!gPaletteFade.active)
{
DestroyListMenuTask(tListTaskId, &gPyramidBagMenuState.scrollPosition, &gPyramidBagMenuState.cursorPosition);
if (gPyramidBagMenu->exitCallback != NULL)
SetMainCallback2(gPyramidBagMenu->exitCallback);
// If ready for a new screen (e.g. party menu for giving an item) go to that screen
// Otherwise exit the bag and use callback set up when the bag was first opened
if (gPyramidBagMenu->newScreenCallback != NULL)
SetMainCallback2(gPyramidBagMenu->newScreenCallback);
else
SetMainCallback2(gPyramidBagMenuState.callback);
SetMainCallback2(gPyramidBagMenuState.exitCallback);
RemoveScrollArrow();
ResetSpriteData();
FreeAllSpritePalettes();
@ -1249,7 +1252,7 @@ static void BagAction_Give(u8 taskId)
}
else if (!ItemId_GetImportance(gSpecialVar_ItemId))
{
gPyramidBagMenu->exitCallback = CB2_ChooseMonToGiveItem;
gPyramidBagMenu->newScreenCallback = CB2_ChooseMonToGiveItem;
CloseBattlePyramidBag(taskId);
}
else

View File

@ -548,9 +548,9 @@ static void Task_HandleInput(u8 taskId)
static void TryChangeDisplayedBerry(u8 taskId, s8 toMove)
{
s16 *data = gTasks[taskId].data;
s16 currPocketPosition = gBagPositionStruct.scrollPosition[3] + gBagPositionStruct.cursorPosition[3];
s16 currPocketPosition = gBagPosition.scrollPosition[BERRIES_POCKET] + gBagPosition.cursorPosition[BERRIES_POCKET];
u32 newPocketPosition = currPocketPosition + toMove;
if (newPocketPosition < 46 && BagGetItemIdByPocketPosition(POCKET_BERRIES, newPocketPosition) != 0)
if (newPocketPosition < ITEM_TO_BERRY(MAX_BERRY_INDEX) && BagGetItemIdByPocketPosition(POCKET_BERRIES, newPocketPosition) != ITEM_NONE)
{
if (toMove < 0)
data[1] = 2;
@ -566,8 +566,8 @@ static void TryChangeDisplayedBerry(u8 taskId, s8 toMove)
static void HandleBagCursorPositionChange(s8 toMove)
{
u16 *scrollPos = &gBagPositionStruct.scrollPosition[3];
u16 *cursorPos = &gBagPositionStruct.cursorPosition[3];
u16 *scrollPos = &gBagPosition.scrollPosition[BERRIES_POCKET];
u16 *cursorPos = &gBagPosition.cursorPosition[BERRIES_POCKET];
if (toMove > 0)
{
if (*cursorPos < 4 || BagGetItemIdByPocketPosition(POCKET_BERRIES, *scrollPos + 8) == 0)

View File

@ -192,10 +192,9 @@ const u32 *const gItemIconTable[][2] =
[ITEM_LANSAT_BERRY] = {gItemIcon_LansatBerry, gItemIconPalette_LansatBerry},
[ITEM_STARF_BERRY] = {gItemIcon_StarfBerry, gItemIconPalette_StarfBerry},
[ITEM_ENIGMA_BERRY] = {gItemIcon_EnigmaBerry, gItemIconPalette_EnigmaBerry},
// ????????
[ITEM_0B0] = {gItemIcon_QuestionMark, gItemIconPalette_QuestionMark},
[ITEM_0B1] = {gItemIcon_QuestionMark, gItemIconPalette_QuestionMark},
[ITEM_0B2] = {gItemIcon_QuestionMark, gItemIconPalette_QuestionMark},
[ITEM_UNUSED_BERRY_1] = {gItemIcon_QuestionMark, gItemIconPalette_QuestionMark},
[ITEM_UNUSED_BERRY_2] = {gItemIcon_QuestionMark, gItemIconPalette_QuestionMark},
[ITEM_UNUSED_BERRY_3] = {gItemIcon_QuestionMark, gItemIconPalette_QuestionMark},
// Hold items
[ITEM_BRIGHT_POWDER] = {gItemIcon_BrightPowder, gItemIconPalette_BrightPowder},
[ITEM_WHITE_HERB] = {gItemIcon_InBattleHerb, gItemIconPalette_WhiteHerb},

View File

@ -2148,7 +2148,7 @@ const struct Item gItems[] =
.battleUseFunc = ItemUseInBattle_EnigmaBerry,
},
[ITEM_0B0] =
[ITEM_UNUSED_BERRY_1] =
{
.name = _("????????"),
.itemId = ITEM_NONE,
@ -2159,7 +2159,7 @@ const struct Item gItems[] =
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
},
[ITEM_0B1] =
[ITEM_UNUSED_BERRY_2] =
{
.name = _("????????"),
.itemId = ITEM_NONE,
@ -2170,7 +2170,7 @@ const struct Item gItems[] =
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
},
[ITEM_0B2] =
[ITEM_UNUSED_BERRY_3] =
{
.name = _("????????"),
.itemId = ITEM_NONE,

View File

@ -559,7 +559,7 @@ const u8 *const gBerryTreeObjectEventGraphicsIdTablePointers[] = {
[ITEM_STARF_BERRY - FIRST_BERRY_INDEX] = gBerryTreeObjectEventGraphicsIdTable,
[ITEM_ENIGMA_BERRY - FIRST_BERRY_INDEX] = gBerryTreeObjectEventGraphicsIdTable,
// 3 unused berries.
[ITEM_0B0 - FIRST_BERRY_INDEX] = gBerryTreeObjectEventGraphicsIdTable,
[ITEM_0B1 - FIRST_BERRY_INDEX] = gBerryTreeObjectEventGraphicsIdTable,
[ITEM_0B2 - FIRST_BERRY_INDEX] = gBerryTreeObjectEventGraphicsIdTable,
[ITEM_UNUSED_BERRY_1 - FIRST_BERRY_INDEX] = gBerryTreeObjectEventGraphicsIdTable,
[ITEM_UNUSED_BERRY_2 - FIRST_BERRY_INDEX] = gBerryTreeObjectEventGraphicsIdTable,
[ITEM_UNUSED_BERRY_3 - FIRST_BERRY_INDEX] = gBerryTreeObjectEventGraphicsIdTable,
};

View File

@ -867,7 +867,7 @@ static void InitDecorationItemsMenuScrollAndCursor(void)
static void InitDecorationItemsMenuScrollAndCursor2(void)
{
sub_8122298(&sDecorationsScrollOffset, &sDecorationsCursorPos, sDecorationItemsMenu->maxShownItems, sDecorationItemsMenu->numMenuItems, 8);
SetCursorScrollWithinListBounds(&sDecorationsScrollOffset, &sDecorationsCursorPos, sDecorationItemsMenu->maxShownItems, sDecorationItemsMenu->numMenuItems, 8);
}
static void PrintDecorationItemMenuItems(u8 taskId)

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,15 @@
#include "window.h"
#include "constants/items.h"
enum {
TAG_BAG_GFX = 100,
TAG_ROTATING_BALL_GFX,
TAG_ITEM_ICON,
TAG_ITEM_ICON_ALT,
};
#define TAG_BERRY_CHECK_CIRCLE_GFX 10000
#define TAG_BERRY_PIC_PAL 30020
struct CompressedTilesPal
{
const u32 *tiles;
@ -128,7 +137,7 @@ const struct CompressedSpritePalette gBagPaletteTable =
gBagPalette, TAG_BAG_GFX
};
static const struct SpriteTemplate gBagSpriteTemplate =
static const struct SpriteTemplate sBagSpriteTemplate =
{
.tileTag = TAG_BAG_GFX,
.paletteTag = TAG_BAG_GFX,
@ -189,17 +198,17 @@ static const union AffineAnimCmd *const sRotatingBallAnimCmds_FullRotation[] =
sSpriteAffineAnim_RotatingBallRotation2,
};
static const struct SpriteSheet gRotatingBallTable =
static const struct SpriteSheet sRotatingBallTable =
{
gRotatingBall, 0x80, TAG_ROTATING_BALL_GFX
};
static const struct SpritePalette gRotatingBallPaletteTable =
static const struct SpritePalette sRotatingBallPaletteTable =
{
gRotatingBall_Pal, TAG_ROTATING_BALL_GFX
};
static const struct SpriteTemplate gRotatingBallSpriteTemplate =
static const struct SpriteTemplate sRotatingBallSpriteTemplate =
{
.tileTag = TAG_ROTATING_BALL_GFX,
.paletteTag = TAG_ROTATING_BALL_GFX,
@ -262,7 +271,7 @@ static const struct SpriteFrameImage sBerryPicSpriteImageTable[] =
static const struct SpriteTemplate gBerryPicSpriteTemplate =
{
.tileTag = TAG_BERRY_PIC_TILE,
.tileTag = 0xFFFF,
.paletteTag = TAG_BERRY_PIC_PAL,
.oam = &sBerryPicOamData,
.anims = sBerryPicSpriteAnimTable,
@ -301,7 +310,7 @@ static const union AffineAnimCmd *const sBerryPicRotatingAnimCmds[] =
static const struct SpriteTemplate gBerryPicRotatingSpriteTemplate =
{
.tileTag = TAG_BERRY_PIC_TILE,
.tileTag = 0xFFFF,
.paletteTag = TAG_BERRY_PIC_PAL,
.oam = &sBerryPicRotatingOamData,
.anims = sBerryPicSpriteAnimTable,
@ -409,11 +418,11 @@ static const struct SpriteTemplate gBerryCheckCircleSpriteTemplate =
// code
void RemoveBagSprite(u8 id)
{
u8 *spriteId = &gBagMenu->spriteId[id];
u8 *spriteId = &gBagMenu->spriteIds[id];
if (*spriteId != SPRITE_NONE)
{
FreeSpriteTilesByTag(id + 100);
FreeSpritePaletteByTag(id + 100);
FreeSpriteTilesByTag(id + TAG_BAG_GFX);
FreeSpritePaletteByTag(id + TAG_BAG_GFX);
FreeSpriteOamMatrix(&gSprites[*spriteId]);
DestroySprite(&gSprites[*spriteId]);
*spriteId = SPRITE_NONE;
@ -422,14 +431,14 @@ void RemoveBagSprite(u8 id)
void AddBagVisualSprite(u8 bagPocketId)
{
u8 *spriteId = &gBagMenu->spriteId[0];
*spriteId = CreateSprite(&gBagSpriteTemplate, 68, 66, 0);
u8 *spriteId = &gBagMenu->spriteIds[ITEMMENUSPRITE_BAG];
*spriteId = CreateSprite(&sBagSpriteTemplate, 68, 66, 0);
SetBagVisualPocketId(bagPocketId, FALSE);
}
void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets)
{
struct Sprite *sprite = &gSprites[gBagMenu->spriteId[0]];
struct Sprite *sprite = &gSprites[gBagMenu->spriteIds[ITEMMENUSPRITE_BAG]];
if (isSwitchingPockets)
{
sprite->y2 = -5;
@ -458,7 +467,7 @@ static void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite)
void ShakeBagSprite(void)
{
struct Sprite *sprite = &gSprites[gBagMenu->spriteId[0]];
struct Sprite *sprite = &gSprites[gBagMenu->spriteIds[ITEMMENUSPRITE_BAG]];
if (sprite->affineAnimEnded)
{
StartSpriteAffineAnim(sprite, 1);
@ -477,10 +486,10 @@ static void SpriteCB_ShakeBagSprite(struct Sprite *sprite)
void AddSwitchPocketRotatingBallSprite(s16 rotationDirection)
{
u8 *spriteId = &gBagMenu->spriteId[1];
LoadSpriteSheet(&gRotatingBallTable);
LoadSpritePalette(&gRotatingBallPaletteTable);
*spriteId = CreateSprite(&gRotatingBallSpriteTemplate, 16, 16, 0);
u8 *spriteId = &gBagMenu->spriteIds[ITEMMENUSPRITE_BALL];
LoadSpriteSheet(&sRotatingBallTable);
LoadSpritePalette(&sRotatingBallPaletteTable);
*spriteId = CreateSprite(&sRotatingBallSpriteTemplate, 16, 16, 0);
gSprites[*spriteId].data[0] = rotationDirection;
}
@ -510,19 +519,20 @@ static void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite)
sprite->data[3]++;
UpdateSwitchPocketRotatingBallCoords(sprite);
if (sprite->data[3] == 16)
RemoveBagSprite(1);
RemoveBagSprite(ITEMMENUSPRITE_BALL);
}
void AddBagItemIconSprite(u16 itemId, u8 id)
{
u8 *spriteId = &gBagMenu->spriteId[id + 2];
u8 *spriteId = &gBagMenu->spriteIds[id + ITEMMENUSPRITE_ITEM];
if (*spriteId == SPRITE_NONE)
{
u8 iconSpriteId;
FreeSpriteTilesByTag(id + 102);
FreeSpritePaletteByTag(id + 102);
iconSpriteId = AddItemIconSprite(id + 102, id + 102, itemId);
// Either TAG_ITEM_ICON or TAG_ITEM_ICON_ALT
FreeSpriteTilesByTag(id + TAG_ITEM_ICON);
FreeSpritePaletteByTag(id + TAG_ITEM_ICON);
iconSpriteId = AddItemIconSprite(id + TAG_ITEM_ICON, id + TAG_ITEM_ICON, itemId);
if (iconSpriteId != MAX_SPRITES)
{
*spriteId = iconSpriteId;
@ -534,22 +544,22 @@ void AddBagItemIconSprite(u16 itemId, u8 id)
void RemoveBagItemIconSprite(u8 id)
{
RemoveBagSprite(id + 2);
RemoveBagSprite(id + ITEMMENUSPRITE_ITEM);
}
void CreateItemMenuSwapLine(void)
{
CreateSwapLineSprites(&gBagMenu->spriteId[4], 8);
CreateSwapLineSprites(&gBagMenu->spriteIds[ITEMMENUSPRITE_SWAP_LINE], ITEMMENU_SWAP_LINE_LENGTH);
}
void SetItemMenuSwapLineInvisibility(bool8 invisible)
{
SetSwapLineSpritesInvisibility(&gBagMenu->spriteId[4], 8, invisible);
SetSwapLineSpritesInvisibility(&gBagMenu->spriteIds[ITEMMENUSPRITE_SWAP_LINE], ITEMMENU_SWAP_LINE_LENGTH, invisible);
}
void UpdateItemMenuSwapLinePos(u8 y)
{
UpdateSwapLineSpritesPos(&gBagMenu->spriteId[4], 136, 120, (y + 1) * 16);
UpdateSwapLineSpritesPos(&gBagMenu->spriteIds[ITEMMENUSPRITE_SWAP_LINE], ITEMMENU_SWAP_LINE_LENGTH | 0x80, 120, (y + 1) * 16);
}
static void sub_80D5018(void *mem0, void *mem1)

View File

@ -91,7 +91,7 @@ static const u8 sClockwiseDirections[] = {DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WE
static const struct YesNoFuncTable sUseTMHMYesNoFuncTable =
{
.yesFunc = UseTMHM,
.noFunc = BagMenu_InitListsMenu,
.noFunc = CloseItemMessage,
};
#define tEnigmaBerryType data[4]
@ -104,12 +104,12 @@ static void SetUpItemUseCallback(u8 taskId)
type = ItemId_GetType(gSpecialVar_ItemId) - 1;
if (!InBattlePyramid())
{
gBagMenu->exitCallback = sItemUseCallbacks[type];
gBagMenu->newScreenCallback = sItemUseCallbacks[type];
Task_FadeAndCloseBagMenu(taskId);
}
else
{
gPyramidBagMenu->exitCallback = sItemUseCallbacks[type];
gPyramidBagMenu->newScreenCallback = sItemUseCallbacks[type];
CloseBattlePyramidBag(taskId);
}
}
@ -143,7 +143,7 @@ static void DisplayCannotUseItemMessage(u8 taskId, bool8 isUsingRegisteredKeyIte
if (!isUsingRegisteredKeyItemOnField)
{
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, gText_DadsAdvice, Task_CloseBattlePyramidBagMessage);
}
@ -189,7 +189,7 @@ static void CB2_CheckMail(void)
void ItemUseOutOfBattle_Mail(u8 taskId)
{
gBagMenu->exitCallback = CB2_CheckMail;
gBagMenu->newScreenCallback = CB2_CheckMail;
Task_FadeAndCloseBagMenu(taskId);
}
@ -614,7 +614,7 @@ void ItemUseOutOfBattle_PokeblockCase(u8 taskId)
}
else if (gTasks[taskId].tUsingRegisteredKeyItem != TRUE)
{
gBagMenu->exitCallback = CB2_OpenPokeblockFromBag;
gBagMenu->newScreenCallback = CB2_OpenPokeblockFromBag;
Task_FadeAndCloseBagMenu(taskId);
}
else
@ -647,7 +647,7 @@ void ItemUseOutOfBattle_CoinCase(u8 taskId)
if (!gTasks[taskId].tUsingRegisteredKeyItem)
{
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage);
}
else
{
@ -662,7 +662,7 @@ void ItemUseOutOfBattle_PowderJar(u8 taskId)
if (!gTasks[taskId].tUsingRegisteredKeyItem)
{
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage);
}
else
{
@ -676,7 +676,7 @@ void ItemUseOutOfBattle_Berry(u8 taskId)
{
sItemUseOnFieldCB = ItemUseOnFieldCB_Berry;
gFieldCallback = FieldCB_UseItemOnField;
gBagMenu->exitCallback = CB2_ReturnToField;
gBagMenu->newScreenCallback = CB2_ReturnToField;
Task_FadeAndCloseBagMenu(taskId);
}
else
@ -801,7 +801,7 @@ static void Task_ShowTMHMContainedMessage(u8 taskId)
static void UseTMHMYesNo(u8 taskId)
{
BagMenu_YesNo(taskId, 6, &sUseTMHMYesNoFuncTable);
BagMenu_YesNo(taskId, ITEMWIN_YESNO_HIGH, &sUseTMHMYesNoFuncTable);
}
static void UseTMHM(u8 taskId)
@ -818,7 +818,7 @@ static void RemoveUsedItem(void)
if (!InBattlePyramid())
{
UpdatePocketItemList(ItemId_GetPocket(gSpecialVar_ItemId));
SetInitialScrollAndCursorPositions(ItemId_GetPocket(gSpecialVar_ItemId));
UpdatePocketListPosition(ItemId_GetPocket(gSpecialVar_ItemId));
}
else
{
@ -832,7 +832,7 @@ void ItemUseOutOfBattle_Repel(u8 taskId)
if (VarGet(VAR_REPEL_STEP_COUNT) == 0)
gTasks[taskId].func = Task_StartUseRepel;
else if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, gText_RepelEffectsLingered, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gText_RepelEffectsLingered, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, gText_RepelEffectsLingered, Task_CloseBattlePyramidBagMessage);
}
@ -856,7 +856,7 @@ static void Task_UseRepel(u8 taskId)
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId));
RemoveUsedItem();
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage);
}
@ -868,7 +868,7 @@ static void Task_UsedBlackWhiteFlute(u8 taskId)
{
PlaySE(SE_GLASS_FLUTE);
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage);
}
@ -947,7 +947,7 @@ void ItemUseInBattle_PokeBall(u8 taskId)
}
else if (!InBattlePyramid())
{
DisplayItemMessage(taskId, 1, gText_BoxFull, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gText_BoxFull, CloseItemMessage);
}
else
DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, Task_CloseBattlePyramidBagMessage);
@ -985,7 +985,7 @@ void ItemUseInBattle_StatIncrease(u8 taskId)
if (ExecuteTableBasedItemEffect(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE)
{
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, gText_WontHaveEffect, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gText_WontHaveEffect, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, gText_WontHaveEffect, Task_CloseBattlePyramidBagMessage);
}
@ -1000,12 +1000,12 @@ static void ItemUseInBattle_ShowPartyMenu(u8 taskId)
{
if (!InBattlePyramid())
{
gBagMenu->exitCallback = ChooseMonForInBattleItem;
gBagMenu->newScreenCallback = ChooseMonForInBattleItem;
Task_FadeAndCloseBagMenu(taskId);
}
else
{
gPyramidBagMenu->exitCallback = ChooseMonForInBattleItem;
gPyramidBagMenu->newScreenCallback = ChooseMonForInBattleItem;
CloseBattlePyramidBag(taskId);
}
}

View File

@ -1097,32 +1097,32 @@ s8 Menu_ProcessInputNoWrapAround_other(void)
return MENU_NOTHING_CHOSEN;
}
void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs)
void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions)
{
u8 i;
for (i = 0; i < itemCount; i++)
{
AddTextPrinterParameterized(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL);
AddTextPrinterParameterized(windowId, fontId, menuActions[i].text, left, (lineHeight * i) + top, 0xFF, NULL);
}
CopyWindowToVram(windowId, 2);
}
void sub_81987BC(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, u8 a6, u8 a7)
void sub_81987BC(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, u8 a6, u8 a7)
{
u8 i;
for (i = 0; i < itemCount; i++)
{
AddTextPrinterParameterized5(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL, a6, a7);
AddTextPrinterParameterized5(windowId, fontId, menuActions[i].text, left, (lineHeight * i) + top, 0xFF, NULL, a6, a7);
}
CopyWindowToVram(windowId, 2);
}
void sub_8198854(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *strs)
void sub_8198854(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions)
{
PrintTextArray(windowId, fontId, GetFontAttribute(fontId, 0), 1, lineHeight, itemCount, strs);
PrintTextArray(windowId, fontId, GetFontAttribute(fontId, 0), 1, lineHeight, itemCount, menuActions);
}
void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8)
void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds)
{
u8 i;
struct TextPrinterTemplate printer;
@ -1140,7 +1140,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l
for (i = 0; i < itemCount; i++)
{
printer.currentChar = strs[a8[i]].text;
printer.currentChar = menuActions[actionIds[i]].text;
printer.y = (lineHeight * i) + top;
printer.currentY = printer.y;
AddTextPrinter(&printer, 0xFF, NULL);
@ -1149,9 +1149,9 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l
CopyWindowToVram(windowId, 2);
}
void sub_81989B8(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a5)
void sub_81989B8(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds)
{
AddItemMenuActionTextPrinters(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, strs, a5);
AddItemMenuActionTextPrinters(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, menuActions, actionIds);
}
void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
@ -1224,7 +1224,7 @@ void sub_8198C78(void)
RemoveWindow(sYesNoWindowId);
}
void sub_8198C94(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7, const struct MenuAction *strs)
void sub_8198C94(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7, const struct MenuAction *menuActions)
{
u8 i;
u8 j;
@ -1232,18 +1232,18 @@ void sub_8198C94(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u
{
for (j = 0; j < a6; j++)
{
AddTextPrinterParameterized(windowId, fontId, strs[(i * a6) + j].text, (a4 * j) + left, (a5 * i) + top, 0xFF, NULL);
AddTextPrinterParameterized(windowId, fontId, menuActions[(i * a6) + j].text, (a4 * j) + left, (a5 * i) + top, 0xFF, NULL);
}
}
CopyWindowToVram(windowId, 2);
}
void sub_8198D54(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *strs)
void sub_8198D54(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *menuActions)
{
sub_8198C94(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a3, a4, a5, strs);
sub_8198C94(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a3, a4, a5, menuActions);
}
void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *strs, const u8 *strIds)
void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds)
{
u8 i;
u8 j;
@ -1262,7 +1262,7 @@ void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth
{
for (j = 0; j < horizontalCount; j++)
{
printer.currentChar = strs[strIds[(horizontalCount * i) + j]].text;
printer.currentChar = menuActions[actionIds[(horizontalCount * i) + j]].text;
printer.x = (optionWidth * j) + left;
printer.y = (GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT) * i) + top;
printer.currentX = printer.x;
@ -1275,9 +1275,9 @@ void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth
}
// Unused
static void PrintMenuActionGrid_TopLeft(u8 windowId, u8 fontId, u8 optionWidth, u8 unused, u8 horizontalCount, u8 verticalCount, const struct MenuAction *strs, const u8 *strIds)
static void PrintMenuActionGrid_TopLeft(u8 windowId, u8 fontId, u8 optionWidth, u8 unused, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds)
{
PrintMenuActionGrid(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, optionWidth, horizontalCount, verticalCount, strs, strIds);
PrintMenuActionGrid(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, optionWidth, horizontalCount, verticalCount, menuActions, actionIds);
}
u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, u8 a6, u8 a7, u8 numChoices, u8 a9)
@ -1597,19 +1597,19 @@ u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 itemCount, u8
return InitMenuInUpperLeftCorner(windowId, itemCount, initialCursorPos, FALSE);
}
void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *strs)
void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *menuActions)
{
u32 i;
for (i = 0; i < itemCount; i++)
{
AddTextPrinterParameterized(windowId, 1, strs[i].text, 8, (i * 16) + 1, 0xFF, NULL);
AddTextPrinterParameterized(windowId, 1, menuActions[i].text, 8, (i * 16) + 1, 0xFF, NULL);
}
CopyWindowToVram(windowId, 2);
}
void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const u8 *a8)
void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds)
{
u8 i;
struct TextPrinterTemplate printer;
@ -1627,7 +1627,7 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const
for (i = 0; i < itemCount; i++)
{
printer.currentChar = strs[a8[i]].text;
printer.currentChar = menuActions[actionIds[i]].text;
printer.y = (i * 16) + 1;
printer.currentY = (i * 16) + 1;
AddTextPrinter(&printer, 0xFF, NULL);
@ -1661,19 +1661,19 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sYesNoWindowId, 2, initialCursorPos);
}
void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *strs)
void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *menuActions)
{
u32 i, j;
for (i = 0; i < rows; i++)
{
for (j = 0; j < columns; j++)
AddTextPrinterParameterized(windowId, 1, strs[(i * columns) + j].text, (optionWidth * j) + 8, (i * 16) + 1, 0xFF, NULL);
AddTextPrinterParameterized(windowId, 1, menuActions[(i * columns) + j].text, (optionWidth * j) + 8, (i * 16) + 1, 0xFF, NULL);
}
CopyWindowToVram(windowId, 2);
}
void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8)
void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *menuActions, const u8 *actionIds)
{
u8 i;
u8 j;
@ -1692,7 +1692,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M
{
for (j = 0; j < itemCount; j++)
{
printer.currentChar = strs[a8[(itemCount * i) + j]].text;
printer.currentChar = menuActions[actionIds[(itemCount * i) + j]].text;
printer.x = (a4 * j) + 8;
printer.y = (16 * i) + 1;
printer.currentX = printer.x;

View File

@ -23,10 +23,10 @@
static void Task_ContinueTaskAfterMessagePrints(u8 taskId);
static void Task_CallYesOrNoCallback(u8 taskId);
EWRAM_DATA static struct YesNoFuncTable gUnknown_0203A138 = {0};
EWRAM_DATA static u8 gUnknown_0203A140 = 0;
EWRAM_DATA static struct YesNoFuncTable sYesNo = {0};
EWRAM_DATA static u8 sMessageWindowId = 0;
static TaskFunc gUnknown_0300117C;
static TaskFunc sMessageNextTask;
static const struct OamData sOamData_SwapLine =
{
@ -122,17 +122,17 @@ void SetVBlankHBlankCallbacksToNull(void)
SetHBlankCallback(NULL);
}
void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 arg2, u8 arg3, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc)
void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 tileNum, u8 paletteNum, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc)
{
gUnknown_0203A140 = windowId;
DrawDialogFrameWithCustomTileAndPalette(windowId, TRUE, arg2, arg3);
sMessageWindowId = windowId;
DrawDialogFrameWithCustomTileAndPalette(windowId, TRUE, tileNum, paletteNum);
if (string != gStringVar4)
StringExpandPlaceholders(gStringVar4, string);
gTextFlags.canABSpeedUpPrint = 1;
AddTextPrinterParameterized2(windowId, fontId, gStringVar4, textSpeed, NULL, 2, 1, 3);
gUnknown_0300117C = taskFunc;
sMessageNextTask = taskFunc;
gTasks[taskId].func = Task_ContinueTaskAfterMessagePrints;
}
@ -144,20 +144,20 @@ bool16 RunTextPrintersRetIsActive(u8 textPrinterId)
static void Task_ContinueTaskAfterMessagePrints(u8 taskId)
{
if (!RunTextPrintersRetIsActive(gUnknown_0203A140))
gUnknown_0300117C(taskId);
if (!RunTextPrintersRetIsActive(sMessageWindowId))
sMessageNextTask(taskId);
}
void DoYesNoFuncWithChoice(u8 taskId, const struct YesNoFuncTable *data)
{
gUnknown_0203A138 = *data;
sYesNo = *data;
gTasks[taskId].func = Task_CallYesOrNoCallback;
}
void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo)
{
CreateYesNoMenu(template, tileStart, palette, 0);
gUnknown_0203A138 = *yesNo;
sYesNo = *yesNo;
gTasks[taskId].func = Task_CallYesOrNoCallback;
}
@ -167,12 +167,12 @@ static void Task_CallYesOrNoCallback(u8 taskId)
{
case 0:
PlaySE(SE_SELECT);
gUnknown_0203A138.yesFunc(taskId);
sYesNo.yesFunc(taskId);
break;
case 1:
case MENU_B_PRESSED:
PlaySE(SE_SELECT);
gUnknown_0203A138.noFunc(taskId);
sYesNo.noFunc(taskId);
break;
}
}
@ -275,11 +275,13 @@ u8 GetLRKeysPressedAndHeld(void)
return 0;
}
bool8 sub_8122148(u16 itemId)
bool8 IsHoldingItemAllowed(u16 itemId)
{
// Enigma Berry can't be held in link areas
if (itemId != ITEM_ENIGMA_BERRY)
return TRUE;
else if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRADE_CENTER) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRADE_CENTER))
else if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRADE_CENTER)
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRADE_CENTER))
return FALSE;
else if (InUnionRoom() != TRUE)
return TRUE;
@ -356,33 +358,37 @@ void sub_812225C(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 numItem
}
}
void sub_8122298(u16 *arg0, u16 *arg1, u8 arg2, u8 arg3, u8 arg4)
void SetCursorScrollWithinListBounds(u16 *scrollOffset, u16 *cursorPos, u8 shownItems, u8 totalItems, u8 maxShownItems)
{
u8 i;
if (arg4 % 2 != 0)
if (maxShownItems % 2 != 0)
{
if ((*arg1) >= arg4 / 2)
// Is cursor at least halfway down visible list
if (*cursorPos >= maxShownItems / 2)
{
for (i = 0; i < (*arg1) - (arg4 / 2); i++)
for (i = 0; i < *cursorPos - (maxShownItems / 2); i++)
{
if ((*arg0) + arg2 == arg3)
// Stop if reached end of list
if (*scrollOffset + shownItems == totalItems)
break;
(*arg1)--;
(*arg0)++;
(*cursorPos)--;
(*scrollOffset)++;
}
}
}
else
{
if ((*arg1) >= (arg4 / 2) + 1)
// Is cursor at least halfway down visible list
if (*cursorPos >= (maxShownItems / 2) + 1)
{
for (i = 0; i <= (*arg1) - (arg4 / 2); i++)
for (i = 0; i <= *cursorPos - (maxShownItems / 2); i++)
{
if ((*arg0) + arg2 == arg3)
// Stop if reached end of list
if (*scrollOffset + shownItems == totalItems)
break;
(*arg1)--;
(*arg0)++;
(*cursorPos)--;
(*scrollOffset)++;
}
}
}

View File

@ -4203,7 +4203,7 @@ static void CB2_ReturnToBagMenu(void)
if (InBattlePyramid() == FALSE)
GoToBagMenu(ITEMMENULOCATION_LAST, POCKETS_COUNT, NULL);
else
GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_PREV, gPyramidBagMenuState.callback);
GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_PREV, gPyramidBagMenuState.exitCallback);
}
static void Task_SetSacredAshCB(u8 taskId)

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "strings.h"
#include "battle_pyramid_bag.h"
#include "item_menu.h"
ALIGNED(4)
const u8 gText_ExpandedPlaceholder_Empty[] = _("");
@ -255,18 +256,18 @@ const u8 gText_ThePC[] = _("the PC");
const u8 *const gBagMenu_ReturnToStrings[] =
{
gText_TheField,
gText_TheBattle,
gText_ThePokemonList,
gText_TheShop,
gText_TheField,
gText_TheField,
gText_ThePC,
gText_TheField,
gText_TheField,
gText_TheField,
gText_TheBattle,
gText_ThePC
[ITEMMENULOCATION_FIELD] = gText_TheField,
[ITEMMENULOCATION_BATTLE] = gText_TheBattle,
[ITEMMENULOCATION_PARTY] = gText_ThePokemonList,
[ITEMMENULOCATION_SHOP] = gText_TheShop,
[ITEMMENULOCATION_BERRY_TREE] = gText_TheField,
[ITEMMENULOCATION_BERRY_BLENDER_CRUSH] = gText_TheField,
[ITEMMENULOCATION_ITEMPC] = gText_ThePC,
[ITEMMENULOCATION_FAVOR_LADY] = gText_TheField,
[ITEMMENULOCATION_QUIZ_LADY] = gText_TheField,
[ITEMMENULOCATION_APPRENTICE] = gText_TheField,
[ITEMMENULOCATION_WALLY] = gText_TheBattle,
[ITEMMENULOCATION_PCBOX] = gText_ThePC
};
const u8 *const gPyramidBagMenu_ReturnToStrings[] =
@ -286,15 +287,15 @@ const u8 gText_KeyItemsPocket[] = _("KEY ITEMS");
const u8 *const gPocketNamesStringsTable[] =
{
gText_ItemsPocket,
gText_PokeBallsPocket,
gText_TMHMPocket,
gText_BerriesPocket,
gText_KeyItemsPocket
[ITEMS_POCKET] = gText_ItemsPocket,
[BALLS_POCKET] = gText_PokeBallsPocket,
[TMHM_POCKET] = gText_TMHMPocket,
[BERRIES_POCKET] = gText_BerriesPocket,
[KEYITEMS_POCKET] = gText_KeyItemsPocket
};
const u8 gText_NumberVar1Clear7Var2[] = _("{NO}{STR_VAR_1}{CLEAR 0x07}{STR_VAR_2}");
const u8 gText_ClearTo11Var1Clear5Var2[] = _("{CLEAR_TO 0x11}{STR_VAR_1}{CLEAR 0x05}{STR_VAR_2}");
const u8 gText_NumberItem_TMBerry[] = _("{NO}{STR_VAR_1}{CLEAR 0x07}{STR_VAR_2}");
const u8 gText_NumberItem_HM[] = _("{CLEAR_TO 0x11}{STR_VAR_1}{CLEAR 0x05}{STR_VAR_2}");
const u8 gText_SizeSlash[] = _("SIZE /");
const u8 gText_FirmSlash[] = _("FIRM /");
const u8 gText_Var1DotVar2[] = _("{STR_VAR_1}.{STR_VAR_2}”");