From 14d78d76332a99f0942f1ad5c05f439ce27d789f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 15 Nov 2021 00:42:23 -0500 Subject: [PATCH] Finish match call menu doc --- .../{86226E0.pal => call_window.pal} | 0 .../{8622700.pal => list_window.pal} | 0 include/pokenav.h | 5 +- src/pokenav_match_call_1.c | 114 +++++++++--------- src/pokenav_match_call_2.c | 22 ++-- 5 files changed, 73 insertions(+), 68 deletions(-) rename graphics/pokenav/match_call/{86226E0.pal => call_window.pal} (100%) rename graphics/pokenav/match_call/{8622700.pal => list_window.pal} (100%) diff --git a/graphics/pokenav/match_call/86226E0.pal b/graphics/pokenav/match_call/call_window.pal similarity index 100% rename from graphics/pokenav/match_call/86226E0.pal rename to graphics/pokenav/match_call/call_window.pal diff --git a/graphics/pokenav/match_call/8622700.pal b/graphics/pokenav/match_call/list_window.pal similarity index 100% rename from graphics/pokenav/match_call/8622700.pal rename to graphics/pokenav/match_call/list_window.pal diff --git a/include/pokenav.h b/include/pokenav.h index 34206d3ae..595198136 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -407,10 +407,9 @@ void ResetBldCnt_(void); bool32 PokenavCallback_Init_MatchCall(void); u32 GetMatchCallCallback(void); void FreeMatchCallSubstruct1(void); -int sub_81CAE28(void); +int IsMatchCallListInitFinished(void); int GetNumberRegistered(void); -int sub_81CAE48(void); -struct PokenavMatchCallEntry *sub_81CAE94(void); +struct PokenavMatchCallEntry *GetMatchCallList(void); u16 GetMatchCallMapSec(int); bool32 ShouldDrawRematchPokeballIcon(int index); void ClearRematchPokeballIcon(u16 windowId, u32 a1); diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index e0e5306e1..d56cfdb62 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -14,26 +14,26 @@ #include "strings.h" #include "constants/songs.h" -struct Pokenav3Struct +struct Pokenav_MatchCallMenu { u16 optionCursorPos; u16 maxOptionId; const u8 *matchCallOptions; u16 headerId; u16 numRegistered; - u16 unkC; - u32 unk10; - u32 unk14; - u32 (*callback)(struct Pokenav3Struct*); + u16 numSpecialTrainers; + bool32 initFinished; + u32 loopedTaskId; + u32 (*callback)(struct Pokenav_MatchCallMenu*); struct PokenavMatchCallEntry matchCallEntries[MAX_REMATCH_ENTRIES - 1]; }; -static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *); -static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *); -static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *); -static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *); -static u32 CB2_HandleCallExitInput(struct Pokenav3Struct *); -static u32 sub_81CAD20(s32); +static u32 CB2_HandleMatchCallInput(struct Pokenav_MatchCallMenu *); +static u32 GetExitMatchCallMenuId(struct Pokenav_MatchCallMenu *); +static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav_MatchCallMenu *); +static u32 CB2_HandleCheckPageInput(struct Pokenav_MatchCallMenu *); +static u32 CB2_HandleCallExitInput(struct Pokenav_MatchCallMenu *); +static u32 LoopedTask_BuildMatchCallList(s32); static bool32 ShouldDoNearbyMessage(void); #include "data/text/match_call_messages.h" @@ -53,20 +53,20 @@ static const u8 sMatchCallOptionsHasCheckPage[] = bool32 PokenavCallback_Init_MatchCall(void) { - struct Pokenav3Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, sizeof(struct Pokenav3Struct)); + struct Pokenav_MatchCallMenu *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, sizeof(struct Pokenav_MatchCallMenu)); if (!state) return FALSE; state->callback = CB2_HandleMatchCallInput; state->headerId = 0; - state->unk10 = 0; - state->unk14 = CreateLoopedTask(sub_81CAD20, 1); + state->initFinished = FALSE; + state->loopedTaskId = CreateLoopedTask(LoopedTask_BuildMatchCallList, 1); return TRUE; } u32 GetMatchCallCallback(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->callback(state); } @@ -75,7 +75,7 @@ void FreeMatchCallSubstruct1(void) FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); } -static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) +static u32 CB2_HandleMatchCallInput(struct Pokenav_MatchCallMenu *state) { int selection; @@ -125,20 +125,20 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *state) +static u32 GetExitMatchCallMenuId(struct Pokenav_MatchCallMenu *state) { return POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL; } -static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) +static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav_MatchCallMenu *state) { - if ((JOY_NEW(DPAD_UP)) && state->optionCursorPos) + if (JOY_NEW(DPAD_UP) && state->optionCursorPos) { state->optionCursorPos--; return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR; } - if ((JOY_NEW(DPAD_DOWN)) && state->optionCursorPos < state->maxOptionId) + if (JOY_NEW(DPAD_DOWN) && state->optionCursorPos < state->maxOptionId) { state->optionCursorPos++; return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR; @@ -175,7 +175,7 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state) +static u32 CB2_HandleCheckPageInput(struct Pokenav_MatchCallMenu *state) { if (JOY_REPEAT(DPAD_UP)) return POKENAV_MC_FUNC_CHECK_PAGE_UP; @@ -191,7 +191,7 @@ static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 CB2_HandleCallExitInput(struct Pokenav3Struct *state) +static u32 CB2_HandleCallExitInput(struct Pokenav_MatchCallMenu *state) { if (JOY_NEW(A_BUTTON | B_BUTTON)) { @@ -202,10 +202,10 @@ static u32 CB2_HandleCallExitInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 sub_81CAD20(s32 taskState) +static u32 LoopedTask_BuildMatchCallList(s32 taskState) { int i, j; - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); switch (taskState) { case 0: @@ -213,6 +213,7 @@ static u32 sub_81CAD20(s32 taskState) state->numRegistered = 0; return LT_INC_AND_CONTINUE; case 1: + // Load special trainers (e.g. Rival, gym leaders) for (i = 0, j = state->headerId; i < 30; i++, j++) { if (MatchCall_GetEnabled(j)) @@ -225,7 +226,7 @@ static u32 sub_81CAD20(s32 taskState) if (++state->headerId >= MC_HEADER_COUNT) { - state->unkC = state->headerId; + state->numSpecialTrainers = state->headerId; state->headerId = 0; return LT_INC_AND_CONTINUE; } @@ -233,6 +234,7 @@ static u32 sub_81CAD20(s32 taskState) return LT_CONTINUE; case 2: + // Load normal trainers for (i = 0, j = state->headerId; i < 30; i++, j++) { if (!MatchCall_HasRematchId(state->headerId) && IsRematchEntryRegistered(state->headerId)) @@ -249,7 +251,7 @@ static u32 sub_81CAD20(s32 taskState) return LT_CONTINUE; case 3: - state->unk10 = 1; + state->initFinished = TRUE; break; } @@ -264,55 +266,58 @@ bool32 IsRematchEntryRegistered(int rematchIndex) return FALSE; } -int sub_81CAE28(void) +int IsMatchCallListInitFinished(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - return state->unk10; + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + return state->initFinished; } int GetNumberRegistered(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->numRegistered; } -int sub_81CAE48(void) +// Unused +static int GetNumSpecialTrainers(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - return state->unkC; + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + return state->numSpecialTrainers; } -int unref_sub_81CAE58(void) +// Unused +static int GetNumNormalTrainers(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - return state->numRegistered - state->unkC; + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + return state->numRegistered - state->numSpecialTrainers; } -int unref_sub_81CAE6C(int arg0) +// Unused +static int GetNormalTrainerHeaderId(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); - arg0 += state->unkC; - if (arg0 >= state->numRegistered) + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + index += state->numSpecialTrainers; + if (index >= state->numRegistered) return REMATCH_TABLE_ENTRIES; - return state->matchCallEntries[arg0].headerId; + return state->matchCallEntries[index].headerId; } -struct PokenavMatchCallEntry *sub_81CAE94(void) +struct PokenavMatchCallEntry *GetMatchCallList(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->matchCallEntries; } u16 GetMatchCallMapSec(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->matchCallEntries[index].mapSec; } bool32 ShouldDrawRematchPokeballIcon(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (!state->matchCallEntries[index].isSpecialTrainer) index = state->matchCallEntries[index].headerId; else @@ -327,7 +332,7 @@ bool32 ShouldDrawRematchPokeballIcon(int index) int GetMatchCallTrainerPic(int index) { int headerId; - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (!state->matchCallEntries[index].isSpecialTrainer) { index = GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId); @@ -348,7 +353,7 @@ int GetMatchCallTrainerPic(int index) const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); *newRematchRequest = FALSE; if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType)) return gText_CallCantBeMadeHere; @@ -364,7 +369,7 @@ const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest) const u8 *GetMatchCallFlavorText(int index, int checkPageEntry) { int rematchId; - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (state->matchCallEntries[index].isSpecialTrainer) { rematchId = MatchCall_GetRematchTableIdx(state->matchCallEntries[index].headerId); @@ -381,13 +386,13 @@ const u8 *GetMatchCallFlavorText(int index, int checkPageEntry) u16 GetMatchCallOptionCursorPos(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->optionCursorPos; } u16 GetMatchCallOptionId(int optionId) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (state->maxOptionId < optionId) return MATCH_CALL_OPTION_COUNT; @@ -431,7 +436,7 @@ u8 GetMatchTableMapSectionId(int rematchIndex) int GetIndexDeltaOfNextCheckPageDown(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int count = 1; while (++index < state->numRegistered) { @@ -448,7 +453,7 @@ int GetIndexDeltaOfNextCheckPageDown(int index) int GetIndexDeltaOfNextCheckPageUp(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int count = -1; while (--index >= 0) { @@ -463,7 +468,8 @@ int GetIndexDeltaOfNextCheckPageUp(int index) return 0; } -bool32 unref_sub_81CB16C(void) +// Unused +static bool32 HasRematchEntry(void) { int i; @@ -488,7 +494,7 @@ bool32 unref_sub_81CB16C(void) static bool32 ShouldDoNearbyMessage(void) { - struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int selection = PokenavList_GetSelectedIndex(); if (!state->matchCallEntries[selection].isSpecialTrainer) { diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index d8704919f..d7e9476f9 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -56,7 +56,7 @@ struct Pokenav_MatchCallGfx static bool32 GetCurrentLoopedTaskActive(void); static u32 LoopedTask_OpenMatchCall(s32); static void CreateMatchCallList(void); -static void sub_81CBC1C(void); +static void DestroyMatchCallList(void); static void FreeMatchCallSprites(void); static void LoadCallWindowAndFade(struct Pokenav_MatchCallGfx *); static void DrawMatchCallLeftColumnWindows(struct Pokenav_MatchCallGfx *); @@ -119,12 +119,12 @@ static const u32 sMatchCallUI_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/ui static const u32 sMatchCallUI_Tilemap[] = INCBIN_U32("graphics/pokenav/match_call/ui.bin.lz"); static const u16 sOptionsCursor_Pal[] = INCBIN_U16("graphics/pokenav/match_call/options_cursor.gbapal"); static const u32 sOptionsCursor_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/options_cursor.4bpp.lz"); -static const u16 gUnknown_086226E0[] = INCBIN_U16("graphics/pokenav/match_call/86226E0.gbapal"); -static const u16 gUnknown_08622700[] = INCBIN_U16("graphics/pokenav/match_call/8622700.gbapal"); +static const u16 sCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call/call_window.gbapal"); +static const u16 sListWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call/list_window.gbapal"); static const u16 sPokeball_Pal[] = INCBIN_U16("graphics/pokenav/match_call/pokeball.gbapal"); static const u32 sPokeball_Gfx[] = INCBIN_U32("graphics/pokenav/match_call/pokeball.4bpp.lz"); -const struct BgTemplate sMatchCallBgTemplates[3] = +static const struct BgTemplate sMatchCallBgTemplates[3] = { { .bg = 1, @@ -223,7 +223,7 @@ static const struct CompressedSpriteSheet sOptionsCursorSpriteSheets[1] = {sOptionsCursor_Gfx, 0x40, GFXTAG_CURSOR} }; -const struct SpritePalette sOptionsCursorSpritePalettes[2] = +static const struct SpritePalette sOptionsCursorSpritePalettes[2] = { {sOptionsCursor_Pal, PALTAG_CURSOR} }; @@ -307,7 +307,7 @@ void FreeMatchCallSubstruct2(void) { struct Pokenav_MatchCallGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); FreeMatchCallSprites(); - sub_81CBC1C(); + DestroyMatchCallList(); RemoveWindow(gfx->infoBoxWindowId); RemoveWindow(gfx->locWindowId); RemoveWindow(gfx->msgBoxWindowId); @@ -343,7 +343,7 @@ static u32 LoopedTask_OpenMatchCall(s32 state) BgDmaFill(1, 0, 0, 1); SetBgTilemapBuffer(1, gfx->bgTilemapBuffer1); FillBgTilemapBufferRect_Palette0(1, 0x1000, 0, 0, 32, 20); - CopyPaletteIntoBufferUnfaded(gUnknown_086226E0, 0x10, 0x20); + CopyPaletteIntoBufferUnfaded(sCallWindow_Pal, 0x10, 0x20); CopyBgTilemapBufferToVram(1); return LT_INC_AND_PAUSE; case 2: @@ -352,11 +352,11 @@ static u32 LoopedTask_OpenMatchCall(s32 state) LoadCallWindowAndFade(gfx); DecompressAndCopyTileDataToVram(3, sPokeball_Gfx, 0, 0, 0); - CopyPaletteIntoBufferUnfaded(gUnknown_08622700, 0x30, 0x20); + CopyPaletteIntoBufferUnfaded(sListWindow_Pal, 0x30, 0x20); CopyPaletteIntoBufferUnfaded(sPokeball_Pal, 0x50, 0x20); return LT_INC_AND_PAUSE; case 3: - if (FreeTempTileDataBuffersIfPossible() || !sub_81CAE28()) + if (FreeTempTileDataBuffersIfPossible() || !IsMatchCallListInitFinished()) return LT_PAUSE; CreateMatchCallList(); @@ -872,7 +872,7 @@ static u32 ExitMatchCall(s32 state) static void CreateMatchCallList(void) { struct PokenavListTemplate template; - template.list = (struct PokenavListItem *)sub_81CAE94(); + template.list = (struct PokenavListItem *)GetMatchCallList(); template.count = GetNumberRegistered(); template.itemSize = sizeof(struct PokenavListItem); template.startIndex = 0; @@ -888,7 +888,7 @@ static void CreateMatchCallList(void) CreateTask(Task_FlashPokeballIcons, 7); } -static void sub_81CBC1C(void) +static void DestroyMatchCallList(void) { DestroyPokenavList(); DestroyTask(FindTaskIdByFunc(Task_FlashPokeballIcons));