pokeemerald/src/pokenav_conditions_2.c

886 lines
28 KiB
C
Raw Normal View History

2019-07-20 04:06:42 +02:00
#include "global.h"
#include "bg.h"
#include "window.h"
#include "pokenav.h"
2019-07-24 17:02:52 +02:00
#include "decompress.h"
#include "gpu_regs.h"
#include "graphics.h"
#include "menu.h"
#include "menu_specialized.h"
#include "mon_markings.h"
#include "palette.h"
#include "pokenav.h"
#include "scanline_effect.h"
#include "string_util.h"
#include "strings.h"
#include "text.h"
2019-07-20 04:06:42 +02:00
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_TransitionMons(s32);
static u32 LoopedTask_ExitPartyConditionMenu(s32);
static u32 LoopedTask_MoveCursorNoTransition(s32);
static u32 LoopedTask_SlideMonOut(s32);
static u32 LoopedTask_OpenMonMarkingsWindow(s32);
static u32 LoopedTask_CloseMonMarkingsWindow(s32);
2019-07-20 04:06:42 +02:00
2021-11-10 02:02:12 +01:00
static u8 sUnknown_030012BC;
2019-07-20 18:30:41 +02:00
2020-08-10 19:48:16 +02:00
const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal");
2020-08-10 23:05:42 +02:00
const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal");
2021-11-10 02:02:12 +01:00
static const u32 sUnknown_08623228[] = INCBIN_U32("graphics/pokenav/condition/graph_data.4bpp.lz");
static const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz");
static const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal");
2019-07-20 04:06:42 +02:00
2021-11-10 02:02:12 +01:00
static const struct BgTemplate sPartyConditionBgTemplates[3] =
2019-07-20 04:06:42 +02:00
{
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 0x1F,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 3,
.mapBaseIndex = 0x1D,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 2,
.mapBaseIndex = 0x1E,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
}
};
2021-11-10 02:02:12 +01:00
static const struct WindowTemplate sMonNameGenderWindowTemplate =
2019-07-20 04:06:42 +02:00
{
.bg = 1,
.tilemapLeft = 13,
.tilemapTop = 1,
.width = 13,
.height = 4,
.paletteNum = 15,
.baseBlock = 2
};
2021-11-10 02:02:12 +01:00
static const struct WindowTemplate sConditionGraphListIdWindowTemplate =
2019-07-20 04:06:42 +02:00
{
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 6,
.width = 7,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x36
};
2021-11-10 02:02:12 +01:00
static const struct WindowTemplate sUnusedWindowTemplate1 =
2019-07-20 04:06:42 +02:00
{
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 0x1C,
.width = 5,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x44
};
2021-11-10 02:02:12 +01:00
static const struct WindowTemplate sUnusedWindowTemplate2 =
2019-07-20 04:06:42 +02:00
{
.bg = 1,
.tilemapLeft = 13,
.tilemapTop = 0x1C,
.width = 3,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x44
};
2021-11-10 02:02:12 +01:00
static const LoopedTask sPartyConditionLoopedTaskFuncs[] =
2019-07-20 04:06:42 +02:00
{
[PARTY_CONDITION_FUNC_NONE] = NULL,
[PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons,
[PARTY_CONDITION_FUNC_RETURN] = LoopedTask_ExitPartyConditionMenu,
[PARTY_CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition,
[PARTY_CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut,
[PARTY_CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow,
2020-10-11 00:17:34 +02:00
[PARTY_CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow
2019-07-20 04:06:42 +02:00
};
2019-07-29 19:06:45 +02:00
2019-07-24 17:02:52 +02:00
struct Pokenav7Struct
{
u32 loopedTaskId;
u8 tilemapBuffers[3][BG_SCREEN_SIZE];
u8 filler[2];
2020-10-11 00:17:34 +02:00
u8 partyPokeballSpriteIds[10];
u32 (*callback)(void);
s16 monTransitionX;
u8 monPicSpriteId;
u16 monPalIndex;
u16 monGfxTileStart;
2019-07-24 17:02:52 +02:00
void *unk181C;
2020-10-11 00:17:34 +02:00
u8 nameGenderWindowId;
u8 listIndexWindowId;
u8 unusedWindowId1;
u8 unusedWindowId2;
2021-11-10 02:02:12 +01:00
struct MonMarkingsMenu marksMenu;
2020-10-11 00:17:34 +02:00
struct Sprite *monMarksSprite;
struct Sprite *conditionSparkleSprites[MAX_CONDITION_SPARKLES];
u8 windowModeState;
2021-11-10 02:02:12 +01:00
u8 filler2[0xFA3];
2019-07-24 17:02:52 +02:00
};
extern s8 GetMonMarkIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c
2019-07-25 18:56:08 +02:00
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_OpenPartyConditionGraph(s32 state);
static u32 GetPartyConditionLoopedTaskActive(void);
static void CreateConditionMonPic(u8 var);
static void CreateMonMarkingsOrPokeballIndicators(void);
static void CopyUnusedConditionWindowsToVram(void);
static bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2);
2021-11-11 00:52:30 +01:00
static void VBlankCB_PokenavConditionGraph(void);
2021-11-10 02:02:12 +01:00
static void DoConditionGraphTransition(void);
static void sub_81CEEC8(void);
static void sub_81CEE68(void);
static void ToggleGraphData(bool8 showBg);
2019-07-24 17:02:52 +02:00
// code
2020-10-11 00:17:34 +02:00
bool32 OpenPartyConditionMenu(void)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU, sizeof(struct Pokenav7Struct));
2019-07-24 17:02:52 +02:00
if (structPtr == NULL)
return FALSE;
2021-02-20 06:30:37 +01:00
structPtr->monPicSpriteId = SPRITE_NONE;
2020-10-11 00:17:34 +02:00
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenPartyConditionGraph, 1);
structPtr->callback = GetPartyConditionLoopedTaskActive;
structPtr->windowModeState = 0;
2019-07-24 17:02:52 +02:00
return TRUE;
}
2020-10-11 00:17:34 +02:00
void CreatePartyConditionLoopedTask(s32 id)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
structPtr->loopedTaskId = CreateLoopedTask(sPartyConditionLoopedTaskFuncs[id], 1);
structPtr->callback = GetPartyConditionLoopedTaskActive;
2019-07-24 17:02:52 +02:00
}
2020-10-11 00:17:34 +02:00
u32 IsPartyConditionLoopedTaskActive(void)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
return structPtr->callback();
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static u32 GetPartyConditionLoopedTaskActive(void)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
return IsLoopedTaskActive(structPtr->loopedTaskId);
}
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_OpenPartyConditionGraph(s32 state)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
if (LoadPartyConditionMenuGfx() != TRUE)
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 1:
2020-10-11 00:17:34 +02:00
InitBgTemplates(sPartyConditionBgTemplates, ARRAY_COUNT(sPartyConditionBgTemplates));
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-07-24 17:02:52 +02:00
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
2020-05-14 10:37:09 +02:00
DecompressAndCopyTileDataToVram(3, gPokenavCondition_Gfx, 0, 0, 0);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 2:
2020-05-14 10:37:09 +02:00
if (FreeTempTileDataBuffersIfPossible())
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
2021-11-10 02:02:12 +01:00
DecompressAndCopyTileDataToVram(2, sUnknown_08623228, 0, 0, 0);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 3:
2020-05-14 10:37:09 +02:00
if (FreeTempTileDataBuffersIfPossible())
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
LZ77UnCompVram(gPokenavCondition_Tilemap, structPtr->tilemapBuffers[0]);
SetBgTilemapBuffer(3, structPtr->tilemapBuffers[0]);
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
CopyToBgTilemapBufferRect(3, gPokenavOptions_Tilemap, 0, 5, 9, 4);
CopyBgTilemapBufferToVram(3);
CopyPaletteIntoBufferUnfaded(gPokenavCondition_Pal, 0x10, 0x20);
2020-08-10 23:05:42 +02:00
CopyPaletteIntoBufferUnfaded(gConditionText_Pal, 0xF0, 0x20);
2020-10-11 00:17:34 +02:00
structPtr->monTransitionX = -80;
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 4:
2020-05-14 10:37:09 +02:00
if (FreeTempTileDataBuffersIfPossible())
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
2020-10-11 00:17:34 +02:00
LZ77UnCompVram(sConditionGraph_Tilemap, structPtr->tilemapBuffers[2]);
2019-07-24 17:02:52 +02:00
SetBgTilemapBuffer(2, structPtr->tilemapBuffers[2]);
CopyBgTilemapBufferToVram(2);
2020-08-10 19:48:16 +02:00
CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, 0x30, 0x20);
2021-11-11 00:52:30 +01:00
ConditionGraph_InitWindow(2);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 5:
2021-11-04 04:20:59 +01:00
BgDmaFill(1, 0, 0, 1);
BgDmaFill(1, 17, 1, 1);
2019-07-24 17:02:52 +02:00
CpuFill32(0, structPtr->tilemapBuffers[1], BG_SCREEN_SIZE);
SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 6:
2020-05-14 10:37:09 +02:00
if (FreeTempTileDataBuffersIfPossible())
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
2020-10-11 00:17:34 +02:00
structPtr->nameGenderWindowId = AddWindow(&sMonNameGenderWindowTemplate);
if (IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
structPtr->listIndexWindowId = AddWindow(&sConditionGraphListIdWindowTemplate);
structPtr->unusedWindowId1 = AddWindow(&sUnusedWindowTemplate1);
structPtr->unusedWindowId2 = AddWindow(&sUnusedWindowTemplate2);
2019-07-24 17:02:52 +02:00
}
DeactivateAllTextPrinters();
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 7:
2020-10-11 00:17:34 +02:00
CreateConditionMonPic(0);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 8:
2020-10-11 00:17:34 +02:00
CreateMonMarkingsOrPokeballIndicators();
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 9:
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() == TRUE)
CopyUnusedConditionWindowsToVram();
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 10:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(0, GetMonMarkIndex(), TRUE);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 11:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(1, GetMonMarkIndex(), TRUE);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 12:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(2, GetMonMarkIndex(), TRUE);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 13:
2020-10-11 00:17:34 +02:00
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), TRUE) != TRUE)
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
PutWindowTilemap(structPtr->nameGenderWindowId);
if (IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
PutWindowTilemap(structPtr->listIndexWindowId);
PutWindowTilemap(structPtr->unusedWindowId1);
PutWindowTilemap(structPtr->unusedWindowId2);
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 14:
ShowBg(1);
HideBg(2);
ShowBg(3);
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() == TRUE)
2019-12-07 10:08:21 +01:00
PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS);
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 15:
2020-02-05 08:47:32 +01:00
PokenavFadeScreen(1);
2020-10-11 00:17:34 +02:00
if (!IsConditionMenuSearchMode())
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
LoadLeftHeaderGfxForIndex(POKENAV_GFX_PARTY_MENU);
ShowLeftHeaderGfx(POKENAV_GFX_CONDITION_MENU, TRUE, 0);
ShowLeftHeaderGfx(POKENAV_GFX_PARTY_MENU, TRUE, 0);
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 16:
if (IsPaletteFadeActive())
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
2020-10-11 00:17:34 +02:00
if (!IsConditionMenuSearchMode() && AreLeftHeaderSpritesMoving())
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
2021-11-11 00:52:30 +01:00
SetVBlankCallback_(VBlankCB_PokenavConditionGraph);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 17:
2020-10-11 00:17:34 +02:00
DoConditionGraphTransition();
2021-11-11 00:52:30 +01:00
ConditionGraph_InitResetScanline(GetConditionGraphPtr());
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 18:
2021-11-11 00:52:30 +01:00
if (ConditionGraph_ResetScanline(GetConditionGraphPtr()))
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 19:
2021-11-10 02:02:12 +01:00
ToggleGraphData(TRUE);
2019-12-07 10:08:21 +01:00
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 20:
2021-11-11 00:52:30 +01:00
if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &structPtr->monTransitionX))
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount())
2021-11-10 02:02:12 +01:00
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles());
2019-07-24 17:02:52 +02:00
2019-12-07 10:08:21 +01:00
return LT_FINISH;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_FINISH;
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_ExitPartyConditionMenu(s32 state)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
switch (state)
{
case 0:
sub_81CEEC8();
2020-10-11 00:17:34 +02:00
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 1:
2021-11-11 00:52:30 +01:00
if (ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &structPtr->monTransitionX))
2019-07-24 17:02:52 +02:00
return 2;
2021-11-10 02:02:12 +01:00
ToggleGraphData(FALSE);
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 2:
2020-02-05 08:47:32 +01:00
PokenavFadeScreen(0);
2020-10-11 00:17:34 +02:00
if (!IsConditionMenuSearchMode())
SlideMenuHeaderDown();
return LT_INC_AND_PAUSE;
2019-07-24 17:02:52 +02:00
case 3:
if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy())
2020-10-11 00:17:34 +02:00
return LT_PAUSE;
FreeConditionSparkles(structPtr->conditionSparkleSprites);
2019-07-24 17:02:52 +02:00
HideBg(1);
HideBg(2);
HideBg(3);
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_FINISH;
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_TransitionMons(s32 state)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2021-11-11 00:52:30 +01:00
struct ConditionGraph *graph = GetConditionGraphPtr();
2019-07-24 17:02:52 +02:00
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(0);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 1:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(1);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 2:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(2);
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 3:
2021-11-11 00:52:30 +01:00
ConditionGraph_TryUpdate(graph);
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 4:
2020-10-11 00:17:34 +02:00
if (!MoveConditionMonOffscreen(&structPtr->monTransitionX))
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
CreateConditionMonPic(GetMonMarkIndex());
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
}
2020-10-11 00:17:34 +02:00
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
case 5:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 6:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 7:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 8:
2020-10-11 00:17:34 +02:00
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
case 9:
2021-11-11 00:52:30 +01:00
graph = GetConditionGraphPtr();
if (!ConditionMenu_UpdateMonEnter(graph, &structPtr->monTransitionX))
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount())
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
2021-11-10 02:02:12 +01:00
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles());
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
}
2020-10-11 00:17:34 +02:00
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_FINISH;
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_MoveCursorNoTransition(s32 state)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(0);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 1:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(1);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 2:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(2);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 3:
2020-10-11 00:17:34 +02:00
CreateConditionMonPic(GetMonMarkIndex());
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 4:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 5:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 6:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 7:
2020-10-11 00:17:34 +02:00
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
case 8:
2021-11-11 00:52:30 +01:00
if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &structPtr->monTransitionX))
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
2021-11-10 02:02:12 +01:00
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles());
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
}
2020-10-11 00:17:34 +02:00
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_FINISH;
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_SlideMonOut(s32 state)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
switch (state)
{
case 0:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(0);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 1:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(1);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 2:
2020-10-11 00:17:34 +02:00
SetConditionGraphData(2);
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 3:
2021-11-11 00:52:30 +01:00
if (!ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &structPtr->monTransitionX))
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
case 4:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 5:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 6:
2020-10-11 00:17:34 +02:00
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE);
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 7:
2020-10-11 00:17:34 +02:00
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_FINISH;
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_OpenMonMarkingsWindow(s32 state)
2019-07-24 17:02:52 +02:00
{
switch (state)
{
case 0:
2021-02-28 23:22:26 +01:00
OpenMonMarkingsMenu(TryGetMonMarkId(), 176, 32);
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 1:
2019-12-07 10:08:21 +01:00
PrintHelpBarText(HELPBAR_CONDITION_MARKINGS);
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 2:
2019-12-07 10:08:21 +01:00
if (WaitForHelpBar() == TRUE)
2020-10-11 00:17:34 +02:00
return LT_PAUSE;
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_FINISH;
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static u32 LoopedTask_CloseMonMarkingsWindow(s32 state)
2019-07-24 17:02:52 +02:00
{
switch (state)
{
case 0:
2021-02-28 23:22:26 +01:00
FreeMonMarkingsMenu();
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 1:
2019-12-07 10:08:21 +01:00
PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS);
2020-10-11 00:17:34 +02:00
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
case 2:
2019-12-07 10:08:21 +01:00
if (WaitForHelpBar() == TRUE)
2020-10-11 00:17:34 +02:00
return LT_PAUSE;
return LT_INC_AND_CONTINUE;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
return LT_FINISH;
2019-07-24 17:02:52 +02:00
}
2019-12-07 10:08:21 +01:00
static u8 *UnusedPrintNumberString(u8 *dst, u16 num)
2019-07-24 17:02:52 +02:00
{
u8 *txtPtr = ConvertIntToDecimalStringN(dst, num, STR_CONV_MODE_RIGHT_ALIGN, 4);
txtPtr = StringCopy(txtPtr, gText_Number2);
return txtPtr;
}
2021-11-10 02:02:12 +01:00
static bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode)
2019-07-24 17:02:52 +02:00
{
u8 text[32];
const u8 *str;
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
2020-10-11 00:17:34 +02:00
switch (mode)
2019-07-24 17:02:52 +02:00
{
case 0:
2020-10-11 00:17:34 +02:00
FillWindowPixelBuffer(structPtr->nameGenderWindowId, 0);
if (IsConditionMenuSearchMode() == TRUE)
FillWindowPixelBuffer(structPtr->listIndexWindowId, 0);
2019-07-24 17:02:52 +02:00
break;
case 1:
2020-10-11 00:17:34 +02:00
if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
{
2021-11-10 02:02:12 +01:00
str = GetConditionMonNameText(bufferIndex);
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL);
2019-07-24 17:02:52 +02:00
}
break;
case 2:
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
{
2021-11-10 02:02:12 +01:00
str = GetConditionMonLocationText(bufferIndex);
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL);
2019-07-24 17:02:52 +02:00
text[0] = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
text[2] = TEXT_COLOR_BLUE;
text[3] = TEXT_COLOR_TRANSPARENT;
text[4] = TEXT_COLOR_LIGHT_BLUE;
2021-11-10 02:02:12 +01:00
StringCopy(&text[5], gText_Number2);
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL);
2021-11-10 02:02:12 +01:00
ConvertIntToDecimalStringN(&text[5], GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4);
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL);
2019-07-24 17:02:52 +02:00
}
break;
case 3:
2020-10-11 00:17:34 +02:00
switch (structPtr->windowModeState)
2019-07-24 17:02:52 +02:00
{
case 0:
2020-10-11 00:17:34 +02:00
if (winMode)
2021-11-03 20:29:18 +01:00
CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_FULL);
2019-07-24 17:02:52 +02:00
else
2021-11-03 20:29:18 +01:00
CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_GFX);
2019-07-24 17:02:52 +02:00
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
structPtr->windowModeState++;
2019-07-24 17:02:52 +02:00
return FALSE;
}
else
{
2020-10-11 00:17:34 +02:00
structPtr->windowModeState = 0;
2019-07-24 17:02:52 +02:00
return TRUE;
}
case 1:
2020-10-11 00:17:34 +02:00
if (winMode)
2021-11-03 20:29:18 +01:00
CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_FULL);
2019-07-24 17:02:52 +02:00
else
2021-11-03 20:29:18 +01:00
CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_GFX);
2019-07-24 17:02:52 +02:00
2020-10-11 00:17:34 +02:00
structPtr->windowModeState = 0;
2019-07-24 17:02:52 +02:00
return TRUE;
}
}
return FALSE;
}
2021-11-10 02:02:12 +01:00
static void CopyUnusedConditionWindowsToVram(void)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
2021-11-03 20:29:18 +01:00
CopyWindowToVram(structPtr->unusedWindowId1, COPYWIN_FULL);
CopyWindowToVram(structPtr->unusedWindowId2, COPYWIN_FULL);
2019-07-24 17:02:52 +02:00
}
void sub_81CE964(struct Sprite *sprite)
{
2020-10-11 00:17:34 +02:00
if (sprite->data[0] == GetConditionGraphCurrentMonIndex())
2019-07-24 17:02:52 +02:00
StartSpriteAnim(sprite, 0);
else
StartSpriteAnim(sprite, 1);
}
2020-10-11 00:17:34 +02:00
void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
if (GetConditionGraphCurrentMonIndex() == GetMonListCount() - 1)
2021-11-10 02:02:12 +01:00
sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_BALL);
2019-07-24 17:02:52 +02:00
else
2021-11-10 02:02:12 +01:00
sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_CANCEL);
2019-07-24 17:02:52 +02:00
}
2020-10-11 00:17:34 +02:00
void MonMarkingsCallback(struct Sprite *sprite)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
StartSpriteAnim(sprite, TryGetMonMarkId());
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static void CreateMonMarkingsOrPokeballIndicators(void)
2019-07-24 17:02:52 +02:00
{
struct SpriteSheet sprSheets[4];
struct SpriteTemplate sprTemplate;
struct SpritePalette sprPals[3];
struct SpriteSheet sprSheet;
struct Sprite *sprite;
u16 i, spriteId;
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
2020-08-10 19:48:16 +02:00
LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals);
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
{
2021-11-10 02:02:12 +01:00
structPtr->marksMenu.baseTileTag = TAG_CONDITION_MARKINGS_MENU;
structPtr->marksMenu.basePaletteTag = TAG_CONDITION_MARKINGS_MENU;
InitMonMarkingsMenu(&structPtr->marksMenu);
2021-02-28 23:22:26 +01:00
BufferMonMarkingsMenuTiles();
2021-11-10 02:02:12 +01:00
sprite = CreateMonMarkingAllCombosSprite(TAG_CONDITION_MON_MARKINGS, TAG_CONDITION_MON_MARKINGS, sConditionGraphMonMarkingsPal);
2019-07-24 17:02:52 +02:00
sprite->oam.priority = 3;
2021-07-07 15:11:52 +02:00
sprite->x = 192;
sprite->y = 32;
2020-10-11 00:17:34 +02:00
sprite->callback = MonMarkingsCallback;
structPtr->monMarksSprite = sprite;
2021-11-10 02:02:12 +01:00
PokenavFillPalette(IndexOfSpritePaletteTag(TAG_CONDITION_MON_MARKINGS), 0);
2019-07-24 17:02:52 +02:00
}
else
{
2020-10-11 00:17:34 +02:00
// party mode -> add pokeballs on right hand side
2019-07-24 17:02:52 +02:00
LoadSpriteSheets(sprSheets);
Pokenav_AllocAndLoadPalettes(sprPals);
2020-10-11 00:17:34 +02:00
for (i = 0; i < GetMonListCount() - 1; i++)
2019-07-24 17:02:52 +02:00
{
spriteId = CreateSprite(&sprTemplate, 226, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
2020-10-11 00:17:34 +02:00
structPtr->partyPokeballSpriteIds[i] = spriteId;
2019-07-24 17:02:52 +02:00
gSprites[spriteId].data[0] = i;
gSprites[spriteId].callback = sub_81CE964;
}
else
{
2021-02-20 06:30:37 +01:00
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE;
2019-07-24 17:02:52 +02:00
}
}
2021-11-10 02:02:12 +01:00
sprTemplate.tileTag = TAG_CONDITION_BALL_PLACEHOLDER;
2019-07-24 17:02:52 +02:00
sprTemplate.callback = SpriteCallbackDummy;
for (; i < 6; i++)
{
spriteId = CreateSprite(&sprTemplate, 230, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
2020-10-11 00:17:34 +02:00
structPtr->partyPokeballSpriteIds[i] = spriteId;
2019-07-24 17:02:52 +02:00
gSprites[spriteId].oam.size = 0;
}
else
{
2021-02-20 06:30:37 +01:00
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE;
2019-07-24 17:02:52 +02:00
}
}
2021-11-10 02:02:12 +01:00
sprTemplate.tileTag = TAG_CONDITION_CANCEL;
2020-10-11 00:17:34 +02:00
sprTemplate.callback = HighlightCurrentPartyIndexPokeball;
2019-07-24 17:02:52 +02:00
spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
{
2020-10-11 00:17:34 +02:00
structPtr->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].oam.shape = SPRITE_SHAPE(32x16);
gSprites[spriteId].oam.size = SPRITE_SIZE(32x16);
2019-07-24 17:02:52 +02:00
}
else
{
2021-02-20 06:30:37 +01:00
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE;
2019-07-24 17:02:52 +02:00
}
}
2020-08-10 19:48:16 +02:00
LoadConditionSparkle(&sprSheet, &sprPals[0]);
2019-07-24 17:02:52 +02:00
LoadSpriteSheet(&sprSheet);
sprPals[1].data = NULL;
Pokenav_AllocAndLoadPalettes(sprPals);
}
void sub_81CEBF4(struct Pokenav7Struct *structPtr)
{
u8 i;
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
DestroySprite(structPtr->monMarksSprite);
2021-11-10 02:02:12 +01:00
FreeSpriteTilesByTag(TAG_CONDITION_MARKINGS_MENU);
FreeSpriteTilesByTag(TAG_CONDITION_MON_MARKINGS);
FreeSpritePaletteByTag(TAG_CONDITION_MARKINGS_MENU);
FreeSpritePaletteByTag(TAG_CONDITION_MON_MARKINGS);
2019-07-24 17:02:52 +02:00
}
else
{
for (i = 0; i < 7; i++)
2020-10-11 00:17:34 +02:00
DestroySprite(&gSprites[structPtr->partyPokeballSpriteIds[i]]);
2019-07-24 17:02:52 +02:00
2021-11-10 02:02:12 +01:00
FreeSpriteTilesByTag(TAG_CONDITION_BALL);
FreeSpriteTilesByTag(TAG_CONDITION_CANCEL);
FreeSpriteTilesByTag(TAG_CONDITION_BALL_PLACEHOLDER);
FreeSpritePaletteByTag(TAG_CONDITION_BALL);
FreeSpritePaletteByTag(TAG_CONDITION_CANCEL);
2019-07-24 17:02:52 +02:00
}
2021-02-20 06:30:37 +01:00
if (structPtr->monPicSpriteId != SPRITE_NONE)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
DestroySprite(&gSprites[structPtr->monPicSpriteId]);
2021-11-10 02:02:12 +01:00
FreeSpriteTilesByTag(TAG_CONDITION_MON);
FreeSpritePaletteByTag(TAG_CONDITION_MON);
2019-07-24 17:02:52 +02:00
}
}
2020-10-11 00:17:34 +02:00
void FreePartyConditionSubstruct2(void)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
2020-10-11 00:17:34 +02:00
RemoveWindow(structPtr->nameGenderWindowId);
if (IsConditionMenuSearchMode() == TRUE)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
RemoveWindow(structPtr->listIndexWindowId);
RemoveWindow(structPtr->unusedWindowId1);
RemoveWindow(structPtr->unusedWindowId2);
2019-07-24 17:02:52 +02:00
}
else
{
2020-10-11 00:17:34 +02:00
SetLeftHeaderSpritesInvisibility();
2019-07-24 17:02:52 +02:00
}
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP);
sub_81CEBF4(structPtr);
sub_81CEE68();
2020-10-11 00:17:34 +02:00
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
}
2020-10-11 00:17:34 +02:00
void MonPicGfxSpriteCallback(struct Sprite *sprite)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2021-07-07 15:11:52 +02:00
sprite->x = structPtr->monTransitionX + 38;
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static void CreateConditionMonPic(u8 id)
2019-07-24 17:02:52 +02:00
{
struct SpriteTemplate sprTemplate;
struct SpriteSheet sprSheet;
struct SpritePalette sprPal;
u8 spriteId;
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
2021-02-20 06:30:37 +01:00
if (structPtr->monPicSpriteId == SPRITE_NONE)
2019-07-24 17:02:52 +02:00
{
2020-08-10 23:05:42 +02:00
LoadConditionMonPicTemplate(&sprSheet, &sprTemplate, &sprPal);
2020-10-11 00:17:34 +02:00
sprSheet.data = GetConditionMonPicGfx(id);
sprPal.data = GetConditionMonPal(id);
structPtr->monPalIndex = LoadSpritePalette(&sprPal);
structPtr->monGfxTileStart = LoadSpriteSheet(&sprSheet);
2019-07-24 17:02:52 +02:00
spriteId = CreateSprite(&sprTemplate, 38, 104, 0);
2020-10-11 00:17:34 +02:00
structPtr->monPicSpriteId = spriteId;
2019-07-24 17:02:52 +02:00
if (spriteId == MAX_SPRITES)
{
2021-11-10 02:02:12 +01:00
FreeSpriteTilesByTag(TAG_CONDITION_MON);
FreeSpritePaletteByTag(TAG_CONDITION_MON);
2021-02-20 06:30:37 +01:00
structPtr->monPicSpriteId = SPRITE_NONE;
2019-07-24 17:02:52 +02:00
}
else
{
2020-10-11 00:17:34 +02:00
structPtr->monPicSpriteId = spriteId;
gSprites[structPtr->monPicSpriteId].callback = MonPicGfxSpriteCallback;
2021-11-10 02:02:12 +01:00
structPtr->unk181C = (void*)VRAM + BG_VRAM_SIZE + (structPtr->monGfxTileStart * 32);
2020-10-11 00:17:34 +02:00
structPtr->monPalIndex = (structPtr->monPalIndex * 16) + 0x100;
2019-07-24 17:02:52 +02:00
}
}
else
{
2021-03-29 15:38:19 +02:00
DmaCopy16Defvars(3, GetConditionMonPicGfx(id), structPtr->unk181C, MON_PIC_SIZE);
2020-10-11 00:17:34 +02:00
LoadPalette(GetConditionMonPal(id), structPtr->monPalIndex, 0x20);
2019-07-24 17:02:52 +02:00
}
}
2021-11-11 00:52:30 +01:00
static void VBlankCB_PokenavConditionGraph(void)
2019-07-24 17:02:52 +02:00
{
2021-11-11 00:52:30 +01:00
struct ConditionGraph *graph = GetConditionGraphPtr();
2019-07-24 17:02:52 +02:00
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
2021-11-11 00:52:30 +01:00
ConditionGraph_Draw(graph);
2019-07-24 17:02:52 +02:00
ScanlineEffect_InitHBlankDmaTransfer();
}
2021-11-10 02:02:12 +01:00
static void sub_81CEE68(void)
2019-07-24 17:02:52 +02:00
{
SetPokenavVBlankCallback();
}
2021-11-10 02:02:12 +01:00
static void ToggleGraphData(bool8 showBg)
2019-07-24 17:02:52 +02:00
{
if (showBg)
ShowBg(2);
else
HideBg(2);
}
2021-11-10 02:02:12 +01:00
static void DoConditionGraphTransition(void)
2019-07-24 17:02:52 +02:00
{
2021-11-11 00:52:30 +01:00
struct ConditionGraph *graph = GetConditionGraphPtr();
2020-10-11 00:17:34 +02:00
u8 id = GetMonMarkIndex();
2019-07-24 17:02:52 +02:00
2021-11-10 02:02:12 +01:00
sUnknown_030012BC = id;
2021-11-11 00:52:30 +01:00
ConditionGraph_SetNewPositions(graph, graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1], graph->savedPositions[id]);
ConditionGraph_TryUpdate(graph);
2019-07-24 17:02:52 +02:00
}
2021-11-10 02:02:12 +01:00
static void sub_81CEEC8(void)
2019-07-24 17:02:52 +02:00
{
2021-11-11 00:52:30 +01:00
struct ConditionGraph *graph = GetConditionGraphPtr();
2019-07-24 17:02:52 +02:00
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() || GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1)
2021-11-11 00:52:30 +01:00
ConditionGraph_SetNewPositions(graph, graph->savedPositions[GetMonMarkIndex()], graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]);
2019-07-24 17:02:52 +02:00
}
2020-10-11 00:17:34 +02:00
u8 GetMonMarkingsData(void)
2019-07-24 17:02:52 +02:00
{
2020-10-11 00:17:34 +02:00
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
2019-07-24 17:02:52 +02:00
2020-10-11 00:17:34 +02:00
if (IsConditionMenuSearchMode() == 1)
2021-11-10 02:02:12 +01:00
return structPtr->marksMenu.markings;
2019-07-24 17:02:52 +02:00
else
return 0;
}