pokeemerald/src/pokenav_menu_handler_gfx.c

1372 lines
41 KiB
C
Raw Normal View History

2019-05-02 20:27:59 +02:00
#include "global.h"
#include "malloc.h"
2019-05-02 23:50:42 +02:00
#include "decompress.h"
2019-05-02 20:27:59 +02:00
#include "bg.h"
2019-08-05 02:39:36 +02:00
#include "palette.h"
#include "trig.h"
2019-08-05 00:15:02 +02:00
#include "gpu_regs.h"
2019-05-02 22:19:25 +02:00
#include "menu.h"
2019-05-02 20:27:59 +02:00
#include "window.h"
#include "pokenav.h"
2019-05-02 22:19:25 +02:00
#include "graphics.h"
#include "sound.h"
#include "gym_leader_rematch.h"
2019-07-19 23:23:52 +02:00
#include "window.h"
#include "strings.h"
#include "scanline_effect.h"
2019-05-02 22:19:25 +02:00
#include "constants/songs.h"
#include "constants/rgb.h"
2019-05-02 20:27:59 +02:00
#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
2019-05-02 20:27:59 +02:00
{
2020-02-05 08:47:32 +01:00
bool32 (*isTaskActiveCB)(void);
2019-05-02 20:27:59 +02:00
u32 loopedTaskId;
2020-02-01 06:25:50 +01:00
u16 optionDescWindowId;
2019-08-05 15:17:21 +02:00
u8 bg3ScrollTaskId;
u8 cursorPos;
u8 numIconsBlending;
2020-02-05 08:47:32 +01:00
bool8 pokenavAlreadyOpen;
2020-02-01 06:25:50 +01:00
bool32 iconVisible[MAX_POKENAV_MENUITEMS];
struct Sprite * blueLightSprite;
struct Sprite * iconSprites[MAX_POKENAV_MENUITEMS][NUM_OPTION_SUBSPRITES];
u8 bg1TilemapBuffer[BG_SCREEN_SIZE];
2019-05-02 20:27:59 +02:00
};
static struct Pokenav_MenuGfx * OpenPokenavMenu(void);
2020-02-05 08:47:32 +01:00
static bool32 GetCurrentLoopedTaskActive(void);
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);
2020-10-11 00:17:34 +02:00
static void LoadPokenavOptionPalettes(void);
static void FreeAndDestroyMainMenuSprites(void);
2020-02-01 06:25:50 +01:00
static void CreateMenuOptionSprites(void);
2020-10-11 00:17:34 +02:00
static void DestroyMenuOptionSprites(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 **);
2020-02-01 06:25:50 +01:00
static bool32 AreMenuOptionSpritesMoving(void);
static void SetOptionInvisibility(struct Sprite **, bool32);
static void SpriteCB_OptionSlide(struct Sprite *);
static void SpriteCB_OptionZoom(struct Sprite *);
static void Task_OptionBlend(u8);
2020-10-11 00:17:34 +02:00
static void CreateMatchCallBlueLightSprite(void);
static void SpriteCB_BlinkingBlueLight(struct Sprite *);
static void DestroyRematchBlueLightSprite(void);
2020-02-01 06:25:50 +01:00
static void AddOptionDescriptionWindow(void);
static void PrintCurrentOptionDescription(void);
static void PrintNoRibbonWinners(void);
2020-10-11 00:17:34 +02:00
static bool32 IsDma3ManagerBusyWithBgCopy_(void);
static void CreateMovingBgDotsTask(void);
static void DestroyMovingDotsBgTask(void);
static void Task_MoveBgDots(u8);
2020-10-11 00:17:34 +02:00
static void CreateBgDotPurplePalTask(void);
static void ChangeBgDotsColorToPurple(void);
static void CreateBgDotLightBluePalTask(void);
static bool32 IsTaskActive_UpdateBgDotsPalette(void);
static void Task_UpdateBgDotsPalette(u8);
2020-10-11 00:17:34 +02:00
static void SetupPokenavMenuScanlineEffects(void);
static void DestroyMenuOptionGlowTask(void);
static void ResetBldCnt(void);
static void InitMenuOptionGlow(void);
static void Task_CurrentMenuOptionGlow(u8);
2020-10-11 00:17:34 +02:00
static void SetMenuOptionGlow(void);
static const u16 sPokenavBgDotsPal[] = INCBIN_U16("graphics/pokenav/bg_dots.gbapal");
static const u32 sPokenavBgDotsTiles[] = INCBIN_U32("graphics/pokenav/bg_dots.4bpp.lz");
2020-10-11 17:11:12 +02:00
static const u32 sPokenavBgDotsTilemap[] = INCBIN_U32("graphics/pokenav/bg_dots.bin.lz");
static const u16 sPokenavDeviceBgPal[] = INCBIN_U16("graphics/pokenav/device_outline.gbapal");
static const u32 sPokenavDeviceBgTiles[] = INCBIN_U32("graphics/pokenav/device_outline.4bpp.lz");
static const u32 sPokenavDeviceBgTilemap[] = INCBIN_U32("graphics/pokenav/device_outline_map.bin.lz");
static const u16 sMatchCallBlueLightPal[] = INCBIN_U16("graphics/pokenav/blue_light.gbapal");
static const u32 sMatchCallBlueLightTiles[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz");
2020-10-11 00:17:34 +02:00
static const struct BgTemplate sPokenavMainMenuBgTemplates[] = {
2019-05-02 20:27:59 +02:00
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 15,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0x000
}, {
.bg = 2,
.charBaseIndex = 2,
.mapBaseIndex = 23,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0x000
}, {
.bg = 3,
.charBaseIndex = 3,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0x000
}
};
static const LoopedTask sMenuHandlerLoopTaskFuncs[] =
{
2020-02-01 06:25:50 +01:00
[POKENAV_MENU_FUNC_NONE] = NULL,
[POKENAV_MENU_FUNC_MOVE_CURSOR] = LoopedTask_MoveMenuCursor,
[POKENAV_MENU_FUNC_OPEN_CONDITION] = LoopedTask_OpenConditionMenu,
[POKENAV_MENU_FUNC_RETURN_TO_MAIN] = LoopedTask_ReturnToMainMenu,
[POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH] = LoopedTask_OpenConditionSearchMenu,
[POKENAV_MENU_FUNC_RETURN_TO_CONDITION] = LoopedTask_ReturnToConditionMenu,
[POKENAV_MENU_FUNC_NO_RIBBON_WINNERS] = LoopedTask_SelectRibbonsNoWinners,
[POKENAV_MENU_FUNC_RESHOW_DESCRIPTION] = LoopedTask_ReShowDescription,
[POKENAV_MENU_FUNC_OPEN_FEATURE] = LoopedTask_OpenPokenavFeature
2019-05-02 20:27:59 +02:00
};
2020-10-11 00:17:34 +02:00
static const struct CompressedSpriteSheet sPokenavOptionsSpriteSheets[] =
2019-07-19 23:23:52 +02:00
{
{
.data = gPokenavOptions_Gfx,
.size = 0x3400,
.tag = GFXTAG_OPTIONS
2019-07-19 23:23:52 +02:00
},
{
.data = sMatchCallBlueLightTiles,
2019-07-19 23:23:52 +02:00
.size = 0x0100,
.tag = GFXTAG_BLUE_LIGHT
2019-07-19 23:23:52 +02:00
}
2019-05-02 23:50:42 +02:00
};
2020-10-11 00:17:34 +02:00
static const struct SpritePalette sPokenavOptionsSpritePalettes[] =
{
{&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},
2019-07-19 23:23:52 +02:00
{}
2019-05-02 23:50:42 +02:00
};
// 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
2020-10-11 00:17:34 +02:00
{
u16 yStart;
u16 deltaY;
const u16 *gfx[MAX_POKENAV_MENUITEMS];
} static const sPokenavMenuOptionLabelGfx[POKENAV_MENU_TYPE_COUNT] =
2019-07-19 23:23:52 +02:00
{
[POKENAV_MENU_TYPE_DEFAULT] =
2019-07-19 23:23:52 +02:00
{
2020-10-11 00:17:34 +02:00
.yStart = 42,
.deltaY = 20,
.gfx = {
sOptionsLabelGfx_RegionMap,
sOptionsLabelGfx_Condition,
sOptionsLabelGfx_SwitchOff
}
2019-07-19 23:23:52 +02:00
},
[POKENAV_MENU_TYPE_UNLOCK_MC] =
2019-07-19 23:23:52 +02:00
{
2020-10-11 00:17:34 +02:00
.yStart = 42,
.deltaY = 20,
.gfx = {
sOptionsLabelGfx_RegionMap,
sOptionsLabelGfx_Condition,
sOptionsLabelGfx_MatchCall,
sOptionsLabelGfx_SwitchOff
}
2019-07-19 23:23:52 +02:00
},
[POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] =
2019-07-19 23:23:52 +02:00
{
2020-10-11 00:17:34 +02:00
.yStart = 42,
.deltaY = 20,
.gfx = {
sOptionsLabelGfx_RegionMap,
sOptionsLabelGfx_Condition,
sOptionsLabelGfx_MatchCall,
sOptionsLabelGfx_Ribbons,
sOptionsLabelGfx_SwitchOff
}
2019-07-19 23:23:52 +02:00
},
[POKENAV_MENU_TYPE_CONDITION] =
2019-07-19 23:23:52 +02:00
{
2020-10-11 00:17:34 +02:00
.yStart = 56,
.deltaY = 20,
.gfx = {
sOptionsLabelGfx_Party,
sOptionsLabelGfx_Search,
sOptionsLabelGfx_Cancel
}
2019-07-19 23:23:52 +02:00
},
[POKENAV_MENU_TYPE_CONDITION_SEARCH] =
2019-07-19 23:23:52 +02:00
{
2020-10-11 00:17:34 +02:00
.yStart = 40,
.deltaY = 16,
.gfx = {
sOptionsLabelGfx_Cool,
sOptionsLabelGfx_Beauty,
sOptionsLabelGfx_Cute,
sOptionsLabelGfx_Smart,
sOptionsLabelGfx_Tough,
sOptionsLabelGfx_Cancel
}
2019-07-19 23:23:52 +02:00
},
};
2020-02-01 06:25:50 +01:00
static const struct WindowTemplate sOptionDescWindowTemplate =
2019-07-19 23:23:52 +02:00
{
.bg = 1,
.tilemapLeft = 3,
.tilemapTop = 17,
.width = 24,
.height = 2,
2019-07-19 23:23:52 +02:00
.paletteNum = 1,
.baseBlock = 8
};
2020-02-01 06:25:50 +01:00
static const u8 *const sPageDescriptions[] =
{
[POKENAV_MENUITEM_MAP] = gText_CheckMapOfHoenn,
[POKENAV_MENUITEM_CONDITION] = gText_CheckPokemonInDetail,
[POKENAV_MENUITEM_MATCH_CALL] = gText_CallRegisteredTrainer,
[POKENAV_MENUITEM_RIBBONS] = gText_CheckObtainedRibbons,
[POKENAV_MENUITEM_SWITCH_OFF] = gText_PutAwayPokenav,
[POKENAV_MENUITEM_CONDITION_PARTY] = gText_CheckPartyPokemonInDetail,
[POKENAV_MENUITEM_CONDITION_SEARCH] = gText_CheckAllPokemonInDetail,
[POKENAV_MENUITEM_CONDITION_CANCEL] = gText_ReturnToPokenavMenu,
[POKENAV_MENUITEM_CONDITION_SEARCH_COOL] = gText_FindCoolPokemon,
[POKENAV_MENUITEM_CONDITION_SEARCH_BEAUTY] = gText_FindBeautifulPokemon,
[POKENAV_MENUITEM_CONDITION_SEARCH_CUTE] = gText_FindCutePokemon,
[POKENAV_MENUITEM_CONDITION_SEARCH_SMART] = gText_FindSmartPokemon,
[POKENAV_MENUITEM_CONDITION_SEARCH_TOUGH] = gText_FindToughPokemon,
[POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL] = gText_ReturnToConditionMenu
2019-07-19 23:23:52 +02:00
};
2020-02-01 06:25:50 +01:00
static const u8 sOptionDescTextColors[] = {TEXT_COLOR_GREEN, TEXT_COLOR_BLUE, TEXT_COLOR_LIGHT_GREEN};
2019-12-10 19:48:20 +01:00
static const u8 sOptionDescTextColors2[] = {TEXT_COLOR_GREEN, TEXT_COLOR_BLUE, TEXT_COLOR_LIGHT_GREEN};
2019-07-19 23:23:52 +02:00
2020-02-01 06:25:50 +01:00
static const struct OamData sOamData_MenuOption =
2019-07-19 23:23:52 +02:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.bpp = ST_OAM_4BPP,
2019-07-19 23:23:52 +02:00
.shape = SPRITE_SHAPE(32x16),
.x = 0,
.size = SPRITE_SIZE(32x16),
.tileNum = 0,
.priority = 2,
.paletteNum = 0,
};
static const union AffineAnimCmd sAffineAnim_MenuOption_Normal[] =
2019-07-19 23:23:52 +02:00
{
AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd sAffineAnim_MenuOption_Zoom[] =
2019-07-19 23:23:52 +02:00
{
AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0),
AFFINEANIMCMD_FRAME(0x10, 0x10, 0, 0x12),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd *const sAffineAnims_MenuOption[] =
2019-07-19 23:23:52 +02:00
{
sAffineAnim_MenuOption_Normal,
sAffineAnim_MenuOption_Zoom
2019-07-19 23:23:52 +02:00
};
2020-02-01 06:25:50 +01:00
static const struct SpriteTemplate sMenuOptionSpriteTemplate =
2019-07-19 23:23:52 +02:00
{
.tileTag = GFXTAG_OPTIONS,
.paletteTag = PALTAG_OPTIONS_START,
2020-02-01 06:25:50 +01:00
.oam = &sOamData_MenuOption,
2019-07-19 23:23:52 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = sAffineAnims_MenuOption,
2019-07-19 23:23:52 +02:00
.callback = SpriteCallbackDummy,
};
2020-10-11 00:17:34 +02:00
static const struct OamData sBlueLightOamData =
2019-07-19 23:23:52 +02:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
.bpp = ST_OAM_4BPP,
2019-07-19 23:23:52 +02:00
.shape = SPRITE_SHAPE(32x16),
.x = 0,
.size = SPRITE_SIZE(32x16),
.tileNum = 0,
.priority = 2,
.paletteNum = 0,
};
2020-10-11 00:17:34 +02:00
static const struct SpriteTemplate sMatchCallBlueLightSpriteTemplate =
2019-07-19 23:23:52 +02:00
{
.tileTag = GFXTAG_BLUE_LIGHT,
.paletteTag = PALTAG_BLUE_LIGHT,
2020-10-11 00:17:34 +02:00
.oam = &sBlueLightOamData,
2019-07-19 23:23:52 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy,
};
2020-10-11 00:17:34 +02:00
static const struct ScanlineEffectParams sPokenavMainMenuScanlineEffectParams =
2019-07-19 23:23:52 +02:00
{
2021-11-10 02:02:12 +01:00
&REG_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
1,
0
2019-07-19 23:23:52 +02:00
};
2019-05-02 23:50:42 +02:00
static bool32 AreAnyTrainerRematchesNearby(void)
2019-05-02 20:27:59 +02:00
{
s32 i;
2019-05-26 12:42:01 +02:00
for (i = 0; i < REMATCH_TABLE_ENTRIES; i++)
2019-05-02 20:27:59 +02:00
{
2020-10-11 00:17:34 +02:00
if (GetMatchTableMapSectionId(i) == gMapHeader.regionMapSectionId
2019-12-05 21:33:36 +01:00
&& IsRematchEntryRegistered(i)
&& gSaveBlock1Ptr->trainerRematches[i])
2019-05-02 20:27:59 +02:00
return TRUE;
}
return FALSE;
}
2020-02-05 08:47:32 +01:00
bool32 OpenPokenavMenuInitial(void)
2019-05-02 20:27:59 +02:00
{
struct Pokenav_MenuGfx * gfx = OpenPokenavMenu();
2019-05-02 20:27:59 +02:00
if (gfx == NULL)
2019-05-02 20:27:59 +02:00
return FALSE;
gfx->pokenavAlreadyOpen = FALSE;
2019-05-02 20:27:59 +02:00
return TRUE;
}
2020-02-05 08:47:32 +01:00
bool32 OpenPokenavMenuNotInitial(void)
2019-05-02 20:27:59 +02:00
{
struct Pokenav_MenuGfx * gfx = OpenPokenavMenu();
2019-05-02 20:27:59 +02:00
if (gfx == NULL)
2019-05-02 20:27:59 +02:00
return FALSE;
gfx->pokenavAlreadyOpen = TRUE;
2019-05-02 20:27:59 +02:00
return TRUE;
}
static struct Pokenav_MenuGfx * OpenPokenavMenu(void)
2019-05-02 20:27:59 +02:00
{
struct Pokenav_MenuGfx * gfx = AllocSubstruct(POKENAV_SUBSTRUCT_MENU_GFX, sizeof(struct Pokenav_MenuGfx));
2019-05-02 20:27:59 +02:00
if (gfx != NULL)
2019-05-02 20:27:59 +02:00
{
gfx->numIconsBlending = 0;
gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenMenu, 1);
gfx->isTaskActiveCB = GetCurrentLoopedTaskActive;
2019-05-02 20:27:59 +02:00
}
return gfx;
2019-05-02 20:27:59 +02:00
}
2020-02-01 06:25:50 +01:00
void CreateMenuHandlerLoopedTask(s32 ltIdx)
2019-05-02 20:27:59 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
gfx->loopedTaskId = CreateLoopedTask(sMenuHandlerLoopTaskFuncs[ltIdx], 1);
gfx->isTaskActiveCB = GetCurrentLoopedTaskActive;
2019-05-02 20:27:59 +02:00
}
2020-02-05 08:47:32 +01:00
bool32 IsMenuHandlerLoopedTaskActive(void)
2019-05-02 20:27:59 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
return gfx->isTaskActiveCB();
2019-05-02 20:27:59 +02:00
}
2020-02-05 08:47:32 +01:00
void FreeMenuHandlerSubstruct2(void)
2019-05-02 20:27:59 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-05-02 20:27:59 +02:00
2020-10-11 00:17:34 +02:00
DestroyMovingDotsBgTask();
RemoveWindow(gfx->optionDescWindowId);
2020-10-11 00:17:34 +02:00
FreeAndDestroyMainMenuSprites();
DestroyMenuOptionGlowTask();
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MENU_GFX);
2019-05-02 20:27:59 +02:00
}
2020-02-05 08:47:32 +01:00
static bool32 GetCurrentLoopedTaskActive(void)
2019-05-02 20:27:59 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-05-02 20:27:59 +02:00
return IsLoopedTaskActive(gfx->loopedTaskId);
2019-05-02 20:27:59 +02:00
}
2019-05-02 22:19:25 +02:00
2020-02-05 08:47:32 +01:00
static u32 LoopedTask_OpenMenu(s32 state)
2019-05-02 22:19:25 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-05-02 22:19:25 +02:00
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
InitBgTemplates(sPokenavMainMenuBgTemplates, ARRAY_COUNT(sPokenavMainMenuBgTemplates));
2020-05-14 10:37:09 +02:00
DecompressAndCopyTileDataToVram(1, gPokenavMessageBox_Gfx, 0, 0, 0);
SetBgTilemapBuffer(1, gfx->bg1TilemapBuffer);
2019-05-02 22:19:25 +02:00
CopyToBgTilemapBuffer(1, gPokenavMessageBox_Tilemap, 0, 0);
CopyBgTilemapBufferToVram(1);
CopyPaletteIntoBufferUnfaded(gPokenavMessageBox_Pal, 0x10, 0x20);
2021-11-04 04:02:06 +01:00
ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET);
ChangeBgX(2, 0, BG_COORD_SET);
ChangeBgY(2, 0, BG_COORD_SET);
ChangeBgX(3, 0, BG_COORD_SET);
ChangeBgY(3, 0, BG_COORD_SET);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:19:25 +02:00
case 1:
2020-05-14 10:37:09 +02:00
if (FreeTempTileDataBuffersIfPossible())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
DecompressAndCopyTileDataToVram(2, sPokenavDeviceBgTiles, 0, 0, 0);
DecompressAndCopyTileDataToVram(2, sPokenavDeviceBgTilemap, 0, 0, 1);
CopyPaletteIntoBufferUnfaded(sPokenavDeviceBgPal, 0x20, 0x20);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:19:25 +02:00
case 2:
2020-05-14 10:37:09 +02:00
if (FreeTempTileDataBuffersIfPossible())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
DecompressAndCopyTileDataToVram(3, sPokenavBgDotsTiles, 0, 0, 0);
DecompressAndCopyTileDataToVram(3, sPokenavBgDotsTilemap, 0, 0, 1);
CopyPaletteIntoBufferUnfaded(sPokenavBgDotsPal, 0x30, 0x20);
2020-02-01 06:25:50 +01:00
if (GetPokenavMenuType() == POKENAV_MENU_TYPE_CONDITION || GetPokenavMenuType() == POKENAV_MENU_TYPE_CONDITION_SEARCH)
2020-10-11 00:17:34 +02:00
ChangeBgDotsColorToPurple();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:19:25 +02:00
case 3:
2020-05-14 10:37:09 +02:00
if (FreeTempTileDataBuffersIfPossible())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-02-01 06:25:50 +01:00
AddOptionDescriptionWindow();
2020-10-11 00:17:34 +02:00
CreateMovingBgDotsTask();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_CONTINUE;
2019-05-02 22:19:25 +02:00
case 4:
2020-10-11 00:17:34 +02:00
LoadPokenavOptionPalettes();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_CONTINUE;
2019-05-02 22:19:25 +02:00
case 5:
2020-02-01 06:25:50 +01:00
PrintCurrentOptionDescription();
CreateMenuOptionSprites();
2020-10-11 00:17:34 +02:00
CreateMatchCallBlueLightSprite();
DrawCurrentMenuOptionLabels();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:19:25 +02:00
case 6:
2020-10-11 00:17:34 +02:00
if (IsDma3ManagerBusyWithBgCopy_())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
return LT_INC_AND_CONTINUE;
2019-05-02 22:19:25 +02:00
case 7:
ShowBg(1);
ShowBg(2);
ShowBg(3);
if (gfx->pokenavAlreadyOpen)
2021-11-12 23:28:06 +01:00
PokenavFadeScreen(POKENAV_FADE_FROM_BLACK);
2019-05-02 22:19:25 +02:00
else
{
2020-08-21 00:02:00 +02:00
PlaySE(SE_POKENAV_ON);
2021-11-12 23:28:06 +01:00
PokenavFadeScreen(POKENAV_FADE_FROM_BLACK_ALL);
2019-05-02 22:19:25 +02:00
}
2020-02-01 06:25:50 +01:00
switch (GetPokenavMenuType())
2019-05-02 22:19:25 +02:00
{
2020-02-01 06:25:50 +01:00
case POKENAV_MENU_TYPE_CONDITION_SEARCH:
2019-05-02 22:19:25 +02:00
LoadLeftHeaderGfxForIndex(7);
// fallthrough
2020-02-01 06:25:50 +01:00
case POKENAV_MENU_TYPE_CONDITION:
2019-05-02 22:19:25 +02:00
LoadLeftHeaderGfxForIndex(1);
break;
default:
LoadLeftHeaderGfxForIndex(0);
break;
}
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:19:25 +02:00
case 8:
if (IsPaletteFadeActive())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-02-01 06:25:50 +01:00
switch (GetPokenavMenuType())
2019-05-02 22:19:25 +02:00
{
2020-02-01 06:25:50 +01:00
case POKENAV_MENU_TYPE_CONDITION_SEARCH:
2020-10-11 00:17:34 +02:00
ShowLeftHeaderGfx(7, FALSE, FALSE);
2019-05-02 22:19:25 +02:00
// fallthrough
2020-02-01 06:25:50 +01:00
case POKENAV_MENU_TYPE_CONDITION:
2020-10-11 00:17:34 +02:00
ShowLeftHeaderGfx(1, FALSE, FALSE);
2019-05-02 22:19:25 +02:00
break;
default:
2020-10-11 00:17:34 +02:00
ShowLeftHeaderGfx(0, FALSE, FALSE);
2019-05-02 22:19:25 +02:00
break;
}
StartOptionAnimations_Enter();
2020-10-11 00:17:34 +02:00
SetupPokenavMenuScanlineEffects();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_CONTINUE;
2019-05-02 22:19:25 +02:00
case 9:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (AreLeftHeaderSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2019-05-02 22:19:25 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:19:25 +02:00
}
2019-05-02 22:43:32 +02:00
2020-02-01 06:25:50 +01:00
static u32 LoopedTask_MoveMenuCursor(s32 state)
2019-05-02 22:43:32 +02:00
{
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
SetMenuOptionGlow();
StartOptionAnimations_CursorMoved();
2020-02-01 06:25:50 +01:00
PrintCurrentOptionDescription();
2019-05-02 22:43:32 +02:00
PlaySE(SE_SELECT);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 1:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (IsDma3ManagerBusyWithBgCopy_())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2019-05-02 22:43:32 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:43:32 +02:00
}
2020-02-01 06:25:50 +01:00
static u32 LoopedTask_OpenConditionMenu(s32 state)
2019-05-02 22:43:32 +02:00
{
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
ResetBldCnt();
StartOptionAnimations_Exit();
2020-10-11 00:17:34 +02:00
HideMainOrSubMenuLeftHeader(POKENAV_GFX_MAIN_MENU, 0);
2019-05-02 22:43:32 +02:00
PlaySE(SE_SELECT);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 1:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (AreLeftHeaderSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
DrawCurrentMenuOptionLabels();
2019-05-02 22:43:32 +02:00
LoadLeftHeaderGfxForIndex(1);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 2:
StartOptionAnimations_Enter();
2020-10-11 00:17:34 +02:00
ShowLeftHeaderGfx(1, FALSE, FALSE);
CreateBgDotPurplePalTask();
2020-02-01 06:25:50 +01:00
PrintCurrentOptionDescription();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 3:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (AreLeftHeaderSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (IsTaskActive_UpdateBgDotsPalette())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (IsDma3ManagerBusyWithBgCopy_())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
InitMenuOptionGlow();
2019-05-02 22:43:32 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:43:32 +02:00
}
2020-02-01 06:25:50 +01:00
static u32 LoopedTask_ReturnToMainMenu(s32 state)
2019-05-02 22:43:32 +02:00
{
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
ResetBldCnt();
StartOptionAnimations_Exit();
2020-10-11 00:17:34 +02:00
HideMainOrSubMenuLeftHeader(POKENAV_GFX_CONDITION_MENU, 0);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 1:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (AreLeftHeaderSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
DrawCurrentMenuOptionLabels();
2019-05-02 22:43:32 +02:00
LoadLeftHeaderGfxForIndex(0);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 2:
StartOptionAnimations_Enter();
2020-10-11 00:17:34 +02:00
ShowLeftHeaderGfx(0, FALSE, FALSE);
CreateBgDotLightBluePalTask();
2020-02-01 06:25:50 +01:00
PrintCurrentOptionDescription();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 3:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (AreLeftHeaderSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (IsTaskActive_UpdateBgDotsPalette())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (IsDma3ManagerBusyWithBgCopy_())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
InitMenuOptionGlow();
2019-05-02 22:43:32 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:43:32 +02:00
}
2020-02-01 06:25:50 +01:00
static u32 LoopedTask_OpenConditionSearchMenu(s32 state)
2019-05-02 22:43:32 +02:00
{
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
ResetBldCnt();
StartOptionAnimations_Exit();
2019-05-02 22:43:32 +02:00
PlaySE(SE_SELECT);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 1:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2019-05-02 22:43:32 +02:00
LoadLeftHeaderGfxForIndex(7);
DrawCurrentMenuOptionLabels();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 2:
StartOptionAnimations_Enter();
2020-10-11 00:17:34 +02:00
ShowLeftHeaderGfx(7, FALSE, FALSE);
2020-02-01 06:25:50 +01:00
PrintCurrentOptionDescription();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 3:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (AreLeftHeaderSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (IsTaskActive_UpdateBgDotsPalette())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
InitMenuOptionGlow();
2019-05-02 22:43:32 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:43:32 +02:00
}
2020-02-01 06:25:50 +01:00
static u32 LoopedTask_ReturnToConditionMenu(s32 state)
2019-05-02 22:43:32 +02:00
{
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
ResetBldCnt();
StartOptionAnimations_Exit();
2020-10-11 00:17:34 +02:00
HideMainOrSubMenuLeftHeader(POKENAV_GFX_SEARCH_MENU, 0);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 1:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (AreLeftHeaderSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
DrawCurrentMenuOptionLabels();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 2:
StartOptionAnimations_Enter();
2020-02-01 06:25:50 +01:00
PrintCurrentOptionDescription();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 3:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (IsTaskActive_UpdateBgDotsPalette())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
InitMenuOptionGlow();
2019-05-02 22:43:32 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:43:32 +02:00
}
2020-02-01 06:25:50 +01:00
static u32 LoopedTask_SelectRibbonsNoWinners(s32 state)
2019-05-02 22:43:32 +02:00
{
switch (state)
{
case 0:
2020-08-21 00:02:00 +02:00
PlaySE(SE_FAILURE);
2020-02-01 06:25:50 +01:00
PrintNoRibbonWinners();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 1:
if (IsDma3ManagerBusyWithBgCopy())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2019-05-02 22:43:32 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:43:32 +02:00
}
2020-02-01 06:25:50 +01:00
// For redisplaying the Ribbons description to replace the No Ribbon Winners message
static u32 LoopedTask_ReShowDescription(s32 state)
2019-05-02 22:43:32 +02:00
{
switch (state)
{
case 0:
PlaySE(SE_SELECT);
2020-02-01 06:25:50 +01:00
PrintCurrentOptionDescription();
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 1:
if (IsDma3ManagerBusyWithBgCopy())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2019-05-02 22:43:32 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:43:32 +02:00
}
2020-02-01 06:25:50 +01:00
// For selecting a feature option from a menu, e.g. the Map, Match Call, Beauty search, etc.
static u32 LoopedTask_OpenPokenavFeature(s32 state)
2019-05-02 22:43:32 +02:00
{
switch (state)
{
case 0:
2019-12-07 10:08:21 +01:00
PrintHelpBarText(GetHelpBarTextId());
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 1:
2019-12-07 10:08:21 +01:00
if (WaitForHelpBar())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
SlideMenuHeaderUp();
ResetBldCnt();
StartOptionAnimations_Exit();
2020-02-01 06:25:50 +01:00
switch (GetPokenavMenuType())
2019-05-02 22:43:32 +02:00
{
2020-02-01 06:25:50 +01:00
case POKENAV_MENU_TYPE_CONDITION_SEARCH:
2020-10-11 00:17:34 +02:00
HideMainOrSubMenuLeftHeader(POKENAV_GFX_SEARCH_MENU, FALSE);
2019-05-02 22:43:32 +02:00
// fallthrough
2020-02-01 06:25:50 +01:00
case POKENAV_MENU_TYPE_CONDITION:
2020-10-11 00:17:34 +02:00
HideMainOrSubMenuLeftHeader(POKENAV_GFX_CONDITION_MENU, FALSE);
2019-05-02 22:43:32 +02:00
break;
default:
2020-10-11 00:17:34 +02:00
HideMainOrSubMenuLeftHeader(POKENAV_GFX_MAIN_MENU, FALSE);
2019-05-02 22:43:32 +02:00
break;
}
PlaySE(SE_SELECT);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 2:
2020-02-01 06:25:50 +01:00
if (AreMenuOptionSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (AreLeftHeaderSpritesMoving())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2021-11-12 23:28:06 +01:00
PokenavFadeScreen(POKENAV_FADE_TO_BLACK);
2019-08-05 14:40:03 +02:00
return LT_INC_AND_PAUSE;
2019-05-02 22:43:32 +02:00
case 3:
if (IsPaletteFadeActive())
2019-08-05 14:40:03 +02:00
return LT_PAUSE;
2019-05-02 22:43:32 +02:00
break;
}
2019-08-05 14:40:03 +02:00
return LT_FINISH;
2019-05-02 22:43:32 +02:00
}
2019-05-02 23:50:42 +02:00
2020-10-11 00:17:34 +02:00
static void LoadPokenavOptionPalettes(void)
2019-05-02 23:50:42 +02:00
{
2019-08-05 14:46:52 +02:00
s32 i;
2019-05-02 23:50:42 +02:00
for (i = 0; i < ARRAY_COUNT(sPokenavOptionsSpriteSheets); i++)
2020-10-11 00:17:34 +02:00
LoadCompressedSpriteSheet(&sPokenavOptionsSpriteSheets[i]);
Pokenav_AllocAndLoadPalettes(sPokenavOptionsSpritePalettes);
2019-05-02 23:50:42 +02:00
}
2020-10-11 00:17:34 +02:00
static void FreeAndDestroyMainMenuSprites(void)
2019-05-02 23:50:42 +02:00
{
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);
2020-10-11 00:17:34 +02:00
DestroyMenuOptionSprites();
DestroyRematchBlueLightSprite();
2019-05-02 23:50:42 +02:00
}
2020-02-01 06:25:50 +01:00
static void CreateMenuOptionSprites(void)
2019-05-02 23:50:42 +02:00
{
s32 i, j;
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-05-02 23:50:42 +02:00
2020-02-01 06:25:50 +01:00
for (i = 0; i < MAX_POKENAV_MENUITEMS; i++)
2019-05-02 23:50:42 +02:00
{
for (j = 0; j < NUM_OPTION_SUBSPRITES; j++)
2019-05-02 23:50:42 +02:00
{
2020-02-01 06:25:50 +01:00
u8 spriteId = CreateSprite(&sMenuOptionSpriteTemplate, 0x8c, 20 * i + 40, 3);
gfx->iconSprites[i][j] = &gSprites[spriteId];
2021-07-07 15:11:52 +02:00
gSprites[spriteId].x2 = 32 * j;
2019-05-02 23:50:42 +02:00
}
}
}
2020-10-11 00:17:34 +02:00
static void DestroyMenuOptionSprites(void)
2019-05-02 23:50:42 +02:00
{
s32 i, j;
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-05-02 23:50:42 +02:00
2020-02-01 06:25:50 +01:00
for (i = 0; i < MAX_POKENAV_MENUITEMS; i++)
2019-05-02 23:50:42 +02:00
{
for (j = 0; j < NUM_OPTION_SUBSPRITES; j++)
2019-05-02 23:50:42 +02:00
{
FreeSpriteOamMatrix(gfx->iconSprites[i][j]);
DestroySprite(gfx->iconSprites[i][j]);
2019-05-02 23:50:42 +02:00
}
}
}
static void DrawCurrentMenuOptionLabels(void)
2019-05-02 23:50:42 +02:00
{
2020-02-01 06:25:50 +01:00
s32 menuType = GetPokenavMenuType();
DrawOptionLabelGfx(sPokenavMenuOptionLabelGfx[menuType].gfx, sPokenavMenuOptionLabelGfx[menuType].yStart, sPokenavMenuOptionLabelGfx[menuType].deltaY);
2019-05-02 23:50:42 +02:00
}
static void DrawOptionLabelGfx(const u16 *const *optionGfx, s32 yPos, s32 deltaY)
2019-05-02 23:50:42 +02:00
{
s32 i, j;
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
s32 baseTile = GetSpriteTileStartByTag(GFXTAG_OPTIONS);
2019-05-02 23:50:42 +02:00
2020-02-01 06:25:50 +01:00
for (i = 0; i < MAX_POKENAV_MENUITEMS; i++)
2019-05-02 23:50:42 +02:00
{
if (*optionGfx != NULL)
2019-05-02 23:50:42 +02:00
{
for (j = 0; j < NUM_OPTION_SUBSPRITES; j++)
2019-05-02 23:50:42 +02:00
{
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;
2019-05-02 23:50:42 +02:00
}
gfx->iconVisible[i] = TRUE;
2019-05-02 23:50:42 +02:00
}
else
{
for (j = 0; j < NUM_OPTION_SUBSPRITES; j++)
gfx->iconSprites[i][j]->invisible = TRUE;
gfx->iconVisible[i] = FALSE;
2019-05-02 23:50:42 +02:00
}
optionGfx++;
2020-10-11 00:17:34 +02:00
yPos += deltaY;
2019-05-02 23:50:42 +02:00
}
}
2019-07-31 01:46:56 +02:00
static void StartOptionAnimations_Enter(void)
2019-07-31 01:46:56 +02:00
{
s32 i;
struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
s32 cursorPos = GetPokenavCursorPos();
s32 iconCount = 0;
s32 x;
2019-07-31 01:46:56 +02:00
2020-02-01 06:25:50 +01:00
for (i = 0; i < MAX_POKENAV_MENUITEMS; i++)
2019-07-31 01:46:56 +02:00
{
if (gfx->iconVisible[i])
2019-07-31 01:46:56 +02:00
{
if (iconCount++ == cursorPos)
2019-07-31 01:46:56 +02:00
{
x = OPTION_SELECTED_X;
gfx->cursorPos = i;
2019-07-31 01:46:56 +02:00
}
else
{
// 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);
2019-07-31 01:46:56 +02:00
}
else
2020-10-11 00:17:34 +02:00
{
SetOptionInvisibility(gfx->iconSprites[i], TRUE);
2020-10-11 00:17:34 +02:00
}
2019-07-31 01:46:56 +02:00
}
}
static void StartOptionAnimations_CursorMoved(void)
2019-07-31 01:46:56 +02:00
{
s32 i;
struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2020-10-11 00:17:34 +02:00
s32 prevPos = GetPokenavCursorPos();
s32 newPos;
2019-07-31 01:46:56 +02:00
// Get the index of the next visible option
2020-10-11 00:17:34 +02:00
for (i = 0, newPos = 0; i < MAX_POKENAV_MENUITEMS; i++)
2019-07-31 01:46:56 +02:00
{
if (gfx->iconVisible[i])
2019-07-31 01:46:56 +02:00
{
2020-10-11 00:17:34 +02:00
if (newPos == prevPos)
2019-07-31 01:46:56 +02:00
{
2020-10-11 00:17:34 +02:00
newPos = i;
2019-07-31 01:46:56 +02:00
break;
}
2020-10-11 00:17:34 +02:00
newPos++;
2019-07-31 01:46:56 +02:00
}
}
// 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;
2019-07-31 01:46:56 +02:00
}
static void StartOptionAnimations_Exit(void)
2019-07-31 01:46:56 +02:00
{
s32 i;
struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-07-31 01:46:56 +02:00
2020-02-01 06:25:50 +01:00
for (i = 0; i < MAX_POKENAV_MENUITEMS; i++)
2019-07-31 01:46:56 +02:00
{
if (gfx->iconVisible[i])
2019-07-31 01:46:56 +02:00
{
// Unselected options slide out,
// selected option zooms in
if (gfx->cursorPos != i)
StartOptionSlide(gfx->iconSprites[i], OPTION_DEFAULT_X, OPTION_EXIT_X, 8);
2019-07-31 01:46:56 +02:00
else
StartOptionZoom(gfx->iconSprites[i]);
2019-07-31 01:46:56 +02:00
}
}
}
2020-02-01 06:25:50 +01:00
static bool32 AreMenuOptionSpritesMoving(void)
2019-07-31 01:46:56 +02:00
{
s32 i;
struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-07-31 01:46:56 +02:00
2020-02-01 06:25:50 +01:00
for (i = 0; i < MAX_POKENAV_MENUITEMS; i++)
2019-07-31 01:46:56 +02:00
{
if (gfx->iconSprites[i][0]->callback != SpriteCallbackDummy)
2019-07-31 01:46:56 +02:00
return TRUE;
}
if (gfx->numIconsBlending != 0)
2019-07-31 01:46:56 +02:00
return TRUE;
return FALSE;
}
#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)
2019-07-31 01:46:56 +02:00
{
s32 i;
for (i = 0; i < NUM_OPTION_SUBSPRITES; i++)
2019-07-31 01:46:56 +02:00
{
(*sprites)->x = startX;
(*sprites)->sSlideTime = time;
(*sprites)->sSlideAccel = 16 * (endX - startX) / time;
(*sprites)->sSlideSpeed = 16 * startX;
(*sprites)->sSlideEndX = endX;
(*sprites)->callback = SpriteCB_OptionSlide;
2019-08-05 00:15:02 +02:00
sprites++;
2019-07-31 01:46:56 +02:00
}
}
2019-08-05 00:15:02 +02:00
#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)
2019-08-05 00:15:02 +02:00
{
s32 i;
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-08-05 00:15:02 +02:00
u8 taskId;
for (i = 0; i < NUM_OPTION_SUBSPRITES; i++)
2019-08-05 00:15:02 +02:00
{
(*sprites)->oam.objMode = ST_OAM_OBJ_BLEND;
(*sprites)->oam.affineMode = ST_OAM_AFFINE_DOUBLE;
(*sprites)->callback = SpriteCB_OptionZoom;
(*sprites)->sZoomDelay = 8;
(*sprites)->sZoomSetAffine = FALSE;
(*sprites)->sZoomSubspriteId = i;
2019-08-05 00:15:02 +02:00
InitSpriteAffineAnim(sprites[0]);
StartSpriteAffineAnim(sprites[0], 0);
sprites++;
}
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
taskId = CreateTask(Task_OptionBlend, 3);
gTasks[taskId].tBlendDelay = 8;
gfx->numIconsBlending++;
2019-08-05 00:15:02 +02:00
}
static void SetOptionInvisibility(struct Sprite ** sprites, bool32 invisible)
{
2019-08-05 00:15:02 +02:00
s32 i;
for (i = 0; i < NUM_OPTION_SUBSPRITES; i++)
2019-08-05 00:15:02 +02:00
{
2020-10-11 00:17:34 +02:00
(*sprites)->invisible = invisible;
2019-08-05 00:15:02 +02:00
sprites++;
}
}
static void SpriteCB_OptionSlide(struct Sprite * sprite)
2019-08-05 00:15:02 +02:00
{
sprite->sSlideTime--;
if (sprite->sSlideTime != -1)
2019-08-05 00:15:02 +02:00
{
sprite->sSlideSpeed += sprite->sSlideAccel;
sprite->x = sprite->sSlideSpeed >> 4;
2019-08-05 00:15:02 +02:00
}
else
{
sprite->x = sprite->sSlideEndX;
2019-08-05 00:15:02 +02:00
sprite->callback = SpriteCallbackDummy;
}
}
2019-08-05 02:39:36 +02:00
#undef sSlideTime
#undef sSlideAccel
#undef sSlideSpeed
#undef sSlideEndX
static void SpriteCB_OptionZoom(struct Sprite * sprite)
2019-08-05 02:39:36 +02:00
{
s32 temp;
s32 x;
if (sprite->sZoomDelay == 0)
2019-08-05 02:39:36 +02:00
{
if (!sprite->sZoomSetAffine)
2019-08-05 02:39:36 +02:00
{
StartSpriteAffineAnim(sprite, 1);
sprite->sZoomSetAffine++;
sprite->sZoomSpeed = 0x100;
2021-07-07 15:11:52 +02:00
sprite->x += sprite->x2;
sprite->x2 = 0;
2019-08-05 02:39:36 +02:00
}
else
{
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)
2019-08-05 02:39:36 +02:00
{
case 0:
sprite->x2 = -x * 3;
2019-08-05 02:39:36 +02:00
break;
case 1:
sprite->x2 = -x;
2019-08-05 02:39:36 +02:00
break;
case 2:
sprite->x2 = x;
2019-08-05 02:39:36 +02:00
break;
case 3:
sprite->x2 = x * 3;
2019-08-05 02:39:36 +02:00
break;
}
if (sprite->affineAnimEnded)
{
sprite->invisible = TRUE;
FreeOamMatrix(sprite->oam.matrixNum);
CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, ST_OAM_AFFINE_OFF);
2019-08-05 02:39:36 +02:00
sprite->oam.affineMode = ST_OAM_AFFINE_OFF;
sprite->oam.objMode = ST_OAM_OBJ_NORMAL;
sprite->callback = SpriteCallbackDummy;
}
}
}
else
{
sprite->sZoomDelay--;
2019-08-05 02:39:36 +02:00
}
}
#undef sZoomDelay
#undef sZoomSetAffine
#undef sZoomSpeed
#undef sZoomSubspriteId
static void Task_OptionBlend(u8 taskId)
2019-08-05 02:39:36 +02:00
{
s16 * data = gTasks[taskId].data;
if (tBlendDelay == 0)
2019-08-05 02:39:36 +02:00
{
switch (tBlendState)
2019-08-05 02:39:36 +02:00
{
case 0:
tBlendTarget1 = 16;
tBlendTarget2 = 0;
2019-08-05 02:39:36 +02:00
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_NONE | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
tBlendState++;
2019-08-05 02:39:36 +02:00
break;
case 1:
if (tBlendCounter & 1)
2019-08-05 02:39:36 +02:00
{
tBlendTarget1 -= 3;
if (tBlendTarget1 < 0)
tBlendTarget1 = 0;
2019-08-05 02:39:36 +02:00
}
else
{
tBlendTarget2 += 3;
if (tBlendTarget2 > 16)
tBlendTarget2 = 16;
2019-08-05 02:39:36 +02:00
}
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(tBlendTarget1, tBlendTarget2));
tBlendCounter++;
if (tBlendCounter == 12)
2019-08-05 02:39:36 +02:00
{
((struct Pokenav_MenuGfx *)GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX))->numIconsBlending--;
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
2019-08-05 02:39:36 +02:00
DestroyTask(taskId);
}
break;
}
}
else
{
tBlendDelay--;
}
2019-08-05 02:39:36 +02:00
}
#undef tBlendDelay
#undef tBlendState
#undef tBlendTarget1
#undef tBlendTarget2
#undef tBlendCounter
// Blue light that blinks if there are available rematches nearby
2020-10-11 00:17:34 +02:00
static void CreateMatchCallBlueLightSprite(void)
2019-08-05 02:39:36 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2020-10-11 00:17:34 +02:00
u8 spriteId = CreateSprite(&sMatchCallBlueLightSpriteTemplate, 0x10, 0x60, 4);
gfx->blueLightSprite = &gSprites[spriteId];
if (AreAnyTrainerRematchesNearby())
gfx->blueLightSprite->callback = SpriteCB_BlinkingBlueLight;
2019-08-05 02:39:36 +02:00
else
gfx->blueLightSprite->invisible = TRUE;
2019-08-05 02:39:36 +02:00
}
static void DestroyRematchBlueLightSprite(void)
2019-08-05 02:39:36 +02:00
{
struct Pokenav_MenuGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
DestroySprite(gfx->blueLightSprite);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite)
2019-08-05 02:39:36 +02:00
{
sprite->data[0]++;
if (sprite->data[0] > 8)
{
sprite->data[0] = 0;
sprite->invisible ^= 1;
}
}
2020-02-01 06:25:50 +01:00
static void AddOptionDescriptionWindow(void)
2019-08-05 02:39:36 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-08-05 02:39:36 +02:00
gfx->optionDescWindowId = AddWindow(&sOptionDescWindowTemplate);
PutWindowTilemap(gfx->optionDescWindowId);
FillWindowPixelBuffer(gfx->optionDescWindowId, PIXEL_FILL(6));
CopyWindowToVram(gfx->optionDescWindowId, COPYWIN_FULL);
2019-08-05 02:39:36 +02:00
}
2020-02-01 06:25:50 +01:00
static void PrintCurrentOptionDescription(void)
2019-08-05 02:39:36 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2020-02-01 06:25:50 +01:00
int menuItem = GetCurrentMenuItemId();
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);
2019-08-05 02:39:36 +02:00
}
2020-02-01 06:25:50 +01:00
// 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)
2019-08-05 02:39:36 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
2019-08-05 02:39:36 +02:00
const u8 * s = gText_NoRibbonWinners;
2021-10-30 22:47:37 +02:00
u32 width = GetStringWidth(FONT_NORMAL, s, -1);
FillWindowPixelBuffer(gfx->optionDescWindowId, PIXEL_FILL(6));
AddTextPrinterParameterized3(gfx->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors2, 0, s);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static bool32 IsDma3ManagerBusyWithBgCopy_(void)
2019-08-05 02:39:36 +02:00
{
return IsDma3ManagerBusyWithBgCopy();
}
2020-10-11 00:17:34 +02:00
static void CreateMovingBgDotsTask(void)
2019-08-05 02:39:36 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
gfx->bg3ScrollTaskId = CreateTask(Task_MoveBgDots, 2);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static void DestroyMovingDotsBgTask(void)
2019-08-05 02:39:36 +02:00
{
struct Pokenav_MenuGfx * gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_GFX);
DestroyTask(gfx->bg3ScrollTaskId);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static void Task_MoveBgDots(u8 taskId)
2019-08-05 02:39:36 +02:00
{
2021-11-04 04:02:06 +01:00
ChangeBgX(3, 0x80, BG_COORD_ADD);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static void CreateBgDotPurplePalTask(void)
2019-08-05 02:39:36 +02:00
{
2020-10-11 00:17:34 +02:00
u8 taskId = CreateTask(Task_UpdateBgDotsPalette, 3);
SetWordTaskArg(taskId, 1, (uintptr_t)(sPokenavBgDotsPal + 1));
SetWordTaskArg(taskId, 3, (uintptr_t)(sPokenavBgDotsPal + 7));
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static void ChangeBgDotsColorToPurple(void)
2019-08-05 02:39:36 +02:00
{
2020-10-11 00:17:34 +02:00
CopyPaletteIntoBufferUnfaded(sPokenavBgDotsPal + 7, 0x31, 4);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static void CreateBgDotLightBluePalTask(void)
2019-08-05 02:39:36 +02:00
{
2020-10-11 00:17:34 +02:00
u8 taskId = CreateTask(Task_UpdateBgDotsPalette, 3);
SetWordTaskArg(taskId, 1, (uintptr_t)(sPokenavBgDotsPal + 7));
SetWordTaskArg(taskId, 3, (uintptr_t)(sPokenavBgDotsPal + 1));
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static bool32 IsTaskActive_UpdateBgDotsPalette(void)
2019-08-05 02:39:36 +02:00
{
2020-10-11 00:17:34 +02:00
return FuncIsActiveTask(Task_UpdateBgDotsPalette);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static void Task_UpdateBgDotsPalette(u8 taskId)
2019-08-05 02:39:36 +02:00
{
u16 sp8[2];
s16 * data = gTasks[taskId].data;
const u16 * pal1 = (const u16 *)GetWordTaskArg(taskId, 1);
const u16 * pal2 = (const u16 *)GetWordTaskArg(taskId, 3);
2020-10-11 00:17:34 +02:00
PokenavCopyPalette(pal1, pal2, 2, 12, ++data[0], sp8);
2019-08-05 02:39:36 +02:00
LoadPalette(sp8, 0x31, 4);
if (data[0] == 12)
DestroyTask(taskId);
}
2020-10-11 00:17:34 +02:00
static void VBlankCB_PokenavMainMenu(void)
2019-08-05 02:39:36 +02:00
{
TransferPlttBuffer();
LoadOam();
ProcessSpriteCopyRequests();
ScanlineEffect_InitHBlankDmaTransfer();
}
2020-10-11 00:17:34 +02:00
static void SetupPokenavMenuScanlineEffects(void)
2019-08-05 02:39:36 +02:00
{
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_LIGHTEN);
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
2021-04-15 08:43:09 +02:00
SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_ALL);
SetGpuRegBits(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ);
2021-04-15 08:04:01 +02:00
SetGpuRegBits(REG_OFFSET_WIN0V, DISPLAY_HEIGHT);
2019-08-05 02:39:36 +02:00
ScanlineEffect_Stop();
2020-10-11 00:17:34 +02:00
SetMenuOptionGlow();
ScanlineEffect_SetParams(sPokenavMainMenuScanlineEffectParams);
SetVBlankCallback_(VBlankCB_PokenavMainMenu);
CreateTask(Task_CurrentMenuOptionGlow, 3);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
static void DestroyMenuOptionGlowTask(void)
2019-08-05 02:39:36 +02:00
{
SetGpuReg(REG_OFFSET_BLDCNT, 0);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
ScanlineEffect_Stop();
2020-10-11 00:17:34 +02:00
DestroyTask(FindTaskIdByFunc(Task_CurrentMenuOptionGlow));
2019-08-05 02:39:36 +02:00
SetPokenavVBlankCallback();
}
2020-10-11 00:17:34 +02:00
static void ResetBldCnt(void)
2019-08-05 02:39:36 +02:00
{
SetGpuReg(REG_OFFSET_BLDCNT, 0);
}
2020-10-11 00:17:34 +02:00
static void InitMenuOptionGlow(void)
2019-08-05 02:39:36 +02:00
{
2020-10-11 00:17:34 +02:00
SetMenuOptionGlow();
2019-08-05 02:39:36 +02:00
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_LIGHTEN);
}
2020-10-11 00:17:34 +02:00
static void Task_CurrentMenuOptionGlow(u8 taskId)
2019-08-05 02:39:36 +02:00
{
s16 * data = gTasks[taskId].data;
data[0]++;
if (data[0] > 0)
{
data[0] = 0;
data[1] += 3;
data[1] &= 0x7F;
SetGpuReg(REG_OFFSET_BLDY, gSineTable[data[1]] >> 5);
}
}
2020-10-11 00:17:34 +02:00
static void SetMenuOptionGlow(void)
2019-08-05 02:39:36 +02:00
{
2020-02-01 06:25:50 +01:00
int menuType = GetPokenavMenuType();
int cursorPos = GetPokenavCursorPos();
2020-10-11 00:17:34 +02:00
int r4 = sPokenavMenuOptionLabelGfx[menuType].deltaY * cursorPos + sPokenavMenuOptionLabelGfx[menuType].yStart - 8;
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);
2019-08-05 02:39:36 +02:00
}
2020-10-11 00:17:34 +02:00
void ResetBldCnt_(void)
2019-08-05 02:39:36 +02:00
{
2020-10-11 00:17:34 +02:00
ResetBldCnt();
2019-08-05 02:39:36 +02:00
}