From 74edaed4265cc7e964a5383c3e0fb8ef256f2bf8 Mon Sep 17 00:00:00 2001 From: Sierraffinity Date: Thu, 14 May 2020 01:37:09 -0700 Subject: [PATCH] Begin item_menu.c cleanup --- include/constants/item.h | 4 + include/item_menu.h | 70 +-- include/item_menu_icons.h | 2 +- include/menu.h | 8 +- include/menu_helpers.h | 4 +- src/battle_controller_player.c | 2 +- src/battle_pyramid_bag.c | 46 +- src/berry_crush.c | 6 +- src/berry_tag_screen.c | 22 +- src/cable_car.c | 6 +- src/decoration.c | 6 +- src/diploma.c | 6 +- src/dodrio_berry_picking.c | 8 +- src/egg_hatch.c | 2 +- src/field_camera.c | 6 +- src/field_region_map.c | 4 +- src/field_screen_effect.c | 2 +- src/field_specials.c | 2 +- src/fieldmap.c | 2 +- src/fldeff_softboiled.c | 4 +- src/frontier_pass.c | 14 +- src/hall_of_fame.c | 6 +- src/item_menu.c | 781 ++++++++++++++++++--------------- src/item_menu_icons.c | 8 +- src/item_use.c | 12 +- src/link.c | 2 +- src/mail.c | 8 +- src/match_call.c | 4 +- src/menu.c | 8 +- src/menu_helpers.c | 6 +- src/menu_specialized.c | 2 +- src/mevent_801BAAC.c | 8 +- src/move_relearner.c | 2 +- src/overworld.c | 14 +- src/party_menu.c | 104 ++--- src/player_pc.c | 30 +- src/pokeblock.c | 40 +- src/pokeblock_feed.c | 14 +- src/pokedex_area_region_map.c | 10 +- src/pokedex_area_screen.c | 4 +- src/pokemon_jump.c | 16 +- src/pokemon_storage_system.c | 30 +- src/pokemon_summary_screen.c | 100 ++--- src/pokenav_conditions_2.c | 12 +- src/pokenav_conditions_3.c | 8 +- src/pokenav_main_menu.c | 6 +- src/pokenav_match_call_2.c | 10 +- src/pokenav_menu_handler_2.c | 16 +- src/pokenav_region_map.c | 4 +- src/pokenav_ribbons_1.c | 8 +- src/pokenav_ribbons_2.c | 12 +- src/rayquaza_scene.c | 76 ++-- src/region_map.c | 16 +- src/reset_rtc_screen.c | 10 +- src/roulette.c | 8 +- src/script_menu.c | 4 +- src/secret_base.c | 10 +- src/shop.c | 20 +- src/starter_choose.c | 8 +- src/trader.c | 4 +- src/union_room_battle.c | 2 +- src/union_room_chat.c | 8 +- src/wallclock.c | 6 +- 63 files changed, 885 insertions(+), 798 deletions(-) diff --git a/include/constants/item.h b/include/constants/item.h index a5c34418d..3277f2379 100644 --- a/include/constants/item.h +++ b/include/constants/item.h @@ -16,5 +16,9 @@ #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 diff --git a/include/item_menu.h b/include/item_menu.h index 089bff6cf..9930ccd4f 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -4,19 +4,35 @@ #include "item.h" #include "menu_helpers.h" -#define RETURN_LOCATION_FIELD 0 -#define RETURN_LOCATION_BATTLE 1 -#define RETURN_LOCATION_POKEMON_LIST 2 -#define RETURN_LOCATION_SHOP 3 -#define RETURN_LOCATION_FIELD_2 4 -#define RETURN_LOCATION_FIELD_3 5 -#define RETURN_LOCATION_PC 6 -#define RETURN_LOCATION_FIELD_4 7 -#define RETURN_LOCATION_FIELD_5 8 -#define RETURN_LOCATION_FIELD_6 9 -#define RETURN_LOCATION_BATTLE_2 10 -#define RETURN_LOCATION_PC_2 11 -#define RETURN_LOCATION_UNCHANGED 12 +#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 + +#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 // Exported type declarations struct BagStruct @@ -33,29 +49,27 @@ extern struct BagStruct gBagPositionStruct; struct BagMenuStruct { - void (*mainCallback2)(void); + void (*exitCallback)(void); u8 tilemapBuffer[0x800]; u8 spriteId[12]; u8 windowPointers[7]; u8 unk817; u8 unk818; u8 unk819; - u8 unk81A; - u8 unk81B:4; - u8 unk81B_1:2; - u8 unk81B_3:1; + u8 itemOriginalLocation; + u8 pocketSwitchDisabled:4; + u8 itemIconSlot:2; + u8 inhibitItemDescriptionPrint:1; u8 hideCloseBagText:1; u8 filler3[2]; - u8 unk81E; - u8 unk81F; - const u8* unk820; - u8 unk824; - u8 unk825; - u8 filler[2]; - u8 unk828; + u8 pocketScrollArrowsTask; + u8 pocketSwitchArrowsTask; + const u8* contextMenuItemsPtr; + u8 contextMenuItemsBuffer[4]; + u8 contextMenuNumItems; u8 numItemStacks[POCKETS_COUNT]; u8 numShownItems[6]; - s16 unk834; + s16 graphicsLoadState; u8 filler4[0xE]; u8 pocketNameBuffer[32][32]; u8 filler2[4]; @@ -68,11 +82,11 @@ extern struct BagMenuStruct *gBagMenu; extern u16 gSpecialVar_ItemId; // Exported ROM declarations -void sub_81AAC14(void); +void CB2_GoToItemDepositMenu(void); void FavorLadyOpenBagMenu(void); void QuizLadyOpenBagMenu(void); void ApprenticeOpenBagMenu(void); -void sub_81AABB0(void); +void CB2_BagMenuFromBattle(void); void SetInitialScrollAndCursorPositions(u8 pocketId); void CB2_ReturnToBagMenuPocket(void); void CB2_BagMenuFromStartMenu(void); diff --git a/include/item_menu_icons.h b/include/item_menu_icons.h index 50f0d5544..75e9100d2 100644 --- a/include/item_menu_icons.h +++ b/include/item_menu_icons.h @@ -10,7 +10,7 @@ extern const struct CompressedSpritePalette gBerryCheckCirclePaletteTable; void RemoveBagSprite(u8 id); void AddBagVisualSprite(u8 bagPocketId); void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets); -void ShakeBagVisual(void); +void ShakeBagSprite(void); void AddSwitchPocketRotatingBallSprite(s16 rotationDirection); void AddBagItemIconSprite(u16 itemId, u8 id); void RemoveBagItemIconSprite(u8 id); diff --git a/include/menu.h b/include/menu.h index d4a038920..1f4d63284 100644 --- a/include/menu.h +++ b/include/menu.h @@ -49,16 +49,16 @@ void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram); void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 palNum, u16 baseBlock); void DrawStdFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileStart, u8 palette); -void schedule_bg_copy_tilemap_to_vram(u8 bgNum); +void ScheduleBgCopyTilemapToVram(u8 bgNum); void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *strs); u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 numItems, u8 initialCursorPos); u8 Menu_GetCursorPos(void); s8 Menu_ProcessInput(void); s8 Menu_ProcessInputNoWrap(void); void blit_move_info_icon(u8 winId, u8 a2, u16 x, u16 y); -void reset_temp_tile_data_buffers(void); -void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode); -bool8 free_temp_tile_data_buffers_if_possible(void); +void ResetTempTileDataBuffers(void); +void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode); +bool8 FreeTempTileDataBuffersIfPossible(void); struct WindowTemplate CreateWindowTemplate(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock); void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos); void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, u32 size, u16 offset, u8 mode); diff --git a/include/menu_helpers.h b/include/menu_helpers.h index 442f4a063..4557ebbb1 100644 --- a/include/menu_helpers.h +++ b/include/menu_helpers.h @@ -30,8 +30,8 @@ u8 GetLRKeysPressed(void); u8 GetLRKeysPressedAndHeld(void); bool8 sub_8122148(u16 itemId); bool8 itemid_80BF6D8_mail_related(u16 itemId); -bool8 sub_81221AC(void); -bool8 sub_81221EC(void); +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); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 7fe1ed24a..6dd9cd2f4 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -1361,7 +1361,7 @@ static void OpenBagAndChooseItem(void) gBattlerControllerFuncs[gActiveBattler] = CompleteWhenChoseItem; nullsub_35(); FreeAllWindowBuffers(); - sub_81AABB0(); + CB2_BagMenuFromBattle(); } } diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 7c650800b..5626dd7bc 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -415,7 +415,7 @@ static void sub_81C5038(void) static void sub_81C504C(void) { - while (sub_81221EC() != TRUE && sub_81C5078() != TRUE && sub_81221AC() != TRUE); + while (MenuHelpers_CallLinkSomething() != TRUE && sub_81C5078() != TRUE && MenuHelpers_LinkSomething() != TRUE); } static bool8 sub_81C5078(void) @@ -445,7 +445,7 @@ static bool8 sub_81C5078(void) gMain.state++; break; case 5: - if (!sub_81221AC()) + if (!MenuHelpers_LinkSomething()) { ResetTasks(); } @@ -516,7 +516,7 @@ static void sub_81C51DC(void) InitBgsFromTemplates(0, gUnknown_0861F2B4, ARRAY_COUNT(gUnknown_0861F2B4)); SetBgTilemapBuffer(2, gPyramidBagResources->tilemapBuffer); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); @@ -531,12 +531,12 @@ static bool8 sub_81C5238(void) switch (gPyramidBagResources->state) { case 0: - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(2, gBagScreen_Gfx, 0, 0, 0); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(2, gBagScreen_Gfx, 0, 0, 0); gPyramidBagResources->state++; break; case 1: - if (free_temp_tile_data_buffers_if_possible() != TRUE) + if (FreeTempTileDataBuffersIfPossible() != TRUE) { LZDecompressWram(gBattleFrontierGfx_PyramidBagTileMap, gPyramidBagResources->tilemapBuffer); gPyramidBagResources->state++; @@ -837,7 +837,7 @@ static void sub_81C5B4C(u8 taskId) static void Task_HandlePyramidBagInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (sub_81221EC() != TRUE && !gPaletteFade.active) + if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) { if (gMain.newKeys & SELECT_BUTTON) { @@ -940,7 +940,7 @@ static void sub_81C5F08(u8 windowId, u8 horizontalCount, u8 verticalCount) static void HandleFewMenuActionsInput(u8 taskId) { - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { s32 id = Menu_ProcessInputNoWrap(); switch (id) @@ -962,7 +962,7 @@ static void HandleFewMenuActionsInput(u8 taskId) static void HandleMenuActionInput(u8 taskId) { - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { s8 id = Menu_GetCursorPos(); if (gMain.newKeys & DPAD_UP) @@ -1049,7 +1049,7 @@ static void BagAction_UseOnField(u8 taskId) { sub_81C61A8(); FillWindowPixelBuffer(1, PIXEL_FILL(0)); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); ItemId_GetFieldFunc(gSpecialVar_ItemId)(taskId); } } @@ -1060,8 +1060,8 @@ static void BagAction_Cancel(u8 taskId) sub_81C61A8(); PrintItemDescription(data[1]); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); sub_81C5A98(data[0], 0); SetTaskToMainPyramidBagInputHandler(taskId); } @@ -1148,7 +1148,7 @@ static void sub_81C64B4(u8 taskId) PlaySE(SE_SELECT); ClearStdWindowAndFrameToTransparent(3, 0); ClearWindowTilemap(3); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); sub_81C6350(taskId); } else if (gMain.newKeys & B_BUTTON) @@ -1156,7 +1156,7 @@ static void sub_81C64B4(u8 taskId) PlaySE(SE_SELECT); ClearStdWindowAndFrameToTransparent(3, 0); ClearWindowTilemap(3); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); DontTossItem(taskId); } } @@ -1188,7 +1188,7 @@ static void sub_81C65CC(u8 taskId) sub_81C59BC(); SetBagItemsListTemplate(); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollOffset, *selectedRow); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); SetTaskToMainPyramidBagInputHandler(taskId); } } @@ -1275,7 +1275,7 @@ static void Task_BeginItemSwap(u8 taskId) static void Task_ItemSwapHandleInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { if (gMain.newKeys & SELECT_BUTTON) { @@ -1400,8 +1400,8 @@ static void sub_81C6BD8(void) PutWindowTilemap(0); PutWindowTilemap(1); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); } static void PrintOnWindow_Font1(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId) @@ -1417,7 +1417,7 @@ static void PrintOnWindow_Font7(u8 windowId, const u8 *src, u8 x, u8 y, u8 lette static void sub_81C6CEC(u8 windowId) { DrawStdFrameWithCustomTileAndPalette(windowId, 0, 1, 0xE); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } static u8 sub_81C6D08(u8 windowArrayId) @@ -1432,7 +1432,7 @@ static u8 sub_81C6D24(u8 windowArrayId) { *windowId = AddWindow(&gUnknown_0861F350[windowArrayId]); DrawStdFrameWithCustomTileAndPalette(*windowId, FALSE, 1, 0xE); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } return *windowId; } @@ -1445,7 +1445,7 @@ static void sub_81C6D6C(u8 windowArrayId) ClearStdWindowAndFrameToTransparent(*windowId, FALSE); ClearWindowTilemap(*windowId); RemoveWindow(*windowId); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); *windowId = 0xFF; } } @@ -1459,7 +1459,7 @@ void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback { FillWindowPixelBuffer(2, PIXEL_FILL(1)); DisplayMessageAndContinueTask(taskId, 2, 0xA, 0xD, 1, GetPlayerTextSpeedDelay(), str, callback); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } static void CloseBattlePyramidBagTextWindow(void) @@ -1467,7 +1467,7 @@ static void CloseBattlePyramidBagTextWindow(void) ClearDialogWindowAndFrameToTransparent(2, FALSE); // This ClearWindowTilemap call is redundant, since ClearDialogWindowAndFrameToTransparent already calls it. ClearWindowTilemap(2); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } #define ITEM_IMAGE_TAG 0x1024 diff --git a/src/berry_crush.c b/src/berry_crush.c index 383d273c4..48e4ac4c3 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -1031,7 +1031,7 @@ int sub_802104C(void) SetHBlankCallback(NULL); SetGpuReg(REG_OFFSET_DISPCNT, 0); ScanlineEffect_Stop(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); break; case 1: CpuFill16(0, (void *)OAM, OAM_SIZE); @@ -1069,10 +1069,10 @@ int sub_802104C(void) CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); - decompress_and_copy_tile_data_to_vram(1, gUnknown_08DE34B8, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gUnknown_08DE34B8, 0, 0, 0); break; case 6: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return 0; InitStandardTextBoxWindows(); diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index 89175c1bf..38c2832ee 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -201,11 +201,11 @@ static void CB2_InitBerryTagScreen(void) { while (1) { - if (sub_81221EC() == TRUE) + if (MenuHelpers_CallLinkSomething() == TRUE) break; if (InitBerryTagScreen() == TRUE) break; - if (sub_81221AC() == TRUE) + if (MenuHelpers_LinkSomething() == TRUE) break; } } @@ -238,7 +238,7 @@ static bool8 InitBerryTagScreen(void) gMain.state++; break; case 5: - if (!sub_81221AC()) + if (!MenuHelpers_LinkSomething()) ResetTasks(); gMain.state++; break; @@ -301,8 +301,8 @@ static void HandleInitBackgrounds(void) SetBgTilemapBuffer(2, sBerryTag->tilemapBuffers[0]); SetBgTilemapBuffer(3, sBerryTag->tilemapBuffers[1]); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(2); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(2); + ScheduleBgCopyTilemapToVram(3); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); SetGpuReg(REG_OFFSET_BLDCNT, 0); ShowBg(0); @@ -318,12 +318,12 @@ static bool8 LoadBerryTagGfx(void) switch (sBerryTag->gfxState) { case 0: - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(2, gBerryCheck_Gfx, 0, 0, 0); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(2, gBerryCheck_Gfx, 0, 0, 0); sBerryTag->gfxState++; break; case 1: - if (free_temp_tile_data_buffers_if_possible() != TRUE) + if (FreeTempTileDataBuffersIfPossible() != TRUE) { LZDecompressWram(gBerryTag_Gfx, sBerryTag->tilemapBuffers[0]); sBerryTag->gfxState++; @@ -371,8 +371,8 @@ static void HandleInitWindows(void) LoadPalette(sFontPalette, 0xF0, 0x20); for (i = 0; i < ARRAY_COUNT(sWindowTemplates) - 1; i++) PutWindowTilemap(i); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); } static void PrintTextInBerryTagScreen(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed, u8 colorStructId) @@ -386,7 +386,7 @@ static void AddBerryTagTextToBg0(void) FillWindowPixelBuffer(WIN_BERRY_TAG, PIXEL_FILL(15)); PrintTextInBerryTagScreen(WIN_BERRY_TAG, gText_BerryTag, GetStringCenterAlignXOffset(1, gText_BerryTag, 0x40), 1, 0, 1); PutWindowTilemap(WIN_BERRY_TAG); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void PrintAllBerryData(void) diff --git a/src/cable_car.c b/src/cable_car.c index 00eedfdae..94d9d0c66 100644 --- a/src/cable_car.c +++ b/src/cable_car.c @@ -265,7 +265,7 @@ static void CableCarMainCallback_Setup(void) ResetTasks(); FreeAllSpritePalettes(); ResetPaletteFade(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); StartWeather(); for (i = 0; i < 20; i++) gWeatherPtr->sprites.s2.ashSprites[i] = NULL; @@ -291,11 +291,11 @@ static void CableCarMainCallback_Setup(void) sCableCar->mountainTilemap = malloc_and_decompress(gCableCarMountainTilemap, &sizeOut); sCableCar->pylonStemTilemap = malloc_and_decompress(gCableCarPylonStemTilemap, &sizeOut); sCableCar->pylonHookTilemapEntries = gCableCarPylonHookTilemapEntries; - decompress_and_copy_tile_data_to_vram(0, gUnknown_08DBA5B8, 0, 0, 0); + DecompressAndCopyTileDataToVram(0, gUnknown_08DBA5B8, 0, 0, 0); gMain.state++; break; case 3: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) { LoadPalette(gUnknown_08DBA518, 0, 0x80); gMain.state++; diff --git a/src/decoration.c b/src/decoration.c index c878f397a..f566cc7c9 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -541,7 +541,7 @@ static u8 AddDecorationWindow(u8 windowIndex) } DrawStdFrameWithCustomTileAndPalette(*windowId, FALSE, 0x214, 14); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); return *windowId; } @@ -550,7 +550,7 @@ static void RemoveDecorationWindow(u8 windowIndex) ClearStdWindowAndFrameToTransparent(sDecorMenuWindowIds[windowIndex], FALSE); ClearWindowTilemap(sDecorMenuWindowIds[windowIndex]); RemoveWindow(sDecorMenuWindowIds[windowIndex]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void AddDecorationActionsWindow(void) @@ -729,7 +729,7 @@ static void PrintDecorationCategoryMenuItems(u8 taskId) } AddTextPrinterParameterized(windowId, 1, gTasks[taskId].tDecorationMenuCommand == DECOR_MENU_TRADE ? gText_Exit : gText_Cancel, 8, i * 16 + 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void PrintDecorationCategoryMenuItem(u8 winid, u8 category, u8 x, u8 y, bool8 disabled, u8 speed) diff --git a/src/diploma.c b/src/diploma.c index 3c03c057f..7eb3b0e81 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -76,9 +76,9 @@ void CB2_ShowDiploma(void) sDiplomaTilemapPtr = malloc(0x1000); InitDiplomaBg(); InitDiplomaWindow(); - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(1, &sDiplomaTiles, 0, 0, 0); - while (free_temp_tile_data_buffers_if_possible()) + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(1, &sDiplomaTiles, 0, 0, 0); + while (FreeTempTileDataBuffersIfPossible()) ; LZDecompressWram(sDiplomaTilemap, sDiplomaTilemapPtr); CopyBgTilemapBufferToVram(1); diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 936c1828f..262b7d111 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -4644,16 +4644,16 @@ static bool32 sub_802A8E8(void) LoadPalette(gDodrioBerryBgPal1, 0, sizeof(gDodrioBerryBgPal1)); break; case 1: - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); break; case 2: - decompress_and_copy_tile_data_to_vram(3, gDodrioBerryBgGfx1, 0, 0, 0); + DecompressAndCopyTileDataToVram(3, gDodrioBerryBgGfx1, 0, 0, 0); break; case 3: - decompress_and_copy_tile_data_to_vram(1, gDodrioBerryBgGfx2, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gDodrioBerryBgGfx2, 0, 0, 0); break; case 4: - if (free_temp_tile_data_buffers_if_possible() == TRUE) + if (FreeTempTileDataBuffersIfPossible() == TRUE) return FALSE; break; case 5: diff --git a/src/egg_hatch.c b/src/egg_hatch.c index a6c39f12b..db25dbbb8 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -490,7 +490,7 @@ static void CB2_EggHatch_0(void) SetVBlankCallback(VBlankCB_EggHatch); gSpecialVar_0x8005 = GetCurrentMapMusic(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBgTemplates_EggHatch, ARRAY_COUNT(sBgTemplates_EggHatch)); diff --git a/src/field_camera.c b/src/field_camera.c index c5b32ff3b..038b6932e 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -306,9 +306,9 @@ static void DrawMetatile(s32 metatileLayerType, u16 *metatiles, u16 offset) gBGTilemapBuffers2[offset + 0x21] = metatiles[7]; break; } - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); + ScheduleBgCopyTilemapToVram(3); } static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset *cameraOffset, s32 x, s32 y) diff --git a/src/field_region_map.c b/src/field_region_map.c index 57f95f93e..b442675f3 100644 --- a/src/field_region_map.c +++ b/src/field_region_map.c @@ -153,7 +153,7 @@ static void FieldUpdateRegionMap(void) DrawStdFrameWithCustomTileAndPalette(1, 0, 0x27, 0xd); offset = GetStringCenterAlignXOffset(1, gText_Hoenn, 0x38); AddTextPrinterParameterized(1, 1, gText_Hoenn, offset, 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); DrawStdFrameWithCustomTileAndPalette(0, 0, 0x27, 0xd); PrintRegionMapSecName(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); @@ -208,7 +208,7 @@ static void PrintRegionMapSecName(void) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); AddTextPrinterParameterized(0, 1, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } else { diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index ea9429ce8..51f719fc9 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -1137,7 +1137,7 @@ static void Task_OrbEffect(u8 taskId) SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ); SetBgTilemapPalette(0, 0, 0, 0x1E, 0x14, 0xF); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); SetOrbFlashScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], tCenterX, tCenterY, 1); CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480); ScanlineEffect_SetParams(sFlashEffectParams); diff --git a/src/field_specials.c b/src/field_specials.c index 64beebcc0..818cd70db 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -2642,7 +2642,7 @@ static void Task_ShowScrollableMultichoice(u8 taskId) ScrollableMultichoice_UpdateScrollArrows(taskId); task->tListTaskId = ListMenuInit(&gScrollableMultichoice_ListMenuTemplate, task->tScrollOffset, task->tSelectedRow); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = ScrollableMultichoice_ProcessInput; } diff --git a/src/fieldmap.c b/src/fieldmap.c index 21bbaa8f8..e953e0f93 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -950,7 +950,7 @@ void copy_tileset_patterns_to_vram(struct Tileset const *tileset, u16 numTiles, if (!tileset->isCompressed) LoadBgTiles(2, tileset->tiles, numTiles * 32, offset); else - decompress_and_copy_tile_data_to_vram(2, tileset->tiles, numTiles * 32, offset, 0); + DecompressAndCopyTileDataToVram(2, tileset->tiles, numTiles * 32, offset, 0); } } diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index 1a42b297d..bfa20cdbc 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -76,7 +76,7 @@ static void Task_DisplayHPRestoredMessage(u8 taskId) GetMonNickname(&gPlayerParty[gPartyMenu.slotId2], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); DisplayPartyMenuMessage(gStringVar4, FALSE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_FinishSoftboiled; } @@ -106,6 +106,6 @@ static void CantUseSoftboiledOnMon(u8 taskId) { PlaySE(SE_SELECT); DisplayPartyMenuMessage(gText_CantBeUsedOnPkmn, FALSE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_ChooseNewMonForSoftboiled; } diff --git a/src/frontier_pass.c b/src/frontier_pass.c index 6b38f0607..757205656 100644 --- a/src/frontier_pass.c +++ b/src/frontier_pass.c @@ -698,7 +698,7 @@ static bool32 InitFrontierPass(void) ResetSpriteData(); FreeAllSpritePalettes(); ResetPaletteFade(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); break; case 3: AllocateFrontierPassGfx(); @@ -719,11 +719,11 @@ static bool32 InitFrontierPass(void) sPassGfx->unk20 = malloc_and_decompress(gUnknown_085712F8, &sizeOut); sPassGfx->unk24 = malloc_and_decompress(gUnknown_08571060, &sizeOut); sPassGfx->unk28 = malloc_and_decompress(gUnknown_085712C0, &sizeOut); - decompress_and_copy_tile_data_to_vram(1, gUnknown_08DE08C8, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(2, gUnknown_08DE2084, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gUnknown_08DE08C8, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gUnknown_08DE2084, 0, 0, 0); break; case 7: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return FALSE; FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 30, 20); @@ -1353,7 +1353,7 @@ static bool32 InitFrontierMap(void) ResetSpriteData(); FreeAllSpritePalettes(); ResetPaletteFade(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); break; case 3: ResetBgsAndClearDma3BusyFlags(0); @@ -1372,10 +1372,10 @@ static bool32 InitFrontierMap(void) InitWindows(sMapWindowTemplates); DeactivateAllTextPrinters(); PrintOnFrontierMap(); - decompress_and_copy_tile_data_to_vram(1, gUnknown_0856FBBC, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gUnknown_0856FBBC, 0, 0, 0); break; case 5: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return FALSE; LoadPalette(gUnknown_08DE07C8[0], 0, 0x1A0); LoadPalette(stdpal_get(0), 0xF0, 0x20); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 05e4ed0aa..1606c2de5 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -1255,7 +1255,7 @@ static void sub_8174F70(void) ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); ResetAllPicSprites(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 8; @@ -1282,10 +1282,10 @@ static bool8 sub_8175024(void) switch (sHofGfxPtr->state) { case 0: - decompress_and_copy_tile_data_to_vram(1, sHallOfFame_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, sHallOfFame_Gfx, 0, 0, 0); break; case 1: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return TRUE; break; case 2: diff --git a/src/item_menu.c b/src/item_menu.c index fe381516c..43e657328 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -52,7 +52,7 @@ #include "battle_pike.h" #include "constants/rgb.h" -void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); +void GoToBagMenu(u8 bagMenuType, u8 pocketId, void (*postExitMenuMainCallback2)()); void CB2_Bag(void); bool8 SetupBagMenu(void); void BagMenu_InitBGs(void); @@ -63,12 +63,12 @@ void LoadBagItemListBuffers(u8); void BagMenu_PrintPocketNames(const u8*, const u8*); void BagMenu_CopyPocketNameToWindow(u32); void BagMenu_DrawPocketIndicatorSquare(u8, u8); -void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); -void bag_menu_add_list_scroll_arrow_indicators_maybe(void); +void CreatePocketScrollArrowPair(void); +void CreatePocketSwitchArrowPair(void); void BagMenu_PrepareTMHMMoveWindow(void); bool8 IsWallysBag(void); void Task_WallyTutorialBagMenu(u8); -void Task_BagMenu(u8); +void Task_BagMenu_HandleInput(u8); void GetItemName(s8*, u16); u16 ItemIdToBattleMoveId(u16); u16 BagGetItemIdByPocketPosition(u8, u16); @@ -77,7 +77,7 @@ void BagMenu_PrintCursor(u8, u8); void BagMenu_Print(u8, u8, const u8*, u8, u8, u8, u8, u8, u8); bool8 ItemId_GetImportance(u16); u16 BagGetQuantityByPocketPosition(u8, u16); -void sub_81AB89C(void); +void BagDestroyPocketSwitchArrowPair(void); void TaskCloseBagMenu_2(u8); u8 AddItemMessageWindow(u8); void bag_menu_RemoveBagItem_message_window(u8); @@ -122,13 +122,13 @@ void sub_81ADC0C(u8); void CB2_ApprenticeExitBagMenu(void); void CB2_FavorLadyExitBagMenu(void); void CB2_QuizLadyExitBagMenu(void); -void sub_81ABA6C(void); +void All_CalculateNItemsAndMaxShowed(void); static void SetPocketListPositions(void); -void sub_81ABAE0(void); -u8 sub_81AB1F0(u8); +void UpdatePocketScrollPositions(void); +u8 CreateBagInputHandlerTask(u8); void sub_81AC23C(u8); void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu*); -void PrintItemQuantityPlusGFX(u8 rboxId, s32 item_index_in_pocket, u8 a); +void BagMenu_ItemPrintCallback(u8 windowId, s32 itemIndex, u8 a); void ItemMenu_UseOutOfBattle(u8 taskId); void ItemMenu_Toss(u8 taskId); void ItemMenu_Register(u8 taskId); @@ -140,11 +140,11 @@ void Task_FadeAndCloseBagMenu(u8 taskId); void unknown_ItemMenu_Show(u8 taskId); void unknown_ItemMenu_Give2(u8 taskId); void unknown_ItemMenu_Confirm2(u8 taskId); -void unknown_item_menu_type(u8 taskId); -void item_menu_type_2(u8 taskId); -void DisplaySellItemAskString(u8 taskId); -void DisplayDepositItemAskString(u8 taskId); -void item_menu_type_b(u8 taskId); +void Task_ItemContext_FieldOrBattle(u8 taskId); +void Task_ItemContext_FieldGive(u8 taskId); +void Task_ItemContext_Sell(u8 taskId); +void Task_ItemContext_Deposit(u8 taskId); +void Task_ItemContext_ItemPC_2(u8 taskId); void BagMenu_ConfirmToss(u8 taskId); void BagMenu_CancelToss(u8 taskId); void BagMenu_ConfirmSell(u8 taskId); @@ -152,7 +152,7 @@ void BagMenu_CancelSell(u8 taskId); // .rodata -static const struct BgTemplate sBgTemplates_ItemMenu[3] = +static const struct BgTemplate sBgTemplates_ItemMenu[] = { { .bg = 0, @@ -187,7 +187,7 @@ static const struct ListMenuTemplate sItemListMenu = { .items = NULL, .moveCursorFunc = BagMenu_MoveCursorCallback, - .itemPrintFunc = PrintItemQuantityPlusGFX, + .itemPrintFunc = BagMenu_ItemPrintCallback, .totalItems = 0, .maxShowed = 0, .windowId = 0, @@ -205,59 +205,115 @@ static const struct ListMenuTemplate sItemListMenu = .cursorKind = 0 }; -const struct MenuAction sItemMenuActions[] = { - {gMenuText_Use, ItemMenu_UseOutOfBattle}, - {gMenuText_Toss, ItemMenu_Toss}, - {gMenuText_Register, ItemMenu_Register}, - {gMenuText_Give, ItemMenu_Give}, - {gText_Cancel2, ItemMenu_Cancel}, - {gMenuText_Use, ItemMenu_UseInBattle}, - {gMenuText_Check, ItemMenu_UseOutOfBattle}, - {gMenuText_Walk, ItemMenu_UseOutOfBattle}, - {gMenuText_Deselect, ItemMenu_Register}, - {gMenuText_CheckTag, ItemMenu_CheckTag}, - {gMenuText_Confirm, Task_FadeAndCloseBagMenu}, - {gMenuText_Show, unknown_ItemMenu_Show}, - {gMenuText_Give2, unknown_ItemMenu_Give2}, - {gMenuText_Confirm, unknown_ItemMenu_Confirm2}, - {gText_EmptyString2, NULL} +static const struct MenuAction sItemMenuActions[] = { + [ITEMMENUACTION_USE] = {gMenuText_Use, ItemMenu_UseOutOfBattle}, + [ITEMMENUACTION_TOSS] = {gMenuText_Toss, ItemMenu_Toss}, + [ITEMMENUACTION_REGISTER] = {gMenuText_Register, ItemMenu_Register}, + [ITEMMENUACTION_GIVE] = {gMenuText_Give, ItemMenu_Give}, + [ITEMMENUACTION_CANCEL] = {gText_Cancel2, ItemMenu_Cancel}, + [ITEMMENUACTION_BATTLE_USE] = {gMenuText_Use, ItemMenu_UseInBattle}, + [ITEMMENUACTION_CHECK] = {gMenuText_Check, ItemMenu_UseOutOfBattle}, + [ITEMMENUACTION_WALK] = {gMenuText_Walk, ItemMenu_UseOutOfBattle}, + [ITEMMENUACTION_DESELECT] = {gMenuText_Deselect, ItemMenu_Register}, + [ITEMMENUACTION_CHECK_TAG] = {gMenuText_CheckTag, ItemMenu_CheckTag}, + [ITEMMENUACTION_CONFIRM] = {gMenuText_Confirm, Task_FadeAndCloseBagMenu}, + [ITEMMENUACTION_SHOW] = {gMenuText_Show, unknown_ItemMenu_Show}, + [ITEMMENUACTION_GIVE_2] = {gMenuText_Give2, unknown_ItemMenu_Give2}, + [ITEMMENUACTION_CONFIRM_2] = {gMenuText_Confirm, unknown_ItemMenu_Confirm2}, + [ITEMMENUACTION_DUMMY] = {gText_EmptyString2, NULL} }; -const u8 gUnknown_0861402C[] = {0, 3, 1, 4}; -const u8 gUnknown_08614030[] = {0, 2, 14, 4}; -const u8 gUnknown_08614034[] = {3, 14, 1, 4}; -const u8 gUnknown_08614038[] = {0, 3, 14, 4}; -const u8 gUnknown_0861403C[] = {9, 14, 0, 3, 1, 4}; -const u8 gUnknown_08614042[] = {5, 4}; -const u8 gUnknown_08614044[] = {3, 4}; -const u8 gUnknown_08614046 = 4; -const u8 gUnknown_08614047[] = {10, 9, 14, 4}; -const u8 gUnknown_0861404B[] = {11, 4}; -const u8 gUnknown_0861404D[] = {12, 4}; -const u8 gUnknown_0861404F[] = {13, 4}; - -const TaskFunc gUnknown_08614054[] = { - unknown_item_menu_type, - unknown_item_menu_type, - item_menu_type_2, - DisplaySellItemAskString, - Task_FadeAndCloseBagMenu, - unknown_item_menu_type, - DisplayDepositItemAskString, - unknown_item_menu_type, - unknown_item_menu_type, - unknown_item_menu_type, - NULL, - item_menu_type_b +// these are all 2D arrays with a width of 2 but are represented as 1D arrays +// ITEMMENUACTION_DUMMY is used to represent blank spaces +static const u8 sContextMenuItems_ItemsPocket[] = { + ITEMMENUACTION_USE, ITEMMENUACTION_GIVE, + ITEMMENUACTION_TOSS, ITEMMENUACTION_CANCEL }; -const struct YesNoFuncTable sYesNoTossFunctions = {BagMenu_ConfirmToss, BagMenu_CancelToss}; +static const u8 sContextMenuItems_KeyItemsPocket[] = { + ITEMMENUACTION_USE, ITEMMENUACTION_REGISTER, + ITEMMENUACTION_DUMMY, ITEMMENUACTION_CANCEL +}; -const struct YesNoFuncTable sYesNoSellItemFunctions = {BagMenu_ConfirmSell, BagMenu_CancelSell}; +static const u8 sContextMenuItems_BallsPocket[] = { + ITEMMENUACTION_GIVE, ITEMMENUACTION_DUMMY, + ITEMMENUACTION_TOSS, ITEMMENUACTION_CANCEL +}; -const struct ScrollArrowsTemplate gBagScrollArrowsTemplate = {SCROLL_ARROW_LEFT, 0x1C, 16, SCROLL_ARROW_RIGHT, 100, 16, -1, -1, 0x6F, 0x6F, 0}; +static const u8 sContextMenuItems_TmHmPocket[] = { + ITEMMENUACTION_USE, ITEMMENUACTION_GIVE, + ITEMMENUACTION_DUMMY, ITEMMENUACTION_CANCEL +}; -const u8 gRegisteredSelect_Gfx[] = INCBIN_U8("graphics/interface/select_button.4bpp"); +static const u8 sContextMenuItems_BerriesPocket[] = { + ITEMMENUACTION_CHECK_TAG, ITEMMENUACTION_DUMMY, + ITEMMENUACTION_USE, ITEMMENUACTION_GIVE, + ITEMMENUACTION_TOSS, ITEMMENUACTION_CANCEL +}; + +static const u8 sContextMenuItems_BattleUse[] = { + ITEMMENUACTION_BATTLE_USE, ITEMMENUACTION_CANCEL +}; + +static const u8 sContextMenuItems_Give[] = { + ITEMMENUACTION_GIVE, ITEMMENUACTION_CANCEL +}; + +static const u8 sContextMenuItems_Cancel[] = { + ITEMMENUACTION_CANCEL +}; + +static const u8 sContextMenuItems_BerryBlenderCrush[] = { + ITEMMENUACTION_CONFIRM, ITEMMENUACTION_CHECK_TAG, + ITEMMENUACTION_DUMMY, ITEMMENUACTION_CANCEL +}; + +static const u8 sContextMenuItems_Apprentice[] = { + ITEMMENUACTION_SHOW, ITEMMENUACTION_CANCEL +}; + +static const u8 sContextMenuItems_FavorLady[] = { + ITEMMENUACTION_GIVE_2, ITEMMENUACTION_CANCEL +}; + +static const u8 sContextMenuItems_QuizLady[] = { + ITEMMENUACTION_CONFIRM_2, ITEMMENUACTION_CANCEL +}; + +static const TaskFunc gUnknown_08614054[] = { + [ITEMMENULOCATION_FIELD] = Task_ItemContext_FieldOrBattle, + [ITEMMENULOCATION_BATTLE] = Task_ItemContext_FieldOrBattle, + [ITEMMENULOCATION_PARTY] = Task_ItemContext_FieldGive, + [ITEMMENULOCATION_SHOP] = Task_ItemContext_Sell, + [ITEMMENULOCATION_BERRY_TREE] = Task_FadeAndCloseBagMenu, + [ITEMMENULOCATION_BERRY_BLENDER_CRUSH] = Task_ItemContext_FieldOrBattle, + [ITEMMENULOCATION_ITEMPC] = Task_ItemContext_Deposit, + [ITEMMENULOCATION_FAVOR_LADY] = Task_ItemContext_FieldOrBattle, + [ITEMMENULOCATION_QUIZ_LADY] = Task_ItemContext_FieldOrBattle, + [ITEMMENULOCATION_APPRENTICE] = Task_ItemContext_FieldOrBattle, + [ITEMMENULOCATION_WALLY] = NULL, + [ITEMMENULOCATION_PCBOX] = Task_ItemContext_ItemPC_2 +}; + +static const struct YesNoFuncTable sYesNoTossFunctions = {BagMenu_ConfirmToss, BagMenu_CancelToss}; + +static const struct YesNoFuncTable sYesNoSellItemFunctions = {BagMenu_ConfirmSell, BagMenu_CancelSell}; + +static const struct ScrollArrowsTemplate sBagScrollArrowsTemplate = { + .firstArrowType = SCROLL_ARROW_LEFT, + .firstX = 28, + .firstY = 16, + .secondArrowType = SCROLL_ARROW_RIGHT, + .secondX = 100, + .secondY = 16, + .fullyUpThreshold = -1, + .fullyDownThreshold = -1, + .tileTag = 111, + .palTag = 111, + .palNum = 0, +}; + +static const u8 sRegisteredSelect_Gfx[] = INCBIN_U8("graphics/interface/select_button.4bpp"); static const u8 sFontColorTable[][3] = { // bgColor, textColor, shadowColor @@ -268,7 +324,7 @@ static const u8 sFontColorTable[][3] = { {0, 14, 10} }; -const struct WindowTemplate gUnknown_08614174[] = +const struct WindowTemplate sDefaultBagWindows[] = { { // Item names .bg = 0, @@ -327,7 +383,7 @@ const struct WindowTemplate gUnknown_08614174[] = DUMMY_WIN_TEMPLATE, }; -const struct WindowTemplate gUnknown_086141AC[] = +const struct WindowTemplate sContextMenuWindowTemplates[] = { { .bg = 1, @@ -424,11 +480,11 @@ const struct WindowTemplate gUnknown_086141AC[] = // .text struct ListBuffer1 { - struct ListMenuItem subBuffers[65]; + struct ListMenuItem subBuffers[MAX_POCKET_ITEMS]; }; struct ListBuffer2 { - s8 name[65][24]; + s8 name[MAX_POCKET_ITEMS][24]; }; struct TempWallyStruct { @@ -436,7 +492,7 @@ struct TempWallyStruct { struct ItemSlot bagPocket_PokeBalls[BAG_POKEBALLS_COUNT]; u16 cursorPosition[POCKETS_COUNT]; u16 scrollPosition[POCKETS_COUNT]; - u8 filler[0x2]; + u8 filler[2]; u16 pocket; }; @@ -461,86 +517,85 @@ void ResetBagScrollPositions(void) void CB2_BagMenuFromStartMenu(void) { - GoToBagMenu(RETURN_LOCATION_FIELD, POCKETS_COUNT, CB2_ReturnToFieldWithOpenMenu); + GoToBagMenu(ITEMMENULOCATION_FIELD, POCKETS_COUNT, CB2_ReturnToFieldWithOpenMenu); } -void sub_81AABB0(void) +void CB2_BagMenuFromBattle(void) { if (!InBattlePyramid()) - GoToBagMenu(RETURN_LOCATION_BATTLE, POCKETS_COUNT, CB2_SetUpReshowBattleScreenAfterMenu2); + GoToBagMenu(ITEMMENULOCATION_BATTLE, POCKETS_COUNT, CB2_SetUpReshowBattleScreenAfterMenu2); else GoToBattlePyramidBagMenu(1, CB2_SetUpReshowBattleScreenAfterMenu2); } void CB2_ChooseBerry(void) { - GoToBagMenu(RETURN_LOCATION_FIELD_2, BERRIES_POCKET, CB2_ReturnToFieldContinueScript); + GoToBagMenu(ITEMMENULOCATION_BERRY_TREE, BERRIES_POCKET, CB2_ReturnToFieldContinueScript); } void ChooseBerrySetCallback(void (*callback)(void)) { - GoToBagMenu(RETURN_LOCATION_FIELD_3, BERRIES_POCKET, callback); + GoToBagMenu(ITEMMENULOCATION_BERRY_BLENDER_CRUSH, BERRIES_POCKET, callback); } void CB2_GoToSellMenu(void) { - GoToBagMenu(RETURN_LOCATION_SHOP, POCKETS_COUNT, CB2_ExitSellMenu); + GoToBagMenu(ITEMMENULOCATION_SHOP, POCKETS_COUNT, CB2_ExitSellMenu); } -void sub_81AAC14(void) +void CB2_GoToItemDepositMenu(void) { - GoToBagMenu(RETURN_LOCATION_PC, POCKETS_COUNT, sub_816B31C); + GoToBagMenu(ITEMMENULOCATION_ITEMPC, POCKETS_COUNT, sub_816B31C); } void ApprenticeOpenBagMenu(void) { - GoToBagMenu(RETURN_LOCATION_FIELD_6, POCKETS_COUNT, CB2_ApprenticeExitBagMenu); + GoToBagMenu(ITEMMENULOCATION_APPRENTICE, POCKETS_COUNT, CB2_ApprenticeExitBagMenu); gSpecialVar_0x8005 = ITEM_NONE; gSpecialVar_Result = FALSE; } void FavorLadyOpenBagMenu(void) { - GoToBagMenu(RETURN_LOCATION_FIELD_4, POCKETS_COUNT, CB2_FavorLadyExitBagMenu); + GoToBagMenu(ITEMMENULOCATION_FAVOR_LADY, POCKETS_COUNT, CB2_FavorLadyExitBagMenu); gSpecialVar_Result = FALSE; } void QuizLadyOpenBagMenu(void) { - GoToBagMenu(RETURN_LOCATION_FIELD_5, POCKETS_COUNT, CB2_QuizLadyExitBagMenu); + GoToBagMenu(ITEMMENULOCATION_QUIZ_LADY, POCKETS_COUNT, CB2_QuizLadyExitBagMenu); gSpecialVar_Result = FALSE; } -void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()) +void GoToBagMenu(u8 location, u8 pocket, void ( *postExitMenuMainCallback2)()) { - u8 temp; gBagMenu = AllocZeroed(sizeof(struct BagMenuStruct)); - if (gBagMenu == 0) + if (gBagMenu == NULL) { SetMainCallback2(postExitMenuMainCallback2); } else { - if (bagMenuType != RETURN_LOCATION_UNCHANGED) - gBagPositionStruct.location = bagMenuType; + if (location != ITEMMENULOCATION_LAST) + gBagPositionStruct.location = location; if (postExitMenuMainCallback2) gBagPositionStruct.bagCallback = postExitMenuMainCallback2; - if (pocketId < POCKETS_COUNT) - gBagPositionStruct.pocket = pocketId; - temp = gBagPositionStruct.location - (POCKETS_COUNT - 1); - if (temp <= 1) - gBagMenu->unk81B = 1; - gBagMenu->mainCallback2 = 0; - gBagMenu->unk81A = 0xFF; - gBagMenu->unk81E = -1; - gBagMenu->unk81F = -1; + if (pocket < POCKETS_COUNT) + gBagPositionStruct.pocket = pocket; + if (gBagPositionStruct.location == ITEMMENULOCATION_BERRY_TREE || + gBagPositionStruct.location == ITEMMENULOCATION_BERRY_BLENDER_CRUSH) + gBagMenu->pocketSwitchDisabled = TRUE; + gBagMenu->exitCallback = NULL; + gBagMenu->itemOriginalLocation = 0xFF; + gBagMenu->pocketScrollArrowsTask = 0xFF; + gBagMenu->pocketSwitchArrowsTask = 0xFF; memset(gBagMenu->spriteId, 0xFF, sizeof(gBagMenu->spriteId)); memset(gBagMenu->windowPointers, 0xFF, 10); SetMainCallback2(CB2_Bag); } } -void c2_bag_3(void) +void CB2_BagMenuRun(void) { RunTasks(); AnimateSprites(); @@ -549,7 +604,7 @@ void c2_bag_3(void) UpdatePaletteFade(); } -void vblank_cb_bag_menu(void) +void VBlankCB_BagMenuRun(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -560,7 +615,7 @@ void vblank_cb_bag_menu(void) void CB2_Bag(void) { - while(sub_81221EC() != TRUE && SetupBagMenu() != TRUE && sub_81221AC() != TRUE) {}; + while(MenuHelpers_CallLinkSomething() != TRUE && SetupBagMenu() != TRUE && MenuHelpers_LinkSomething() != TRUE) {}; } bool8 SetupBagMenu(void) @@ -596,13 +651,13 @@ bool8 SetupBagMenu(void) gMain.state++; break; case 6: - if (sub_81221AC() == FALSE) + if (!MenuHelpers_LinkSomething()) ResetTasks(); gMain.state++; break; case 7: BagMenu_InitBGs(); - gBagMenu->unk834 = 0; + gBagMenu->graphicsLoadState = 0; gMain.state++; break; case 8: @@ -615,9 +670,9 @@ bool8 SetupBagMenu(void) gMain.state++; break; case 10: - sub_81ABA6C(); + All_CalculateNItemsAndMaxShowed(); SetPocketListPositions(); - sub_81ABAE0(); + UpdatePocketScrollPositions(); gMain.state++; break; case 11: @@ -635,7 +690,7 @@ bool8 SetupBagMenu(void) gMain.state++; break; case 14: - taskId = sub_81AB1F0(gBagPositionStruct.location); + taskId = CreateBagInputHandlerTask(gBagPositionStruct.location); gTasks[taskId].data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]); gTasks[taskId].data[3] = 0; gTasks[taskId].tItemCount = 0; @@ -650,8 +705,8 @@ bool8 SetupBagMenu(void) gMain.state++; break; case 17: - bag_menu_add_pocket_scroll_arrow_indicators_maybe(); - bag_menu_add_list_scroll_arrow_indicators_maybe(); + CreatePocketScrollArrowPair(); + CreatePocketSwitchArrowPair(); gMain.state++; break; case 18: @@ -659,7 +714,7 @@ bool8 SetupBagMenu(void) gMain.state++; break; case 19: - BlendPalettes(-1, 16, 0); + BlendPalettes(0xFFFFFFFF, 16, 0); gMain.state++; break; case 20: @@ -668,8 +723,8 @@ bool8 SetupBagMenu(void) gMain.state++; break; default: - SetVBlankCallback(vblank_cb_bag_menu); - SetMainCallback2(c2_bag_3); + SetVBlankCallback(VBlankCB_BagMenuRun); + SetMainCallback2(CB2_BagMenuRun); return TRUE; } return FALSE; @@ -683,7 +738,7 @@ void BagMenu_InitBGs(void) InitBgsFromTemplates(0, sBgTemplates_ItemMenu, 3); SetBgTilemapBuffer(2, gBagMenu->tilemapBuffer); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); ShowBg(1); @@ -693,18 +748,18 @@ void BagMenu_InitBGs(void) bool8 LoadBagMenu_Graphics(void) { - switch (gBagMenu->unk834) + switch (gBagMenu->graphicsLoadState) { case 0: - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(2, gBagScreen_Gfx, 0, 0, 0); - gBagMenu->unk834++; + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(2, gBagScreen_Gfx, 0, 0, 0); + gBagMenu->graphicsLoadState++; break; case 1: - if (free_temp_tile_data_buffers_if_possible() != TRUE) + if (FreeTempTileDataBuffersIfPossible() != TRUE) { LZDecompressWram(gBagScreen_GfxTileMap, gBagMenu->tilemapBuffer); - gBagMenu->unk834++; + gBagMenu->graphicsLoadState++; } break; case 2: @@ -712,34 +767,34 @@ bool8 LoadBagMenu_Graphics(void) LoadCompressedPalette(gBagScreenFemale_Pal, 0, 0x40); else LoadCompressedPalette(gBagScreenMale_Pal, 0, 0x40); - gBagMenu->unk834++; + gBagMenu->graphicsLoadState++; break; case 3: if (IsWallysBag() == TRUE || gSaveBlock2Ptr->playerGender == MALE) LoadCompressedSpriteSheet(&gBagMaleSpriteSheet); else LoadCompressedSpriteSheet(&gBagFemaleSpriteSheet); - gBagMenu->unk834++; + gBagMenu->graphicsLoadState++; break; case 4: LoadCompressedSpritePalette(&gBagPaletteTable); - gBagMenu->unk834++; + gBagMenu->graphicsLoadState++; break; default: LoadListMenuArrowsGfx(); - gBagMenu->unk834 = 0; + gBagMenu->graphicsLoadState = 0; return TRUE; } return FALSE; } -u8 sub_81AB1F0(u8 a) +u8 CreateBagInputHandlerTask(u8 location) { u8 taskId; - if (a == 10) + if (location == ITEMMENULOCATION_WALLY) taskId = CreateTask(Task_WallyTutorialBagMenu, 0); else - taskId = CreateTask(Task_BagMenu, 0); + taskId = CreateTask(Task_BagMenu_HandleInput, 0); return taskId; } @@ -767,7 +822,7 @@ void LoadBagItemListBuffers(u8 pocketId) StringCopy(sListBuffer2->name[i], gText_CloseBag); subBuffer = sListBuffer1->subBuffers; subBuffer[i].name = sListBuffer2->name[i]; - subBuffer[i].id = -2; + subBuffer[i].id = LIST_CANCEL; } else { @@ -813,73 +868,76 @@ void GetItemName(s8 *dest, u16 itemId) } } -void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu *unused) +void BagMenu_MoveCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list) { - if (b != 1) + if (onInit != TRUE) { PlaySE(SE_SELECT); - ShakeBagVisual(); + ShakeBagSprite(); } - if (gBagMenu->unk81A == 0xFF) + if (gBagMenu->itemOriginalLocation == 0xFF) { - RemoveBagItemIconSprite(1 ^ gBagMenu->unk81B_1); - if (a != -2) - AddBagItemIconSprite(BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, a), gBagMenu->unk81B_1); + RemoveBagItemIconSprite(gBagMenu->itemIconSlot ^ 1); + if (itemIndex != LIST_CANCEL) + AddBagItemIconSprite(BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, itemIndex), gBagMenu->itemIconSlot); else - AddBagItemIconSprite(-1, gBagMenu->unk81B_1); - gBagMenu->unk81B_1 ^= 1; - if (!gBagMenu->unk81B_3) - BagMenu_PrintDescription(a); + AddBagItemIconSprite(-1, gBagMenu->itemIconSlot); + gBagMenu->itemIconSlot ^= 1; + if (!gBagMenu->inhibitItemDescriptionPrint) + BagMenu_PrintDescription(itemIndex); } } -void PrintItemQuantityPlusGFX(u8 rboxId, s32 item_index_in_pocket, u8 a) +void BagMenu_ItemPrintCallback(u8 windowId, s32 itemIndex, u8 y) { u16 itemId; u16 itemQuantity; - bool8 unique; int offset; - if (item_index_in_pocket != -2) + + if (itemIndex != LIST_CANCEL) { - if (gBagMenu->unk81A != 0xFF) + if (gBagMenu->itemOriginalLocation != 0xFF) { - if (gBagMenu->unk81A == (u8)item_index_in_pocket) - BagMenu_PrintCursor(a, 2); + if (gBagMenu->itemOriginalLocation == (u8)itemIndex) + BagMenu_PrintCursor(y, 2); else - BagMenu_PrintCursor(a, -1); + BagMenu_PrintCursor(y, 0xFF); } - itemId = BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, item_index_in_pocket); - itemQuantity = BagGetQuantityByPocketPosition(gBagPositionStruct.pocket + 1, item_index_in_pocket); + + itemId = BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, itemIndex); + itemQuantity = BagGetQuantityByPocketPosition(gBagPositionStruct.pocket + 1, itemIndex); + if (itemId >= ITEM_HM01 && itemId <= ITEM_HM08) - BlitBitmapToWindow(rboxId, gBagMenuHMIcon_Gfx, 8, a - 1, 16, 16); + BlitBitmapToWindow(windowId, gBagMenuHMIcon_Gfx, 8, y - 1, 16, 16); + if (gBagPositionStruct.pocket == BERRIES_POCKET) { ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_xVar1); - offset = GetStringRightAlignXOffset(7, gStringVar4, 0x77); - BagMenu_Print(rboxId, 7, gStringVar4, offset, a, 0, 0, -1, 0); + offset = GetStringRightAlignXOffset(7, gStringVar4, 119); + BagMenu_Print(windowId, 7, gStringVar4, offset, y, 0, 0, -1, 0); } - else if (gBagPositionStruct.pocket != KEYITEMS_POCKET && (unique = ItemId_GetImportance(itemId)) == FALSE) + else if (gBagPositionStruct.pocket != KEYITEMS_POCKET && ItemId_GetImportance(itemId) == FALSE) { ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, gText_xVar1); - offset = GetStringRightAlignXOffset(7, gStringVar4, 0x77); - BagMenu_Print(rboxId, 7, gStringVar4, offset, a, unique, unique, -1, unique); + offset = GetStringRightAlignXOffset(7, gStringVar4, 119); + BagMenu_Print(windowId, 7, gStringVar4, offset, y, 0, 0, -1, 0); } else { if (gSaveBlock1Ptr->registeredItem && gSaveBlock1Ptr->registeredItem == itemId) - BlitBitmapToWindow(rboxId, gRegisteredSelect_Gfx, 0x60, a - 1, 0x18, 16); + BlitBitmapToWindow(windowId, sRegisteredSelect_Gfx, 96, y - 1, 24, 16); } } } -void BagMenu_PrintDescription(int a) +void BagMenu_PrintDescription(int itemIndex) { const u8 *str; - if (a != -2) + if (itemIndex != LIST_CANCEL) { - str = ItemId_GetDescription(BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, a)); + str = ItemId_GetDescription(BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, itemIndex)); } else { @@ -891,48 +949,56 @@ void BagMenu_PrintDescription(int a) BagMenu_Print(1, 1, str, 3, 1, 0, 0, 0, 0); } -void BagMenu_PrintCursor_(u8 a, u8 b) +void BagMenu_PrintCursor_(u8 listTaskId, u8 colorIndex) { - BagMenu_PrintCursor(ListMenuGetYCoordForPrintingArrowCursor(a), b); + BagMenu_PrintCursor(ListMenuGetYCoordForPrintingArrowCursor(listTaskId), colorIndex); } -void BagMenu_PrintCursor(u8 a, u8 b) +void BagMenu_PrintCursor(u8 y, u8 colorIndex) { - if (b == 0xFF) - FillWindowPixelRect(0, PIXEL_FILL(0), 0, a, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); + if (colorIndex == 0xFF) + FillWindowPixelRect(0, PIXEL_FILL(0), 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); else - BagMenu_Print(0, 1, gText_SelectorArrow2, 0, a, 0, 0, 0, b); + BagMenu_Print(0, 1, gText_SelectorArrow2, 0, y, 0, 0, 0, colorIndex); } -void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void) +void CreatePocketScrollArrowPair(void) { - if (gBagMenu->unk81E == 0xFF) - gBagMenu->unk81E = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0xAC, 12, 0x94, gBagMenu->numItemStacks[gBagPositionStruct.pocket] - gBagMenu->numShownItems[gBagPositionStruct.pocket], 0x6E, 0x6E, &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]); + if (gBagMenu->pocketScrollArrowsTask == 0xFF) + gBagMenu->pocketScrollArrowsTask = AddScrollIndicatorArrowPairParameterized( + SCROLL_ARROW_UP, + 172, + 12, + 148, + gBagMenu->numItemStacks[gBagPositionStruct.pocket] - gBagMenu->numShownItems[gBagPositionStruct.pocket], + 110, + 110, + &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]); } -void sub_81AB824(void) +void BagDestroyPocketScrollArrowPair(void) { - if (gBagMenu->unk81E != 0xFF) + if (gBagMenu->pocketScrollArrowsTask != 0xFF) { - RemoveScrollIndicatorArrowPair(gBagMenu->unk81E); - gBagMenu->unk81E = 0xFF; + RemoveScrollIndicatorArrowPair(gBagMenu->pocketScrollArrowsTask); + gBagMenu->pocketScrollArrowsTask = 0xFF; } - sub_81AB89C(); + BagDestroyPocketSwitchArrowPair(); } -void bag_menu_add_list_scroll_arrow_indicators_maybe(void) +void CreatePocketSwitchArrowPair(void) { - if (gBagMenu->unk81B != 1 && gBagMenu->unk81F == 0xFF) - gBagMenu->unk81F = AddScrollIndicatorArrowPair(&gBagScrollArrowsTemplate, &gBagPositionStruct.unk6); + if (gBagMenu->pocketSwitchDisabled != TRUE && gBagMenu->pocketSwitchArrowsTask == 0xFF) + gBagMenu->pocketSwitchArrowsTask = AddScrollIndicatorArrowPair(&sBagScrollArrowsTemplate, &gBagPositionStruct.unk6); } -void sub_81AB89C(void) +void BagDestroyPocketSwitchArrowPair(void) { - if (gBagMenu->unk81F != 0xFF) + if (gBagMenu->pocketSwitchArrowsTask != 0xFF) { - RemoveScrollIndicatorArrowPair(gBagMenu->unk81F); - gBagMenu->unk81F = 0xFF; + RemoveScrollIndicatorArrowPair(gBagMenu->pocketSwitchArrowsTask); + gBagMenu->pocketSwitchArrowsTask = 0xFF; } } @@ -956,11 +1022,11 @@ void TaskCloseBagMenu_2(u8 taskId) if (!gPaletteFade.active) { DestroyListMenuTask(data[0], &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]); - if (gBagMenu->mainCallback2 != 0) - SetMainCallback2(gBagMenu->mainCallback2); + if (gBagMenu->exitCallback != NULL) + SetMainCallback2(gBagMenu->exitCallback); else SetMainCallback2(gBagPositionStruct.bagCallback); - sub_81AB824(); + BagDestroyPocketScrollArrowPair(); ResetSpriteData(); FreeAllSpritePalettes(); FreeBagItemListBuffers(); @@ -982,7 +1048,9 @@ void UpdatePocketItemList(u8 pocketId) CompactItemsInBagPocket(pocket); break; } + gBagMenu->numItemStacks[pocketId] = 0; + for (i = 0; i < pocket->capacity && pocket->itemSlots[i].itemId; i++) gBagMenu->numItemStacks[pocketId]++; @@ -995,7 +1063,7 @@ void UpdatePocketItemList(u8 pocketId) gBagMenu->numShownItems[pocketId] = gBagMenu->numItemStacks[pocketId]; } -void sub_81ABA6C(void) +void All_CalculateNItemsAndMaxShowed(void) { u8 i; for (i = 0; i < POCKETS_COUNT; i++) @@ -1014,7 +1082,7 @@ static void SetPocketListPositions(void) SetInitialScrollAndCursorPositions(i); } -void sub_81ABAE0(void) +void UpdatePocketScrollPositions(void) { u8 i; for (i = 0; i < POCKETS_COUNT; i++) @@ -1026,14 +1094,14 @@ u8 GetItemListPosition(u8 pocketId) return gBagPositionStruct.scrollPosition[pocketId] + gBagPositionStruct.cursorPosition[pocketId]; } -void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void ( *callback)(u8 taskId)) +void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void (*callback)(u8 taskId)) { s16* data = gTasks[taskId].data; data[10] = AddItemMessageWindow(4); FillWindowPixelBuffer(data[10], PIXEL_FILL(1)); DisplayMessageAndContinueTask(taskId, data[10], 10, 13, fontId, GetPlayerTextSpeedDelay(), str, callback); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } void BagMenu_InitListsMenu(u8 taskId) @@ -1047,7 +1115,7 @@ void BagMenu_InitListsMenu(u8 taskId) SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket); LoadBagItemListBuffers(gBagPositionStruct.pocket); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); set_callback3_to_bag(taskId); } @@ -1073,13 +1141,14 @@ void PrintItemSoldAmount(int windowId, int numSold, int moneyEarned) PrintMoneyAmount(windowId, 38, 1, moneyEarned, 0); } -void Task_BagMenu(u8 taskId) +void Task_BagMenu_HandleInput(u8 taskId) { s16* data = gTasks[taskId].data; u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]; u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]; - u16 select; - if (sub_81221EC() != TRUE && !gPaletteFade.active) + s32 listPosition; + + if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) { switch (GetSwitchBagPocketDirection()) { @@ -1089,67 +1158,67 @@ void Task_BagMenu(u8 taskId) case 2: SwitchBagPocket(taskId, 1, 0); return; - } - if ((select = (gMain.newKeys & SELECT_BUTTON))) - { - if (sub_81AC2C0() == 1) - { - ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); - if ((*scrollPos + *cursorPos) != gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1) + default: + if (gMain.newKeys & SELECT_BUTTON) { - PlaySE(SE_SELECT); - BagMenu_SwapItems(taskId); - } - } - return; - } - else - { - int listPosition = ListMenu_ProcessInput(data[0]); - ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); - switch (listPosition) - { - case LIST_NOTHING_CHOSEN: - break; - case LIST_CANCEL: - if (gBagPositionStruct.location == 5) + if (sub_81AC2C0() == 1) { - PlaySE(SE_HAZURE); - break; + ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); + if ((*scrollPos + *cursorPos) != gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1) + { + PlaySE(SE_SELECT); + BagMenu_SwapItems(taskId); + } } - PlaySE(SE_SELECT); - gSpecialVar_ItemId = select; - gTasks[taskId].func = Task_FadeAndCloseBagMenu; + return; + } + break; + } + + listPosition = ListMenu_ProcessInput(data[0]); + ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); + switch (listPosition) + { + case LIST_NOTHING_CHOSEN: + break; + case LIST_CANCEL: + if (gBagPositionStruct.location == ITEMMENULOCATION_BERRY_BLENDER_CRUSH) + { + PlaySE(SE_HAZURE); break; - default: // A_BUTTON - PlaySE(SE_SELECT); - sub_81AB824(); - BagMenu_PrintCursor_(data[0], 2); - data[1] = listPosition; - data[2] = BagGetQuantityByPocketPosition(gBagPositionStruct.pocket + 1, listPosition); - gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, listPosition); - gUnknown_08614054[gBagPositionStruct.location](taskId); - break; - } + } + PlaySE(SE_SELECT); + gSpecialVar_ItemId = ITEM_NONE; + gTasks[taskId].func = Task_FadeAndCloseBagMenu; + break; + default: // A_BUTTON + PlaySE(SE_SELECT); + BagDestroyPocketScrollArrowPair(); + BagMenu_PrintCursor_(data[0], 2); + data[1] = listPosition; + data[2] = BagGetQuantityByPocketPosition(gBagPositionStruct.pocket + 1, listPosition); + gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, listPosition); + gUnknown_08614054[gBagPositionStruct.location](taskId); + break; } } } void set_callback3_to_bag(u8 taskId) { - bag_menu_add_pocket_scroll_arrow_indicators_maybe(); - bag_menu_add_list_scroll_arrow_indicators_maybe(); + CreatePocketScrollArrowPair(); + CreatePocketSwitchArrowPair(); ClearWindowTilemap(3); ClearWindowTilemap(4); PutWindowTilemap(1); - schedule_bg_copy_tilemap_to_vram(0); - gTasks[taskId].func = Task_BagMenu; + ScheduleBgCopyTilemapToVram(0); + gTasks[taskId].func = Task_BagMenu_HandleInput; } u8 GetSwitchBagPocketDirection(void) { u8 LRKeys; - if (gBagMenu->unk81B != 0) + if (gBagMenu->pocketSwitchDisabled) return 0; LRKeys = GetLRKeysPressed(); if ((gMain.newKeys & DPAD_LEFT) || LRKeys == MENU_L_PRESSED) @@ -1188,9 +1257,9 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) ClearWindowTilemap(0); ClearWindowTilemap(1); DestroyListMenuTask(data[0], &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]); - schedule_bg_copy_tilemap_to_vram(0); - gSprites[gBagMenu->spriteId[2 + (gBagMenu->unk81B_1 ^ 1)]].invisible = TRUE; - sub_81AB824(); + ScheduleBgCopyTilemapToVram(0); + gSprites[gBagMenu->spriteId[2 + (gBagMenu->itemIconSlot ^ 1)]].invisible = TRUE; + BagDestroyPocketScrollArrowPair(); } pocketId = gBagPositionStruct.pocket; ChangeBagPocketId(&pocketId, deltaBagPocketId); @@ -1207,7 +1276,7 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) BagMenu_DrawPocketIndicatorSquare(gBagPositionStruct.pocket, 0); BagMenu_DrawPocketIndicatorSquare(pocketId, 1); FillBgTilemapBufferRect_Palette0(2, 11, 14, 2, 15, 16); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); SetBagVisualPocketId(pocketId, 1); RemoveBagSprite(1); AddSwitchPocketRotatingBallSprite(deltaBagPocketId); @@ -1218,7 +1287,7 @@ void sub_81AC10C(u8 taskId) { s16* data = gTasks[taskId].data; - if (!sub_81221AC() && !IsWallysBag()) + if (!MenuHelpers_LinkSomething() && !IsWallysBag()) { switch (GetSwitchBagPocketDirection()) { @@ -1254,9 +1323,9 @@ void sub_81AC10C(u8 taskId) data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]); PutWindowTilemap(1); PutWindowTilemap(2); - schedule_bg_copy_tilemap_to_vram(0); - bag_menu_add_pocket_scroll_arrow_indicators_maybe(); - bag_menu_add_list_scroll_arrow_indicators_maybe(); + ScheduleBgCopyTilemapToVram(0); + CreatePocketScrollArrowPair(); + CreatePocketSwitchArrowPair(); SwitchTaskToFollowupFunc(taskId); } } @@ -1264,7 +1333,7 @@ void sub_81AC10C(u8 taskId) void sub_81AC23C(u8 a) { FillBgTilemapBufferRect_Palette0(2, 17, 14, a + 2, 15, 1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } void BagMenu_DrawPocketIndicatorSquare(u8 x, u8 is_current_bag) @@ -1273,12 +1342,12 @@ void BagMenu_DrawPocketIndicatorSquare(u8 x, u8 is_current_bag) FillBgTilemapBufferRect_Palette0(2, 0x1017, x + 5, 3, 1, 1); else FillBgTilemapBufferRect_Palette0(2, 0x102B, x + 5, 3, 1, 1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } bool8 sub_81AC2C0(void) { - if (gBagPositionStruct.location <= 1) + if (gBagPositionStruct.location <= ITEMMENULOCATION_BATTLE) { u8 temp = gBagPositionStruct.pocket - 2; if (temp > 1) @@ -1293,13 +1362,13 @@ void BagMenu_SwapItems(u8 taskId) ListMenuSetUnkIndicatorsStructField(data[0], 16, 1); data[1] = gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket] + gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]; - gBagMenu->unk81A = data[1]; + gBagMenu->itemOriginalLocation = data[1]; CopyItemName(BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, data[1]), gStringVar1); StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where); FillWindowPixelBuffer(1, PIXEL_FILL(0)); BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); sub_80D4FEC(data[1]); - sub_81AB89C(); + BagDestroyPocketSwitchArrowPair(); BagMenu_PrintCursor_(data[0], 2); gTasks[taskId].func = sub_81AC3C0; } @@ -1309,7 +1378,7 @@ void sub_81AC3C0(u8 taskId) s16* data = gTasks[taskId].data; int input; - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { if (gMain.newKeys & SELECT_BUTTON) { @@ -1354,15 +1423,15 @@ void sub_81AC498(u8 taskId) else { MoveItemSlotInList(gBagPockets[gBagPositionStruct.pocket].itemSlots, data[1], realPos); - gBagMenu->unk81A = -1; + gBagMenu->itemOriginalLocation = -1; DestroyListMenuTask(data[0], scrollPos, cursorPos); if (data[1] < realPos) gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]--; LoadBagItemListBuffers(gBagPositionStruct.pocket); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); sub_80D4FC8(1); - bag_menu_add_list_scroll_arrow_indicators_maybe(); - gTasks[taskId].func = Task_BagMenu; + CreatePocketSwitchArrowPair(); + gTasks[taskId].func = Task_BagMenu_HandleInput; } } @@ -1372,90 +1441,90 @@ void sub_81AC590(u8 taskId) u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]; u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]; - gBagMenu->unk81A = -1; + gBagMenu->itemOriginalLocation = -1; DestroyListMenuTask(data[0], scrollPos, cursorPos); if (data[1] < (*scrollPos + *cursorPos)) gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]--; LoadBagItemListBuffers(gBagPositionStruct.pocket); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); sub_80D4FC8(1); - bag_menu_add_list_scroll_arrow_indicators_maybe(); - gTasks[taskId].func = Task_BagMenu; + CreatePocketSwitchArrowPair(); + gTasks[taskId].func = Task_BagMenu_HandleInput; } -void sub_81AC644(u8 unused) +void OpenContextMenu(u8 unused) { - switch (gBagPositionStruct.location - 1) + switch (gBagPositionStruct.location) { - case 0: - case 9: + case ITEMMENULOCATION_BATTLE: + case ITEMMENULOCATION_WALLY: if (ItemId_GetBattleUsage(gSpecialVar_ItemId)) { - gBagMenu->unk820 = gUnknown_08614042; - gBagMenu->unk828 = 2; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_BattleUse; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_BattleUse); } else { - gBagMenu->unk820 = &gUnknown_08614046; - gBagMenu->unk828 = 1; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel); } break; - case 4: - gBagMenu->unk820 = gUnknown_08614047; - gBagMenu->unk828 = 4; + case ITEMMENULOCATION_BERRY_BLENDER_CRUSH: + gBagMenu->contextMenuItemsPtr = sContextMenuItems_BerryBlenderCrush; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_BerryBlenderCrush); break; - case 8: + case ITEMMENULOCATION_APPRENTICE: if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY) { - gBagMenu->unk820 = gUnknown_0861404B; - gBagMenu->unk828 = 2; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_Apprentice; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Apprentice); } else { - gBagMenu->unk820 = &gUnknown_08614046; - gBagMenu->unk828 = 1; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel); } break; - case 6: + case ITEMMENULOCATION_FAVOR_LADY: if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY) { - gBagMenu->unk820 = gUnknown_0861404D; - gBagMenu->unk828 = 2; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_FavorLady; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_FavorLady); } else { - gBagMenu->unk820 = &gUnknown_08614046; - gBagMenu->unk828 = 1; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel); } break; - case 7: + case ITEMMENULOCATION_QUIZ_LADY: if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY) { - gBagMenu->unk820 = gUnknown_0861404F; - gBagMenu->unk828 = 2; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_QuizLady; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_QuizLady); } else { - gBagMenu->unk820 = &gUnknown_08614046; - gBagMenu->unk828 = 1; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel); } break; - case 1: - case 2: - case 3: - case 5: + case ITEMMENULOCATION_PARTY: + case ITEMMENULOCATION_SHOP: + case ITEMMENULOCATION_BERRY_TREE: + case ITEMMENULOCATION_ITEMPC: default: - if (sub_81221AC() == TRUE || InUnionRoom() == TRUE) + if (MenuHelpers_LinkSomething() == TRUE || InUnionRoom() == TRUE) { if (gBagPositionStruct.pocket == KEYITEMS_POCKET || !sub_8122148(gSpecialVar_ItemId)) { - gBagMenu->unk820 = &gUnknown_08614046; - gBagMenu->unk828 = 1; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel); } else { - gBagMenu->unk820 = gUnknown_08614044; - gBagMenu->unk828 = 2; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_Give; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Give); } } else @@ -1463,35 +1532,35 @@ void sub_81AC644(u8 unused) switch (gBagPositionStruct.pocket) { case ITEMS_POCKET: - gBagMenu->unk820 = &gBagMenu->unk824; - gBagMenu->unk828 = 4; - memcpy(&gBagMenu->unk824, &gUnknown_0861402C, 4); + gBagMenu->contextMenuItemsPtr = gBagMenu->contextMenuItemsBuffer; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_ItemsPocket); + memcpy(&gBagMenu->contextMenuItemsBuffer, &sContextMenuItems_ItemsPocket, sizeof(sContextMenuItems_ItemsPocket)); if (ItemIsMail(gSpecialVar_ItemId) == TRUE) - gBagMenu->unk824 = 6; + gBagMenu->contextMenuItemsBuffer[0] = ITEMMENUACTION_CHECK; break; case KEYITEMS_POCKET: - gBagMenu->unk820 = &gBagMenu->unk824; - gBagMenu->unk828 = 4; - memcpy(&gBagMenu->unk824, &gUnknown_08614030, 4); + gBagMenu->contextMenuItemsPtr = gBagMenu->contextMenuItemsBuffer; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_KeyItemsPocket); + memcpy(&gBagMenu->contextMenuItemsBuffer, &sContextMenuItems_KeyItemsPocket, sizeof(sContextMenuItems_KeyItemsPocket)); if (gSaveBlock1Ptr->registeredItem == gSpecialVar_ItemId) - gBagMenu->unk825 = 8; + gBagMenu->contextMenuItemsBuffer[1] = ITEMMENUACTION_DESELECT; if (gSpecialVar_ItemId == ITEM_MACH_BIKE || gSpecialVar_ItemId == ITEM_ACRO_BIKE) { - if (TestPlayerAvatarFlags(6)) - gBagMenu->unk824 = 7; + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) + gBagMenu->contextMenuItemsBuffer[0] = ITEMMENUACTION_WALK; } break; case BALLS_POCKET: - gBagMenu->unk820 = gUnknown_08614034; - gBagMenu->unk828 = 4; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_BallsPocket; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_BallsPocket); break; case TMHM_POCKET: - gBagMenu->unk820 = gUnknown_08614038; - gBagMenu->unk828 = 4; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_TmHmPocket; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_TmHmPocket); break; case BERRIES_POCKET: - gBagMenu->unk820 = gUnknown_0861403C; - gBagMenu->unk828 = 6; + gBagMenu->contextMenuItemsPtr = sContextMenuItems_BerriesPocket; + gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_BerriesPocket); break; } } @@ -1502,7 +1571,7 @@ void sub_81AC644(u8 unused) PrintTMHMMoveData(gSpecialVar_ItemId); PutWindowTilemap(3); PutWindowTilemap(4); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } else { @@ -1511,11 +1580,11 @@ void sub_81AC644(u8 unused) FillWindowPixelBuffer(1, PIXEL_FILL(0)); BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); } - if (gBagMenu->unk828 == 1) + if (gBagMenu->contextMenuNumItems == 1) sub_81ACAF8(BagMenu_AddWindow(0)); - else if (gBagMenu->unk828 == 2) + else if (gBagMenu->contextMenuNumItems == 2) sub_81ACAF8(BagMenu_AddWindow(1)); - else if (gBagMenu->unk828 == 4) + else if (gBagMenu->contextMenuNumItems == 4) sub_81ACB54(BagMenu_AddWindow(2), 2, 2); else sub_81ACB54(BagMenu_AddWindow(3), 2, 3); @@ -1523,20 +1592,20 @@ void sub_81AC644(u8 unused) void sub_81ACAF8(u8 a) { - AddItemMenuActionTextPrinters(a, 7, 8, 1, 0, 16, gBagMenu->unk828, sItemMenuActions, gBagMenu->unk820); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(a, gBagMenu->unk828, 0); + AddItemMenuActionTextPrinters(a, 7, 8, 1, 0, 16, gBagMenu->contextMenuNumItems, sItemMenuActions, gBagMenu->contextMenuItemsPtr); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(a, gBagMenu->contextMenuNumItems, 0); } void sub_81ACB54(u8 a, u8 b, u8 c) { - sub_8198DBC(a, 7, 8, 1, 0x38, b, c, sItemMenuActions, gBagMenu->unk820); + sub_8198DBC(a, 7, 8, 1, 0x38, b, c, sItemMenuActions, gBagMenu->contextMenuItemsPtr); sub_8199944(a, 0x38, b, c, 0); } -void unknown_item_menu_type(u8 taskId) +void Task_ItemContext_FieldOrBattle(u8 taskId) { - sub_81AC644(taskId); - if (gBagMenu->unk828 <= 2) + OpenContextMenu(taskId); + if (gBagMenu->contextMenuNumItems <= 2) gTasks[taskId].func = Task_HandleInBattleItemMenuInput; else gTasks[taskId].func = Task_HandleOutOfBattleItemMenuInput; @@ -1544,20 +1613,20 @@ void unknown_item_menu_type(u8 taskId) void Task_HandleInBattleItemMenuInput(u8 taskId) { - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { - s8 r4 = Menu_ProcessInputNoWrap(); - switch (r4) + s8 selection = Menu_ProcessInputNoWrap(); + switch (selection) { case MENU_NOTHING_CHOSEN: break; case MENU_B_PRESSED: PlaySE(SE_SELECT); - sItemMenuActions[4].func.void_u8(taskId); + sItemMenuActions[ITEMMENUACTION_CANCEL].func.void_u8(taskId); break; default: PlaySE(SE_SELECT); - sItemMenuActions[gBagMenu->unk820[r4]].func.void_u8(taskId); + sItemMenuActions[gBagMenu->contextMenuItemsPtr[selection]].func.void_u8(taskId); break; } } @@ -1565,7 +1634,7 @@ void Task_HandleInBattleItemMenuInput(u8 taskId) void Task_HandleOutOfBattleItemMenuInput(u8 taskId) { - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { s8 cursorPos = Menu_GetCursorPos(); if (gMain.newKeys & DPAD_UP) @@ -1578,7 +1647,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) } else if (gMain.newKeys & DPAD_DOWN) { - if (cursorPos < (gBagMenu->unk828 - 2) && sub_81ACDFC(cursorPos + 2)) + if (cursorPos < (gBagMenu->contextMenuNumItems - 2) && sub_81ACDFC(cursorPos + 2)) { PlaySE(SE_SELECT); sub_8199134(0, 1); @@ -1603,12 +1672,12 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - sItemMenuActions[gBagMenu->unk820[cursorPos]].func.void_u8(taskId); + sItemMenuActions[gBagMenu->contextMenuItemsPtr[cursorPos]].func.void_u8(taskId); } else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); - sItemMenuActions[4].func.void_u8(taskId); + sItemMenuActions[ITEMMENUACTION_CANCEL].func.void_u8(taskId); } } } @@ -1617,22 +1686,22 @@ bool8 sub_81ACDFC(s8 a) { if (a < 0) return FALSE; - if (a > gBagMenu->unk828) + if (a > gBagMenu->contextMenuNumItems) return FALSE; - if (gBagMenu->unk820[a] == 14) + if (gBagMenu->contextMenuItemsPtr[a] == 14) return FALSE; return TRUE; } void BagMenu_RemoveSomeWindow(void) { - if (gBagMenu->unk828 == 1) + if (gBagMenu->contextMenuNumItems == 1) BagMenu_RemoveWindow(0); - else if (gBagMenu->unk828 == 2) + else if (gBagMenu->contextMenuNumItems == 2) { BagMenu_RemoveWindow(1); } - else if (gBagMenu->unk828 == 4) + else if (gBagMenu->contextMenuNumItems == 4) { BagMenu_RemoveWindow(2); } @@ -1650,7 +1719,7 @@ void ItemMenu_UseOutOfBattle(u8 taskId) else { FillWindowPixelBuffer(1, PIXEL_FILL(0)); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); if (gBagPositionStruct.pocket != BERRIES_POCKET) ItemId_GetFieldFunc(gSpecialVar_ItemId)(taskId); else @@ -1750,7 +1819,7 @@ void Task_ActuallyToss(u8 taskId) SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket); LoadBagItemListBuffers(gBagPositionStruct.pocket); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); set_callback3_to_bag(taskId); } } @@ -1768,7 +1837,7 @@ void ItemMenu_Register(u8 taskId) DestroyListMenuTask(data[0], scrollPos, cursorPos); LoadBagItemListBuffers(gBagPositionStruct.pocket); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); ItemMenu_Cancel(taskId); } @@ -1785,7 +1854,7 @@ void ItemMenu_Give(u8 taskId) BagMenu_PrintThereIsNoPokemon(taskId); else { - gBagMenu->mainCallback2 = CB2_ChooseMonToGiveItem; + gBagMenu->exitCallback = CB2_ChooseMonToGiveItem; Task_FadeAndCloseBagMenu(taskId); } } @@ -1818,7 +1887,7 @@ void sub_81AD350(u8 taskId) void ItemMenu_CheckTag(u8 taskId) { - gBagMenu->mainCallback2 = DoBerryTagScreen; + gBagMenu->exitCallback = DoBerryTagScreen; Task_FadeAndCloseBagMenu(taskId); } @@ -1828,8 +1897,8 @@ void ItemMenu_Cancel(u8 taskId) BagMenu_RemoveSomeWindow(); BagMenu_PrintDescription(data[1]); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); BagMenu_PrintCursor_(data[0], 0); set_callback3_to_bag(taskId); } @@ -1845,10 +1914,10 @@ void ItemMenu_UseInBattle(u8 taskId) void CB2_ReturnToBagMenuPocket(void) { - GoToBagMenu(RETURN_LOCATION_UNCHANGED, POCKETS_COUNT, NULL); + GoToBagMenu(ITEMMENULOCATION_LAST, POCKETS_COUNT, NULL); } -void item_menu_type_2(u8 taskId) +void Task_ItemContext_FieldGive(u8 taskId) { if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId)) { @@ -1870,7 +1939,7 @@ void item_menu_type_2(u8 taskId) } } -void item_menu_type_b(u8 taskId) +void Task_ItemContext_ItemPC_2(u8 taskId) { if (ItemIsMail(gSpecialVar_ItemId) == TRUE) DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350); @@ -1914,7 +1983,7 @@ bool8 UseRegisteredKeyItemOnField(void) #undef tUsingRegisteredKeyItem -void DisplaySellItemAskString(u8 taskId) +void Task_ItemContext_Sell(u8 taskId) { s16* data = gTasks[taskId].data; @@ -2039,7 +2108,7 @@ void sub_81AD9C0(u8 taskId) } } -void DisplayDepositItemAskString(u8 taskId) +void Task_ItemContext_Deposit(u8 taskId) { s16* data = gTasks[taskId].data; @@ -2166,7 +2235,7 @@ void DoWallyTutorialBagMenu(void) PrepareBagForWallyTutorial(); AddBagItem(ITEM_POTION, 1); AddBagItem(ITEM_POKE_BALL, 1); - GoToBagMenu(RETURN_LOCATION_BATTLE_2, ITEMS_POCKET, CB2_SetUpReshowBattleScreenAfterMenu2); + GoToBagMenu(ITEMMENULOCATION_WALLY, ITEMS_POCKET, CB2_SetUpReshowBattleScreenAfterMenu2); } void Task_WallyTutorialBagMenu(u8 taskId) @@ -2186,7 +2255,7 @@ void Task_WallyTutorialBagMenu(u8 taskId) PlaySE(SE_SELECT); BagMenu_PrintCursor_(data[0], 2); gSpecialVar_ItemId = ITEM_POKE_BALL; - sub_81AC644(taskId); + OpenContextMenu(taskId); data[8]++; break; case 0x132: @@ -2286,7 +2355,7 @@ void SetupBagMenu_Textboxes(void) { u8 i; - InitWindows(gUnknown_08614174); + InitWindows(sDefaultBagWindows); DeactivateAllTextPrinters(); LoadUserWindowBorderGfx(0, 1, 0xE0); LoadMessageBoxGfx(0, 10, 0xD0); @@ -2297,71 +2366,71 @@ void SetupBagMenu_Textboxes(void) FillWindowPixelBuffer(i, PIXEL_FILL(0)); PutWindowTilemap(i); } - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); } -void BagMenu_Print(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 h) +void BagMenu_Print(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIndex) { - AddTextPrinterParameterized4(windowId, fontId, left, top, letterSpacing, lineSpacing, sFontColorTable[h], speed, str); + AddTextPrinterParameterized4(windowId, fontId, left, top, letterSpacing, lineSpacing, sFontColorTable[colorIndex], speed, str); } //Unused -u8 sub_81AE124(u8 a) +u8 sub_81AE124(u8 which) { - return gBagMenu->windowPointers[a]; + return gBagMenu->windowPointers[which]; } -u8 BagMenu_AddWindow(u8 a) +u8 BagMenu_AddWindow(u8 which) { - u8 *ptr = &gBagMenu->windowPointers[a]; + u8 *ptr = &gBagMenu->windowPointers[which]; if (*ptr == 0xFF) { - *ptr = AddWindow(&gUnknown_086141AC[a]); + *ptr = AddWindow(&sContextMenuWindowTemplates[which]); DrawStdFrameWithCustomTileAndPalette(*ptr, 0, 1, 14); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } return *ptr; } -void BagMenu_RemoveWindow(u8 a) +void BagMenu_RemoveWindow(u8 which) { - u8 *ptr = &gBagMenu->windowPointers[a]; + u8 *ptr = &gBagMenu->windowPointers[which]; if (*ptr != 0xFF) { - ClearStdWindowAndFrameToTransparent(*ptr, 0); + ClearStdWindowAndFrameToTransparent(*ptr, FALSE); ClearWindowTilemap(*ptr); RemoveWindow(*ptr); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); *ptr = 0xFF; } } -u8 AddItemMessageWindow(u8 a) +u8 AddItemMessageWindow(u8 which) { - u8 *ptr = &gBagMenu->windowPointers[a]; + u8 *ptr = &gBagMenu->windowPointers[which]; if (*ptr == 0xFF) - *ptr = AddWindow(&gUnknown_086141AC[a]); + *ptr = AddWindow(&sContextMenuWindowTemplates[which]); return *ptr; } -void bag_menu_RemoveBagItem_message_window(u8 a) +void bag_menu_RemoveBagItem_message_window(u8 which) { - u8 *ptr = &gBagMenu->windowPointers[a]; + u8 *ptr = &gBagMenu->windowPointers[which]; if (*ptr != 0xFF) { ClearDialogWindowAndFrameToTransparent(*ptr, FALSE); // This ClearWindowTilemap call is redundant, since ClearDialogWindowAndFrameToTransparent already calls it. ClearWindowTilemap(*ptr); RemoveWindow(*ptr); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); *ptr = 0xFF; } } void BagMenu_YesNo(u8 a, u8 b, const struct YesNoFuncTable *funcTable) { - CreateYesNoMenuWithCallbacks(a, &gUnknown_086141AC[b], 1, 0, 2, 1, 14, funcTable); + CreateYesNoMenuWithCallbacks(a, &sContextMenuWindowTemplates[b], 1, 0, 2, 1, 14, funcTable); } void DisplayCurrentMoneyWindow(void) diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c index cbc038d8c..cfafcbb75 100644 --- a/src/item_menu_icons.c +++ b/src/item_menu_icons.c @@ -19,7 +19,7 @@ struct CompressedTilesPal // this file's functions static void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite); -static void SpriteCB_ShakeBagVisual(struct Sprite *sprite); +static void SpriteCB_ShakeBagSprite(struct Sprite *sprite); static void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite); static void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite); @@ -456,17 +456,17 @@ static void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite) } } -void ShakeBagVisual(void) +void ShakeBagSprite(void) { struct Sprite *sprite = &gSprites[gBagMenu->spriteId[0]]; if (sprite->affineAnimEnded) { StartSpriteAffineAnim(sprite, 1); - sprite->callback = SpriteCB_ShakeBagVisual; + sprite->callback = SpriteCB_ShakeBagSprite; } } -static void SpriteCB_ShakeBagVisual(struct Sprite *sprite) +static void SpriteCB_ShakeBagSprite(struct Sprite *sprite) { if (sprite->affineAnimEnded) { diff --git a/src/item_use.c b/src/item_use.c index d359dbcef..ff689a19a 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -107,7 +107,7 @@ static void SetUpItemUseCallback(u8 taskId) type = ItemId_GetType(gSpecialVar_ItemId) - 1; if (!InBattlePyramid()) { - gBagMenu->mainCallback2 = sItemUseCallbacks[type]; + gBagMenu->exitCallback = sItemUseCallbacks[type]; Task_FadeAndCloseBagMenu(taskId); } else @@ -192,7 +192,7 @@ static void CB2_CheckMail(void) void ItemUseOutOfBattle_Mail(u8 taskId) { - gBagMenu->mainCallback2 = CB2_CheckMail; + gBagMenu->exitCallback = CB2_CheckMail; Task_FadeAndCloseBagMenu(taskId); } @@ -611,13 +611,13 @@ static void Task_StandingOnHiddenItem(u8 taskId) void ItemUseOutOfBattle_PokeblockCase(u8 taskId) { - if (sub_81221AC() == TRUE) // link func + if (MenuHelpers_LinkSomething() == TRUE) // link func { DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].tUsingRegisteredKeyItem); } else if (gTasks[taskId].tUsingRegisteredKeyItem != TRUE) { - gBagMenu->mainCallback2 = CB2_OpenPokeblockCaseOnField; + gBagMenu->exitCallback = CB2_OpenPokeblockCaseOnField; Task_FadeAndCloseBagMenu(taskId); } else @@ -679,7 +679,7 @@ void ItemUseOutOfBattle_Berry(u8 taskId) { sItemUseOnFieldCB = ItemUseOnFieldCB_Berry; gFieldCallback = FieldCB_UseItemOnField; - gBagMenu->mainCallback2 = CB2_ReturnToField; + gBagMenu->exitCallback = CB2_ReturnToField; Task_FadeAndCloseBagMenu(taskId); } else @@ -1003,7 +1003,7 @@ static void ItemUseInBattle_ShowPartyMenu(u8 taskId) { if (!InBattlePyramid()) { - gBagMenu->mainCallback2 = ChooseMonForInBattleItem; + gBagMenu->exitCallback = ChooseMonForInBattleItem; Task_FadeAndCloseBagMenu(taskId); } else diff --git a/src/link.c b/src/link.c index 34c9ee7ef..aed1afe30 100644 --- a/src/link.c +++ b/src/link.c @@ -1657,7 +1657,7 @@ void CB2_LinkError(void) if (InitWindows(gUnknown_082ED204)) { DeactivateAllTextPrinters(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BG0HOFS, 0); diff --git a/src/mail.c b/src/mail.c index f6f96b012..0fc62678a 100644 --- a/src/mail.c +++ b/src/mail.c @@ -323,7 +323,7 @@ static bool8 MailReadBuildGraphics(void) break; case 5: FreeAllSpritePalettes(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0); SetGpuReg(REG_OFFSET_BG1HOFS, 0); @@ -346,10 +346,10 @@ static bool8 MailReadBuildGraphics(void) DeactivateAllTextPrinters(); break; case 8: - decompress_and_copy_tile_data_to_vram(1, sUnknown_0859F2B8[sMailRead->mailType].tiles, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, sUnknown_0859F2B8[sMailRead->mailType].tiles, 0, 0, 0); break; case 9: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) { return FALSE; } @@ -438,7 +438,7 @@ static void CB2_InitMailRead(void) SetMainCallback2(CB2_MailRead); break; } - } while (sub_81221AC() != TRUE); + } while (MenuHelpers_LinkSomething() != TRUE); } static void sub_8121A1C(void) diff --git a/src/match_call.c b/src/match_call.c index 033276684..307b84413 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1182,7 +1182,7 @@ static bool32 LoadMatchCallWindowGfx(u8 taskId) return FALSE; } - if (!decompress_and_copy_tile_data_to_vram(0, sPokeNavIconGfx, 0, 0x279, 0)) + if (!DecompressAndCopyTileDataToVram(0, sPokeNavIconGfx, 0, 0x279, 0)) { RemoveWindow(taskData[2]); DestroyTask(taskId); @@ -1199,7 +1199,7 @@ static bool32 LoadMatchCallWindowGfx(u8 taskId) static bool32 MoveMatchCallWindowToVram(u8 taskId) { s16 *taskData = gTasks[taskId].data; - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return FALSE; PutWindowTilemap(taskData[2]); diff --git a/src/menu.c b/src/menu.c index 62387c323..738c904ce 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1742,7 +1742,7 @@ void clear_scheduled_bg_copies_to_vram(void) memset(gUnknown_0203CDA4, 0, sizeof(gUnknown_0203CDA4)); } -void schedule_bg_copy_tilemap_to_vram(u8 bgId) +void ScheduleBgCopyTilemapToVram(u8 bgId) { gUnknown_0203CDA4[bgId] = TRUE; } @@ -1771,7 +1771,7 @@ void do_scheduled_bg_tilemap_copies_to_vram(void) } } -void reset_temp_tile_data_buffers(void) +void ResetTempTileDataBuffers(void) { int i; for (i = 0; i < (s32)ARRAY_COUNT(gUnknown_0203CDAC); i++) @@ -1781,7 +1781,7 @@ void reset_temp_tile_data_buffers(void) gUnknown_0203CDA8 = 0; } -bool8 free_temp_tile_data_buffers_if_possible(void) +bool8 FreeTempTileDataBuffersIfPossible(void) { int i; @@ -1803,7 +1803,7 @@ bool8 free_temp_tile_data_buffers_if_possible(void) } } -void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) +void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; if (gUnknown_0203CDA8 < ARRAY_COUNT(gUnknown_0203CDAC)) diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 5b68828c8..69443d309 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -299,7 +299,7 @@ bool8 itemid_80BF6D8_mail_related(u16 itemId) return FALSE; } -bool8 sub_81221AC(void) +bool8 MenuHelpers_LinkSomething(void) { if (IsUpdateLinkStateCBActive() == TRUE || gReceivedRemoteLinkPlayers == 1) return TRUE; @@ -309,13 +309,13 @@ bool8 sub_81221AC(void) static bool8 sub_81221D0(void) { - if (!sub_81221AC()) + if (!MenuHelpers_LinkSomething()) return FALSE; else return sub_8087598(); } -bool8 sub_81221EC(void) +bool8 MenuHelpers_CallLinkSomething(void) { if (sub_81221D0() == TRUE) return TRUE; diff --git a/src/menu_specialized.c b/src/menu_specialized.c index d1b00f883..b7dd1f33a 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -704,7 +704,7 @@ void InitMoveRelearnerWindows(bool8 useContextWindow) DrawStdFrameWithCustomTileAndPalette(2, 0, 1, 0xE); DrawStdFrameWithCustomTileAndPalette(3, 0, 1, 0xE); nullsub_79(); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } static void nullsub_79(void) diff --git a/src/mevent_801BAAC.c b/src/mevent_801BAAC.c index 8596b43cd..1bfac23d1 100644 --- a/src/mevent_801BAAC.c +++ b/src/mevent_801BAAC.c @@ -200,13 +200,13 @@ s32 FadeToWonderCardMenu(void) CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); - decompress_and_copy_tile_data_to_vram(2, sWonderCardData->unk_0170->tiles, 0, 0x008, 0); + DecompressAndCopyTileDataToVram(2, sWonderCardData->unk_0170->tiles, 0, 0x008, 0); sWonderCardData->unk_0176[0] = AddWindow(&gUnknown_082F0E1C[0]); sWonderCardData->unk_0176[1] = AddWindow(&gUnknown_082F0E1C[1]); sWonderCardData->unk_0176[2] = AddWindow(&gUnknown_082F0E1C[2]); break; case 3: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return 0; LoadPalette(stdpal_get(1), 0x20, 0x20); gPaletteFade.bufferTransferDisabled = TRUE; @@ -600,12 +600,12 @@ s32 FadeToWonderNewsMenu(void) CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); - decompress_and_copy_tile_data_to_vram(3, sWonderNewsData->unk_01BC->tiles, 0, 8, 0); + DecompressAndCopyTileDataToVram(3, sWonderNewsData->unk_01BC->tiles, 0, 8, 0); sWonderNewsData->unk_01C8[0] = AddWindow(&gUnknown_082F1DE8[0]); sWonderNewsData->unk_01C8[1] = AddWindow(&gUnknown_082F1DE8[1]); break; case 3: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return 0; LoadPalette(stdpal_get(1), 0x20, 0x20); gPaletteFade.bufferTransferDisabled = TRUE; diff --git a/src/move_relearner.c b/src/move_relearner.c index cbeb3a1df..8c4cf7b2e 100644 --- a/src/move_relearner.c +++ b/src/move_relearner.c @@ -796,7 +796,7 @@ static void HandleInput(bool8 showContest) sMoveRelearnerMenuSate.showContestInfo = FALSE; } - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); MoveRelearnerShowHideHearts(GetCurrentSelectedMove()); break; case LIST_CANCEL: diff --git a/src/overworld.c b/src/overworld.c index 72bc38693..8937af8f1 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1858,7 +1858,7 @@ static bool32 map_loading_iteration_3(u8 *state) (*state)++; break; case 8: - if (free_temp_tile_data_buffers_if_possible() != TRUE) + if (FreeTempTileDataBuffersIfPossible() != TRUE) { apply_map_tileset1_tileset2_palette(gMapHeader.mapLayout); (*state)++; @@ -1933,7 +1933,7 @@ static bool32 load_map_stuff(u8 *state, u32 a2) (*state)++; break; case 8: - if (free_temp_tile_data_buffers_if_possible() != TRUE) + if (FreeTempTileDataBuffersIfPossible() != TRUE) { apply_map_tileset1_tileset2_palette(gMapHeader.mapLayout); (*state)++; @@ -2030,7 +2030,7 @@ static bool32 map_loading_iteration_2_link(u8 *state) (*state)++; break; case 7: - if (free_temp_tile_data_buffers_if_possible() != TRUE) + if (FreeTempTileDataBuffersIfPossible() != TRUE) { apply_map_tileset1_tileset2_palette(gMapHeader.mapLayout); (*state)++; @@ -2101,7 +2101,7 @@ static void sub_8086860(void) static void InitOverworldGraphicsRegisters(void) { clear_scheduled_bg_copies_to_vram(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); SetGpuReg(REG_OFFSET_MOSAIC, 0); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WINOBJ_BG0); @@ -2113,9 +2113,9 @@ static void InitOverworldGraphicsRegisters(void) | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(13, 7)); InitOverworldBgs(); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); + ScheduleBgCopyTilemapToVram(3); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); ChangeBgX(1, 0, 0); diff --git a/src/party_menu.c b/src/party_menu.c index 4ed7ab1b2..c4497e824 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -479,7 +479,7 @@ static void CB2_InitPartyMenu(void) { while (TRUE) { - if (sub_81221EC() == TRUE || ShowPartyMenu() == TRUE || sub_81221AC() == TRUE) + if (MenuHelpers_CallLinkSomething() == TRUE || ShowPartyMenu() == TRUE || MenuHelpers_LinkSomething() == TRUE) break; } } @@ -512,7 +512,7 @@ static bool8 ShowPartyMenu(void) gMain.state++; break; case 5: - if (!sub_81221AC()) + if (!MenuHelpers_LinkSomething()) ResetTasks(); gMain.state++; break; @@ -645,7 +645,7 @@ static bool8 AllocPartyMenuBg(void) InitBgsFromTemplates(0, sPartyMenuBgTemplates, ARRAY_COUNT(sPartyMenuBgTemplates)); SetBgTilemapBuffer(1, sPartyBgTilemapBuffer); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_BLDCNT, 0); ShowBg(0); @@ -759,7 +759,7 @@ static void RenderPartyMenuBox(u8 slot) LoadPartyBoxPalette(&sPartyMenuBoxes[slot], PARTY_PAL_MULTI_ALT); CopyWindowToVram(sPartyMenuBoxes[slot].windowId, 2); PutWindowTilemap(sPartyMenuBoxes[slot].windowId); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } else { @@ -792,7 +792,7 @@ static void RenderPartyMenuBox(u8 slot) AnimatePartySlot(slot, 0); } PutWindowTilemap(sPartyMenuBoxes[slot].windowId); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } } @@ -1086,7 +1086,7 @@ void AnimatePartySlot(u8 slot, u8 animNum) break; } PartyMenuStartSpriteAnim(spriteId, animNum); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } static u8 GetPartyBoxPaletteFlags(u8 slot, u8 animNum) @@ -1127,7 +1127,7 @@ static void DrawCancelConfirmButtons(void) { CopyToBgTilemapBufferRect_ChangePalette(1, sConfirmButton_Tilemap, 23, 16, 7, 2, 17); CopyToBgTilemapBufferRect_ChangePalette(1, sCancelButton_Tilemap, 23, 18, 7, 2, 17); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } bool8 IsMultiBattle(void) @@ -1185,7 +1185,7 @@ u8 GetPartyMenuType(void) void Task_HandleChooseMonInput(u8 taskId) { - if (!gPaletteFade.active && sub_81221EC() != TRUE) + if (!gPaletteFade.active && MenuHelpers_CallLinkSomething() != TRUE) { s8 *slotPtr = GetCurrentPartySlotPtr(); @@ -1322,7 +1322,7 @@ static void HandleChooseMonCancel(u8 taskId, s8 *slotPtr) PlaySE(SE_SELECT); if (DisplayCancelChooseMonYesNo(taskId) != TRUE) { - if (!sub_81221AC()) + if (!MenuHelpers_LinkSomething()) gSpecialVar_0x8004 = PARTY_SIZE + 1; gPartyMenuUseExitCallback = FALSE; *slotPtr = PARTY_SIZE + 1; @@ -1662,7 +1662,7 @@ bool8 IsPartyMenuTextPrinterActive(void) static void Task_WaitForLinkAndReturnToChooseMon(u8 taskId) { - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); gTasks[taskId].func = Task_HandleChooseMonInput; @@ -1675,7 +1675,7 @@ static void Task_ReturnToChooseMonAfterText(u8 taskId) { ClearStdWindowAndFrameToTransparent(6, 0); ClearWindowTilemap(6); - if (sub_81221AC() == TRUE) + if (MenuHelpers_LinkSomething() == TRUE) { gTasks[taskId].func = Task_WaitForLinkAndReturnToChooseMon; } @@ -1693,7 +1693,7 @@ static void DisplayGaveHeldItemMessage(struct Pokemon *mon, u16 item, bool8 keep CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_PkmnWasGivenItem); DisplayPartyMenuMessage(gStringVar4, keepOpen); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void DisplayTookHeldItemMessage(struct Pokemon *mon, u16 item, bool8 keepOpen) @@ -1702,7 +1702,7 @@ static void DisplayTookHeldItemMessage(struct Pokemon *mon, u16 item, bool8 keep CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_ReceivedItemFromPkmn); DisplayPartyMenuMessage(gStringVar4, keepOpen); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void DisplayAlreadyHoldingItemSwitchMessage(struct Pokemon *mon, u16 item, bool8 keepOpen) @@ -1711,7 +1711,7 @@ static void DisplayAlreadyHoldingItemSwitchMessage(struct Pokemon *mon, u16 item CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_PkmnAlreadyHoldingItemSwitch); DisplayPartyMenuMessage(gStringVar4, keepOpen); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void DisplaySwitchedHeldItemMessage(u16 item, u16 item2, bool8 keepOpen) @@ -1720,7 +1720,7 @@ static void DisplaySwitchedHeldItemMessage(u16 item, u16 item2, bool8 keepOpen) CopyItemName(item2, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_SwitchedPkmnItem); DisplayPartyMenuMessage(gStringVar4, keepOpen); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void GiveItemToMon(struct Pokemon *mon, u16 item) @@ -1919,7 +1919,7 @@ static void TryEnterMonForMinigame(u8 taskId, u8 slot) { PlaySE(SE_HAZURE); DisplayPartyMenuMessage(gText_PkmnCantParticipate, FALSE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_ReturnToChooseMonAfterText; } } @@ -1927,7 +1927,7 @@ static void TryEnterMonForMinigame(u8 taskId, u8 slot) static void CancelParticipationPrompt(u8 taskId) { DisplayPartyMenuMessage(gText_CancelParticipation, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_CancelParticipationYesNo; } @@ -2067,7 +2067,7 @@ static void CreateCancelConfirmWindows(bool8 chooseHalf) } PutWindowTilemap(cancelWindowId); CopyWindowToVram(cancelWindowId, 2); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } } @@ -2381,7 +2381,7 @@ static void PartyMenuRemoveWindow(u8 *ptr) ClearStdWindowAndFrameToTransparent(*ptr, 0); RemoveWindow(*ptr); *ptr = 0xFF; - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } } @@ -2427,7 +2427,7 @@ void DisplayPartyMenuStdMessage(u32 stringId) DrawStdFrameWithCustomTileAndPalette(*windowPtr, FALSE, 0x4F, 0xD); StringExpandPlaceholders(gStringVar4, sActionStringTable[stringId]); AddTextPrinterParameterized(*windowPtr, 1, gStringVar4, 0, 1, 0, 0); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } } @@ -2487,7 +2487,7 @@ static u8 DisplaySelectionWindow(u8 windowType) } InitMenuInUpperLeftCorner(sPartyMenuInternal->windowId[0], sPartyMenuInternal->numActions, 0, 1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); return sPartyMenuInternal->windowId[0]; } @@ -2649,7 +2649,7 @@ static bool8 CreateSelectionWindow(u8 taskId) { StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_UpdateHeldItemSprite; return FALSE; } @@ -2668,7 +2668,7 @@ static void Task_TryCreateSelectionWindow(u8 taskId) static void Task_HandleSelectionMenuInput(u8 taskId) { - if (!gPaletteFade.active && sub_81221EC() != TRUE) + if (!gPaletteFade.active && MenuHelpers_CallLinkSomething() != TRUE) { s8 input; s16 *data = gTasks[taskId].data; @@ -2860,7 +2860,7 @@ static void SlidePartyMenuBoxOneStep(u8 taskId) MoveAndBufferPartySlot(sSlot1TilemapBuffer, tSlot1Left + tSlot1Offset, tSlot1Top, tSlot1Width, tSlot1Height, tSlot1SlideDir); if (tSlot2SlideDir != 0) MoveAndBufferPartySlot(sSlot2TilemapBuffer, tSlot2Left + tSlot2Offset, tSlot2Top, tSlot2Width, tSlot2Height, tSlot2SlideDir); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void Task_SlideSelectedSlotsOffscreen(u8 taskId) @@ -2905,7 +2905,7 @@ static void Task_SlideSelectedSlotsOnscreen(u8 taskId) { PutWindowTilemap(sPartyMenuBoxes[gPartyMenu.slotId].windowId); PutWindowTilemap(sPartyMenuBoxes[gPartyMenu.slotId2].windowId); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); Free(sSlot1TilemapBuffer); Free(sSlot2TilemapBuffer); FinishTwoMonAction(taskId); @@ -3023,7 +3023,7 @@ static void CursorCb_Give(u8 taskId) static void CB2_SelectBagItemToGive(void) { if (InBattlePyramid() == FALSE) - GoToBagMenu(RETURN_LOCATION_POKEMON_LIST, POCKETS_COUNT, CB2_GiveHoldItem); + GoToBagMenu(ITEMMENULOCATION_PARTY, POCKETS_COUNT, CB2_GiveHoldItem); else GoToBattlePyramidBagMenu(2, CB2_GiveHoldItem); } @@ -3223,7 +3223,7 @@ static void CursorCb_TakeItem(u8 taskId) DisplayTookHeldItemMessage(mon, item, TRUE); break; } - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_UpdateHeldItemSprite; } @@ -3640,7 +3640,7 @@ static void CursorCb_FieldMove(u8 taskId) PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); - if (sub_81221AC() == TRUE || InUnionRoom() == TRUE) + if (MenuHelpers_LinkSomething() == TRUE || InUnionRoom() == TRUE) { if (fieldMove == FIELD_MOVE_MILK_DRINK || fieldMove == FIELD_MOVE_SOFT_BOILED) DisplayPartyMenuStdMessage(PARTY_MSG_CANT_USE_HERE); @@ -4206,7 +4206,7 @@ void CB2_ShowPartyMenuForItemUse(void) static void CB2_ReturnToBagMenu(void) { if (InBattlePyramid() == FALSE) - GoToBagMenu(RETURN_LOCATION_UNCHANGED, POCKETS_COUNT, NULL); + GoToBagMenu(ITEMMENULOCATION_LAST, POCKETS_COUNT, NULL); else GoToBattlePyramidBagMenu(4, gPyramidBagCursorData.callback); } @@ -4345,7 +4345,7 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) gPartyMenuUseExitCallback = FALSE; PlaySE(SE_SELECT); DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; return; } @@ -4381,7 +4381,7 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) GetMonNickname(mon, gStringVar1); GetMedicineItemEffectMessage(item); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; } } @@ -4391,7 +4391,7 @@ static void Task_DisplayHPRestoredMessage(u8 taskId) GetMonNickname(&gPlayerParty[gPartyMenu.slotId], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); DisplayPartyMenuMessage(gStringVar4, FALSE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); HandleBattleLowHpMusicChange(); gTasks[taskId].func = Task_ClosePartyMenuAfterText; } @@ -4422,7 +4422,7 @@ void ItemUseCB_ReduceEV(u8 taskId, TaskFunc task) gPartyMenuUseExitCallback = FALSE; PlaySE(SE_SELECT); DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; } else @@ -4444,7 +4444,7 @@ void ItemUseCB_ReduceEV(u8 taskId, TaskFunc task) StringExpandPlaceholders(gStringVar4, gText_PkmnAdoresBaseVar2Fell); } DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; } } @@ -4512,7 +4512,7 @@ static void ShowMoveSelectWindow(u8 slot) moveCount++; } InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, moveCount, 0); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void Task_HandleWhichMoveInput(u8 taskId) @@ -4586,7 +4586,7 @@ static void TryUsePPItem(u8 taskId) gPartyMenuUseExitCallback = FALSE; PlaySE(SE_SELECT); DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_ClosePartyMenuAfterText; } else @@ -4599,7 +4599,7 @@ static void TryUsePPItem(u8 taskId) StringCopy(gStringVar1, gMoveNames[move]); GetMedicineItemEffectMessage(item); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_ClosePartyMenuAfterText; } } @@ -4646,7 +4646,7 @@ static void DisplayLearnMoveMessage(const u8 *str) { StringExpandPlaceholders(gStringVar4, str); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void DisplayLearnMoveMessageAndClose(u8 taskId, const u8 *str) @@ -4709,7 +4709,7 @@ static void Task_LearnedMove(u8 taskId) StringCopy(gStringVar2, gMoveNames[move[0]]); StringExpandPlaceholders(gStringVar4, gText_PkmnLearnedMove3); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_DoLearnedMoveFanfareAfterText; } @@ -4824,7 +4824,7 @@ static void StopLearningMovePrompt(u8 taskId) StringCopy(gStringVar2, gMoveNames[gPartyMenu.data1]); StringExpandPlaceholders(gStringVar4, gText_StopLearningMove2); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_StopLearningMoveYesNo; } @@ -4900,7 +4900,7 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task) { gPartyMenuUseExitCallback = FALSE; DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; } else @@ -4913,7 +4913,7 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task) ConvertIntToDecimalStringN(gStringVar2, GetMonData(mon, MON_DATA_LEVEL), STR_CONV_MODE_LEFT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_PkmnElevatedToLvVar2); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_DisplayLevelUpStatsPg1; } } @@ -4928,7 +4928,7 @@ static void UpdateMonDisplayInfoAfterRareCandy(u8 slot, struct Pokemon *mon) DisplayPartyPokemonHPBarCheck(mon, &sPartyMenuBoxes[slot]); UpdatePartyMonHPBar(sPartyMenuBoxes[slot].monSpriteId, mon); AnimatePartySlot(slot, 1); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void Task_DisplayLevelUpStatsPg1(u8 taskId) @@ -4958,7 +4958,7 @@ static void DisplayLevelUpStatsPg1(u8 taskId) arrayPtr[12] = CreateLevelUpStatsWindow(); DrawLevelUpWindowPg1(arrayPtr[12], arrayPtr, &arrayPtr[6], TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY); CopyWindowToVram(arrayPtr[12], 2); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void DisplayLevelUpStatsPg2(u8 taskId) @@ -4967,7 +4967,7 @@ static void DisplayLevelUpStatsPg2(u8 taskId) DrawLevelUpWindowPg2(arrayPtr[12], &arrayPtr[6], TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY); CopyWindowToVram(arrayPtr[12], 2); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void Task_TryLearnNewMoves(u8 taskId) @@ -5041,7 +5041,7 @@ static void DisplayMonNeedsToReplaceMove(u8 taskId) StringCopy(gStringVar2, gMoveNames[gMoveToLearn]); StringExpandPlaceholders(gStringVar4, gText_PkmnNeedsToReplaceMove); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gPartyMenu.data1 = gMoveToLearn; gTasks[taskId].func = Task_ReplaceMoveYesNo; } @@ -5052,7 +5052,7 @@ static void DisplayMonLearnedMove(u8 taskId, u16 move) StringCopy(gStringVar2, gMoveNames[move]); StringExpandPlaceholders(gStringVar4, gText_PkmnLearnedMove3); DisplayPartyMenuMessage(gStringVar4, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gPartyMenu.data1 = move; gTasks[taskId].func = Task_DoLearnedMoveFanfareAfterText; } @@ -5124,7 +5124,7 @@ static void Task_SacredAshLoop(u8 taskId) { gPartyMenuUseExitCallback = FALSE; DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } else { @@ -5146,7 +5146,7 @@ static void Task_SacredAshDisplayHPRestored(u8 taskId) GetMonNickname(&gPlayerParty[gPartyMenu.slotId], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); DisplayPartyMenuMessage(gStringVar4, FALSE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_SacredAshLoop; } @@ -5162,7 +5162,7 @@ void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task) { gPartyMenuUseExitCallback = FALSE; DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = task; } else @@ -5440,7 +5440,7 @@ static void Task_HandleSwitchItemsFromBagYesNoInput(u8 taskId) static void DisplayItemMustBeRemovedFirstMessage(u8 taskId) { DisplayPartyMenuMessage(gText_RemoveMailBeforeItem, TRUE); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; } @@ -5484,7 +5484,7 @@ static void TryGiveMailToSelectedMon(u8 taskId) ClearMailStruct(mail); DisplayPartyMenuMessage(gText_MailTransferredFromMailbox, TRUE); } - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_UpdateHeldItemSpriteAndClosePartyMenu; } diff --git a/src/player_pc.c b/src/player_pc.c index bb2361779..fc0bd9f4c 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -340,7 +340,7 @@ static void InitPlayerPCMenu(u8 taskId) SetStandardWindowBorderStyle(data[4], 0); sub_81995E4(data[4], gPcItemMenuOptionsNum, sPlayerPCMenuActions, gPcItemMenuOptionOrder); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], gPcItemMenuOptionsNum, 0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = PlayerPCProcessMenuInput; } @@ -364,14 +364,14 @@ static void PlayerPCProcessMenuInput(u8 taskId) ClearStdWindowAndFrameToTransparent(data[4], FALSE); ClearWindowTilemap(data[4]); RemoveWindow(data[4]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = PlayerPC_TurnOff; break; default: ClearStdWindowAndFrameToTransparent(data[4], FALSE); ClearWindowTilemap(data[4]); RemoveWindow(data[4]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = sPlayerPCMenuActions[gPcItemMenuOptionOrder[inputOptionId]].func.void_u8; break; } @@ -445,7 +445,7 @@ static void InitItemStorageMenu(u8 taskId, u8 var) SetStandardWindowBorderStyle(data[4], 0); PrintMenuTable(data[4], 4, gPCText_ItemPCOptionsText); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], 4, var); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); ItemStorageMenuPrint(gPCText_OptionDescList[var]); } @@ -492,7 +492,7 @@ static void Task_ItemStorage_Deposit(u8 taskId) if (!gPaletteFade.active) { CleanupOverworldWindowsAndTilemaps(); - sub_81AAC14(); + CB2_GoToItemDepositMenu(); DestroyTask(taskId); } } @@ -586,7 +586,7 @@ static void sub_816B4DC(u8 taskId) ClearStdWindowAndFrameToTransparent(data[4], FALSE); ClearWindowTilemap(data[4]); RemoveWindow(data[4]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static u8 GetMailboxMailCount(void) @@ -626,7 +626,7 @@ static void Mailbox_DrawMailboxMenu(u8 taskId) windowId = sub_81D1C84(0); sub_81D1C84(1); AddTextPrinterParameterized(windowId, 1, gText_Mailbox, GetStringCenterAlignXOffset(1, gText_Mailbox, 0x40), 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].data[5] = sub_81D1DC0(&playerPCItemPageInfo); sub_81D1E90(&playerPCItemPageInfo); } @@ -655,7 +655,7 @@ static void Mailbox_ProcessInput(u8 taskId) sub_81D1D04(0); sub_81D1D04(1); DestroyListMenuTask(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); RemoveScrollIndicatorArrowPair(playerPCItemPageInfo.scrollIndicatorId); gTasks[taskId].func = Mailbox_PrintWhatToDoWithPlayerMailText; break; @@ -678,7 +678,7 @@ static void Mailbox_ReturnToPlayerPC(u8 taskId) sub_81D1D04(0); sub_81D1D04(1); DestroyListMenuTask(data[5], NULL, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); sub_81D1EC0(); ReshowPlayerPC(taskId); } @@ -688,7 +688,7 @@ static void Mailbox_PrintMailOptions(u8 taskId) u8 r4 = sub_81D1C84(2); PrintMenuTable(r4, 4, gMailboxMailOptions); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(r4, 4, 0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = Mailbox_MailOptionsProcessInput; } @@ -865,7 +865,7 @@ static void Mailbox_Cancel(u8 taskId) sub_81D1D04(2); ClearDialogWindowAndFrame(0, 0); Mailbox_DrawMailboxMenu(taskId); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = Mailbox_ProcessInput; } @@ -893,7 +893,7 @@ static u8 sub_816BC7C(u8 a) { *windowIdLoc = AddWindow(&gUnknown_085DFF5C[a]); DrawStdFrameWithCustomTileAndPalette(*windowIdLoc, FALSE, 0x214, 0xE); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } return *windowIdLoc; } @@ -905,7 +905,7 @@ static void sub_816BCC4(u8 a) { ClearStdWindowAndFrameToTransparent(*windowIdLoc, FALSE); ClearWindowTilemap(*windowIdLoc); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); RemoveWindow(*windowIdLoc); *windowIdLoc = 0xFF; } @@ -1076,7 +1076,7 @@ static void ItemStorage_ProcessWithdrawTossInput(u8 taskId) ItemStorage_RefreshListMenu(); data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos); ItemStorage_StartScrollIndicator(); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = ItemStorage_ProcessInput; } @@ -1272,7 +1272,7 @@ static void ItemStorage_DoItemSwap(u8 taskId, bool8 a) sub_81223FC(gUnknown_0203BCC4->spriteIds, 7, 1); gUnknown_0203BCC4->unk666 = 0xFF; data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = ItemStorage_ProcessInput; } diff --git a/src/pokeblock.c b/src/pokeblock.c index b9031e173..523c4ad91 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -490,11 +490,11 @@ static void CB2_InitPokeblockMenu(void) { while (1) { - if (sub_81221EC() == TRUE) + if (MenuHelpers_CallLinkSomething() == TRUE) break; if (InitPokeblockMenu() == TRUE) break; - if (sub_81221AC() == TRUE) + if (MenuHelpers_LinkSomething() == TRUE) break; } } @@ -606,7 +606,7 @@ static void HandleInitBackgrounds(void) InitBgsFromTemplates(0, sBgTemplatesForPokeblockMenu, ARRAY_COUNT(sBgTemplatesForPokeblockMenu)); SetBgTilemapBuffer(2, sPokeblockMenu->tilemap); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); @@ -622,12 +622,12 @@ static bool8 LoadPokeblockMenuGfx(void) switch (sPokeblockMenu->gfxState) { case 0: - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(2, gMenuPokeblock_Gfx, 0, 0, 0); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(2, gMenuPokeblock_Gfx, 0, 0, 0); sPokeblockMenu->gfxState++; break; case 1: - if (free_temp_tile_data_buffers_if_possible() != TRUE) + if (FreeTempTileDataBuffersIfPossible() != TRUE) { LZDecompressWram(gMenuPokeblock_Tilemap, sPokeblockMenu->tilemap); sPokeblockMenu->gfxState++; @@ -669,8 +669,8 @@ static void HandleInitWindows(void) FillWindowPixelBuffer(i, PIXEL_FILL(0)); } - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); } static void PrintOnPokeblockWindow(u8 windowId, const u8 *string, s32 x) @@ -786,14 +786,14 @@ static void sub_8135FCC(s32 pkblId) CopyWindowToVram(7, 2); } - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(2); } static void HandlePokeblockMenuCursor(u16 cursorPos, u16 arg1) { FillBgTilemapBufferRect_Palette0(2, arg1, 0xF, (cursorPos * 2) + 1, 0xE, 2); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void CompactPokeblockSlots(void) @@ -982,7 +982,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (!gPaletteFade.active && sub_81221EC() != TRUE) + if (!gPaletteFade.active && MenuHelpers_CallLinkSomething() != TRUE) { if (gMain.newKeys & SELECT_BUTTON) { @@ -1032,7 +1032,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (sub_81221EC() == TRUE) + if (MenuHelpers_CallLinkSomething() == TRUE) return; if (gMain.newKeys & SELECT_BUTTON) @@ -1101,7 +1101,7 @@ static void HandlePokeblocksSwap(u8 taskId, bool8 noSwap) sSavedPokeblockData.lastItemPos--; data[0] = ListMenuInit(&gMultiuseListMenuTemplate, sSavedPokeblockData.lastItemPage, sSavedPokeblockData.lastItemPos); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); sub_81223FC(sPokeblockMenu->field_E75, FIELD_E75_COUNT, 1); for (i = 0; i < 9; i++) @@ -1125,7 +1125,7 @@ static void PutPokeblockOptionsWindow(u8 taskId) sub_81995E4(data[1], sPokeblockMenu->optionsNo, sPokeblockMenuActions, sPokeblockMenu->pokeblockOptionsIds); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[1], sPokeblockMenu->optionsNo, 0); PutWindowTilemap(data[1]); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); gTasks[taskId].func = Task_HandlePokeblockOptionsInput; } @@ -1134,7 +1134,7 @@ static void Task_HandlePokeblockOptionsInput(u8 taskId) { s8 itemId; - if (sub_81221EC() == TRUE) + if (MenuHelpers_CallLinkSomething() == TRUE) return; itemId = Menu_ProcessInputNoWrap(); @@ -1212,8 +1212,8 @@ static void HandleErasePokeblock(u8 taskId) HandlePokeblockListMenuItems(); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *lastPage, *lastPos); HandlePokeblockMenuCursor(*lastPos, 0x1005); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); TossPokeblockChoice_No(taskId); } } @@ -1221,7 +1221,7 @@ static void HandleErasePokeblock(u8 taskId) static void TossPokeblockChoice_No(u8 taskId) { ClearDialogWindowAndFrameToTransparent(10, FALSE); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); sub_81363BC(); gTasks[taskId].func = Task_HandlePokeblockMenuInput; } @@ -1268,7 +1268,7 @@ static void PokeblockAction_Cancel(u8 taskId) s16 *data = gTasks[taskId].data; ClearStdWindowAndFrameToTransparent(data[1], FALSE); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); sub_81363BC(); gTasks[taskId].func = Task_HandlePokeblockMenuInput; } diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 5edf14309..f6e6a19b2 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -607,11 +607,11 @@ void CB2_PreparePokeblockFeedScene(void) { while (1) { - if (sub_81221EC() == TRUE) + if (MenuHelpers_CallLinkSomething() == TRUE) break; if (TransitionToPokeblockFeedScene() == TRUE) break; - if (sub_81221AC() == TRUE) + if (MenuHelpers_LinkSomething() == TRUE) break; } } @@ -624,7 +624,7 @@ static void HandleInitBackgrounds(void) InitBgsFromTemplates(0, sBackgroundTemplates, ARRAY_COUNT(sBackgroundTemplates)); SetBgTilemapBuffer(1, sPokeblockFeed->tilemapBuffer); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); @@ -676,12 +676,12 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon) sPokeblockFeed->loadGfxState++; break; case 6: - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(1, gBattleTerrainTiles_Building, 0, 0, 0); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(1, gBattleTerrainTiles_Building, 0, 0, 0); sPokeblockFeed->loadGfxState++; break; case 7: - if (free_temp_tile_data_buffers_if_possible() != TRUE) + if (FreeTempTileDataBuffersIfPossible() != TRUE) { LZDecompressWram(gUnknown_08D9BA44, sPokeblockFeed->tilemapBuffer); sPokeblockFeed->loadGfxState++; @@ -704,7 +704,7 @@ static void HandleInitWindows(void) LoadPalette(gUnknown_0860F074, 0xF0, 0x20); FillWindowPixelBuffer(0, PIXEL_FILL(0)); PutWindowTilemap(0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void SetPokeblockSpritePal(u8 pokeblockCaseId) diff --git a/src/pokedex_area_region_map.c b/src/pokedex_area_region_map.c index dfea9ea44..82d5e50e5 100644 --- a/src/pokedex_area_region_map.c +++ b/src/pokedex_area_region_map.c @@ -23,15 +23,15 @@ void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) if (mode == 0) { SetBgAttribute(template->bg, BG_ATTR_METRIC, 0); - decompress_and_copy_tile_data_to_vram(template->bg, sPokedexAreaMap_Gfx, 0, template->offset, 0); - sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, sPokedexAreaMap_Tilemap, 0, 0, 1), template->offset, 32, 32, FALSE); + DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMap_Gfx, 0, template->offset, 0); + sub_8199D3C(DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMap_Tilemap, 0, 0, 1), template->offset, 32, 32, FALSE); } else { SetBgAttribute(template->bg, BG_ATTR_METRIC, 2); SetBgAttribute(template->bg, BG_ATTR_TYPE, 1); - decompress_and_copy_tile_data_to_vram(template->bg, sPokedexAreaMapAffine_Gfx, 0, template->offset, 0); - sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, sPokedexAreaMapAffine_Tilemap, 0, 0, 1), template->offset, 64, 64, TRUE); + DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Gfx, 0, template->offset, 0); + sub_8199D3C(DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Tilemap, 0, 0, 1), template->offset, 64, 64, TRUE); } ChangeBgX(template->bg, 0, 0); @@ -43,7 +43,7 @@ void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) bool32 sub_81C4E90(void) { - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) { ShowBg(*sPokedexAreaMapBgNum); return FALSE; diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index ed692d6e3..a2545cc1a 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -310,11 +310,11 @@ static bool8 DrawAreaGlow(void) BuildAreaGlowTilemap(); break; case 2: - decompress_and_copy_tile_data_to_vram(2, sAreaGlow_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, sAreaGlow_Gfx, 0, 0, 0); LoadBgTilemap(2, sPokedexAreaScreen->areaGlowTilemap, 0x500, 0); break; case 3: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) { CpuCopy32(sAreaGlow_Pal, gPlttBufferUnfaded + 0xA0, 0x20); sPokedexAreaScreen->drawAreaGlowState++; diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index f2f416c35..e755b6ca8 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -2966,18 +2966,18 @@ static void sub_802D150(void) ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gUnknown_082FE164, ARRAY_COUNT(gUnknown_082FE164)); InitWindows(gUnknown_082FE174); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); sub_802C974(gUnknown_02022D00); sub_802DD08(); LoadPalette(gPkmnJumpBgPal, 0, 0x20); - decompress_and_copy_tile_data_to_vram(3, gPkmnJumpBgGfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(3, gPkmnJumpBgTilemap, 0, 0, 1); + DecompressAndCopyTileDataToVram(3, gPkmnJumpBgGfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(3, gPkmnJumpBgTilemap, 0, 0, 1); LoadPalette(gPkmnJumpVenusaurPal, 0x30, 0x20); - decompress_and_copy_tile_data_to_vram(2, gPkmnJumpVenusaurGfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(2, gPkmnJumpVenusaurTilemap, 0, 0, 1); + DecompressAndCopyTileDataToVram(2, gPkmnJumpVenusaurGfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gPkmnJumpVenusaurTilemap, 0, 0, 1); LoadPalette(gPkmnJumpResultsPal, 0x10, 0x20); - decompress_and_copy_tile_data_to_vram(1, gPkmnJumpResultsGfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(1, gPkmnJumpResultsTilemap, 0, 0, 1); + DecompressAndCopyTileDataToVram(1, gPkmnJumpResultsGfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gPkmnJumpResultsTilemap, 0, 0, 1); LoadPalette(gPkmnJumpPal3, 0x20, 0x20); SetBgTilemapBuffer(0, gUnknown_02022D00->tilemapBuffer); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); @@ -2991,7 +2991,7 @@ static void sub_802D150(void) gUnknown_02022D00->unk4++; break; case 1: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) { sub_802DBF8(); sub_802CE9C(gUnknown_02022D00); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index ef9afe663..30a29b6ea 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -3892,7 +3892,7 @@ static void Cb_ChangeScreen(u8 taskId) break; case SCREEN_CHANGE_ITEM_FROM_BAG: FreePSSData(); - GoToBagMenu(11, 0, Cb2_ReturnToPSS); + GoToBagMenu(ITEMMENULOCATION_PCBOX, 0, Cb2_ReturnToPSS); break; } @@ -3944,7 +3944,7 @@ static void LoadPSSMenuGfx(void) LZ77UnCompWram(gUnknown_085722A0, sPSSData->field_5AC4); SetBgTilemapBuffer(1, sPSSData->field_5AC4); ShowBg(1); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } static bool8 InitPSSWindows(void) @@ -4010,7 +4010,7 @@ static void RefreshCursorMonData(void) LoadCursorMonGfx(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality); PrintCursorMonInfo(); sub_80CA65C(); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void BoxSetMosaic(void) @@ -4154,7 +4154,7 @@ static void sub_80CA65C(void) } sub_80D2918(0); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } static void sub_80CA704(void) @@ -4181,7 +4181,7 @@ static void sub_80CA704(void) sub_80D2918(2); } - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); sPSSData->unk_02C7 = 0; } @@ -4202,7 +4202,7 @@ static bool8 ShowPartyMenu(void) sPSSData->field_2C2++; sub_80D27F4(1, 3, 1); sub_80D2918(1); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); sub_80CBAF0(8); if (++sPSSData->field_2C5 == 20) { @@ -4236,7 +4236,7 @@ static bool8 HidePartyMenu(void) sub_80CBAF0(-8); if (++sPSSData->field_2C5 != 20) { - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); return TRUE; } else @@ -4246,7 +4246,7 @@ static bool8 HidePartyMenu(void) CompactPartySlots(); sub_80D27AC(2, 0, 0, 9, 2); sub_80D2918(2); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); return FALSE; } } @@ -4262,7 +4262,7 @@ static void sub_80CA984(bool8 arg0) sub_80D27AC(2, 0, 2, 9, 2); sub_80D2918(2); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } static void sub_80CA9C0(void) @@ -4331,7 +4331,7 @@ static void sub_80CAB20(void) sub_80CAA74(); sub_80D27AC(1, 0, 0, 12, 22); sub_80D2918(1); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } static void SetUpDoShowPartyMenu(void) @@ -4422,7 +4422,7 @@ static void PrintStorageActionText(u8 id) DrawTextBorderOuter(1, 2, 14); PutWindowTilemap(1); CopyWindowToVram(1, 2); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void ShowYesNoWindow(s8 cursorPos) @@ -4434,7 +4434,7 @@ static void ShowYesNoWindow(s8 cursorPos) static void ClearBottomWindow(void) { ClearStdWindowAndFrameToTransparent(1, FALSE); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void AddWallpaperSetsMenu(void) @@ -7904,7 +7904,7 @@ static void AddMenu(void) DrawStdFrameWithCustomTileAndPalette(sPSSData->field_CB0, FALSE, 11, 14); PrintMenuTable(sPSSData->field_CB0, sPSSData->menuItemsCount, (void*)sPSSData->menuItems); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sPSSData->field_CB0, sPSSData->menuItemsCount, 0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); sPSSData->field_CAE = 0; } @@ -9127,7 +9127,7 @@ static bool8 sub_80D18E4(void) sub_80D19B4(var); FillBgTilemapBufferRect(0, 0, var + 1, 12, 1, 9, 0x11); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); return TRUE; } @@ -9141,7 +9141,7 @@ static void sub_80D19B4(u32 arg0) FillBgTilemapBufferRect(0, 0x13B, arg0, 0xD, 1, 7, 0xFu); FillBgTilemapBufferRect(0, 0x13C, arg0, 0xC, 1, 1, 0xFu); FillBgTilemapBufferRect(0, 0x13D, arg0, 0x14, 1, 1, 0xFu); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void sub_80D1A48(struct Sprite *sprite) diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index fc0e432bd..e8b30f773 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1133,7 +1133,7 @@ static void VBlank(void) static void CB2_InitSummaryScreen(void) { - while (sub_81221EC() != TRUE && LoadGraphics() != TRUE && sub_81221AC() != TRUE); + while (MenuHelpers_CallLinkSomething() != TRUE && LoadGraphics() != TRUE && MenuHelpers_LinkSomething() != TRUE); } static bool8 LoadGraphics(void) @@ -1271,9 +1271,9 @@ static void InitBGs(void) SetBgTilemapBuffer(2, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_SKILLS][0]); SetBgTilemapBuffer(3, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0]); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); + ScheduleBgCopyTilemapToVram(3); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_BLDCNT, 0); ShowBg(0); @@ -1287,12 +1287,12 @@ static bool8 DecompressGraphics(void) switch (sMonSummaryScreen->switchCounter) { case 0: - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(1, &gStatusScreenBitmap, 0, 0, 0); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(1, &gStatusScreenBitmap, 0, 0, 0); sMonSummaryScreen->switchCounter++; break; case 1: - if (free_temp_tile_data_buffers_if_possible() != 1) + if (FreeTempTileDataBuffersIfPossible() != 1) { LZDecompressWram(gPageInfoTilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0]); sMonSummaryScreen->switchCounter++; @@ -1477,7 +1477,7 @@ static void BeginCloseSummaryScreen(u8 taskId) static void CloseSummaryScreen(u8 taskId) { - if (sub_81221EC() != TRUE && !gPaletteFade.active) + if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) { SetMainCallback2(sMonSummaryScreen->callback); gLastViewedMonIndex = sMonSummaryScreen->curMonIndex; @@ -1495,7 +1495,7 @@ static void CloseSummaryScreen(u8 taskId) static void Task_HandleInput(u8 taskId) { - if (sub_81221EC() != TRUE && !gPaletteFade.active) + if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) { if (gMain.newKeys & DPAD_UP) { @@ -1579,7 +1579,7 @@ static void ChangeSummaryPokemon(u8 taskId, s8 delta) { SetSpriteInvisibility(SPRITE_ARR_ID_STATUS, TRUE); ClearWindowTilemap(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATUS); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); HandleStatusTilemap(0, 2); } sMonSummaryScreen->curMonIndex = monId; @@ -1647,7 +1647,7 @@ static void Task_ChangeSummaryMon(u8 taskId) gSprites[sMonSummaryScreen->spriteIds[SPRITE_ARR_ID_MON]].data[2] = 0; break; default: - if (sub_81221EC() == 0 && FuncIsActiveTask(Task_ShowStatusWindow) == 0) + if (MenuHelpers_CallLinkSomething() == 0 && FuncIsActiveTask(Task_ShowStatusWindow) == 0) { data[0] = 0; gTasks[taskId].func = Task_HandleInput; @@ -1756,14 +1756,14 @@ static void PssScrollRight(u8 taskId) // Scroll right data[1] = 1; SetBgAttribute(1, BG_ATTR_PRIORITY, 1); SetBgAttribute(2, BG_ATTR_PRIORITY, 2); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } else { data[1] = 2; SetBgAttribute(2, BG_ATTR_PRIORITY, 1); SetBgAttribute(1, BG_ATTR_PRIORITY, 2); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } ChangeBgX(data[1], 0, 0); SetBgTilemapBuffer(data[1], sMonSummaryScreen->bgTilemapBuffers[sMonSummaryScreen->currPageIndex][0]); @@ -1813,13 +1813,13 @@ static void PssScrollLeftEnd(u8 taskId) // display left { SetBgAttribute(1, BG_ATTR_PRIORITY, 1); SetBgAttribute(2, BG_ATTR_PRIORITY, 2); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } else { SetBgAttribute(2, BG_ATTR_PRIORITY, 1); SetBgAttribute(1, BG_ATTR_PRIORITY, 2); - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); } if (sMonSummaryScreen->currPageIndex > 1) { @@ -1865,9 +1865,9 @@ static void SwitchToMoveSelection(u8 taskId) PrintMoveDetails(move); PrintNewMoveDetailsOrCancelText(); SetNewMoveTypeIcon(); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); CreateMoveSelectorSprites(SPRITE_ARR_ID_MOVE_SELECTOR1); gTasks[taskId].func = Task_HandleInput_MoveSelect; } @@ -1876,7 +1876,7 @@ static void Task_HandleInput_MoveSelect(u8 taskId) { s16 *data = gTasks[taskId].data; - if (sub_81221EC() != 1) + if (MenuHelpers_CallLinkSomething() != 1) { if (gMain.newKeys & DPAD_UP) { @@ -1950,8 +1950,8 @@ static void ChangeSelectedMove(s16 *taskData, s8 direction, u8 *moveIndexPtr) break; } DrawContestMoveHearts(move); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); PrintMoveDetails(move); if ((*moveIndexPtr == MAX_MON_MOVES && sMonSummaryScreen->newMove == MOVE_NONE) || taskData[1] == 1) @@ -1959,7 +1959,7 @@ static void ChangeSelectedMove(s16 *taskData, s8 direction, u8 *moveIndexPtr) ClearWindowTilemap(PSS_LABEL_WINDOW_PORTRAIT_SPECIES); if (!gSprites[sMonSummaryScreen->spriteIds[SPRITE_ARR_ID_STATUS]].invisible) ClearWindowTilemap(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATUS); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); HandlePowerAccTilemap(9, -3); HandleAppealJamTilemap(9, -3, move); } @@ -1969,7 +1969,7 @@ static void ChangeSelectedMove(s16 *taskData, s8 direction, u8 *moveIndexPtr) { ClearWindowTilemap(PSS_LABEL_WINDOW_MOVES_POWER_ACC); ClearWindowTilemap(PSS_LABEL_WINDOW_MOVES_APPEAL_JAM); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); HandlePowerAccTilemap(0, 3); HandleAppealJamTilemap(0, 3, 0); } @@ -1998,9 +1998,9 @@ static void CloseMoveSelectMode(u8 taskId) HandlePowerAccTilemap(0, 3); HandleAppealJamTilemap(0, 3, 0); } - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_HandleInput; } @@ -2016,7 +2016,7 @@ static void Task_HandleInput_MovePositionSwitch(u8 taskId) { s16* data = gTasks[taskId].data; - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { if (gMain.newKeys & DPAD_UP) { @@ -2071,8 +2071,8 @@ static void ExitMovePositionSwitchMode(u8 taskId, bool8 swapMoves) move = sMonSummaryScreen->summary.moves[sMonSummaryScreen->firstMoveIndex]; PrintMoveDetails(move); DrawContestMoveHearts(move); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); gTasks[taskId].func = Task_HandleInput_MoveSelect; } @@ -2157,7 +2157,7 @@ static void Task_HandleReplaceMoveInput(u8 taskId) { s16* data = gTasks[taskId].data; - if (sub_81221EC() != TRUE) + if (MenuHelpers_CallLinkSomething() != TRUE) { if (gPaletteFade.active != TRUE) { @@ -2221,7 +2221,7 @@ static void ShowCantForgetHMsWindow(u8 taskId) { ClearWindowTilemap(PSS_LABEL_WINDOW_MOVES_POWER_ACC); ClearWindowTilemap(PSS_LABEL_WINDOW_MOVES_APPEAL_JAM); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); HandlePowerAccTilemap(0, 3); HandleAppealJamTilemap(0, 3, 0); PrintHMMovesCantBeForgotten(); @@ -2286,7 +2286,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId) ClearWindowTilemap(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATUS); move = sMonSummaryScreen->summary.moves[sMonSummaryScreen->firstMoveIndex]; PrintMoveDetails(move); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); HandlePowerAccTilemap(9, -3); HandleAppealJamTilemap(9, -3, move); gTasks[taskId].func = Task_HandleReplaceMoveInput; @@ -2362,7 +2362,7 @@ static void DrawPagination(void) // Updates the pagination dots at the top of th } } CopyToBgTilemapBufferRect_ChangePalette(3, alloced, 11, 0, 8, 2, 16); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(3); Free(alloced); } @@ -2435,11 +2435,11 @@ static void Task_ShowPowerAccWindow(u8 taskId) PutWindowTilemap(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATUS); PutWindowTilemap(PSS_LABEL_WINDOW_PORTRAIT_SPECIES); } - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); DestroyTask(taskId); } - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); } static void HandleAppealJamTilemap(u16 a, s16 b, u16 move) @@ -2491,11 +2491,11 @@ static void Task_ShowAppealJamWindow(u8 taskId) } PutWindowTilemap(PSS_LABEL_WINDOW_PORTRAIT_SPECIES); } - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); DestroyTask(taskId); } - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); } static void HandleStatusTilemap(u16 a, s16 b) @@ -2525,14 +2525,14 @@ static void Task_ShowStatusWindow(u8 taskId) data[1] = sStatusTilemapCtrl1.field_6; ChangeTilemap(&sStatusTilemapCtrl1, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0], data[1], FALSE); ChangeTilemap(&sStatusTilemapCtrl2, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0], data[1], FALSE); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(3); if (data[1] <= 0 || data[1] >= sStatusTilemapCtrl1.field_6) { if (data[0] < 0) { CreateSetStatusSprite(); PutWindowTilemap(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATUS); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } DestroyTask(taskId); } @@ -2576,7 +2576,7 @@ static void DrawPokerusCuredSymbol(struct Pokemon *mon) // This checks if the mo sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0][0x223] = 0x81A; sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][1][0x223] = 0x81A; } - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(3); } static void SetDexNumberColor(bool8 isMonShiny) @@ -2585,7 +2585,7 @@ static void SetDexNumberColor(bool8 isMonShiny) SetBgTilemapPalette(3, 1, 4, 8, 8, 0); else SetBgTilemapPalette(3, 1, 4, 8, 8, 5); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(3); } static void DrawExperienceProgressBar(struct Pokemon *unused) @@ -2625,9 +2625,9 @@ static void DrawExperienceProgressBar(struct Pokemon *unused) } if (GetBgTilemapBuffer(1) == sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_SKILLS][0]) - schedule_bg_copy_tilemap_to_vram(1); + ScheduleBgCopyTilemapToVram(1); else - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void DrawContestMoveHearts(u16 move) @@ -2698,7 +2698,7 @@ static void PrintMonInfo(void) PrintNotEggInfo(); else PrintEggInfo(); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void PrintNotEggInfo(void) @@ -2886,7 +2886,7 @@ static void PutPageWindowTilemaps(u8 page) for (i = 0; i < ARRAY_COUNT(sMonSummaryScreen->windowIds); i++) PutWindowTilemap(sMonSummaryScreen->windowIds[i]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void ClearPageWindowTilemaps(u8 page) @@ -2933,7 +2933,7 @@ static void ClearPageWindowTilemaps(u8 page) for (i = 0; i < ARRAY_COUNT(sMonSummaryScreen->windowIds); i++) RemoveWindowByIndex(i); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static u8 AddWindowFromTemplateList(const struct WindowTemplate *template, u8 templateId) @@ -3629,7 +3629,7 @@ static void PrintMoveDetails(u16 move) ClearWindowTilemap(windowId); } - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void PrintNewMoveDetailsOrCancelText(void) @@ -3712,7 +3712,7 @@ static void SetSpriteInvisibility(u8 spriteArrayId, bool8 invisible) static void HidePageSpecificSprites(void) { - // Keeps Pokémon, caught ball and status sprites visible. + // Keeps Pokďż˝mon, caught ball and status sprites visible. u8 i; for (i = SPRITE_ARR_ID_TYPE; i < ARRAY_COUNT(sMonSummaryScreen->spriteIds); i++) diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index ed253f90f..65a85aa7e 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -208,15 +208,15 @@ u32 sub_81CDE94(s32 state) SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); - decompress_and_copy_tile_data_to_vram(3, gPokenavCondition_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(3, gPokenavCondition_Gfx, 0, 0, 0); return LT_INC_AND_PAUSE; case 2: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - decompress_and_copy_tile_data_to_vram(2, gUnknown_08623228, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gUnknown_08623228, 0, 0, 0); return LT_INC_AND_PAUSE; case 3: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; LZ77UnCompVram(gPokenavCondition_Tilemap, structPtr->tilemapBuffers[0]); @@ -230,7 +230,7 @@ u32 sub_81CDE94(s32 state) structPtr->unk1814 = -80; return LT_INC_AND_PAUSE; case 4: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; LZ77UnCompVram(gUnknown_0862323C, structPtr->tilemapBuffers[2]); @@ -246,7 +246,7 @@ u32 sub_81CDE94(s32 state) SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]); return LT_INC_AND_PAUSE; case 6: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; structPtr->unk1820 = AddWindow(&gUnknown_08623364); diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index 74bc3cc9d..7a48b9234 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -408,7 +408,7 @@ static u32 sub_81CF418(s32 state) { case 0: InitBgTemplates(gUnknown_08623590, NELEMS(gUnknown_08623590)); - decompress_and_copy_tile_data_to_vram(1, gUnknown_086233E4, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gUnknown_086233E4, 0, 0, 0); SetBgTilemapBuffer(1, unk->buff); CopyToBgTilemapBuffer(1, gUnknown_086234AC, 0, 0); CopyBgTilemapBufferToVram(1); @@ -416,13 +416,13 @@ static u32 sub_81CF418(s32 state) CopyBgTilemapBufferToVram(1); return LT_INC_AND_PAUSE; case 1: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; if (!sub_81CF0C0()) return LT_PAUSE; return LT_INC_AND_PAUSE; case 2: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 0x20); sub_81CF88C(); @@ -434,7 +434,7 @@ static u32 sub_81CF418(s32 state) PrintHelpBarText(HELPBAR_CONDITION_MON_LIST); return LT_INC_AND_PAUSE; case 4: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; ChangeBgX(1, 0, 0); ChangeBgY(1, 0, 0); diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index fdd27b087..d9aae7e4e 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -342,18 +342,18 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gPokenavMainMenuBgTemplates, ARRAY_COUNT(gPokenavMainMenuBgTemplates)); ResetBgPositions(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); return LT_INC_AND_CONTINUE; case 1: structPtr = GetSubstructPtr(0); - decompress_and_copy_tile_data_to_vram(0, &gPokenavHeader_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0); SetBgTilemapBuffer(0, structPtr->tilemapBuffer); CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0); CopyPaletteIntoBufferUnfaded(gPokenavHeader_Pal, 0, 0x20); CopyBgTilemapBufferToVram(0); return LT_INC_AND_PAUSE; case 2: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; InitHelpBar(); diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index aa69c592f..d03bad88b 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -325,7 +325,7 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) InitBgTemplates(gUnknown_0862278C, ARRAY_COUNT(gUnknown_0862278C)); ChangeBgX(2, 0, 0); ChangeBgY(2, 0, 0); - decompress_and_copy_tile_data_to_vram(2, sMatchCallUI_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, sMatchCallUI_Gfx, 0, 0, 0); SetBgTilemapBuffer(2, state->unk1024); CopyToBgTilemapBuffer(2, sMatchCallUI_Tilemap, 0, 0); CopyBgTilemapBufferToVram(2); @@ -333,7 +333,7 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) CopyBgTilemapBufferToVram(2); return LT_INC_AND_PAUSE; case 1: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; sub_8199DF0(1, 0, 0, 1); @@ -343,16 +343,16 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) CopyBgTilemapBufferToVram(1); return LT_INC_AND_PAUSE; case 2: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; sub_81CC034(state); - decompress_and_copy_tile_data_to_vram(3, gUnknown_08622760, 0, 0, 0); + DecompressAndCopyTileDataToVram(3, gUnknown_08622760, 0, 0, 0); CopyPaletteIntoBufferUnfaded(gUnknown_08622700, 0x30, 0x20); CopyPaletteIntoBufferUnfaded(gUnknown_08622720, 0x50, 0x20); return LT_INC_AND_PAUSE; case 3: - if (free_temp_tile_data_buffers_if_possible() || !sub_81CAE28()) + if (FreeTempTileDataBuffersIfPossible() || !sub_81CAE28()) return LT_PAUSE; sub_81CBBB8(); diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index 1dfbf3417..86ad8c744 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -410,7 +410,7 @@ static u32 LoopedTask_OpenMenu(s32 state) { case 0: InitBgTemplates(gUnknown_08620194, ARRAY_COUNT(gUnknown_08620194)); - decompress_and_copy_tile_data_to_vram(1, gPokenavMessageBox_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gPokenavMessageBox_Gfx, 0, 0, 0); SetBgTilemapBuffer(1, unk->bg1TilemapBuffer); CopyToBgTilemapBuffer(1, gPokenavMessageBox_Tilemap, 0, 0); CopyBgTilemapBufferToVram(1); @@ -423,23 +423,23 @@ static u32 LoopedTask_OpenMenu(s32 state) ChangeBgY(3, 0, 0); return LT_INC_AND_PAUSE; case 1: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - decompress_and_copy_tile_data_to_vram(2, gUnknown_0861FD6C, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(2, gUnknown_0861FFF4, 0, 0, 1); + DecompressAndCopyTileDataToVram(2, gUnknown_0861FD6C, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gUnknown_0861FFF4, 0, 0, 1); CopyPaletteIntoBufferUnfaded(gUnknown_0861FD4C, 0x20, 0x20); return LT_INC_AND_PAUSE; case 2: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - decompress_and_copy_tile_data_to_vram(3, gUnknown_0861FC98, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(3, gUnknown_0861FCAC, 0, 0, 1); + DecompressAndCopyTileDataToVram(3, gUnknown_0861FC98, 0, 0, 0); + DecompressAndCopyTileDataToVram(3, gUnknown_0861FCAC, 0, 0, 1); CopyPaletteIntoBufferUnfaded(gUnknown_0861FC78, 0x30, 0x20); if (GetPokenavMenuType() == POKENAV_MENU_TYPE_CONDITION || GetPokenavMenuType() == POKENAV_MENU_TYPE_CONDITION_SEARCH) sub_81CA850(); return LT_INC_AND_PAUSE; case 3: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; AddOptionDescriptionWindow(); sub_81CA7D4(); diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index dff6b8c6c..e858fad4a 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -506,7 +506,7 @@ static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *state) state->infoWindowId = AddWindow(&sMapSecInfoWindowTemplate); LoadUserWindowBorderGfx_(state->infoWindowId, 0x42, 0x40); DrawTextBorderOuter(state->infoWindowId, 0x42, 4); - decompress_and_copy_tile_data_to_vram(1, sRegionMapCityZoomTiles_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, sRegionMapCityZoomTiles_Gfx, 0, 0, 0); FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); PutWindowTilemap(state->infoWindowId); CopyWindowToVram(state->infoWindowId, 3); @@ -522,7 +522,7 @@ static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *state) static bool32 TryFreeTempTileDataBuffers(void) { - return free_temp_tile_data_buffers_if_possible(); + return FreeTempTileDataBuffersIfPossible(); } static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state) diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_1.c index db3b7f08e..ffc049c47 100644 --- a/src/pokenav_ribbons_1.c +++ b/src/pokenav_ribbons_1.c @@ -414,14 +414,14 @@ static u32 sub_81CFEB8(s32 state) { case 0: InitBgTemplates(gUnknown_086237B0, NELEMS(gUnknown_086237B0)); - decompress_and_copy_tile_data_to_vram(1, gUnknown_08623604, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gUnknown_08623604, 0, 0, 0); SetBgTilemapBuffer(1, unk->buff); CopyToBgTilemapBuffer(1, gUnknown_086236CC, 0, 0); CopyPaletteIntoBufferUnfaded(gUnknown_086235E4, 0x10, 0x20); CopyBgTilemapBufferToVram(1); return LT_INC_AND_PAUSE; case 1: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; if (!sub_81CFB18()) return LT_PAUSE; @@ -430,7 +430,7 @@ static u32 sub_81CFEB8(s32 state) ShowBg(1); return LT_INC_AND_PAUSE; case 2: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; CopyPaletteIntoBufferUnfaded(gUnknown_08623790, 0x20, 0x20); sub_81D0304(); @@ -441,7 +441,7 @@ static u32 sub_81CFEB8(s32 state) sub_81D024C(unk); return LT_INC_AND_PAUSE; case 4: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; ShowBg(2); HideBg(3); diff --git a/src/pokenav_ribbons_2.c b/src/pokenav_ribbons_2.c index f27b664ea..bb6116472 100644 --- a/src/pokenav_ribbons_2.c +++ b/src/pokenav_ribbons_2.c @@ -517,17 +517,17 @@ u32 sub_81D0A6C(s32 state) { case 0: InitBgTemplates(gUnknown_08624B98, ARRAY_COUNT(gUnknown_08624B98)); - decompress_and_copy_tile_data_to_vram(2, gUnknown_08DDE030, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gUnknown_08DDE030, 0, 0, 0); SetBgTilemapBuffer(2, structPtr->tilemapBuffers[0]); CopyToBgTilemapBuffer(2, gUnknown_08DDE12C, 0, 0); CopyPaletteIntoBufferUnfaded(gUnknown_08DDE010, 0x10, 0x20); CopyBgTilemapBufferToVram(2); return LT_INC_AND_PAUSE; case 1: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) { sub_8199DF0(1, 0, 0, 1); - decompress_and_copy_tile_data_to_vram(1, sRibbonIconsSmall_Gfx, 0, 1, 0); + DecompressAndCopyTileDataToVram(1, sRibbonIconsSmall_Gfx, 0, 1, 0); SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]); FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 32, 20); CopyPaletteIntoBufferUnfaded(gUnknown_08623FF8, 0x20, 0xA0); @@ -537,21 +537,21 @@ u32 sub_81D0A6C(s32 state) } return LT_PAUSE; case 2: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) { sub_81D0E60(structPtr); return LT_INC_AND_PAUSE; } return LT_PAUSE; case 3: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) { sub_81D0FCC(structPtr); return LT_INC_AND_PAUSE; } return LT_PAUSE; case 4: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) { sub_81D10A4(structPtr); return LT_INC_AND_PAUSE; diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index cef7f4cdd..d902b7319 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -1508,9 +1508,9 @@ static void sub_81D6FE0(void) SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); ShowBg(1); @@ -1520,9 +1520,9 @@ static void sub_81D6FE0(void) static void sub_81D706C(void) { - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(0, gRaySceneClouds_Gfx, 0, 0, 0); - while (free_temp_tile_data_buffers_if_possible()); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(0, gRaySceneClouds_Gfx, 0, 0, 0); + while (FreeTempTileDataBuffersIfPossible()); LZDecompressWram(gRaySceneClouds2_Tilemap, sRayScene->tilemapBuffers[0]); LZDecompressWram(gRaySceneClouds1_Tilemap, sRayScene->tilemapBuffers[1]); @@ -1921,9 +1921,9 @@ static void sub_81D7E10(void) SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); ShowBg(1); @@ -1933,11 +1933,11 @@ static void sub_81D7E10(void) static void sub_81D7E9C(void) { - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(0, gRaySceneClouds_Gfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(1, gRaySceneOvercast_Gfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(2, gRaySceneRayquaza_Gfx, 0, 0, 0); - while (free_temp_tile_data_buffers_if_possible()); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(0, gRaySceneClouds_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gRaySceneOvercast_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gRaySceneRayquaza_Gfx, 0, 0, 0); + while (FreeTempTileDataBuffersIfPossible()); LZDecompressWram(gRaySceneClouds2_Tilemap, sRayScene->tilemapBuffers[0]); LZDecompressWram(gRaySceneOvercast_Tilemap, sRayScene->tilemapBuffers[1]); @@ -2090,10 +2090,10 @@ static void sub_81D82B0(void) SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); SetBgTilemapBuffer(3, sRayScene->tilemapBuffers[3]); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); + ScheduleBgCopyTilemapToVram(3); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); ShowBg(1); @@ -2104,10 +2104,10 @@ static void sub_81D82B0(void) static void sub_81D8358(void) { - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(0, gRaySceneRayquazaLight_Gfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(1, gRaySceneOvercast2_Gfx, 0, 0, 0); - while (free_temp_tile_data_buffers_if_possible()); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(0, gRaySceneRayquazaLight_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gRaySceneOvercast2_Gfx, 0, 0, 0); + while (FreeTempTileDataBuffersIfPossible()); LZDecompressWram(gRaySceneRayquazaLight_Tilemap, sRayScene->tilemapBuffers[0]); LZDecompressWram(gRaySceneOvercast2_Tilemap, sRayScene->tilemapBuffers[3]); @@ -2312,10 +2312,10 @@ static void sub_81D8828(void) SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); SetBgTilemapBuffer(3, sRayScene->tilemapBuffers[3]); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); + ScheduleBgCopyTilemapToVram(3); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_WIN0_ON); ShowBg(0); ShowBg(1); @@ -2326,11 +2326,11 @@ static void sub_81D8828(void) static void sub_81D88D0(void) { - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(1, gRaySceneRayquazaChase_Gfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(2, gRaySceneChaseStreaks_Gfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(3, gRaySceneChaseBg_Gfx, 0, 0, 0); - while (free_temp_tile_data_buffers_if_possible()); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(1, gRaySceneRayquazaChase_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gRaySceneChaseStreaks_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(3, gRaySceneChaseBg_Gfx, 0, 0, 0); + while (FreeTempTileDataBuffersIfPossible()); LZDecompressWram(gRayChaseRayquazaChase2_Tilemap, sRayScene->tilemapBuffers[0]); LZDecompressWram(gRayChaseRayquazaChase_Tilemap, sRayScene->tilemapBuffers[1]); @@ -2468,9 +2468,9 @@ static void sub_81D8C38(void) SetBgTilemapBuffer(1, sRayScene->tilemapBuffers[1]); SetBgTilemapBuffer(2, sRayScene->tilemapBuffers[2]); ResetAllBgsCoordinates(); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_WIN0_ON); ShowBg(0); ShowBg(1); @@ -2480,10 +2480,10 @@ static void sub_81D8C38(void) static void sub_81D8CC4(void) { - reset_temp_tile_data_buffers(); - decompress_and_copy_tile_data_to_vram(2, gRaySceneHushRing_Gfx, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(0, gRaySceneHushBg_Gfx, 0, 0, 0); - while (free_temp_tile_data_buffers_if_possible()); + ResetTempTileDataBuffers(); + DecompressAndCopyTileDataToVram(2, gRaySceneHushRing_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(0, gRaySceneHushBg_Gfx, 0, 0, 0); + while (FreeTempTileDataBuffersIfPossible()); LZDecompressWram(gRaySceneHushRing_Tilemap, sRayScene->tilemapBuffers[1]); LZDecompressWram(gRaySceneHushBg_Tilemap, sRayScene->tilemapBuffers[0]); diff --git a/src/region_map.c b/src/region_map.c index 0ee30527f..287e97fe9 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -547,15 +547,15 @@ bool8 LoadRegionMapGfx(void) { case 0: if (gRegionMap->bgManaged) - decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBg_GfxLZ, 0, 0, 0); + DecompressAndCopyTileDataToVram(gRegionMap->bgNum, sRegionMapBg_GfxLZ, 0, 0, 0); else LZ77UnCompVram(sRegionMapBg_GfxLZ, (u16 *)BG_CHAR_ADDR(2)); break; case 1: if (gRegionMap->bgManaged) { - if (!free_temp_tile_data_buffers_if_possible()) - decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBg_TilemapLZ, 0, 0, 1); + if (!FreeTempTileDataBuffersIfPossible()) + DecompressAndCopyTileDataToVram(gRegionMap->bgNum, sRegionMapBg_TilemapLZ, 0, 0, 1); } else { @@ -563,7 +563,7 @@ bool8 LoadRegionMapGfx(void) } break; case 2: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) LoadPalette(sRegionMapBg_Pal, 0x70, 0x60); break; case 3: @@ -1710,7 +1710,7 @@ void CB2_OpenFlyMap(void) PutWindowTilemap(2); FillWindowPixelBuffer(2, PIXEL_FILL(0)); AddTextPrinterParameterized(2, 1, gText_FlyToWhere, 0, 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gMain.state++; break; case 8: @@ -1778,7 +1778,7 @@ static void DrawFlyDestTextWindow(void) AddTextPrinterParameterized(1, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); name = sMultiNameFlyDestinations[i].name[sFlyMap->regionMap.posWithinMapSec]; AddTextPrinterParameterized(1, 1, name, GetStringRightAlignXOffset(1, name, 96), 17, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gUnknown_03001180 = TRUE; } break; @@ -1796,7 +1796,7 @@ static void DrawFlyDestTextWindow(void) FillWindowPixelBuffer(0, PIXEL_FILL(1)); } AddTextPrinterParameterized(0, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gUnknown_03001180 = FALSE; } } @@ -1809,7 +1809,7 @@ static void DrawFlyDestTextWindow(void) } FillWindowPixelBuffer(0, PIXEL_FILL(1)); CopyWindowToVram(0, 2); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gUnknown_03001180 = FALSE; } } diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c index 07e96f3bd..2756aa861 100644 --- a/src/reset_rtc_screen.c +++ b/src/reset_rtc_screen.c @@ -293,7 +293,7 @@ static void HideChooseTimeWindow(u8 windowId) { ClearStdWindowAndFrameToTransparent(windowId, FALSE); RemoveWindow(windowId); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void PrintTime(u8 windowId, u8 x, u8 y, u16 days, u8 hours, u8 minutes, u8 seconds) @@ -323,7 +323,7 @@ static void ShowChooseTimeWindow(u8 windowId, u16 days, u8 hours, u8 minutes, u8 DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, 0x214, 0xE); PrintTime(windowId, 0, 1, days, hours, minutes, seconds); AddTextPrinterParameterized(windowId, 1, gText_Confirm2, 126, 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static bool32 MoveTimeUpDown(s16 *val, int minVal, int maxVal, u16 keys) @@ -470,7 +470,7 @@ static void sub_809F048(void) clear_scheduled_bg_copies_to_vram(); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBackgroundTemplates, ARRAY_COUNT(sBackgroundTemplates)); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); InitWindows(sUnknown_08510408); @@ -498,7 +498,7 @@ static void ShowMessage(const u8 *str) { DrawDialogFrameWithCustomTileAndPalette(1, FALSE, 0x200, 0xF); AddTextPrinterParameterized(1, 1, str, 0, 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void Task_ShowResetRtcPrompt(u8 taskId) @@ -529,7 +529,7 @@ static void Task_ShowResetRtcPrompt(u8 taskId) gSaveBlock2Ptr->lastBerryTreeUpdate.seconds); ShowMessage(gText_ResetRTCConfirmCancel); CopyWindowToVram(0, 2); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); data[0]++; case 1: if (gMain.newKeys & B_BUTTON) diff --git a/src/roulette.c b/src/roulette.c index e38da31d0..58e120cb5 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -943,15 +943,15 @@ static void sub_81405CC(void) ResetPaletteFade(); ResetSpriteData(); ResetTasks(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); break; case 3: LoadPalette(&gUnknown_085B5BFC, 0, 0x1C0); - decompress_and_copy_tile_data_to_vram(1, gRouletteMenuTiles, 0, 0, 0); - decompress_and_copy_tile_data_to_vram(2, gRouletteWheelTiles, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gRouletteMenuTiles, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gRouletteWheelTiles, 0, 0, 0); break; case 4: - if (free_temp_tile_data_buffers_if_possible()) + if (FreeTempTileDataBuffersIfPossible()) return; sub_8140470(); diff --git a/src/script_menu.c b/src/script_menu.c index 9ff63e357..2b135e301 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -110,7 +110,7 @@ static void DrawMultichoiceMenu(u8 left, u8 top, u8 multichoiceId, bool8 ignoreB SetStandardWindowBorderStyle(windowId, 0); PrintMenuTable(windowId, count, actions); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, count, cursorPos); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); InitMultichoiceCheckWrap(ignoreBPress, count, windowId, multichoiceId); } @@ -595,7 +595,7 @@ bool8 ScriptMenu_ShowPokemonPic(u16 species, u8 x, u8 y) gSprites[spriteId].callback = SpriteCallbackDummy; gSprites[spriteId].oam.priority = 0; SetStandardWindowBorderStyle(gTasks[taskId].tWindowId, 1); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); return TRUE; } } diff --git a/src/secret_base.c b/src/secret_base.c index 24644d0ec..172568db6 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -947,7 +947,7 @@ static void FinalizeRegistryMenu(u8 taskId) SetStandardWindowBorderStyle(data[6], 0); data[5] = ListMenuInit(&gMultiuseListMenuTemplate, data[2], data[1]); AddRegistryMenuScrollArrows(taskId); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void AddRegistryMenuScrollArrows(u8 taskId) @@ -975,7 +975,7 @@ static void HandleRegistryMenuInput(u8 taskId) ClearStdWindowAndFrame(data[6], 0); ClearWindowTilemap(data[6]); RemoveWindow(data[6]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); free(sRegistryMenu); GoToSecretBasePCRegisterMenu(taskId); break; @@ -998,7 +998,7 @@ static void ShowRegistryMenuActions(u8 taskId) SetStandardWindowBorderStyle(data[7], 0); PrintMenuTable(data[7], 2, sRegistryMenuActions); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[7], 2, 0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = HandleRegistryMenuActionsInput; } @@ -1028,7 +1028,7 @@ static void ShowRegistryMenuDeleteConfirmation(u8 taskId) ClearWindowTilemap(data[6]); ClearWindowTilemap(data[7]); RemoveWindow(data[7]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); GetSecretBaseName(gStringVar1, data[4]); StringExpandPlaceholders(gStringVar4, gText_OkayToDeleteFromRegistry); DisplayItemMessageOnField(taskId, gStringVar4, ShowRegistryMenuDeleteYesNo); @@ -1073,7 +1073,7 @@ static void ReturnToMainRegistryMenu(u8 taskId) ClearStdWindowAndFrame(data[7], 0); ClearWindowTilemap(data[7]); RemoveWindow(data[7]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = HandleRegistryMenuInput; } diff --git a/src/shop.c b/src/shop.c index 73b1cd4e2..837ba1bca 100755 --- a/src/shop.c +++ b/src/shop.c @@ -441,7 +441,7 @@ static void CB2_InitBuyMenu(void) SetVBlankHBlankCallbacksToNull(); CpuFastFill(0, (void *)OAM, OAM_SIZE); ScanlineEffect_Stop(); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); FreeAllSpritePalettes(); ResetPaletteFade(); ResetSpriteData(); @@ -462,7 +462,7 @@ static void CB2_InitBuyMenu(void) gMain.state++; break; case 1: - if (!free_temp_tile_data_buffers_if_possible()) + if (!FreeTempTileDataBuffersIfPossible()) gMain.state++; break; default: @@ -673,7 +673,7 @@ static void BuyMenuInitBgs(void) static void BuyMenuDecompressBgGraphics(void) { - decompress_and_copy_tile_data_to_vram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0); + DecompressAndCopyTileDataToVram(1, gBuyMenuFrame_Gfx, 0x3A0, 0x3E3, 0); LZDecompressWram(gBuyMenuFrame_Tilemap, gShopDataPtr->tilemapBuffers[0]); LoadCompressedPalette(gMenuMoneyPal, 0xC0, 0x20); } @@ -697,7 +697,7 @@ static void BuyMenuPrint(u8 windowId, const u8 *text, u8 x, u8 y, s8 speed, u8 c static void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback) { DisplayMessageAndContinueTask(taskId, 5, 10, 14, 1, GetPlayerTextSpeedDelay(), text, callback); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void BuyMenuDrawGraphics(void) @@ -706,10 +706,10 @@ static void BuyMenuDrawGraphics(void) BuyMenuCopyMenuBgToBg1TilemapBuffer(); AddMoneyLabelObject(19, 11); PrintMoneyAmountInMoneyBoxWithBorder(0, 1, 13, GetMoney(&gSaveBlock1Ptr->money)); - schedule_bg_copy_tilemap_to_vram(0); - schedule_bg_copy_tilemap_to_vram(1); - schedule_bg_copy_tilemap_to_vram(2); - schedule_bg_copy_tilemap_to_vram(3); + ScheduleBgCopyTilemapToVram(0); + ScheduleBgCopyTilemapToVram(1); + ScheduleBgCopyTilemapToVram(2); + ScheduleBgCopyTilemapToVram(3); } static void BuyMenuDrawMapGraphics(void) @@ -990,7 +990,7 @@ static void Task_BuyHowManyDialogueInit(u8 taskId) tItemCount = 1; DrawStdFrameWithCustomTileAndPalette(4, FALSE, 1, 13); BuyMenuPrintItemQuantityAndPrice(taskId); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); maxQuantity = GetMoney(&gSaveBlock1Ptr->money) / gShopDataPtr->totalCost; @@ -1137,7 +1137,7 @@ static void BuyMenuReturnToItemList(u8 taskId) BuyMenuPrintCursor(tListTaskId, 1); PutWindowTilemap(1); PutWindowTilemap(2); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); BuyMenuAddScrollIndicatorArrows(); gTasks[taskId].func = Task_BuyMenu; } diff --git a/src/starter_choose.c b/src/starter_choose.c index 11b84a9e2..dbdb1a8b3 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -487,7 +487,7 @@ static void Task_StarterChoose1(u8 taskId) DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x2A8, 0xD); AddTextPrinterParameterized(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL); PutWindowTilemap(0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = Task_StarterChoose2; } @@ -540,7 +540,7 @@ static void Task_StarterChoose4(u8 taskId) PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0); FillWindowPixelBuffer(0, PIXEL_FILL(1)); AddTextPrinterParameterized(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); CreateYesNoMenu(&gUnknown_085B1DDC, 0x2A8, 0xD, 0); gTasks[taskId].func = Task_StarterChoose5; } @@ -603,7 +603,7 @@ static void CreateStarterPokemonLabel(u8 selection) AddTextPrinterParameterized3(sStarterChooseWindowId, 1, width, 0x11, sTextColors, 0, speciesName); PutWindowTilemap(sStarterChooseWindowId); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); labelLeft = sStarterLabelCoords[selection][0] * 8 - 4; labelRight = (sStarterLabelCoords[selection][0] + 13) * 8 + 4; @@ -621,7 +621,7 @@ static void sub_8134604(void) sStarterChooseWindowId = 0xFF; SetGpuReg(REG_OFFSET_WIN0H, 0); SetGpuReg(REG_OFFSET_WIN0V, 0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } static void Task_MoveStarterChooseCursor(u8 taskId) diff --git a/src/trader.c b/src/trader.c index ac6a30df0..f6d021dfe 100644 --- a/src/trader.c +++ b/src/trader.c @@ -83,7 +83,7 @@ void CreateAvailableDecorationsMenu(u8 taskId) } AddTextPrinterParameterized(data[3], 1, gText_Exit, 8, 16 * i + 1, 255, NULL); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[3], 5, 0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); } void Task_BufferDecorSelectionAndCloseWindow(u8 taskId, u8 decorationId) @@ -101,7 +101,7 @@ void Task_BufferDecorSelectionAndCloseWindow(u8 taskId, u8 decorationId) ClearStdWindowAndFrameToTransparent(data[3], FALSE); ClearWindowTilemap(data[3]); RemoveWindow(data[3]); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); DestroyTask(taskId); EnableBothScriptContexts(); } diff --git a/src/union_room_battle.c b/src/union_room_battle.c index 18dd7c320..d2c3a5cd0 100644 --- a/src/union_room_battle.c +++ b/src/union_room_battle.c @@ -518,7 +518,7 @@ void sub_801AC54(void) ResetTasks(); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gUnknown_082F0DD0, 1); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); if (!InitWindows(gUnknown_082F0DD4)) { return; diff --git a/src/union_room_chat.c b/src/union_room_chat.c index f212c69a7..16d05d0ef 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -1828,7 +1828,7 @@ static bool8 sub_801F4D0(void) ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gUnknown_082F2C60, ARRAY_COUNT(gUnknown_082F2C60)); InitWindows(gUnknown_082F2C70); - reset_temp_tile_data_buffers(); + ResetTempTileDataBuffers(); sub_8020770(); sub_801F574(gUnknown_02022C88); sub_801F580(); @@ -1916,7 +1916,7 @@ static bool8 sub_801F644(u8 arg0) bool32 sub_801F658(u8 *state) { - if (free_temp_tile_data_buffers_if_possible() == TRUE) + if (FreeTempTileDataBuffersIfPossible() == TRUE) return TRUE; switch (*state) @@ -2739,7 +2739,7 @@ static void sub_80205B4(void) { LoadPalette(gUnknown_08DD4BD0, 0x70, 0x20); LoadPalette(gUnknown_08DD4BB0, 0xC0, 0x20); - decompress_and_copy_tile_data_to_vram(1, gUnknown_08DD4BF0, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gUnknown_08DD4BF0, 0, 0, 0); CopyToBgTilemapBuffer(1, gUnknown_08DD4C4C, 0, 0); CopyBgTilemapBufferToVram(1); } @@ -2749,7 +2749,7 @@ static void sub_8020604(void) u8 *ptr; LoadPalette(gLinkMiscMenu_Pal, 0, 0x20); - ptr = decompress_and_copy_tile_data_to_vram(2, gLinkMiscMenu_Gfx, 0, 0, 0); + ptr = DecompressAndCopyTileDataToVram(2, gLinkMiscMenu_Gfx, 0, 0, 0); if (ptr) { CpuFastCopy(&ptr[0x220], gUnknown_02022C88->unk2128, 0x20); diff --git a/src/wallclock.c b/src/wallclock.c index 01900dc8e..00ab65817 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -724,7 +724,7 @@ void CB2_StartWallClock(void) AddTextPrinterParameterized(1, 1, gText_Confirm3, 0, 1, 0, NULL); PutWindowTilemap(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } void CB2_ViewWallClock(void) @@ -772,7 +772,7 @@ void CB2_ViewWallClock(void) AddTextPrinterParameterized(1, 1, gText_Cancel4, 0, 1, 0, NULL); PutWindowTilemap(1); - schedule_bg_copy_tilemap_to_vram(2); + ScheduleBgCopyTilemapToVram(2); } static void WallClockMainCallback(void) @@ -839,7 +839,7 @@ static void Task_SetClock3(u8 taskId) DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x250, 0x0d); AddTextPrinterParameterized(0, 1, gText_IsThisTheCorrectTime, 0, 1, 0, NULL); PutWindowTilemap(0); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); CreateYesNoMenu(&gUnknown_085B21F4, 0x250, 0x0d, 1); gTasks[taskId].func = Task_SetClock4; }