2019-04-07 19:40:35 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "pokenav.h"
|
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "constants/rgb.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "bg.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "graphics.h"
|
|
|
|
#include "decompress.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "dma3.h"
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2020-10-10 23:17:34 +01:00
|
|
|
void (*loopTask)(u32);
|
|
|
|
u32 (*isLoopTaskActiveFunc)(void);
|
|
|
|
u32 unused;
|
2019-04-07 19:40:35 +01:00
|
|
|
u32 currentTaskId;
|
2019-12-07 09:08:21 +00:00
|
|
|
u32 helpBarWindowId;
|
2020-02-05 07:47:32 +00:00
|
|
|
u32 palettes;
|
2019-04-07 23:10:53 +01:00
|
|
|
struct Sprite *spinningPokenav;
|
2019-04-07 19:40:35 +01:00
|
|
|
struct Sprite *leftHeaderSprites[2];
|
|
|
|
struct Sprite *submenuLeftHeaderSprites[2];
|
2021-11-12 17:40:36 +00:00
|
|
|
u8 tilemapBuffer[BG_SCREEN_SIZE];
|
2019-04-07 19:40:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// This struct uses a 32bit tag, and doesn't have a size field.
|
|
|
|
// Needed to match LoadLeftHeaderGfxForSubMenu.
|
|
|
|
struct CompressedSpriteSheetNoSize
|
|
|
|
{
|
|
|
|
const u32 *data; // LZ77 compressed palette data
|
|
|
|
u32 tag;
|
|
|
|
};
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void CleanupPokenavMainMenuResources(void);
|
2021-11-12 17:40:36 +00:00
|
|
|
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 *);
|
2019-04-13 21:54:05 +01:00
|
|
|
static void InitPokenavMainMenuResources(void);
|
2021-11-12 17:40:36 +00:00
|
|
|
static void CreateLeftHeaderSprites(void);
|
2019-12-07 09:08:21 +00:00
|
|
|
static void InitHelpBar(void);
|
2021-11-12 17:40:36 +00:00
|
|
|
static u32 LoopedTask_SlideMenuHeaderUp(s32);
|
|
|
|
static u32 LoopedTask_SlideMenuHeaderDown(s32);
|
|
|
|
static void DrawHelpBar(u32);
|
2022-07-29 16:15:33 +01:00
|
|
|
static void SpriteCB_SpinningPokenav(struct Sprite *);
|
2021-11-12 17:40:36 +00:00
|
|
|
static u32 LoopedTask_InitPokenavMenu(s32);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
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
|
2019-04-07 19:40:35 +01:00
|
|
|
|
|
|
|
const struct BgTemplate gPokenavMainMenuBgTemplates[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 5,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
static const struct WindowTemplate sHelpBarWindowTemplate[] =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 22,
|
|
|
|
.width = 16,
|
|
|
|
.height = 2,
|
2022-08-19 16:32:00 +01:00
|
|
|
.paletteNum = 0,
|
2019-04-07 19:40:35 +01:00
|
|
|
.baseBlock = 0x36,
|
|
|
|
},
|
2019-12-07 09:08:21 +00:00
|
|
|
DUMMY_WIN_TEMPLATE
|
2019-04-07 19:40:35 +01:00
|
|
|
};
|
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
static const u8 *const sHelpBarTexts[HELPBAR_COUNT] =
|
|
|
|
{
|
2024-08-16 21:41:26 +01:00
|
|
|
[HELPBAR_NONE] = COMPOUND_STRING("{CLEAR 0x80}"),
|
|
|
|
[HELPBAR_MAP_ZOOMED_OUT] = COMPOUND_STRING("{A_BUTTON}ZOOM {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_MAP_ZOOMED_IN] = COMPOUND_STRING("{A_BUTTON}FULL {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_CONDITION_MON_LIST] = COMPOUND_STRING("{A_BUTTON}CONDITION {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_CONDITION_MON_STATUS] = COMPOUND_STRING("{A_BUTTON}MARKINGS {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_CONDITION_MARKINGS] = COMPOUND_STRING("{A_BUTTON}SELECT MARK {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_MC_TRAINER_LIST] = COMPOUND_STRING("{A_BUTTON}MENU {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_MC_CALL_MENU] = COMPOUND_STRING("{A_BUTTON}OK {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_MC_CHECK_PAGE] = COMPOUND_STRING("{B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_RIBBONS_MON_LIST] = COMPOUND_STRING("{A_BUTTON}RIBBONS {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_RIBBONS_LIST] = COMPOUND_STRING("{A_BUTTON}CHECK {B_BUTTON}CANCEL"),
|
|
|
|
[HELPBAR_RIBBONS_CHECK] = COMPOUND_STRING("{B_BUTTON}CANCEL"),
|
2019-04-07 19:40:35 +01:00
|
|
|
};
|
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
static const u8 sHelpBarTextColors[3] =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-04-10 03:39:34 +01:00
|
|
|
TEXT_COLOR_RED, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY
|
2019-04-07 19:40:35 +01:00
|
|
|
};
|
|
|
|
|
2022-05-17 18:51:54 +01:00
|
|
|
static const struct CompressedSpriteSheet sSpinningPokenavSpriteSheet[] =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
.data = sSpinningPokenav_Gfx,
|
2019-04-07 19:40:35 +01:00
|
|
|
.size = 0x1000,
|
|
|
|
.tag = 0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-05-17 18:51:54 +01:00
|
|
|
static const struct SpritePalette sSpinningNavgearPalettes[] =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
.data = sSpinningPokenav_Pal,
|
2019-04-07 19:40:35 +01:00
|
|
|
.tag = 0,
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static const struct CompressedSpriteSheet sMenuLeftHeaderSpriteSheet =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
.data = gPokenavLeftHeaderHoennMap_Gfx, // Hoenn map is the first of the headers listed
|
2019-04-07 19:40:35 +01:00
|
|
|
.size = 0xC00,
|
|
|
|
.tag = 2
|
|
|
|
};
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static const struct CompressedSpriteSheet sMenuLeftHeaderSpriteSheets[] =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_MAIN_MENU] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderMainMenu_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 3
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_CONDITION_MENU] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderCondition_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 1
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_RIBBONS_MENU] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderRibbons_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 2
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_MATCH_CALL_MENU] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderMatchCall_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 4
|
|
|
|
},
|
2020-02-05 07:47:32 +00:00
|
|
|
[POKENAV_GFX_MAP_MENU_ZOOMED_OUT] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderHoennMap_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 0
|
|
|
|
},
|
2020-02-05 07:47:32 +00:00
|
|
|
[POKENAV_GFX_MAP_MENU_ZOOMED_IN] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderHoennMap_Gfx,
|
|
|
|
.size = 0x40,
|
|
|
|
.tag = 0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CompressedSpriteSheetNoSize sPokenavSubMenuLeftHeaderSpriteSheets[] =
|
|
|
|
{
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_PARTY_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderParty_Gfx,
|
|
|
|
.tag = 1
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_SEARCH_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderSearch_Gfx,
|
|
|
|
.tag = 1
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_COOL_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderCool_Gfx,
|
|
|
|
.tag = 4
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_BEAUTY_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderBeauty_Gfx,
|
|
|
|
.tag = 1
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_CUTE_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderCute_Gfx,
|
|
|
|
.tag = 2
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_SMART_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderSmart_Gfx,
|
|
|
|
.tag = 0
|
|
|
|
},
|
2019-04-07 23:10:53 +01:00
|
|
|
[POKENAV_GFX_TOUGH_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 19:40:35 +01:00
|
|
|
.data = gPokenavLeftHeaderTough_Gfx,
|
|
|
|
.tag = 0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-07 23:10:53 +01:00
|
|
|
static const struct OamData sSpinningPokenavSpriteOam =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-07 23:31:01 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
|
|
|
.shape = SPRITE_SHAPE(32x32),
|
2019-04-07 19:40:35 +01:00
|
|
|
.x = 0,
|
2019-04-07 23:31:01 +01:00
|
|
|
.size = SPRITE_SIZE(32x32),
|
2019-04-07 19:40:35 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2019-04-07 23:10:53 +01:00
|
|
|
static const union AnimCmd sSpinningPokenavAnims[] =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 8),
|
|
|
|
ANIMCMD_FRAME(16, 8),
|
|
|
|
ANIMCMD_FRAME(32, 8),
|
|
|
|
ANIMCMD_FRAME(48, 8),
|
|
|
|
ANIMCMD_FRAME(64, 8),
|
|
|
|
ANIMCMD_FRAME(80, 8),
|
|
|
|
ANIMCMD_FRAME(96, 8),
|
|
|
|
ANIMCMD_FRAME(112, 8),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
2019-04-07 23:10:53 +01:00
|
|
|
static const union AnimCmd *const sSpinningPokenavAnimTable[] =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-04-07 23:10:53 +01:00
|
|
|
sSpinningPokenavAnims
|
2019-04-07 19:40:35 +01:00
|
|
|
};
|
|
|
|
|
2019-04-07 23:10:53 +01:00
|
|
|
static const struct SpriteTemplate sSpinningPokenavSpriteTemplate =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
.tileTag = 0,
|
|
|
|
.paletteTag = 0,
|
2019-04-07 23:10:53 +01:00
|
|
|
.oam = &sSpinningPokenavSpriteOam,
|
|
|
|
.anims = sSpinningPokenavAnimTable,
|
2019-04-07 19:40:35 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2019-04-07 23:10:53 +01:00
|
|
|
.callback = SpriteCB_SpinningPokenav
|
2019-04-07 19:40:35 +01:00
|
|
|
};
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static const struct OamData sOamData_LeftHeader =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-07 23:31:01 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
|
|
|
.shape = SPRITE_SHAPE(64x32),
|
2019-04-07 19:40:35 +01:00
|
|
|
.x = 0,
|
2019-04-07 23:31:01 +01:00
|
|
|
.size = SPRITE_SIZE(64x32),
|
2019-04-07 19:40:35 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static const struct OamData sOamData_SubmenuLeftHeader =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-07 23:31:01 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2019-12-04 20:25:13 +00:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-04-07 23:31:01 +01:00
|
|
|
.shape = SPRITE_SHAPE(32x16),
|
2019-04-07 19:40:35 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-04-07 23:31:01 +01:00
|
|
|
.size = SPRITE_SIZE(32x16),
|
2019-04-07 19:40:35 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static const struct SpriteTemplate sLeftHeaderSpriteTemplate =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
.tileTag = 2,
|
|
|
|
.paletteTag = 1,
|
2021-11-12 17:40:36 +00:00
|
|
|
.oam = &sOamData_LeftHeader,
|
2019-04-07 19:40:35 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static const struct SpriteTemplate sSubmenuLeftHeaderSpriteTemplate =
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
.tileTag = 2,
|
|
|
|
.paletteTag = 2,
|
2021-11-12 17:40:36 +00:00
|
|
|
.oam = &sOamData_SubmenuLeftHeader,
|
2019-04-07 19:40:35 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
|
|
|
bool32 InitPokenavMainMenu(void)
|
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu;
|
2020-09-02 14:49:04 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
menu = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct Pokenav_MainMenu));
|
|
|
|
if (menu == NULL)
|
2019-04-07 19:40:35 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->currentTaskId = CreateLoopedTask(LoopedTask_InitPokenavMenu, 1);
|
2019-04-07 19:40:35 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 PokenavMainMenuLoopedTaskIsActive(void)
|
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
return IsLoopedTaskActive(menu->currentTaskId);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShutdownPokenav(void)
|
|
|
|
{
|
2020-08-20 23:02:00 +01:00
|
|
|
PlaySE(SE_POKENAV_OFF);
|
2020-10-10 23:17:34 +01:00
|
|
|
ResetBldCnt_();
|
2021-02-24 16:01:02 +00:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 16, RGB_BLACK);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool32 WaitForPokenavShutdownFade(void)
|
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-02-05 07:47:32 +00:00
|
|
|
FreeMenuHandlerSubstruct2();
|
2019-04-07 19:40:35 +01:00
|
|
|
CleanupPokenavMainMenuResources();
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static u32 LoopedTask_InitPokenavMenu(s32 state)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu;
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
switch (state)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
|
|
|
InitBgsFromTemplates(0, gPokenavMainMenuBgTemplates, ARRAY_COUNT(gPokenavMainMenuBgTemplates));
|
|
|
|
ResetBgPositions();
|
2020-05-14 09:37:09 +01:00
|
|
|
ResetTempTileDataBuffers();
|
2019-04-07 19:40:35 +01:00
|
|
|
return LT_INC_AND_CONTINUE;
|
|
|
|
case 1:
|
2021-11-12 17:40:36 +00:00
|
|
|
menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2020-05-14 09:37:09 +01:00
|
|
|
DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0);
|
2021-11-12 17:40:36 +00:00
|
|
|
SetBgTilemapBuffer(0, menu->tilemapBuffer);
|
2019-04-07 19:40:35 +01:00
|
|
|
CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0);
|
2022-08-19 16:32:00 +01:00
|
|
|
CopyPaletteIntoBufferUnfaded(gPokenavHeader_Pal, BG_PLTT_ID(0), PLTT_SIZE_4BPP);
|
2019-04-07 19:40:35 +01:00
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 2:
|
2020-05-14 09:37:09 +01:00
|
|
|
if (FreeTempTileDataBuffersIfPossible())
|
2019-04-07 19:40:35 +01:00
|
|
|
return LT_PAUSE;
|
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
InitHelpBar();
|
2019-04-07 19:40:35 +01:00
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 3:
|
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
|
|
|
return LT_PAUSE;
|
|
|
|
|
|
|
|
InitPokenavMainMenuResources();
|
2021-11-12 17:40:36 +00:00
|
|
|
CreateLeftHeaderSprites();
|
2019-04-07 19:40:35 +01:00
|
|
|
ShowBg(0);
|
|
|
|
return LT_FINISH;
|
|
|
|
default:
|
|
|
|
return LT_FINISH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void SetActiveMenuLoopTasks(void *createLoopTask, void *isLoopTaskActive) // Fix types later.
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
menu->loopTask = createLoopTask;
|
|
|
|
menu->isLoopTaskActiveFunc = isLoopTaskActive;
|
|
|
|
menu->unused = 0;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
void RunMainMenuLoopedTask(u32 state)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
menu->unused = 0;
|
|
|
|
menu->loopTask(state);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
u32 IsActiveMenuLoopTaskActive(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
return menu->isLoopTaskActiveFunc();
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void SlideMenuHeaderUp(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
menu->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void SlideMenuHeaderDown(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
menu->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool32 MainMenuLoopedTaskIsBusy(void)
|
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
return IsLoopedTaskActive(menu->currentTaskId);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static u32 LoopedTask_SlideMenuHeaderUp(s32 state)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
switch (state)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
return LT_FINISH;
|
|
|
|
case 1:
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 0:
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 2:
|
2021-11-04 03:02:06 +00:00
|
|
|
if (ChangeBgY(0, 384, BG_COORD_ADD) >= 0x2000u)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-04 03:02:06 +00:00
|
|
|
ChangeBgY(0, 0x2000, BG_COORD_SET);
|
2019-04-07 19:40:35 +01:00
|
|
|
return LT_FINISH;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LT_PAUSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static u32 LoopedTask_SlideMenuHeaderDown(s32 state)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-04 03:02:06 +00:00
|
|
|
if (ChangeBgY(0, 384, BG_COORD_SUB) <= 0)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-04 03:02:06 +00:00
|
|
|
ChangeBgY(0, 0, BG_COORD_SET);
|
2020-11-02 23:43:11 +00:00
|
|
|
return LT_FINISH;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
2020-11-02 23:43:11 +00:00
|
|
|
return LT_PAUSE;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size)
|
|
|
|
{
|
2023-05-23 18:16:18 +01:00
|
|
|
CpuCopy16(palette, &gPlttBufferUnfaded[bufferOffset], size);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Pokenav_AllocAndLoadPalettes(const struct SpritePalette *palettes)
|
|
|
|
{
|
|
|
|
const struct SpritePalette *current;
|
|
|
|
u32 index;
|
|
|
|
|
|
|
|
for (current = palettes; current->data != NULL; current++)
|
|
|
|
{
|
|
|
|
index = AllocSpritePalette(current->tag);
|
|
|
|
if (index == 0xFF)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 08:22:50 +01:00
|
|
|
else
|
|
|
|
{
|
2022-08-19 15:29:35 +01:00
|
|
|
index = OBJ_PLTT_ID(index);
|
|
|
|
CopyPaletteIntoBufferUnfaded(current->data, index, PLTT_SIZE_4BPP);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 08:22:50 +01:00
|
|
|
}
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void PokenavFillPalette(u32 palIndex, u16 fillValue)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2023-05-23 18:16:18 +01:00
|
|
|
CpuFill16(fillValue, &gPlttBufferFaded[OBJ_PLTT_ID(palIndex)], PLTT_SIZE_4BPP);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a4, u16 *palette)
|
2020-10-24 03:07:30 +01:00
|
|
|
{
|
|
|
|
if (a4 == 0)
|
|
|
|
{
|
2020-10-10 23:17:34 +01:00
|
|
|
CpuCopy16(src, palette, size * 2);
|
2020-10-24 03:07:30 +01:00
|
|
|
}
|
|
|
|
else if (a4 >= a3)
|
|
|
|
{
|
2020-10-10 23:17:34 +01:00
|
|
|
CpuCopy16(dest, palette, size * 2);
|
2020-10-24 03:07:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int r, g, b;
|
|
|
|
int r1, g1, b1;
|
2020-10-10 23:17:34 +01:00
|
|
|
while (size--)
|
2020-10-24 03:07:30 +01:00
|
|
|
{
|
2020-10-10 23:17:34 +01:00
|
|
|
r = GET_R(*src);
|
|
|
|
g = GET_G(*src);
|
|
|
|
b = GET_B(*src);
|
2020-10-24 03:07:30 +01:00
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
r1 = ((((GET_R(*dest) << 8) - (r << 8)) / a3) * a4) >> 8;
|
|
|
|
g1 = ((((GET_G(*dest) << 8) - (g << 8)) / a3) * a4) >> 8;
|
|
|
|
b1 = ((((GET_B(*dest) << 8) - (b << 8)) / a3) * a4) >> 8;
|
2020-10-24 03:07:30 +01:00
|
|
|
|
2021-11-12 22:28:06 +00:00
|
|
|
r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match
|
|
|
|
g = (g + g1) & 0x1F;
|
|
|
|
b = (b + b1) & 0x1F;
|
2020-10-24 03:07:30 +01:00
|
|
|
|
2021-11-12 22:28:06 +00:00
|
|
|
*palette = RGB2(r, g, b);
|
2020-10-24 03:07:30 +01:00
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
src++, dest++;
|
2020-10-24 03:07:30 +01:00
|
|
|
palette++;
|
|
|
|
}
|
|
|
|
}
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
void PokenavFadeScreen(s32 fadeType)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
switch (fadeType)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 22:28:06 +00:00
|
|
|
case POKENAV_FADE_TO_BLACK:
|
2021-11-12 17:40:36 +00:00
|
|
|
BeginNormalPaletteFade(menu->palettes, -2, 0, 16, RGB_BLACK);
|
2019-04-07 19:40:35 +01:00
|
|
|
break;
|
2021-11-12 22:28:06 +00:00
|
|
|
case POKENAV_FADE_FROM_BLACK:
|
2021-11-12 17:40:36 +00:00
|
|
|
BeginNormalPaletteFade(menu->palettes, -2, 16, 0, RGB_BLACK);
|
2019-04-07 19:40:35 +01:00
|
|
|
break;
|
2021-11-12 22:28:06 +00:00
|
|
|
case POKENAV_FADE_TO_BLACK_ALL:
|
2021-02-24 16:01:02 +00:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK);
|
2019-04-07 19:40:35 +01:00
|
|
|
break;
|
2021-11-12 22:28:06 +00:00
|
|
|
case POKENAV_FADE_FROM_BLACK_ALL:
|
2021-02-24 16:01:02 +00:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -2, 16, 0, RGB_BLACK);
|
2019-04-07 19:40:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool32 IsPaletteFadeActive(void)
|
|
|
|
{
|
|
|
|
return gPaletteFade.active;
|
|
|
|
}
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
// Excludes the first obj and bg palettes
|
|
|
|
void FadeToBlackExceptPrimary(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
BlendPalettes(PALETTES_ALL & ~(1 << 16 | 1), 16, RGB_BLACK);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
void InitBgTemplates(const struct BgTemplate *templates, int count)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-04-13 21:54:05 +01:00
|
|
|
int i;
|
2019-04-07 19:40:35 +01:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
InitBgFromTemplate(templates++);
|
|
|
|
}
|
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
static void InitHelpBar(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
InitWindows(&sHelpBarWindowTemplate[0]);
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->helpBarWindowId = 0;
|
|
|
|
DrawHelpBar(menu->helpBarWindowId);
|
|
|
|
PutWindowTilemap(menu->helpBarWindowId);
|
|
|
|
CopyWindowToVram(menu->helpBarWindowId, COPYWIN_FULL);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
void PrintHelpBarText(u32 textId)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
DrawHelpBar(menu->helpBarWindowId);
|
|
|
|
AddTextPrinterParameterized3(menu->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
bool32 WaitForHelpBar(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
2019-12-07 09:08:21 +00:00
|
|
|
static void DrawHelpBar(u32 windowId)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(4));
|
|
|
|
FillWindowPixelRect(windowId, PIXEL_FILL(5), 0, 0, 0x80, 1);
|
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void InitPokenavMainMenuResources(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-07-19 01:46:00 +01:00
|
|
|
s32 i;
|
2019-04-07 19:40:35 +01:00
|
|
|
u8 spriteId;
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2022-05-17 18:51:54 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sSpinningPokenavSpriteSheet); i++)
|
|
|
|
LoadCompressedSpriteSheet(&sSpinningPokenavSpriteSheet[i]);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2022-05-17 18:51:54 +01:00
|
|
|
Pokenav_AllocAndLoadPalettes(sSpinningNavgearPalettes);
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0));
|
2019-04-07 23:10:53 +01:00
|
|
|
spriteId = CreateSprite(&sSpinningPokenavSpriteTemplate, 220, 12, 0);
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->spinningPokenav = &gSprites[spriteId];
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void CleanupPokenavMainMenuResources(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
DestroySprite(menu->spinningPokenav);
|
2019-04-07 19:40:35 +01:00
|
|
|
FreeSpriteTilesByTag(0);
|
|
|
|
FreeSpritePaletteByTag(0);
|
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void SpriteCB_SpinningPokenav(struct Sprite *sprite)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
// If the background starts scrolling, follow it.
|
2021-07-07 14:11:52 +01:00
|
|
|
sprite->y2 = (GetBgY(0) / 256u) * -1;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2021-11-12 22:28:06 +00:00
|
|
|
struct Sprite *GetSpinningPokenavSprite(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->spinningPokenav->callback = SpriteCallbackDummy;
|
|
|
|
return menu->spinningPokenav;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2021-11-12 22:28:06 +00:00
|
|
|
void HideSpinningPokenavSprite(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 22:28:06 +00:00
|
|
|
// Move sprite so it's no longer visible
|
2021-11-12 17:40:36 +00:00
|
|
|
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;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
static void CreateLeftHeaderSprites(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-07-19 01:46:00 +01:00
|
|
|
s32 i, spriteId;
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
LoadCompressedSpriteSheet(&sMenuLeftHeaderSpriteSheet);
|
2019-04-07 19:40:35 +01:00
|
|
|
AllocSpritePalette(1);
|
|
|
|
AllocSpritePalette(2);
|
2021-11-12 17:40:36 +00:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
// 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;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
void LoadLeftHeaderGfxForIndex(u32 menuGfxId)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2020-02-05 07:47:32 +00:00
|
|
|
if (menuGfxId < POKENAV_GFX_SUBMENUS_START)
|
|
|
|
LoadLeftHeaderGfxForMenu(menuGfxId);
|
2019-04-07 19:40:35 +01:00
|
|
|
else
|
2020-02-05 07:47:32 +00:00
|
|
|
LoadLeftHeaderGfxForSubMenu(menuGfxId - POKENAV_GFX_SUBMENUS_START);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void UpdateRegionMapRightHeaderTiles(u32 menuGfxId)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT)
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32;
|
2019-04-07 19:40:35 +01:00
|
|
|
else
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
static void LoadLeftHeaderGfxForMenu(u32 menuGfxId)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu;
|
2019-04-07 19:40:35 +01:00
|
|
|
u32 size, tag;
|
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
if (menuGfxId >= POKENAV_GFX_SUBMENUS_START)
|
2019-04-07 19:40:35 +01:00
|
|
|
return;
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
tag = sMenuLeftHeaderSpriteSheets[menuGfxId].tag;
|
|
|
|
size = GetDecompressedDataSize(sMenuLeftHeaderSpriteSheets[menuGfxId].data);
|
2022-08-19 15:29:35 +01:00
|
|
|
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], OBJ_PLTT_ID(IndexOfSpritePaletteTag(1)), PLTT_SIZE_4BPP);
|
2021-11-12 17:40:36 +00:00
|
|
|
LZ77UnCompWram(sMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer);
|
2020-11-02 23:43:11 +00:00
|
|
|
RequestDma3Copy(gDecompressionBuffer, (void *)OBJ_VRAM0 + (GetSpriteTileStartByTag(2) * 32), size, 1);
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sMenuLeftHeaderSpriteSheets[menuGfxId].size;
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT || menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_IN)
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->leftHeaderSprites[1]->x2 = 56;
|
2019-04-07 19:40:35 +01:00
|
|
|
else
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->leftHeaderSprites[1]->x2 = 64;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
u32 size, tag;
|
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
if (menuGfxId >= POKENAV_GFX_MENUS_END - POKENAV_GFX_SUBMENUS_START)
|
2019-04-07 19:40:35 +01:00
|
|
|
return;
|
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
tag = sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].tag;
|
|
|
|
size = GetDecompressedDataSize(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data);
|
2022-08-19 15:29:35 +01:00
|
|
|
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], OBJ_PLTT_ID(IndexOfSpritePaletteTag(2)), PLTT_SIZE_4BPP);
|
2020-02-05 07:47:32 +00:00
|
|
|
LZ77UnCompWram(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data, &gDecompressionBuffer[0x1000]);
|
2021-03-30 20:07:04 +01:00
|
|
|
RequestDma3Copy(&gDecompressionBuffer[0x1000], (void *)OBJ_VRAM0 + 0x800 + (GetSpriteTileStartByTag(2) * 32), size, 1);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void ShowLeftHeaderGfx(u32 menuGfxId, bool32 isMain, bool32 isOnRightSide)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2020-10-10 23:17:34 +01:00
|
|
|
u32 tileTop;
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
if (!isMain)
|
|
|
|
tileTop = 0x30;
|
2019-04-07 19:40:35 +01:00
|
|
|
else
|
2020-10-10 23:17:34 +01:00
|
|
|
tileTop = 0x10;
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2020-02-05 07:47:32 +00:00
|
|
|
if (menuGfxId < POKENAV_GFX_SUBMENUS_START)
|
2020-10-10 23:17:34 +01:00
|
|
|
ShowLeftHeaderSprites(tileTop, isOnRightSide);
|
2019-04-07 19:40:35 +01:00
|
|
|
else
|
2020-10-10 23:17:34 +01:00
|
|
|
ShowLeftHeaderSubmenuSprites(tileTop, isOnRightSide);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2020-10-10 23:17:34 +01:00
|
|
|
if (id < POKENAV_GFX_PARTY_MENU)
|
|
|
|
HideLeftHeaderSprites(onRightSide);
|
2019-04-07 19:40:35 +01:00
|
|
|
else
|
2020-10-10 23:17:34 +01:00
|
|
|
HideLeftHeaderSubmenuSprites(onRightSide);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
void SetLeftHeaderSpritesInvisibility(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-07-19 01:46:00 +01:00
|
|
|
s32 i;
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->leftHeaderSprites[i]->invisible = TRUE;
|
|
|
|
menu->submenuLeftHeaderSprites[i]->invisible = TRUE;
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-10 23:17:34 +01:00
|
|
|
bool32 AreLeftHeaderSpritesMoving(void)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
if (menu->leftHeaderSprites[0]->callback == SpriteCallbackDummy && menu->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy)
|
2019-04-07 19:40:35 +01:00
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-07-19 01:46:00 +01:00
|
|
|
s32 start, end, i;
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
|
|
|
if (!isOnRightSide)
|
|
|
|
start = -96, end = 32;
|
|
|
|
else
|
|
|
|
start = 256, end = 160;
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->leftHeaderSprites[i]->y = startY;
|
|
|
|
MoveLeftHeader(menu->leftHeaderSprites[i], start, end, 12);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-07-19 01:46:00 +01:00
|
|
|
s32 start, end, i;
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
|
|
|
if (!isOnRightSide)
|
|
|
|
start = -96, end = 16;
|
|
|
|
else
|
|
|
|
start = 256, end = 192;
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(menu->submenuLeftHeaderSprites); i++)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
menu->submenuLeftHeaderSprites[i]->y = startY;
|
|
|
|
MoveLeftHeader(menu->submenuLeftHeaderSprites[i], start, end, 12);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void HideLeftHeaderSprites(bool32 isOnRightSide)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-07-19 01:46:00 +01:00
|
|
|
s32 start, end, i;
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
|
|
|
if (!isOnRightSide)
|
|
|
|
start = 32, end = -96;
|
|
|
|
else
|
|
|
|
start = 192, end = 256;
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(menu->leftHeaderSprites); i++)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
MoveLeftHeader(menu->leftHeaderSprites[i], start, end, 12);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2019-07-19 01:46:00 +01:00
|
|
|
s32 start, end, i;
|
2021-11-12 17:40:36 +00:00
|
|
|
struct Pokenav_MainMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 19:40:35 +01:00
|
|
|
|
|
|
|
if (!isOnRightSide)
|
|
|
|
start = 16, end = -96;
|
|
|
|
else
|
|
|
|
start = 192, end = 256;
|
|
|
|
|
2021-11-12 17:40:36 +00:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(menu->submenuLeftHeaderSprites); i++)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-11-12 17:40:36 +00:00
|
|
|
MoveLeftHeader(menu->submenuLeftHeaderSprites[i], start, end, 12);
|
2019-04-07 19:40:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-19 01:46:00 +01:00
|
|
|
static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
2021-07-07 14:11:52 +01:00
|
|
|
sprite->x = startX;
|
2019-04-07 19:40:35 +01:00
|
|
|
sprite->data[0] = startX * 16;
|
|
|
|
sprite->data[1] = (endX - startX) * 16 / duration;
|
|
|
|
sprite->data[2] = duration;
|
|
|
|
sprite->data[7] = endX;
|
|
|
|
sprite->callback = SpriteCB_MoveLeftHeader;
|
|
|
|
}
|
|
|
|
|
2019-04-13 21:54:05 +01:00
|
|
|
static void SpriteCB_MoveLeftHeader(struct Sprite *sprite)
|
2019-04-07 19:40:35 +01:00
|
|
|
{
|
|
|
|
if (sprite->data[2] != 0)
|
|
|
|
{
|
|
|
|
sprite->data[2]--;
|
|
|
|
sprite->data[0] += sprite->data[1];
|
2021-07-07 14:11:52 +01:00
|
|
|
sprite->x = sprite->data[0] >> 4;
|
|
|
|
if (sprite->x < -16 || sprite->x > 256)
|
2019-04-07 19:40:35 +01:00
|
|
|
sprite->invisible = TRUE;
|
|
|
|
else
|
|
|
|
sprite->invisible = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 14:11:52 +01:00
|
|
|
sprite->x = sprite->data[7];
|
2019-04-07 19:40:35 +01:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|