Cleanup some pokenav code

This commit is contained in:
Marcus Huderle 2019-04-13 15:54:05 -05:00 committed by huderlem
parent 1268691410
commit 065c60544d
6 changed files with 196 additions and 182 deletions

View File

@ -1506,7 +1506,7 @@ sub_81CBE50: @ 81CBE50
movs r0, 0x9 movs r0, 0x9
bl GetGameStat bl GetGameStat
adds r1, r0, 0 adds r1, r0, 0
ldr r0, =0x0001869f @ Note to decompiler: See UNKNOWN_POKENAV_OFFSET ldr r0, =0x0001869f
cmp r1, r0 cmp r1, r0
ble _081CBE68 ble _081CBE68
adds r1, r0, 0 adds r1, r0, 0

View File

@ -1,7 +1,7 @@
#ifndef GUARD_POKENAV_H #ifndef GUARD_POKENAV_H
#define GUARD_POKENAV_H #define GUARD_POKENAV_H
typedef u32 (*LoopedTask)(s32 state); typedef u32 (*LoopedTask)(int state);
// Return values of LoopedTask functions. // Return values of LoopedTask functions.
#define LT_INC_AND_PAUSE 0 #define LT_INC_AND_PAUSE 0
@ -11,7 +11,32 @@ typedef u32 (*LoopedTask)(s32 state);
#define LT_FINISH 4 #define LT_FINISH 4
#define LT_SET_STATE(newState) (newState + 5) #define LT_SET_STATE(newState) (newState + 5)
#define UNKNOWN_POKENAV_OFFSET 100000 enum
{
POKENAV_MODE_NORMAL, // Chosen from Start menu.
POKENAV_MODE_FORCE_CALL_1, // Used for the script's special. Has to choose Match Call and make a call.
POKENAV_MODE_FORCE_CALL_2, // Set after making a call, has to exit Pokenav.
};
#define POKENAV_MENU_IDS_START 100000
enum
{
POKENAV_MENU_0 = POKENAV_MENU_IDS_START,
POKENAV_MENU_1,
POKENAV_MENU_2,
POKENAV_MENU_3,
POKENAV_MENU_4,
POKENAV_MENU_5,
POKENAV_MENU_6,
POKENAV_MENU_7,
POKENAV_MENU_8,
POKENAV_MENU_9,
POKENAV_MENU_A,
POKENAV_MENU_B,
POKENAV_MENU_C,
POKENAV_MENU_D,
POKENAV_MENU_E,
};
// pokenav.c // pokenav.c
void sub_81C7694(u32); void sub_81C7694(u32);
@ -31,6 +56,12 @@ bool32 CanViewRibbonsMenu(void);
// pokenav_match_call_ui.c // pokenav_match_call_ui.c
// pokenav_main_menu.c
bool32 InitPokenavMainMenu(void);
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size);
void sub_81C7850(u32 a0);
u32 sub_81C786C(void);
// pokenav_unk_1.c // pokenav_unk_1.c
bool32 sub_81C9298(void); bool32 sub_81C9298(void);
bool32 sub_81C92CC(void); bool32 sub_81C92CC(void);
@ -43,6 +74,7 @@ int sub_81C9894(void);
// pokenav_unk_2.c // pokenav_unk_2.c
u32 sub_81C99D4(void); u32 sub_81C99D4(void);
void sub_81CAADC(void);
#endif //GUARD_POKENAV_H #endif //GUARD_POKENAV_H

View File

@ -4039,7 +4039,7 @@ void sub_80C0460(u16 weight, u8 left, u8 top)
lsls r2, 24\n\ lsls r2, 24\n\
lsrs r2, 24\n\ lsrs r2, 24\n\
str r2, [sp, 0x10]\n\ str r2, [sp, 0x10]\n\
ldr r5, =0x000186a0 @ Note to decompiler: See UNKNOWN_POKENAV_OFFSET\n\ ldr r5, =0x000186a0\n\
muls r0, r5\n\ muls r0, r5\n\
ldr r1, =0x000011b8\n\ ldr r1, =0x000011b8\n\
bl __divsi3\n\ bl __divsi3\n\
@ -4073,7 +4073,7 @@ _080C04C0:\n\
mov r8, r1\n\ mov r8, r1\n\
movs r6, 0x1\n\ movs r6, 0x1\n\
_080C04C6:\n\ _080C04C6:\n\
ldr r1, =0x000186a0 @ Note to decompiler: See UNKNOWN_POKENAV_OFFSET\n\ ldr r1, =0x000186a0\n\
adds r0, r7, 0\n\ adds r0, r7, 0\n\
bl __umodsi3\n\ bl __umodsi3\n\
adds r7, r0, 0\n\ adds r7, r0, 0\n\

View File

@ -8,13 +8,6 @@
#include "pokemon_storage_system.h" #include "pokemon_storage_system.h"
#include "pokenav.h" #include "pokenav.h"
enum
{
MODE_NORMAL, // Chosen from Start menu.
MODE_FORCE_CALL_1, // Used for the script's special. Has to choose Match Call and make a call.
MODE_FORCE_CALL_2, // Set after making a call, has to exit Pokenav.
};
#define LOOPED_TASK_DECODE_STATE(action) (action - 5) #define LOOPED_TASK_DECODE_STATE(action) (action - 5)
#define LOOPED_TASK_ID(primary, secondary) (((secondary) << 16) |(primary)) #define LOOPED_TASK_ID(primary, secondary) (((secondary) << 16) |(primary))
@ -96,17 +89,14 @@ extern u32 sub_81D09F4(void);
extern u32 sub_81CFA04(void); extern u32 sub_81CFA04(void);
extern u32 sub_81CFE08(void); extern u32 sub_81CFE08(void);
bool32 SetActivePokenavMenu(u32 a0); static bool32 SetActivePokenavMenu(u32 menuId);
bool32 InitPokenavMainMenu(void);
static bool32 AnyMonHasRibbon(void); static bool32 AnyMonHasRibbon(void);
u32 sub_81C75E0(void); u32 sub_81C75E0(void);
u32 sub_81C75D4(void); u32 sub_81C75D4(void);
u32 PokenavMainMenuLoopedTaskIsActive(void); u32 PokenavMainMenuLoopedTaskIsActive(void);
u32 sub_81C786C(void);
bool32 WaitForPokenavShutdownFade(void); bool32 WaitForPokenavShutdownFade(void);
void sub_81C7834(void *func1, void *func2); void sub_81C7834(void *func1, void *func2);
static void InitPokenavResources(struct PokenavResources *a0); static void InitPokenavResources(struct PokenavResources *a0);
void sub_81C7850(u32 a0);
void Task_RunLoopedTask_LinkMode(u8 a0); void Task_RunLoopedTask_LinkMode(u8 a0);
void Task_RunLoopedTask(u8 taskId); void Task_RunLoopedTask(u8 taskId);
void sub_81C742C(u8 taskId); void sub_81C742C(u8 taskId);
@ -117,7 +107,6 @@ static void VBlankCB_Pokenav(void);
static void CB2_Pokenav(void); static void CB2_Pokenav(void);
void sub_81C72BC(void); void sub_81C72BC(void);
// Const rom data.
const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] = const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] =
{ {
{ {
@ -291,7 +280,7 @@ bool32 IsLoopedTaskActive(u32 taskId)
bool32 FuncIsActiveLoopedTask(LoopedTask func) bool32 FuncIsActiveLoopedTask(LoopedTask func)
{ {
s32 i; int i;
for (i = 0; i < NUM_TASKS; i++) for (i = 0; i < NUM_TASKS; i++)
{ {
if (gTasks[i].isActive if (gTasks[i].isActive
@ -404,7 +393,7 @@ void sub_81C72BC(void)
else else
{ {
InitPokenavResources(gPokenavResources); InitPokenavResources(gPokenavResources);
gPokenavResources->mode = MODE_FORCE_CALL_1; gPokenavResources->mode = POKENAV_MODE_FORCE_CALL_1;
ResetTasks(); ResetTasks();
ResetSpriteData(); ResetSpriteData();
FreeAllSpritePalettes(); FreeAllSpritePalettes();
@ -417,7 +406,7 @@ void sub_81C72BC(void)
static void FreePokenavResources(void) static void FreePokenavResources(void)
{ {
s32 i; int i;
for (i = 0; i < SUBSTRUCT_COUNT; i++) for (i = 0; i < SUBSTRUCT_COUNT; i++)
FreePokenavSubstruct(i); FreePokenavSubstruct(i);
@ -428,12 +417,12 @@ static void FreePokenavResources(void)
static void InitPokenavResources(struct PokenavResources *a0) static void InitPokenavResources(struct PokenavResources *a0)
{ {
s32 i; int i;
for (i = 0; i < SUBSTRUCT_COUNT; i++) for (i = 0; i < SUBSTRUCT_COUNT; i++)
a0->field10[i] = NULL; a0->field10[i] = NULL;
a0->mode = MODE_NORMAL; a0->mode = POKENAV_MODE_NORMAL;
a0->currentMenuIndex = 0; a0->currentMenuIndex = 0;
a0->hasAnyRibbons = AnyMonHasRibbon(); a0->hasAnyRibbons = AnyMonHasRibbon();
a0->currentMenuCb1 = NULL; a0->currentMenuCb1 = NULL;
@ -441,7 +430,7 @@ static void InitPokenavResources(struct PokenavResources *a0)
static bool32 AnyMonHasRibbon(void) static bool32 AnyMonHasRibbon(void)
{ {
s32 i, j; int i, j;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
@ -498,7 +487,7 @@ void sub_81C742C(u8 taskId)
// Wait for LoopedTask_InitPokenavMenu to finish // Wait for LoopedTask_InitPokenavMenu to finish
if (PokenavMainMenuLoopedTaskIsActive()) if (PokenavMainMenuLoopedTaskIsActive())
break; break;
SetActivePokenavMenu(0 + UNKNOWN_POKENAV_OFFSET); SetActivePokenavMenu(POKENAV_MENU_0);
data[0] = 4; data[0] = 4;
break; break;
case 2: case 2:
@ -512,7 +501,7 @@ void sub_81C742C(u8 taskId)
ShutdownPokenav(); ShutdownPokenav();
data[0] = 5; data[0] = 5;
} }
else if (v1 >= UNKNOWN_POKENAV_OFFSET) else if (v1 >= POKENAV_MENU_IDS_START)
{ {
PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].unk18(); PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].unk18();
PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].unk14(); PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].unk14();
@ -540,7 +529,7 @@ void sub_81C742C(u8 taskId)
case 5: case 5:
if (!WaitForPokenavShutdownFade()) if (!WaitForPokenavShutdownFade())
{ {
bool32 calledFromScript = (gPokenavResources->mode != MODE_NORMAL); bool32 calledFromScript = (gPokenavResources->mode != POKENAV_MODE_NORMAL);
sub_81C9430(); sub_81C9430();
FreePokenavResources(); FreePokenavResources();
@ -553,9 +542,9 @@ void sub_81C742C(u8 taskId)
} }
} }
bool32 SetActivePokenavMenu(u32 indexWithOffset) static bool32 SetActivePokenavMenu(u32 menuId)
{ {
u32 index = indexWithOffset - UNKNOWN_POKENAV_OFFSET; u32 index = menuId - POKENAV_MENU_IDS_START;
InitKeys_(); InitKeys_();
if (!PokenavMenuCallbacks[index].unk0()) if (!PokenavMenuCallbacks[index].unk0())

View File

@ -19,12 +19,10 @@ enum
POKENAV_GFX_CONDITION_MENU, POKENAV_GFX_CONDITION_MENU,
POKENAV_GFX_RIBBONS_MENU, POKENAV_GFX_RIBBONS_MENU,
POKENAV_GFX_MATCH_CALL_MENU, POKENAV_GFX_MATCH_CALL_MENU,
// One of these is for the zoomed-in map, and the other is for the // One of these is for the zoomed-in map, and the other is for the
// zoomed-out map. Don't know which is which yet. // zoomed-out map. Don't know which is which yet.
POKENAV_GFX_MAP_MENU_UNK0, POKENAV_GFX_MAP_MENU_UNK0,
POKENAV_GFX_MAP_MENU_UNK1, POKENAV_GFX_MAP_MENU_UNK1,
POKENAV_GFX_PARTY_MENU, POKENAV_GFX_PARTY_MENU,
POKENAV_GFX_SEARCH_MENU, POKENAV_GFX_SEARCH_MENU,
POKENAV_GFX_COOL_MENU, POKENAV_GFX_COOL_MENU,
@ -32,8 +30,7 @@ enum
POKENAV_GFX_CUTE_MENU, POKENAV_GFX_CUTE_MENU,
POKENAV_GFX_SMART_MENU, POKENAV_GFX_SMART_MENU,
POKENAV_GFX_TOUGH_MENU, POKENAV_GFX_TOUGH_MENU,
POKENAV_GFX_MENUS_END,
POKENAV_GFX_MENUS_END
}; };
#define POKENAV_GFX_SUBMENUS_START POKENAV_GFX_PARTY_MENU #define POKENAV_GFX_SUBMENUS_START POKENAV_GFX_PARTY_MENU
@ -60,27 +57,23 @@ struct CompressedSpriteSheetNoSize
u32 tag; u32 tag;
}; };
extern void sub_81CAADC(void); static void CleanupPokenavMainMenuResources(void);
void CleanupPokenavMainMenuResources(void); static void LoadLeftHeaderGfxForSubMenu(u32 arg0);
void LoadLeftHeaderGfxForSubMenu(u32 arg0); static void LoadLeftHeaderGfxForMenu(u32 index);
void LoadLeftHeaderGfxForMenu(u32 arg0); static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide);
void HideLeftHeaderSubmenuSprites(bool32 arg0); static void HideLeftHeaderSprites(bool32 isOnRightSide);
void HideLeftHeaderSprites(bool32 arg0); static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide);
void ShowLeftHeaderSprites(u32 arg0, bool32 arg1); static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide);
void ShowLeftHeaderSubmenuSprites(u32 arg0, bool32 arg1); static void MoveLeftHeader(struct Sprite *sprite, int startX, int endX, int duration);
void MoveLeftHeader(struct Sprite *sprite, s32 arg1, s32 arg2, s32 arg3); static void SpriteCB_MoveLeftHeader(struct Sprite *sprite);
void SpriteCB_MoveLeftHeader(struct Sprite *sprite); static void InitPokenavMainMenuResources(void);
void InitPokenavMainMenuResources(void); static void InitHoennMapHeaderSprites(void);
void InitHoennMapHeaderSprites(void); static void sub_81C7B74(void);
void sub_81C7B74(void); static u32 LoopedTask_ScrollMenuHeaderDown(int a0);
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 a1, u32 a2); static u32 LoopedTask_ScrollMenuHeaderUp(int a0);
u32 LoopedTask_ScrollMenuHeaderDown(s32 a0); static void sub_81C7BF8(u32 a0);
u32 LoopedTask_ScrollMenuHeaderUp(s32 a0); static void SpriteCB_SpinningPokenav(struct Sprite* sprite);
void sub_81C7BF8(u32 a0); static u32 LoopedTask_InitPokenavMenu(int a0);
void SpriteCB_SpinningPokenav(struct Sprite* sprite);
u32 LoopedTask_InitPokenavMenu(s32 a0);
const u16 gSpinningPokenavPaletteData[] = INCBIN_U16("graphics/pokenav/icon2.gbapal"); const u16 gSpinningPokenavPaletteData[] = INCBIN_U16("graphics/pokenav/icon2.gbapal");
const u32 gSpinningPokenavGfx[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz"); const u32 gSpinningPokenavGfx[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz");
@ -121,7 +114,7 @@ const struct WindowTemplate gUnknown_0861FA08[2] =
}, },
}; };
const u8 *const sMenuButtonReminders[12] = const u8 *const sHelpBarTexts[12] =
{ {
gText_Pokenav_ClearButtonList, gText_Pokenav_ClearButtonList,
gText_PokenavMap_ZoomedOutButtons, gText_PokenavMap_ZoomedOutButtons,
@ -367,7 +360,7 @@ bool32 WaitForPokenavShutdownFade(void)
return TRUE; return TRUE;
} }
u32 LoopedTask_InitPokenavMenu(s32 a0) static u32 LoopedTask_InitPokenavMenu(int a0)
{ {
struct PokenavMainMenuResources *structPtr; struct PokenavMainMenuResources *structPtr;
@ -447,7 +440,7 @@ bool32 MainMenuLoopedTaskIsBusy(void)
return IsLoopedTaskActive(structPtr->currentTaskId); return IsLoopedTaskActive(structPtr->currentTaskId);
} }
u32 LoopedTask_ScrollMenuHeaderDown(s32 a0) static u32 LoopedTask_ScrollMenuHeaderDown(int a0)
{ {
switch (a0) switch (a0)
{ {
@ -468,7 +461,7 @@ u32 LoopedTask_ScrollMenuHeaderDown(s32 a0)
} }
} }
u32 LoopedTask_ScrollMenuHeaderUp(s32 a0) static u32 LoopedTask_ScrollMenuHeaderUp(int a0)
{ {
if (ChangeBgY(0, 384, 2) <= 0) if (ChangeBgY(0, 384, 2) <= 0)
{ {
@ -508,7 +501,7 @@ void sub_81C7990(u32 a0, u16 a1)
CpuFill16(a1, gPlttBufferFaded + 0x100 + (a0 * 16), 16 * sizeof(u16)); CpuFill16(a1, gPlttBufferFaded + 0x100 + (a0 * 16), 16 * sizeof(u16));
} }
__attribute__((naked)) NAKED
void sub_81C79BC(u16 *a0, u16 *a1, u32 a2, u32 a3, u32 a4, u32 a5) void sub_81C79BC(u16 *a0, u16 *a1, u32 a2, u32 a3, u32 a4, u32 a5)
{ {
asm(".syntax unified\n\ asm(".syntax unified\n\
@ -644,7 +637,7 @@ _081C7AAE:\n\
.syntax divided"); .syntax divided");
} }
void sub_81C7AC0(s32 a0) void sub_81C7AC0(int a0)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
@ -675,15 +668,15 @@ void sub_81C7B40(void)
BlendPalettes(0xFFFEFFFE, 16, RGB_BLACK); BlendPalettes(0xFFFEFFFE, 16, RGB_BLACK);
} }
void InitBgTemplates(const struct BgTemplate *templates, s32 count) void InitBgTemplates(const struct BgTemplate *templates, int count)
{ {
s32 i; int i;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
InitBgFromTemplate(templates++); InitBgFromTemplate(templates++);
} }
void sub_81C7B74(void) static void sub_81C7B74(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
@ -694,12 +687,12 @@ void sub_81C7B74(void)
CopyWindowToVram(structPtr->unk10, 3); // TODO: Use a defined constant here. CopyWindowToVram(structPtr->unk10, 3); // TODO: Use a defined constant here.
} }
void sub_81C7BA4(u32 a0) void sub_81C7BA4(u32 helpBarIndex)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
sub_81C7BF8(structPtr->unk10); sub_81C7BF8(structPtr->unk10);
AddTextPrinterParameterized3(structPtr->unk10, 1, 0, 1, gMenuButtonReminderColor, 0, sMenuButtonReminders[a0]); AddTextPrinterParameterized3(structPtr->unk10, 1, 0, 1, gMenuButtonReminderColor, 0, sHelpBarTexts[helpBarIndex]);
} }
bool32 IsDma3ManagerBusyWithBgCopy_(void) bool32 IsDma3ManagerBusyWithBgCopy_(void)
@ -707,15 +700,15 @@ bool32 IsDma3ManagerBusyWithBgCopy_(void)
return IsDma3ManagerBusyWithBgCopy(); return IsDma3ManagerBusyWithBgCopy();
} }
void sub_81C7BF8(u32 windowId) static void sub_81C7BF8(u32 windowId)
{ {
FillWindowPixelBuffer(windowId, PIXEL_FILL(4)); FillWindowPixelBuffer(windowId, PIXEL_FILL(4));
FillWindowPixelRect(windowId, PIXEL_FILL(5), 0, 0, 0x80, 1); FillWindowPixelRect(windowId, PIXEL_FILL(5), 0, 0, 0x80, 1);
} }
void InitPokenavMainMenuResources(void) static void InitPokenavMainMenuResources(void)
{ {
s32 i; int i;
u8 spriteId; u8 spriteId;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
@ -728,7 +721,7 @@ void InitPokenavMainMenuResources(void)
structPtr->spinningPokenav = &gSprites[spriteId]; structPtr->spinningPokenav = &gSprites[spriteId];
} }
void CleanupPokenavMainMenuResources(void) static void CleanupPokenavMainMenuResources(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
@ -737,7 +730,7 @@ void CleanupPokenavMainMenuResources(void)
FreeSpritePaletteByTag(0); FreeSpritePaletteByTag(0);
} }
void SpriteCB_SpinningPokenav(struct Sprite *sprite) static void SpriteCB_SpinningPokenav(struct Sprite *sprite)
{ {
// If the background starts scrolling, follow it. // If the background starts scrolling, follow it.
sprite->pos2.y = (GetBgY(0) / 256u) * -1; sprite->pos2.y = (GetBgY(0) / 256u) * -1;
@ -763,15 +756,15 @@ void ResumeSpinningPokenavSprite(void)
structPtr->spinningPokenav->subpriority = 0; structPtr->spinningPokenav->subpriority = 0;
} }
void InitHoennMapHeaderSprites(void) static void InitHoennMapHeaderSprites(void)
{ {
s32 i, spriteId; int i, spriteId;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet); LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet);
AllocSpritePalette(1); AllocSpritePalette(1);
AllocSpritePalette(2); AllocSpritePalette(2);
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
{ {
spriteId = CreateSprite(&sPokenavLeftHeaderHoennMapSpriteTemplate, 0, 0, 1); spriteId = CreateSprite(&sPokenavLeftHeaderHoennMapSpriteTemplate, 0, 0, 1);
structPtr->leftHeaderSprites[i] = &gSprites[spriteId]; structPtr->leftHeaderSprites[i] = &gSprites[spriteId];
@ -805,7 +798,7 @@ void sub_81C7E14(u32 arg0)
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64; structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64;
} }
void LoadLeftHeaderGfxForMenu(u32 index) static void LoadLeftHeaderGfxForMenu(u32 index)
{ {
struct PokenavMainMenuResources *structPtr; struct PokenavMainMenuResources *structPtr;
u32 size, tag; u32 size, tag;
@ -827,7 +820,7 @@ void LoadLeftHeaderGfxForMenu(u32 index)
structPtr->leftHeaderSprites[1]->pos2.x = 64; structPtr->leftHeaderSprites[1]->pos2.x = 64;
} }
void LoadLeftHeaderGfxForSubMenu(u32 arg0) static void LoadLeftHeaderGfxForSubMenu(u32 arg0)
{ {
u32 size, tag; u32 size, tag;
@ -866,10 +859,10 @@ void sub_81C7FC4(u32 arg0, bool32 arg1)
void sub_81C7FDC(void) void sub_81C7FDC(void)
{ {
s32 i; int i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
{ {
structPtr->leftHeaderSprites[i]->invisible = TRUE; structPtr->leftHeaderSprites[i]->invisible = TRUE;
structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE; structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE;
@ -886,9 +879,9 @@ bool32 sub_81C8010(void)
return TRUE; return TRUE;
} }
void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
{ {
s32 start, end, i; int start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
if (!isOnRightSide) if (!isOnRightSide)
@ -896,16 +889,16 @@ void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
else else
start = 256, end = 160; start = 256, end = 160;
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
{ {
structPtr->leftHeaderSprites[i]->pos1.y = startY; structPtr->leftHeaderSprites[i]->pos1.y = startY;
MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12); MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12);
} }
} }
void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
{ {
s32 start, end, i; int start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
if (!isOnRightSide) if (!isOnRightSide)
@ -913,16 +906,16 @@ void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
else else
start = 256, end = 192; start = 256, end = 192;
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
{ {
structPtr->submenuLeftHeaderSprites[i]->pos1.y = startY; structPtr->submenuLeftHeaderSprites[i]->pos1.y = startY;
MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12); MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12);
} }
} }
void HideLeftHeaderSprites(bool32 isOnRightSide) static void HideLeftHeaderSprites(bool32 isOnRightSide)
{ {
s32 start, end, i; int start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
if (!isOnRightSide) if (!isOnRightSide)
@ -930,15 +923,15 @@ void HideLeftHeaderSprites(bool32 isOnRightSide)
else else
start = 192, end = 256; start = 192, end = 256;
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
{ {
MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12); MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12);
} }
} }
void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide) static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide)
{ {
s32 start, end, i; int start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
if (!isOnRightSide) if (!isOnRightSide)
@ -946,13 +939,13 @@ void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide)
else else
start = 192, end = 256; start = 192, end = 256;
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
{ {
MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12); MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12);
} }
} }
void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration) static void MoveLeftHeader(struct Sprite *sprite, int startX, int endX, int duration)
{ {
sprite->pos1.x = startX; sprite->pos1.x = startX;
sprite->data[0] = startX * 16; sprite->data[0] = startX * 16;
@ -962,7 +955,7 @@ void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration)
sprite->callback = SpriteCB_MoveLeftHeader; sprite->callback = SpriteCB_MoveLeftHeader;
} }
void SpriteCB_MoveLeftHeader(struct Sprite *sprite) static void SpriteCB_MoveLeftHeader(struct Sprite *sprite)
{ {
if (sprite->data[2] != 0) if (sprite->data[2] != 0)
{ {

View File

@ -7,12 +7,12 @@
struct Pokenav1Struct struct Pokenav1Struct
{ {
u16 unk0; u16 menuType;
s16 unk2; s16 cursorPos;
u16 unk4; u16 descriptionId;
u16 unk6; u16 helpBarIndex;
u32 unk8; u32 unk8;
u32 (*unkC)(struct Pokenav1Struct*); u32 (*callback)(struct Pokenav1Struct*);
}; };
static bool32 sub_81C9814(struct Pokenav1Struct *a0); static bool32 sub_81C9814(struct Pokenav1Struct *a0);
@ -31,9 +31,9 @@ static u32 sub_81C943C(struct Pokenav1Struct *a0);
static u32 (*sub_81C93EC(void))(struct Pokenav1Struct*); static u32 (*sub_81C93EC(void))(struct Pokenav1Struct*);
static void sub_81C939C(struct Pokenav1Struct *state); static void sub_81C939C(struct Pokenav1Struct *state);
static const u8 sUnknown_0861FC54[] = {2, 3, 4, 2, 5}; static const u8 sLastCursorPositions[] = {2, 3, 4, 2, 5};
static const u8 sUnknown_0861FC59[][6] = static const u8 sDescriptionIds[][6] =
{ {
{ 0, 1, 4, 4, 4, 4 }, { 0, 1, 4, 4, 4, 4 },
{ 0, 1, 2, 4, 4, 4 }, { 0, 1, 2, 4, 4, 4 },
@ -42,7 +42,7 @@ static const u8 sUnknown_0861FC59[][6] =
{ 8, 9, 10, 11, 12, 13 }, { 8, 9, 10, 11, 12, 13 },
}; };
static u8 sub_81C9268(void) static u8 GetPokenavMainMenuType(void)
{ {
u8 retVal = 0; u8 retVal = 0;
if (FlagGet(FLAG_ADDED_MATCH_CALL_TO_POKENAV)) if (FlagGet(FLAG_ADDED_MATCH_CALL_TO_POKENAV))
@ -61,10 +61,10 @@ bool32 sub_81C9298(void)
if (!state) if (!state)
return FALSE; return FALSE;
state->unk0 = sub_81C9268(); state->menuType = GetPokenavMainMenuType();
state->unk2 = 0; state->cursorPos = 0;
state->unk4 = 0; state->descriptionId = 0;
state->unk6 = 0; state->helpBarIndex = 0;
sub_81C939C(state); sub_81C939C(state);
return TRUE; return TRUE;
} }
@ -75,10 +75,10 @@ bool32 sub_81C92CC(void)
if (!state) if (!state)
return FALSE; return FALSE;
state->unk0 = sub_81C9268(); state->menuType = GetPokenavMainMenuType();
state->unk2 = 2; state->cursorPos = 2;
state->unk4 = 2; state->descriptionId = 2;
state->unk6 = 0; state->helpBarIndex = 0;
sub_81C939C(state); sub_81C939C(state);
return TRUE; return TRUE;
} }
@ -89,9 +89,9 @@ bool32 sub_81C9304(void)
if (!state) if (!state)
return FALSE; return FALSE;
state->unk0 = sub_81C9268(); state->menuType = GetPokenavMainMenuType();
state->unk2 = 3; state->cursorPos = 3;
state->unk4 = 3; state->descriptionId = 3;
sub_81C939C(state); sub_81C939C(state);
return TRUE; return TRUE;
} }
@ -102,10 +102,10 @@ bool32 sub_81C9338(void)
if (!state) if (!state)
return FALSE; return FALSE;
state->unk0 = 3; state->menuType = 3;
state->unk2 = 0; state->cursorPos = 0;
state->unk4 = 5; state->descriptionId = 5;
state->unk6 = 0; state->helpBarIndex = 0;
sub_81C939C(state); sub_81C939C(state);
return TRUE; return TRUE;
} }
@ -116,30 +116,30 @@ bool32 sub_81C9368(void)
if (!state) if (!state)
return FALSE; return FALSE;
state->unk0 = 4; state->menuType = 4;
state->unk2 = sub_81C76AC(); state->cursorPos = sub_81C76AC();
state->unk4 = state->unk2 + 8; state->descriptionId = state->cursorPos + 8;
state->unk6 = 0; state->helpBarIndex = 0;
sub_81C939C(state); sub_81C939C(state);
return TRUE; return TRUE;
} }
static void sub_81C939C(struct Pokenav1Struct *state) static void sub_81C939C(struct Pokenav1Struct *state)
{ {
switch (state->unk0) switch (state->menuType)
{ {
case 0: case 0:
SetPokenavMode(0); SetPokenavMode(POKENAV_MODE_NORMAL);
// fallthrough // fallthrough
case 1: case 1:
case 2: case 2:
state->unkC = sub_81C93EC(); state->callback = sub_81C93EC();
break; break;
case 3: case 3:
state->unkC = sub_81C963C; state->callback = sub_81C963C;
break; break;
case 4: case 4:
state->unkC = sub_81C96FC; state->callback = sub_81C96FC;
break; break;
} }
} }
@ -149,11 +149,11 @@ static u32 (*sub_81C93EC(void))(struct Pokenav1Struct*)
switch (GetPokenavMode()) switch (GetPokenavMode())
{ {
default: default:
case 0: case POKENAV_MODE_NORMAL:
return sub_81C943C; return sub_81C943C;
case 1: case POKENAV_MODE_FORCE_CALL_1:
return sub_81C9520; return sub_81C9520;
case 2: case POKENAV_MODE_FORCE_CALL_2:
return sub_81C9588; return sub_81C9588;
} }
} }
@ -161,7 +161,7 @@ static u32 (*sub_81C93EC(void))(struct Pokenav1Struct*)
u32 sub_81C941C(void) u32 sub_81C941C(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unkC(state); return state->callback(state);
} }
void sub_81C9430(void) void sub_81C9430(void)
@ -176,32 +176,32 @@ static u32 sub_81C943C(struct Pokenav1Struct *a0)
if (gMain.newKeys & A_BUTTON) if (gMain.newKeys & A_BUTTON)
{ {
switch (sUnknown_0861FC59[a0->unk0][a0->unk2]) switch (sDescriptionIds[a0->menuType][a0->cursorPos])
{ {
case 0: case 0:
a0->unk6 = gSaveBlock2Ptr->regionMapZoom ? 2 : 1; a0->helpBarIndex = gSaveBlock2Ptr->regionMapZoom ? 2 : 1;
sub_81C97B0(a0, UNKNOWN_POKENAV_OFFSET + 6); sub_81C97B0(a0, POKENAV_MENU_6);
return 8; return 8;
case 1: case 1:
a0->unk0 = 3; a0->menuType = 3;
a0->unk2 = 0; a0->cursorPos = 0;
a0->unk4 = sUnknown_0861FC59[3][0]; a0->descriptionId = sDescriptionIds[3][0];
a0->unkC = sub_81C963C; a0->callback = sub_81C963C;
return 2; return 2;
case 2: case 2:
a0->unk6 = 6; a0->helpBarIndex = 6;
sub_81C97B0(a0, UNKNOWN_POKENAV_OFFSET + 11); sub_81C97B0(a0, POKENAV_MENU_B);
return 8; return 8;
case 3: case 3:
if (CanViewRibbonsMenu()) if (CanViewRibbonsMenu())
{ {
a0->unk6 = 9; a0->helpBarIndex = 9;
sub_81C97B0(a0, UNKNOWN_POKENAV_OFFSET + 12); sub_81C97B0(a0, POKENAV_MENU_C);
return 8; return 8;
} }
else else
{ {
a0->unkC = sub_81C9600; a0->callback = sub_81C9600;
return 6; return 6;
} }
case 4: case 4:
@ -222,10 +222,10 @@ static u32 sub_81C9520(struct Pokenav1Struct *a0)
if (gMain.newKeys & A_BUTTON) if (gMain.newKeys & A_BUTTON)
{ {
if (sUnknown_0861FC59[a0->unk0][a0->unk2] == 2) if (sDescriptionIds[a0->menuType][a0->cursorPos] == 2)
{ {
a0->unk6 = 6; a0->helpBarIndex = 6;
sub_81C97B0(a0, UNKNOWN_POKENAV_OFFSET + 11); sub_81C97B0(a0, POKENAV_MENU_B);
return 8; return 8;
} }
else else
@ -251,7 +251,7 @@ static u32 sub_81C9588(struct Pokenav1Struct *a0)
if (gMain.newKeys & A_BUTTON) if (gMain.newKeys & A_BUTTON)
{ {
u32 v0 = sUnknown_0861FC59[a0->unk0][a0->unk2]; u32 v0 = sDescriptionIds[a0->menuType][a0->cursorPos];
if (v0 != 2 && v0 != 4) if (v0 != 2 && v0 != 4)
{ {
PlaySE(SE_HAZURE); PlaySE(SE_HAZURE);
@ -259,8 +259,8 @@ static u32 sub_81C9588(struct Pokenav1Struct *a0)
} }
else if (v0 == 2) else if (v0 == 2)
{ {
a0->unk6 = 6; a0->helpBarIndex = 6;
sub_81C97B0(a0, UNKNOWN_POKENAV_OFFSET + 11); sub_81C97B0(a0, POKENAV_MENU_B);
return 8; return 8;
} }
else else
@ -279,13 +279,13 @@ static u32 sub_81C9600(struct Pokenav1Struct *a0)
{ {
if (sub_81C9814(a0)) if (sub_81C9814(a0))
{ {
a0->unkC = sub_81C93EC(); a0->callback = sub_81C93EC();
return 1; return 1;
} }
if (gMain.newKeys & (A_BUTTON | B_BUTTON)) if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{ {
a0->unkC = sub_81C93EC(); a0->callback = sub_81C93EC();
return 7; return 7;
} }
@ -300,17 +300,17 @@ static u32 sub_81C963C(struct Pokenav1Struct *a0)
if (gMain.newKeys & A_BUTTON) if (gMain.newKeys & A_BUTTON)
{ {
switch (sUnknown_0861FC59[a0->unk0][a0->unk2]) switch (sDescriptionIds[a0->menuType][a0->cursorPos])
{ {
case 6: case 6:
a0->unk0 = 4; a0->menuType = 4;
a0->unk2 = v0; a0->cursorPos = v0;
a0->unk4 = sUnknown_0861FC59[4][0]; a0->descriptionId = sDescriptionIds[4][0];
a0->unkC = sub_81C96FC; a0->callback = sub_81C96FC;
return 4; return 4;
case 5: case 5:
a0->unk6 = v0; a0->helpBarIndex = v0;
sub_81C97B0(a0, UNKNOWN_POKENAV_OFFSET + 7); sub_81C97B0(a0, POKENAV_MENU_7);
return 8; return 8;
case 7: case 7:
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
@ -320,10 +320,10 @@ static u32 sub_81C963C(struct Pokenav1Struct *a0)
} }
if (gMain.newKeys & B_BUTTON) if (gMain.newKeys & B_BUTTON)
{ {
if (a0->unk2 != sUnknown_0861FC54[a0->unk0]) if (a0->cursorPos != sLastCursorPositions[a0->menuType])
{ {
a0->unk2 = sUnknown_0861FC54[a0->unk0]; a0->cursorPos = sLastCursorPositions[a0->menuType];
a0->unkC = sub_81C9798; a0->callback = sub_81C9798;
return 1; return 1;
} }
else else
@ -344,12 +344,12 @@ static u32 sub_81C96FC(struct Pokenav1Struct *a0)
if (gMain.newKeys & A_BUTTON) if (gMain.newKeys & A_BUTTON)
{ {
u8 v0 = sUnknown_0861FC59[a0->unk0][a0->unk2]; u8 v0 = sDescriptionIds[a0->menuType][a0->cursorPos];
if (v0 != 13) if (v0 != 13)
{ {
sub_81C7694(v0 - 8); sub_81C7694(v0 - 8);
sub_81C97B0(a0, UNKNOWN_POKENAV_OFFSET + 8); sub_81C97B0(a0, POKENAV_MENU_8);
a0->unk6 = 3; a0->helpBarIndex = 3;
return 8; return 8;
} }
else else
@ -361,10 +361,10 @@ static u32 sub_81C96FC(struct Pokenav1Struct *a0)
} }
if (gMain.newKeys & B_BUTTON) if (gMain.newKeys & B_BUTTON)
{ {
if (a0->unk2 != sUnknown_0861FC54[a0->unk0]) if (a0->cursorPos != sLastCursorPositions[a0->menuType])
{ {
a0->unk2 = sUnknown_0861FC54[a0->unk0]; a0->cursorPos = sLastCursorPositions[a0->menuType];
a0->unkC = sub_81C97A4; a0->callback = sub_81C97A4;
return 1; return 1;
} }
else else
@ -392,7 +392,7 @@ static u32 sub_81C97A4(struct Pokenav1Struct *a0)
static void sub_81C97B0(struct Pokenav1Struct *a0, u32 a1) static void sub_81C97B0(struct Pokenav1Struct *a0, u32 a1)
{ {
a0->unk8 = a1; a0->unk8 = a1;
a0->unkC = sub_81C97BC; a0->callback = sub_81C97BC;
} }
static u32 sub_81C97BC(struct Pokenav1Struct *a0) static u32 sub_81C97BC(struct Pokenav1Struct *a0)
@ -402,37 +402,37 @@ static u32 sub_81C97BC(struct Pokenav1Struct *a0)
static void sub_81C97C0(struct Pokenav1Struct *a0) static void sub_81C97C0(struct Pokenav1Struct *a0)
{ {
a0->unk0 = sub_81C9268(); a0->menuType = GetPokenavMainMenuType();
a0->unk2 = 1; a0->cursorPos = 1;
a0->unk4 = sUnknown_0861FC59[a0->unk0][a0->unk2]; a0->descriptionId = sDescriptionIds[a0->menuType][a0->cursorPos];
a0->unkC = sub_81C943C; a0->callback = sub_81C943C;
} }
static void sub_81C97F8(struct Pokenav1Struct *a0) static void sub_81C97F8(struct Pokenav1Struct *a0)
{ {
a0->unk0 = 3; a0->menuType = 3;
a0->unk2 = 1; a0->cursorPos = 1;
a0->unk4 = sUnknown_0861FC59[3][1]; a0->descriptionId = sDescriptionIds[3][1];
a0->unkC = sub_81C963C; a0->callback = sub_81C963C;
} }
static bool32 sub_81C9814(struct Pokenav1Struct *a0) static bool32 sub_81C9814(struct Pokenav1Struct *a0)
{ {
if (gMain.newKeys & DPAD_UP) if (gMain.newKeys & DPAD_UP)
{ {
if (--a0->unk2 < 0) if (--a0->cursorPos < 0)
a0->unk2 = sUnknown_0861FC54[a0->unk0]; a0->cursorPos = sLastCursorPositions[a0->menuType];
a0->unk4 = sUnknown_0861FC59[a0->unk0][a0->unk2]; a0->descriptionId = sDescriptionIds[a0->menuType][a0->cursorPos];
return TRUE; return TRUE;
} }
else if (gMain.newKeys & DPAD_DOWN) else if (gMain.newKeys & DPAD_DOWN)
{ {
a0->unk2++; a0->cursorPos++;
if (a0->unk2 > sUnknown_0861FC54[a0->unk0]) if (a0->cursorPos > sLastCursorPositions[a0->menuType])
a0->unk2 = 0; a0->cursorPos = 0;
a0->unk4 = sUnknown_0861FC59[a0->unk0][a0->unk2]; a0->descriptionId = sDescriptionIds[a0->menuType][a0->cursorPos];
return TRUE; return TRUE;
} }
else else
@ -444,23 +444,23 @@ static bool32 sub_81C9814(struct Pokenav1Struct *a0)
int sub_81C9894(void) int sub_81C9894(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unk0; return state->menuType;
} }
int sub_81C98A4(void) int sub_81C98A4(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unk2; return state->cursorPos;
} }
int sub_81C98B4(void) int sub_81C98B4(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unk4; return state->descriptionId;
} }
int sub_81C98C4(void) int sub_81C98C4(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(1);
return state->unk6; return state->helpBarIndex;
} }