2019-04-07 20:40:35 +02: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"
|
|
|
|
|
|
|
|
struct PokenavMainMenuResources
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
void (*loopTask)(u32);
|
|
|
|
u32 (*isLoopTaskActiveFunc)(void);
|
|
|
|
u32 unused;
|
2019-04-07 20:40:35 +02:00
|
|
|
u32 currentTaskId;
|
2019-12-07 10:08:21 +01:00
|
|
|
u32 helpBarWindowId;
|
2020-02-05 08:47:32 +01:00
|
|
|
u32 palettes;
|
2019-04-08 00:10:53 +02:00
|
|
|
struct Sprite *spinningPokenav;
|
2019-04-07 20:40:35 +02:00
|
|
|
struct Sprite *leftHeaderSprites[2];
|
|
|
|
struct Sprite *submenuLeftHeaderSprites[2];
|
|
|
|
u8 tilemapBuffer[0x800];
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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 22:54:05 +02:00
|
|
|
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);
|
2019-07-19 02:46:00 +02:00
|
|
|
static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration);
|
2019-04-13 22:54:05 +02:00
|
|
|
static void SpriteCB_MoveLeftHeader(struct Sprite *sprite);
|
|
|
|
static void InitPokenavMainMenuResources(void);
|
|
|
|
static void InitHoennMapHeaderSprites(void);
|
2019-12-07 10:08:21 +01:00
|
|
|
static void InitHelpBar(void);
|
2020-10-11 00:17:34 +02:00
|
|
|
static u32 LoopedTask_SlideMenuHeaderUp(s32 a0);
|
|
|
|
static u32 LoopedTask_SlideMenuHeaderDown(s32 a0);
|
2019-12-07 10:08:21 +01:00
|
|
|
static void DrawHelpBar(u32 windowId);
|
2019-04-13 22:54:05 +02:00
|
|
|
static void SpriteCB_SpinningPokenav(struct Sprite* sprite);
|
2019-07-19 02:46:00 +02:00
|
|
|
static u32 LoopedTask_InitPokenavMenu(s32 a0);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
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");
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
const struct BgTemplate gPokenavMainMenuBgTemplates[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 5,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
static const struct WindowTemplate sHelpBarWindowTemplate[] =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 22,
|
|
|
|
.width = 16,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.baseBlock = 0x36,
|
|
|
|
},
|
2019-12-07 10:08:21 +01:00
|
|
|
DUMMY_WIN_TEMPLATE
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
static const u8 *const sHelpBarTexts[HELPBAR_COUNT] =
|
|
|
|
{
|
|
|
|
[HELPBAR_NONE] = gText_Pokenav_ClearButtonList,
|
|
|
|
[HELPBAR_MAP_ZOOMED_OUT] = gText_PokenavMap_ZoomedOutButtons,
|
|
|
|
[HELPBAR_MAP_ZOOMED_IN] = gText_PokenavMap_ZoomedInButtons,
|
|
|
|
[HELPBAR_CONDITION_MON_LIST] = gText_PokenavCondition_MonListButtons,
|
|
|
|
[HELPBAR_CONDITION_MON_STATUS] = gText_PokenavCondition_MonStatusButtons,
|
|
|
|
[HELPBAR_CONDITION_MARKINGS] = gText_PokenavCondition_MarkingButtons,
|
|
|
|
[HELPBAR_MC_TRAINER_LIST] = gText_PokenavMatchCall_TrainerListButtons,
|
|
|
|
[HELPBAR_MC_CALL_MENU] = gText_PokenavMatchCall_CallMenuButtons,
|
|
|
|
[HELPBAR_MC_CHECK_PAGE] = gText_PokenavMatchCall_CheckTrainerButtons,
|
|
|
|
[HELPBAR_RIBBONS_MON_LIST] = gText_PokenavRibbons_MonListButtons,
|
|
|
|
[HELPBAR_RIBBONS_LIST] = gText_PokenavRibbons_RibbonListButtons,
|
|
|
|
[HELPBAR_RIBBONS_CHECK] = gText_PokenavRibbons_RibbonCheckButtons,
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
static const u8 sHelpBarTextColors[3] =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-04-10 04:39:34 +02:00
|
|
|
TEXT_COLOR_RED, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
static const struct CompressedSpriteSheet gSpinningPokenavSpriteSheet[] =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
{
|
2019-04-08 00:10:53 +02:00
|
|
|
.data = gSpinningPokenavGfx,
|
2019-04-07 20:40:35 +02:00
|
|
|
.size = 0x1000,
|
|
|
|
.tag = 0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-08 00:31:01 +02:00
|
|
|
static const struct SpritePalette gSpinningNavgearPalettes[] =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
{
|
2019-04-08 00:10:53 +02:00
|
|
|
.data = gSpinningPokenavPaletteData,
|
2019-04-07 20:40:35 +02:00
|
|
|
.tag = 0,
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2019-04-08 00:31:01 +02:00
|
|
|
static const struct CompressedSpriteSheet sPokenavHoennMapLeftHeaderSpriteSheet =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
.data = gPokenavLeftHeaderHoennMap_Gfx,
|
|
|
|
.size = 0xC00,
|
|
|
|
.tag = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CompressedSpriteSheet sPokenavMenuLeftHeaderSpriteSheets[] =
|
|
|
|
{
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_MAIN_MENU] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderMainMenu_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 3
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_CONDITION_MENU] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderCondition_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 1
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_RIBBONS_MENU] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderRibbons_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 2
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_MATCH_CALL_MENU] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderMatchCall_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 4
|
|
|
|
},
|
2020-02-05 08:47:32 +01:00
|
|
|
[POKENAV_GFX_MAP_MENU_ZOOMED_OUT] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderHoennMap_Gfx,
|
|
|
|
.size = 0x20,
|
|
|
|
.tag = 0
|
|
|
|
},
|
2020-02-05 08:47:32 +01:00
|
|
|
[POKENAV_GFX_MAP_MENU_ZOOMED_IN] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderHoennMap_Gfx,
|
|
|
|
.size = 0x40,
|
|
|
|
.tag = 0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CompressedSpriteSheetNoSize sPokenavSubMenuLeftHeaderSpriteSheets[] =
|
|
|
|
{
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_PARTY_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderParty_Gfx,
|
|
|
|
.tag = 1
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_SEARCH_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderSearch_Gfx,
|
|
|
|
.tag = 1
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_COOL_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderCool_Gfx,
|
|
|
|
.tag = 4
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_BEAUTY_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderBeauty_Gfx,
|
|
|
|
.tag = 1
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_CUTE_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderCute_Gfx,
|
|
|
|
.tag = 2
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_SMART_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderSmart_Gfx,
|
|
|
|
.tag = 0
|
|
|
|
},
|
2019-04-08 00:10:53 +02:00
|
|
|
[POKENAV_GFX_TOUGH_MENU - POKENAV_GFX_SUBMENUS_START] = {
|
2019-04-07 20:40:35 +02:00
|
|
|
.data = gPokenavLeftHeaderTough_Gfx,
|
|
|
|
.tag = 0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
static const struct OamData sSpinningPokenavSpriteOam =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-08 00:31:01 +02:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
|
|
|
.shape = SPRITE_SHAPE(32x32),
|
2019-04-07 20:40:35 +02:00
|
|
|
.x = 0,
|
2019-04-08 00:31:01 +02:00
|
|
|
.size = SPRITE_SIZE(32x32),
|
2019-04-07 20:40:35 +02:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
static const union AnimCmd sSpinningPokenavAnims[] =
|
2019-04-07 20:40:35 +02: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-08 00:10:53 +02:00
|
|
|
static const union AnimCmd *const sSpinningPokenavAnimTable[] =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-04-08 00:10:53 +02:00
|
|
|
sSpinningPokenavAnims
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
static const struct SpriteTemplate sSpinningPokenavSpriteTemplate =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
.tileTag = 0,
|
|
|
|
.paletteTag = 0,
|
2019-04-08 00:10:53 +02:00
|
|
|
.oam = &sSpinningPokenavSpriteOam,
|
|
|
|
.anims = sSpinningPokenavAnimTable,
|
2019-04-07 20:40:35 +02:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2019-04-08 00:10:53 +02:00
|
|
|
.callback = SpriteCB_SpinningPokenav
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2019-04-08 00:31:01 +02:00
|
|
|
static const struct OamData sPokenavLeftHeaderHoennMapSpriteOam =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-08 00:31:01 +02:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
|
|
|
.shape = SPRITE_SHAPE(64x32),
|
2019-04-07 20:40:35 +02:00
|
|
|
.x = 0,
|
2019-04-08 00:31:01 +02:00
|
|
|
.size = SPRITE_SIZE(64x32),
|
2019-04-07 20:40:35 +02:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct OamData sUnknown_0861FB24 =
|
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-08 00:31:01 +02:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2019-12-04 21:25:13 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-04-08 00:31:01 +02:00
|
|
|
.shape = SPRITE_SHAPE(32x16),
|
2019-04-07 20:40:35 +02:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-04-08 00:31:01 +02:00
|
|
|
.size = SPRITE_SIZE(32x16),
|
2019-04-07 20:40:35 +02:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2019-04-08 00:31:01 +02:00
|
|
|
static const struct SpriteTemplate sPokenavLeftHeaderHoennMapSpriteTemplate =
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
.tileTag = 2,
|
|
|
|
.paletteTag = 1,
|
2019-04-08 00:31:01 +02:00
|
|
|
.oam = &sPokenavLeftHeaderHoennMapSpriteOam,
|
2019-04-07 20:40:35 +02:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpriteTemplate sUnknown_0861FB44 =
|
|
|
|
{
|
|
|
|
.tileTag = 2,
|
|
|
|
.paletteTag = 2,
|
|
|
|
.oam = &sUnknown_0861FB24,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
|
|
|
bool32 InitPokenavMainMenu(void)
|
|
|
|
{
|
|
|
|
struct PokenavMainMenuResources *structPtr;
|
2020-09-02 15:49:04 +02:00
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct PokenavMainMenuResources));
|
2019-04-07 20:40:35 +02:00
|
|
|
if (structPtr == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
structPtr->currentTaskId = CreateLoopedTask(LoopedTask_InitPokenavMenu, 1);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 PokenavMainMenuLoopedTaskIsActive(void)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
return IsLoopedTaskActive(structPtr->currentTaskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShutdownPokenav(void)
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_POKENAV_OFF);
|
2020-10-11 00:17:34 +02:00
|
|
|
ResetBldCnt_();
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 16, RGB_BLACK);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool32 WaitForPokenavShutdownFade(void)
|
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-02-05 08:47:32 +01:00
|
|
|
FreeMenuHandlerSubstruct2();
|
2019-04-07 20:40:35 +02:00
|
|
|
CleanupPokenavMainMenuResources();
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
static u32 LoopedTask_InitPokenavMenu(s32 a0)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
struct PokenavMainMenuResources *structPtr;
|
|
|
|
|
|
|
|
switch (a0)
|
|
|
|
{
|
|
|
|
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 10:37:09 +02:00
|
|
|
ResetTempTileDataBuffers();
|
2019-04-07 20:40:35 +02:00
|
|
|
return LT_INC_AND_CONTINUE;
|
|
|
|
case 1:
|
2020-10-11 00:17:34 +02:00
|
|
|
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2020-05-14 10:37:09 +02:00
|
|
|
DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0);
|
2019-04-07 20:40:35 +02:00
|
|
|
SetBgTilemapBuffer(0, structPtr->tilemapBuffer);
|
|
|
|
CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0);
|
|
|
|
CopyPaletteIntoBufferUnfaded(gPokenavHeader_Pal, 0, 0x20);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 2:
|
2020-05-14 10:37:09 +02:00
|
|
|
if (FreeTempTileDataBuffersIfPossible())
|
2019-04-07 20:40:35 +02:00
|
|
|
return LT_PAUSE;
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
InitHelpBar();
|
2019-04-07 20:40:35 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 3:
|
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
|
|
|
return LT_PAUSE;
|
|
|
|
|
|
|
|
InitPokenavMainMenuResources();
|
2019-04-08 00:31:01 +02:00
|
|
|
InitHoennMapHeaderSprites();
|
2019-04-07 20:40:35 +02:00
|
|
|
ShowBg(0);
|
|
|
|
return LT_FINISH;
|
|
|
|
default:
|
|
|
|
return LT_FINISH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void SetActiveMenuLoopTasks(void *createLoopTask, void *isLoopTaskActive) // Fix types later.
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
structPtr->loopTask = createLoopTask;
|
|
|
|
structPtr->isLoopTaskActiveFunc = isLoopTaskActive;
|
|
|
|
structPtr->unused = 0;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void RunMainMenuLoopedTask(u32 a0)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
structPtr->unused = 0;
|
|
|
|
structPtr->loopTask(a0);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
u32 IsActiveMenuLoopTaskActive(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
return structPtr->isLoopTaskActiveFunc();
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void SlideMenuHeaderUp(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void SlideMenuHeaderDown(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
|
|
|
structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool32 MainMenuLoopedTaskIsBusy(void)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
return IsLoopedTaskActive(structPtr->currentTaskId);
|
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
static u32 LoopedTask_SlideMenuHeaderUp(s32 a0)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
switch (a0)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return LT_FINISH;
|
|
|
|
case 1:
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 0:
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 2:
|
|
|
|
if (ChangeBgY(0, 384, 1) >= 0x2000u)
|
|
|
|
{
|
|
|
|
ChangeBgY(0, 0x2000, 0);
|
|
|
|
return LT_FINISH;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LT_PAUSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
static u32 LoopedTask_SlideMenuHeaderDown(s32 a0)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
if (ChangeBgY(0, 384, 2) <= 0)
|
|
|
|
{
|
|
|
|
ChangeBgY(0, 0, 0);
|
2020-11-03 00:43:11 +01:00
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2020-11-03 00:43:11 +01:00
|
|
|
return LT_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size)
|
|
|
|
{
|
|
|
|
CpuCopy16(palette, gPlttBufferUnfaded + bufferOffset, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 09:22:50 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
index = (index * 16) + 0x100;
|
|
|
|
CopyPaletteIntoBufferUnfaded(current->data, index, 0x20);
|
|
|
|
}
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void PokenavFillPalette(u32 palIndex, u16 fillValue)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
CpuFill16(fillValue, gPlttBufferFaded + 0x100 + (palIndex * 16), 16 * sizeof(u16));
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a4, u16 *palette)
|
2020-10-24 04:07:30 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
if (a4 == 0)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
CpuCopy16(src, palette, size * 2);
|
2020-10-24 04:07:30 +02:00
|
|
|
}
|
|
|
|
else if (a4 >= a3)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
CpuCopy16(dest, palette, size * 2);
|
2020-10-24 04:07:30 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int r, g, b;
|
|
|
|
int r1, g1, b1;
|
2020-10-11 00:17:34 +02:00
|
|
|
while (size--)
|
2020-10-24 04:07:30 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
r = GET_R(*src);
|
|
|
|
g = GET_G(*src);
|
|
|
|
b = GET_B(*src);
|
2020-10-24 04:07:30 +02:00
|
|
|
|
2020-10-11 00:17:34 +02: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 04:07:30 +02:00
|
|
|
|
2021-01-19 18:15:12 +01:00
|
|
|
r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match; I have to assign the value of ((r + r1) & 0x1F) to r
|
2020-10-24 04:07:30 +02:00
|
|
|
g = (g + g1) & 0x1F; //See above
|
|
|
|
b = (b + b1) & 0x1F; //See above
|
|
|
|
|
|
|
|
*palette = RGB2(r, g, b); //See above comment
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
src++, dest++;
|
2020-10-24 04:07:30 +02:00
|
|
|
palette++;
|
|
|
|
}
|
|
|
|
}
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
void PokenavFadeScreen(s32 fadeType)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
switch (fadeType)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2020-02-05 08:47:32 +01:00
|
|
|
BeginNormalPaletteFade(structPtr->palettes, -2, 0, 16, RGB_BLACK);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-02-05 08:47:32 +01:00
|
|
|
BeginNormalPaletteFade(structPtr->palettes, -2, 16, 0, RGB_BLACK);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -2, 16, 0, RGB_BLACK);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool32 IsPaletteFadeActive(void)
|
|
|
|
{
|
|
|
|
return gPaletteFade.active;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81C7B40(void)
|
|
|
|
{
|
2021-02-24 17:01:02 +01:00
|
|
|
BlendPalettes(PALETTES_ALL & ~(0x10000 | 0x1), 16, RGB_BLACK);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
void InitBgTemplates(const struct BgTemplate *templates, int count)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-04-13 22:54:05 +02:00
|
|
|
int i;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
InitBgFromTemplate(templates++);
|
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
static void InitHelpBar(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
InitWindows(&sHelpBarWindowTemplate[0]);
|
|
|
|
structPtr->helpBarWindowId = 0;
|
|
|
|
DrawHelpBar(structPtr->helpBarWindowId);
|
|
|
|
PutWindowTilemap(structPtr->helpBarWindowId);
|
|
|
|
CopyWindowToVram(structPtr->helpBarWindowId, 3); // TODO: Use a defined constant here.
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
void PrintHelpBarText(u32 textId)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
DrawHelpBar(structPtr->helpBarWindowId);
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized3(structPtr->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
bool32 WaitForHelpBar(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
static void DrawHelpBar(u32 windowId)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(4));
|
|
|
|
FillWindowPixelRect(windowId, PIXEL_FILL(5), 0, 0, 0x80, 1);
|
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
static void InitPokenavMainMenuResources(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-07-19 02:46:00 +02:00
|
|
|
s32 i;
|
2019-04-07 20:40:35 +02:00
|
|
|
u8 spriteId;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(gSpinningPokenavSpriteSheet); i++)
|
|
|
|
LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-04-08 00:31:01 +02:00
|
|
|
Pokenav_AllocAndLoadPalettes(gSpinningNavgearPalettes);
|
2020-02-05 08:47:32 +01:00
|
|
|
structPtr->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0));
|
2019-04-08 00:10:53 +02:00
|
|
|
spriteId = CreateSprite(&sSpinningPokenavSpriteTemplate, 220, 12, 0);
|
|
|
|
structPtr->spinningPokenav = &gSprites[spriteId];
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
static void CleanupPokenavMainMenuResources(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
DestroySprite(structPtr->spinningPokenav);
|
2019-04-07 20:40:35 +02:00
|
|
|
FreeSpriteTilesByTag(0);
|
|
|
|
FreeSpritePaletteByTag(0);
|
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
static void SpriteCB_SpinningPokenav(struct Sprite *sprite)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
// If the background starts scrolling, follow it.
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = (GetBgY(0) / 256u) * -1;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
struct Sprite *PauseSpinningPokenavSprite(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
structPtr->spinningPokenav->callback = SpriteCallbackDummy;
|
|
|
|
return structPtr->spinningPokenav;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-04-08 00:10:53 +02:00
|
|
|
void ResumeSpinningPokenavSprite(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
structPtr->spinningPokenav->x = 220;
|
|
|
|
structPtr->spinningPokenav->y = 12;
|
2019-04-08 00:10:53 +02:00
|
|
|
structPtr->spinningPokenav->callback = SpriteCB_SpinningPokenav;
|
|
|
|
structPtr->spinningPokenav->invisible = FALSE;
|
|
|
|
structPtr->spinningPokenav->oam.priority = 0;
|
|
|
|
structPtr->spinningPokenav->subpriority = 0;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
static void InitHoennMapHeaderSprites(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-07-19 02:46:00 +02:00
|
|
|
s32 i, spriteId;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-04-08 00:31:01 +02:00
|
|
|
LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet);
|
2019-04-07 20:40:35 +02:00
|
|
|
AllocSpritePalette(1);
|
|
|
|
AllocSpritePalette(2);
|
2019-07-19 02:46:00 +02:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-04-08 00:31:01 +02:00
|
|
|
spriteId = CreateSprite(&sPokenavLeftHeaderHoennMapSpriteTemplate, 0, 0, 1);
|
2019-04-07 20:40:35 +02:00
|
|
|
structPtr->leftHeaderSprites[i] = &gSprites[spriteId];
|
|
|
|
structPtr->leftHeaderSprites[i]->invisible = TRUE;
|
2021-07-07 15:11:52 +02:00
|
|
|
structPtr->leftHeaderSprites[i]->x2 = i * 64;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
spriteId = CreateSprite(&sUnknown_0861FB44, 0, 0, 2);
|
|
|
|
structPtr->submenuLeftHeaderSprites[i] = &gSprites[spriteId];
|
|
|
|
structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE;
|
2021-07-07 15:11:52 +02:00
|
|
|
structPtr->submenuLeftHeaderSprites[i]->x2 = i * 32;
|
|
|
|
structPtr->submenuLeftHeaderSprites[i]->y2 = 18;
|
2019-04-07 20:40:35 +02:00
|
|
|
structPtr->submenuLeftHeaderSprites[i]->oam.tileNum += (i * 8) + 64;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
void LoadLeftHeaderGfxForIndex(u32 menuGfxId)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-02-05 08:47:32 +01:00
|
|
|
if (menuGfxId < POKENAV_GFX_SUBMENUS_START)
|
|
|
|
LoadLeftHeaderGfxForMenu(menuGfxId);
|
2019-04-07 20:40:35 +02:00
|
|
|
else
|
2020-02-05 08:47:32 +01:00
|
|
|
LoadLeftHeaderGfxForSubMenu(menuGfxId - POKENAV_GFX_SUBMENUS_START);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void UpdateRegionMapRightHeaderTiles(u32 menuGfxId)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT)
|
2019-04-07 20:40:35 +02:00
|
|
|
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32;
|
|
|
|
else
|
|
|
|
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64;
|
|
|
|
}
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
static void LoadLeftHeaderGfxForMenu(u32 menuGfxId)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
struct PokenavMainMenuResources *structPtr;
|
|
|
|
u32 size, tag;
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
if (menuGfxId >= POKENAV_GFX_SUBMENUS_START)
|
2019-04-07 20:40:35 +02:00
|
|
|
return;
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2020-02-05 08:47:32 +01:00
|
|
|
tag = sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].tag;
|
|
|
|
size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data);
|
2019-04-07 20:40:35 +02:00
|
|
|
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20);
|
2020-02-05 08:47:32 +01:00
|
|
|
LZ77UnCompWram(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer);
|
2020-11-03 00:43:11 +01:00
|
|
|
RequestDma3Copy(gDecompressionBuffer, (void *)OBJ_VRAM0 + (GetSpriteTileStartByTag(2) * 32), size, 1);
|
2020-02-05 08:47:32 +01:00
|
|
|
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].size;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT || menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_IN)
|
2021-07-07 15:11:52 +02:00
|
|
|
structPtr->leftHeaderSprites[1]->x2 = 56;
|
2019-04-07 20:40:35 +02:00
|
|
|
else
|
2021-07-07 15:11:52 +02:00
|
|
|
structPtr->leftHeaderSprites[1]->x2 = 64;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
u32 size, tag;
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
if (menuGfxId >= POKENAV_GFX_MENUS_END - POKENAV_GFX_SUBMENUS_START)
|
2019-04-07 20:40:35 +02:00
|
|
|
return;
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
tag = sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].tag;
|
|
|
|
size = GetDecompressedDataSize(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data);
|
2019-04-07 20:40:35 +02:00
|
|
|
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(2) * 16) + 0x100, 0x20);
|
2020-02-05 08:47:32 +01:00
|
|
|
LZ77UnCompWram(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data, &gDecompressionBuffer[0x1000]);
|
2021-03-30 21:07:04 +02:00
|
|
|
RequestDma3Copy(&gDecompressionBuffer[0x1000], (void *)OBJ_VRAM0 + 0x800 + (GetSpriteTileStartByTag(2) * 32), size, 1);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void ShowLeftHeaderGfx(u32 menuGfxId, bool32 isMain, bool32 isOnRightSide)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
u32 tileTop;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
if (!isMain)
|
|
|
|
tileTop = 0x30;
|
2019-04-07 20:40:35 +02:00
|
|
|
else
|
2020-10-11 00:17:34 +02:00
|
|
|
tileTop = 0x10;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
if (menuGfxId < POKENAV_GFX_SUBMENUS_START)
|
2020-10-11 00:17:34 +02:00
|
|
|
ShowLeftHeaderSprites(tileTop, isOnRightSide);
|
2019-04-07 20:40:35 +02:00
|
|
|
else
|
2020-10-11 00:17:34 +02:00
|
|
|
ShowLeftHeaderSubmenuSprites(tileTop, isOnRightSide);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
if (id < POKENAV_GFX_PARTY_MENU)
|
|
|
|
HideLeftHeaderSprites(onRightSide);
|
2019-04-07 20:40:35 +02:00
|
|
|
else
|
2020-10-11 00:17:34 +02:00
|
|
|
HideLeftHeaderSubmenuSprites(onRightSide);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void SetLeftHeaderSpritesInvisibility(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-07-19 02:46:00 +02:00
|
|
|
s32 i;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
structPtr->leftHeaderSprites[i]->invisible = TRUE;
|
|
|
|
structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
bool32 AreLeftHeaderSpritesMoving(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (structPtr->leftHeaderSprites[0]->callback == SpriteCallbackDummy && structPtr->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy)
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-07-19 02:46:00 +02:00
|
|
|
s32 start, end, i;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (!isOnRightSide)
|
|
|
|
start = -96, end = 32;
|
|
|
|
else
|
|
|
|
start = 256, end = 160;
|
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
structPtr->leftHeaderSprites[i]->y = startY;
|
2019-04-07 20:40:35 +02:00
|
|
|
MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-07-19 02:46:00 +02:00
|
|
|
s32 start, end, i;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (!isOnRightSide)
|
|
|
|
start = -96, end = 16;
|
|
|
|
else
|
|
|
|
start = 256, end = 192;
|
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
structPtr->submenuLeftHeaderSprites[i]->y = startY;
|
2019-04-07 20:40:35 +02:00
|
|
|
MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
static void HideLeftHeaderSprites(bool32 isOnRightSide)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-07-19 02:46:00 +02:00
|
|
|
s32 start, end, i;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (!isOnRightSide)
|
|
|
|
start = 32, end = -96;
|
|
|
|
else
|
|
|
|
start = 192, end = 256;
|
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-13 22:54:05 +02:00
|
|
|
static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-07-19 02:46:00 +02:00
|
|
|
s32 start, end, i;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (!isOnRightSide)
|
|
|
|
start = 16, end = -96;
|
|
|
|
else
|
|
|
|
start = 192, end = 256;
|
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = startX;
|
2019-04-07 20:40:35 +02: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 22:54:05 +02:00
|
|
|
static void SpriteCB_MoveLeftHeader(struct Sprite *sprite)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
if (sprite->data[2] != 0)
|
|
|
|
{
|
|
|
|
sprite->data[2]--;
|
|
|
|
sprite->data[0] += sprite->data[1];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sprite->data[0] >> 4;
|
|
|
|
if (sprite->x < -16 || sprite->x > 256)
|
2019-04-07 20:40:35 +02:00
|
|
|
sprite->invisible = TRUE;
|
|
|
|
else
|
|
|
|
sprite->invisible = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sprite->data[7];
|
2019-04-07 20:40:35 +02:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|