From baeacbe2f10ef69468d3bdb223d8ca74c963e9d6 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 12 Nov 2021 12:40:36 -0500 Subject: [PATCH] Clean up pokenav general menus, organize pokenav graphics --- graphics/pokenav/icon2_unused.png | Bin 194 -> 0 bytes .../{arrows_matchcall.png => list_arrows.png} | Bin graphics/pokenav/{ => match_call}/86226E0.pal | 0 graphics/pokenav/{ => match_call}/8622700.pal | 0 .../{arrow2.png => match_call/arrow.png} | Bin .../{icon.png => match_call/nav_icon.png} | Bin .../{8622720.pal => match_call/pokeball.pal} | 0 .../pokeball.png} | Bin .../{ui_matchcall.bin => match_call/ui.bin} | Bin .../{ui_matchcall.png => match_call/ui.png} | Bin .../window.png} | Bin graphics/pokenav/{icon2.png => nav_icon.png} | Bin graphics/pokenav/pokeball_matchcall.pal | 35 - .../pokenav/{ => region_map}/brendan_icon.png | Bin graphics/pokenav/{ => region_map}/cursor.pal | 0 .../pokenav/{ => region_map}/cursor_large.png | Bin .../pokenav/{ => region_map}/cursor_small.png | Bin .../{ => region_map}/fly_target_icons.png | Bin .../{map_frame.bin => region_map/frame.bin} | Bin .../{map_frame.png => region_map/frame.png} | Bin .../info_window.pal} | 0 .../pokenav/{ => region_map}/may_icon.png | Bin graphics_file_rules.mk | 2 +- include/pokenav.h | 6 +- src/match_call.c | 8 +- src/pokenav.c | 1 - src/pokenav_main_menu.c | 271 ++++---- src/pokenav_match_call_2.c | 20 +- src/pokenav_match_call_ui.c | 4 +- src/pokenav_menu_handler_1.c | 302 ++++----- src/pokenav_menu_handler_2.c | 636 ++++++++++-------- src/pokenav_region_map.c | 4 +- src/region_map.c | 33 +- 33 files changed, 687 insertions(+), 635 deletions(-) delete mode 100644 graphics/pokenav/icon2_unused.png rename graphics/pokenav/{arrows_matchcall.png => list_arrows.png} (100%) rename graphics/pokenav/{ => match_call}/86226E0.pal (100%) rename graphics/pokenav/{ => match_call}/8622700.pal (100%) rename graphics/pokenav/{arrow2.png => match_call/arrow.png} (100%) rename graphics/pokenav/{icon.png => match_call/nav_icon.png} (100%) rename graphics/pokenav/{8622720.pal => match_call/pokeball.pal} (100%) rename graphics/pokenav/{pokeball_matchcall.png => match_call/pokeball.png} (100%) rename graphics/pokenav/{ui_matchcall.bin => match_call/ui.bin} (100%) rename graphics/pokenav/{ui_matchcall.png => match_call/ui.png} (100%) rename graphics/pokenav/{match_call_window.png => match_call/window.png} (100%) rename graphics/pokenav/{icon2.png => nav_icon.png} (100%) delete mode 100644 graphics/pokenav/pokeball_matchcall.pal rename graphics/pokenav/{ => region_map}/brendan_icon.png (100%) rename graphics/pokenav/{ => region_map}/cursor.pal (100%) rename graphics/pokenav/{ => region_map}/cursor_large.png (100%) rename graphics/pokenav/{ => region_map}/cursor_small.png (100%) rename graphics/pokenav/{ => region_map}/fly_target_icons.png (100%) rename graphics/pokenav/{map_frame.bin => region_map/frame.bin} (100%) rename graphics/pokenav/{map_frame.png => region_map/frame.png} (100%) rename graphics/pokenav/{region_map_info_window.pal => region_map/info_window.pal} (100%) rename graphics/pokenav/{ => region_map}/may_icon.png (100%) diff --git a/graphics/pokenav/icon2_unused.png b/graphics/pokenav/icon2_unused.png deleted file mode 100644 index c32a9b9be9f17feb7585d641a220838974e2e0dc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!VDx^^%AmxltF+`i0l9V|JNjGu9-4r%bGR+ zj~0KcPFk|$Y*NxUpg6~t|3Fo6aQ5ugHEZ@NEI8W&6!P_SaSV}|y0zbsiNTPCWpBgx z)t^l57x*5QeK%``v1qUkx0cB4%GQO>LKCWImHWsvcMIqyZi&`eEVO8UK?~o*{=OZ` i$8LVSQBga^`n7%Z*Gfgh6Q@3c?DBN=b6Mw<&;$ULGfE%; diff --git a/graphics/pokenav/arrows_matchcall.png b/graphics/pokenav/list_arrows.png similarity index 100% rename from graphics/pokenav/arrows_matchcall.png rename to graphics/pokenav/list_arrows.png diff --git a/graphics/pokenav/86226E0.pal b/graphics/pokenav/match_call/86226E0.pal similarity index 100% rename from graphics/pokenav/86226E0.pal rename to graphics/pokenav/match_call/86226E0.pal diff --git a/graphics/pokenav/8622700.pal b/graphics/pokenav/match_call/8622700.pal similarity index 100% rename from graphics/pokenav/8622700.pal rename to graphics/pokenav/match_call/8622700.pal diff --git a/graphics/pokenav/arrow2.png b/graphics/pokenav/match_call/arrow.png similarity index 100% rename from graphics/pokenav/arrow2.png rename to graphics/pokenav/match_call/arrow.png diff --git a/graphics/pokenav/icon.png b/graphics/pokenav/match_call/nav_icon.png similarity index 100% rename from graphics/pokenav/icon.png rename to graphics/pokenav/match_call/nav_icon.png diff --git a/graphics/pokenav/8622720.pal b/graphics/pokenav/match_call/pokeball.pal similarity index 100% rename from graphics/pokenav/8622720.pal rename to graphics/pokenav/match_call/pokeball.pal diff --git a/graphics/pokenav/pokeball_matchcall.png b/graphics/pokenav/match_call/pokeball.png similarity index 100% rename from graphics/pokenav/pokeball_matchcall.png rename to graphics/pokenav/match_call/pokeball.png diff --git a/graphics/pokenav/ui_matchcall.bin b/graphics/pokenav/match_call/ui.bin similarity index 100% rename from graphics/pokenav/ui_matchcall.bin rename to graphics/pokenav/match_call/ui.bin diff --git a/graphics/pokenav/ui_matchcall.png b/graphics/pokenav/match_call/ui.png similarity index 100% rename from graphics/pokenav/ui_matchcall.png rename to graphics/pokenav/match_call/ui.png diff --git a/graphics/pokenav/match_call_window.png b/graphics/pokenav/match_call/window.png similarity index 100% rename from graphics/pokenav/match_call_window.png rename to graphics/pokenav/match_call/window.png diff --git a/graphics/pokenav/icon2.png b/graphics/pokenav/nav_icon.png similarity index 100% rename from graphics/pokenav/icon2.png rename to graphics/pokenav/nav_icon.png diff --git a/graphics/pokenav/pokeball_matchcall.pal b/graphics/pokenav/pokeball_matchcall.pal deleted file mode 100644 index 25baec517..000000000 --- a/graphics/pokenav/pokeball_matchcall.pal +++ /dev/null @@ -1,35 +0,0 @@ -JASC-PAL -0100 -32 -0 197 0 -246 197 123 -255 255 255 -106 115 123 -0 0 0 -189 106 65 -49 65 74 -255 222 156 -180 131 82 -189 139 106 -197 197 197 -255 255 255 -0 0 0 -0 0 0 -0 0 0 -255 74 16 -0 197 0 -246 197 123 -255 255 255 -106 115 123 -0 0 0 -189 106 65 -49 65 74 -255 222 156 -180 131 82 -189 139 106 -197 197 197 -197 197 197 -0 0 0 -0 0 0 -0 0 0 -189 106 65 diff --git a/graphics/pokenav/brendan_icon.png b/graphics/pokenav/region_map/brendan_icon.png similarity index 100% rename from graphics/pokenav/brendan_icon.png rename to graphics/pokenav/region_map/brendan_icon.png diff --git a/graphics/pokenav/cursor.pal b/graphics/pokenav/region_map/cursor.pal similarity index 100% rename from graphics/pokenav/cursor.pal rename to graphics/pokenav/region_map/cursor.pal diff --git a/graphics/pokenav/cursor_large.png b/graphics/pokenav/region_map/cursor_large.png similarity index 100% rename from graphics/pokenav/cursor_large.png rename to graphics/pokenav/region_map/cursor_large.png diff --git a/graphics/pokenav/cursor_small.png b/graphics/pokenav/region_map/cursor_small.png similarity index 100% rename from graphics/pokenav/cursor_small.png rename to graphics/pokenav/region_map/cursor_small.png diff --git a/graphics/pokenav/fly_target_icons.png b/graphics/pokenav/region_map/fly_target_icons.png similarity index 100% rename from graphics/pokenav/fly_target_icons.png rename to graphics/pokenav/region_map/fly_target_icons.png diff --git a/graphics/pokenav/map_frame.bin b/graphics/pokenav/region_map/frame.bin similarity index 100% rename from graphics/pokenav/map_frame.bin rename to graphics/pokenav/region_map/frame.bin diff --git a/graphics/pokenav/map_frame.png b/graphics/pokenav/region_map/frame.png similarity index 100% rename from graphics/pokenav/map_frame.png rename to graphics/pokenav/region_map/frame.png diff --git a/graphics/pokenav/region_map_info_window.pal b/graphics/pokenav/region_map/info_window.pal similarity index 100% rename from graphics/pokenav/region_map_info_window.pal rename to graphics/pokenav/region_map/info_window.pal diff --git a/graphics/pokenav/may_icon.png b/graphics/pokenav/region_map/may_icon.png similarity index 100% rename from graphics/pokenav/may_icon.png rename to graphics/pokenav/region_map/may_icon.png diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index bc503eec2..eb36d4255 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -697,7 +697,7 @@ $(PKNAVGFXDIR)/header.4bpp: %.4bpp: %.png $(PKNAVGFXDIR)/device_outline.4bpp: %.4bpp: %.png $(GFX) $< $@ -num_tiles 53 -$(PKNAVGFXDIR)/ui_matchcall.4bpp: %.4bpp: %.png +$(PKNAVGFXDIR)/match_call/ui.4bpp: %.4bpp: %.png $(GFX) $< $@ -num_tiles 13 $(INTERFACEGFXDIR)/region_map.8bpp: %.8bpp: %.png diff --git a/include/pokenav.h b/include/pokenav.h index a0e293453..6dc88cab7 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -69,7 +69,7 @@ enum { POKENAV_SUBSTRUCT_MAIN_MENU, POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, - POKENAV_SUBSTRUCT_MENU_ICONS, + POKENAV_SUBSTRUCT_MENU_GFX, POKENAV_SUBSTRUCT_REGION_MAP_STATE, POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, @@ -82,7 +82,7 @@ enum POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX, POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, - POKENAV_SUBSTRUCT_15, //unused + POKENAV_SUBSTRUCT_UNUSED, POKENAV_SUBSTRUCT_REGION_MAP, POKENAV_SUBSTRUCT_MATCH_CALL_LIST, POKENAV_SUBSTRUCT_MON_LIST, @@ -358,7 +358,7 @@ void SlideMenuHeaderDown(void); bool32 MainMenuLoopedTaskIsBusy(void); void SetLeftHeaderSpritesInvisibility(void); void PokenavCopyPalette(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette); -void sub_81C7B40(void); +void FadeToBlackExceptPrimary(void); struct Sprite *PauseSpinningPokenavSprite(void); void ResumeSpinningPokenavSprite(void); void UpdateRegionMapRightHeaderTiles(u32 arg0); diff --git a/src/match_call.c b/src/match_call.c index 9e4659ee6..0595ad3e3 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1187,10 +1187,10 @@ static void StartMatchCall(void) CreateTask(ExecuteMatchCall, 1); } -static const u16 sMatchCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call_window.gbapal"); -static const u8 sMatchCallWindow_Gfx[] = INCBIN_U8("graphics/pokenav/match_call_window.4bpp"); -static const u16 sPokenavIcon_Pal[] = INCBIN_U16("graphics/pokenav/icon.gbapal"); -static const u32 sPokenavIcon_Gfx[] = INCBIN_U32("graphics/pokenav/icon.4bpp.lz"); +static const u16 sMatchCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call/window.gbapal"); +static const u8 sMatchCallWindow_Gfx[] = INCBIN_U8("graphics/pokenav/match_call/window.4bpp"); +static const u16 sPokenavIcon_Pal[] = INCBIN_U16("graphics/pokenav/match_call/nav_icon.gbapal"); +static const u32 sPokenavIcon_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/nav_icon.4bpp.lz"); static const u8 sText_PokenavCallEllipsis[] = _("………………\p"); diff --git a/src/pokenav.c b/src/pokenav.c index b09fc9da0..f9a6614a8 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -49,7 +49,6 @@ static void Task_RunLoopedTask(u8 taskId); static void Task_Pokenav(u8 taskId); static void CB2_InitPokenavForTutorial(void); -// TODO: Use MENU ids const struct PokenavCallbacks PokenavMenuCallbacks[15] = { [POKENAV_MAIN_MENU - POKENAV_MENU_IDS_START] = diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index 714c8221a..77faecaa3 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -13,7 +13,7 @@ #include "menu.h" #include "dma3.h" -struct PokenavMainMenuResources +struct Pokenav_MainMenu { void (*loopTask)(u32); u32 (*isLoopTaskActiveFunc)(void); @@ -24,7 +24,7 @@ struct PokenavMainMenuResources struct Sprite *spinningPokenav; struct Sprite *leftHeaderSprites[2]; struct Sprite *submenuLeftHeaderSprites[2]; - u8 tilemapBuffer[0x800]; + u8 tilemapBuffer[BG_SCREEN_SIZE]; }; // This struct uses a 32bit tag, and doesn't have a size field. @@ -36,26 +36,26 @@ struct CompressedSpriteSheetNoSize }; static void CleanupPokenavMainMenuResources(void); -static void LoadLeftHeaderGfxForSubMenu(u32 arg0); -static void LoadLeftHeaderGfxForMenu(u32 index); -static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide); -static void HideLeftHeaderSprites(bool32 isOnRightSide); -static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide); -static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide); -static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration); -static void SpriteCB_MoveLeftHeader(struct Sprite *sprite); +static void LoadLeftHeaderGfxForSubMenu(u32); +static void LoadLeftHeaderGfxForMenu(u32); +static void HideLeftHeaderSubmenuSprites(bool32); +static void HideLeftHeaderSprites(bool32); +static void ShowLeftHeaderSprites(u32, bool32); +static void ShowLeftHeaderSubmenuSprites(u32, bool32); +static void MoveLeftHeader(struct Sprite *, s32, s32, s32); +static void SpriteCB_MoveLeftHeader(struct Sprite *); static void InitPokenavMainMenuResources(void); -static void InitHoennMapHeaderSprites(void); +static void CreateLeftHeaderSprites(void); static void InitHelpBar(void); -static u32 LoopedTask_SlideMenuHeaderUp(s32 a0); -static u32 LoopedTask_SlideMenuHeaderDown(s32 a0); -static void DrawHelpBar(u32 windowId); -static void SpriteCB_SpinningPokenav(struct Sprite* sprite); -static u32 LoopedTask_InitPokenavMenu(s32 a0); +static u32 LoopedTask_SlideMenuHeaderUp(s32); +static u32 LoopedTask_SlideMenuHeaderDown(s32); +static void DrawHelpBar(u32); +static void SpriteCB_SpinningPokenav(struct Sprite*); +static u32 LoopedTask_InitPokenavMenu(s32); -const u16 gSpinningPokenavPaletteData[] = INCBIN_U16("graphics/pokenav/icon2.gbapal"); -const u32 gSpinningPokenavGfx[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz"); -const u32 gUnused_SpinningPokenavGfx2[] = INCBIN_U32("graphics/pokenav/icon2_unused.4bpp.lz"); +static const u16 sSpinningPokenav_Pal[] = INCBIN_U16("graphics/pokenav/nav_icon.gbapal"); +static const u32 sSpinningPokenav_Gfx[] = INCBIN_U32("graphics/pokenav/nav_icon.4bpp.lz"); +static const u32 sBlueLightCopy[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz"); // Unused copy of sMatchCallBlueLightTiles const struct BgTemplate gPokenavMainMenuBgTemplates[] = { @@ -108,7 +108,7 @@ static const u8 sHelpBarTextColors[3] = static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] = { { - .data = gSpinningPokenavGfx, + .data = sSpinningPokenav_Gfx, .size = 0x1000, .tag = 0, } @@ -117,20 +117,20 @@ static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] = static const struct SpritePalette gSpinningNavgearPalettes[] = { { - .data = gSpinningPokenavPaletteData, + .data = sSpinningPokenav_Pal, .tag = 0, }, {} }; -static const struct CompressedSpriteSheet sPokenavHoennMapLeftHeaderSpriteSheet = +static const struct CompressedSpriteSheet sMenuLeftHeaderSpriteSheet = { - .data = gPokenavLeftHeaderHoennMap_Gfx, + .data = gPokenavLeftHeaderHoennMap_Gfx, // Hoenn map is the first of the headers listed .size = 0xC00, .tag = 2 }; -static const struct CompressedSpriteSheet sPokenavMenuLeftHeaderSpriteSheets[] = +static const struct CompressedSpriteSheet sMenuLeftHeaderSpriteSheets[] = { [POKENAV_GFX_MAIN_MENU] = { .data = gPokenavLeftHeaderMainMenu_Gfx, @@ -239,7 +239,7 @@ static const struct SpriteTemplate sSpinningPokenavSpriteTemplate = .callback = SpriteCB_SpinningPokenav }; -static const struct OamData sPokenavLeftHeaderHoennMapSpriteOam = +static const struct OamData sOamData_LeftHeader = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -253,7 +253,7 @@ static const struct OamData sPokenavLeftHeaderHoennMapSpriteOam = .paletteNum = 0, }; -static const struct OamData sUnknown_0861FB24 = +static const struct OamData sOamData_SubmenuLeftHeader = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -268,22 +268,22 @@ static const struct OamData sUnknown_0861FB24 = .paletteNum = 0, }; -static const struct SpriteTemplate sPokenavLeftHeaderHoennMapSpriteTemplate = +static const struct SpriteTemplate sLeftHeaderSpriteTemplate = { .tileTag = 2, .paletteTag = 1, - .oam = &sPokenavLeftHeaderHoennMapSpriteOam, + .oam = &sOamData_LeftHeader, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate sUnknown_0861FB44 = +static const struct SpriteTemplate sSubmenuLeftHeaderSpriteTemplate = { .tileTag = 2, .paletteTag = 2, - .oam = &sUnknown_0861FB24, + .oam = &sOamData_SubmenuLeftHeader, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -292,22 +292,22 @@ static const struct SpriteTemplate sUnknown_0861FB44 = bool32 InitPokenavMainMenu(void) { - struct PokenavMainMenuResources *structPtr; + struct Pokenav_MainMenu *menu; - structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct PokenavMainMenuResources)); - if (structPtr == NULL) + menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct Pokenav_MainMenu)); + if (menu == NULL) return FALSE; ResetSpriteData(); FreeAllSpritePalettes(); - structPtr->currentTaskId = CreateLoopedTask(LoopedTask_InitPokenavMenu, 1); + menu->currentTaskId = CreateLoopedTask(LoopedTask_InitPokenavMenu, 1); return TRUE; } u32 PokenavMainMenuLoopedTaskIsActive(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - return IsLoopedTaskActive(structPtr->currentTaskId); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + return IsLoopedTaskActive(menu->currentTaskId); } void ShutdownPokenav(void) @@ -330,11 +330,11 @@ bool32 WaitForPokenavShutdownFade(void) return TRUE; } -static u32 LoopedTask_InitPokenavMenu(s32 a0) +static u32 LoopedTask_InitPokenavMenu(s32 state) { - struct PokenavMainMenuResources *structPtr; + struct Pokenav_MainMenu *menu; - switch (a0) + switch (state) { case 0: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); @@ -345,9 +345,9 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) ResetTempTileDataBuffers(); return LT_INC_AND_CONTINUE; case 1: - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0); - SetBgTilemapBuffer(0, structPtr->tilemapBuffer); + SetBgTilemapBuffer(0, menu->tilemapBuffer); CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0); CopyPaletteIntoBufferUnfaded(gPokenavHeader_Pal, 0, 0x20); CopyBgTilemapBufferToVram(0); @@ -363,7 +363,7 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) return LT_PAUSE; InitPokenavMainMenuResources(); - InitHoennMapHeaderSprites(); + CreateLeftHeaderSprites(); ShowBg(0); return LT_FINISH; default: @@ -373,46 +373,46 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) void SetActiveMenuLoopTasks(void *createLoopTask, void *isLoopTaskActive) // Fix types later. { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->loopTask = createLoopTask; - structPtr->isLoopTaskActiveFunc = isLoopTaskActive; - structPtr->unused = 0; + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu->loopTask = createLoopTask; + menu->isLoopTaskActiveFunc = isLoopTaskActive; + menu->unused = 0; } -void RunMainMenuLoopedTask(u32 a0) +void RunMainMenuLoopedTask(u32 state) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->unused = 0; - structPtr->loopTask(a0); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu->unused = 0; + menu->loopTask(state); } u32 IsActiveMenuLoopTaskActive(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - return structPtr->isLoopTaskActiveFunc(); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + return menu->isLoopTaskActiveFunc(); } void SlideMenuHeaderUp(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4); } void SlideMenuHeaderDown(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + menu->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4); } bool32 MainMenuLoopedTaskIsBusy(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - return IsLoopedTaskActive(structPtr->currentTaskId); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + return IsLoopedTaskActive(menu->currentTaskId); } -static u32 LoopedTask_SlideMenuHeaderUp(s32 a0) +static u32 LoopedTask_SlideMenuHeaderUp(s32 state) { - switch (a0) + switch (state) { default: return LT_FINISH; @@ -431,7 +431,7 @@ static u32 LoopedTask_SlideMenuHeaderUp(s32 a0) } } -static u32 LoopedTask_SlideMenuHeaderDown(s32 a0) +static u32 LoopedTask_SlideMenuHeaderDown(s32 state) { if (ChangeBgY(0, 384, BG_COORD_SUB) <= 0) { @@ -510,15 +510,15 @@ void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a void PokenavFadeScreen(s32 fadeType) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); switch (fadeType) { case 0: - BeginNormalPaletteFade(structPtr->palettes, -2, 0, 16, RGB_BLACK); + BeginNormalPaletteFade(menu->palettes, -2, 0, 16, RGB_BLACK); break; case 1: - BeginNormalPaletteFade(structPtr->palettes, -2, 16, 0, RGB_BLACK); + BeginNormalPaletteFade(menu->palettes, -2, 16, 0, RGB_BLACK); break; case 2: BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK); @@ -534,9 +534,10 @@ bool32 IsPaletteFadeActive(void) return gPaletteFade.active; } -void sub_81C7B40(void) +// Excludes the first obj and bg palettes +void FadeToBlackExceptPrimary(void) { - BlendPalettes(PALETTES_ALL & ~(0x10000 | 0x1), 16, RGB_BLACK); + BlendPalettes(PALETTES_ALL & ~(1 << 16 | 1), 16, RGB_BLACK); } void InitBgTemplates(const struct BgTemplate *templates, int count) @@ -549,21 +550,21 @@ void InitBgTemplates(const struct BgTemplate *templates, int count) static void InitHelpBar(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); InitWindows(&sHelpBarWindowTemplate[0]); - structPtr->helpBarWindowId = 0; - DrawHelpBar(structPtr->helpBarWindowId); - PutWindowTilemap(structPtr->helpBarWindowId); - CopyWindowToVram(structPtr->helpBarWindowId, COPYWIN_FULL); + menu->helpBarWindowId = 0; + DrawHelpBar(menu->helpBarWindowId); + PutWindowTilemap(menu->helpBarWindowId); + CopyWindowToVram(menu->helpBarWindowId, COPYWIN_FULL); } void PrintHelpBarText(u32 textId) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - DrawHelpBar(structPtr->helpBarWindowId); - AddTextPrinterParameterized3(structPtr->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]); + DrawHelpBar(menu->helpBarWindowId); + AddTextPrinterParameterized3(menu->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]); } bool32 WaitForHelpBar(void) @@ -581,22 +582,22 @@ static void InitPokenavMainMenuResources(void) { s32 i; u8 spriteId; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); for (i = 0; i < ARRAY_COUNT(gSpinningPokenavSpriteSheet); i++) LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]); Pokenav_AllocAndLoadPalettes(gSpinningNavgearPalettes); - structPtr->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0)); + menu->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0)); spriteId = CreateSprite(&sSpinningPokenavSpriteTemplate, 220, 12, 0); - structPtr->spinningPokenav = &gSprites[spriteId]; + menu->spinningPokenav = &gSprites[spriteId]; } static void CleanupPokenavMainMenuResources(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - DestroySprite(structPtr->spinningPokenav); + DestroySprite(menu->spinningPokenav); FreeSpriteTilesByTag(0); FreeSpritePaletteByTag(0); } @@ -609,45 +610,47 @@ static void SpriteCB_SpinningPokenav(struct Sprite *sprite) struct Sprite *PauseSpinningPokenavSprite(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->spinningPokenav->callback = SpriteCallbackDummy; - return structPtr->spinningPokenav; + menu->spinningPokenav->callback = SpriteCallbackDummy; + return menu->spinningPokenav; } void ResumeSpinningPokenavSprite(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - structPtr->spinningPokenav->x = 220; - structPtr->spinningPokenav->y = 12; - structPtr->spinningPokenav->callback = SpriteCB_SpinningPokenav; - structPtr->spinningPokenav->invisible = FALSE; - structPtr->spinningPokenav->oam.priority = 0; - structPtr->spinningPokenav->subpriority = 0; + menu->spinningPokenav->x = 220; + menu->spinningPokenav->y = 12; + menu->spinningPokenav->callback = SpriteCB_SpinningPokenav; + menu->spinningPokenav->invisible = FALSE; + menu->spinningPokenav->oam.priority = 0; + menu->spinningPokenav->subpriority = 0; } -static void InitHoennMapHeaderSprites(void) +static void CreateLeftHeaderSprites(void) { s32 i, spriteId; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet); + LoadCompressedSpriteSheet(&sMenuLeftHeaderSpriteSheet); AllocSpritePalette(1); AllocSpritePalette(2); - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++) { - spriteId = CreateSprite(&sPokenavLeftHeaderHoennMapSpriteTemplate, 0, 0, 1); - structPtr->leftHeaderSprites[i] = &gSprites[spriteId]; - structPtr->leftHeaderSprites[i]->invisible = TRUE; - structPtr->leftHeaderSprites[i]->x2 = i * 64; + // Create main left header + spriteId = CreateSprite(&sLeftHeaderSpriteTemplate, 0, 0, 1); + menu->leftHeaderSprites[i] = &gSprites[spriteId]; + menu->leftHeaderSprites[i]->invisible = TRUE; + menu->leftHeaderSprites[i]->x2 = i * 64; - spriteId = CreateSprite(&sUnknown_0861FB44, 0, 0, 2); - structPtr->submenuLeftHeaderSprites[i] = &gSprites[spriteId]; - structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE; - structPtr->submenuLeftHeaderSprites[i]->x2 = i * 32; - structPtr->submenuLeftHeaderSprites[i]->y2 = 18; - structPtr->submenuLeftHeaderSprites[i]->oam.tileNum += (i * 8) + 64; + // Create submenu left header + spriteId = CreateSprite(&sSubmenuLeftHeaderSpriteTemplate, 0, 0, 2); + menu->submenuLeftHeaderSprites[i] = &gSprites[spriteId]; + menu->submenuLeftHeaderSprites[i]->invisible = TRUE; + menu->submenuLeftHeaderSprites[i]->x2 = i * 32; + menu->submenuLeftHeaderSprites[i]->y2 = 18; + menu->submenuLeftHeaderSprites[i]->oam.tileNum += (i * 8) + 64; } } @@ -661,34 +664,34 @@ void LoadLeftHeaderGfxForIndex(u32 menuGfxId) void UpdateRegionMapRightHeaderTiles(u32 menuGfxId) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT) - structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32; + menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32; else - structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64; + menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64; } static void LoadLeftHeaderGfxForMenu(u32 menuGfxId) { - struct PokenavMainMenuResources *structPtr; + struct Pokenav_MainMenu *menu; u32 size, tag; if (menuGfxId >= POKENAV_GFX_SUBMENUS_START) return; - structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - tag = sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].tag; - size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data); + menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + tag = sMenuLeftHeaderSpriteSheets[menuGfxId].tag; + size = GetDecompressedDataSize(sMenuLeftHeaderSpriteSheets[menuGfxId].data); LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20); - LZ77UnCompWram(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer); + LZ77UnCompWram(sMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer); RequestDma3Copy(gDecompressionBuffer, (void *)OBJ_VRAM0 + (GetSpriteTileStartByTag(2) * 32), size, 1); - structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].size; + menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sMenuLeftHeaderSpriteSheets[menuGfxId].size; if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT || menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_IN) - structPtr->leftHeaderSprites[1]->x2 = 56; + menu->leftHeaderSprites[1]->x2 = 56; else - structPtr->leftHeaderSprites[1]->x2 = 64; + menu->leftHeaderSprites[1]->x2 = 64; } static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId) @@ -731,20 +734,20 @@ void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide) void SetLeftHeaderSpritesInvisibility(void) { s32 i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++) { - structPtr->leftHeaderSprites[i]->invisible = TRUE; - structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE; + menu->leftHeaderSprites[i]->invisible = TRUE; + menu->submenuLeftHeaderSprites[i]->invisible = TRUE; } } bool32 AreLeftHeaderSpritesMoving(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); - if (structPtr->leftHeaderSprites[0]->callback == SpriteCallbackDummy && structPtr->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy) + if (menu->leftHeaderSprites[0]->callback == SpriteCallbackDummy && menu->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy) return FALSE; else return TRUE; @@ -753,66 +756,66 @@ bool32 AreLeftHeaderSpritesMoving(void) static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = -96, end = 32; else start = 256, end = 160; - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++) { - structPtr->leftHeaderSprites[i]->y = startY; - MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12); + menu->leftHeaderSprites[i]->y = startY; + MoveLeftHeader(menu->leftHeaderSprites[i], start, end, 12); } } static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = -96, end = 16; else start = 256, end = 192; - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->submenuLeftHeaderSprites); i++) { - structPtr->submenuLeftHeaderSprites[i]->y = startY; - MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12); + menu->submenuLeftHeaderSprites[i]->y = startY; + MoveLeftHeader(menu->submenuLeftHeaderSprites[i], start, end, 12); } } static void HideLeftHeaderSprites(bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = 32, end = -96; else start = 192, end = 256; - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++) { - MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12); + MoveLeftHeader(menu->leftHeaderSprites[i], start, end, 12); } } static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = 16, end = -96; else start = 192, end = 256; - for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(menu->submenuLeftHeaderSprites); i++) { - MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12); + MoveLeftHeader(menu->submenuLeftHeaderSprites[i], start, end, 12); } } diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 8f2220957..29cb0a06d 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -109,15 +109,15 @@ u32 ShowCheckPageDown(s32); u32 ExitCheckPage(s32); u32 ExitMatchCall(s32); -static const u16 sMatchCallUI_Pal[] = INCBIN_U16("graphics/pokenav/ui_matchcall.gbapal"); -static const u32 sMatchCallUI_Gfx[] = INCBIN_U32("graphics/pokenav/ui_matchcall.4bpp.lz"); -static const u32 sMatchCallUI_Tilemap[] = INCBIN_U32("graphics/pokenav/ui_matchcall.bin.lz"); -static const u16 gUnknown_08622698[] = INCBIN_U16("graphics/pokenav/arrow2.gbapal"); -static const u32 gUnknown_086226B8[] = INCBIN_U32("graphics/pokenav/arrow2.4bpp.lz"); -static const u16 gUnknown_086226E0[] = INCBIN_U16("graphics/pokenav/86226E0.gbapal"); -static const u16 gUnknown_08622700[] = INCBIN_U16("graphics/pokenav/8622700.gbapal"); -static const u16 gUnknown_08622720[] = INCBIN_U16("graphics/pokenav/pokeball_matchcall.gbapal"); -static const u32 gUnknown_08622760[] = INCBIN_U32("graphics/pokenav/pokeball_matchcall.4bpp.lz"); +static const u16 sMatchCallUI_Pal[] = INCBIN_U16("graphics/pokenav/match_call/ui.gbapal"); +static const u32 sMatchCallUI_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/ui.4bpp.lz"); +static const u32 sMatchCallUI_Tilemap[] = INCBIN_U32("graphics/pokenav/match_call/ui.bin.lz"); +static const u16 gUnknown_08622698[] = INCBIN_U16("graphics/pokenav/match_call/arrow.gbapal"); +static const u32 gUnknown_086226B8[] = INCBIN_U32("graphics/pokenav/match_call/arrow.4bpp.lz"); +static const u16 gUnknown_086226E0[] = INCBIN_U16("graphics/pokenav/match_call/86226E0.gbapal"); +static const u16 gUnknown_08622700[] = INCBIN_U16("graphics/pokenav/match_call/8622700.gbapal"); +static const u16 gUnknown_08622720[] = INCBIN_U16("graphics/pokenav/match_call/pokeball.gbapal"); +static const u32 gUnknown_08622760[] = INCBIN_U32("graphics/pokenav/match_call/pokeball.4bpp.lz"); const struct BgTemplate sMatchCallBgTemplates[3] = { @@ -1062,7 +1062,7 @@ static void sub_81CC034(struct Pokenav4Struct *state) { state->msgBoxWindowId = AddWindow(&sCallMsgBoxWindowTemplate); LoadMatchCallWindowGfx(state->msgBoxWindowId, 1, 4); - sub_81C7B40(); + FadeToBlackExceptPrimary(); } static void DrawMsgBoxForMatchCallMsg(struct Pokenav4Struct *state) diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 47226ca72..ce3db25c5 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -94,8 +94,8 @@ u32 LoopedTask_sub_81C8870(s32 state); u32 LoopedTask_sub_81C8A28(s32 state); u32 LoopedTask_PrintCheckPageInfo(s32 state); -static const u16 sMatchcallArrowPaletteData[] = INCBIN_U16("graphics/pokenav/arrows_matchcall.gbapal"); -static const u32 sMatchcallArrowSpriteSheetData[] = INCBIN_U32("graphics/pokenav/arrows_matchcall.4bpp.lz"); +static const u16 sMatchcallArrowPaletteData[] = INCBIN_U16("graphics/pokenav/list_arrows.gbapal"); +static const u32 sMatchcallArrowSpriteSheetData[] = INCBIN_U32("graphics/pokenav/list_arrows.4bpp.lz"); EWRAM_DATA u32 gUnknown_0203CF44 = 0; diff --git a/src/pokenav_menu_handler_1.c b/src/pokenav_menu_handler_1.c index a500e7c18..b72247742 100644 --- a/src/pokenav_menu_handler_1.c +++ b/src/pokenav_menu_handler_1.c @@ -5,31 +5,31 @@ #include "sound.h" #include "constants/songs.h" -struct Pokenav1Struct +struct Pokenav_Menu { u16 menuType; s16 cursorPos; u16 currMenuItem; u16 helpBarIndex; u32 menuId; - u32 (*callback)(struct Pokenav1Struct*); + u32 (*callback)(struct Pokenav_Menu*); }; -static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state); -static void ReturnToConditionMenu(struct Pokenav1Struct *state); -static void ReturnToMainMenu(struct Pokenav1Struct *state); -static u32 GetMenuId(struct Pokenav1Struct *state); -static void SetMenuIdAndCB(struct Pokenav1Struct *state, u32 a1); -static u32 CB2_ReturnToConditionMenu(struct Pokenav1Struct *state); -static u32 CB2_ReturnToMainMenu(struct Pokenav1Struct *state); -static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state); -static u32 HandleConditionMenuInput(struct Pokenav1Struct *state); -static u32 HandleCantOpenRibbonsInput(struct Pokenav1Struct *state); -static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state); -static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state); -static u32 HandleMainMenuInput(struct Pokenav1Struct *state); -static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*); -static void SetMenuInputHandler(struct Pokenav1Struct *state); +static bool32 UpdateMenuCursorPos(struct Pokenav_Menu *); +static void ReturnToConditionMenu(struct Pokenav_Menu *); +static void ReturnToMainMenu(struct Pokenav_Menu *); +static u32 GetMenuId(struct Pokenav_Menu *); +static void SetMenuIdAndCB(struct Pokenav_Menu *, u32); +static u32 CB2_ReturnToConditionMenu(struct Pokenav_Menu *); +static u32 CB2_ReturnToMainMenu(struct Pokenav_Menu *); +static u32 HandleConditionSearchMenuInput(struct Pokenav_Menu *); +static u32 HandleConditionMenuInput(struct Pokenav_Menu *); +static u32 HandleCantOpenRibbonsInput(struct Pokenav_Menu *); +static u32 HandleMainMenuInputEndTutorial(struct Pokenav_Menu *); +static u32 HandleMainMenuInputTutorial(struct Pokenav_Menu *); +static u32 HandleMainMenuInput(struct Pokenav_Menu *); +static u32 (*GetMainMenuInputHandler(void))(struct Pokenav_Menu*); +static void SetMenuInputHandler(struct Pokenav_Menu *); // Number of entries - 1 for that menu type static const u8 sLastCursorPositions[] = @@ -41,20 +41,20 @@ static const u8 sLastCursorPositions[] = [POKENAV_MENU_TYPE_CONDITION_SEARCH] = 5 }; -static const u8 sMenuItems[][6] = +static const u8 sMenuItems[][MAX_POKENAV_MENUITEMS] = { [POKENAV_MENU_TYPE_DEFAULT] = { POKENAV_MENUITEM_MAP, POKENAV_MENUITEM_CONDITION, - [2 ... 5] = POKENAV_MENUITEM_SWITCH_OFF + [2 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF }, [POKENAV_MENU_TYPE_UNLOCK_MC] = { POKENAV_MENUITEM_MAP, POKENAV_MENUITEM_CONDITION, POKENAV_MENUITEM_MATCH_CALL, - [3 ... 5] = POKENAV_MENUITEM_SWITCH_OFF + [3 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF }, [POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] = { @@ -62,14 +62,14 @@ static const u8 sMenuItems[][6] = POKENAV_MENUITEM_CONDITION, POKENAV_MENUITEM_MATCH_CALL, POKENAV_MENUITEM_RIBBONS, - [4 ... 5] = POKENAV_MENUITEM_SWITCH_OFF + [4 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF }, [POKENAV_MENU_TYPE_CONDITION] = { POKENAV_MENUITEM_CONDITION_PARTY, POKENAV_MENUITEM_CONDITION_SEARCH, POKENAV_MENUITEM_CONDITION_CANCEL, - [3 ... 5] = POKENAV_MENUITEM_SWITCH_OFF + [3 ... MAX_POKENAV_MENUITEMS - 1] = POKENAV_MENUITEM_SWITCH_OFF }, [POKENAV_MENU_TYPE_CONDITION_SEARCH] = { @@ -99,94 +99,94 @@ static u8 GetPokenavMainMenuType(void) bool32 PokenavCallback_Init_MainMenuCursorOnMap(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = GetPokenavMainMenuType(); - state->cursorPos = POKENAV_MENUITEM_MAP; - state->currMenuItem = POKENAV_MENUITEM_MAP; - state->helpBarIndex = HELPBAR_NONE; - SetMenuInputHandler(state); + menu->menuType = GetPokenavMainMenuType(); + menu->cursorPos = POKENAV_MENUITEM_MAP; + menu->currMenuItem = POKENAV_MENUITEM_MAP; + menu->helpBarIndex = HELPBAR_NONE; + SetMenuInputHandler(menu); return TRUE; } bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = GetPokenavMainMenuType(); - state->cursorPos = POKENAV_MENUITEM_MATCH_CALL; - state->currMenuItem = POKENAV_MENUITEM_MATCH_CALL; - state->helpBarIndex = HELPBAR_NONE; - SetMenuInputHandler(state); + menu->menuType = GetPokenavMainMenuType(); + menu->cursorPos = POKENAV_MENUITEM_MATCH_CALL; + menu->currMenuItem = POKENAV_MENUITEM_MATCH_CALL; + menu->helpBarIndex = HELPBAR_NONE; + SetMenuInputHandler(menu); return TRUE; } bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = GetPokenavMainMenuType(); - state->cursorPos = POKENAV_MENUITEM_RIBBONS; - state->currMenuItem = POKENAV_MENUITEM_RIBBONS; - SetMenuInputHandler(state); + menu->menuType = GetPokenavMainMenuType(); + menu->cursorPos = POKENAV_MENUITEM_RIBBONS; + menu->currMenuItem = POKENAV_MENUITEM_RIBBONS; + SetMenuInputHandler(menu); return TRUE; } bool32 PokenavCallback_Init_ConditionMenu(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = POKENAV_MENU_TYPE_CONDITION; - state->cursorPos = 0; //party - state->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY; - state->helpBarIndex = HELPBAR_NONE; - SetMenuInputHandler(state); + menu->menuType = POKENAV_MENU_TYPE_CONDITION; + menu->cursorPos = 0; //party + menu->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY; + menu->helpBarIndex = HELPBAR_NONE; + SetMenuInputHandler(menu); return TRUE; } bool32 PokenavCallback_Init_ConditionSearchMenu(void) { - struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); - if (!state) + struct Pokenav_Menu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav_Menu)); + if (!menu) return FALSE; - state->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH; - state->cursorPos = GetSelectedConditionSearch(); - state->currMenuItem = state->cursorPos + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; - state->helpBarIndex = HELPBAR_NONE; - SetMenuInputHandler(state); + menu->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH; + menu->cursorPos = GetSelectedConditionSearch(); + menu->currMenuItem = menu->cursorPos + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; + menu->helpBarIndex = HELPBAR_NONE; + SetMenuInputHandler(menu); return TRUE; } -static void SetMenuInputHandler(struct Pokenav1Struct *state) +static void SetMenuInputHandler(struct Pokenav_Menu *menu) { - switch (state->menuType) + switch (menu->menuType) { case POKENAV_MENU_TYPE_DEFAULT: SetPokenavMode(POKENAV_MODE_NORMAL); // fallthrough case POKENAV_MENU_TYPE_UNLOCK_MC: case POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS: - state->callback = GetMainMenuInputHandler(); + menu->callback = GetMainMenuInputHandler(); break; case POKENAV_MENU_TYPE_CONDITION: - state->callback = HandleConditionMenuInput; + menu->callback = HandleConditionMenuInput; break; case POKENAV_MENU_TYPE_CONDITION_SEARCH: - state->callback = HandleConditionSearchMenuInput; + menu->callback = HandleConditionSearchMenuInput; break; } } -static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*) +static u32 (*GetMainMenuInputHandler(void))(struct Pokenav_Menu*) { switch (GetPokenavMode()) { @@ -202,8 +202,8 @@ static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*) u32 GetMenuHandlerCallback(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->callback(state); + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->callback(menu); } void FreeMenuHandlerSubstruct1(void) @@ -211,39 +211,39 @@ void FreeMenuHandlerSubstruct1(void) FreePokenavSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); } -static u32 HandleMainMenuInput(struct Pokenav1Struct *state) +static u32 HandleMainMenuInput(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - switch (sMenuItems[state->menuType][state->cursorPos]) + switch (sMenuItems[menu->menuType][menu->cursorPos]) { case POKENAV_MENUITEM_MAP: - state->helpBarIndex = gSaveBlock2Ptr->regionMapZoom ? HELPBAR_MAP_ZOOMED_IN : HELPBAR_MAP_ZOOMED_OUT; - SetMenuIdAndCB(state, POKENAV_REGION_MAP); + menu->helpBarIndex = gSaveBlock2Ptr->regionMapZoom ? HELPBAR_MAP_ZOOMED_IN : HELPBAR_MAP_ZOOMED_OUT; + SetMenuIdAndCB(menu, POKENAV_REGION_MAP); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_CONDITION: - state->menuType = POKENAV_MENU_TYPE_CONDITION; - state->cursorPos = 0; - state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][0]; - state->callback = HandleConditionMenuInput; + menu->menuType = POKENAV_MENU_TYPE_CONDITION; + menu->cursorPos = 0; + menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][0]; + menu->callback = HandleConditionMenuInput; return POKENAV_MENU_FUNC_OPEN_CONDITION; case POKENAV_MENUITEM_MATCH_CALL: - state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - SetMenuIdAndCB(state, POKENAV_MATCH_CALL); + menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST; + SetMenuIdAndCB(menu, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_RIBBONS: if (CanViewRibbonsMenu()) { - state->helpBarIndex = HELPBAR_RIBBONS_MON_LIST; - SetMenuIdAndCB(state, POKENAV_RIBBONS_MON_LIST); + menu->helpBarIndex = HELPBAR_RIBBONS_MON_LIST; + SetMenuIdAndCB(menu, POKENAV_RIBBONS_MON_LIST); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else { - state->callback = HandleCantOpenRibbonsInput; + menu->callback = HandleCantOpenRibbonsInput; return POKENAV_MENU_FUNC_NO_RIBBON_WINNERS; } case POKENAV_MENUITEM_SWITCH_OFF: @@ -258,17 +258,17 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state) } // Force the player to select Match Call during the call Mr. Stone pokenav tutorial -static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state) +static u32 HandleMainMenuInputTutorial(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - if (sMenuItems[state->menuType][state->cursorPos] == POKENAV_MENUITEM_MATCH_CALL) + if (sMenuItems[menu->menuType][menu->cursorPos] == POKENAV_MENUITEM_MATCH_CALL) { - state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - SetMenuIdAndCB(state, POKENAV_MATCH_CALL); + menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST; + SetMenuIdAndCB(menu, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else @@ -288,14 +288,14 @@ static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state) } // After calling Mr. Stone during the pokenav tutorial, force player to exit or use Match Call again -static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) +static u32 HandleMainMenuInputEndTutorial(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - u32 menuItem = sMenuItems[state->menuType][state->cursorPos]; + u32 menuItem = sMenuItems[menu->menuType][menu->cursorPos]; if (menuItem != POKENAV_MENUITEM_MATCH_CALL && menuItem != POKENAV_MENUITEM_SWITCH_OFF) { PlaySE(SE_FAILURE); @@ -303,8 +303,8 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) } else if (menuItem == POKENAV_MENUITEM_MATCH_CALL) { - state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - SetMenuIdAndCB(state, POKENAV_MATCH_CALL); + menu->helpBarIndex = HELPBAR_MC_TRAINER_LIST; + SetMenuIdAndCB(menu, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else @@ -321,60 +321,60 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) // Handles input after selecting Ribbons when there are no ribbon winners left // Selecting it again just reprints the Ribbon description to replace the "No Ribbon winners" message -static u32 HandleCantOpenRibbonsInput(struct Pokenav1Struct *state) +static u32 HandleCantOpenRibbonsInput(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) { - state->callback = GetMainMenuInputHandler(); + menu->callback = GetMainMenuInputHandler(); return POKENAV_MENU_FUNC_MOVE_CURSOR; } if (JOY_NEW(A_BUTTON | B_BUTTON)) { - state->callback = GetMainMenuInputHandler(); + menu->callback = GetMainMenuInputHandler(); return POKENAV_MENU_FUNC_RESHOW_DESCRIPTION; } return POKENAV_MENU_FUNC_NONE; } -static u32 HandleConditionMenuInput(struct Pokenav1Struct *state) +static u32 HandleConditionMenuInput(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - switch (sMenuItems[state->menuType][state->cursorPos]) + switch (sMenuItems[menu->menuType][menu->cursorPos]) { case POKENAV_MENUITEM_CONDITION_SEARCH: - state->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH; - state->cursorPos = 0; - state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION_SEARCH][0]; - state->callback = HandleConditionSearchMenuInput; + menu->menuType = POKENAV_MENU_TYPE_CONDITION_SEARCH; + menu->cursorPos = 0; + menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION_SEARCH][0]; + menu->callback = HandleConditionSearchMenuInput; return POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH; case POKENAV_MENUITEM_CONDITION_PARTY: - state->helpBarIndex = 0; - SetMenuIdAndCB(state, POKENAV_CONDITION_GRAPH_PARTY); + menu->helpBarIndex = 0; + SetMenuIdAndCB(menu, POKENAV_CONDITION_GRAPH_PARTY); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_CONDITION_CANCEL: PlaySE(SE_SELECT); - ReturnToMainMenu(state); + ReturnToMainMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_MAIN; } } if (JOY_NEW(B_BUTTON)) { - if (state->cursorPos != sLastCursorPositions[state->menuType]) + if (menu->cursorPos != sLastCursorPositions[menu->menuType]) { - state->cursorPos = sLastCursorPositions[state->menuType]; - state->callback = CB2_ReturnToMainMenu; + menu->cursorPos = sLastCursorPositions[menu->menuType]; + menu->callback = CB2_ReturnToMainMenu; return POKENAV_MENU_FUNC_MOVE_CURSOR; } else { PlaySE(SE_SELECT); - ReturnToMainMenu(state); + ReturnToMainMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_MAIN; } } @@ -382,102 +382,102 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_NONE; } -static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state) +static u32 HandleConditionSearchMenuInput(struct Pokenav_Menu *menu) { - if (UpdateMenuCursorPos(state)) + if (UpdateMenuCursorPos(menu)) return POKENAV_MENU_FUNC_MOVE_CURSOR; if (JOY_NEW(A_BUTTON)) { - u8 menuItem = sMenuItems[state->menuType][state->cursorPos]; + u8 menuItem = sMenuItems[menu->menuType][menu->cursorPos]; if (menuItem != POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL) { SetSelectedConditionSearch(menuItem - POKENAV_MENUITEM_CONDITION_SEARCH_COOL); - SetMenuIdAndCB(state, POKENAV_CONDITION_SEARCH_RESULTS); - state->helpBarIndex = HELPBAR_CONDITION_MON_LIST; + SetMenuIdAndCB(menu, POKENAV_CONDITION_SEARCH_RESULTS); + menu->helpBarIndex = HELPBAR_CONDITION_MON_LIST; return POKENAV_MENU_FUNC_OPEN_FEATURE; } else { PlaySE(SE_SELECT); - ReturnToConditionMenu(state); + ReturnToConditionMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_CONDITION; } } if (JOY_NEW(B_BUTTON)) { - if (state->cursorPos != sLastCursorPositions[state->menuType]) + if (menu->cursorPos != sLastCursorPositions[menu->menuType]) { - state->cursorPos = sLastCursorPositions[state->menuType]; - state->callback = CB2_ReturnToConditionMenu; + menu->cursorPos = sLastCursorPositions[menu->menuType]; + menu->callback = CB2_ReturnToConditionMenu; return POKENAV_MENU_FUNC_MOVE_CURSOR; } else { PlaySE(SE_SELECT); - ReturnToConditionMenu(state); + ReturnToConditionMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_CONDITION; } } return POKENAV_MENU_FUNC_NONE; } -static u32 CB2_ReturnToMainMenu(struct Pokenav1Struct *state) +static u32 CB2_ReturnToMainMenu(struct Pokenav_Menu *menu) { - ReturnToMainMenu(state); + ReturnToMainMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_MAIN; } -static u32 CB2_ReturnToConditionMenu(struct Pokenav1Struct *state) +static u32 CB2_ReturnToConditionMenu(struct Pokenav_Menu *menu) { - ReturnToConditionMenu(state); + ReturnToConditionMenu(menu); return POKENAV_MENU_FUNC_RETURN_TO_CONDITION; } -static void SetMenuIdAndCB(struct Pokenav1Struct *state, u32 menuId) +static void SetMenuIdAndCB(struct Pokenav_Menu *menu, u32 menuId) { - state->menuId = menuId; - state->callback = GetMenuId; + menu->menuId = menuId; + menu->callback = GetMenuId; } -static u32 GetMenuId(struct Pokenav1Struct *state) +static u32 GetMenuId(struct Pokenav_Menu *menu) { - return state->menuId; + return menu->menuId; } -static void ReturnToMainMenu(struct Pokenav1Struct *state) +static void ReturnToMainMenu(struct Pokenav_Menu *menu) { - state->menuType = GetPokenavMainMenuType(); - state->cursorPos = 1; - state->currMenuItem = sMenuItems[state->menuType][state->cursorPos]; - state->callback = HandleMainMenuInput; + menu->menuType = GetPokenavMainMenuType(); + menu->cursorPos = 1; + menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos]; + menu->callback = HandleMainMenuInput; } -static void ReturnToConditionMenu(struct Pokenav1Struct *state) +static void ReturnToConditionMenu(struct Pokenav_Menu *menu) { - state->menuType = POKENAV_MENU_TYPE_CONDITION; - state->cursorPos = 1; - state->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][1]; - state->callback = HandleConditionMenuInput; + menu->menuType = POKENAV_MENU_TYPE_CONDITION; + menu->cursorPos = 1; + menu->currMenuItem = sMenuItems[POKENAV_MENU_TYPE_CONDITION][1]; + menu->callback = HandleConditionMenuInput; } -static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state) +static bool32 UpdateMenuCursorPos(struct Pokenav_Menu *menu) { if (JOY_NEW(DPAD_UP)) { - if (--state->cursorPos < 0) - state->cursorPos = sLastCursorPositions[state->menuType]; + if (--menu->cursorPos < 0) + menu->cursorPos = sLastCursorPositions[menu->menuType]; - state->currMenuItem = sMenuItems[state->menuType][state->cursorPos]; + menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos]; return TRUE; } else if (JOY_NEW(DPAD_DOWN)) { - state->cursorPos++; - if (state->cursorPos > sLastCursorPositions[state->menuType]) - state->cursorPos = 0; + menu->cursorPos++; + if (menu->cursorPos > sLastCursorPositions[menu->menuType]) + menu->cursorPos = 0; - state->currMenuItem = sMenuItems[state->menuType][state->cursorPos]; + menu->currMenuItem = sMenuItems[menu->menuType][menu->cursorPos]; return TRUE; } else @@ -488,26 +488,26 @@ static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state) int GetPokenavMenuType(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->menuType; + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->menuType; } // Position of cursor relative to number of current menu options int GetPokenavCursorPos(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->cursorPos; + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->cursorPos; } // ID of menu item the cursor is currently on int GetCurrentMenuItemId(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->currMenuItem; + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->currMenuItem; } u16 GetHelpBarTextId(void) { - struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); - return state->helpBarIndex; + struct Pokenav_Menu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); + return menu->helpBarIndex; } diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index a50f45106..1738142ac 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -17,68 +17,86 @@ #include "constants/songs.h" #include "constants/rgb.h" -struct Pokenav2Struct +#define GFXTAG_BLUE_LIGHT 1 +#define GFXTAG_OPTIONS 3 + +#define PALTAG_BLUE_LIGHT 3 +#define PALTAG_OPTIONS_DEFAULT 4 // Includes green for Smart/Region Map and yellow for Tough +#define PALTAG_OPTIONS_BLUE 5 +#define PALTAG_OPTIONS_PINK 6 +#define PALTAG_OPTIONS_BEIGE 7 +#define PALTAG_OPTIONS_RED 8 + +#define PALTAG_OPTIONS_START PALTAG_OPTIONS_DEFAULT + +#define NUM_OPTION_SUBSPRITES 4 + +#define OPTION_DEFAULT_X 140 +#define OPTION_SELECTED_X 130 +#define OPTION_EXIT_X (DISPLAY_WIDTH + 16) + +struct Pokenav_MenuGfx { bool32 (*isTaskActiveCB)(void); u32 loopedTaskId; u16 optionDescWindowId; u8 bg3ScrollTaskId; u8 cursorPos; - bool8 otherIconsInMotion; + u8 numIconsBlending; bool8 pokenavAlreadyOpen; bool32 iconVisible[MAX_POKENAV_MENUITEMS]; - struct Sprite * blueLightSpriteId; - struct Sprite * iconSprites[MAX_POKENAV_MENUITEMS][4]; - u16 bg1TilemapBuffer[0x400]; + struct Sprite * blueLightSprite; + struct Sprite * iconSprites[MAX_POKENAV_MENUITEMS][NUM_OPTION_SUBSPRITES]; + u8 bg1TilemapBuffer[BG_SCREEN_SIZE]; }; -static struct Pokenav2Struct * OpenPokenavMenu(void); +static struct Pokenav_MenuGfx * OpenPokenavMenu(void); static bool32 GetCurrentLoopedTaskActive(void); -static u32 LoopedTask_OpenMenu(s32 state); -static u32 LoopedTask_MoveMenuCursor(s32 state); -static u32 LoopedTask_OpenConditionMenu(s32 state); -static u32 LoopedTask_ReturnToMainMenu(s32 state); -static u32 LoopedTask_OpenConditionSearchMenu(s32 state); -static u32 LoopedTask_ReturnToConditionMenu(s32 state); -static u32 LoopedTask_SelectRibbonsNoWinners(s32 state); -static u32 LoopedTask_ReShowDescription(s32 state); -static u32 LoopedTask_OpenPokenavFeature(s32 state); +static u32 LoopedTask_OpenMenu(s32); +static u32 LoopedTask_MoveMenuCursor(s32); +static u32 LoopedTask_OpenConditionMenu(s32); +static u32 LoopedTask_ReturnToMainMenu(s32); +static u32 LoopedTask_OpenConditionSearchMenu(s32); +static u32 LoopedTask_ReturnToConditionMenu(s32); +static u32 LoopedTask_SelectRibbonsNoWinners(s32); +static u32 LoopedTask_ReShowDescription(s32); +static u32 LoopedTask_OpenPokenavFeature(s32); static void LoadPokenavOptionPalettes(void); static void FreeAndDestroyMainMenuSprites(void); static void CreateMenuOptionSprites(void); static void DestroyMenuOptionSprites(void); -static void sub_81CA0C8(void); -static void DrawOptionLabelGfx(const u16 *const * a0, s32 yPos, s32 a2); -static void SetupCurrentMenuOptionsGfx(void); -static void SetMenuOptionGfxParams_CursorMoved(void); -static void SetMenuOptionGfxParamsInactive(struct Sprite ** sprites, s32 x, s32 a2, s32 a3); -static void SetMenuOptionGfxParamsActive(struct Sprite ** sprites); -static void SetupPokenavMenuOptions(void); +static void DrawCurrentMenuOptionLabels(void); +static void DrawOptionLabelGfx(const u16 *const *, s32, s32); +static void StartOptionAnimations_Enter(void); +static void StartOptionAnimations_CursorMoved(void); +static void StartOptionAnimations_Exit(void); +static void StartOptionSlide(struct Sprite **, s32, s32, s32); +static void StartOptionZoom(struct Sprite **); static bool32 AreMenuOptionSpritesMoving(void); -static void SetMenuOptionGfxInvisibility(struct Sprite ** sprites, bool32 a1); -static void sub_81CA474(struct Sprite * sprite); -static void sub_81CA4AC(struct Sprite * sprite); -static void sub_81CA580(u8 taskId); +static void SetOptionInvisibility(struct Sprite **, bool32); +static void SpriteCB_OptionSlide(struct Sprite *); +static void SpriteCB_OptionZoom(struct Sprite *); +static void Task_OptionBlend(u8); static void CreateMatchCallBlueLightSprite(void); -static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite); -static void DestroyRematchBlueLightSpriteId(void); +static void SpriteCB_BlinkingBlueLight(struct Sprite *); +static void DestroyRematchBlueLightSprite(void); static void AddOptionDescriptionWindow(void); static void PrintCurrentOptionDescription(void); static void PrintNoRibbonWinners(void); static bool32 IsDma3ManagerBusyWithBgCopy_(void); static void CreateMovingBgDotsTask(void); static void DestroyMovingDotsBgTask(void); -static void Task_MoveBgDots(u8 taskId); +static void Task_MoveBgDots(u8); static void CreateBgDotPurplePalTask(void); static void ChangeBgDotsColorToPurple(void); static void CreateBgDotLightBluePalTask(void); static bool32 IsTaskActive_UpdateBgDotsPalette(void); -static void Task_UpdateBgDotsPalette(u8 taskId); +static void Task_UpdateBgDotsPalette(u8); static void SetupPokenavMenuScanlineEffects(void); static void DestroyMenuOptionGlowTask(void); static void ResetBldCnt(void); static void InitMenuOptionGlow(void); -static void Task_CurrentMenuOptionGlow(u8 taskId); +static void Task_CurrentMenuOptionGlow(u8); static void SetMenuOptionGlow(void); static const u16 sPokenavBgDotsPal[] = INCBIN_U16("graphics/pokenav/bg_dots.gbapal"); @@ -136,78 +154,103 @@ static const struct CompressedSpriteSheet sPokenavOptionsSpriteSheets[] = { .data = gPokenavOptions_Gfx, .size = 0x3400, - .tag = 0x0003 + .tag = GFXTAG_OPTIONS }, { .data = sMatchCallBlueLightTiles, .size = 0x0100, - .tag = 0x0001 + .tag = GFXTAG_BLUE_LIGHT } }; static const struct SpritePalette sPokenavOptionsSpritePalettes[] = { - {gPokenavOptions_Pal + 0x00, 4}, - {gPokenavOptions_Pal + 0x10, 5}, - {gPokenavOptions_Pal + 0x20, 6}, - {gPokenavOptions_Pal + 0x30, 7}, - {gPokenavOptions_Pal + 0x40, 8}, - {sMatchCallBlueLightPal, 3}, + {&gPokenavOptions_Pal[0x00], PALTAG_OPTIONS_DEFAULT}, + {&gPokenavOptions_Pal[0x10], PALTAG_OPTIONS_BLUE}, + {&gPokenavOptions_Pal[0x20], PALTAG_OPTIONS_PINK}, + {&gPokenavOptions_Pal[0x30], PALTAG_OPTIONS_BEIGE}, + {&gPokenavOptions_Pal[0x40], PALTAG_OPTIONS_RED}, + {sMatchCallBlueLightPal, PALTAG_BLUE_LIGHT}, {} }; -static const u16 sOptionsLabelGfx_RegionMap[] = {0, 0}; -static const u16 sOptionsLabelGfx_Condition[] = {0x20, 1}; -static const u16 sOptionsLabelGfx_MatchCall[] = {0x40, 4}; -static const u16 sOptionsLabelGfx_Ribbons[] = {0x60, 2}; -static const u16 sOptionsLabelGfx_SwitchOff[] = {0x80, 3}; -static const u16 sOptionsLabelGfx_Party[] = {0xA0, 1}; -static const u16 sOptionsLabelGfx_Search[] = {0xC0, 1}; -static const u16 sOptionsLabelGfx_Cool[] = {0xE0, 4}; -static const u16 sOptionsLabelGfx_Beauty[] = {0x100, 1}; -static const u16 sOptionsLabelGfx_Cute[] = {0x120, 2}; -static const u16 sOptionsLabelGfx_Smart[] = {0x140, 0}; -static const u16 sOptionsLabelGfx_Tough[] = {0x160, 0}; -static const u16 sOptionsLabelGfx_Cancel[] = {0x180, 3}; +// Tile number, palette tag offset +static const u16 sOptionsLabelGfx_RegionMap[] = {0x000, PALTAG_OPTIONS_DEFAULT - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Condition[] = {0x020, PALTAG_OPTIONS_BLUE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_MatchCall[] = {0x040, PALTAG_OPTIONS_RED - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Ribbons[] = {0x060, PALTAG_OPTIONS_PINK - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_SwitchOff[] = {0x080, PALTAG_OPTIONS_BEIGE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Party[] = {0x0A0, PALTAG_OPTIONS_BLUE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Search[] = {0x0C0, PALTAG_OPTIONS_BLUE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Cool[] = {0x0E0, PALTAG_OPTIONS_RED - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Beauty[] = {0x100, PALTAG_OPTIONS_BLUE - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Cute[] = {0x120, PALTAG_OPTIONS_PINK - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Smart[] = {0x140, PALTAG_OPTIONS_DEFAULT - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Tough[] = {0x160, PALTAG_OPTIONS_DEFAULT - PALTAG_OPTIONS_START}; +static const u16 sOptionsLabelGfx_Cancel[] = {0x180, PALTAG_OPTIONS_BEIGE - PALTAG_OPTIONS_START}; -struct OptionsLabelGfx +struct { u16 yStart; u16 deltaY; - const u16 *tiles[MAX_POKENAV_MENUITEMS]; -}; - -static const struct OptionsLabelGfx sPokenavMenuOptionLabelGfx[POKENAV_MENU_TYPE_COUNT] = + const u16 *gfx[MAX_POKENAV_MENUITEMS]; +} static const sPokenavMenuOptionLabelGfx[POKENAV_MENU_TYPE_COUNT] = { [POKENAV_MENU_TYPE_DEFAULT] = { .yStart = 42, .deltaY = 20, - {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_SwitchOff} + .gfx = { + sOptionsLabelGfx_RegionMap, + sOptionsLabelGfx_Condition, + sOptionsLabelGfx_SwitchOff + } }, [POKENAV_MENU_TYPE_UNLOCK_MC] = { .yStart = 42, .deltaY = 20, - {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_MatchCall, sOptionsLabelGfx_SwitchOff} + .gfx = { + sOptionsLabelGfx_RegionMap, + sOptionsLabelGfx_Condition, + sOptionsLabelGfx_MatchCall, + sOptionsLabelGfx_SwitchOff + } }, [POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] = { .yStart = 42, .deltaY = 20, - {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_MatchCall, sOptionsLabelGfx_Ribbons, sOptionsLabelGfx_SwitchOff} + .gfx = { + sOptionsLabelGfx_RegionMap, + sOptionsLabelGfx_Condition, + sOptionsLabelGfx_MatchCall, + sOptionsLabelGfx_Ribbons, + sOptionsLabelGfx_SwitchOff + } }, [POKENAV_MENU_TYPE_CONDITION] = { .yStart = 56, .deltaY = 20, - {sOptionsLabelGfx_Party, sOptionsLabelGfx_Search, sOptionsLabelGfx_Cancel} + .gfx = { + sOptionsLabelGfx_Party, + sOptionsLabelGfx_Search, + sOptionsLabelGfx_Cancel + } }, [POKENAV_MENU_TYPE_CONDITION_SEARCH] = { .yStart = 40, .deltaY = 16, - {sOptionsLabelGfx_Cool, sOptionsLabelGfx_Beauty, sOptionsLabelGfx_Cute, sOptionsLabelGfx_Smart, sOptionsLabelGfx_Tough, sOptionsLabelGfx_Cancel} + .gfx = { + sOptionsLabelGfx_Cool, + sOptionsLabelGfx_Beauty, + sOptionsLabelGfx_Cute, + sOptionsLabelGfx_Smart, + sOptionsLabelGfx_Tough, + sOptionsLabelGfx_Cancel + } }, }; @@ -216,8 +259,8 @@ static const struct WindowTemplate sOptionDescWindowTemplate = .bg = 1, .tilemapLeft = 3, .tilemapTop = 17, - .width = 0x18, - .height = 0x2, + .width = 24, + .height = 2, .paletteNum = 1, .baseBlock = 8 }; @@ -257,33 +300,33 @@ static const struct OamData sOamData_MenuOption = .paletteNum = 0, }; -static const union AffineAnimCmd gUnknown_0862031C[] = +static const union AffineAnimCmd sAffineAnim_MenuOption_Normal[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gUnknown_0862032C[] = +static const union AffineAnimCmd sAffineAnim_MenuOption_Zoom[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0x10, 0x10, 0, 0x12), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd *const sSpriteAnims_MenuOption[] = +static const union AffineAnimCmd *const sAffineAnims_MenuOption[] = { - gUnknown_0862031C, - gUnknown_0862032C + sAffineAnim_MenuOption_Normal, + sAffineAnim_MenuOption_Zoom }; static const struct SpriteTemplate sMenuOptionSpriteTemplate = { - .tileTag = 3, - .paletteTag = 4, + .tileTag = GFXTAG_OPTIONS, + .paletteTag = PALTAG_OPTIONS_START, .oam = &sOamData_MenuOption, .anims = gDummySpriteAnimTable, .images = NULL, - .affineAnims = sSpriteAnims_MenuOption, + .affineAnims = sAffineAnims_MenuOption, .callback = SpriteCallbackDummy, }; @@ -303,8 +346,8 @@ static const struct OamData sBlueLightOamData = static const struct SpriteTemplate sMatchCallBlueLightSpriteTemplate = { - .tileTag = 1, - .paletteTag = 3, + .tileTag = GFXTAG_BLUE_LIGHT, + .paletteTag = PALTAG_BLUE_LIGHT, .oam = &sBlueLightOamData, .anims = gDummySpriteAnimTable, .images = NULL, @@ -320,7 +363,7 @@ static const struct ScanlineEffectParams sPokenavMainMenuScanlineEffectParams = 0 }; -static bool32 PlayerHasTrainerRematches(void) +static bool32 AreAnyTrainerRematchesNearby(void) { s32 i; @@ -337,81 +380,81 @@ static bool32 PlayerHasTrainerRematches(void) bool32 OpenPokenavMenuInitial(void) { - struct Pokenav2Struct * state = OpenPokenavMenu(); + struct Pokenav_MenuGfx * gfx = OpenPokenavMenu(); - if (state == NULL) + if (gfx == NULL) return FALSE; - state->pokenavAlreadyOpen = FALSE; + gfx->pokenavAlreadyOpen = FALSE; return TRUE; } bool32 OpenPokenavMenuNotInitial(void) { - struct Pokenav2Struct * state = OpenPokenavMenu(); + struct Pokenav_MenuGfx * gfx = OpenPokenavMenu(); - if (state == NULL) + if (gfx == NULL) return FALSE; - state->pokenavAlreadyOpen = TRUE; + gfx->pokenavAlreadyOpen = TRUE; return TRUE; } -static struct Pokenav2Struct * OpenPokenavMenu(void) +static struct Pokenav_MenuGfx * OpenPokenavMenu(void) { - struct Pokenav2Struct * state = AllocSubstruct(POKENAV_SUBSTRUCT_MENU_ICONS, sizeof(struct Pokenav2Struct)); + struct Pokenav_MenuGfx * gfx = AllocSubstruct(POKENAV_SUBSTRUCT_MENU_GFX, sizeof(struct Pokenav_MenuGfx)); - if (state != NULL) + if (gfx != NULL) { - state->otherIconsInMotion = FALSE; - state->loopedTaskId = CreateLoopedTask(LoopedTask_OpenMenu, 1); - state->isTaskActiveCB = GetCurrentLoopedTaskActive; + gfx->numIconsBlending = 0; + gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenMenu, 1); + gfx->isTaskActiveCB = GetCurrentLoopedTaskActive; } - return state; + return gfx; } void CreateMenuHandlerLoopedTask(s32 ltIdx) { - struct Pokenav2Struct * state = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - state->loopedTaskId = CreateLoopedTask(sMenuHandlerLoopTaskFuncs[ltIdx], 1); - state->isTaskActiveCB = GetCurrentLoopedTaskActive; + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + gfx->loopedTaskId = CreateLoopedTask(sMenuHandlerLoopTaskFuncs[ltIdx], 1); + gfx->isTaskActiveCB = GetCurrentLoopedTaskActive; } bool32 IsMenuHandlerLoopedTaskActive(void) { - struct Pokenav2Struct * state = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - return state->isTaskActiveCB(); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + return gfx->isTaskActiveCB(); } void FreeMenuHandlerSubstruct2(void) { - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); DestroyMovingDotsBgTask(); - RemoveWindow(unk->optionDescWindowId); + RemoveWindow(gfx->optionDescWindowId); FreeAndDestroyMainMenuSprites(); DestroyMenuOptionGlowTask(); - FreePokenavSubstruct(POKENAV_SUBSTRUCT_MENU_ICONS); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MENU_GFX); } static bool32 GetCurrentLoopedTaskActive(void) { - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); - return IsLoopedTaskActive(unk->loopedTaskId); + return IsLoopedTaskActive(gfx->loopedTaskId); } static u32 LoopedTask_OpenMenu(s32 state) { - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); switch (state) { case 0: InitBgTemplates(sPokenavMainMenuBgTemplates, ARRAY_COUNT(sPokenavMainMenuBgTemplates)); DecompressAndCopyTileDataToVram(1, gPokenavMessageBox_Gfx, 0, 0, 0); - SetBgTilemapBuffer(1, unk->bg1TilemapBuffer); + SetBgTilemapBuffer(1, gfx->bg1TilemapBuffer); CopyToBgTilemapBuffer(1, gPokenavMessageBox_Tilemap, 0, 0); CopyBgTilemapBufferToVram(1); CopyPaletteIntoBufferUnfaded(gPokenavMessageBox_Pal, 0x10, 0x20); @@ -451,7 +494,7 @@ static u32 LoopedTask_OpenMenu(s32 state) PrintCurrentOptionDescription(); CreateMenuOptionSprites(); CreateMatchCallBlueLightSprite(); - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); return LT_INC_AND_PAUSE; case 6: if (IsDma3ManagerBusyWithBgCopy_()) @@ -461,7 +504,7 @@ static u32 LoopedTask_OpenMenu(s32 state) ShowBg(1); ShowBg(2); ShowBg(3); - if (unk->pokenavAlreadyOpen) + if (gfx->pokenavAlreadyOpen) PokenavFadeScreen(1); else { @@ -496,7 +539,7 @@ static u32 LoopedTask_OpenMenu(s32 state) ShowLeftHeaderGfx(0, FALSE, FALSE); break; } - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); SetupPokenavMenuScanlineEffects(); return LT_INC_AND_CONTINUE; case 9: @@ -515,7 +558,7 @@ static u32 LoopedTask_MoveMenuCursor(s32 state) { case 0: SetMenuOptionGlow(); - SetMenuOptionGfxParams_CursorMoved(); + StartOptionAnimations_CursorMoved(); PrintCurrentOptionDescription(); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; @@ -535,7 +578,7 @@ static u32 LoopedTask_OpenConditionMenu(s32 state) { case 0: ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); HideMainOrSubMenuLeftHeader(POKENAV_GFX_MAIN_MENU, 0); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; @@ -544,11 +587,11 @@ static u32 LoopedTask_OpenConditionMenu(s32 state) return LT_PAUSE; if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); LoadLeftHeaderGfxForIndex(1); return LT_INC_AND_PAUSE; case 2: - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); ShowLeftHeaderGfx(1, FALSE, FALSE); CreateBgDotPurplePalTask(); PrintCurrentOptionDescription(); @@ -574,7 +617,7 @@ static u32 LoopedTask_ReturnToMainMenu(s32 state) { case 0: ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); HideMainOrSubMenuLeftHeader(POKENAV_GFX_CONDITION_MENU, 0); return LT_INC_AND_PAUSE; case 1: @@ -582,11 +625,11 @@ static u32 LoopedTask_ReturnToMainMenu(s32 state) return LT_PAUSE; if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); LoadLeftHeaderGfxForIndex(0); return LT_INC_AND_PAUSE; case 2: - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); ShowLeftHeaderGfx(0, FALSE, FALSE); CreateBgDotLightBluePalTask(); PrintCurrentOptionDescription(); @@ -612,17 +655,17 @@ static u32 LoopedTask_OpenConditionSearchMenu(s32 state) { case 0: ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; case 1: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; LoadLeftHeaderGfxForIndex(7); - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); return LT_INC_AND_PAUSE; case 2: - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); ShowLeftHeaderGfx(7, FALSE, FALSE); PrintCurrentOptionDescription(); return LT_INC_AND_PAUSE; @@ -645,7 +688,7 @@ static u32 LoopedTask_ReturnToConditionMenu(s32 state) { case 0: ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); HideMainOrSubMenuLeftHeader(POKENAV_GFX_SEARCH_MENU, 0); return LT_INC_AND_PAUSE; case 1: @@ -653,10 +696,10 @@ static u32 LoopedTask_ReturnToConditionMenu(s32 state) return LT_PAUSE; if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - sub_81CA0C8(); + DrawCurrentMenuOptionLabels(); return LT_INC_AND_PAUSE; case 2: - SetupCurrentMenuOptionsGfx(); + StartOptionAnimations_Enter(); PrintCurrentOptionDescription(); return LT_INC_AND_PAUSE; case 3: @@ -716,7 +759,7 @@ static u32 LoopedTask_OpenPokenavFeature(s32 state) return LT_PAUSE; SlideMenuHeaderUp(); ResetBldCnt(); - SetupPokenavMenuOptions(); + StartOptionAnimations_Exit(); switch (GetPokenavMenuType()) { case POKENAV_MENU_TYPE_CONDITION_SEARCH: @@ -757,30 +800,29 @@ static void LoadPokenavOptionPalettes(void) static void FreeAndDestroyMainMenuSprites(void) { - FreeSpriteTilesByTag(3); - FreeSpriteTilesByTag(1); - FreeSpritePaletteByTag(4); - FreeSpritePaletteByTag(5); - FreeSpritePaletteByTag(6); - FreeSpritePaletteByTag(7); - FreeSpritePaletteByTag(8); - FreeSpritePaletteByTag(3); + FreeSpriteTilesByTag(GFXTAG_OPTIONS); + FreeSpriteTilesByTag(GFXTAG_BLUE_LIGHT); + FreeSpritePaletteByTag(PALTAG_OPTIONS_DEFAULT); + FreeSpritePaletteByTag(PALTAG_OPTIONS_BLUE); + FreeSpritePaletteByTag(PALTAG_OPTIONS_PINK); + FreeSpritePaletteByTag(PALTAG_OPTIONS_BEIGE); + FreeSpritePaletteByTag(PALTAG_OPTIONS_RED); + FreeSpritePaletteByTag(PALTAG_BLUE_LIGHT); DestroyMenuOptionSprites(); - DestroyRematchBlueLightSpriteId(); + DestroyRematchBlueLightSprite(); } static void CreateMenuOptionSprites(void) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - // Each menu option is 4 subsprites - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_OPTION_SUBSPRITES; j++) { u8 spriteId = CreateSprite(&sMenuOptionSpriteTemplate, 0x8c, 20 * i + 40, 3); - unk->iconSprites[i][j] = &gSprites[spriteId]; + gfx->iconSprites[i][j] = &gSprites[spriteId]; gSprites[spriteId].x2 = 32 * j; } } @@ -789,97 +831,102 @@ static void CreateMenuOptionSprites(void) static void DestroyMenuOptionSprites(void) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_OPTION_SUBSPRITES; j++) { - FreeSpriteOamMatrix(unk->iconSprites[i][j]); - DestroySprite(unk->iconSprites[i][j]); + FreeSpriteOamMatrix(gfx->iconSprites[i][j]); + DestroySprite(gfx->iconSprites[i][j]); } } } -static void sub_81CA0C8(void) +static void DrawCurrentMenuOptionLabels(void) { s32 menuType = GetPokenavMenuType(); - DrawOptionLabelGfx(sPokenavMenuOptionLabelGfx[menuType].tiles, sPokenavMenuOptionLabelGfx[menuType].yStart, sPokenavMenuOptionLabelGfx[menuType].deltaY); + DrawOptionLabelGfx(sPokenavMenuOptionLabelGfx[menuType].gfx, sPokenavMenuOptionLabelGfx[menuType].yStart, sPokenavMenuOptionLabelGfx[menuType].deltaY); } -static void DrawOptionLabelGfx(const u16 *const *tiles, s32 yPos, s32 deltaY) +static void DrawOptionLabelGfx(const u16 *const *optionGfx, s32 yPos, s32 deltaY) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - s32 sp04 = GetSpriteTileStartByTag(3); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + s32 baseTile = GetSpriteTileStartByTag(GFXTAG_OPTIONS); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (*tiles != NULL) + if (*optionGfx != NULL) { - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_OPTION_SUBSPRITES; j++) { - unk->iconSprites[i][j]->oam.tileNum = (*tiles)[0] + sp04 + 8 * j; - unk->iconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag((*tiles)[1] + 4); - unk->iconSprites[i][j]->invisible = TRUE; - unk->iconSprites[i][j]->y = yPos; - unk->iconSprites[i][j]->x = 0x8c; - unk->iconSprites[i][j]->x2 = 32 * j; + gfx->iconSprites[i][j]->oam.tileNum = (*optionGfx)[0] + baseTile + 8 * j; + gfx->iconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag((*optionGfx)[1] + PALTAG_OPTIONS_START); + gfx->iconSprites[i][j]->invisible = TRUE; + gfx->iconSprites[i][j]->y = yPos; + gfx->iconSprites[i][j]->x = OPTION_DEFAULT_X; + gfx->iconSprites[i][j]->x2 = 32 * j; } - unk->iconVisible[i] = TRUE; + gfx->iconVisible[i] = TRUE; } else { - for (j = 0; j < 4; j++) - { - unk->iconSprites[i][j]->invisible = TRUE; - } - unk->iconVisible[i] = FALSE; + for (j = 0; j < NUM_OPTION_SUBSPRITES; j++) + gfx->iconSprites[i][j]->invisible = TRUE; + + gfx->iconVisible[i] = FALSE; } - tiles++; + optionGfx++; yPos += deltaY; } } -static void SetupCurrentMenuOptionsGfx(void) +static void StartOptionAnimations_Enter(void) { s32 i; - struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - s32 r8 = GetPokenavCursorPos(); - s32 r7 = 0; - s32 r2; + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + s32 cursorPos = GetPokenavCursorPos(); + s32 iconCount = 0; + s32 x; for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (icons->iconVisible[i]) + if (gfx->iconVisible[i]) { - if (r7++ == r8) + if (iconCount++ == cursorPos) { - r2 = 0x82; - icons->cursorPos = i; + x = OPTION_SELECTED_X; + gfx->cursorPos = i; } else - r2 = 0x8c; - SetMenuOptionGfxParamsInactive(icons->iconSprites[i], 0x100, r2, 0xC); - SetMenuOptionGfxInvisibility(icons->iconSprites[i], FALSE); + { + // Not selected, set default position + x = OPTION_DEFAULT_X; + } + + // Slide new options in + StartOptionSlide(gfx->iconSprites[i], OPTION_EXIT_X, x, 12); + SetOptionInvisibility(gfx->iconSprites[i], FALSE); } else { - SetMenuOptionGfxInvisibility(icons->iconSprites[i], TRUE); + SetOptionInvisibility(gfx->iconSprites[i], TRUE); } } } -static void SetMenuOptionGfxParams_CursorMoved(void) +static void StartOptionAnimations_CursorMoved(void) { s32 i; - struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); s32 prevPos = GetPokenavCursorPos(); s32 newPos; + // Get the index of the next visible option for (i = 0, newPos = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (icons->iconVisible[i]) + if (gfx->iconVisible[i]) { if (newPos == prevPos) { @@ -890,24 +937,28 @@ static void SetMenuOptionGfxParams_CursorMoved(void) } } - SetMenuOptionGfxParamsInactive(icons->iconSprites[icons->cursorPos], 0x82, 0x8c, 0x4); - SetMenuOptionGfxParamsInactive(icons->iconSprites[newPos], 0x8c, 0x82, 0x4); - icons->cursorPos = newPos; + // The selected option slides out a bit and the previously + // selected option slides back to its original position. + StartOptionSlide(gfx->iconSprites[gfx->cursorPos], OPTION_SELECTED_X, OPTION_DEFAULT_X, 4); + StartOptionSlide(gfx->iconSprites[newPos], OPTION_DEFAULT_X, OPTION_SELECTED_X, 4); + gfx->cursorPos = newPos; } -static void SetupPokenavMenuOptions(void) +static void StartOptionAnimations_Exit(void) { s32 i; - struct Pokenav2Struct *optionIcons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (optionIcons->iconVisible[i]) + if (gfx->iconVisible[i]) { - if (optionIcons->cursorPos != i) - SetMenuOptionGfxParamsInactive(optionIcons->iconSprites[i], 0x8C, 0x100, 0x8); + // Unselected options slide out, + // selected option zooms in + if (gfx->cursorPos != i) + StartOptionSlide(gfx->iconSprites[i], OPTION_DEFAULT_X, OPTION_EXIT_X, 8); else - SetMenuOptionGfxParamsActive(optionIcons->iconSprites[i]); + StartOptionZoom(gfx->iconSprites[i]); } } } @@ -915,120 +966,145 @@ static void SetupPokenavMenuOptions(void) static bool32 AreMenuOptionSpritesMoving(void) { s32 i; - struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (icons->iconSprites[i][0]->callback != SpriteCallbackDummy) + if (gfx->iconSprites[i][0]->callback != SpriteCallbackDummy) return TRUE; } - if (icons->otherIconsInMotion) + if (gfx->numIconsBlending != 0) return TRUE; return FALSE; } -static void SetMenuOptionGfxParamsInactive(struct Sprite ** sprites, s32 x, s32 a2, s32 a3) +#define sSlideTime data[0] +#define sSlideAccel data[1] +#define sSlideSpeed data[2] +#define sSlideEndX data[7] + +static void StartOptionSlide(struct Sprite ** sprites, s32 startX, s32 endX, s32 time) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_OPTION_SUBSPRITES; i++) { - (*sprites)->x = x; - (*sprites)->data[0] = a3; - (*sprites)->data[1] = 16 * (a2 - x) / a3; - (*sprites)->data[2] = 16 * x; - (*sprites)->data[7] = a2; - (*sprites)->callback = sub_81CA474; + (*sprites)->x = startX; + (*sprites)->sSlideTime = time; + (*sprites)->sSlideAccel = 16 * (endX - startX) / time; + (*sprites)->sSlideSpeed = 16 * startX; + (*sprites)->sSlideEndX = endX; + (*sprites)->callback = SpriteCB_OptionSlide; sprites++; } } -static void SetMenuOptionGfxParamsActive(struct Sprite ** sprites) +#define sZoomDelay data[0] +#define sZoomSetAffine data[1] +#define sZoomSpeed data[2] +#define sZoomSubspriteId data[7] + +#define tBlendDelay data[0] +#define tBlendState data[1] +#define tBlendTarget1 data[2] +#define tBlendTarget2 data[3] +#define tBlendCounter data[4] + +// When an option is selected it zooms in and blends away as part +// of the transition to the next screen. +static void StartOptionZoom(struct Sprite ** sprites) { s32 i; - struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); u8 taskId; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_OPTION_SUBSPRITES; i++) { (*sprites)->oam.objMode = ST_OAM_OBJ_BLEND; (*sprites)->oam.affineMode = ST_OAM_AFFINE_DOUBLE; - (*sprites)->callback = sub_81CA4AC; - (*sprites)->data[0] = 8; - (*sprites)->data[1] = 0; - (*sprites)->data[7] = i; + (*sprites)->callback = SpriteCB_OptionZoom; + (*sprites)->sZoomDelay = 8; + (*sprites)->sZoomSetAffine = FALSE; + (*sprites)->sZoomSubspriteId = i; InitSpriteAffineAnim(sprites[0]); StartSpriteAffineAnim(sprites[0], 0); sprites++; } - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0x00)); - taskId = CreateTask(sub_81CA580, 3); - gTasks[taskId].data[0] = 8; - unk->otherIconsInMotion++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + taskId = CreateTask(Task_OptionBlend, 3); + gTasks[taskId].tBlendDelay = 8; + gfx->numIconsBlending++; } -static void SetMenuOptionGfxInvisibility(struct Sprite ** sprites, bool32 invisible) +static void SetOptionInvisibility(struct Sprite ** sprites, bool32 invisible) { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_OPTION_SUBSPRITES; i++) { (*sprites)->invisible = invisible; sprites++; } } -static void sub_81CA474(struct Sprite * sprite) +static void SpriteCB_OptionSlide(struct Sprite * sprite) { - sprite->data[0]--; - if (sprite->data[0] != -1) + sprite->sSlideTime--; + if (sprite->sSlideTime != -1) { - sprite->data[2] += sprite->data[1]; - sprite->x = sprite->data[2] >> 4; + sprite->sSlideSpeed += sprite->sSlideAccel; + sprite->x = sprite->sSlideSpeed >> 4; } else { - sprite->x = sprite->data[7]; + sprite->x = sprite->sSlideEndX; sprite->callback = SpriteCallbackDummy; } } -static void sub_81CA4AC(struct Sprite * sprite) +#undef sSlideTime +#undef sSlideAccel +#undef sSlideSpeed +#undef sSlideEndX + +static void SpriteCB_OptionZoom(struct Sprite * sprite) { - s32 r0; - s32 r1; - if (sprite->data[0] == 0) + s32 temp; + s32 x; + if (sprite->sZoomDelay == 0) { - if (sprite->data[1] == 0) + if (!sprite->sZoomSetAffine) { StartSpriteAffineAnim(sprite, 1); - sprite->data[1]++; - sprite->data[2] = 0x100; + sprite->sZoomSetAffine++; + sprite->sZoomSpeed = 0x100; sprite->x += sprite->x2; sprite->x2 = 0; } else { - sprite->data[2] += 16; - r0 = sprite->data[2]; - r1 = r0 >> 3; - r1 = (r1 - 32) / 2; - switch (sprite->data[7]) + sprite->sZoomSpeed += 16; + temp = sprite->sZoomSpeed; + x = temp >> 3; + x = (x - 32) / 2; + + // Each subsprite needs to zoom to a different degree/direction + switch (sprite->sZoomSubspriteId) { case 0: - sprite->x2 = -r1 * 3; + sprite->x2 = -x * 3; break; case 1: - sprite->x2 = -r1; + sprite->x2 = -x; break; case 2: - sprite->x2 = r1; + sprite->x2 = x; break; case 3: - sprite->x2 = r1 * 3; + sprite->x2 = x * 3; break; } if (sprite->affineAnimEnded) @@ -1044,68 +1120,82 @@ static void sub_81CA4AC(struct Sprite * sprite) } else { - sprite->data[0]--; + sprite->sZoomDelay--; } } -static void sub_81CA580(u8 taskId) +#undef sZoomDelay +#undef sZoomSetAffine +#undef sZoomSpeed +#undef sZoomSubspriteId + +static void Task_OptionBlend(u8 taskId) { s16 * data = gTasks[taskId].data; - if (data[0] == 0) + if (tBlendDelay == 0) { - switch (data[1]) + switch (tBlendState) { case 0: - data[2] = 16; - data[3] = 0; + tBlendTarget1 = 16; + tBlendTarget2 = 0; SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_NONE | BLDCNT_TGT2_ALL); - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0x00)); - data[1]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + tBlendState++; break; case 1: - if (data[4] & 1) + if (tBlendCounter & 1) { - data[2] -= 3; - if (data[2] < 0) - data[2] = 0; + tBlendTarget1 -= 3; + if (tBlendTarget1 < 0) + tBlendTarget1 = 0; } else { - data[3] += 3; - if (data[3] > 16) - data[3] = 16; + tBlendTarget2 += 3; + if (tBlendTarget2 > 16) + tBlendTarget2 = 16; } - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(data[2], data[3])); - data[4]++; - if (data[4] == 12) + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(tBlendTarget1, tBlendTarget2)); + tBlendCounter++; + if (tBlendCounter == 12) { - ((struct Pokenav2Struct *)GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS))->otherIconsInMotion--; - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x00, 0x10)); + ((struct Pokenav_MenuGfx *)GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX))->numIconsBlending--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); DestroyTask(taskId); } break; } } else - data[0]--; + { + tBlendDelay--; + } } +#undef tBlendDelay +#undef tBlendState +#undef tBlendTarget1 +#undef tBlendTarget2 +#undef tBlendCounter + +// Blue light that blinks if there are available rematches nearby static void CreateMatchCallBlueLightSprite(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); u8 spriteId = CreateSprite(&sMatchCallBlueLightSpriteTemplate, 0x10, 0x60, 4); - ptr->blueLightSpriteId = &gSprites[spriteId]; - if (PlayerHasTrainerRematches()) - ptr->blueLightSpriteId->callback = SpriteCB_BlinkingBlueLight; + gfx->blueLightSprite = &gSprites[spriteId]; + if (AreAnyTrainerRematchesNearby()) + gfx->blueLightSprite->callback = SpriteCB_BlinkingBlueLight; else - ptr->blueLightSpriteId->invisible = TRUE; + gfx->blueLightSprite->invisible = TRUE; } -static void DestroyRematchBlueLightSpriteId(void) +static void DestroyRematchBlueLightSprite(void) { - struct Pokenav2Struct *ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - DestroySprite(ptr->blueLightSpriteId); + struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + DestroySprite(gfx->blueLightSprite); } static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite) @@ -1120,33 +1210,33 @@ static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite) static void AddOptionDescriptionWindow(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); - ptr->optionDescWindowId = AddWindow(&sOptionDescWindowTemplate); - PutWindowTilemap(ptr->optionDescWindowId); - FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - CopyWindowToVram(ptr->optionDescWindowId, COPYWIN_FULL); + gfx->optionDescWindowId = AddWindow(&sOptionDescWindowTemplate); + PutWindowTilemap(gfx->optionDescWindowId); + FillWindowPixelBuffer(gfx->optionDescWindowId, PIXEL_FILL(6)); + CopyWindowToVram(gfx->optionDescWindowId, COPYWIN_FULL); } static void PrintCurrentOptionDescription(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); int menuItem = GetCurrentMenuItemId(); - const u8 * s = sPageDescriptions[menuItem]; - u32 width = GetStringWidth(FONT_NORMAL, s, -1); - FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - AddTextPrinterParameterized3(ptr->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors, 0, s); + const u8 * desc = sPageDescriptions[menuItem]; + u32 width = GetStringWidth(FONT_NORMAL, desc, -1); + FillWindowPixelBuffer(gfx->optionDescWindowId, PIXEL_FILL(6)); + AddTextPrinterParameterized3(gfx->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors, 0, desc); } // Printed when Ribbons is selected if no PC/party mons have ribbons // Can occur by obtaining a mon with a ribbon and then releasing all ribbon winners static void PrintNoRibbonWinners(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); const u8 * s = gText_NoRibbonWinners; u32 width = GetStringWidth(FONT_NORMAL, s, -1); - FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - AddTextPrinterParameterized3(ptr->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors2, 0, s); + FillWindowPixelBuffer(gfx->optionDescWindowId, PIXEL_FILL(6)); + AddTextPrinterParameterized3(gfx->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors2, 0, s); } static bool32 IsDma3ManagerBusyWithBgCopy_(void) @@ -1156,14 +1246,14 @@ static bool32 IsDma3ManagerBusyWithBgCopy_(void) static void CreateMovingBgDotsTask(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - ptr->bg3ScrollTaskId = CreateTask(Task_MoveBgDots, 2); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + gfx->bg3ScrollTaskId = CreateTask(Task_MoveBgDots, 2); } static void DestroyMovingDotsBgTask(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - DestroyTask(ptr->bg3ScrollTaskId); + struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX); + DestroyTask(gfx->bg3ScrollTaskId); } static void Task_MoveBgDots(u8 taskId) @@ -1269,8 +1359,8 @@ static void SetMenuOptionGlow(void) int menuType = GetPokenavMenuType(); int cursorPos = GetPokenavCursorPos(); int r4 = sPokenavMenuOptionLabelGfx[menuType].deltaY * cursorPos + sPokenavMenuOptionLabelGfx[menuType].yStart - 8; - CpuFill16(0, gScanlineEffectRegBuffers[0], 0x140); - CpuFill16(0, gScanlineEffectRegBuffers[1], 0x140); + CpuFill16(0, gScanlineEffectRegBuffers[0], DISPLAY_HEIGHT * 2); + CpuFill16(0, gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); CpuFill16(RGB(16, 23, 28), &gScanlineEffectRegBuffers[0][r4], 0x20); CpuFill16(RGB(16, 23, 28), &gScanlineEffectRegBuffers[1][r4], 0x20); } diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index 89bd2f7c7..4ea3b3b19 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -74,7 +74,7 @@ static u32 LoopedTask_ExitRegionMap(s32); extern const u16 gRegionMapCityZoomTiles_Pal[]; extern const u32 gRegionMapCityZoomText_Gfx[]; -static const u16 sMapSecInfoWindow_Pal[] = INCBIN_U16("graphics/pokenav/region_map_info_window.gbapal"); +static const u16 sMapSecInfoWindow_Pal[] = INCBIN_U16("graphics/pokenav/region_map/info_window.gbapal"); static const u32 sRegionMapCityZoomTiles_Gfx[] = INCBIN_U32("graphics/pokenav/zoom_tiles.4bpp.lz"); #include "data/region_map/city_map_tilemaps.h" @@ -346,7 +346,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) return LT_PAUSE; UpdateMapSecInfoWindow(state); - sub_81C7B40(); + FadeToBlackExceptPrimary(); return LT_INC_AND_PAUSE; case 5: if (IsDma3ManagerBusyWithBgCopy_(state)) diff --git a/src/region_map.c b/src/region_map.c index 021ef7c71..759a26e84 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -116,19 +116,18 @@ static void CB_FadeInFlyMap(void); static void CB_HandleFlyMapInput(void); static void CB_ExitFlyMap(void); -// .rodata - -static const u16 sRegionMapCursorPal[] = INCBIN_U16("graphics/pokenav/cursor.gbapal"); -static const u32 sRegionMapCursorSmallGfxLZ[] = INCBIN_U32("graphics/pokenav/cursor_small.4bpp.lz"); -static const u32 sRegionMapCursorLargeGfxLZ[] = INCBIN_U32("graphics/pokenav/cursor_large.4bpp.lz"); +// NOTE: Some of the below graphics are not in graphics/pokenav/region_map +// because porymap expects them to be in their current location. +static const u16 sRegionMapCursorPal[] = INCBIN_U16("graphics/pokenav/region_map/cursor.gbapal"); +static const u32 sRegionMapCursorSmallGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/cursor_small.4bpp.lz"); +static const u32 sRegionMapCursorLargeGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/cursor_large.4bpp.lz"); static const u16 sRegionMapBg_Pal[] = INCBIN_U16("graphics/pokenav/region_map.gbapal"); static const u32 sRegionMapBg_GfxLZ[] = INCBIN_U32("graphics/pokenav/region_map.8bpp.lz"); static const u32 sRegionMapBg_TilemapLZ[] = INCBIN_U32("graphics/pokenav/region_map_map.bin.lz"); -static const u16 sRegionMapPlayerIcon_BrendanPal[] = INCBIN_U16("graphics/pokenav/brendan_icon.gbapal"); -static const u8 sRegionMapPlayerIcon_BrendanGfx[] = INCBIN_U8("graphics/pokenav/brendan_icon.4bpp"); -static const u16 sRegionMapPlayerIcon_MayPal[] = INCBIN_U16("graphics/pokenav/may_icon.gbapal"); -static const u8 sRegionMapPlayerIcon_MayGfx[] = INCBIN_U8("graphics/pokenav/may_icon.4bpp"); - +static const u16 sRegionMapPlayerIcon_BrendanPal[] = INCBIN_U16("graphics/pokenav/region_map/brendan_icon.gbapal"); +static const u8 sRegionMapPlayerIcon_BrendanGfx[] = INCBIN_U8("graphics/pokenav/region_map/brendan_icon.4bpp"); +static const u16 sRegionMapPlayerIcon_MayPal[] = INCBIN_U16("graphics/pokenav/region_map/may_icon.gbapal"); +static const u8 sRegionMapPlayerIcon_MayGfx[] = INCBIN_U8("graphics/pokenav/region_map/may_icon.4bpp"); static const u8 sRegionMap_MapSectionLayout[] = INCBIN_U8("graphics/pokenav/region_map_section_layout.bin"); #include "data/region_map/region_map_entries.h" @@ -283,15 +282,11 @@ static const u8 sMapSecIdsOffMap[] = MAPSEC_NAVEL_ROCK }; -static const u16 sRegionMapFramePal[] = INCBIN_U16("graphics/pokenav/map_frame.gbapal"); - -static const u32 sRegionMapFrameGfxLZ[] = INCBIN_U32("graphics/pokenav/map_frame.4bpp.lz"); - -static const u32 sRegionMapFrameTilemapLZ[] = INCBIN_U32("graphics/pokenav/map_frame.bin.lz"); - -static const u16 sFlyTargetIcons_Pal[] = INCBIN_U16("graphics/pokenav/fly_target_icons.gbapal"); - -static const u32 sFlyTargetIcons_Gfx[] = INCBIN_U32("graphics/pokenav/fly_target_icons.4bpp.lz"); +static const u16 sRegionMapFramePal[] = INCBIN_U16("graphics/pokenav/region_map/frame.gbapal"); +static const u32 sRegionMapFrameGfxLZ[] = INCBIN_U32("graphics/pokenav/region_map/frame.4bpp.lz"); +static const u32 sRegionMapFrameTilemapLZ[] = INCBIN_U32("graphics/pokenav/region_map/frame.bin.lz"); +static const u16 sFlyTargetIcons_Pal[] = INCBIN_U16("graphics/pokenav/region_map/fly_target_icons.gbapal"); +static const u32 sFlyTargetIcons_Gfx[] = INCBIN_U32("graphics/pokenav/region_map/fly_target_icons.4bpp.lz"); static const u8 sMapHealLocations[][3] = {