Merge pull request #769 from PikalaxALT/pokenav_unk_9

Pokenav unk 9
This commit is contained in:
PikalaxALT 2019-08-06 12:49:03 -04:00 committed by GitHub
commit 1bda9ef2f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 710 additions and 1359 deletions

File diff suppressed because it is too large Load Diff

View File

@ -144,13 +144,17 @@ void sub_81C7E14(u32 arg0);
void sub_81C7FC4(u32 arg0, bool32 arg1);
void sub_81C7880(void);
void sub_81C7990(u32 a0, u16 a1);
u32 PokenavMainMenuLoopedTaskIsActive(void);
bool32 WaitForPokenavShutdownFade(void);
void sub_81C7834(void *func1, void *func2);
void ShutdownPokenav(void);
// pokenav_unk_1.c
bool32 sub_81C9298(void);
bool32 sub_81C92CC(void);
bool32 sub_81C9304(void);
bool32 sub_81C9338(void);
bool32 sub_81C9368(void);
bool32 PokenavCallback_Init_0(void);
bool32 PokenavCallback_Init_4(void);
bool32 PokenavCallback_Init_5(void);
bool32 PokenavCallback_Init_2(void);
bool32 PokenavCallback_Init_3(void);
u32 sub_81C941C(void);
void sub_81C9430(void);
int sub_81C9894(void);
@ -168,7 +172,7 @@ void sub_81C99D4(void);
void sub_81CAADC(void);
// pokenav_unk_3.c
bool32 sub_81CAAE8(void);
bool32 PokenavCallback_Init_11(void);
u32 sub_81CAB24(void);
void sub_81CAB38(void);
int sub_81CAE28(void);
@ -195,7 +199,7 @@ void sub_81CB2E0(void);
void sub_81CBD48(u16 windowId, u32 a1);
// pokenav_unk_5.c
u32 sub_81CC4D4(void);
u32 PokenavCallback_Init_6(void);
void sub_81CC524(void);
u32 sub_81CC554(void);
bool32 sub_81CC5F4(void);
@ -204,6 +208,10 @@ u32 sub_81CC65C(void);
void sub_81CC670(void);
// pokenav_unk_6.c
u32 PokenavCallback_Init_7(void);
u32 PokenavCallback_Init_9(void);
u32 sub_81CD070(void);
void sub_81CD1C0(void);
bool32 sub_81CD3C4(void);
bool32 sub_81CDD5C(void);
struct UnknownStruct_81D1ED4 *sub_81CDC70(void);
@ -219,6 +227,41 @@ void *sub_81CDCB4(u8 id);
void *sub_81CDCD4(u8 id);
// pokenav_unk_7.c
bool32 sub_81CDDD4(void);
void sub_81CDE2C(s32);
u32 sub_81CDE64(void);
void sub_81CECA0(void);
u8 sub_81CEF14(void);
// pokenav_unk_8.c
u32 PokenavCallback_Init_8(void);
u32 PokenavCallback_Init_10(void);
u32 sub_81CEFDC(void);
void sub_81CEFF0(void);
bool32 sub_81CF330(void);
bool32 sub_81CF368(void);
void sub_81CF3A0(s32);
u32 sub_81CF3D0(void);
void sub_81CF3F8(void);
// pokenav_unk_9.c
u32 PokenavCallback_Init_12(void);
u32 PokenavCallback_Init_14(void);
u32 sub_81CFA34(void);
void sub_81CFA48(void);
bool32 sub_81CFDD0(void);
bool32 sub_81CFE08(void);
void sub_81CFE40(s32);
u32 sub_81CFE70(void);
void sub_81CFE98(void);
// pokenav_unk_10.c
u32 PokenavCallback_Init_13(void);
u32 sub_81D04A0(void);
void sub_81D04B8(void);
bool32 sub_81D0978(void);
void sub_81D09B0(s32);
u32 sub_81D09E0(void);
void sub_81D09F4(void);
#endif // GUARD_POKENAV_H

View File

@ -317,7 +317,6 @@ SECTIONS {
src/pokenav_unk_7.o(.text);
src/pokenav_unk_8.o(.text);
src/pokenav_unk_9.o(.text);
asm/pokenav_unk_9.o(.text);
src/pokenav_unk_10.o(.text);
src/pokenav_match_call_data.o(.text);
src/menu_specialized.o(.text);

View File

@ -2482,7 +2482,7 @@ void WipeTrainerNameRecords(void)
}
}
void nullsub_5(const char *unused_0, u8 unused_1, u8 unused_2)
void nullsub_5(const void *unused_0, u8 unused_1, u8 unused_2)
{
// debug?
}
@ -2512,7 +2512,7 @@ void sub_800E604(void)
sub_800D724(&gUnknown_03005000.unk_9e8);
CpuFill16(0, gSendCmd, sizeof gSendCmd);
CpuFill16(0, gRecvCmds, sizeof gRecvCmds);
CpuFill16(0, gLinkPlayers, sizeof gLinkPlayers)
CpuFill16(0, gLinkPlayers, sizeof gLinkPlayers);
}
void sub_800E6D0(void)

View File

@ -1319,7 +1319,7 @@ void CB2_Pokedex(void)
default:
SetVBlankCallback(NULL);
sub_80C09B0(0);
DmaFillLarge16(3, 0, (u8 *)VRAM, VRAM_SIZE, 0x1000)
DmaFillLarge16(3, 0, (u8 *)VRAM, VRAM_SIZE, 0x1000);
DmaClear32(3, OAM, OAM_SIZE);
DmaClear16(3, PLTT, PLTT_SIZE);
gMain.state = 1;

View File

@ -37,67 +37,24 @@ struct UnknownPokenavCallbackStruct
void (*unk18)(void);
};
// TODO: Move these to pokenav.h
extern bool32 sub_81C9924(void);
extern u32 sub_81C99C0(void);
extern void sub_81C9990(s32);
extern bool32 sub_81C9940(void);
extern u32 sub_81CCFD8(void);
extern u32 sub_81CD070(void);
extern bool32 sub_81CDDD4(void);
extern void sub_81CDE2C(s32);
extern u32 sub_81CDE64(void);
extern void sub_81CD1C0(void);
extern void sub_81CECA0(void);
extern u32 sub_81CEF3C(void);
extern u32 sub_81CEFDC(void);
extern bool32 sub_81CF330(void);
extern void sub_81CF3A0(s32);
extern u32 sub_81CF3D0(void);
extern void sub_81CEFF0(void);
extern void sub_81CF3F8(void);
extern u32 sub_81CD024(void);
extern u32 sub_81CEF98(void);
extern bool32 sub_81CF368(void);
extern u32 sub_81CF9BC(void);
extern u32 sub_81CFA34(void);
extern bool32 sub_81CFDD0(void);
extern void sub_81CFE40(s32);
extern u32 sub_81CFE70(void);
extern void sub_81CFA48(void);
extern void sub_81CFE98(void);
extern u32 sub_81D0450(void);
extern u32 sub_81D04A0(void);
extern bool32 sub_81D0978(void);
extern void sub_81D09B0(s32);
extern u32 sub_81D09E0(void);
extern void sub_81D04B8(void);
extern void sub_81D09F4(void);
extern u32 sub_81CFA04(void);
extern bool32 sub_81CFE08(void);
static u32 sub_81C75E0(void);
static u32 sub_81C75D4(void);
static bool32 SetActivePokenavMenu(u32 menuId);
static bool32 AnyMonHasRibbon(void);
u32 sub_81C75E0(void);
u32 sub_81C75D4(void);
u32 PokenavMainMenuLoopedTaskIsActive(void);
bool32 WaitForPokenavShutdownFade(void);
void sub_81C7834(void *func1, void *func2);
static void InitPokenavResources(struct PokenavResources *a0);
void Task_RunLoopedTask_LinkMode(u8 a0);
void Task_RunLoopedTask(u8 taskId);
void sub_81C742C(u8 taskId);
void ShutdownPokenav(void);
static void InitKeys_(void);
static void FreePokenavResources(void);
static void VBlankCB_Pokenav(void);
static void CB2_Pokenav(void);
void sub_81C72BC(void);
static void Task_RunLoopedTask_LinkMode(u8 a0);
static void Task_RunLoopedTask(u8 taskId);
static void sub_81C742C(u8 taskId);
static void sub_81C72BC(void);
const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
{
{
.unk0 = sub_81C9298,
.unk0 = PokenavCallback_Init_0,
.unk4 = sub_81C941C,
.unk8 = sub_81C9924,
.unkC = sub_81C9990,
@ -106,7 +63,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81C99D4,
},
{
.unk0 = sub_81C9298,
.unk0 = PokenavCallback_Init_0,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
@ -115,7 +72,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81C99D4,
},
{
.unk0 = sub_81C9338,
.unk0 = PokenavCallback_Init_2,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
@ -124,7 +81,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81C99D4,
},
{
.unk0 = sub_81C9368,
.unk0 = PokenavCallback_Init_3,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
@ -133,16 +90,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81C99D4,
},
{
.unk0 = sub_81C92CC,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
.unk10 =sub_81C99C0,
.unk14 = sub_81C9430,
.unk18 = sub_81C99D4,
},
{
.unk0 = sub_81C9304,
.unk0 = PokenavCallback_Init_4,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
@ -151,7 +99,16 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81C99D4,
},
{
.unk0 = sub_81CC4D4,
.unk0 = PokenavCallback_Init_5,
.unk4 = sub_81C941C,
.unk8 = sub_81C9940,
.unkC = sub_81C9990,
.unk10 = sub_81C99C0,
.unk14 = sub_81C9430,
.unk18 = sub_81C99D4,
},
{
.unk0 = PokenavCallback_Init_6,
.unk4 = sub_81CC554,
.unk8 = sub_81CC5F4,
.unkC = sub_81CC62C,
@ -160,7 +117,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81CC670,
},
{
.unk0 = sub_81CCFD8,
.unk0 = PokenavCallback_Init_7,
.unk4 = sub_81CD070,
.unk8 = sub_81CDDD4,
.unkC = sub_81CDE2C,
@ -169,7 +126,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81CECA0,
},
{
.unk0 = sub_81CEF3C,
.unk0 = PokenavCallback_Init_8,
.unk4 = sub_81CEFDC,
.unk8 = sub_81CF330,
.unkC = sub_81CF3A0,
@ -178,7 +135,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81CF3F8,
},
{
.unk0 = sub_81CD024,
.unk0 = PokenavCallback_Init_9,
.unk4 = sub_81CD070,
.unk8 = sub_81CDDD4,
.unkC = sub_81CDE2C,
@ -187,7 +144,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81CECA0,
},
{
.unk0 = sub_81CEF98,
.unk0 = PokenavCallback_Init_10,
.unk4 = sub_81CEFDC,
.unk8 = sub_81CF368,
.unkC = sub_81CF3A0,
@ -196,7 +153,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81CF3F8,
},
{
.unk0 = sub_81CAAE8,
.unk0 = PokenavCallback_Init_11,
.unk4 = sub_81CAB24,
.unk8 = sub_81CB260,
.unkC = sub_81CB29C,
@ -205,7 +162,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81CB2E0,
},
{
.unk0 = sub_81CF9BC,
.unk0 = PokenavCallback_Init_12,
.unk4 = sub_81CFA34,
.unk8 = sub_81CFDD0,
.unkC = sub_81CFE40,
@ -214,7 +171,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81CFE98,
},
{
.unk0 = sub_81D0450,
.unk0 = PokenavCallback_Init_13,
.unk4 = sub_81D04A0,
.unk8 = sub_81D0978,
.unkC = sub_81D09B0,
@ -223,7 +180,7 @@ const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
.unk18 = sub_81D09F4,
},
{
.unk0 = sub_81CFA04,
.unk0 = PokenavCallback_Init_14,
.unk4 = sub_81CFA34,
.unk8 = sub_81CFE08,
.unkC = sub_81CFE40,
@ -278,7 +235,7 @@ bool32 FuncIsActiveLoopedTask(LoopedTask func)
return FALSE;
}
void Task_RunLoopedTask(u8 taskId)
static void Task_RunLoopedTask(u8 taskId)
{
LoopedTask loopedTask = (LoopedTask)GetWordTaskArg(taskId, 1);
s16 *state = &gTasks[taskId].data[0];
@ -311,7 +268,7 @@ void Task_RunLoopedTask(u8 taskId)
}
// Every "Continue" action pauses instead.
void Task_RunLoopedTask_LinkMode(u8 taskId)
static void Task_RunLoopedTask_LinkMode(u8 taskId)
{
LoopedTask task;
s16 *state;
@ -366,7 +323,7 @@ void sub_81C72A4(void)
FadeScreen(1, 0);
}
void sub_81C72BC(void)
static void sub_81C72BC(void)
{
UpdatePaletteFade();
if (gPaletteFade.active)
@ -459,7 +416,7 @@ static void VBlankCB_Pokenav(void)
ProcessSpriteCopyRequests();
}
void sub_81C742C(u8 taskId)
static void sub_81C742C(u8 taskId)
{
u32 v1;
s16 *data = gTasks[taskId].data;
@ -545,12 +502,12 @@ static bool32 SetActivePokenavMenu(u32 menuId)
return TRUE;
}
u32 sub_81C75D4(void)
static u32 sub_81C75D4(void)
{
return sub_81C786C();
}
u32 sub_81C75E0(void)
static u32 sub_81C75E0(void)
{
return gPokenavResources->currentMenuCb1();
}

View File

@ -55,7 +55,7 @@ static u8 GetPokenavMainMenuType(void)
return retVal;
}
bool32 sub_81C9298(void)
bool32 PokenavCallback_Init_0(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
if (!state)
@ -69,7 +69,7 @@ bool32 sub_81C9298(void)
return TRUE;
}
bool32 sub_81C92CC(void)
bool32 PokenavCallback_Init_4(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
if (!state)
@ -83,7 +83,7 @@ bool32 sub_81C92CC(void)
return TRUE;
}
bool32 sub_81C9304(void)
bool32 PokenavCallback_Init_5(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
if (!state)
@ -96,7 +96,7 @@ bool32 sub_81C9304(void)
return TRUE;
}
bool32 sub_81C9338(void)
bool32 PokenavCallback_Init_2(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
if (!state)
@ -110,7 +110,7 @@ bool32 sub_81C9338(void)
return TRUE;
}
bool32 sub_81C9368(void)
bool32 PokenavCallback_Init_3(void)
{
struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct));
if (!state)

View File

@ -158,7 +158,7 @@ static const LoopedTask gUnknown_08624BA0[] =
};
// code
bool32 sub_81D0450(void)
bool32 PokenavCallback_Init_13(void)
{
struct PokenavSub13 *structPtr = AllocSubstruct(13, sizeof(struct PokenavSub13));
if (structPtr == NULL)
@ -235,7 +235,7 @@ u32 sub_81D0548(struct PokenavSub13 *structPtr)
u32 sub_81D05D4(struct PokenavSub13 *structPtr)
{
return 0x186ae;
return 100014;
}
bool32 sub_81D05DC(struct PokenavSub13 *structPtr)
@ -472,7 +472,7 @@ bool32 sub_81D0978(void)
return TRUE;
}
void sub_81D09B0(int id)
void sub_81D09B0(s32 id)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(14);
structPtr->loopedTaskId = CreateLoopedTask(gUnknown_08624BA0[id], 1);

View File

@ -42,7 +42,7 @@ static bool32 sub_81CB1D0(void);
const u8 gUnknown_08622508[] = {0, 2};
const u8 gUnknown_0862250A[] = {0, 1, 2};
bool32 sub_81CAAE8(void)
bool32 PokenavCallback_Init_11(void)
{
struct Pokenav3Struct *state = AllocSubstruct(5, sizeof(struct Pokenav3Struct));
if (!state)

View File

@ -166,7 +166,7 @@ const struct SpriteTemplate gUnknown_086231D0 =
.callback = sub_81CCEF4,
};
u32 sub_81CC4D4(void)
u32 PokenavCallback_Init_6(void)
{
struct Pokenav5Struct *state = AllocSubstruct(3, sizeof(struct Pokenav5Struct));
if (!state)
@ -194,7 +194,7 @@ void sub_81CC524(void)
u32 sub_81CC554(void)
{
struct Pokenav5Struct *state = GetSubstructPtr(3);
state->unk10(state);
return state->unk10(state);
}
static u32 sub_81CC568(struct Pokenav5Struct *state)

View File

@ -47,7 +47,7 @@ void sub_81CDA1C(s16 arg0, u8 arg1);
void sub_81CDB98(s16 arg0, u8 arg1);
// code
bool32 sub_81CCFD8(void)
bool32 PokenavCallback_Init_7(void)
{
struct PokenavSub11 *structPtr = AllocSubstruct(11, sizeof(struct PokenavSub11));
@ -61,7 +61,7 @@ bool32 sub_81CCFD8(void)
return TRUE;
}
bool32 sub_81CD024(void)
bool32 PokenavCallback_Init_9(void)
{
struct PokenavSub11 *structPtr = AllocSubstruct(11, sizeof(struct PokenavSub11));
@ -147,9 +147,9 @@ u32 sub_81CD110(struct PokenavSub11 *structPtr)
u32 sub_81CD19C(struct PokenavSub11 *structPtr)
{
if (structPtr->unk6300 == 0)
return 0x186A2;
return 100002;
else
return 0x186AA;
return 100010;
}
void sub_81CD1C0(void)
@ -365,7 +365,7 @@ u8 *sub_81CD624(u8 *str, u16 id, bool8 arg3)
str_ = str; // For some reason, a variable is needed to match.
while (*str_ != EOS)
*(str_++);
(str_++);
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = 0x12;

View File

@ -168,7 +168,7 @@ bool32 sub_81CDDD4(void)
return TRUE;
}
void sub_81CDE2C(int id)
void sub_81CDE2C(s32 id)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC);
structPtr->loopedTaskId = CreateLoopedTask(gUnknown_08623384[id], 1);

View File

@ -29,7 +29,7 @@ struct PokenavSub8
u32 ltid;
u16 winid;
bool32 unkC;
u16 buff[0x400];
u8 buff[BG_SCREEN_SIZE];
}; // size: 0x810
static u32 sub_81CF010(struct PokenavSub7 *structPtr);
@ -117,7 +117,7 @@ static const u8 gUnknown_086235BC[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHI
static const u8 gUnknown_086235C8[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}");
static const u8 gUnknown_086235D4[] = _("{UNK_SPACER}");
bool32 sub_81CEF3C(void)
bool32 PokenavCallback_Init_8(void)
{
struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7));
if (structPtr == NULL)
@ -134,7 +134,7 @@ bool32 sub_81CEF3C(void)
return TRUE;
}
bool32 sub_81CEF98(void)
bool32 PokenavCallback_Init_10(void)
{
struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7));
if (structPtr == NULL)
@ -197,12 +197,12 @@ static u32 sub_81CF030(struct PokenavSub7 *structPtr)
static u32 sub_81CF0B0(struct PokenavSub7 *structPtr)
{
return 0x186A3;
return 100003;
}
static u32 sub_81CF0B8(struct PokenavSub7 *structPtr)
{
return 0x186A9;
return 100009;
}
static u32 sub_81CF0C0(void)
@ -387,7 +387,7 @@ bool32 sub_81CF3D0(void)
return unk->callback();
}
static bool32 sub_81CF3E4(void)
bool32 sub_81CF3E4(void)
{
struct PokenavSub8 * unk = GetSubstructPtr(8);
return IsLoopedTaskActive(unk->ltid);

View File

@ -1,68 +1,91 @@
#include "global.h"
#include "pokenav.h"
#include "bg.h"
#include "menu.h"
#include "window.h"
#include "sound.h"
#include "string_util.h"
#include "international_string_util.h"
#include "constants/songs.h"
struct PokenavSub9
{
u32 (*unk0)(struct PokenavSub9*);
u32 loopedTaskId;
u8 filler[0xC];
u16 winid;
s32 unkC;
s32 unk10;
u32 unk14;
u32 unk18;
struct PokenavSub18 *unk1C;
};
u32 sub_81CFA68(struct PokenavSub9 *structPtr);
u32 sub_81CFA88(struct PokenavSub9 *structPtr);
u32 sub_81CFB08(struct PokenavSub9 *structPtr);
u32 sub_81CFB10(struct PokenavSub9 *structPtr);
u32 sub_81CFB8C(void);
u32 sub_81CFC2C(void);
u32 sub_81CFC40(void);
u32 sub_81CFB74(s32 state);
u32 sub_81CFFFC(s32 state);
u32 sub_81D0074(s32 state);
u32 sub_81D00EC(s32 state);
u32 sub_81D0164(s32 state);
u32 sub_81D01DC(s32 state);
u32 sub_81D021C(s32 state);
struct PokenavSub10
{
bool32 (*callback)(void);
u32 ltid;
u16 winid;
bool32 unkC;
u8 buff[BG_SCREEN_SIZE];
};
u32 (*const gUnknown_086235D8[])(void) =
static u32 sub_81CFA68(struct PokenavSub9 *structPtr);
static u32 sub_81CFA88(struct PokenavSub9 *structPtr);
static u32 sub_81CFB08(struct PokenavSub9 *structPtr);
static u32 sub_81CFB10(struct PokenavSub9 *structPtr);
static u32 sub_81CFB8C(s32 state);
static u32 sub_81CFC2C(s32 state);
static u32 sub_81CFC40(s32 state);
static u32 sub_81CFB74(s32 state);
static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item);
static u32 sub_81CFEB8(s32 state);
static bool32 sub_81CFE84(void);
static u32 sub_81CFFFC(s32 state);
static u32 sub_81D0074(s32 state);
static u32 sub_81D00EC(s32 state);
static u32 sub_81D0164(s32 state);
static u32 sub_81D01DC(s32 state);
static u32 sub_81D021C(s32 state);
static void sub_81D02B0(s32 windowId, s32 val1, s32 val2);
static void sub_81D024C(struct PokenavSub10 *ptr);
static void sub_81D0288(struct PokenavSub10 *ptr);
static void sub_81D0304(void);
static void sub_81D035C(struct PokenavMonList *, u8 *);
static const LoopedTask gUnknown_086235D8[] =
{
sub_81CFB8C,
sub_81CFC2C,
sub_81CFC40
};
const u16 gUnknown_086235E4[] = INCBIN_U16("graphics/pokenav/ui_ribbons.gbapal");
const u32 gUnknown_08623604[] = INCBIN_U32("graphics/pokenav/ui_ribbons.4bpp.lz");
const u32 gUnknown_086236CC[] = INCBIN_U32("graphics/pokenav/ui_ribbons.bin.lz");
const u16 gUnknown_08623790[] = INCBIN_U16("graphics/pokenav/8623790.gbapal");
static const u16 gUnknown_086235E4[] = INCBIN_U16("graphics/pokenav/ui_ribbons.gbapal");
static const u32 gUnknown_08623604[] = INCBIN_U32("graphics/pokenav/ui_ribbons.4bpp.lz");
static const u32 gUnknown_086236CC[] = INCBIN_U32("graphics/pokenav/ui_ribbons.bin.lz");
static const u16 gUnknown_08623790[] = INCBIN_U16("graphics/pokenav/8623790.gbapal");
const struct BgTemplate gUnknown_086237B0 =
static const struct BgTemplate gUnknown_086237B0[] =
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 0x06,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 0x06,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
}, {
.bg = 2,
.charBaseIndex = 2,
.mapBaseIndex = 0x07,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
}
};
const struct BgTemplate gUnknown_086237B4 =
{
.bg = 2,
.charBaseIndex = 2,
.mapBaseIndex = 0x07,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
};
const LoopedTask gUnknown_086237B8[] =
static const LoopedTask gUnknown_086237B8[] =
{
NULL,
sub_81CFFFC,
@ -73,7 +96,7 @@ const LoopedTask gUnknown_086237B8[] =
sub_81D021C
};
const struct WindowTemplate gUnknown_086237D4 =
static const struct WindowTemplate gUnknown_086237D4 =
{
.bg = 1,
.tilemapLeft = 1,
@ -84,11 +107,11 @@ const struct WindowTemplate gUnknown_086237D4 =
.baseBlock = 20
};
const u8 gUnknown_086237DC[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}");
const u8 gUnknown_086237E8[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}");
const u8 gUnknown_086237F4[] = _("{UNK_SPACER}");
static const u8 gUnknown_086237DC[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}");
static const u8 gUnknown_086237E8[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}");
static const u8 gUnknown_086237F4[] = _("{UNK_SPACER}");
bool32 sub_81CF9BC(void)
bool32 PokenavCallback_Init_12(void)
{
struct PokenavSub9 *structPtr = AllocSubstruct(9, sizeof(struct PokenavSub9));
if (structPtr == NULL)
@ -104,7 +127,7 @@ bool32 sub_81CF9BC(void)
return TRUE;
}
bool32 sub_81CFA04(void)
bool32 PokenavCallback_Init_14(void)
{
struct PokenavSub9 *structPtr = AllocSubstruct(9, sizeof(struct PokenavSub9));
if (structPtr == NULL)
@ -130,14 +153,14 @@ void sub_81CFA48(void)
FreePokenavSubstruct(9);
}
u32 sub_81CFA68(struct PokenavSub9 *structPtr)
static u32 sub_81CFA68(struct PokenavSub9 *structPtr)
{
if (!IsLoopedTaskActive(structPtr->loopedTaskId))
structPtr->unk0 = sub_81CFA88;
return 0;
}
u32 sub_81CFA88(struct PokenavSub9 *structPtr)
static u32 sub_81CFA88(struct PokenavSub9 *structPtr)
{
if (gMain.newAndRepeatedKeys & DPAD_UP)
return 1;
@ -163,18 +186,541 @@ u32 sub_81CFA88(struct PokenavSub9 *structPtr)
return 0;
}
u32 sub_81CFB08(struct PokenavSub9 *structPtr)
static u32 sub_81CFB08(struct PokenavSub9 *structPtr)
{
return 0x186a5;
return 100005;
}
u32 sub_81CFB10(struct PokenavSub9 *structPtr)
static u32 sub_81CFB10(struct PokenavSub9 *structPtr)
{
return 0x186ad;
return 100013;
}
u32 sub_81CFB18(void)
static u32 sub_81CFB18(void)
{
struct PokenavSub9 *structPtr = GetSubstructPtr(9);
return structPtr->unk14;
}
static struct PokenavMonList * sub_81CFB28(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(9);
return ptr->unk1C->unk4;
}
static s32 sub_81CFB38(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(9);
return ptr->unk1C->unk0;
}
static s32 sub_81CFB48(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(9);
s32 idx = GetSelectedMatchCall();
return ptr->unk1C->unk4[idx].unk6;
}
static s32 sub_81CFB64(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(9);
return ptr->unk1C->unk2;
}
static u32 sub_81CFB74(s32 state)
{
return gUnknown_086235D8[state](state);
}
static u32 sub_81CFB8C(s32 state)
{
s32 i;
struct PokenavMonList item;
struct PokenavSub9 * ptr = GetSubstructPtr(9);
ptr->unk1C->unk0 = 0;
ptr->unk1C->unk2 = 0;
item.boxId = 14;
for (i = 0; i < PARTY_SIZE; i++)
{
struct Pokemon * pokemon = &gPlayerParty[i];
if (!GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES))
return LT_INC_AND_CONTINUE;
if (!GetMonData(pokemon, MON_DATA_SANITY_IS_EGG) && !GetMonData(pokemon, MON_DATA_SANITY_IS_BAD_EGG))
{
u32 ribbonCount = GetMonData(pokemon, MON_DATA_RIBBON_COUNT);
if (ribbonCount != 0)
{
item.monId = i;
item.unk6 = ribbonCount;
sub_81CFCEC(ptr, &item);
}
}
}
return LT_INC_AND_CONTINUE;
}
static u32 sub_81CFC2C(s32 state)
{
struct PokenavSub9 * ptr = GetSubstructPtr(9);
ptr->unk10 = 0;
ptr->unkC = 0;
return LT_INC_AND_CONTINUE;
}
static u32 sub_81CFC40(s32 state)
{
struct PokenavSub9 * ptr = GetSubstructPtr(9);
s32 boxId = ptr->unkC;
s32 monId = ptr->unk10;
s32 boxCount = 0;
struct PokenavMonList item;
while (boxId < TOTAL_BOXES_COUNT)
{
while (monId < IN_BOX_COUNT)
{
if (CheckBoxMonSanityAt(boxId, monId))
{
u32 ribbonCount = GetBoxMonDataAt(boxId, monId, MON_DATA_RIBBON_COUNT);
if (ribbonCount != 0)
{
item.boxId = boxId;
item.monId = monId;
item.unk6 = ribbonCount;
sub_81CFCEC(ptr, &item);
}
}
boxCount++;
monId++;
if (boxCount > 14)
{
ptr->unkC = boxId;
ptr->unk10 = monId;
return LT_CONTINUE;
}
}
monId = 0;
boxId++;
}
ptr->unk14 = 1;
return LT_FINISH;
}
static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item)
{
u32 left = 0;
u32 right = structPtr->unk1C->unk0;
u32 insertionIdx = left + (right - left) / 2;
while (right != insertionIdx)
{
if (item->unk6 > structPtr->unk1C->unk4[insertionIdx].unk6)
right = insertionIdx;
else
left = insertionIdx + 1;
insertionIdx = left + (right - left) / 2;
}
for (right = structPtr->unk1C->unk0; right > insertionIdx; right--)
structPtr->unk1C->unk4[right] = structPtr->unk1C->unk4[right - 1];
structPtr->unk1C->unk4[insertionIdx] = *item;
structPtr->unk1C->unk0++;
}
static bool32 sub_81CFD58(void)
{
s32 i, j;
for (i = 0; i < PARTY_SIZE; i++)
{
struct Pokemon * mon = &gPlayerParty[i];
if (!GetMonData(mon, MON_DATA_SANITY_HAS_SPECIES))
continue;
if (GetMonData(mon, MON_DATA_SANITY_IS_EGG))
continue;
if (GetMonData(mon, MON_DATA_RIBBONS))
return TRUE;
}
for (i = 0; i < TOTAL_BOXES_COUNT; i++)
{
for (j = 0; j < IN_BOX_COUNT; j++)
{
if (!CheckBoxMonSanityAt(i, j))
continue;
if (GetBoxMonDataAt(i, j, MON_DATA_RIBBONS))
return TRUE;
}
}
return FALSE;
}
bool32 sub_81CFDD0(void)
{
struct PokenavSub10 * ptr = AllocSubstruct(10, sizeof(struct PokenavSub10));
if (ptr == NULL)
return FALSE;
ptr->ltid = CreateLoopedTask(sub_81CFEB8, 1);
ptr->callback = sub_81CFE84;
ptr->unkC = FALSE;
return TRUE;
}
bool32 sub_81CFE08(void)
{
struct PokenavSub10 * ptr = AllocSubstruct(10, sizeof(struct PokenavSub10));
if (ptr == NULL)
return FALSE;
ptr->ltid = CreateLoopedTask(sub_81CFEB8, 1);
ptr->callback = sub_81CFE84;
ptr->unkC = TRUE;
return TRUE;
}
void sub_81CFE40(s32 idx)
{
struct PokenavSub10 * ptr = GetSubstructPtr(10);
ptr->ltid = CreateLoopedTask(gUnknown_086237B8[idx], 1);
ptr->callback = sub_81CFE84;
}
bool32 sub_81CFE70(void)
{
struct PokenavSub10 * ptr = GetSubstructPtr(10);
return ptr->callback();
}
bool32 sub_81CFE84(void)
{
struct PokenavSub10 * ptr = GetSubstructPtr(10);
return IsLoopedTaskActive(ptr->ltid);
}
void sub_81CFE98(void)
{
struct PokenavSub10 * ptr = GetSubstructPtr(10);
sub_81C8234();
RemoveWindow(ptr->winid);
FreePokenavSubstruct(10);
}
static u32 sub_81CFEB8(s32 state)
{
struct PokenavSub10 * unk = GetSubstructPtr(10);
switch (state)
{
case 0:
InitBgTemplates(gUnknown_086237B0, NELEMS(gUnknown_086237B0));
decompress_and_copy_tile_data_to_vram(1, gUnknown_08623604, 0, 0, 0);
SetBgTilemapBuffer(1, unk->buff);
CopyToBgTilemapBuffer(1, gUnknown_086236CC, 0, 0);
CopyPaletteIntoBufferUnfaded(gUnknown_086235E4, 0x10, 0x20);
CopyBgTilemapBufferToVram(1);
return LT_INC_AND_PAUSE;
case 1:
if (free_temp_tile_data_buffers_if_possible())
return LT_PAUSE;
if (!sub_81CFB18())
return LT_PAUSE;
ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0);
ShowBg(1);
return LT_INC_AND_PAUSE;
case 2:
if (free_temp_tile_data_buffers_if_possible())
return LT_PAUSE;
CopyPaletteIntoBufferUnfaded(gUnknown_08623790, 0x20, 0x20);
sub_81D0304();
return LT_INC_AND_PAUSE;
case 3:
if (sub_81C8224())
return LT_PAUSE;
sub_81D024C(unk);
return LT_INC_AND_PAUSE;
case 4:
if (free_temp_tile_data_buffers_if_possible())
return LT_PAUSE;
ShowBg(2);
HideBg(3);
sub_81C7BA4(9);
sub_81C7AC0(1);
if (!unk->unkC)
{
LoadLeftHeaderGfxForIndex(2);
sub_81C7FA0(2, 1, 0);
}
return LT_INC_AND_PAUSE;
case 5:
if (IsPaletteFadeActive())
return LT_PAUSE;
if (sub_81C8010())
return LT_PAUSE;
break;
}
return LT_FINISH;
}
static u32 sub_81CFFFC(s32 state)
{
struct PokenavSub10 * unk = GetSubstructPtr(10);
switch (state)
{
case 0:
switch (MatchCall_MoveCursorUp())
{
case 0:
return LT_FINISH;
case 1:
PlaySE(SE_SELECT);
return LT_SET_STATE(2);
case 2:
PlaySE(SE_SELECT);
break;
}
return LT_INC_AND_PAUSE;
case 1:
if (sub_81C8630())
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(unk);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
break;
}
return LT_FINISH;
}
static u32 sub_81D0074(s32 state)
{
struct PokenavSub10 * unk = GetSubstructPtr(10);
switch (state)
{
case 0:
switch (MatchCall_MoveCursorDown())
{
case 0:
return LT_FINISH;
case 1:
PlaySE(SE_SELECT);
return LT_SET_STATE(2);
case 2:
PlaySE(SE_SELECT);
break;
}
return LT_INC_AND_PAUSE;
case 1:
if (sub_81C8630())
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(unk);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
break;
}
return LT_FINISH;
}
static u32 sub_81D00EC(s32 state)
{
struct PokenavSub10 * unk = GetSubstructPtr(10);
switch (state)
{
case 0:
switch (MatchCall_PageUp())
{
case 0:
return LT_FINISH;
case 1:
PlaySE(SE_SELECT);
return LT_SET_STATE(2);
case 2:
PlaySE(SE_SELECT);
break;
}
return LT_INC_AND_PAUSE;
case 1:
if (sub_81C8630())
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(unk);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
break;
}
return LT_FINISH;
}
static u32 sub_81D0164(s32 state)
{
struct PokenavSub10 * unk = GetSubstructPtr(10);
switch (state)
{
case 0:
switch (MatchCall_PageDown())
{
case 0:
return LT_FINISH;
case 1:
PlaySE(SE_SELECT);
return LT_SET_STATE(2);
case 2:
PlaySE(SE_SELECT);
break;
}
return LT_INC_AND_PAUSE;
case 1:
if (sub_81C8630())
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(unk);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
break;
}
return LT_FINISH;
}
static u32 sub_81D01DC(s32 state)
{
switch (state)
{
case 0:
PlaySE(SE_SELECT);
sub_81C7AC0(0);
sub_81C78A0();
return LT_INC_AND_PAUSE;
case 1:
if (IsPaletteFadeActive())
return LT_PAUSE;
if (MainMenuLoopedTaskIsBusy())
return LT_PAUSE;
sub_81C7FDC();
break;
}
return LT_FINISH;
}
static u32 sub_81D021C(s32 state)
{
switch (state)
{
case 0:
PlaySE(SE_SELECT);
sub_81C7AC0(0);
return LT_INC_AND_PAUSE;
case 1:
if (IsPaletteFadeActive())
return LT_PAUSE;
break;
}
return LT_FINISH;
}
static void sub_81D024C(struct PokenavSub10 * ptr)
{
s32 r2;
ptr->winid = AddWindow(&gUnknown_086237D4);
PutWindowTilemap(ptr->winid);
r2 = sub_81CFB38();
sub_81D02B0(ptr->winid, 0, r2);
CopyWindowToVram(ptr->winid, 1);
sub_81D0288(ptr);
}
static void sub_81D0288(struct PokenavSub10 * ptr)
{
s32 r4 = GetSelectedMatchCall();
s32 r2 = sub_81CFB38();
sub_81D02B0(ptr->winid, r4 + 1, r2);
CopyWindowToVram(ptr->winid, 2);
}
static void sub_81D02B0(s32 windowId, s32 val1, s32 val2)
{
u8 strbuf[16];
u32 x;
u8 * ptr = strbuf;
ptr = ConvertIntToDecimalStringN(ptr, val1, STR_CONV_MODE_RIGHT_ALIGN, 3);
*ptr++ = CHAR_SLASH;
ConvertIntToDecimalStringN(ptr, val2, STR_CONV_MODE_RIGHT_ALIGN, 3);
x = GetStringCenterAlignXOffset(1, strbuf, 56);
AddTextPrinterParameterized(windowId, 1, strbuf,x, 1, 0xFF, NULL);
}
static void sub_81D0304(void)
{
struct MatchCallListTemplate template;
template.unk0 = sub_81CFB28();
template.unk4 = sub_81CFB38();
template.unk8 = 4;
template.unk6 = sub_81CFB64();
template.unk9 = 13;
template.unkA = 17;
template.unkB = 1;
template.unkC = 8;
template.unkD = 2;
template.unkE = 1;
template.unk10 = sub_81D035C;
template.unk14 = NULL;
sub_81C81D4(&gUnknown_086237B0[1], &template, 0);
}
static void sub_81D035C(struct PokenavMonList * item0, u8 * dest)
{
u8 gender;
u8 level;
u8 * s;
const u8 * genderStr;
struct PokenavMonList * item = item0;
if (item->boxId == 14)
{
struct Pokemon * mon = &gPlayerParty[item->monId];
gender = GetMonGender(mon);
level = GetLevelFromMonExp(mon);
GetMonData(mon, MON_DATA_NICKNAME, gStringVar3);
}
else
{
struct BoxPokemon * mon = GetBoxedMonPtr(item->boxId, item->monId);
gender = GetBoxMonGender(mon);
level = GetLevelFromBoxMonExp(mon);
GetBoxMonData(mon, MON_DATA_NICKNAME, gStringVar3);
}
StringGetEnd10(gStringVar3);
dest = sub_81DB494(dest, 1, gStringVar3, 60);
switch (gender)
{
default:
genderStr = gUnknown_086237F4;
break;
case MON_MALE:
genderStr = gUnknown_086237DC;
break;
case MON_FEMALE:
genderStr = gUnknown_086237E8;
break;
}
s = StringCopy(gStringVar1, genderStr);
*s++ = CHAR_SLASH;
*s++ = CHAR_SPECIAL_F9;
*s++ = 5; // LV
ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3);
dest = sub_81DB494(dest, 1, gStringVar1, 54);
ConvertIntToDecimalStringN(dest, item->unk6, STR_CONV_MODE_RIGHT_ALIGN, 2);
}