pokeemerald/src/pokenav.c

618 lines
14 KiB
C
Raw Normal View History

2019-02-11 20:59:44 +01:00
#include "global.h"
#include "alloc.h"
#include "task.h"
#include "main.h"
#include "overworld.h"
2019-02-12 07:39:27 +01:00
#include "field_weather.h"
2019-02-12 08:23:08 +01:00
#include "palette.h"
2019-02-12 09:48:32 +01:00
#include "pokemon_storage_system.h"
#include "pokenav.h"
2019-02-12 08:23:08 +01:00
2019-04-06 22:15:52 +02:00
#define LOOPED_TASK_DECODE_STATE(action) (action - 5)
#define LOOPED_TASK_ID(primary, secondary) (((secondary) << 16) |(primary))
#define LOOPED_TASK_PRIMARY_ID(taskId) (taskId & 0xFFFF)
#define LOOPED_TASK_SECONDARY_ID(taskId) (taskId >> 16)
2019-02-23 13:34:01 +01:00
#define SUBSTRUCT_COUNT 19
2019-04-06 22:15:52 +02:00
struct PokenavResources
2019-02-15 06:07:57 +01:00
{
u32 (*currentMenuCb1)(void);
u32 currentMenuIndex;
2019-02-23 13:34:01 +01:00
u16 mode;
2019-02-15 06:29:32 +01:00
u16 fieldA;
2019-02-23 13:34:01 +01:00
bool32 hasAnyRibbons;
2019-02-24 05:17:26 +01:00
void *field10[SUBSTRUCT_COUNT];
2019-02-13 04:35:07 +01:00
};
struct UnknownPokenavCallbackStruct
{
2019-04-14 17:13:51 +02:00
bool32 (*unk0)(void);
u32 (*unk4)(void);
2019-04-16 21:18:01 +02:00
bool32 (*unk8)(void);
void (*unkC)(s32);
u32 (*unk10)(void);
void (*unk14)(void);
2019-04-16 00:51:11 +02:00
void (*unk18)(void);
};
2019-08-05 03:23:38 +02:00
// TODO: Move these to pokenav.h
2019-04-16 21:18:01 +02:00
extern bool32 sub_81C9924(void);
extern u32 sub_81C99C0(void);
2019-08-05 03:23:38 +02:00
extern void sub_81C9990(s32);
2019-04-16 21:18:01 +02:00
extern bool32 sub_81C9940(void);
extern u32 sub_81CCFD8(void);
extern u32 sub_81CD070(void);
2019-04-16 21:18:01 +02:00
extern bool32 sub_81CDDD4(void);
2019-08-05 03:23:38 +02:00
extern void sub_81CDE2C(s32);
extern u32 sub_81CDE64(void);
extern void sub_81CD1C0(void);
2019-04-16 00:51:11 +02:00
extern void sub_81CECA0(void);
extern u32 sub_81CEF3C(void);
extern u32 sub_81CEFDC(void);
2019-04-16 21:18:01 +02:00
extern bool32 sub_81CF330(void);
2019-08-05 03:23:38 +02:00
extern void sub_81CF3A0(s32);
extern u32 sub_81CF3D0(void);
extern void sub_81CEFF0(void);
2019-04-16 00:51:11 +02:00
extern void sub_81CF3F8(void);
extern u32 sub_81CD024(void);
extern u32 sub_81CEF98(void);
2019-04-16 21:18:01 +02:00
extern bool32 sub_81CF368(void);
extern u32 sub_81CF9BC(void);
extern u32 sub_81CFA34(void);
2019-04-16 21:18:01 +02:00
extern bool32 sub_81CFDD0(void);
extern void sub_81CFE40(s32);
extern u32 sub_81CFE70(void);
extern void sub_81CFA48(void);
2019-04-16 00:51:11 +02:00
extern void sub_81CFE98(void);
extern u32 sub_81D0450(void);
extern u32 sub_81D04A0(void);
2019-04-16 21:18:01 +02:00
extern bool32 sub_81D0978(void);
extern void sub_81D09B0(s32);
extern u32 sub_81D09E0(void);
extern void sub_81D04B8(void);
2019-04-16 00:51:11 +02:00
extern void sub_81D09F4(void);
extern u32 sub_81CFA04(void);
2019-04-16 21:18:01 +02:00
extern bool32 sub_81CFE08(void);
2019-04-13 22:54:05 +02:00
static bool32 SetActivePokenavMenu(u32 menuId);
2019-02-23 13:34:01 +01:00
static bool32 AnyMonHasRibbon(void);
2019-02-13 03:33:15 +01:00
u32 sub_81C75E0(void);
u32 sub_81C75D4(void);
u32 PokenavMainMenuLoopedTaskIsActive(void);
bool32 WaitForPokenavShutdownFade(void);
2019-02-23 13:34:01 +01:00
void sub_81C7834(void *func1, void *func2);
static void InitPokenavResources(struct PokenavResources *a0);
2019-04-06 22:15:52 +02:00
void Task_RunLoopedTask_LinkMode(u8 a0);
void Task_RunLoopedTask(u8 taskId);
2019-02-13 04:18:12 +01:00
void sub_81C742C(u8 taskId);
void ShutdownPokenav(void);
2019-02-23 13:34:01 +01:00
static void InitKeys_(void);
static void FreePokenavResources(void);
2019-04-06 22:15:52 +02:00
static void VBlankCB_Pokenav(void);
2019-03-02 09:18:08 +01:00
static void CB2_Pokenav(void);
2019-02-12 08:23:08 +01:00
void sub_81C72BC(void);
2019-02-23 13:34:01 +01:00
const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
{
2019-02-15 06:29:32 +01:00
{
.unk0 = sub_81C9298,
.unk4 = sub_81C941C,
.unk8 = sub_81C9924,
.unkC = sub_81C9990,
.unk10 = sub_81C99C0,
.unk14 = sub_81C9430,
.unk18 = sub_81C99D4,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81C9298,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
.unk10 = sub_81C99C0,
.unk14 = sub_81C9430,
.unk18 = sub_81C99D4,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81C9338,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
.unk10 = sub_81C99C0,
.unk14 = sub_81C9430,
.unk18 = sub_81C99D4,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81C9368,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
.unk10 = sub_81C99C0,
.unk14 = sub_81C9430,
.unk18 = sub_81C99D4,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81C92CC,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
.unk10 =sub_81C99C0,
.unk14 = sub_81C9430,
.unk18 = sub_81C99D4,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81C9304,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
.unk10 = sub_81C99C0,
.unk14 = sub_81C9430,
.unk18 = sub_81C99D4,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81CC4D4,
.unk4 = sub_81CC554,
.unk8 = sub_81CC5F4,
.unkC = sub_81CC62C,
.unk10 = sub_81CC65C,
.unk14 = sub_81CC524,
.unk18 = sub_81CC670,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81CCFD8,
.unk4 = sub_81CD070,
.unk8 = sub_81CDDD4,
.unkC = sub_81CDE2C,
.unk10 = sub_81CDE64,
.unk14 = sub_81CD1C0,
.unk18 = sub_81CECA0,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81CEF3C,
.unk4 = sub_81CEFDC,
.unk8 = sub_81CF330,
.unkC = sub_81CF3A0,
.unk10 = sub_81CF3D0,
.unk14 = sub_81CEFF0,
.unk18 = sub_81CF3F8,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81CD024,
.unk4 = sub_81CD070,
.unk8 = sub_81CDDD4,
.unkC = sub_81CDE2C,
.unk10 = sub_81CDE64,
.unk14 = sub_81CD1C0,
.unk18 = sub_81CECA0,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81CEF98,
.unk4 = sub_81CEFDC,
.unk8 = sub_81CF368,
.unkC = sub_81CF3A0,
.unk10 = sub_81CF3D0,
.unk14 = sub_81CEFF0,
.unk18 = sub_81CF3F8,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81CAAE8,
.unk4 = sub_81CAB24,
.unk8 = sub_81CB260,
.unkC = sub_81CB29C,
.unk10 = sub_81CB2CC,
.unk14 = sub_81CAB38,
.unk18 = sub_81CB2E0,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81CF9BC,
.unk4 = sub_81CFA34,
.unk8 = sub_81CFDD0,
.unkC = sub_81CFE40,
.unk10 = sub_81CFE70,
.unk14 = sub_81CFA48,
.unk18 = sub_81CFE98,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81D0450,
.unk4 = sub_81D04A0,
.unk8 = sub_81D0978,
.unkC = sub_81D09B0,
.unk10 = sub_81D09E0,
.unk14 = sub_81D04B8,
.unk18 = sub_81D09F4,
2019-02-15 06:29:32 +01:00
},
{
.unk0 = sub_81CFA04,
.unk4 = sub_81CFA34,
.unk8 = sub_81CFE08,
.unkC = sub_81CFE40,
.unk10 = sub_81CFE70,
.unk14 = sub_81CFA48,
.unk18 = sub_81CFE98,
2019-02-15 06:29:32 +01:00
},
};
2019-04-06 22:15:52 +02:00
EWRAM_DATA u8 gNextLoopedTaskId = 0;
EWRAM_DATA struct PokenavResources *gPokenavResources = NULL;
2019-03-16 00:33:30 +01:00
2019-02-23 13:34:01 +01:00
// code
2019-04-06 22:15:52 +02:00
u32 CreateLoopedTask(LoopedTask loopedTask, u32 priority)
2019-02-11 20:59:44 +01:00
{
u16 taskId;
if (!IsUpdateLinkStateCBActive())
2019-04-06 22:15:52 +02:00
taskId = CreateTask(Task_RunLoopedTask, priority);
2019-02-15 06:29:32 +01:00
else
2019-04-06 22:15:52 +02:00
taskId = CreateTask(Task_RunLoopedTask_LinkMode, priority);
2019-02-11 20:59:44 +01:00
2019-04-06 22:15:52 +02:00
SetWordTaskArg(taskId, 1, (u32)loopedTask);
2019-02-11 20:59:44 +01:00
2019-04-06 22:15:52 +02:00
gTasks[taskId].data[3] = gNextLoopedTaskId;
return LOOPED_TASK_ID(taskId, gNextLoopedTaskId++);
2019-02-11 20:59:44 +01:00
}
2019-04-06 22:15:52 +02:00
bool32 IsLoopedTaskActive(u32 taskId)
2019-02-11 22:35:02 +01:00
{
2019-04-06 22:15:52 +02:00
u32 primaryId = LOOPED_TASK_PRIMARY_ID(taskId);
u32 secondaryId = LOOPED_TASK_SECONDARY_ID(taskId);
2019-02-23 13:34:01 +01:00
2019-04-06 22:15:52 +02:00
if (gTasks[primaryId].isActive
&& (gTasks[primaryId].func == Task_RunLoopedTask || gTasks[primaryId].func == Task_RunLoopedTask_LinkMode)
&& gTasks[primaryId].data[3] == secondaryId)
2019-02-15 06:29:32 +01:00
return TRUE;
else
return FALSE;
2019-02-11 22:06:46 +01:00
}
2019-04-06 22:15:52 +02:00
bool32 FuncIsActiveLoopedTask(LoopedTask func)
2019-02-11 22:35:02 +01:00
{
2019-04-13 22:54:05 +02:00
int i;
2019-02-23 13:34:01 +01:00
for (i = 0; i < NUM_TASKS; i++)
2019-02-15 06:29:32 +01:00
{
if (gTasks[i].isActive
2019-04-06 22:15:52 +02:00
&& (gTasks[i].func == Task_RunLoopedTask || gTasks[i].func == Task_RunLoopedTask_LinkMode)
&& (LoopedTask)GetWordTaskArg(i, 1) == func)
2019-02-23 13:34:01 +01:00
return TRUE;
2019-02-15 06:29:32 +01:00
}
return FALSE;
2019-02-12 06:51:54 +01:00
}
2019-04-06 22:15:52 +02:00
void Task_RunLoopedTask(u8 taskId)
2019-02-12 06:51:54 +01:00
{
2019-04-06 22:15:52 +02:00
LoopedTask loopedTask = (LoopedTask)GetWordTaskArg(taskId, 1);
s16 *state = &gTasks[taskId].data[0];
2019-02-23 13:34:01 +01:00
bool32 exitLoop = FALSE;
2019-02-15 06:29:32 +01:00
while (!exitLoop)
{
2019-04-06 22:15:52 +02:00
u32 action = loopedTask(*state);
switch (action)
2019-02-16 18:09:27 +01:00
{
2019-04-06 22:15:52 +02:00
case LT_INC_AND_CONTINUE:
(*state)++;
2019-02-15 06:29:32 +01:00
break;
case LT_INC_AND_PAUSE:
2019-04-06 22:15:52 +02:00
(*state)++;
2019-02-15 06:29:32 +01:00
return;
2019-04-06 22:15:52 +02:00
case LT_FINISH:
2019-02-15 06:29:32 +01:00
DestroyTask(taskId);
return;
2019-04-06 22:15:52 +02:00
// case LT_SET_STATE:
2019-02-15 06:29:32 +01:00
default:
2019-04-06 22:15:52 +02:00
*state = LOOPED_TASK_DECODE_STATE(action);
2019-02-15 06:29:32 +01:00
break;
2019-04-06 22:15:52 +02:00
case LT_CONTINUE:
2019-02-15 06:29:32 +01:00
break;
case LT_PAUSE:
2019-02-15 06:29:32 +01:00
return;
}
}
2019-02-12 07:30:39 +01:00
}
// Every "Continue" action pauses instead.
2019-04-06 22:15:52 +02:00
void Task_RunLoopedTask_LinkMode(u8 taskId)
2019-02-15 06:07:57 +01:00
{
2019-04-06 22:15:52 +02:00
LoopedTask task;
s16 *state;
u32 action;
2019-02-15 06:29:32 +01:00
if (sub_8087598())
return;
2019-07-25 21:41:02 +02:00
2019-04-06 22:15:52 +02:00
task = (LoopedTask)GetWordTaskArg(taskId, 1);
state = &gTasks[taskId].data[0];
action = task(*state);
switch (action)
{
case LT_INC_AND_PAUSE:
2019-04-06 22:15:52 +02:00
case LT_INC_AND_CONTINUE:
(*state)++;
2019-02-16 18:09:27 +01:00
break;
2019-04-06 22:15:52 +02:00
case LT_FINISH:
2019-02-16 18:09:27 +01:00
DestroyTask(taskId);
break;
2019-04-06 22:15:52 +02:00
// case: LT_SET_STATE:
2019-02-16 18:09:27 +01:00
default:
2019-04-06 22:15:52 +02:00
*state = LOOPED_TASK_DECODE_STATE(action);
2019-02-16 18:09:27 +01:00
break;
case LT_PAUSE:
2019-04-06 22:15:52 +02:00
case LT_CONTINUE:
break;
2019-02-15 06:29:32 +01:00
}
2019-02-12 07:34:43 +01:00
}
2019-03-02 09:18:08 +01:00
void CB2_InitPokeNav(void)
2019-02-12 07:34:43 +01:00
{
2019-04-06 22:15:52 +02:00
gPokenavResources = Alloc(sizeof(*gPokenavResources));
if (gPokenavResources == NULL)
{
2019-02-12 07:34:43 +01:00
SetMainCallback2(CB2_ReturnToFieldWithOpenMenu);
}
2019-02-16 18:09:27 +01:00
else
{
InitPokenavResources(gPokenavResources);
2019-02-12 07:34:43 +01:00
ResetTasks();
SetVBlankCallback(NULL);
CreateTask(sub_81C742C, 0);
2019-03-02 09:18:08 +01:00
SetMainCallback2(CB2_Pokenav);
2019-04-06 22:15:52 +02:00
SetVBlankCallback(VBlankCB_Pokenav);
2019-02-12 07:34:43 +01:00
}
2019-02-12 07:39:27 +01:00
}
2019-02-23 13:34:01 +01:00
void sub_81C72A4(void)
2019-02-15 06:07:57 +01:00
{
2019-02-15 06:29:32 +01:00
SetMainCallback2(sub_81C72BC);
FadeScreen(1, 0);
2019-02-12 08:23:08 +01:00
}
2019-02-23 13:34:01 +01:00
void sub_81C72BC(void)
2019-02-15 06:07:57 +01:00
{
2019-02-15 06:29:32 +01:00
UpdatePaletteFade();
2019-02-23 13:34:01 +01:00
if (gPaletteFade.active)
return;
2019-04-06 22:15:52 +02:00
gPokenavResources = Alloc(sizeof(*gPokenavResources));
if (gPokenavResources == NULL)
2019-02-15 06:29:32 +01:00
{
2019-02-23 13:34:01 +01:00
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
}
else
{
InitPokenavResources(gPokenavResources);
2019-04-13 22:54:05 +02:00
gPokenavResources->mode = POKENAV_MODE_FORCE_CALL_1;
2019-02-23 13:34:01 +01:00
ResetTasks();
ResetSpriteData();
FreeAllSpritePalettes();
SetVBlankCallback(NULL);
CreateTask(sub_81C742C, 0);
2019-03-02 09:18:08 +01:00
SetMainCallback2(CB2_Pokenav);
2019-04-06 22:15:52 +02:00
SetVBlankCallback(VBlankCB_Pokenav);
2019-02-15 06:29:32 +01:00
}
2019-02-12 08:28:46 +01:00
}
static void FreePokenavResources(void)
2019-02-15 06:07:57 +01:00
{
2019-04-13 22:54:05 +02:00
int i;
2019-02-12 08:28:46 +01:00
2019-02-23 13:34:01 +01:00
for (i = 0; i < SUBSTRUCT_COUNT; i++)
FreePokenavSubstruct(i);
2019-02-23 13:34:01 +01:00
2019-04-06 22:15:52 +02:00
FREE_AND_SET_NULL(gPokenavResources);
2019-02-15 06:29:32 +01:00
InitKeys();
2019-02-12 08:59:17 +01:00
}
static void InitPokenavResources(struct PokenavResources *a0)
2019-02-15 06:07:57 +01:00
{
2019-04-13 22:54:05 +02:00
int i;
2019-02-15 06:29:32 +01:00
2019-02-23 13:34:01 +01:00
for (i = 0; i < SUBSTRUCT_COUNT; i++)
a0->field10[i] = NULL;
2019-04-13 22:54:05 +02:00
a0->mode = POKENAV_MODE_NORMAL;
a0->currentMenuIndex = 0;
2019-02-23 13:34:01 +01:00
a0->hasAnyRibbons = AnyMonHasRibbon();
a0->currentMenuCb1 = NULL;
2019-02-12 09:48:32 +01:00
}
2019-02-23 13:34:01 +01:00
static bool32 AnyMonHasRibbon(void)
2019-02-15 06:07:57 +01:00
{
2019-04-13 22:54:05 +02:00
int i, j;
2019-02-15 06:29:32 +01:00
for (i = 0; i < PARTY_SIZE; i++)
2019-02-15 06:29:32 +01:00
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_HAS_SPECIES)
&& !GetMonData(&gPlayerParty[i], MON_DATA_SANITY_IS_EGG)
&& GetMonData(&gPlayerParty[i], MON_DATA_RIBBON_COUNT) != 0)
{
return TRUE;
}
}
for (j = 0; j < TOTAL_BOXES_COUNT; j++)
2019-02-15 06:29:32 +01:00
{
2019-02-23 13:34:01 +01:00
for (i = 0; i < IN_BOX_COUNT; i++)
2019-02-15 06:29:32 +01:00
{
if (CheckBoxMonSanityAt(j, i)
&& GetBoxMonDataAt(j, i, MON_DATA_RIBBON_COUNT) != 0)
{
return TRUE;
}
}
}
return FALSE;
2019-02-12 09:51:48 +01:00
}
2019-03-02 09:18:08 +01:00
static void CB2_Pokenav(void)
2019-02-15 06:07:57 +01:00
{
2019-02-15 06:29:32 +01:00
RunTasks();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
2019-02-12 09:54:35 +01:00
}
2019-04-06 22:15:52 +02:00
static void VBlankCB_Pokenav(void)
2019-02-15 06:07:57 +01:00
{
2019-02-15 06:29:32 +01:00
TransferPlttBuffer();
LoadOam();
ProcessSpriteCopyRequests();
2019-02-13 02:20:15 +01:00
}
2019-02-15 06:07:57 +01:00
void sub_81C742C(u8 taskId)
{
2019-02-15 06:29:32 +01:00
u32 v1;
2019-02-23 13:34:01 +01:00
s16 *data = gTasks[taskId].data;
2019-02-15 06:29:32 +01:00
2019-02-23 13:34:01 +01:00
switch (data[0])
2019-02-15 06:29:32 +01:00
{
case 0:
InitPokenavMainMenu();
2019-02-23 13:34:01 +01:00
data[0] = 1;
2019-02-15 06:29:32 +01:00
break;
case 1:
// Wait for LoopedTask_InitPokenavMenu to finish
if (PokenavMainMenuLoopedTaskIsActive())
2019-02-15 06:29:32 +01:00
break;
2019-04-13 22:54:05 +02:00
SetActivePokenavMenu(POKENAV_MENU_0);
2019-02-23 13:34:01 +01:00
data[0] = 4;
2019-02-15 06:29:32 +01:00
break;
case 2:
if (sub_81C786C())
break;
2019-02-23 13:34:01 +01:00
data[0] = 3;
2019-02-15 06:29:32 +01:00
case 3:
v1 = sub_81C75E0();
if (v1 == -1)
{
ShutdownPokenav();
2019-02-23 13:34:01 +01:00
data[0] = 5;
2019-02-15 06:29:32 +01:00
}
2019-04-13 22:54:05 +02:00
else if (v1 >= POKENAV_MENU_IDS_START)
2019-02-15 06:29:32 +01:00
{
PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].unk18();
PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].unk14();
if (SetActivePokenavMenu(v1))
{
2019-02-23 13:34:01 +01:00
data[0] = 4;
}
2019-02-15 06:29:32 +01:00
else
{
ShutdownPokenav();
2019-02-23 13:34:01 +01:00
data[0] = 5;
2019-02-15 06:29:32 +01:00
}
}
else if (v1 != 0)
{
sub_81C7850(v1);
if (sub_81C786C())
2019-02-23 13:34:01 +01:00
data[0] = 2;
2019-02-15 06:29:32 +01:00
}
break;
case 4:
if (!sub_81C75D4())
2019-02-23 13:34:01 +01:00
data[0] = 3;
2019-02-15 06:29:32 +01:00
break;
case 5:
if (!WaitForPokenavShutdownFade())
2019-02-15 06:29:32 +01:00
{
2019-04-13 22:54:05 +02:00
bool32 calledFromScript = (gPokenavResources->mode != POKENAV_MODE_NORMAL);
2019-02-23 13:34:01 +01:00
2019-02-15 06:29:32 +01:00
sub_81C9430();
FreePokenavResources();
2019-02-23 13:34:01 +01:00
if (calledFromScript)
2019-02-15 06:29:32 +01:00
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
else
SetMainCallback2(CB2_ReturnToFieldWithOpenMenu);
}
break;
2019-02-15 06:29:32 +01:00
}
}
2019-04-13 22:54:05 +02:00
static bool32 SetActivePokenavMenu(u32 menuId)
2019-02-15 06:07:57 +01:00
{
2019-04-13 22:54:05 +02:00
u32 index = menuId - POKENAV_MENU_IDS_START;
2019-02-15 06:29:32 +01:00
2019-02-23 13:34:01 +01:00
InitKeys_();
if (!PokenavMenuCallbacks[index].unk0())
2019-02-15 06:29:32 +01:00
return FALSE;
if (!PokenavMenuCallbacks[index].unk8())
2019-02-15 06:29:32 +01:00
return FALSE;
2019-02-23 13:34:01 +01:00
sub_81C7834(PokenavMenuCallbacks[index].unkC, PokenavMenuCallbacks[index].unk10);
gPokenavResources->currentMenuCb1 = PokenavMenuCallbacks[index].unk4;
gPokenavResources->currentMenuIndex = index;
2019-02-15 06:29:32 +01:00
return TRUE;
2019-02-13 03:33:15 +01:00
}
2019-02-15 06:07:57 +01:00
u32 sub_81C75D4(void)
{
2019-02-15 06:29:32 +01:00
return sub_81C786C();
2019-02-13 03:33:15 +01:00
}
2019-02-15 06:07:57 +01:00
u32 sub_81C75E0(void)
{
return gPokenavResources->currentMenuCb1();
2019-02-13 03:33:15 +01:00
}
2019-02-23 13:34:01 +01:00
static void InitKeys_(void)
2019-02-15 06:07:57 +01:00
{
2019-02-15 06:29:32 +01:00
InitKeys();
2019-02-13 03:33:15 +01:00
}
2019-02-23 13:34:01 +01:00
void SetVBlankCallback_(IntrCallback callback)
2019-02-15 06:07:57 +01:00
{
2019-02-15 06:29:32 +01:00
SetVBlankCallback(callback);
2019-02-13 03:33:15 +01:00
}
2019-02-23 13:34:01 +01:00
void SetPokenavVBlankCallback(void)
2019-02-15 06:07:57 +01:00
{
2019-04-06 22:15:52 +02:00
SetVBlankCallback(VBlankCB_Pokenav);
2019-02-13 03:33:15 +01:00
}
2019-02-23 13:34:01 +01:00
void *AllocSubstruct(u32 index, u32 size)
2019-02-15 06:07:57 +01:00
{
2019-04-13 21:46:46 +02:00
gPokenavResources->field10[index] = Alloc(size);
return gPokenavResources->field10[index];
2019-02-13 04:18:12 +01:00
}
void *GetSubstructPtr(u32 index)
2019-02-15 06:07:57 +01:00
{
2019-04-06 22:15:52 +02:00
return gPokenavResources->field10[index];
2019-02-13 04:18:12 +01:00
}
void FreePokenavSubstruct(u32 index)
2019-02-15 06:07:57 +01:00
{
2019-04-06 22:15:52 +02:00
if (gPokenavResources->field10[index] != NULL)
FREE_AND_SET_NULL(gPokenavResources->field10[index]);
2019-02-13 04:18:12 +01:00
}
u32 GetPokenavMode(void)
2019-02-15 06:07:57 +01:00
{
2019-04-06 22:15:52 +02:00
return gPokenavResources->mode;
2019-02-13 04:18:12 +01:00
}
2019-02-23 13:34:01 +01:00
void SetPokenavMode(u16 mode)
2019-02-15 06:07:57 +01:00
{
2019-04-06 22:15:52 +02:00
gPokenavResources->mode = mode;
2019-02-13 04:18:12 +01:00
}
2019-02-15 06:07:57 +01:00
void sub_81C7694(u32 a0)
{
2019-02-23 13:34:01 +01:00
u32 value = a0;
if (value > 4)
2019-02-15 06:29:32 +01:00
value = 0;
2019-04-06 22:15:52 +02:00
gPokenavResources->fieldA = value;
2019-02-13 04:18:12 +01:00
}
2019-07-25 21:41:02 +02:00
u32 sub_81C76AC(void)
2019-02-15 06:07:57 +01:00
{
2019-04-06 22:15:52 +02:00
return gPokenavResources->fieldA;
2019-02-13 04:18:12 +01:00
}
2019-02-23 13:34:01 +01:00
bool32 CanViewRibbonsMenu(void)
2019-02-15 06:07:57 +01:00
{
2019-04-06 22:15:52 +02:00
return gPokenavResources->hasAnyRibbons;
2019-02-13 04:18:12 +01:00
}