Merge branch 'master' of github.com:pret/pokeemerald into battle_engine_sync

This commit is contained in:
ultima-soul 2021-08-16 15:43:27 -07:00
commit b620349da0
40 changed files with 2381 additions and 2179 deletions

View File

@ -12,6 +12,8 @@
ptr = NULL; \
}
#define TRY_FREE_AND_SET_NULL(ptr) if (ptr != NULL) FREE_AND_SET_NULL(ptr)
extern u8 gHeap[];
void *Alloc(u32 size);

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

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

@ -5284,13 +5284,13 @@ extern const u32 gKantoTrainerCardFrontLink_Tilemap[];
extern const u32 gHoennTrainerCardBg_Tilemap[];
// Frontier Pass
extern const u32 gUnknown_08DE08C8[];
extern const u32 gUnknown_08DE2084[];
extern const u32 gUnknown_08DE3350[];
extern const u32 gUnknown_08DE3374[];
extern const u32 gUnknown_08DE3060[];
extern const u32 gFrontierPassBg_Gfx[];
extern const u32 gFrontierPassBg_Tilemap[];
extern const u16 gFrontierPassBg_Pal[][16];
extern const u32 gFrontierPassMapAndCard_Gfx[];
extern const u32 gFrontierPassCancelButton_Tilemap[];
extern const u32 gFrontierPassCancelButtonHighlighted_Tilemap[];
extern const u32 gFrontierPassMedals_Gfx[];
extern const u16 gUnknown_08DE07C8[][16];
extern const u16 gFrontierPassCursor_Pal[];
extern const u16 gFrontierPassMedalsGold_Pal[];
extern const u16 gFrontierPassMedalsSilver_Pal[];

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 SetItemListPerPageCount(struct ItemSlot *slots, u8 slotsCount, u8 *pageItems, u8 *totalItems, u8 maxPerPage);
void SetCursorWithinListBounds(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 totalItems);
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

@ -15,6 +15,14 @@
#define MAX_CONDITION_SPARKLES 10
// Window IDs for the Player PC Mailbox
enum {
MAILBOXWIN_TITLE,
MAILBOXWIN_LIST,
MAILBOXWIN_OPTIONS,
MAILBOXWIN_COUNT
};
struct UnknownSubStruct_81D1ED4
{
u16 unk0;
@ -35,12 +43,12 @@ struct ConditionGraph
/*0x355*/ u8 state;
};
bool8 sub_81D1C44(u8 count);
u8 sub_81D1C84(u8 a0);
u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page);
void sub_81D1E90(struct PlayerPCItemPageStruct *page);
void sub_81D1EC0(void);
void sub_81D1D04(u8 a0);
bool8 MailboxMenu_Alloc(u8 count);
u8 MailboxMenu_AddWindow(u8 windowIdx);
u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page);
void MailboxMenu_AddScrollArrows(struct PlayerPCItemPageStruct *page);
void MailboxMenu_Free(void);
void MailboxMenu_RemoveWindow(u8 windowIdx);
void InitConditionGraphData(struct ConditionGraph *graph);
void sub_81D2108(struct ConditionGraph *graph);
void SetConditionGraphIOWindows(u8 bg);

View File

@ -3,69 +3,6 @@
#include "menu.h"
// local task defines
#define PAGE_INDEX data[0]
#define ITEMS_ABOVE_TOP data[1]
#define NUM_ITEMS data[1]
#define NUM_QUANTITY_ROLLER data[3]
#define NUM_PAGE_ITEMS data[4]
// not used
#define CURRENT_ITEM_STORAGE_MENU data[3]
// not used
#define SWAP_ITEM_INDEX data[8]
#define SWITCH_MODE_ACTIVE data[9]
// this is potentially an ewram access occuring in high ewram. TODO: investigate this further.
#define NEW_GAME_PC_ITEMS(i, type) ((u16)((u16 *)gNewGamePCItems + type)[i * 2])
// defined and used in the above macro
enum
{
PC_ITEM_ID,
PC_QUANTITY
};
// player PC menu options
enum
{
PLAYERPC_MENU_ITEMSTORAGE,
PLAYERPC_MENU_MAILBOX,
PLAYERPC_MENU_DECORATION,
PLAYERPC_MENU_TURNOFF
};
// item storage menus
enum
{
ITEMPC_MENU_WITHDRAW,
ITEMPC_MENU_DEPOSIT,
ITEMPC_MENU_TOSS,
ITEMPC_MENU_EXIT
};
// mailbox mail options
enum
{
MAILBOX_READ,
MAILBOX_MOVE_TO_BAG,
MAILBOX_GIVE,
MAILBOX_CANCEL,
};
// special item description handlers
enum
{
ITEMPC_SWITCH_WHICH_ITEM = 0xFFF7,
ITEMPC_OKAY_TO_THROW_AWAY,
ITEMPC_TOO_IMPORTANT,
ITEMPC_NO_MORE_ROOM,
ITEMPC_THREW_AWAY_ITEM,
ITEMPC_HOW_MANY_TO_TOSS,
ITEMPC_WITHDREW_THING,
ITEMPC_HOW_MANY_TO_WITHDRAW,
ITEMPC_GO_BACK_TO_PREV
};
struct PlayerPCItemPageStruct
{
u16 cursorPos;
@ -76,16 +13,12 @@ struct PlayerPCItemPageStruct
u8 scrollIndicatorTaskId;
};
// Exported type declarations
extern struct PlayerPCItemPageStruct gPlayerPCItemPageInfo;
// Exported RAM declarations
extern struct PlayerPCItemPageStruct playerPCItemPageInfo;
// Exported ROM declarations
extern const struct MenuAction gMailboxMailOptions[];
void ReshowPlayerPC(u8 taskId);
void sub_816B31C(void);
void CB2_PlayerPCExitBagMenu(void);
void Mailbox_ReturnToMailListAfterDeposit(void);
void NewGameInitPCItems(void);

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

@ -862,12 +862,12 @@ static void InitDecorationItemsMenuLimits(void)
static void InitDecorationItemsMenuScrollAndCursor(void)
{
sub_812225C(&sDecorationsScrollOffset, &sDecorationsCursorPos, sDecorationItemsMenu->maxShownItems, sDecorationItemsMenu->numMenuItems);
SetCursorWithinListBounds(&sDecorationsScrollOffset, &sDecorationsCursorPos, sDecorationItemsMenu->maxShownItems, sDecorationItemsMenu->numMenuItems);
}
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

@ -2049,14 +2049,12 @@ const u32 gTitleScreenPressStartGfx[] = INCBIN_U32("graphics/title_screen/press_
const u32 gUnknown_08DE0644[] = INCBIN_U32("graphics/title_screen/title_screen2.bin.lz");
// more trainer card stuff
const u16 gUnknown_08DE07C8[][16] = INCBIN_U16("graphics/frontier_pass/tiles.gbapal");// size in LoadPalette calls is reported as 0xD0 << 1, which is 0x1A0, but palette is only 0x100 bytes long so it loads garbage as well
const u32 gUnknown_08DE08C8[] = INCBIN_U32("graphics/frontier_pass/tiles.4bpp.lz");
const u32 gUnknown_08DE2084[] = INCBIN_U32("graphics/frontier_pass/tiles2.8bpp.lz");
const u32 gUnknown_08DE3060[] = INCBIN_U32("graphics/frontier_pass/tiles.bin.lz");
const u16 gUnknown_08DE3350[] = INCBIN_U16("graphics/frontier_pass/tilemap1.bin");
const u16 gUnknown_08DE3374[] = INCBIN_U16("graphics/frontier_pass/tilemap2.bin");
const u16 gFrontierPassBg_Pal[][16] = INCBIN_U16("graphics/frontier_pass/bg.gbapal");// size in LoadPalette calls is reported as 0xD0 << 1, which is 0x1A0, but palette is only 0x100 bytes long so it loads garbage as well
const u32 gFrontierPassBg_Gfx[] = INCBIN_U32("graphics/frontier_pass/bg.4bpp.lz");
const u32 gFrontierPassMapAndCard_Gfx[] = INCBIN_U32("graphics/frontier_pass/map_and_card.8bpp.lz");
const u32 gFrontierPassBg_Tilemap[] = INCBIN_U32("graphics/frontier_pass/bg.bin.lz");
const u16 gFrontierPassCancelButton_Tilemap[] = INCBIN_U16("graphics/frontier_pass/cancel.bin");
const u16 gFrontierPassCancelButtonHighlighted_Tilemap[] = INCBIN_U16("graphics/frontier_pass/cancel_highlighted.bin");
// Berry Crush
const u16 gBerryCrush_Crusher_Pal[] = INCBIN_U16("graphics/berry_crush/crusher.gbapal");

View File

@ -34,11 +34,11 @@ int GetStringWidthDifference(int fontId, const u8 *str, int totalWidth, int lett
return 0;
}
int GetMaxWidthInMenuTable(const struct MenuAction *str, int arg1)
int GetMaxWidthInMenuTable(const struct MenuAction *str, int numActions)
{
int i, var;
for (var = 0, i = 0; i < arg1; i++)
for (var = 0, i = 0; i < numActions; i++)
{
int stringWidth = GetStringWidth(1, str[i].text, 0);
if (stringWidth > var)

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

@ -92,7 +92,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]
@ -105,12 +105,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);
}
}
@ -144,7 +144,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);
}
@ -190,7 +190,7 @@ static void CB2_CheckMail(void)
void ItemUseOutOfBattle_Mail(u8 taskId)
{
gBagMenu->exitCallback = CB2_CheckMail;
gBagMenu->newScreenCallback = CB2_CheckMail;
Task_FadeAndCloseBagMenu(taskId);
}
@ -615,7 +615,7 @@ void ItemUseOutOfBattle_PokeblockCase(u8 taskId)
}
else if (gTasks[taskId].tUsingRegisteredKeyItem != TRUE)
{
gBagMenu->exitCallback = CB2_OpenPokeblockFromBag;
gBagMenu->newScreenCallback = CB2_OpenPokeblockFromBag;
Task_FadeAndCloseBagMenu(taskId);
}
else
@ -648,7 +648,7 @@ void ItemUseOutOfBattle_CoinCase(u8 taskId)
if (!gTasks[taskId].tUsingRegisteredKeyItem)
{
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage);
}
else
{
@ -663,7 +663,7 @@ void ItemUseOutOfBattle_PowderJar(u8 taskId)
if (!gTasks[taskId].tUsingRegisteredKeyItem)
{
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage);
}
else
{
@ -677,7 +677,7 @@ void ItemUseOutOfBattle_Berry(u8 taskId)
{
sItemUseOnFieldCB = ItemUseOnFieldCB_Berry;
gFieldCallback = FieldCB_UseItemOnField;
gBagMenu->exitCallback = CB2_ReturnToField;
gBagMenu->newScreenCallback = CB2_ReturnToField;
Task_FadeAndCloseBagMenu(taskId);
}
else
@ -802,7 +802,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)
@ -819,7 +819,7 @@ static void RemoveUsedItem(void)
if (!InBattlePyramid())
{
UpdatePocketItemList(ItemId_GetPocket(gSpecialVar_ItemId));
SetInitialScrollAndCursorPositions(ItemId_GetPocket(gSpecialVar_ItemId));
UpdatePocketListPosition(ItemId_GetPocket(gSpecialVar_ItemId));
}
else
{
@ -833,7 +833,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);
}
@ -857,7 +857,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);
}
@ -869,7 +869,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);
}
@ -944,7 +944,7 @@ void ItemUseInBattle_PokeBall(u8 taskId)
static const u8 textCantThrowPokeBall[] = _("Cannot throw a ball!\nThere are two pokemon out there!\p");
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, textCantThrowPokeBall, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, textCantThrowPokeBall, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, textCantThrowPokeBall, Task_CloseBattlePyramidBagMessage);
}
@ -954,7 +954,7 @@ void ItemUseInBattle_PokeBall(u8 taskId)
static const u8 textCantThrowPokeBall[] = _("Cannot throw a ball!\p");
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, textCantThrowPokeBall, BagMenu_InitListsMenu);
DisplayItemMessage(taskId, 1, textCantThrowPokeBall, CloseItemMessage);
else
DisplayItemMessageInBattlePyramid(taskId, textCantThrowPokeBall, Task_CloseBattlePyramidBagMessage);
}
@ -969,7 +969,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);
}
@ -1007,7 +1007,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);
}
@ -1022,12 +1022,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

@ -906,7 +906,6 @@ void CgbSound(void)
{
s32 ch;
struct CgbChannel *channels;
s32 envelopeStepTimeAndDir;
s32 prevC15;
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
vu8 *nrx0ptr;
@ -914,6 +913,7 @@ void CgbSound(void)
vu8 *nrx2ptr;
vu8 *nrx3ptr;
vu8 *nrx4ptr;
s32 envelopeStepTimeAndDir;
// Most comparision operations that cast to s8 perform 'and' by 0xFF.
int mask = 0xff;
@ -1198,8 +1198,8 @@ void CgbSound(void)
}
else
{
envelopeStepTimeAndDir &= 0xf;
*nrx2ptr = (channels->envelopeVolume << 4) + envelopeStepTimeAndDir;
u32 envMask = 0xF;
*nrx2ptr = (envelopeStepTimeAndDir & envMask) + (channels->envelopeVolume << 4);
*nrx4ptr = channels->n4 | 0x80;
if (ch == 1 && !(*nrx0ptr & 0x08))
*nrx4ptr = channels->n4 | 0x80;

View File

@ -1098,32 +1098,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;
@ -1141,7 +1141,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);
@ -1150,9 +1150,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)
@ -1225,7 +1225,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;
@ -1233,18 +1233,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;
@ -1263,7 +1263,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;
@ -1276,9 +1276,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)
@ -1598,19 +1598,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;
@ -1628,7 +1628,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);
@ -1662,19 +1662,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;
@ -1693,7 +1693,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;
@ -323,66 +325,72 @@ bool8 MenuHelpers_CallLinkSomething(void)
return TRUE;
}
void sub_812220C(struct ItemSlot *slots, u8 count, u8 *arg2, u8 *usedSlotsCount, u8 maxUsedSlotsCount)
void SetItemListPerPageCount(struct ItemSlot *slots, u8 slotsCount, u8 *pageItems, u8 *totalItems, u8 maxPerPage)
{
u16 i;
struct ItemSlot *slots_ = slots;
(*usedSlotsCount) = 0;
for (i = 0; i < count; i++)
// Count the number of non-empty item slots
*totalItems = 0;
for (i = 0; i < slotsCount; i++)
{
if (slots_[i].itemId != ITEM_NONE)
(*usedSlotsCount)++;
(*totalItems)++;
}
(*totalItems)++; // + 1 for 'Cancel'
(*usedSlotsCount)++;
if ((*usedSlotsCount) > maxUsedSlotsCount)
*arg2 = maxUsedSlotsCount;
// Set number of items per page
if (*totalItems > maxPerPage)
*pageItems = maxPerPage;
else
*arg2 = (*usedSlotsCount);
*pageItems = *totalItems;
}
void sub_812225C(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 numItems)
void SetCursorWithinListBounds(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 totalItems)
{
if (*scrollOffset != 0 && *scrollOffset + maxShownItems > numItems)
*scrollOffset = numItems - maxShownItems;
if (*scrollOffset != 0 && *scrollOffset + maxShownItems > totalItems)
*scrollOffset = totalItems - maxShownItems;
if (*scrollOffset + *cursorPos >= numItems)
if (*scrollOffset + *cursorPos >= totalItems)
{
if (numItems == 0)
if (totalItems == 0)
*cursorPos = 0;
else
*cursorPos = numItems - 1;
*cursorPos = totalItems - 1;
}
}
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

@ -28,10 +28,10 @@
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
EWRAM_DATA static u8 sUnknown_0203CF48[3] = {0};
EWRAM_DATA static struct ListMenuItem *sUnknown_0203CF4C = NULL;
EWRAM_DATA static u8 sMailboxWindowIds[MAILBOXWIN_COUNT] = {0};
EWRAM_DATA static struct ListMenuItem *sMailboxList = NULL;
static void sub_81D1E7C(s32 itemIndex, bool8 onInit, struct ListMenu *list);
static void MailboxMenu_MoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list);
static void sub_81D24A4(struct ConditionGraph *a0);
static void sub_81D2634(struct ConditionGraph *a0);
static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list);
@ -40,33 +40,33 @@ static void SetNextConditionSparkle(struct Sprite *sprite);
static void SpriteCB_ConditionSparkle(struct Sprite *sprite);
static void ShowAllConditionSparkles(struct Sprite *sprite);
static const struct WindowTemplate sUnknown_086253E8[] =
static const struct WindowTemplate sWindowTemplates_MailboxMenu[MAILBOXWIN_COUNT] =
{
{
[MAILBOXWIN_TITLE] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
.width = 8,
.height = 2,
.paletteNum = 0xF,
.paletteNum = 15,
.baseBlock = 0x8
},
{
[MAILBOXWIN_LIST] = {
.bg = 0,
.tilemapLeft = 21,
.tilemapTop = 1,
.width = 8,
.height = 18,
.paletteNum = 0xF,
.paletteNum = 15,
.baseBlock = 0x18
},
{
[MAILBOXWIN_OPTIONS] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
.width = 11,
.height = 8,
.paletteNum = 0xF,
.paletteNum = 15,
.baseBlock = 0x18
}
};
@ -207,53 +207,55 @@ static const struct ListMenuTemplate sMoveRelearnerMovesListTemplate =
.cursorKind = 0
};
bool8 sub_81D1C44(u8 count)
bool8 MailboxMenu_Alloc(u8 count)
{
u8 i;
sUnknown_0203CF4C = Alloc(count * sizeof(*sUnknown_0203CF4C) + sizeof(*sUnknown_0203CF4C));
if (sUnknown_0203CF4C == NULL)
// + 1 to count for 'Cancel'
sMailboxList = Alloc((count + 1) * sizeof(*sMailboxList));
if (sMailboxList == NULL)
return FALSE;
for (i = 0; i < ARRAY_COUNT(sUnknown_0203CF48); i++)
sUnknown_0203CF48[i] = WINDOW_NONE;
for (i = 0; i < ARRAY_COUNT(sMailboxWindowIds); i++)
sMailboxWindowIds[i] = WINDOW_NONE;
return TRUE;
}
u8 sub_81D1C84(u8 a0)
u8 MailboxMenu_AddWindow(u8 windowIdx)
{
if (sUnknown_0203CF48[a0] == WINDOW_NONE)
if (sMailboxWindowIds[windowIdx] == WINDOW_NONE)
{
if (a0 == 2)
if (windowIdx == MAILBOXWIN_OPTIONS)
{
struct WindowTemplate template = sUnknown_086253E8[2];
struct WindowTemplate template = sWindowTemplates_MailboxMenu[windowIdx];
template.width = GetMaxWidthInMenuTable(&gMailboxMailOptions[0], 4);
sUnknown_0203CF48[2] = AddWindow(&template);
sMailboxWindowIds[windowIdx] = AddWindow(&template);
}
else
else // MAILBOXWIN_TITLE or MAILBOXWIN_LIST
{
sUnknown_0203CF48[a0] = AddWindow(&sUnknown_086253E8[a0]);
sMailboxWindowIds[windowIdx] = AddWindow(&sWindowTemplates_MailboxMenu[windowIdx]);
}
SetStandardWindowBorderStyle(sUnknown_0203CF48[a0], 0);
SetStandardWindowBorderStyle(sMailboxWindowIds[windowIdx], 0);
}
return sUnknown_0203CF48[a0];
return sMailboxWindowIds[windowIdx];
}
void sub_81D1D04(u8 a0)
void MailboxMenu_RemoveWindow(u8 windowIdx)
{
ClearStdWindowAndFrameToTransparent(sUnknown_0203CF48[a0], 0);
ClearWindowTilemap(sUnknown_0203CF48[a0]);
RemoveWindow(sUnknown_0203CF48[a0]);
sUnknown_0203CF48[a0] = WINDOW_NONE;
ClearStdWindowAndFrameToTransparent(sMailboxWindowIds[windowIdx], 0);
ClearWindowTilemap(sMailboxWindowIds[windowIdx]);
RemoveWindow(sMailboxWindowIds[windowIdx]);
sMailboxWindowIds[windowIdx] = WINDOW_NONE;
}
static u8 sub_81D1D34(u8 a0)
// Unused
static u8 MailboxMenu_GetWindowId(u8 windowIdx)
{
return sUnknown_0203CF48[a0];
return sMailboxWindowIds[windowIdx];
}
static void sub_81D1D44(u8 windowId, u32 itemId, u8 y)
static void MailboxMenu_ItemPrintFunc(u8 windowId, u32 itemId, u8 y)
{
u8 buffer[30];
u16 length;
@ -269,21 +271,21 @@ static void sub_81D1D44(u8 windowId, u32 itemId, u8 y)
AddTextPrinterParameterized4(windowId, 1, 8, y, 0, 0, sPlayerNameTextColors, -1, buffer);
}
u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page)
u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page)
{
u16 i;
for (i = 0; i < page->count; i++)
{
sUnknown_0203CF4C[i].name = sEmptyItemName;
sUnknown_0203CF4C[i].id = i;
sMailboxList[i].name = sEmptyItemName;
sMailboxList[i].id = i;
}
sUnknown_0203CF4C[i].name = gText_Cancel2;
sUnknown_0203CF4C[i].id = LIST_CANCEL;
sMailboxList[i].name = gText_Cancel2;
sMailboxList[i].id = LIST_CANCEL;
gMultiuseListMenuTemplate.items = sUnknown_0203CF4C;
gMultiuseListMenuTemplate.items = sMailboxList;
gMultiuseListMenuTemplate.totalItems = page->count + 1;
gMultiuseListMenuTemplate.windowId = sUnknown_0203CF48[1];
gMultiuseListMenuTemplate.windowId = sMailboxWindowIds[MAILBOXWIN_LIST];
gMultiuseListMenuTemplate.header_X = 0;
gMultiuseListMenuTemplate.item_X = 8;
gMultiuseListMenuTemplate.cursor_X = 0;
@ -292,8 +294,8 @@ u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page)
gMultiuseListMenuTemplate.cursorPal = 2;
gMultiuseListMenuTemplate.fillValue = 1;
gMultiuseListMenuTemplate.cursorShadowPal = 3;
gMultiuseListMenuTemplate.moveCursorFunc = sub_81D1E7C;
gMultiuseListMenuTemplate.itemPrintFunc = sub_81D1D44;
gMultiuseListMenuTemplate.moveCursorFunc = MailboxMenu_MoveCursorFunc;
gMultiuseListMenuTemplate.itemPrintFunc = MailboxMenu_ItemPrintFunc;
gMultiuseListMenuTemplate.fontId = 1;
gMultiuseListMenuTemplate.cursorKind = 0;
gMultiuseListMenuTemplate.lettersSpacing = 0;
@ -302,20 +304,20 @@ u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page)
return ListMenuInit(&gMultiuseListMenuTemplate, page->itemsAbove, page->cursorPos);
}
static void sub_81D1E7C(s32 itemIndex, bool8 onInit, struct ListMenu *list)
static void MailboxMenu_MoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list)
{
if (onInit != TRUE)
PlaySE(SE_SELECT);
}
void sub_81D1E90(struct PlayerPCItemPageStruct *page)
void MailboxMenu_AddScrollArrows(struct PlayerPCItemPageStruct *page)
{
page->scrollIndicatorTaskId = AddScrollIndicatorArrowPairParameterized(2, 0xC8, 12, 0x94, page->count - page->pageItems + 1, 0x6E, 0x6E, &page->itemsAbove);
}
void sub_81D1EC0(void)
void MailboxMenu_Free(void)
{
Free(sUnknown_0203CF4C);
Free(sMailboxList);
}
void InitConditionGraphData(struct ConditionGraph *graph)

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)
@ -5475,7 +5475,7 @@ static void TryGiveMailToSelectedMon(u8 taskId)
struct MailStruct *mail;
gPartyMenuUseExitCallback = FALSE;
mail = &gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos];
mail = &gSaveBlock1Ptr->mail[gPlayerPCItemPageInfo.itemsAbove + PARTY_SIZE + gPlayerPCItemPageInfo.cursorPos];
if (GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE)
{
DisplayPartyMenuMessage(gText_PkmnHoldingItemCantHoldMail, TRUE);

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,12 @@
#define FLYDESTICON_RED_OUTLINE 6
enum {
TAG_CURSOR,
TAG_PLAYER_ICON,
TAG_FLY_ICON,
};
// Static type declarations
struct MultiNameFlyDest
@ -237,13 +243,13 @@ static const union AnimCmd *const sRegionMapCursorAnimTable[] =
static const struct SpritePalette sRegionMapCursorSpritePalette =
{
.data = sRegionMapCursorPal,
.tag = 0
.tag = TAG_CURSOR
};
static const struct SpriteTemplate sRegionMapCursorSpriteTemplate =
{
.tileTag = 0,
.paletteTag = 0,
.tileTag = TAG_CURSOR,
.paletteTag = TAG_CURSOR,
.oam = &sRegionMapCursorOam,
.anims = sRegionMapCursorAnimTable,
.images = NULL,
@ -419,7 +425,7 @@ static const struct WindowTemplate sFlyMapWindowTemplates[] =
static const struct SpritePalette sFlyTargetIconsSpritePalette =
{
.data = sFlyTargetIcons_Pal,
.tag = 2
.tag = TAG_FLY_ICON
};
static const u16 sRedOutlineFlyDestinations[][2] =
@ -497,8 +503,8 @@ static const union AnimCmd *const sFlyDestIcon_Anims[] =
static const struct SpriteTemplate sFlyDestIconSpriteTemplate =
{
.tileTag = 2,
.paletteTag = 2,
.tileTag = TAG_FLY_ICON,
.paletteTag = TAG_FLY_ICON,
.oam = &sFlyDestIcon_OamData,
.anims = sFlyDestIcon_Anims,
.images = NULL,
@ -1692,8 +1698,8 @@ void CB2_OpenFlyMap(void)
break;
case 4:
InitRegionMap(&sFlyMap->regionMap, FALSE);
CreateRegionMapCursor(0, 0);
CreateRegionMapPlayerIcon(1, 1);
CreateRegionMapCursor(TAG_CURSOR, TAG_CURSOR);
CreateRegionMapPlayerIcon(TAG_PLAYER_ICON, TAG_PLAYER_ICON);
sFlyMap->mapSecId = sFlyMap->regionMap.mapSecId;
StringFill(sFlyMap->nameBuffer, CHAR_SPACE, MAP_NAME_LENGTH);
sDrawFlyDestTextWindow = TRUE;
@ -1827,7 +1833,7 @@ static void LoadFlyDestIcons(void)
LZ77UnCompWram(sFlyTargetIcons_Gfx, sFlyMap->tileBuffer);
sheet.data = sFlyMap->tileBuffer;
sheet.size = sizeof(sFlyMap->tileBuffer);
sheet.tag = 2;
sheet.tag = TAG_FLY_ICON;
LoadSpriteSheet(&sheet);
LoadSpritePalette(&sFlyTargetIconsSpritePalette);
CreateFlyDestIcons();

View File

@ -1074,7 +1074,7 @@ void DeleteRegistry_Yes_Callback(u8 taskId)
DestroyListMenuTask(tListTaskId, &tScrollOffset, &tSelectedRow);
gSaveBlock1Ptr->secretBases[tSelectedBaseId].registryStatus = UNREGISTERED;
BuildRegistryMenuItems(taskId);
sub_812225C(&tScrollOffset, &tSelectedRow, tMaxShownItems, tNumBases);
SetCursorWithinListBounds(&tScrollOffset, &tSelectedRow, tMaxShownItems, tNumBases);
FinalizeRegistryMenu(taskId);
gTasks[taskId].func = HandleRegistryMenuInput;
}

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}”");