From 2b2be90a5266e294342e1759dddfe8af4d6f39f2 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 10 Oct 2020 16:17:34 -0600 Subject: [PATCH 1/5] start pokenav documentation --- include/menu_specialized.h | 12 +- include/mon_markings.h | 4 +- include/pokenav.h | 198 +++++++----- src/menu_specialized.c | 50 +-- src/mon_markings.c | 4 +- src/pokemon_storage_system.c | 2 +- src/pokemon_summary_screen.c | 2 +- src/pokenav.c | 154 +++++---- src/pokenav_conditions_1.c | 444 +++++++++++++------------- src/pokenav_conditions_2.c | 589 ++++++++++++++++++----------------- src/pokenav_conditions_3.c | 433 ++++++++++++------------- src/pokenav_main_menu.c | 146 ++++----- src/pokenav_match_call_1.c | 48 +-- src/pokenav_match_call_2.c | 114 +++---- src/pokenav_match_call_ui.c | 430 ++++++++++++------------- src/pokenav_menu_handler_1.c | 34 +- src/pokenav_menu_handler_2.c | 517 +++++++++++++++--------------- src/pokenav_region_map.c | 58 ++-- src/pokenav_ribbons_1.c | 414 ++++++++++++------------ src/pokenav_ribbons_2.c | 348 +++++++++++---------- src/use_pokeblock.c | 10 +- 21 files changed, 2043 insertions(+), 1968 deletions(-) diff --git a/include/menu_specialized.h b/include/menu_specialized.h index 242e1c6b2..987fca9fc 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -23,7 +23,7 @@ struct UnknownSubStruct_81D1ED4 struct ConditionGraph { - /*0x000*/ u8 unk0[4][FLAVOR_COUNT]; + /*0x000*/ u8 stat[4][FLAVOR_COUNT]; /*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][FLAVOR_COUNT]; /*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[10][FLAVOR_COUNT]; /*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[FLAVOR_COUNT]; @@ -32,7 +32,7 @@ struct ConditionGraph /*0x350*/ u16 unk350; /*0x352*/ u16 unk352; /*0x354*/ u8 unk354; - /*0x355*/ u8 unk355; + /*0x355*/ u8 state; }; bool8 sub_81D1C44(u8 count); @@ -41,12 +41,12 @@ u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page); void sub_81D1E90(struct PlayerPCItemPageStruct *page); void sub_81D1EC0(void); void sub_81D1D04(u8 a0); -void sub_81D1ED4(struct ConditionGraph *graph); +void InitConditionGraphData(struct ConditionGraph *graph); void sub_81D2108(struct ConditionGraph *graph); -void sub_81D21DC(u8 bg); -void sub_81D20AC(struct ConditionGraph *graph); +void SetConditionGraphIOWindows(u8 bg); +void InitConditionGraphState(struct ConditionGraph *graph); void sub_81D2230(struct ConditionGraph *graph); -bool8 sub_81D20BC(struct ConditionGraph *graph); +bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph); bool32 TransitionConditionGraph(struct ConditionGraph *graph); void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1); void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2); diff --git a/include/mon_markings.h b/include/mon_markings.h index 241b31e01..3cb04ad48 100644 --- a/include/mon_markings.h +++ b/include/mon_markings.h @@ -29,8 +29,8 @@ bool8 sub_811F960(void); void sub_811FA90(void); void sub_811FAA4(u8 markings, s16 x, s16 y); void sub_811FAF8(void); -bool8 sub_811FBA4(void); -struct Sprite *sub_811FF94(u16 tileTag, u16 paletteTag, const u16 *palette); +bool8 MonMarkingsMenuHandleInput(void); +struct Sprite *CreateMonMarkingsSpriteWithPal(u16 tileTag, u16 paletteTag, const u16 *palette); struct Sprite *sub_811FFB4(u16 tileTag, u16 paletteTag, const u16 *palette); void sub_8120084(u8 markings, void *dest); diff --git a/include/pokenav.h b/include/pokenav.h index ed4e5a906..34692236d 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -27,17 +27,17 @@ struct PokenavListTemplate struct PokenavMonList *monList; struct PokenavMatchCallEntries *matchCallEntries; } list; - u16 unk4; + u16 count; u16 unk6; u8 unk8; - u8 unk9; - u8 unkA; - u8 unkB; - u8 unkC; - u8 unkD; - u8 unkE; + u8 item_X; + u8 windowWidth; + u8 listTop; + u8 maxShowed; + u8 fillValue; + u8 fontId; union { - void (*unk10_1)(struct PokenavMonList *, u8 *a1); + void (*printMonFunc)(struct PokenavMonList *item, u8 *dest); void (*unk10_2)(struct PokenavMatchCallEntries *, u8 *a1); } listFunc; void (*unk14)(u16 a0, u32 a1, u32 a2); @@ -45,9 +45,9 @@ struct PokenavListTemplate struct PokenavSub18 { - u16 unk0; - u16 unk2; - struct PokenavMonList unk4[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE]; + u16 listCount; + u16 currIndex; + struct PokenavMonList monData[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE]; }; // Return values of LoopedTask functions. @@ -65,6 +65,31 @@ enum POKENAV_MODE_FORCE_CALL_EXIT, // Pokenav tutorial after calling Mr. Stone }; +// TODO - refine these names +enum Substructures +{ + POKENAV_SUBSTRUCT_MAIN_MENU, + POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, + POKENAV_SUBSTRUCT_MENU_ICONS, + POKENAV_SUBSTRUCT_REGION_MAP_STATE, + POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, + POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, + POKENAV_SUBSTRUCT_MATCH_CALL_OPEN, + POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, + POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, + POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, + POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, + POKENAV_SUBSTRUCT_CONDITION_GRAPH, + POKENAV_SUBSTRUCT_MON_MARK_MENU, + POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, + POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, + POKENAV_SUBSTRUCT_15, //unused + POKENAV_SUBSTRUCT_REGION_MAP, + POKENAV_SUBSTRUCT_MATCH_CALL_LIST, + POKENAV_SUBSTRUCT_MON_LIST, + POKENAV_SUBSTRUCT_COUNT, +}; + enum { POKENAV_GFX_MAIN_MENU, @@ -97,12 +122,12 @@ enum POKENAV_REGION_MAP, POKENAV_CONDITION_PARTY, POKENAV_CONDITION_SEARCH_RESULTS, - POKENAV_MENU_9, // Condition - POKENAV_MENU_A, // Condition + POKENAV_MENU_CONDITION_GRAPH_FROM_SEARCH, // opening condition graph from search list + POKENAV_RETURN_CONDITION_SEARCH, //return to search list from condition graph POKENAV_MATCH_CALL, POKENAV_RIBBONS_MON_LIST, - POKENAV_MENU_D, // Ribbons - POKENAV_MENU_E, // Ribbons + POKENAV_RIBBONS_SUMMARY_SCREEN, + POKENAV_RIBBONS_RETURN_TO_MON_LIST, }; enum @@ -207,7 +232,7 @@ enum // Pokenav Function IDs // Indices into the LoopedTask tables for each of the main Pokenav features -enum +enum RegionMapFuncIds { POKENAV_MENU_FUNC_NONE, POKENAV_MENU_FUNC_MOVE_CURSOR, @@ -220,6 +245,19 @@ enum POKENAV_MENU_FUNC_OPEN_FEATURE, }; +enum PartyConditionFuncIds +{ + PARTY_CONDITION_FUNC_NONE, + PARTY_CONDITION_FUNC_SLIDE_MON_IN, + PARTY_CONDITION_FUNC_RETURN, + PARTY_CONDITION_FUNC_NO_TRANSITION, + PARTY_CONDITION_FUNC_SLIDE_MON_OUT, + PARTY_CONDITION_FUNC_ADD_MARKINGS, + PARTY_CONDITION_FUNC_CLOSE_MARKINGS, +}; + +#define POKENAV_MENU_FUNC_EXIT -1 + enum { POKENAV_MC_FUNC_NONE, @@ -268,17 +306,17 @@ void SetPokenavVBlankCallback(void); void SetVBlankCallback_(IntrCallback callback); // pokenav_match_call_ui.c -u32 GetSelectedMatchCall(void); +u32 GetSelectedPokenavListIndex(void); bool32 sub_81C8224(void); int MatchCall_MoveCursorUp(void); int MatchCall_MoveCursorDown(void); int MatchCall_PageDown(void); int MatchCall_PageUp(void); -bool32 sub_81C8630(void); +bool32 IsMonListLoopedTaskActive(void); void ToggleMatchCallVerticalArrows(bool32 shouldHide); void sub_81C8838(void); void sub_81C877C(void); -bool32 sub_81C8820(void); +bool32 IsMatchCallListTaskActive(void); void PrintCheckPageInfo(s16 a0); u32 GetMatchCallListTopIndex(void); void sub_81C87F0(void); @@ -300,30 +338,30 @@ void MatchCall_GetNameAndDesc(u32 idx, const u8 **desc, const u8 **name); // 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); +void RunMainMenuLoopedTask(u32 a0); +u32 IsActiveMenuLoopTaskActive(void); void LoadLeftHeaderGfxForIndex(u32 arg0); -void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2); +void ShowLeftHeaderGfx(u32 menugfxId, bool32 arg1, bool32 isOnRightSide); void PokenavFadeScreen(s32 fadeType); -bool32 sub_81C8010(void); +bool32 AreLeftHeaderSpritesMoving(void); void InitBgTemplates(const struct BgTemplate *templates, int count); bool32 IsPaletteFadeActive(void); void PrintHelpBarText(u32 textId); bool32 WaitForHelpBar(void); -void sub_81C78A0(void); +void SlideMenuHeaderDown(void); bool32 MainMenuLoopedTaskIsBusy(void); -void sub_81C7FDC(void); -void sub_81C79BC(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette); +void SetLeftHeaderSpritesInvisibility(void); +void PokenavCopyPalette(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette); void sub_81C7B40(void); struct Sprite *PauseSpinningPokenavSprite(void); void ResumeSpinningPokenavSprite(void); -void sub_81C7E14(u32 arg0); -void sub_81C7FC4(u32 arg0, bool32 arg1); -void sub_81C7880(void); -void sub_81C7990(u32 a0, u16 a1); +void UpdateRegionMapRightHeaderTiles(u32 arg0); +void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide); +void SlideMenuHeaderUp(void); +void PokenavFillPalette(u32 palIndex, u16 fillValue); u32 PokenavMainMenuLoopedTaskIsActive(void); bool32 WaitForPokenavShutdownFade(void); -void sub_81C7834(void *func1, void *func2); +void SetActiveMenuLoopTasks(void *func1, void *func2); void ShutdownPokenav(void); // pokenav_menu_handler_1.c @@ -345,7 +383,7 @@ bool32 OpenPokenavMenuNotInitial(void); void CreateMenuHandlerLoopedTask(s32 ltIdx); bool32 IsMenuHandlerLoopedTaskActive(void); void FreeMenuHandlerSubstruct2(void); -void sub_81CAADC(void); +void ResetBldCnt_(void); // pokenav_match_call_1.c bool32 PokenavCallback_Init_MatchCall(void); @@ -364,7 +402,7 @@ const u8 *GetMatchCallMessageText(int index, u8 *arg1); u16 GetMatchCallOptionCursorPos(void); u16 GetMatchCallOptionId(int arg0); void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries * arg0, u8 *str); -u8 sub_81CB0C8(int rematchIndex); +u8 GetMatchTableMapSectionId(int rematchIndex); int GetIndexDeltaOfNextCheckPageDown(int index); int GetIndexDeltaOfNextCheckPageUp(int index); bool32 IsRematchEntryRegistered(int index); @@ -385,60 +423,60 @@ void FreeRegionMapSubstruct1(void); void FreeRegionMapSubstruct2(void); // pokenav_conditions_1.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 ConditionGraph *sub_81CDC70(void); -u16 sub_81CDC60(void); -u16 sub_81CDC50(void); -u8 sub_81CDDB0(void); -bool32 sub_81CD548(u8 arg0); -u8 sub_81CDD7C(void); -u8 *sub_81CDD04(u8 id); -u8 *sub_81CDD24(u8 id); -u16 sub_81CDD48(void); -void *sub_81CDCB4(u8 id); -void *sub_81CDCD4(u8 id); +u32 PokenavCallback_Init_PartyCondition(void); +u32 PokenavCallback_Init_ConditionGraphFromSearch(void); +u32 GetPartyConditionCallback(void); +void FreePartyConditionSubstruct1(void); +bool32 LoadPartyConditionMenuGfx(void); +bool32 IsConditionMenuSearchMode(void); +struct ConditionGraph *GetConditionGraphDataPtr(void); +u16 GetConditionGraphCurrentMonIndex(void); +u16 GetMonListCount(void); +u8 GetMonSheen(void); +bool32 SetConditionGraphData(u8 arg0); +u8 TryGetMonMarkId(void); +u8 *GetConditionMonNameBuffer(u8 id); +u8 *GetConditionMonLocationBuffer(u8 id); +u16 GetConditionMonDataBuffer(void); +void *GetConditionMonPicGfx(u8 id); +void *GetConditionMonPal(u8 id); // pokenav_conditions_2.c -bool32 sub_81CDDD4(void); -void sub_81CDE2C(s32); -u32 sub_81CDE64(void); -void sub_81CECA0(void); -u8 sub_81CEF14(void); +bool32 OpenPartyConditionMenu(void); +void CreatePartyConditionLoopedTask(s32); +u32 IsPartyConditionLoopedTaskActive(void); +void FreePartyConditionSubstruct2(void); +u8 GetMonMarkingsData(void); // pokenav_conditions_3.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); +u32 PokenavCallback_Init_ConditionSearch(void); +u32 PokenavCallback_Init_ReturnToMonSearchList(void); +u32 GetConditionSearchResultsCallback(void); +void FreeSearchResultSubstruct1(void); +bool32 OpenConditionSearchResults(void); +bool32 OpenConditionSearchListFromGraph(void); +void CreateSearchResultsLoopedTask(s32); +u32 IsSearchResultLoopedTaskActive(void); +void FreeSearchResultSubstruct2(void); // pokenav_ribbons_1.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); +u32 PokenavCallback_Init_MonRibbonList(void); +u32 PokenavCallback_Init_RibbonsMonListFromSummary(void); +u32 GetRibbonsMonListCallback(void); +void FreeRibbonsMonList1(void); +bool32 OpenRibbonsMonList(void); +bool32 OpenRibbonsMonListFromRibbonsSummary(void); +void CreateRibbonsMonListLoopedTask(s32); +u32 IsRibbonsMonListLoopedTaskActive(void); +void FreeRibbonsMonList2(void); // pokenav_ribbons_2.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); +u32 PokenavCallback_Init_RibbonsSummaryMenu(void); +u32 GetRibbonsSummaryMenuCallback(void); +void FreeRibbonsSummaryScreen1(void); +bool32 OpenRibbonsSummaryMenu(void); +void CreateRibbonsSummaryLoopedTask(s32); +u32 IsRibbonsSummaryLoopedTaskActive(void); +void FreeRibbonsSummaryScreen2(void); #endif // GUARD_POKENAV_H diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 327dcefc4..0745ac6d5 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -319,7 +319,7 @@ void sub_81D1EC0(void) Free(sUnknown_0203CF4C); } -void sub_81D1ED4(struct ConditionGraph *a0) +void InitConditionGraphData(struct ConditionGraph *graph) { u8 i, j; @@ -327,22 +327,22 @@ void sub_81D1ED4(struct ConditionGraph *a0) { for (i = 0; i < 10; i++) { - a0->unk64[i][j].unk0 = 0; - a0->unk64[i][j].unk2 = 0; + graph->unk64[i][j].unk0 = 0; + graph->unk64[i][j].unk2 = 0; } for (i = 0; i < 4; i++) { - a0->unk0[i][j] = 0; - a0->unk14[i][j].unk0 = 0x9B; - a0->unk14[i][j].unk2 = 0x5B; + graph->stat[i][j] = 0; + graph->unk14[i][j].unk0 = 155; + graph->unk14[i][j].unk2 = 91; } - a0->unk12C[j].unk0 = 0; - a0->unk12C[j].unk2 = 0; + graph->unk12C[j].unk0 = 0; + graph->unk12C[j].unk2 = 0; } - a0->unk354 = 0; - a0->unk352 = 0; + graph->unk354 = 0; + graph->unk352 = 0; } void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2) @@ -350,7 +350,7 @@ void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 * u16 i, j; s32 r5, r6; - for (i = 0; i < 5; i++) + for (i = 0; i < FLAVOR_COUNT; i++) { r5 = arg1[i].unk0 << 8; r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / 10; @@ -387,25 +387,25 @@ bool32 TransitionConditionGraph(struct ConditionGraph *graph) } } -void sub_81D20AC(struct ConditionGraph *a0) +void InitConditionGraphState(struct ConditionGraph *graph) { - a0->unk355 = 0; + graph->state = 0; } -bool8 sub_81D20BC(struct ConditionGraph *graph) +bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph) { struct ScanlineEffectParams params; - switch (graph->unk355) + switch (graph->state) { case 0: ScanlineEffect_Clear(); - graph->unk355++; + graph->state++; return TRUE; case 1: params = sConditionGraphScanline; ScanlineEffect_SetParams(params); - graph->unk355++; + graph->state++; return FALSE; default: return FALSE; @@ -431,7 +431,7 @@ void sub_81D2108(struct ConditionGraph *graph) graph->unk354 = 0; } -void sub_81D21DC(u8 bg) +void SetConditionGraphIOWindows(u8 bg) { u32 flags; @@ -1025,23 +1025,23 @@ void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 if (partyId != numMons) { - graph->unk0[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); - graph->unk0[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); - graph->unk0[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); - graph->unk0[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); - graph->unk0[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + graph->stat[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + graph->stat[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + graph->stat[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + graph->stat[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + graph->stat[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF) ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u : 9; - sub_81D2754(graph->unk0[id], graph->unk14[id]); + sub_81D2754(graph->stat[id], graph->unk14[id]); } else { for (i = 0; i < FLAVOR_COUNT; i++) { - graph->unk0[id][i] = 0; + graph->stat[id][i] = 0; graph->unk14[id][i].unk0 = 155; graph->unk14[id][i].unk2 = 91; } diff --git a/src/mon_markings.c b/src/mon_markings.c index c2afdda83..a819d4f9a 100644 --- a/src/mon_markings.c +++ b/src/mon_markings.c @@ -390,7 +390,7 @@ void sub_811FAF8(void) } } -bool8 sub_811FBA4(void) +bool8 MonMarkingsMenuHandleInput(void) { u16 i; @@ -564,7 +564,7 @@ static void sub_811FF7C(struct Sprite *sprite) sprite->pos1.y = (16 * sMenu->cursorPos) + sprite->data[0]; } -struct Sprite *sub_811FF94(u16 tileTag, u16 paletteTag, const u16 *palette) +struct Sprite *CreateMonMarkingsSpriteWithPal(u16 tileTag, u16 paletteTag, const u16 *palette) { if (!palette) palette = gUnknown_0859E65C; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index b61aff350..4db9fbf92 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -3183,7 +3183,7 @@ static void Cb_ShowMarkMenu(u8 taskId) sPSSData->state++; break; case 1: - if (!sub_811FBA4()) + if (!MonMarkingsMenuHandleInput()) { sub_811FAF8(); ClearBottomWindow(); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index c80c4c5c4..012e133e6 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -3976,7 +3976,7 @@ static void StopPokemonAnimations(void) // A subtle effect, this function stops static void CreateMonMarkingsSprite(struct Pokemon *mon) { - struct Sprite *sprite = sub_811FF94(TAG_MON_MARKINGS, TAG_MON_MARKINGS, sSummaryMarkingsPalette); + struct Sprite *sprite = CreateMonMarkingsSpriteWithPal(TAG_MON_MARKINGS, TAG_MON_MARKINGS, sSummaryMarkingsPalette); sMonSummaryScreen->markingsSprite = sprite; if (sprite != NULL) diff --git a/src/pokenav.c b/src/pokenav.c index 30dc001c3..12a13509b 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -14,8 +14,6 @@ #define LOOPED_TASK_PRIMARY_ID(taskId) (taskId & 0xFFFF) #define LOOPED_TASK_SECONDARY_ID(taskId) (taskId >> 16) -#define SUBSTRUCT_COUNT 19 - struct PokenavResources { u32 (*currentMenuCb1)(void); @@ -23,7 +21,7 @@ struct PokenavResources u16 mode; u16 conditionSearchId; bool32 hasAnyRibbons; - void *field10[SUBSTRUCT_COUNT]; + void *substructPtrs[POKENAV_SUBSTRUCT_COUNT]; }; struct PokenavCallbacks @@ -38,7 +36,7 @@ struct PokenavCallbacks }; static u32 GetCurrentMenuCB(void); -static u32 sub_81C75D4(void); +static u32 IsActiveMenuLoopTaskActive_(void); static bool32 SetActivePokenavMenu(u32 menuId); static bool32 AnyMonHasRibbon(void); static void InitPokenavResources(struct PokenavResources *a0); @@ -126,43 +124,43 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] = }, [POKENAV_CONDITION_PARTY - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_7, - .callback = sub_81CD070, - .open = sub_81CDDD4, - .createLoopTask = sub_81CDE2C, - .isLoopTaskActive = sub_81CDE64, - .free1 = sub_81CD1C0, - .free2 = sub_81CECA0, + .init = PokenavCallback_Init_PartyCondition, + .callback = GetPartyConditionCallback, + .open = OpenPartyConditionMenu, + .createLoopTask = CreatePartyConditionLoopedTask, + .isLoopTaskActive = IsPartyConditionLoopedTaskActive, + .free1 = FreePartyConditionSubstruct1, + .free2 = FreePartyConditionSubstruct2, }, [POKENAV_CONDITION_SEARCH_RESULTS - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_8, - .callback = sub_81CEFDC, - .open = sub_81CF330, - .createLoopTask = sub_81CF3A0, - .isLoopTaskActive = sub_81CF3D0, - .free1 = sub_81CEFF0, - .free2 = sub_81CF3F8, + .init = PokenavCallback_Init_ConditionSearch, + .callback = GetConditionSearchResultsCallback, + .open = OpenConditionSearchResults, + .createLoopTask = CreateSearchResultsLoopedTask, + .isLoopTaskActive = IsSearchResultLoopedTaskActive, + .free1 = FreeSearchResultSubstruct1, + .free2 = FreeSearchResultSubstruct2, }, - [POKENAV_MENU_9 - POKENAV_MENU_IDS_START] = + [POKENAV_MENU_CONDITION_GRAPH_FROM_SEARCH - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_9, - .callback = sub_81CD070, - .open = sub_81CDDD4, - .createLoopTask = sub_81CDE2C, - .isLoopTaskActive = sub_81CDE64, - .free1 = sub_81CD1C0, - .free2 = sub_81CECA0, + .init = PokenavCallback_Init_ConditionGraphFromSearch, + .callback = GetPartyConditionCallback, + .open = OpenPartyConditionMenu, + .createLoopTask = CreatePartyConditionLoopedTask, + .isLoopTaskActive = IsPartyConditionLoopedTaskActive, + .free1 = FreePartyConditionSubstruct1, + .free2 = FreePartyConditionSubstruct2, }, - [POKENAV_MENU_A - POKENAV_MENU_IDS_START] = + [POKENAV_RETURN_CONDITION_SEARCH - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_10, - .callback = sub_81CEFDC, - .open = sub_81CF368, - .createLoopTask = sub_81CF3A0, - .isLoopTaskActive = sub_81CF3D0, - .free1 = sub_81CEFF0, - .free2 = sub_81CF3F8, + .init = PokenavCallback_Init_ReturnToMonSearchList, + .callback = GetConditionSearchResultsCallback, + .open = OpenConditionSearchListFromGraph, + .createLoopTask = CreateSearchResultsLoopedTask, + .isLoopTaskActive = IsSearchResultLoopedTaskActive, + .free1 = FreeSearchResultSubstruct1, + .free2 = FreeSearchResultSubstruct2, }, [POKENAV_MATCH_CALL - POKENAV_MENU_IDS_START] = { @@ -176,33 +174,33 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] = }, [POKENAV_RIBBONS_MON_LIST - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_12, - .callback = sub_81CFA34, - .open = sub_81CFDD0, - .createLoopTask = sub_81CFE40, - .isLoopTaskActive = sub_81CFE70, - .free1 = sub_81CFA48, - .free2 = sub_81CFE98, + .init = PokenavCallback_Init_MonRibbonList, + .callback = GetRibbonsMonListCallback, + .open = OpenRibbonsMonList, + .createLoopTask = CreateRibbonsMonListLoopedTask, + .isLoopTaskActive = IsRibbonsMonListLoopedTaskActive, + .free1 = FreeRibbonsMonList1, + .free2 = FreeRibbonsMonList2, }, - [POKENAV_MENU_D - POKENAV_MENU_IDS_START] = + [POKENAV_RIBBONS_SUMMARY_SCREEN - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_13, - .callback = sub_81D04A0, - .open = sub_81D0978, - .createLoopTask = sub_81D09B0, - .isLoopTaskActive = sub_81D09E0, - .free1 = sub_81D04B8, - .free2 = sub_81D09F4, + .init = PokenavCallback_Init_RibbonsSummaryMenu, + .callback = GetRibbonsSummaryMenuCallback, + .open = OpenRibbonsSummaryMenu, + .createLoopTask = CreateRibbonsSummaryLoopedTask, + .isLoopTaskActive = IsRibbonsSummaryLoopedTaskActive, + .free1 = FreeRibbonsSummaryScreen1, + .free2 = FreeRibbonsSummaryScreen2, }, - [POKENAV_MENU_E - POKENAV_MENU_IDS_START] = + [POKENAV_RIBBONS_RETURN_TO_MON_LIST - POKENAV_MENU_IDS_START] = { - .init = PokenavCallback_Init_14, - .callback = sub_81CFA34, - .open = sub_81CFE08, - .createLoopTask = sub_81CFE40, - .isLoopTaskActive = sub_81CFE70, - .free1 = sub_81CFA48, - .free2 = sub_81CFE98, + .init = PokenavCallback_Init_RibbonsMonListFromSummary, + .callback = GetRibbonsMonListCallback, + .open = OpenRibbonsMonListFromRibbonsSummary, + .createLoopTask = CreateRibbonsMonListLoopedTask, + .isLoopTaskActive = IsRibbonsMonListLoopedTaskActive, + .free1 = FreeRibbonsMonList1, + .free2 = FreeRibbonsMonList2, }, }; @@ -368,24 +366,24 @@ static void FreePokenavResources(void) { int i; - for (i = 0; i < SUBSTRUCT_COUNT; i++) + for (i = 0; i < POKENAV_SUBSTRUCT_COUNT; i++) FreePokenavSubstruct(i); FREE_AND_SET_NULL(gPokenavResources); InitKeys(); } -static void InitPokenavResources(struct PokenavResources *a0) +static void InitPokenavResources(struct PokenavResources *resources) { int i; - for (i = 0; i < SUBSTRUCT_COUNT; i++) - a0->field10[i] = NULL; + for (i = 0; i < POKENAV_SUBSTRUCT_COUNT; i++) + resources->substructPtrs[i] = NULL; - a0->mode = POKENAV_MODE_NORMAL; - a0->currentMenuIndex = 0; - a0->hasAnyRibbons = AnyMonHasRibbon(); - a0->currentMenuCb1 = NULL; + resources->mode = POKENAV_MODE_NORMAL; + resources->currentMenuIndex = 0; + resources->hasAnyRibbons = AnyMonHasRibbon(); + resources->currentMenuCb1 = NULL; } static bool32 AnyMonHasRibbon(void) @@ -453,12 +451,12 @@ static void Task_Pokenav(u8 taskId) tState = 4; break; case 2: - if (sub_81C786C()) + if (IsActiveMenuLoopTaskActive()) break; tState = 3; case 3: menuId = GetCurrentMenuCB(); - if (menuId == -1) + if (menuId == POKENAV_MENU_FUNC_EXIT) { ShutdownPokenav(); tState = 5; @@ -479,13 +477,13 @@ static void Task_Pokenav(u8 taskId) } else if (menuId != 0) { - sub_81C7850(menuId); - if (sub_81C786C()) + RunMainMenuLoopedTask(menuId); + if (IsActiveMenuLoopTaskActive()) tState = 2; } break; case 4: - if (!sub_81C75D4()) + if (!IsActiveMenuLoopTaskActive_()) tState = 3; break; case 5: @@ -516,15 +514,15 @@ static bool32 SetActivePokenavMenu(u32 menuId) if (!PokenavMenuCallbacks[index].open()) return FALSE; - sub_81C7834(PokenavMenuCallbacks[index].createLoopTask, PokenavMenuCallbacks[index].isLoopTaskActive); + SetActiveMenuLoopTasks(PokenavMenuCallbacks[index].createLoopTask, PokenavMenuCallbacks[index].isLoopTaskActive); gPokenavResources->currentMenuCb1 = PokenavMenuCallbacks[index].callback; gPokenavResources->currentMenuIndex = index; return TRUE; } -static u32 sub_81C75D4(void) +static u32 IsActiveMenuLoopTaskActive_(void) { - return sub_81C786C(); + return IsActiveMenuLoopTaskActive(); } static u32 GetCurrentMenuCB(void) @@ -549,19 +547,19 @@ void SetPokenavVBlankCallback(void) void *AllocSubstruct(u32 index, u32 size) { - gPokenavResources->field10[index] = Alloc(size); - return gPokenavResources->field10[index]; + gPokenavResources->substructPtrs[index] = Alloc(size); + return gPokenavResources->substructPtrs[index]; } void *GetSubstructPtr(u32 index) { - return gPokenavResources->field10[index]; + return gPokenavResources->substructPtrs[index]; } void FreePokenavSubstruct(u32 index) { - if (gPokenavResources->field10[index] != NULL) - FREE_AND_SET_NULL(gPokenavResources->field10[index]); + if (gPokenavResources->substructPtrs[index] != NULL) + FREE_AND_SET_NULL(gPokenavResources->substructPtrs[index]); } u32 GetPokenavMode(void) diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c index 15d55ffb8..c27cd410c 100644 --- a/src/pokenav_conditions_1.c +++ b/src/pokenav_conditions_1.c @@ -18,98 +18,98 @@ struct PokenavSub11 u32 monPal[3][0x20]; u8 fill[0x180]; u32 monPicGfx[3][0x800]; - u8 unk6300; - s16 unk6302; - u32 (*unk6304)(struct PokenavSub11 *); + u8 searchMode; + s16 monIndex; + u32 (*callback)(struct PokenavSub11 *); u8 fill2[0x6320 - 0x6308]; - u8 unk6320[3][24]; - u8 unk6368[3][64]; - struct ConditionGraph unk6428; - u8 unk6780[3]; - u8 unk6783[3]; - s8 unk6786; + u8 searchLocBuffer[3][24]; + u8 nameBuffer[3][64]; + struct ConditionGraph conditionData; + u8 sheen[3]; + u8 monMarks[3]; + s8 mark; s8 unk6787; s8 unk6788; s8 unk6789; - u8 unk678A; + u8 state; }; -void sub_81CD970(void); +void InitPartyConditionListParameters(void); void sub_81CD9F8(void); -u32 sub_81CD08C(struct PokenavSub11 *structPtr); -u32 sub_81CD19C(struct PokenavSub11 *structPtr); -u32 sub_81CD110(struct PokenavSub11 *structPtr); -u8 sub_81CD1E4(struct PokenavSub11 *structPtr); -u8 sub_81CD258(u8 arg0); -void sub_81CD824(s16 arg0, u8 arg1); -void sub_81CDA1C(s16 arg0, u8 arg1); -void sub_81CDB98(s16 arg0, u8 arg1); +u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr); +u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr); +u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr); +u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr); +u8 SwitchConditionSummaryIndex(u8 moveUp); +void CopyMonNameGenderLocation(s16 id, u8 arg1); +void GetMonConditionGraphData(s16 id, u8 arg1); +void ConditionGraphDrawMonPic(s16 id, u8 arg1); // code -bool32 PokenavCallback_Init_7(void) +bool32 PokenavCallback_Init_PartyCondition(void) { - struct PokenavSub11 *structPtr = AllocSubstruct(11, sizeof(struct PokenavSub11)); + struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11)); if (structPtr == NULL) return FALSE; - sub_81D1ED4(&structPtr->unk6428); - sub_81CD970(); + InitConditionGraphData(&structPtr->conditionData); + InitPartyConditionListParameters(); gKeyRepeatStartDelay = 20; - structPtr->unk6304 = sub_81CD08C; + structPtr->callback = HandlePartyConditionInput; return TRUE; } -bool32 PokenavCallback_Init_9(void) +bool32 PokenavCallback_Init_ConditionGraphFromSearch(void) { - struct PokenavSub11 *structPtr = AllocSubstruct(11, sizeof(struct PokenavSub11)); + struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11)); if (structPtr == NULL) return FALSE; - sub_81D1ED4(&structPtr->unk6428); + InitConditionGraphData(&structPtr->conditionData); sub_81CD9F8(); gKeyRepeatStartDelay = 20; - structPtr->unk6304 = sub_81CD08C; + structPtr->callback = HandlePartyConditionInput; return TRUE; } -u32 sub_81CD070(void) +u32 GetPartyConditionCallback(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - return structPtr->unk6304(structPtr); + return structPtr->callback(structPtr); } -u32 sub_81CD08C(struct PokenavSub11 *structPtr) +u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr) { - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); - u32 ret = sub_81CD1E4(structPtr); + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + u32 ret = ConditionGraphHandleDpadInput(structPtr); - if (ret == 0) + if (ret == PARTY_CONDITION_FUNC_NONE) { if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - structPtr->unk6304 = sub_81CD19C; - ret = 2; + structPtr->callback = GetConditionReturnCallback; + ret = PARTY_CONDITION_FUNC_RETURN; } else if (JOY_NEW(A_BUTTON)) { - if (structPtr->unk6300 == 0) + if (structPtr->searchMode == 0) { - if (unkPtr->unk2 == unkPtr->unk0 - 1) + if (monListPtr->currIndex == monListPtr->listCount - 1) { PlaySE(SE_SELECT); - structPtr->unk6304 = sub_81CD19C; - ret = 2; + structPtr->callback = GetConditionReturnCallback; + ret = PARTY_CONDITION_FUNC_RETURN; } } else { PlaySE(SE_SELECT); - ret = 5; - structPtr->unk6304 = sub_81CD110; + ret = PARTY_CONDITION_FUNC_ADD_MARKINGS; + structPtr->callback = ConditionMenu_OpenMarkingsMenu; } } } @@ -117,204 +117,204 @@ u32 sub_81CD08C(struct PokenavSub11 *structPtr) return ret; } -u32 sub_81CD110(struct PokenavSub11 *structPtr) +u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr) { - struct PokenavSub18 *unkPtr; + struct PokenavSub18 *monListPtr; u8 markings; - u32 ret = 0, boxId, monId; + u32 ret = PARTY_CONDITION_FUNC_NONE, boxId, monId; - if (!sub_811FBA4()) + if (!MonMarkingsMenuHandleInput()) { - structPtr->unk6783[structPtr->unk6786] = sub_81CEF14(); - unkPtr = GetSubstructPtr(18); - boxId = unkPtr->unk4[unkPtr->unk2].boxId; - monId = unkPtr->unk4[unkPtr->unk2].monId; - markings = structPtr->unk6783[structPtr->unk6786]; + structPtr->monMarks[structPtr->mark] = GetMonMarkingsData(); + monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + boxId = monListPtr->monData[monListPtr->currIndex].boxId; + monId = monListPtr->monData[monListPtr->currIndex].monId; + markings = structPtr->monMarks[structPtr->mark]; if (boxId == TOTAL_BOXES_COUNT) SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings); else SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings); - structPtr->unk6304 = sub_81CD08C; - ret = 6; + structPtr->callback = HandlePartyConditionInput; + ret = PARTY_CONDITION_FUNC_CLOSE_MARKINGS; } return ret; } -u32 sub_81CD19C(struct PokenavSub11 *structPtr) +u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr) { - if (structPtr->unk6300 == 0) + if (structPtr->searchMode == 0) return POKENAV_CONDITION_MENU; else - return POKENAV_MENU_A; + return POKENAV_RETURN_CONDITION_SEARCH; } -void sub_81CD1C0(void) +void FreePartyConditionSubstruct1(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - if (structPtr->unk6300 == 0) - FreePokenavSubstruct(18); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + if (structPtr->searchMode == 0) + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST); - FreePokenavSubstruct(11); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH); } -u8 sub_81CD1E4(struct PokenavSub11 *structPtr) +u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) { - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); u8 ret = 0; if (JOY_HELD(DPAD_UP)) { - if (structPtr->unk6300 == 0 || unkPtr->unk2 != 0) + if (structPtr->searchMode == 0 || monListPtr->currIndex != 0) { PlaySE(SE_SELECT); - ret = sub_81CD258(1); + ret = SwitchConditionSummaryIndex(1); } } else if (JOY_HELD(DPAD_DOWN)) { - if (structPtr->unk6300 == 0 || unkPtr->unk2 < unkPtr->unk0 - 1) + if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1) { PlaySE(SE_SELECT); - ret = sub_81CD258(0); + ret = SwitchConditionSummaryIndex(0); } } return ret; } -u8 sub_81CD258(u8 arg0) +u8 SwitchConditionSummaryIndex(u8 moveUp) { u16 r7; - bool8 r6, r0; - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); + bool8 wasNotLastMon, isNotLastMon; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - r7 = (arg0) ? structPtr->unk6788 : structPtr->unk6787; - sub_81D1F84(&structPtr->unk6428, structPtr->unk6428.unk14[structPtr->unk6786], structPtr->unk6428.unk14[r7]); - r6 = (unkPtr->unk2 != ((sub_81CDD5C() != 0) ? unkPtr->unk0 : unkPtr->unk0 - 1)); - if (arg0) + r7 = (moveUp) ? structPtr->unk6788 : structPtr->unk6787; + sub_81D1F84(&structPtr->conditionData, structPtr->conditionData.unk14[structPtr->mark], structPtr->conditionData.unk14[r7]); + wasNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1)); + if (moveUp) { structPtr->unk6788 = structPtr->unk6787; - structPtr->unk6787 = structPtr->unk6786; - structPtr->unk6786 = r7; + structPtr->unk6787 = structPtr->mark; + structPtr->mark = r7; structPtr->unk6789 = structPtr->unk6788; - unkPtr->unk2 = (unkPtr->unk2 == 0) ? unkPtr->unk0 - 1 : unkPtr->unk2 - 1; - structPtr->unk6302 = (unkPtr->unk2 != 0) ? unkPtr->unk2 - 1 : unkPtr->unk0 - 1; + monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1; + structPtr->monIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1; } else { structPtr->unk6787 = structPtr->unk6788; - structPtr->unk6788 = structPtr->unk6786; - structPtr->unk6786 = r7; + structPtr->unk6788 = structPtr->mark; + structPtr->mark = r7; structPtr->unk6789 = structPtr->unk6787; - unkPtr->unk2 = (unkPtr->unk2 < unkPtr->unk0 - 1) ? unkPtr->unk2 + 1 : 0; - structPtr->unk6302 = (unkPtr->unk2 < unkPtr->unk0 - 1) ? unkPtr->unk2 + 1 : 0; + monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0; + structPtr->monIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0; } - r0 = (unkPtr->unk2 != ((sub_81CDD5C() != 0) ? unkPtr->unk0 : unkPtr->unk0 - 1)); - - if (!r6) - return 3; - else if (!r0) - return 4; + isNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1)); + + if (!wasNotLastMon) + return PARTY_CONDITION_FUNC_NO_TRANSITION; + else if (!isNotLastMon) + return PARTY_CONDITION_FUNC_SLIDE_MON_OUT; else - return 1; + return PARTY_CONDITION_FUNC_SLIDE_MON_IN; } -bool32 sub_81CD3C4(void) +bool32 LoadPartyConditionMenuGfx(void) { s32 var; - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - switch (structPtr->unk678A) + switch (structPtr->state) { case 0: - sub_81CD824(unkPtr->unk2, 0); + CopyMonNameGenderLocation(monListPtr->currIndex, 0); break; case 1: - sub_81CDA1C(unkPtr->unk2, 0); + GetMonConditionGraphData(monListPtr->currIndex, 0); break; case 2: - sub_81CDB98(unkPtr->unk2, 0); + ConditionGraphDrawMonPic(monListPtr->currIndex, 0); break; case 3: - if (unkPtr->unk0 == 1) + if (monListPtr->listCount == 1) { - structPtr->unk6786 = 0; + structPtr->mark = 0; structPtr->unk6787 = 0; structPtr->unk6788 = 0; - structPtr->unk678A = 0; + structPtr->state = 0; return TRUE; } else { - structPtr->unk6786 = 0; + structPtr->mark = 0; structPtr->unk6787 = 1; structPtr->unk6788 = 2; } break; // These were probably ternaries just like cases 7-9, but couldn't match it any other way. case 4: - var = unkPtr->unk2 + 1; - if (var >= unkPtr->unk0) + var = monListPtr->currIndex + 1; + if (var >= monListPtr->listCount) var = 0; - sub_81CD824(var, 1); + CopyMonNameGenderLocation(var, 1); break; case 5: - var = unkPtr->unk2 + 1; - if (var >= unkPtr->unk0) + var = monListPtr->currIndex + 1; + if (var >= monListPtr->listCount) var = 0; - sub_81CDA1C(var, 1); + GetMonConditionGraphData(var, 1); break; case 6: - var = unkPtr->unk2 + 1; - if (var >= unkPtr->unk0) + var = monListPtr->currIndex + 1; + if (var >= monListPtr->listCount) var = 0; - sub_81CDB98(var, 1); + ConditionGraphDrawMonPic(var, 1); break; case 7: - sub_81CD824((unkPtr->unk2 - 1 >= 0) ? unkPtr->unk2 - 1 : unkPtr->unk0 - 1, 2); + CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); break; case 8: - sub_81CDA1C((unkPtr->unk2 - 1 >= 0) ? unkPtr->unk2 - 1 : unkPtr->unk0 - 1, 2); + GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); break; case 9: - sub_81CDB98((unkPtr->unk2 - 1 >= 0) ? unkPtr->unk2 - 1 : unkPtr->unk0 - 1, 2); - structPtr->unk678A = 0; + ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); + structPtr->state = 0; return TRUE; } - structPtr->unk678A++; + structPtr->state++; return FALSE; } -bool32 sub_81CD548(u8 arg0) +bool32 SetConditionGraphData(u8 mode) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); - switch (arg0) + switch (mode) { case 0: - sub_81CD824(structPtr->unk6302, structPtr->unk6789); + CopyMonNameGenderLocation(structPtr->monIndex, structPtr->unk6789); break; case 1: - sub_81CDA1C(structPtr->unk6302, structPtr->unk6789); + GetMonConditionGraphData(structPtr->monIndex, structPtr->unk6789); break; case 2: - sub_81CDB98(structPtr->unk6302, structPtr->unk6789); + ConditionGraphDrawMonPic(structPtr->monIndex, structPtr->unk6789); return TRUE; } return FALSE; } -u8 *sub_81CD5CC(u8 *dst, const u8 *src, s16 n) +u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n) { while (*src != EOS) *dst++ = *src++, n--; @@ -326,15 +326,15 @@ u8 *sub_81CD5CC(u8 *dst, const u8 *src, s16 n) return dst; } -u8 *sub_81CD624(u8 *str, u16 id, bool8 arg3) +u8 *CopyMonConditionNameGender(u8 *str, u16 id, bool8 arg3) { u16 boxId, monId, gender, species, level, lvlDigits; struct BoxPokemon *boxMon; u8 *txtPtr, *str_; - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - boxId = unkPtr->unk4[id].boxId; - monId = unkPtr->unk4[id].monId; + boxId = monListPtr->monData[id].boxId; + monId = monListPtr->monData[id].monId; *(str++) = EXT_CTRL_CODE_BEGIN; *(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; *(str++) = TEXT_COLOR_BLUE; @@ -417,115 +417,115 @@ u8 *sub_81CD624(u8 *str, u16 id, bool8 arg3) return str_; } -void sub_81CD824(s16 arg0, u8 arg1) +void CopyMonNameGenderLocation(s16 id, u8 arg1) { u16 boxId, i; - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (arg0 != (sub_81CDD5C() != 0 ? unkPtr->unk0 : unkPtr->unk0 - 1)) + if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) { - sub_81CD624(structPtr->unk6368[arg1], arg0, FALSE); - boxId = unkPtr->unk4[arg0].boxId; - structPtr->unk6320[arg1][0] = EXT_CTRL_CODE_BEGIN; - structPtr->unk6320[arg1][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; - structPtr->unk6320[arg1][2] = TEXT_COLOR_BLUE; - structPtr->unk6320[arg1][3] = TEXT_COLOR_TRANSPARENT; - structPtr->unk6320[arg1][4] = TEXT_COLOR_LIGHT_BLUE; + CopyMonConditionNameGender(structPtr->nameBuffer[arg1], id, FALSE); + boxId = monListPtr->monData[id].boxId; + structPtr->searchLocBuffer[arg1][0] = EXT_CTRL_CODE_BEGIN; + structPtr->searchLocBuffer[arg1][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; + structPtr->searchLocBuffer[arg1][2] = TEXT_COLOR_BLUE; + structPtr->searchLocBuffer[arg1][3] = TEXT_COLOR_TRANSPARENT; + structPtr->searchLocBuffer[arg1][4] = TEXT_COLOR_LIGHT_BLUE; if (boxId == TOTAL_BOXES_COUNT) - sub_81CD5CC(&structPtr->unk6320[arg1][5], gText_InParty, 8); + CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], gText_InParty, 8); else - sub_81CD5CC(&structPtr->unk6320[arg1][5], GetBoxNamePtr(boxId), 8); + CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], GetBoxNamePtr(boxId), 8); } else { for (i = 0; i < 12; i++) - structPtr->unk6368[arg1][i] = CHAR_SPACE; - structPtr->unk6368[arg1][i] = EOS; + structPtr->nameBuffer[arg1][i] = CHAR_SPACE; + structPtr->nameBuffer[arg1][i] = EOS; for (i = 0; i < 8; i++) - structPtr->unk6320[arg1][i] = CHAR_SPACE; - structPtr->unk6320[arg1][i] = EOS; + structPtr->searchLocBuffer[arg1][i] = CHAR_SPACE; + structPtr->searchLocBuffer[arg1][i] = EOS; } } -void sub_81CD970(void) +void InitPartyConditionListParameters(void) { u16 i, count; - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - struct PokenavSub18 *unkPtr = AllocSubstruct(18, sizeof(struct PokenavSub18)); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct PokenavSub18 *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); - structPtr->unk6300 = 0; + structPtr->searchMode = 0; for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++) { if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) { - unkPtr->unk4[count].boxId = TOTAL_BOXES_COUNT; - unkPtr->unk4[count].monId = i; - unkPtr->unk4[count].data = 0; + monListPtr->monData[count].boxId = TOTAL_BOXES_COUNT; + monListPtr->monData[count].monId = i; + monListPtr->monData[count].data = 0; count++; } } - unkPtr->unk4[count].boxId = 0; - unkPtr->unk4[count].monId = 0; - unkPtr->unk4[count].data = 0; - unkPtr->unk2 = 0; - unkPtr->unk0 = count + 1; - structPtr->unk678A = 0; + monListPtr->monData[count].boxId = 0; + monListPtr->monData[count].monId = 0; + monListPtr->monData[count].data = 0; + monListPtr->currIndex = 0; + monListPtr->listCount = count + 1; + structPtr->state = 0; } void sub_81CD9F8(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - structPtr->unk6300 = 1; - structPtr->unk678A = 0; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + structPtr->searchMode = 1; + structPtr->state = 0; } -void sub_81CDA1C(s16 arg0, u8 arg1) +void GetMonConditionGraphData(s16 id, u8 arg1) { u16 boxId, monId, i; - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (arg0 != (sub_81CDD5C() != 0 ? unkPtr->unk0 : unkPtr->unk0 - 1)) + if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) { - boxId = unkPtr->unk4[arg0].boxId; - monId = unkPtr->unk4[arg0].monId; - structPtr->unk6428.unk0[arg1][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); - structPtr->unk6428.unk0[arg1][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); - structPtr->unk6428.unk0[arg1][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); - structPtr->unk6428.unk0[arg1][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); - structPtr->unk6428.unk0[arg1][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); - structPtr->unk6780[arg1] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 255) + boxId = monListPtr->monData[id].boxId; + monId = monListPtr->monData[id].monId; + structPtr->conditionData.stat[arg1][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + structPtr->conditionData.stat[arg1][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + structPtr->conditionData.stat[arg1][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + structPtr->conditionData.stat[arg1][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + structPtr->conditionData.stat[arg1][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + structPtr->sheen[arg1] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 255) ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u : 9; - structPtr->unk6783[arg1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); - sub_81D2754(structPtr->unk6428.unk0[arg1], structPtr->unk6428.unk14[arg1]); + structPtr->monMarks[arg1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); + sub_81D2754(structPtr->conditionData.stat[arg1], structPtr->conditionData.unk14[arg1]); } else { - for (i = 0; i < 5; i++) + for (i = 0; i < FLAVOR_COUNT; i++) { - structPtr->unk6428.unk0[arg1][i] = 0; - structPtr->unk6428.unk14[arg1][i].unk0 = 155; - structPtr->unk6428.unk14[arg1][i].unk2 = 91; + structPtr->conditionData.stat[arg1][i] = 0; + structPtr->conditionData.unk14[arg1][i].unk0 = 155; + structPtr->conditionData.unk14[arg1][i].unk2 = 91; } } } -void sub_81CDB98(s16 arg0, u8 arg1) +void ConditionGraphDrawMonPic(s16 index, u8 arg1) { u16 boxId, monId, species; u32 personality, tid; - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); - if (arg0 == (sub_81CDD5C() != 0 ? unkPtr->unk0 : unkPtr->unk0 - 1)) + if (index == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) return; - boxId = unkPtr->unk4[arg0].boxId; - monId = unkPtr->unk4[arg0].monId; + boxId = monListPtr->monData[index].boxId; + monId = monListPtr->monData[index].monId; species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); @@ -533,92 +533,92 @@ void sub_81CDB98(s16 arg0, u8 arg1) LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[arg1]); } -u16 sub_81CDC50(void) +u16 GetMonListCount(void) { - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); - return unkPtr->unk0; + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + return monListPtr->listCount; } -u16 sub_81CDC60(void) +u16 GetConditionGraphCurrentMonIndex(void) { - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); - return unkPtr->unk2; + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + return monListPtr->currIndex; } -struct ConditionGraph *sub_81CDC70(void) +struct ConditionGraph *GetConditionGraphDataPtr(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - return &structPtr->unk6428; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + return &structPtr->conditionData; } -u8 sub_81CDC84(void) +u8 GetMonMarkIndex(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - return structPtr->unk6786; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + return structPtr->mark; } u8 sub_81CDC9C(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - return structPtr->unk6302; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + return structPtr->monIndex; } -void *sub_81CDCB4(u8 id) +void *GetConditionMonPicGfx(u8 id) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); return structPtr->monPicGfx[id]; } -void *sub_81CDCD4(u8 id) +void *GetConditionMonPal(u8 id) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); return structPtr->monPal[id]; } u8 sub_81CDCEC(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); return structPtr->unk6789; } -u8 *sub_81CDD04(u8 id) +u8 *GetConditionMonNameBuffer(u8 id) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - return structPtr->unk6368[id]; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + return structPtr->nameBuffer[id]; } -u8 *sub_81CDD24(u8 id) +u8 *GetConditionMonLocationBuffer(u8 id) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - return structPtr->unk6320[id]; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + return structPtr->searchLocBuffer[id]; } -u16 sub_81CDD48(void) +u16 GetConditionMonDataBuffer(void) { - struct PokenavSub18 *unkPtr = GetSubstructPtr(18); - return unkPtr->unk4[unkPtr->unk2].data; + struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + return monListPtr->monData[monListPtr->currIndex].data; } -bool32 sub_81CDD5C(void) +bool32 IsConditionMenuSearchMode(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - if (structPtr->unk6300 == 1) + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + if (structPtr->searchMode == 1) return TRUE; else return FALSE; } -u8 sub_81CDD7C(void) +u8 TryGetMonMarkId(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - if (structPtr->unk6300 == 1) - return structPtr->unk6783[structPtr->unk6786]; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + if (structPtr->searchMode == 1) + return structPtr->monMarks[structPtr->mark]; else return 0; } -u8 sub_81CDDB0(void) +u8 GetMonSheen(void) { - struct PokenavSub11 *structPtr = GetSubstructPtr(11); - return structPtr->unk6780[structPtr->unk6786]; + struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); + return structPtr->sheen[structPtr->mark]; } diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index 7c536cd6a..dc845ecab 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -15,22 +15,22 @@ #include "strings.h" #include "text.h" -u32 sub_81CE37C(s32); -u32 sub_81CE2D0(s32); -u32 sub_81CE4D8(s32); -u32 sub_81CE5E4(s32); -u32 sub_81CE6BC(s32); -u32 sub_81CE700(s32); +u32 LoopedTask_TransitionMons(s32); +u32 LoopedTask_ExitPartyConditionMenu(s32); +u32 LoopedTask_MoveCursorNoTransition(s32); +u32 LoopedTask_SlideMonOut(s32); +u32 LoopedTask_OpenMonMarkingsWindow(s32); +u32 LoopedTask_CloseMonMarkingsWindow(s32); BSS_DATA u8 gUnknown_030012BC; const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal"); const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal"); const u32 gUnknown_08623228[] = INCBIN_U32("graphics/pokenav/8623228.4bpp.lz"); -const u32 gUnknown_0862323C[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz"); -const u16 gUnknown_08623338[] = INCBIN_U16("graphics/pokenav/8623338.gbapal"); +const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz"); +const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal"); -const struct BgTemplate gUnknown_08623358[3] = +const struct BgTemplate sPartyConditionBgTemplates[3] = { { .bg = 1, @@ -61,7 +61,7 @@ const struct BgTemplate gUnknown_08623358[3] = } }; -const struct WindowTemplate gUnknown_08623364 = +const struct WindowTemplate sMonNameGenderWindowTemplate = { .bg = 1, .tilemapLeft = 13, @@ -72,7 +72,7 @@ const struct WindowTemplate gUnknown_08623364 = .baseBlock = 2 }; -const struct WindowTemplate gUnknown_0862336C = +const struct WindowTemplate sConditionGraphListIdWindowTemplate = { .bg = 1, .tilemapLeft = 1, @@ -83,7 +83,7 @@ const struct WindowTemplate gUnknown_0862336C = .baseBlock = 0x36 }; -const struct WindowTemplate gUnknown_08623374 = +const struct WindowTemplate sUnusedWindowTemplate1 = { .bg = 1, .tilemapLeft = 1, @@ -94,7 +94,7 @@ const struct WindowTemplate gUnknown_08623374 = .baseBlock = 0x44 }; -const struct WindowTemplate gUnknown_0862337C = +const struct WindowTemplate sUnusedWindowTemplate2 = { .bg = 1, .tilemapLeft = 13, @@ -105,15 +105,15 @@ const struct WindowTemplate gUnknown_0862337C = .baseBlock = 0x44 }; -const LoopedTask gUnknown_08623384[] = +const LoopedTask sPartyConditionLoopedTaskFuncs[] = { - NULL, - sub_81CE37C, - sub_81CE2D0, - sub_81CE4D8, - sub_81CE5E4, - sub_81CE6BC, - sub_81CE700 + [PARTY_CONDITION_FUNC_NONE] = NULL, + [PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons, + [PARTY_CONDITION_FUNC_RETURN] = LoopedTask_ExitPartyConditionMenu, + [PARTY_CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition, + [PARTY_CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut, + [PARTY_CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow, + [PARTY_CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow }; struct Pokenav7Struct @@ -121,84 +121,84 @@ struct Pokenav7Struct u32 loopedTaskId; u8 tilemapBuffers[3][BG_SCREEN_SIZE]; u8 filler[2]; - u8 unk1806[10]; - u32 (*unk1810)(void); - s16 unk1814; - u8 unk1816; - u16 unk1818; - u16 unk181A; + u8 partyPokeballSpriteIds[10]; + u32 (*callback)(void); + s16 monTransitionX; + u8 monPicSpriteId; + u16 monPalIndex; + u16 monGfxTileStart; void *unk181C; - u8 unk1820; - u8 unk1821; - u8 unk1822; - u8 unk1823; + u8 nameGenderWindowId; + u8 listIndexWindowId; + u8 unusedWindowId1; + u8 unusedWindowId2; struct PokemonMarkMenu monMarks; - struct Sprite *unk28dc; - struct Sprite *unk28e0[MAX_CONDITION_SPARKLES]; - u8 unk2908; + struct Sprite *monMarksSprite; + struct Sprite *conditionSparkleSprites[MAX_CONDITION_SPARKLES]; + u8 windowModeState; u8 filler2[0x38ac - 0x2909]; }; -extern s8 sub_81CDC84(void); // This function's declaration here is different than its definition in pokenav_unk_6. u8/s8 +extern s8 GetMonMarkIndex(void); // This function's declaration here is different than its definition in pokenav_unk_6. u8/s8 -u32 sub_81CDE94(s32 state); -u32 sub_81CDE80(void); -void sub_81CED30(u8 var); -void sub_81CE9E4(void); -void sub_81CE934(void); -bool32 sub_81CE754(u8 a0, u16 a1, bool8 a2); +u32 LoopedTask_OpenPartyConditionGraph(s32 state); +u32 GetPartyConditionLoopedTaskActive(void); +void CreateConditionMonPic(u8 var); +void CreateMonMarkingsOrPokeballIndicators(void); +void CopyUnusedConditionWindowsToVram(void); +bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2); void sub_81CEE44(void); -void sub_81CEE90(void); +void DoConditionGraphTransition(void); void sub_81CEEC8(void); void sub_81CEE68(void); -void sub_81CEE74(bool8 showBg); +void ToggleBg2(bool8 showBg); // code -bool32 sub_81CDDD4(void) +bool32 OpenPartyConditionMenu(void) { - struct Pokenav7Struct *structPtr = AllocSubstruct(0xC, sizeof(struct Pokenav7Struct)); + struct Pokenav7Struct *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU, sizeof(struct Pokenav7Struct)); if (structPtr == NULL) return FALSE; - structPtr->unk1816 = 0xFF; - structPtr->loopedTaskId = CreateLoopedTask(sub_81CDE94, 1); - structPtr->unk1810 = sub_81CDE80; - structPtr->unk2908 = 0; + structPtr->monPicSpriteId = 0xFF; + structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenPartyConditionGraph, 1); + structPtr->callback = GetPartyConditionLoopedTaskActive; + structPtr->windowModeState = 0; return TRUE; } -void sub_81CDE2C(s32 id) +void CreatePartyConditionLoopedTask(s32 id) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); - structPtr->loopedTaskId = CreateLoopedTask(gUnknown_08623384[id], 1); - structPtr->unk1810 = sub_81CDE80; + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + structPtr->loopedTaskId = CreateLoopedTask(sPartyConditionLoopedTaskFuncs[id], 1); + structPtr->callback = GetPartyConditionLoopedTaskActive; } -u32 sub_81CDE64(void) +u32 IsPartyConditionLoopedTaskActive(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); - return structPtr->unk1810(); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + return structPtr->callback(); } -u32 sub_81CDE80(void) +u32 GetPartyConditionLoopedTaskActive(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); return IsLoopedTaskActive(structPtr->loopedTaskId); } -u32 sub_81CDE94(s32 state) +u32 LoopedTask_OpenPartyConditionGraph(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); switch (state) { case 0: - if (sub_81CD3C4() != TRUE) + if (LoadPartyConditionMenuGfx() != TRUE) return LT_PAUSE; return LT_INC_AND_PAUSE; case 1: - InitBgTemplates(gUnknown_08623358, ARRAY_COUNT(gUnknown_08623358)); + InitBgTemplates(sPartyConditionBgTemplates, ARRAY_COUNT(sPartyConditionBgTemplates)); ChangeBgX(1, 0, 0); ChangeBgY(1, 0, 0); ChangeBgX(2, 0, 0); @@ -221,23 +221,23 @@ u32 sub_81CDE94(s32 state) LZ77UnCompVram(gPokenavCondition_Tilemap, structPtr->tilemapBuffers[0]); SetBgTilemapBuffer(3, structPtr->tilemapBuffers[0]); - if (sub_81CDD5C() == TRUE) + if (IsConditionMenuSearchMode() == TRUE) CopyToBgTilemapBufferRect(3, gPokenavOptions_Tilemap, 0, 5, 9, 4); CopyBgTilemapBufferToVram(3); CopyPaletteIntoBufferUnfaded(gPokenavCondition_Pal, 0x10, 0x20); CopyPaletteIntoBufferUnfaded(gConditionText_Pal, 0xF0, 0x20); - structPtr->unk1814 = -80; + structPtr->monTransitionX = -80; return LT_INC_AND_PAUSE; case 4: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - LZ77UnCompVram(gUnknown_0862323C, structPtr->tilemapBuffers[2]); + LZ77UnCompVram(sConditionGraph_Tilemap, structPtr->tilemapBuffers[2]); SetBgTilemapBuffer(2, structPtr->tilemapBuffers[2]); CopyBgTilemapBufferToVram(2); CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, 0x30, 0x20); - sub_81D21DC(2); + SetConditionGraphIOWindows(2); return LT_INC_AND_PAUSE; case 5: sub_8199DF0(1, 0, 0, 1); @@ -249,85 +249,85 @@ u32 sub_81CDE94(s32 state) if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - structPtr->unk1820 = AddWindow(&gUnknown_08623364); - if (sub_81CDD5C() == TRUE) + structPtr->nameGenderWindowId = AddWindow(&sMonNameGenderWindowTemplate); + if (IsConditionMenuSearchMode() == TRUE) { - structPtr->unk1821 = AddWindow(&gUnknown_0862336C); - structPtr->unk1822 = AddWindow(&gUnknown_08623374); - structPtr->unk1823 = AddWindow(&gUnknown_0862337C); + structPtr->listIndexWindowId = AddWindow(&sConditionGraphListIdWindowTemplate); + structPtr->unusedWindowId1 = AddWindow(&sUnusedWindowTemplate1); + structPtr->unusedWindowId2 = AddWindow(&sUnusedWindowTemplate2); } DeactivateAllTextPrinters(); return LT_INC_AND_PAUSE; case 7: - sub_81CED30(0); + CreateConditionMonPic(0); return LT_INC_AND_PAUSE; case 8: - sub_81CE9E4(); + CreateMonMarkingsOrPokeballIndicators(); return LT_INC_AND_PAUSE; case 9: - if (sub_81CDD5C() == TRUE) - sub_81CE934(); + if (IsConditionMenuSearchMode() == TRUE) + CopyUnusedConditionWindowsToVram(); return LT_INC_AND_PAUSE; case 10: - sub_81CE754(0, sub_81CDC84(), TRUE); + UpdateConditionGraphWindows(0, GetMonMarkIndex(), TRUE); return LT_INC_AND_PAUSE; case 11: - sub_81CE754(1, sub_81CDC84(), TRUE); + UpdateConditionGraphWindows(1, GetMonMarkIndex(), TRUE); return LT_INC_AND_PAUSE; case 12: - sub_81CE754(2, sub_81CDC84(), TRUE); + UpdateConditionGraphWindows(2, GetMonMarkIndex(), TRUE); return LT_INC_AND_PAUSE; case 13: - if (sub_81CE754(3, sub_81CDC84(), TRUE) != TRUE) + if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), TRUE) != TRUE) return LT_PAUSE; - PutWindowTilemap(structPtr->unk1820); - if (sub_81CDD5C() == TRUE) + PutWindowTilemap(structPtr->nameGenderWindowId); + if (IsConditionMenuSearchMode() == TRUE) { - PutWindowTilemap(structPtr->unk1821); - PutWindowTilemap(structPtr->unk1822); - PutWindowTilemap(structPtr->unk1823); + PutWindowTilemap(structPtr->listIndexWindowId); + PutWindowTilemap(structPtr->unusedWindowId1); + PutWindowTilemap(structPtr->unusedWindowId2); } return LT_INC_AND_PAUSE; case 14: ShowBg(1); HideBg(2); ShowBg(3); - if (sub_81CDD5C() == TRUE) + if (IsConditionMenuSearchMode() == TRUE) PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS); return LT_INC_AND_PAUSE; case 15: PokenavFadeScreen(1); - if (!sub_81CDD5C()) + if (!IsConditionMenuSearchMode()) { - LoadLeftHeaderGfxForIndex(6); - sub_81C7FA0(1, TRUE, 0); - sub_81C7FA0(6, TRUE, 0); + LoadLeftHeaderGfxForIndex(POKENAV_GFX_PARTY_MENU); + ShowLeftHeaderGfx(POKENAV_GFX_CONDITION_MENU, TRUE, 0); + ShowLeftHeaderGfx(POKENAV_GFX_PARTY_MENU, TRUE, 0); } return LT_INC_AND_PAUSE; case 16: if (IsPaletteFadeActive()) return LT_PAUSE; - if (!sub_81CDD5C() && sub_81C8010()) + if (!IsConditionMenuSearchMode() && AreLeftHeaderSpritesMoving()) return LT_PAUSE; SetVBlankCallback_(sub_81CEE44); return LT_INC_AND_PAUSE; case 17: - sub_81CEE90(); - sub_81D20AC(sub_81CDC70()); + DoConditionGraphTransition(); + InitConditionGraphState(GetConditionGraphDataPtr()); return LT_INC_AND_PAUSE; case 18: - if (sub_81D20BC(sub_81CDC70())) + if (SetupConditionGraphScanlineParams(GetConditionGraphDataPtr())) return LT_PAUSE; return LT_INC_AND_PAUSE; case 19: - sub_81CEE74(TRUE); + ToggleBg2(TRUE); return LT_INC_AND_PAUSE; case 20: - if (!TryUpdateConditionMonTransitionOn(sub_81CDC70(), &structPtr->unk1814)) + if (!TryUpdateConditionMonTransitionOn(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) { - ResetConditionSparkleSprites(structPtr->unk28e0); - if (sub_81CDD5C() == TRUE || sub_81CDC60() != sub_81CDC50()) - CreateConditionSparkleSprites(structPtr->unk28e0, structPtr->unk1816, sub_81CDDB0()); + ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); + if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount()) + CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); return LT_FINISH; } @@ -337,211 +337,211 @@ u32 sub_81CDE94(s32 state) return LT_FINISH; } -u32 sub_81CE2D0(s32 state) +u32 LoopedTask_ExitPartyConditionMenu(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); switch (state) { case 0: sub_81CEEC8(); - DestroyConditionSparkleSprites(structPtr->unk28e0); - return 1; + DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); + return LT_INC_AND_CONTINUE; case 1: - if (TryUpdateConditionMonTransitionOff(sub_81CDC70(), &structPtr->unk1814)) + if (TryUpdateConditionMonTransitionOff(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) return 2; - sub_81CEE74(FALSE); - return 1; + ToggleBg2(FALSE); + return LT_INC_AND_CONTINUE; case 2: PokenavFadeScreen(0); - if (!sub_81CDD5C()) - sub_81C78A0(); - return 0; + if (!IsConditionMenuSearchMode()) + SlideMenuHeaderDown(); + return LT_INC_AND_PAUSE; case 3: if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy()) - return 2; - FreeConditionSparkles(structPtr->unk28e0); + return LT_PAUSE; + FreeConditionSparkles(structPtr->conditionSparkleSprites); HideBg(1); HideBg(2); HideBg(3); - return 1; + return LT_INC_AND_CONTINUE; } return LT_FINISH; } -u32 sub_81CE37C(s32 state) +u32 LoopedTask_TransitionMons(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); - struct ConditionGraph *unkPtr = sub_81CDC70(); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + struct ConditionGraph *unkPtr = GetConditionGraphDataPtr(); switch (state) { case 0: - sub_81CD548(0); - return 1; + SetConditionGraphData(0); + return LT_INC_AND_CONTINUE; case 1: - sub_81CD548(1); - return 1; + SetConditionGraphData(1); + return LT_INC_AND_CONTINUE; case 2: - sub_81CD548(2); - DestroyConditionSparkleSprites(structPtr->unk28e0); - return 1; + SetConditionGraphData(2); + DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); + return LT_INC_AND_CONTINUE; case 3: TransitionConditionGraph(unkPtr); - return 1; + return LT_INC_AND_CONTINUE; case 4: - if (!MoveConditionMonOffscreen(&structPtr->unk1814)) + if (!MoveConditionMonOffscreen(&structPtr->monTransitionX)) { - sub_81CED30(sub_81CDC84()); - return 1; + CreateConditionMonPic(GetMonMarkIndex()); + return LT_INC_AND_CONTINUE; } - return 2; + return LT_PAUSE; case 5: - sub_81CE754(0, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 6: - sub_81CE754(1, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 7: - sub_81CE754(2, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 8: - if (sub_81CE754(3, sub_81CDC84(), FALSE) == TRUE) - return 1; - return 2; + if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) + return LT_INC_AND_CONTINUE; + return LT_PAUSE; case 9: - unkPtr = sub_81CDC70(); - if (!TryUpdateConditionMonTransitionOn(unkPtr, &structPtr->unk1814)) + unkPtr = GetConditionGraphDataPtr(); + if (!TryUpdateConditionMonTransitionOn(unkPtr, &structPtr->monTransitionX)) { - ResetConditionSparkleSprites(structPtr->unk28e0); - if (sub_81CDD5C() != TRUE && sub_81CDC60() == sub_81CDC50()) - return 1; + ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); + if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount()) + return LT_INC_AND_CONTINUE; - CreateConditionSparkleSprites(structPtr->unk28e0, structPtr->unk1816, sub_81CDDB0()); - return 1; + CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); + return LT_INC_AND_CONTINUE; } - return 2; + return LT_PAUSE; } return LT_FINISH; } -u32 sub_81CE4D8(s32 state) +u32 LoopedTask_MoveCursorNoTransition(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); switch (state) { case 0: - sub_81CD548(0); - return 1; + SetConditionGraphData(0); + return LT_INC_AND_CONTINUE; case 1: - sub_81CD548(1); - return 1; + SetConditionGraphData(1); + return LT_INC_AND_CONTINUE; case 2: - sub_81CD548(2); - return 1; + SetConditionGraphData(2); + return LT_INC_AND_CONTINUE; case 3: - sub_81CED30(sub_81CDC84()); - return 1; + CreateConditionMonPic(GetMonMarkIndex()); + return LT_INC_AND_CONTINUE; case 4: - sub_81CE754(0, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 5: - sub_81CE754(1, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 6: - sub_81CE754(2, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 7: - if (sub_81CE754(3, sub_81CDC84(), FALSE) == TRUE) - return 1; - return 2; + if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) + return LT_INC_AND_CONTINUE; + return LT_PAUSE; case 8: - if (!TryUpdateConditionMonTransitionOn(sub_81CDC70(), &structPtr->unk1814)) + if (!TryUpdateConditionMonTransitionOn(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) { - ResetConditionSparkleSprites(structPtr->unk28e0); - CreateConditionSparkleSprites(structPtr->unk28e0, structPtr->unk1816, sub_81CDDB0()); - return 1; + ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); + CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); + return LT_INC_AND_CONTINUE; } - return 2; + return LT_PAUSE; } return LT_FINISH; } -u32 sub_81CE5E4(s32 state) +u32 LoopedTask_SlideMonOut(s32 state) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); switch (state) { case 0: - sub_81CD548(0); - return 1; + SetConditionGraphData(0); + return LT_INC_AND_CONTINUE; case 1: - sub_81CD548(1); - return 1; + SetConditionGraphData(1); + return LT_INC_AND_CONTINUE; case 2: - sub_81CD548(2); - DestroyConditionSparkleSprites(structPtr->unk28e0); - return 1; + SetConditionGraphData(2); + DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); + return LT_INC_AND_CONTINUE; case 3: - if (!TryUpdateConditionMonTransitionOff(sub_81CDC70(), &structPtr->unk1814)) - return 1; - return 2; + if (!TryUpdateConditionMonTransitionOff(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) + return LT_INC_AND_CONTINUE; + return LT_PAUSE; case 4: - sub_81CE754(0, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 5: - sub_81CE754(1, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 6: - sub_81CE754(2, sub_81CDC84(), FALSE); - return 1; + UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); + return LT_INC_AND_CONTINUE; case 7: - if (sub_81CE754(3, sub_81CDC84(), FALSE) == TRUE) - return 1; - return 2; + if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) + return LT_INC_AND_CONTINUE; + return LT_PAUSE; } return LT_FINISH; } -u32 sub_81CE6BC(s32 state) +u32 LoopedTask_OpenMonMarkingsWindow(s32 state) { switch (state) { case 0: - sub_811FAA4(sub_81CDD7C(), 176, 32); - return 1; + sub_811FAA4(TryGetMonMarkId(), 176, 32); + return LT_INC_AND_CONTINUE; case 1: PrintHelpBarText(HELPBAR_CONDITION_MARKINGS); - return 1; + return LT_INC_AND_CONTINUE; case 2: if (WaitForHelpBar() == TRUE) - return 2; - return 1; + return LT_PAUSE; + return LT_INC_AND_CONTINUE; } return LT_FINISH; } -u32 sub_81CE700(s32 state) +u32 LoopedTask_CloseMonMarkingsWindow(s32 state) { switch (state) { case 0: sub_811FAF8(); - return 1; + return LT_INC_AND_CONTINUE; case 1: PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS); - return 1; + return LT_INC_AND_CONTINUE; case 2: if (WaitForHelpBar() == TRUE) - return 2; - return 1; + return LT_PAUSE; + return LT_INC_AND_CONTINUE; } return LT_FINISH; @@ -555,68 +555,68 @@ static u8 *UnusedPrintNumberString(u8 *dst, u16 num) return txtPtr; } -bool32 sub_81CE754(u8 a0, u16 a1, bool8 a2) +bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) { u8 text[32]; const u8 *str; - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - switch (a0) + switch (mode) { case 0: - FillWindowPixelBuffer(structPtr->unk1820, 0); - if (sub_81CDD5C() == TRUE) - FillWindowPixelBuffer(structPtr->unk1821, 0); + FillWindowPixelBuffer(structPtr->nameGenderWindowId, 0); + if (IsConditionMenuSearchMode() == TRUE) + FillWindowPixelBuffer(structPtr->listIndexWindowId, 0); break; case 1: - if (sub_81CDC60() != sub_81CDC50() - 1 || sub_81CDD5C() == TRUE) + if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE) { - str = sub_81CDD04(a1); - AddTextPrinterParameterized(structPtr->unk1820, 1, str, 0, 1, 0, NULL); + str = GetConditionMonNameBuffer(bufferIndex); + AddTextPrinterParameterized(structPtr->nameGenderWindowId, 1, str, 0, 1, 0, NULL); } break; case 2: - if (sub_81CDD5C() == TRUE) + if (IsConditionMenuSearchMode() == TRUE) { - str = sub_81CDD24(a1); - AddTextPrinterParameterized(structPtr->unk1820, 1, str, 0, 17, 0, NULL); + str = GetConditionMonLocationBuffer(bufferIndex); + AddTextPrinterParameterized(structPtr->nameGenderWindowId, 1, str, 0, 17, 0, NULL); text[0] = EXT_CTRL_CODE_BEGIN; text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; text[2] = TEXT_COLOR_BLUE; text[3] = TEXT_COLOR_TRANSPARENT; text[4] = TEXT_COLOR_LIGHT_BLUE; StringCopy(text + 5, gText_Number2); - AddTextPrinterParameterized(structPtr->unk1821, 1, text, 4, 1, 0, NULL); - ConvertIntToDecimalStringN(text + 5, sub_81CDD48(), STR_CONV_MODE_RIGHT_ALIGN, 4); - AddTextPrinterParameterized(structPtr->unk1821, 1, text, 28, 1, 0, NULL); + AddTextPrinterParameterized(structPtr->listIndexWindowId, 1, text, 4, 1, 0, NULL); + ConvertIntToDecimalStringN(text + 5, GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4); + AddTextPrinterParameterized(structPtr->listIndexWindowId, 1, text, 28, 1, 0, NULL); } break; case 3: - switch (structPtr->unk2908) + switch (structPtr->windowModeState) { case 0: - if (a2) - CopyWindowToVram(structPtr->unk1820, 3); + if (winMode) + CopyWindowToVram(structPtr->nameGenderWindowId, 3); else - CopyWindowToVram(structPtr->unk1820, 2); + CopyWindowToVram(structPtr->nameGenderWindowId, 2); - if (sub_81CDD5C() == TRUE) + if (IsConditionMenuSearchMode() == TRUE) { - structPtr->unk2908++; + structPtr->windowModeState++; return FALSE; } else { - structPtr->unk2908 = 0; + structPtr->windowModeState = 0; return TRUE; } case 1: - if (a2) - CopyWindowToVram(structPtr->unk1821, 3); + if (winMode) + CopyWindowToVram(structPtr->listIndexWindowId, 3); else - CopyWindowToVram(structPtr->unk1821, 2); + CopyWindowToVram(structPtr->listIndexWindowId, 2); - structPtr->unk2908 = 0; + structPtr->windowModeState = 0; return TRUE; } } @@ -624,36 +624,36 @@ bool32 sub_81CE754(u8 a0, u16 a1, bool8 a2) return FALSE; } -void sub_81CE934(void) +void CopyUnusedConditionWindowsToVram(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - CopyWindowToVram(structPtr->unk1822, 3); - CopyWindowToVram(structPtr->unk1823, 3); + CopyWindowToVram(structPtr->unusedWindowId1, 3); + CopyWindowToVram(structPtr->unusedWindowId2, 3); } void sub_81CE964(struct Sprite *sprite) { - if (sprite->data[0] == sub_81CDC60()) + if (sprite->data[0] == GetConditionGraphCurrentMonIndex()) StartSpriteAnim(sprite, 0); else StartSpriteAnim(sprite, 1); } -void sub_81CE990(struct Sprite *sprite) +void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite) { - if (sub_81CDC60() == sub_81CDC50() - 1) + if (GetConditionGraphCurrentMonIndex() == GetMonListCount() - 1) sprite->oam.paletteNum = IndexOfSpritePaletteTag(0x65); else sprite->oam.paletteNum = IndexOfSpritePaletteTag(0x66); } -void sub_81CE9C8(struct Sprite *sprite) +void MonMarkingsCallback(struct Sprite *sprite) { - StartSpriteAnim(sprite, sub_81CDD7C()); + StartSpriteAnim(sprite, TryGetMonMarkId()); } -void sub_81CE9E4(void) +void CreateMonMarkingsOrPokeballIndicators(void) { struct SpriteSheet sprSheets[4]; struct SpriteTemplate sprTemplate; @@ -661,39 +661,40 @@ void sub_81CE9E4(void) struct SpriteSheet sprSheet; struct Sprite *sprite; u16 i, spriteId; - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals); - if (sub_81CDD5C() == TRUE) + if (IsConditionMenuSearchMode() == TRUE) { structPtr->monMarks.baseTileTag = 0x6A; structPtr->monMarks.basePaletteTag = 0x6A; sub_811F90C(&structPtr->monMarks); sub_811FA90(); - sprite = sub_811FF94(0x69, 0x69, gUnknown_08623338); + sprite = CreateMonMarkingsSpriteWithPal(0x69, 0x69, sConditionGraphMonMarkingsPal); sprite->oam.priority = 3; sprite->pos1.x = 192; sprite->pos1.y = 32; - sprite->callback = sub_81CE9C8; - structPtr->unk28dc = sprite; - sub_81C7990(IndexOfSpritePaletteTag(0x69), 0); + sprite->callback = MonMarkingsCallback; + structPtr->monMarksSprite = sprite; + PokenavFillPalette(IndexOfSpritePaletteTag(0x69), 0); } else { + // party mode -> add pokeballs on right hand side LoadSpriteSheets(sprSheets); Pokenav_AllocAndLoadPalettes(sprPals); - for (i = 0; i < sub_81CDC50() - 1; i++) + for (i = 0; i < GetMonListCount() - 1; i++) { spriteId = CreateSprite(&sprTemplate, 226, (i * 20) + 8, 0); if (spriteId != MAX_SPRITES) { - structPtr->unk1806[i] = spriteId; + structPtr->partyPokeballSpriteIds[i] = spriteId; gSprites[spriteId].data[0] = i; gSprites[spriteId].callback = sub_81CE964; } else { - structPtr->unk1806[i] = 0xFF; + structPtr->partyPokeballSpriteIds[i] = 0xFF; } } @@ -704,27 +705,27 @@ void sub_81CE9E4(void) spriteId = CreateSprite(&sprTemplate, 230, (i * 20) + 8, 0); if (spriteId != MAX_SPRITES) { - structPtr->unk1806[i] = spriteId; + structPtr->partyPokeballSpriteIds[i] = spriteId; gSprites[spriteId].oam.size = 0; } else { - structPtr->unk1806[i] = 0xFF; + structPtr->partyPokeballSpriteIds[i] = 0xFF; } } sprTemplate.tileTag = 0x66; - sprTemplate.callback = sub_81CE990; + sprTemplate.callback = HighlightCurrentPartyIndexPokeball; spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0); if (spriteId != MAX_SPRITES) { - structPtr->unk1806[i] = spriteId; + structPtr->partyPokeballSpriteIds[i] = spriteId; gSprites[spriteId].oam.shape = SPRITE_SHAPE(32x16); gSprites[spriteId].oam.size = SPRITE_SIZE(32x16); } else { - structPtr->unk1806[i] = 0xFF; + structPtr->partyPokeballSpriteIds[i] = 0xFF; } } @@ -738,9 +739,9 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr) { u8 i; - if (sub_81CDD5C() == TRUE) + if (IsConditionMenuSearchMode() == TRUE) { - DestroySprite(structPtr->unk28dc); + DestroySprite(structPtr->monMarksSprite); FreeSpriteTilesByTag(0x6A); FreeSpriteTilesByTag(0x69); FreeSpritePaletteByTag(0x6A); @@ -749,7 +750,7 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr) else { for (i = 0; i < 7; i++) - DestroySprite(&gSprites[structPtr->unk1806[i]]); + DestroySprite(&gSprites[structPtr->partyPokeballSpriteIds[i]]); FreeSpriteTilesByTag(0x65); FreeSpriteTilesByTag(0x66); @@ -758,83 +759,83 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr) FreeSpritePaletteByTag(0x66); } - if (structPtr->unk1816 != 0xFF) + if (structPtr->monPicSpriteId != 0xFF) { - DestroySprite(&gSprites[structPtr->unk1816]); + DestroySprite(&gSprites[structPtr->monPicSpriteId]); FreeSpriteTilesByTag(0x64); FreeSpritePaletteByTag(0x64); } } -void sub_81CECA0(void) +void FreePartyConditionSubstruct2(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - RemoveWindow(structPtr->unk1820); - if (sub_81CDD5C() == TRUE) + RemoveWindow(structPtr->nameGenderWindowId); + if (IsConditionMenuSearchMode() == TRUE) { - RemoveWindow(structPtr->unk1821); - RemoveWindow(structPtr->unk1822); - RemoveWindow(structPtr->unk1823); + RemoveWindow(structPtr->listIndexWindowId); + RemoveWindow(structPtr->unusedWindowId1); + RemoveWindow(structPtr->unusedWindowId2); } else { - sub_81C7FDC(); + SetLeftHeaderSpritesInvisibility(); } SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP); sub_81CEBF4(structPtr); sub_81CEE68(); - FreePokenavSubstruct(0xC); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU); } -void sub_81CED10(struct Sprite *sprite) +void MonPicGfxSpriteCallback(struct Sprite *sprite) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); - sprite->pos1.x = structPtr->unk1814 + 38; + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); + sprite->pos1.x = structPtr->monTransitionX + 38; } -void sub_81CED30(u8 var) +void CreateConditionMonPic(u8 id) { struct SpriteTemplate sprTemplate; struct SpriteSheet sprSheet; struct SpritePalette sprPal; u8 spriteId; - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - if (structPtr->unk1816 == 0xFF) + if (structPtr->monPicSpriteId == 0xFF) { LoadConditionMonPicTemplate(&sprSheet, &sprTemplate, &sprPal); - sprSheet.data = sub_81CDCB4(var); - sprPal.data = sub_81CDCD4(var); - structPtr->unk1818 = LoadSpritePalette(&sprPal); - structPtr->unk181A = LoadSpriteSheet(&sprSheet); + sprSheet.data = GetConditionMonPicGfx(id); + sprPal.data = GetConditionMonPal(id); + structPtr->monPalIndex = LoadSpritePalette(&sprPal); + structPtr->monGfxTileStart = LoadSpriteSheet(&sprSheet); spriteId = CreateSprite(&sprTemplate, 38, 104, 0); - structPtr->unk1816 = spriteId; + structPtr->monPicSpriteId = spriteId; if (spriteId == MAX_SPRITES) { FreeSpriteTilesByTag(0x64); FreeSpritePaletteByTag(0x64); - structPtr->unk1816 = 0xFF; + structPtr->monPicSpriteId = 0xFF; } else { - structPtr->unk1816 = spriteId; - gSprites[structPtr->unk1816].callback = sub_81CED10; - structPtr->unk181C = (void*)(VRAM) + 0x10000 + (structPtr->unk181A * 32); - structPtr->unk1818 = (structPtr->unk1818 * 16) + 0x100; + structPtr->monPicSpriteId = spriteId; + gSprites[structPtr->monPicSpriteId].callback = MonPicGfxSpriteCallback; + structPtr->unk181C = (void*)(VRAM) + 0x10000 + (structPtr->monGfxTileStart * 32); + structPtr->monPalIndex = (structPtr->monPalIndex * 16) + 0x100; } } else { - DmaCopy16Defvars(3, sub_81CDCB4(var), structPtr->unk181C, 0x800); - LoadPalette(sub_81CDCD4(var), structPtr->unk1818, 0x20); + DmaCopy16Defvars(3, GetConditionMonPicGfx(id), structPtr->unk181C, 0x800); + LoadPalette(GetConditionMonPal(id), structPtr->monPalIndex, 0x20); } } void sub_81CEE44(void) { - struct ConditionGraph *unk = sub_81CDC70(); + struct ConditionGraph *unk = GetConditionGraphDataPtr(); LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); @@ -847,7 +848,7 @@ void sub_81CEE68(void) SetPokenavVBlankCallback(); } -void sub_81CEE74(bool8 showBg) +void ToggleBg2(bool8 showBg) { if (showBg) ShowBg(2); @@ -855,29 +856,29 @@ void sub_81CEE74(bool8 showBg) HideBg(2); } -void sub_81CEE90(void) +void DoConditionGraphTransition(void) { - struct ConditionGraph *unk = sub_81CDC70(); - u8 id = sub_81CDC84(); + struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr(); + u8 id = GetMonMarkIndex(); gUnknown_030012BC = id; - sub_81D1F84(unk, unk->unk14[3], unk->unk14[id]); - TransitionConditionGraph(unk); + sub_81D1F84(conditionPtr, conditionPtr->unk14[3], conditionPtr->unk14[id]); + TransitionConditionGraph(conditionPtr); } void sub_81CEEC8(void) { - struct ConditionGraph *unk = sub_81CDC70(); + struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr(); - if (sub_81CDD5C() || sub_81CDC60() != sub_81CDC50() - 1) - sub_81D1F84(unk, unk->unk14[sub_81CDC84()], unk->unk14[3]); + if (IsConditionMenuSearchMode() || GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1) + sub_81D1F84(conditionPtr, conditionPtr->unk14[GetMonMarkIndex()], conditionPtr->unk14[3]); } -u8 sub_81CEF14(void) +u8 GetMonMarkingsData(void) { - struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC); + struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - if (sub_81CDD5C() == 1) + if (IsConditionMenuSearchMode() == 1) return structPtr->monMarks.markings; else return 0; diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index 15b687a42..c93544c52 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -10,67 +10,78 @@ #include "international_string_util.h" #include "constants/songs.h" +enum +{ + CONDITION_SEARCH_FUNC_NONE, + CONDITION_SEARCH_FUNC_MOVE_UP, + CONDITION_SEARCH_FUNC_MOVE_DOWN, + CONDITION_SEARCH_FUNC_PAGE_UP, + CONDITION_SEARCH_FUNC_PAGE_DOWN, + CONDITION_SEARCH_FUNC_EXIT, + CONDITION_SEARCH_FUNC_SELECT_MON, +}; + struct PokenavSub7 { - u32 (*unk0)(struct PokenavSub7 *); + u32 (*callback)(struct PokenavSub7 *); u32 loopedTaskId; u8 fill1[4]; - s32 unkC; - s32 unk10; - u32 unk14; + s32 boxId; + s32 monId; + u32 conditionDataId; u32 unk18; - u32 unk1C; - struct PokenavSub18 *unkPtr; + u32 isPartyCondition; + struct PokenavSub18 *monList; }; struct PokenavSub8 { bool32 (*callback)(void); - u32 ltid; + u32 ltid; //looped task Id u16 winid; - bool32 unkC; + bool32 fromGraph; u8 buff[BG_SCREEN_SIZE]; }; // size: 0x810 -static u32 sub_81CF010(struct PokenavSub7 *structPtr); -static u32 sub_81CF030(struct PokenavSub7 *structPtr); +static u32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr); +static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr); static u32 sub_81CF0B8(struct PokenavSub7 *structPtr); -static u32 sub_81CF0B0(struct PokenavSub7 *structPtr); -static u32 sub_81CF11C(s32 state); -static u32 sub_81CF134(s32 state); -static u32 sub_81CF1C4(s32 state); -static u32 sub_81CF1D8(s32 state); +static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr); +static u32 GetConditionSearchLoopedTask(s32 state); +static u32 BuildPartyMonSearchResults(s32 state); +static u32 InitBoxMonSearchResults(s32 state); +static u32 BuildBoxMonSearchResults(s32 state); static u32 sub_81CF278(s32 state); -static u32 sub_81CF578(s32 state); -static u32 sub_81CF5F0(s32 state); -static u32 sub_81CF668(s32 state); -static u32 sub_81CF6E0(s32 state); -static u32 sub_81CF758(s32 state); -static u32 sub_81CF798(s32 state); +static u32 LoopedTask_MoveSearchListCursorUp(s32 state); +static u32 LoopedTask_MoveSearchListCursorDown(s32 state); +static u32 LoopedTask_MoveSearchListPageUp(s32 state); +static u32 LoopedTask_MoveSearchListPageDown(s32 state); +static u32 LoopedTask_ExitConditionSearchMenu(s32 state); +static u32 LoopedTask_SelectSearchResult(s32 state); static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item); -static bool32 sub_81CF3E4(void); -static u32 sub_81CF418(s32 state); -static void sub_81CF7C8(struct PokenavSub8 *); -static void sub_81CF7F4(struct PokenavSub8 *); -static void sub_81CF88C(void); -static void sub_81CF8E4(struct PokenavMonList *, u8 *); +static bool32 GetSearchResultCurrentLoopedTaskActive(void); +static u32 LoopedTask_OpenConditionSearchResults(s32 state); +static void AddSearchResultListMenuWindow(struct PokenavSub8 *); +static void PrintSearchResultListMenuItems(struct PokenavSub8 *); +static void InitConditionSearchListMenuTemplate(void); +static void PrintSearchMonListItem(struct PokenavMonList *, u8 *); -static const u32 gUnknown_086233A0[] = {0x16, 0x17, 0x18, 0x21, 0x2F}; +static const u32 sSearchMonDataIds[] = {MON_DATA_COOL, MON_DATA_BEAUTY, MON_DATA_CUTE, MON_DATA_SMART, MON_DATA_TOUGH}; -static const LoopedTask gUnknown_086233B4[] = +static const LoopedTask sConditionSearchLoopedTaskFuncs[] = { - sub_81CF134, - sub_81CF1C4, - sub_81CF1D8, + BuildPartyMonSearchResults, + InitBoxMonSearchResults, + BuildBoxMonSearchResults, sub_81CF278 }; -static const u16 gUnknown_086233C4[] = INCBIN_U16("graphics/pokenav/condition_search2.gbapal"); -static const u32 gUnknown_086233E4[] = INCBIN_U32("graphics/pokenav/condition_search2.4bpp.lz"); -static const u32 gUnknown_086234AC[] = INCBIN_U32("graphics/pokenav/condition_search2.bin.lz"); +static const u16 sConditionSearchResultFramePal[] = INCBIN_U16("graphics/pokenav/condition_search2.gbapal"); +static const u32 sConditionSearchResultTiles[] = INCBIN_U32("graphics/pokenav/condition_search2.4bpp.lz"); +static const u32 sConditionSearchResultTilemap[] = INCBIN_U32("graphics/pokenav/condition_search2.bin.lz"); static const u16 gUnknown_08623570[] = INCBIN_U16("graphics/pokenav/8623570.gbapal"); -static const struct BgTemplate gUnknown_08623590[] = +static const struct BgTemplate sConditionSearchResultBgTemplates[] = { { .bg = 1, @@ -91,18 +102,18 @@ static const struct BgTemplate gUnknown_08623590[] = } }; -static const LoopedTask gUnknown_08623598[] = +static const LoopedTask sSearchResultLoopTaskFuncs[] = { - NULL, - sub_81CF578, - sub_81CF5F0, - sub_81CF668, - sub_81CF6E0, - sub_81CF758, - sub_81CF798 + [CONDITION_SEARCH_FUNC_NONE] = NULL, + [CONDITION_SEARCH_FUNC_MOVE_UP] = LoopedTask_MoveSearchListCursorUp, + [CONDITION_SEARCH_FUNC_MOVE_DOWN] = LoopedTask_MoveSearchListCursorDown, + [CONDITION_SEARCH_FUNC_PAGE_UP] = LoopedTask_MoveSearchListPageUp, + [CONDITION_SEARCH_FUNC_PAGE_DOWN] = LoopedTask_MoveSearchListPageDown, + [CONDITION_SEARCH_FUNC_EXIT] = LoopedTask_ExitConditionSearchMenu, + [CONDITION_SEARCH_FUNC_SELECT_MON] = LoopedTask_SelectSearchResult }; -static const struct WindowTemplate gUnknown_086235B4 = +static const struct WindowTemplate sSearchResultListMenuWindowTemplate = { .bg = 1, .tilemapLeft = 1, @@ -117,137 +128,138 @@ static const u8 sText_MaleSymbol[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHIT static const u8 sText_FemaleSymbol[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}"); -bool32 PokenavCallback_Init_8(void) +bool32 PokenavCallback_Init_ConditionSearch(void) { struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7)); if (structPtr == NULL) return FALSE; - structPtr->unkPtr = AllocSubstruct(18, sizeof(struct PokenavSub18)); - if (structPtr->unkPtr == NULL) + structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); + if (structPtr->monList == NULL) return FALSE; - structPtr->unk0 = sub_81CF010; - structPtr->loopedTaskId = CreateLoopedTask(sub_81CF11C, 1); + structPtr->callback = HandleConditionSearchInput_WaitSetup; + structPtr->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1); structPtr->unk18 = 0; - structPtr->unk14 = gUnknown_086233A0[GetSelectedConditionSearch()]; + structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; return TRUE; } -bool32 PokenavCallback_Init_10(void) +// return to search results from condition graph +bool32 PokenavCallback_Init_ReturnToMonSearchList(void) { - struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7)); + struct PokenavSub7 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct PokenavSub7)); if (structPtr == NULL) return FALSE; - structPtr->unkPtr = GetSubstructPtr(18); - structPtr->unk0 = sub_81CF030; + structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + structPtr->callback = HandleConditionSearchInput; structPtr->unk18 = 1; - structPtr->unk14 = gUnknown_086233A0[GetSelectedConditionSearch()]; + structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; return TRUE; } -u32 sub_81CEFDC(void) +u32 GetConditionSearchResultsCallback(void) { - struct PokenavSub7 *structPtr = GetSubstructPtr(7); - return structPtr->unk0(structPtr); + struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return structPtr->callback(structPtr); } -void sub_81CEFF0(void) +void FreeSearchResultSubstruct1(void) { - struct PokenavSub7 *structPtr = GetSubstructPtr(7); - if (structPtr->unk1C == 0) - FreePokenavSubstruct(18); - FreePokenavSubstruct(7); + struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + if (structPtr->isPartyCondition == 0) + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); } -static bool32 sub_81CF010(struct PokenavSub7 *structPtr) +static bool32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr) { if (!IsLoopedTaskActive(structPtr->loopedTaskId)) - structPtr->unk0 = sub_81CF030; + structPtr->callback = HandleConditionSearchInput; return FALSE; } -static u32 sub_81CF030(struct PokenavSub7 *structPtr) +static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr) { if (JOY_REPEAT(DPAD_UP)) - return 1; + return CONDITION_SEARCH_FUNC_MOVE_UP; if (JOY_REPEAT(DPAD_DOWN)) - return 2; + return CONDITION_SEARCH_FUNC_MOVE_DOWN; if (JOY_NEW(DPAD_LEFT)) - return 3; + return CONDITION_SEARCH_FUNC_PAGE_UP; if (JOY_NEW(DPAD_RIGHT)) - return 4; + return CONDITION_SEARCH_FUNC_PAGE_DOWN; if (JOY_NEW(B_BUTTON)) { - structPtr->unk1C = 0; - structPtr->unk0 = sub_81CF0B0; - return 5; + structPtr->isPartyCondition = 0; + structPtr->callback = ReturnToConditionSearchList; + return CONDITION_SEARCH_FUNC_EXIT; } if (JOY_NEW(A_BUTTON)) { - structPtr->unkPtr->unk2 = GetSelectedMatchCall(); - structPtr->unk1C = 1; - structPtr->unk0 = sub_81CF0B8; - return 6; + structPtr->monList->currIndex = GetSelectedPokenavListIndex(); + structPtr->isPartyCondition = 1; + structPtr->callback = sub_81CF0B8; + return CONDITION_SEARCH_FUNC_SELECT_MON; } - return 0; + return CONDITION_SEARCH_FUNC_NONE; } -static u32 sub_81CF0B0(struct PokenavSub7 *structPtr) +static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr) { return POKENAV_CONDITION_SEARCH_MENU; } static u32 sub_81CF0B8(struct PokenavSub7 *structPtr) { - return POKENAV_MENU_9; + return POKENAV_MENU_CONDITION_GRAPH_FROM_SEARCH; } static u32 sub_81CF0C0(void) { - struct PokenavSub7 *structPtr = GetSubstructPtr(7); + struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); return structPtr->unk18; } -static struct PokenavMonList * sub_81CF0D0(void) +static struct PokenavMonList * GetSearchResultsMonDataList(void) { - struct PokenavSub7 * ptr = GetSubstructPtr(7); - return ptr->unkPtr->unk4; + struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return ptr->monList->monData; } -static u16 sub_81CF0E0(void) +static u16 GetSearchResultsMonListCount(void) { - struct PokenavSub7 * ptr = GetSubstructPtr(7); - return ptr->unkPtr->unk0; + struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return ptr->monList->listCount; } -static s32 sub_81CF0F0(void) +static s32 GetSearchResultsSelectedMonData(void) { - struct PokenavSub7 * ptr = GetSubstructPtr(7); - s32 i = GetSelectedMatchCall(); - return ptr->unkPtr->unk4[i].data; + struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + s32 i = GetSelectedPokenavListIndex(); + return ptr->monList->monData[i].data; } static u16 sub_81CF10C(void) { - struct PokenavSub7 * ptr = GetSubstructPtr(7); - return ptr->unkPtr->unk2; + struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + return ptr->monList->currIndex; } -static u32 sub_81CF11C(s32 state) +static u32 GetConditionSearchLoopedTask(s32 state) { - return gUnknown_086233B4[state](state); + return sConditionSearchLoopedTaskFuncs[state](state); } -static u32 sub_81CF134(s32 state) +static u32 BuildPartyMonSearchResults(s32 state) { s32 i; struct PokenavMonList item; - struct PokenavSub7 * ptr = GetSubstructPtr(7); + struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - ptr->unkPtr->unk0 = 0; - ptr->unkPtr->unk2 = 0; + ptr->monList->listCount = 0; + ptr->monList->currIndex = 0; item.boxId = 14; for (i = 0; i < PARTY_SIZE; i++) { @@ -257,7 +269,7 @@ static u32 sub_81CF134(s32 state) if (!GetMonData(pokemon, MON_DATA_SANITY_IS_EGG)) { item.monId = i; - item.data = GetMonData(pokemon, ptr->unk14); + item.data = GetMonData(pokemon, ptr->conditionDataId); sub_81CF2C4(ptr, &item); } } @@ -265,19 +277,19 @@ static u32 sub_81CF134(s32 state) return LT_INC_AND_CONTINUE; } -static u32 sub_81CF1C4(s32 state) +static u32 InitBoxMonSearchResults(s32 state) { - struct PokenavSub7 * ptr = GetSubstructPtr(7); - ptr->unk10 = 0; - ptr->unkC = 0; + struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + ptr->monId = 0; + ptr->boxId = 0; return LT_INC_AND_CONTINUE; } -static u32 sub_81CF1D8(s32 state) +static u32 BuildBoxMonSearchResults(s32 state) { - struct PokenavSub7 * ptr = GetSubstructPtr(7); - s32 boxId = ptr->unkC; - s32 monId = ptr->unk10; + struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + s32 boxId = ptr->boxId; + s32 monId = ptr->monId; s32 boxCount = 0; struct PokenavMonList item; @@ -289,15 +301,15 @@ static u32 sub_81CF1D8(s32 state) { item.boxId = boxId; item.monId = monId; - item.data = GetBoxMonDataAt(boxId, monId, ptr->unk14); + item.data = GetBoxMonDataAt(boxId, monId, ptr->conditionDataId); sub_81CF2C4(ptr, &item); } boxCount++; monId++; if (boxCount > 14) { - ptr->unkC = boxId; - ptr->unk10 = monId; + ptr->boxId = boxId; + ptr->monId = monId; return LT_CONTINUE; } } @@ -310,21 +322,21 @@ static u32 sub_81CF1D8(s32 state) static u32 sub_81CF278(s32 state) { - struct PokenavSub7 * ptr = GetSubstructPtr(7); - s32 r6 = ptr->unkPtr->unk0; - s32 r4 = ptr->unkPtr->unk4[0].data; + struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); + s32 r6 = ptr->monList->listCount; + s32 r4 = ptr->monList->monData[0].data; s32 i; - ptr->unkPtr->unk4[0].data = 1; + ptr->monList->monData[0].data = 1; for (i = 1; i < r6; i++) { - if (ptr->unkPtr->unk4[i].data == r4) + if (ptr->monList->monData[i].data == r4) { - ptr->unkPtr->unk4[i].data = ptr->unkPtr->unk4[i - 1].data; + ptr->monList->monData[i].data = ptr->monList->monData[i - 1].data; } else { - r4 = ptr->unkPtr->unk4[i].data; - ptr->unkPtr->unk4[i].data = i + 1; + r4 = ptr->monList->monData[i].data; + ptr->monList->monData[i].data = i + 1; } } ptr->unk18 = 1; @@ -334,84 +346,84 @@ static u32 sub_81CF278(s32 state) static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item) { u32 left = 0; - u32 right = structPtr->unkPtr->unk0; + u32 right = structPtr->monList->listCount; u32 insertionIdx = left + (right - left) / 2; while (right != insertionIdx) { - if (item->data > structPtr->unkPtr->unk4[insertionIdx].data) + if (item->data > structPtr->monList->monData[insertionIdx].data) right = insertionIdx; else left = insertionIdx + 1; insertionIdx = left + (right - left) / 2; } - for (right = structPtr->unkPtr->unk0; right > insertionIdx; right--) - structPtr->unkPtr->unk4[right] = structPtr->unkPtr->unk4[right - 1]; - structPtr->unkPtr->unk4[insertionIdx] = *item; - structPtr->unkPtr->unk0++; + for (right = structPtr->monList->listCount; right > insertionIdx; right--) + structPtr->monList->monData[right] = structPtr->monList->monData[right - 1]; + structPtr->monList->monData[insertionIdx] = *item; + structPtr->monList->listCount++; } -bool32 sub_81CF330(void) +bool32 OpenConditionSearchResults(void) { - struct PokenavSub8 * unk = AllocSubstruct(8, sizeof(struct PokenavSub8)); - if (unk == NULL) + struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8)); + if (searchList == NULL) return FALSE; - unk->ltid = CreateLoopedTask(sub_81CF418, 1); - unk->callback = sub_81CF3E4; - unk->unkC = FALSE; + searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1); + searchList->callback = GetSearchResultCurrentLoopedTaskActive; + searchList->fromGraph = FALSE; return TRUE; } -bool32 sub_81CF368(void) +bool32 OpenConditionSearchListFromGraph(void) { - struct PokenavSub8 * unk = AllocSubstruct(8, sizeof(struct PokenavSub8)); - if (unk == NULL) + struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8)); + if (searchList == NULL) return FALSE; - unk->ltid = CreateLoopedTask(sub_81CF418, 1); - unk->callback = sub_81CF3E4; - unk->unkC = TRUE; + searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1); + searchList->callback = GetSearchResultCurrentLoopedTaskActive; + searchList->fromGraph = TRUE; return TRUE; } -void sub_81CF3A0(s32 idx) +void CreateSearchResultsLoopedTask(s32 idx) { - struct PokenavSub8 * unk = GetSubstructPtr(8); - unk->ltid = CreateLoopedTask(gUnknown_08623598[idx], 1); - unk->callback = sub_81CF3E4; + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + searchList->ltid = CreateLoopedTask(sSearchResultLoopTaskFuncs[idx], 1); + searchList->callback = GetSearchResultCurrentLoopedTaskActive; } -bool32 sub_81CF3D0(void) +bool32 IsSearchResultLoopedTaskActive(void) { - struct PokenavSub8 * unk = GetSubstructPtr(8); - return unk->callback(); + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + return searchList->callback(); } -bool32 sub_81CF3E4(void) +bool32 GetSearchResultCurrentLoopedTaskActive(void) { - struct PokenavSub8 * unk = GetSubstructPtr(8); - return IsLoopedTaskActive(unk->ltid); + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); + return IsLoopedTaskActive(searchList->ltid); } -void sub_81CF3F8(void) +void FreeSearchResultSubstruct2(void) { - struct PokenavSub8 * unk = GetSubstructPtr(8); + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); sub_81C8234(); - RemoveWindow(unk->winid); - FreePokenavSubstruct(8); + RemoveWindow(searchList->winid); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); } -static u32 sub_81CF418(s32 state) +static u32 LoopedTask_OpenConditionSearchResults(s32 state) { - struct PokenavSub8 * unk = GetSubstructPtr(8); + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); switch (state) { case 0: - InitBgTemplates(gUnknown_08623590, NELEMS(gUnknown_08623590)); - DecompressAndCopyTileDataToVram(1, gUnknown_086233E4, 0, 0, 0); - SetBgTilemapBuffer(1, unk->buff); - CopyToBgTilemapBuffer(1, gUnknown_086234AC, 0, 0); + InitBgTemplates(sConditionSearchResultBgTemplates, NELEMS(sConditionSearchResultBgTemplates)); + DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0); + SetBgTilemapBuffer(1, searchList->buff); + CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0); CopyBgTilemapBufferToVram(1); - CopyPaletteIntoBufferUnfaded(gUnknown_086233C4, 0x10, 0x20); + CopyPaletteIntoBufferUnfaded(sConditionSearchResultFramePal, 0x10, 0x20); CopyBgTilemapBufferToVram(1); return LT_INC_AND_PAUSE; case 1: @@ -423,13 +435,13 @@ static u32 sub_81CF418(s32 state) case 2: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 0x20); - sub_81CF88C(); + CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 32); + InitConditionSearchListMenuTemplate(); return LT_INC_AND_PAUSE; case 3: if (sub_81C8224()) return LT_PAUSE; - sub_81CF7C8(unk); + AddSearchResultListMenuWindow(searchList); PrintHelpBarText(HELPBAR_CONDITION_MON_LIST); return LT_INC_AND_PAUSE; case 4: @@ -440,28 +452,28 @@ static u32 sub_81CF418(s32 state) ShowBg(1); ShowBg(2); HideBg(3); - if (!unk->unkC) + if (!searchList->fromGraph) { - u8 r4 = GetSelectedConditionSearch() + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; - LoadLeftHeaderGfxForIndex(r4); - sub_81C7FA0(r4, 1, 0); - sub_81C7FA0(1, 1, 0); + u8 searchGfxId = GetSelectedConditionSearch() + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; + LoadLeftHeaderGfxForIndex(searchGfxId); + ShowLeftHeaderGfx(searchGfxId, 1, 0); + ShowLeftHeaderGfx(POKENAV_GFX_CONDITION_MENU, 1, 0); } PokenavFadeScreen(1); return LT_INC_AND_PAUSE; case 5: if (IsPaletteFadeActive()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; break; } return LT_FINISH; } -static u32 sub_81CF578(s32 state) +static u32 LoopedTask_MoveSearchListCursorUp(s32 state) { - struct PokenavSub8 * unk = GetSubstructPtr(8); + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); switch (state) { case 0: @@ -478,11 +490,11 @@ static u32 sub_81CF578(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; // fallthrough case 2: - sub_81CF7F4(unk); + PrintSearchResultListMenuItems(searchList); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -492,9 +504,9 @@ static u32 sub_81CF578(s32 state) return LT_FINISH; } -static u32 sub_81CF5F0(s32 state) +static u32 LoopedTask_MoveSearchListCursorDown(s32 state) { - struct PokenavSub8 * unk = GetSubstructPtr(8); + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); switch (state) { case 0: @@ -511,11 +523,11 @@ static u32 sub_81CF5F0(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; // fallthrough case 2: - sub_81CF7F4(unk); + PrintSearchResultListMenuItems(searchList); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -525,9 +537,9 @@ static u32 sub_81CF5F0(s32 state) return LT_FINISH; } -static u32 sub_81CF668(s32 state) +static u32 LoopedTask_MoveSearchListPageUp(s32 state) { - struct PokenavSub8 * unk = GetSubstructPtr(8); + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); switch (state) { case 0: @@ -544,11 +556,11 @@ static u32 sub_81CF668(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; // fallthrough case 2: - sub_81CF7F4(unk); + PrintSearchResultListMenuItems(searchList); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -558,9 +570,9 @@ static u32 sub_81CF668(s32 state) return LT_FINISH; } -static u32 sub_81CF6E0(s32 state) +static u32 LoopedTask_MoveSearchListPageDown(s32 state) { - struct PokenavSub8 * unk = GetSubstructPtr(8); + struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); switch (state) { case 0: @@ -577,11 +589,11 @@ static u32 sub_81CF6E0(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; // fallthrough case 2: - sub_81CF7F4(unk); + PrintSearchResultListMenuItems(searchList); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -591,27 +603,27 @@ static u32 sub_81CF6E0(s32 state) return LT_FINISH; } -static u32 sub_81CF758(s32 state) +static u32 LoopedTask_ExitConditionSearchMenu(s32 state) { switch (state) { case 0: PlaySE(SE_SELECT); PokenavFadeScreen(0); - sub_81C78A0(); + SlideMenuHeaderDown(); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) return LT_PAUSE; if (MainMenuLoopedTaskIsBusy()) return LT_PAUSE; - sub_81C7FDC(); + SetLeftHeaderSpritesInvisibility(); break; } return LT_FINISH; } -static u32 sub_81CF798(s32 state) +static u32 LoopedTask_SelectSearchResult(s32 state) { switch (state) { @@ -627,46 +639,47 @@ static u32 sub_81CF798(s32 state) return LT_FINISH; } -static void sub_81CF7C8(struct PokenavSub8 * ptr) +static void AddSearchResultListMenuWindow(struct PokenavSub8 *searchList) { - ptr->winid = AddWindow(&gUnknown_086235B4); - PutWindowTilemap(ptr->winid); - CopyWindowToVram(ptr->winid, 1); - sub_81CF7F4(ptr); + searchList->winid = AddWindow(&sSearchResultListMenuWindowTemplate); + PutWindowTilemap(searchList->winid); + CopyWindowToVram(searchList->winid, 1); + PrintSearchResultListMenuItems(searchList); } -static void sub_81CF7F4(struct PokenavSub8 * ptr) +static void PrintSearchResultListMenuItems(struct PokenavSub8 *searchList) { - s32 r7 = sub_81CF0F0(); + s32 r7 = GetSearchResultsSelectedMonData(); DynamicPlaceholderTextUtil_Reset(); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); *gStringVar1 = EOS; DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberF700); - AddTextPrinterParameterized(ptr->winid, 1, gStringVar2, 4, 1, 0xFF, NULL); + AddTextPrinterParameterized(searchList->winid, 1, gStringVar2, 4, 1, 0xFF, NULL); ConvertIntToDecimalStringN(gStringVar1, r7, STR_CONV_MODE_RIGHT_ALIGN, 3); - AddTextPrinterParameterized(ptr->winid, 1, gStringVar1, 34, 1, 0xFF, NULL); - CopyWindowToVram(ptr->winid, 2); + AddTextPrinterParameterized(searchList->winid, 1, gStringVar1, 34, 1, 0xFF, NULL); + CopyWindowToVram(searchList->winid, 2); } -static void sub_81CF88C(void) +static void InitConditionSearchListMenuTemplate(void) { struct PokenavListTemplate template; - template.list.monList = sub_81CF0D0(); - template.unk4 = sub_81CF0E0(); + + template.list.monList = GetSearchResultsMonDataList(); + template.count = GetSearchResultsMonListCount(); template.unk8 = 4; template.unk6 = sub_81CF10C(); - template.unk9 = 13; - template.unkA = 17; - template.unkB = 1; - template.unkC = 8; - template.unkD = 2; - template.unkE = 1; - template.listFunc.unk10_1 = sub_81CF8E4; + template.item_X = 13; + template.windowWidth = 17; + template.listTop = 1; + template.maxShowed = 8; + template.fillValue = 2; + template.fontId = 1; + template.listFunc.printMonFunc = PrintSearchMonListItem; template.unk14 = NULL; - sub_81C81D4(&gUnknown_08623590[1], &template, 0); + sub_81C81D4(&sConditionSearchResultBgTemplates[1], &template, 0); } -static void sub_81CF8E4(struct PokenavMonList * item, u8 * dest) +static void PrintSearchMonListItem(struct PokenavMonList * item, u8 * dest) { u8 gender; u8 level; diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index f2b9b0dcc..806300539 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -15,9 +15,9 @@ struct PokenavMainMenuResources { - void (*unk0)(u32); - u32 (*unk4)(void); - u32 unk8; + void (*loopTask)(u32); + u32 (*isLoopTaskActiveFunc)(void); + u32 unused; u32 currentTaskId; u32 helpBarWindowId; u32 palettes; @@ -47,8 +47,8 @@ static void SpriteCB_MoveLeftHeader(struct Sprite *sprite); static void InitPokenavMainMenuResources(void); static void InitHoennMapHeaderSprites(void); static void InitHelpBar(void); -static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0); -static u32 LoopedTask_ScrollMenuHeaderUp(s32 a0); +static u32 LoopedTask_SlideMenuHeaderUp(s32 a0); +static u32 LoopedTask_SlideMenuHeaderDown(s32 a0); static void DrawHelpBar(u32 windowId); static void SpriteCB_SpinningPokenav(struct Sprite* sprite); static u32 LoopedTask_InitPokenavMenu(s32 a0); @@ -294,7 +294,7 @@ bool32 InitPokenavMainMenu(void) { struct PokenavMainMenuResources *structPtr; - structPtr = AllocSubstruct(0, sizeof(struct PokenavMainMenuResources)); + structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct PokenavMainMenuResources)); if (structPtr == NULL) return FALSE; @@ -306,14 +306,14 @@ bool32 InitPokenavMainMenu(void) u32 PokenavMainMenuLoopedTaskIsActive(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); return IsLoopedTaskActive(structPtr->currentTaskId); } void ShutdownPokenav(void) { PlaySE(SE_POKENAV_OFF); - sub_81CAADC(); + ResetBldCnt_(); BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); } @@ -345,7 +345,7 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) ResetTempTileDataBuffers(); return LT_INC_AND_CONTINUE; case 1: - structPtr = GetSubstructPtr(0); + structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0); SetBgTilemapBuffer(0, structPtr->tilemapBuffer); CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0); @@ -371,46 +371,46 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0) } } -void sub_81C7834(void *func1, void *func2) // Fix types later. +void SetActiveMenuLoopTasks(void *createLoopTask, void *isLoopTaskActive) // Fix types later. { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); - structPtr->unk0 = func1; - structPtr->unk4 = func2; - structPtr->unk8 = 0; + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + structPtr->loopTask = createLoopTask; + structPtr->isLoopTaskActiveFunc = isLoopTaskActive; + structPtr->unused = 0; } -void sub_81C7850(u32 a0) +void RunMainMenuLoopedTask(u32 a0) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); - structPtr->unk8 = 0; - structPtr->unk0(a0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + structPtr->unused = 0; + structPtr->loopTask(a0); } -u32 sub_81C786C(void) +u32 IsActiveMenuLoopTaskActive(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); - return structPtr->unk4(); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + return structPtr->isLoopTaskActiveFunc(); } -void sub_81C7880(void) +void SlideMenuHeaderUp(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); - structPtr->currentTaskId = CreateLoopedTask(LoopedTask_ScrollMenuHeaderDown, 4); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4); } -void sub_81C78A0(void) +void SlideMenuHeaderDown(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); - structPtr->currentTaskId = CreateLoopedTask(LoopedTask_ScrollMenuHeaderUp, 4); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); + structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4); } bool32 MainMenuLoopedTaskIsBusy(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); return IsLoopedTaskActive(structPtr->currentTaskId); } -static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0) +static u32 LoopedTask_SlideMenuHeaderUp(s32 a0) { switch (a0) { @@ -431,7 +431,7 @@ static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0) } } -static u32 LoopedTask_ScrollMenuHeaderUp(s32 a0) +static u32 LoopedTask_SlideMenuHeaderDown(s32 a0) { if (ChangeBgY(0, 384, 2) <= 0) { @@ -465,35 +465,35 @@ void Pokenav_AllocAndLoadPalettes(const struct SpritePalette *palettes) } } -void sub_81C7990(u32 a0, u16 a1) +void PokenavFillPalette(u32 palIndex, u16 fillValue) { - CpuFill16(a1, gPlttBufferFaded + 0x100 + (a0 * 16), 16 * sizeof(u16)); + CpuFill16(fillValue, gPlttBufferFaded + 0x100 + (palIndex * 16), 16 * sizeof(u16)); } -void sub_81C79BC(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette) +void PokenavCopyPalette(const u16 *src, const u16 *dest, int size, int a3, int a4, u16 *palette) { if (a4 == 0) { - CpuCopy16(a0, palette, a2 * 2); + CpuCopy16(src, palette, size * 2); } else if (a4 >= a3) { - CpuCopy16(a1, palette, a2 * 2); + CpuCopy16(dest, palette, size * 2); } else { int r, g, b; int r1, g1, b1; - while (a2--) + while (size--) { - r = GET_R(*a0); - g = GET_G(*a0); - b = GET_B(*a0); + r = GET_R(*src); + g = GET_G(*src); + b = GET_B(*src); - r1 = ((((GET_R(*a1) << 8) - (r << 8)) / a3) * a4) >> 8; - g1 = ((((GET_G(*a1) << 8) - (g << 8)) / a3) * a4) >> 8; - b1 = ((((GET_B(*a1) << 8) - (b << 8)) / a3) * a4) >> 8; + r1 = ((((GET_R(*dest) << 8) - (r << 8)) / a3) * a4) >> 8; + g1 = ((((GET_G(*dest) << 8) - (g << 8)) / a3) * a4) >> 8; + b1 = ((((GET_B(*dest) << 8) - (b << 8)) / a3) * a4) >> 8; r = (r + r1) & 0x1F; //_RGB(r + r1, g + g1, b + b1); doesn't match; I have to assign the value of ((r + r1) & 0x1F) to r1 g = (g + g1) & 0x1F; //See above @@ -501,7 +501,7 @@ void sub_81C79BC(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *pale *palette = RGB2(r, g, b); //See above comment - a0++, a1++; + src++, dest++; palette++; } } @@ -509,7 +509,7 @@ void sub_81C79BC(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *pale void PokenavFadeScreen(s32 fadeType) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); switch (fadeType) { @@ -548,7 +548,7 @@ void InitBgTemplates(const struct BgTemplate *templates, int count) static void InitHelpBar(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); InitWindows(&sHelpBarWindowTemplate[0]); structPtr->helpBarWindowId = 0; @@ -559,7 +559,7 @@ static void InitHelpBar(void) void PrintHelpBarText(u32 textId) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); DrawHelpBar(structPtr->helpBarWindowId); AddTextPrinterParameterized3(structPtr->helpBarWindowId, 1, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]); @@ -580,7 +580,7 @@ static void InitPokenavMainMenuResources(void) { s32 i; u8 spriteId; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); for (i = 0; i < ARRAY_COUNT(gSpinningPokenavSpriteSheet); i++) LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]); @@ -593,7 +593,7 @@ static void InitPokenavMainMenuResources(void) static void CleanupPokenavMainMenuResources(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); DestroySprite(structPtr->spinningPokenav); FreeSpriteTilesByTag(0); @@ -608,7 +608,7 @@ static void SpriteCB_SpinningPokenav(struct Sprite *sprite) struct Sprite *PauseSpinningPokenavSprite(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); structPtr->spinningPokenav->callback = SpriteCallbackDummy; return structPtr->spinningPokenav; @@ -616,7 +616,7 @@ struct Sprite *PauseSpinningPokenavSprite(void) void ResumeSpinningPokenavSprite(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); structPtr->spinningPokenav->pos1.x = 220; structPtr->spinningPokenav->pos1.y = 12; @@ -629,7 +629,7 @@ void ResumeSpinningPokenavSprite(void) static void InitHoennMapHeaderSprites(void) { s32 i, spriteId; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet); AllocSpritePalette(1); @@ -658,9 +658,9 @@ void LoadLeftHeaderGfxForIndex(u32 menuGfxId) LoadLeftHeaderGfxForSubMenu(menuGfxId - POKENAV_GFX_SUBMENUS_START); } -void sub_81C7E14(u32 menuGfxId) +void UpdateRegionMapRightHeaderTiles(u32 menuGfxId) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT) structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32; @@ -676,7 +676,7 @@ static void LoadLeftHeaderGfxForMenu(u32 menuGfxId) if (menuGfxId >= POKENAV_GFX_SUBMENUS_START) return; - structPtr = GetSubstructPtr(0); + structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); tag = sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].tag; size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data); LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20); @@ -704,33 +704,33 @@ static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId) RequestDma3Copy(&gDecompressionBuffer[0x1000], (void *)VRAM + 0x10800 + (GetSpriteTileStartByTag(2) * 32), size, 1); } -void sub_81C7FA0(u32 menuGfxId, bool32 arg1, bool32 arg2) +void ShowLeftHeaderGfx(u32 menuGfxId, bool32 isMain, bool32 isOnRightSide) { - u32 var; + u32 tileTop; - if (!arg1) - var = 0x30; + if (!isMain) + tileTop = 0x30; else - var = 0x10; + tileTop = 0x10; if (menuGfxId < POKENAV_GFX_SUBMENUS_START) - ShowLeftHeaderSprites(var, arg2); + ShowLeftHeaderSprites(tileTop, isOnRightSide); else - ShowLeftHeaderSubmenuSprites(var, arg2); + ShowLeftHeaderSubmenuSprites(tileTop, isOnRightSide); } -void sub_81C7FC4(u32 arg0, bool32 arg1) +void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide) { - if (arg0 < 6) - HideLeftHeaderSprites(arg1); + if (id < POKENAV_GFX_PARTY_MENU) + HideLeftHeaderSprites(onRightSide); else - HideLeftHeaderSubmenuSprites(arg1); + HideLeftHeaderSubmenuSprites(onRightSide); } -void sub_81C7FDC(void) +void SetLeftHeaderSpritesInvisibility(void) { s32 i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) { @@ -739,9 +739,9 @@ void sub_81C7FDC(void) } } -bool32 sub_81C8010(void) +bool32 AreLeftHeaderSpritesMoving(void) { - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (structPtr->leftHeaderSprites[0]->callback == SpriteCallbackDummy && structPtr->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy) return FALSE; @@ -752,7 +752,7 @@ bool32 sub_81C8010(void) static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = -96, end = 32; @@ -769,7 +769,7 @@ static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = -96, end = 16; @@ -786,7 +786,7 @@ static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) static void HideLeftHeaderSprites(bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = 32, end = -96; @@ -802,7 +802,7 @@ static void HideLeftHeaderSprites(bool32 isOnRightSide) static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide) { s32 start, end, i; - struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); + struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); if (!isOnRightSide) start = 16, end = -96; diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index d919a4dbf..fb44aaa87 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -53,7 +53,7 @@ static const u8 sMatchCallOptionsHasCheckPage[] = bool32 PokenavCallback_Init_MatchCall(void) { - struct Pokenav3Struct *state = AllocSubstruct(5, sizeof(struct Pokenav3Struct)); + struct Pokenav3Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, sizeof(struct Pokenav3Struct)); if (!state) return FALSE; @@ -66,13 +66,13 @@ bool32 PokenavCallback_Init_MatchCall(void) u32 GetMatchCallCallback(void) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->callback(state); } void FreeMatchCallSubstruct1(void) { - FreePokenavSubstruct(5); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); } static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) @@ -92,7 +92,7 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) { state->callback = CB2_HandleMatchCallOptionsInput; state->optionCursorPos = 0; - selection = GetSelectedMatchCall(); + selection = GetSelectedPokenavListIndex(); if (!state->matchCallEntries[selection].isSpecialTrainer || MatchCall_HasCheckPage(state->matchCallEntries[selection].headerId)) { @@ -205,7 +205,7 @@ static u32 CB2_HandleCallInput(struct Pokenav3Struct *state) static u32 sub_81CAD20(s32 taskState) { int i, j; - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); switch (taskState) { case 0: @@ -239,7 +239,7 @@ static u32 sub_81CAD20(s32 taskState) { state->matchCallEntries[state->numRegistered].headerId = state->headerId; state->matchCallEntries[state->numRegistered].isSpecialTrainer = FALSE; - state->matchCallEntries[state->numRegistered].mapSec = sub_81CB0C8(j); + state->matchCallEntries[state->numRegistered].mapSec = GetMatchTableMapSectionId(j); state->numRegistered++; } @@ -266,31 +266,31 @@ bool32 IsRematchEntryRegistered(int rematchIndex) int sub_81CAE28(void) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->unk10; } int GetNumberRegistered(void) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->numRegistered; } int sub_81CAE48(void) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->unkC; } int unref_sub_81CAE58(void) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->numRegistered - state->unkC; } int unref_sub_81CAE6C(int arg0) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); arg0 += state->unkC; if (arg0 >= state->numRegistered) return REMATCH_TABLE_ENTRIES; @@ -300,19 +300,19 @@ int unref_sub_81CAE6C(int arg0) struct PokenavMatchCallEntries *sub_81CAE94(void) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->matchCallEntries; } u16 GetMatchCallMapSec(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->matchCallEntries[index].mapSec; } bool32 ShouldDrawRematchPokeballIcon(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (!state->matchCallEntries[index].isSpecialTrainer) index = state->matchCallEntries[index].headerId; else @@ -327,7 +327,7 @@ bool32 ShouldDrawRematchPokeballIcon(int index) int GetMatchCallTrainerPic(int index) { int headerId; - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (!state->matchCallEntries[index].isSpecialTrainer) { index = GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId); @@ -348,7 +348,7 @@ int GetMatchCallTrainerPic(int index) const u8 *GetMatchCallMessageText(int index, u8 *arg1) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); *arg1 = 0; if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType)) return gText_CallCantBeMadeHere; @@ -364,7 +364,7 @@ const u8 *GetMatchCallMessageText(int index, u8 *arg1) const u8 *GetMatchCallFlavorText(int index, int checkPageEntry) { int rematchId; - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (state->matchCallEntries[index].isSpecialTrainer) { rematchId = MatchCall_GetRematchTableIdx(state->matchCallEntries[index].headerId); @@ -381,13 +381,13 @@ const u8 *GetMatchCallFlavorText(int index, int checkPageEntry) u16 GetMatchCallOptionCursorPos(void) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); return state->optionCursorPos; } u16 GetMatchCallOptionId(int optionId) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); if (state->maxOptionId < optionId) return MATCH_CALL_OPTION_COUNT; @@ -422,7 +422,7 @@ void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries *matchCallEntry, } } -u8 sub_81CB0C8(int rematchIndex) +u8 GetMatchTableMapSectionId(int rematchIndex) { int mapGroup = gRematchTable[rematchIndex].mapGroup; int mapNum = gRematchTable[rematchIndex].mapNum; @@ -431,7 +431,7 @@ u8 sub_81CB0C8(int rematchIndex) int GetIndexDeltaOfNextCheckPageDown(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int count = 1; while (++index < state->numRegistered) { @@ -448,7 +448,7 @@ int GetIndexDeltaOfNextCheckPageDown(int index) int GetIndexDeltaOfNextCheckPageUp(int index) { - struct Pokenav3Struct *state = GetSubstructPtr(5); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); int count = -1; while (--index >= 0) { @@ -488,8 +488,8 @@ bool32 unref_sub_81CB16C(void) static bool32 sub_81CB1D0(void) { - struct Pokenav3Struct *state = GetSubstructPtr(5); - int selection = GetSelectedMatchCall(); + struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN); + int selection = GetSelectedPokenavListIndex(); if (!state->matchCallEntries[selection].isSpecialTrainer) { if (GetMatchCallMapSec(selection) == gMapHeader.regionMapSectionId) diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 337c75ce6..63426199c 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -36,7 +36,7 @@ struct Pokenav4Struct u16 msgBoxWindowId; s16 unk16; u8 unused18; - u8 unk19; + u8 unused19; u16 unk1A; struct Sprite *optionsCursorSprite; struct Sprite *trainerPicSprite; @@ -50,9 +50,9 @@ struct Pokenav4Struct static bool32 GetCurrentLoopedTaskActive(void); static u32 LoopedTask_OpenMatchCall(s32); -static void sub_81CBBB8(void); +static void InitMatchCallPokenavListMenuTemplate(void); static void sub_81CBC1C(void); -static void sub_81CC2B4(void); +static void RemoveMatchCallSprites(void); static void sub_81CC034(struct Pokenav4Struct *); static void DrawMatchCallLeftColumnWindows(struct Pokenav4Struct *); static void UpdateMatchCallInfoBox(struct Pokenav4Struct *); @@ -119,7 +119,7 @@ static const u16 gUnknown_08622700[] = INCBIN_U16("graphics/pokenav/8622700.gbap static const u16 gUnknown_08622720[] = INCBIN_U16("graphics/pokenav/pokeball_matchcall.gbapal"); static const u32 gUnknown_08622760[] = INCBIN_U32("graphics/pokenav/pokeball_matchcall.4bpp.lz"); -const struct BgTemplate gUnknown_0862278C[3] = +const struct BgTemplate sMatchCallBgTemplates[3] = { { .bg = 1, @@ -275,11 +275,11 @@ static const struct SpriteTemplate sTrainerPicSpriteTemplate = bool32 OpenMatchCall(void) { - struct Pokenav4Struct *state = AllocSubstruct(6, sizeof(struct Pokenav4Struct)); + struct Pokenav4Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN, sizeof(struct Pokenav4Struct)); if (!state) return FALSE; - state->unk19 = 0; + state->unused19 = 0; state->loopTaskId = CreateLoopedTask(LoopedTask_OpenMatchCall, 1); state->isTaskActiveCB = GetCurrentLoopedTaskActive; return TRUE; @@ -287,21 +287,21 @@ bool32 OpenMatchCall(void) void CreateMatchCallLoopedTask(s32 index) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); state->loopTaskId = CreateLoopedTask(sMatchCallLoopTaskFuncs[index], 1); state->isTaskActiveCB = GetCurrentLoopedTaskActive; } bool32 IsMatchCallLoopedTaskActive(void) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); return state->isTaskActiveCB(); } void FreeMatchCallSubstruct2(void) { - struct Pokenav4Struct *state = GetSubstructPtr(6); - sub_81CC2B4(); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); + RemoveMatchCallSprites(); sub_81CBC1C(); RemoveWindow(state->infoBoxWindowId); RemoveWindow(state->locWindowId); @@ -311,17 +311,17 @@ void FreeMatchCallSubstruct2(void) static bool32 GetCurrentLoopedTaskActive(void) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); return IsLoopedTaskActive(state->loopTaskId); } static u32 LoopedTask_OpenMatchCall(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: - InitBgTemplates(gUnknown_0862278C, ARRAY_COUNT(gUnknown_0862278C)); + InitBgTemplates(sMatchCallBgTemplates, ARRAY_COUNT(sMatchCallBgTemplates)); ChangeBgX(2, 0, 0); ChangeBgY(2, 0, 0); DecompressAndCopyTileDataToVram(2, sMatchCallUI_Gfx, 0, 0, 0); @@ -354,7 +354,7 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) if (FreeTempTileDataBuffersIfPossible() || !sub_81CAE28()) return LT_PAUSE; - sub_81CBBB8(); + InitMatchCallPokenavListMenuTemplate(); return LT_INC_AND_PAUSE; case 4: if (sub_81C8224()) @@ -374,11 +374,11 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) ShowBg(1); sub_81CC214(); LoadLeftHeaderGfxForIndex(3); - sub_81C7FA0(3, 1, 0); + ShowLeftHeaderGfx(POKENAV_GFX_MATCH_CALL_MENU, 1, 0); PokenavFadeScreen(1); return LT_INC_AND_PAUSE; case 7: - if (IsPaletteFadeActive() || sub_81C8010()) + if (IsPaletteFadeActive() || AreLeftHeaderSpritesMoving()) return LT_PAUSE; sub_81CBC38(1); @@ -390,7 +390,7 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) u32 MatchCallListCursorDown(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -409,7 +409,7 @@ u32 MatchCallListCursorDown(s32 taskState) } break; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; PrintMatchCallLocation(state, 0); @@ -427,7 +427,7 @@ u32 MatchCallListCursorDown(s32 taskState) u32 MatchCallListCursorUp(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -446,7 +446,7 @@ u32 MatchCallListCursorUp(s32 taskState) } break; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; PrintMatchCallLocation(state, 0); @@ -464,7 +464,7 @@ u32 MatchCallListCursorUp(s32 taskState) u32 MatchCallListPageDown(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -483,7 +483,7 @@ u32 MatchCallListPageDown(s32 taskState) } break; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; PrintMatchCallLocation(state, 0); @@ -501,7 +501,7 @@ u32 MatchCallListPageDown(s32 taskState) u32 MatchCallListPageUp(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -520,7 +520,7 @@ u32 MatchCallListPageUp(s32 taskState) } break; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; PrintMatchCallLocation(state, 0); @@ -538,7 +538,7 @@ u32 MatchCallListPageUp(s32 taskState) u32 SelectMatchCallEntry(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -561,7 +561,7 @@ u32 MoveMatchCallOptionsCursor(s32 taskState) u16 cursorPos; PlaySE(SE_SELECT); - state = GetSubstructPtr(6); + state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); cursorPos = GetMatchCallOptionCursorPos(); UpdateCursorGfxPos(state, cursorPos); return LT_FINISH; @@ -569,7 +569,7 @@ u32 MoveMatchCallOptionsCursor(s32 taskState) u32 CancelMatchCallSelection(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -588,7 +588,7 @@ u32 CancelMatchCallSelection(s32 taskState) u32 DoMatchCallMessage(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -620,7 +620,7 @@ u32 DoMatchCallMessage(s32 taskState) u32 DoTrainerCloseByMessage(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -646,7 +646,7 @@ u32 DoTrainerCloseByMessage(s32 taskState) u32 sub_81CB888(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); u32 result = LT_INC_AND_PAUSE; switch (taskState) @@ -710,7 +710,7 @@ u32 sub_81CB888(s32 taskState) u32 ShowCheckPage(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -719,7 +719,7 @@ u32 ShowCheckPage(s32 taskState) UpdateWindowsToShowCheckPage(state); return LT_INC_AND_PAUSE; case 1: - if (sub_81C8820() || IsDma3ManagerBusyWithBgCopy1(state)) + if (IsMatchCallListTaskActive() || IsDma3ManagerBusyWithBgCopy1(state)) return LT_PAUSE; PrintHelpBarText(HELPBAR_MC_CHECK_PAGE); @@ -729,7 +729,7 @@ u32 ShowCheckPage(s32 taskState) LoadCheckPageTrainerPic(state); return LT_INC_AND_PAUSE; case 3: - if (sub_81C8820() || WaitForTrainerPic(state) || WaitForHelpBar()) + if (IsMatchCallListTaskActive() || WaitForTrainerPic(state) || WaitForHelpBar()) return LT_PAUSE; break; } @@ -741,7 +741,7 @@ u32 ShowCheckPageDown(s32 taskState) { int topId; int delta; - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -768,7 +768,7 @@ u32 ShowCheckPageDown(s32 taskState) LoadCheckPageTrainerPic(state); return LT_INC_AND_PAUSE; case 4: - if (sub_81C8820() || WaitForTrainerPic(state)) + if (IsMatchCallListTaskActive() || WaitForTrainerPic(state)) return LT_PAUSE; break; } @@ -778,7 +778,7 @@ u32 ShowCheckPageDown(s32 taskState) u32 ExitCheckPage(s32 taskState) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -787,7 +787,7 @@ u32 ExitCheckPage(s32 taskState) sub_81C87F0(); return LT_INC_AND_PAUSE; case 1: - if (sub_81C8820() || WaitForTrainerPic(state)) + if (IsMatchCallListTaskActive() || WaitForTrainerPic(state)) return LT_PAUSE; PrintHelpBarText(HELPBAR_MC_TRAINER_LIST); @@ -806,7 +806,7 @@ u32 ShowCheckPageUp(s32 taskState) { int topId; int delta; - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); switch (taskState) { case 0: @@ -833,7 +833,7 @@ u32 ShowCheckPageUp(s32 taskState) LoadCheckPageTrainerPic(state); return LT_INC_AND_PAUSE; case 4: - if (sub_81C8820() || WaitForTrainerPic(state)) + if (IsMatchCallListTaskActive() || WaitForTrainerPic(state)) return LT_PAUSE; break; } @@ -849,35 +849,35 @@ u32 ExitMatchCall(s32 taskState) PlaySE(SE_SELECT); sub_81CBC38(0); PokenavFadeScreen(0); - sub_81C78A0(); + SlideMenuHeaderDown(); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy()) return LT_PAUSE; - sub_81C7FDC(); + SetLeftHeaderSpritesInvisibility(); break; } return LT_FINISH; } -static void sub_81CBBB8(void) +static void InitMatchCallPokenavListMenuTemplate(void) { struct PokenavListTemplate template; template.list.matchCallEntries = sub_81CAE94(); - template.unk4 = GetNumberRegistered(); + template.count = GetNumberRegistered(); template.unk8 = 4; template.unk6 = 0; - template.unk9 = 13; - template.unkA = 16; - template.unkB = 1; - template.unkC = 8; - template.unkD = 3; - template.unkE = 7; + template.item_X = 13; + template.windowWidth = 16; + template.listTop = 1; + template.maxShowed = 8; + template.fillValue = 3; + template.fontId = 7; template.listFunc.unk10_2 = BufferMatchCallNameAndDesc; template.unk14 = TryDrawRematchPokeballIcon; - sub_81C81D4(&gUnknown_0862278C[2], &template, 2); + sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2); CreateTask(sub_81CBC64, 7); } @@ -902,7 +902,7 @@ static void sub_81CBC64(u8 taskId) taskData[0] += 4; taskData[0] &= 0x7F; taskData[1] = gSineTable[taskData[0]] >> 4; - sub_81C79BC(gUnknown_08622720, gUnknown_08622720 + 0x10, 0x10, 0x10, taskData[1], gPlttBufferUnfaded + 0x50); + PokenavCopyPalette(gUnknown_08622720, gUnknown_08622720 + 0x10, 0x10, 0x10, taskData[1], gPlttBufferUnfaded + 0x50); if (!gPaletteFade.active) CpuCopy32(gPlttBufferUnfaded + 0x50, gPlttBufferFaded + 0x50, 0x20); } @@ -1000,7 +1000,7 @@ static void PrintMatchCallLocation(struct Pokenav4Struct *state, int arg1) { u8 mapName[32]; int x; - int index = GetSelectedMatchCall() + arg1; + int index = GetSelectedPokenavListIndex() + arg1; int mapSec = GetMatchCallMapSec(index); if (mapSec != MAPSEC_NONE) GetMapName(mapName, mapSec, 0); @@ -1117,7 +1117,7 @@ static bool32 WaitForTrainerIsCloseByText(struct Pokenav4Struct *state) static void PrintMatchCallMessage(struct Pokenav4Struct *state) { - int index = GetSelectedMatchCall(); + int index = GetSelectedPokenavListIndex(); const u8 *str = GetMatchCallMessageText(index, &state->unkF); u8 speed = GetPlayerTextSpeedDelay(); AddTextPrinterParameterized(state->msgBoxWindowId, 1, str, 32, 1, speed, NULL); @@ -1151,7 +1151,7 @@ static void sub_81CC214(void) int i; u8 paletteNum; struct SpriteSheet spriteSheet; - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); for (i = 0; i < ARRAY_COUNT(gUnknown_08622810); i++) LoadCompressedSpriteSheet(&gUnknown_08622810[i]); @@ -1168,9 +1168,9 @@ static void sub_81CC214(void) state->trainerPicSprite->invisible = TRUE; } -static void sub_81CC2B4(void) +static void RemoveMatchCallSprites(void) { - struct Pokenav4Struct *state = GetSubstructPtr(6); + struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN); if (state->optionsCursorSprite) DestroySprite(state->optionsCursorSprite); if (state->trainerPicSprite) @@ -1221,7 +1221,7 @@ static struct Sprite *CreateTrainerPicSprite(void) static void LoadCheckPageTrainerPic(struct Pokenav4Struct *state) { u16 cursor; - int trainerPic = GetMatchCallTrainerPic(GetSelectedMatchCall()); + int trainerPic = GetMatchCallTrainerPic(GetSelectedPokenavListIndex()); if (trainerPic >= 0) { DecompressPicFromTable(&gTrainerFrontPicTable[trainerPic], state->unk1828, SPECIES_NONE); diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 01740fcce..2d89f9c39 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -9,7 +9,7 @@ // TODO: This UI isnt just for match call, seems to be the general pokenav list UI -struct UnknownSubSubStruct_0203CF40 { +struct PokenavListMenuWindow { u8 bg; u8 unk1; u8 unk2; @@ -38,14 +38,14 @@ struct MatchCallWindowState { struct PokenavSub17Substruct { - struct UnknownSubSubStruct_0203CF40 unk0; + struct PokenavListMenuWindow listWindow; u32 unk10; u32 unk14; u32 unk18; void * unk1C; s32 unk20; s32 unk24; - u32 unk28; + u32 loopedTaskId; s32 unk2C; u32 unk30; void (*unk34)(struct PokenavMatchCallEntries *, u8*); @@ -59,34 +59,34 @@ struct PokenavSub17Substruct // Generally at index 0x11 (17) struct PokenavSub17 { - struct PokenavSub17Substruct unk0; + struct PokenavSub17Substruct list; u8 tilemapBuffer[0x800]; struct MatchCallWindowState unk888; s32 unk89C; - u32 unk8A0; + u32 loopedTaskId; }; extern void sub_81DB620(u32 windowId, u32 a1, u32 a2, u32 a3, u32 a4); -void sub_81C82E4(struct PokenavSub17 *a0); -bool32 sub_81C91AC(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3); -void sub_81C9160(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1); +void sub_81C82E4(struct PokenavSub17 *matchCall); +bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3); +void InitMatchCallWindowState(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1); void SpriteCB_MatchCallUpArrow(struct Sprite *sprite); void SpriteCB_MatchCallDownArrow(struct Sprite *sprite); void SpriteCB_MatchCallRightArrow(struct Sprite *sprite); void ToggleMatchCallArrows(struct PokenavSub17Substruct *a0, u32 a1); -void sub_81C8FE0(struct PokenavSub17Substruct *a0); -void sub_81C8EF8(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); +void DestroyMatchCallListArrows(struct PokenavSub17Substruct *a0); +void CreateMatchCallArrowSprites(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); void sub_81C8ED0(void); static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1, u32 a2); void PrintMatchCallFieldNames(struct PokenavSub17Substruct *a0, u32 a1); void sub_81C8D4C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); void sub_81C8CB4(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); -void sub_81C8B70(struct UnknownSubSubStruct_0203CF40 *a0, s32 a1, s32 a2); +void sub_81C8B70(struct PokenavListMenuWindow *a0, s32 a1, s32 a2); void sub_81C8568(s32 a0, struct PokenavSub17Substruct *a1); void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *a5); void sub_81C837C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); -void sub_81C835C(struct UnknownSubSubStruct_0203CF40 *a0); +void sub_81C835C(struct PokenavListMenuWindow *a0); u32 LoopedTask_sub_81C8254(s32 state); bool32 sub_81C83E0(void); u32 LoopedTask_sub_81C83F0(s32 state); @@ -102,12 +102,12 @@ EWRAM_DATA u32 gUnknown_0203CF44 = 0; bool32 sub_81C81D4(const struct BgTemplate *arg0, struct PokenavListTemplate *arg1, s32 arg2) { - struct PokenavSub17 *structPtr = AllocSubstruct(17, sizeof(struct PokenavSub17)); + struct PokenavSub17 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_LIST, sizeof(struct PokenavSub17)); if (structPtr == NULL) return FALSE; - sub_81C9160(&structPtr->unk888, arg1); - if (!sub_81C91AC(&structPtr->unk0, arg0, arg1, arg2)) + InitMatchCallWindowState(&structPtr->unk888, arg1); + if (!CopyPokenavListMenuTemplate(&structPtr->list, arg0, arg1, arg2)) return FALSE; CreateLoopedTask(LoopedTask_sub_81C8254, 6); @@ -123,10 +123,10 @@ void sub_81C8234(void) { struct PokenavSub17 *structPtr; - structPtr = GetSubstructPtr(17); - sub_81C8FE0(&structPtr->unk0); - RemoveWindow(structPtr->unk0.unk0.windowId); - FreePokenavSubstruct(17); + structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + DestroyMatchCallListArrows(&structPtr->list); + RemoveWindow(structPtr->list.listWindow.windowId); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); } u32 LoopedTask_sub_81C8254(s32 state) @@ -134,9 +134,9 @@ u32 LoopedTask_sub_81C8254(s32 state) struct PokenavSub17 *structPtr; if (IsDma3ManagerBusyWithBgCopy()) - return 2; + return LT_PAUSE; - structPtr = GetSubstructPtr(17); + structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); switch (state) { @@ -144,10 +144,10 @@ u32 LoopedTask_sub_81C8254(s32 state) sub_81C82E4(structPtr); return LT_INC_AND_PAUSE; case 1: - sub_81C835C(&structPtr->unk0.unk0); + sub_81C835C(&structPtr->list.listWindow); return LT_INC_AND_PAUSE; case 2: - sub_81C837C(&structPtr->unk888, &structPtr->unk0); + sub_81C837C(&structPtr->unk888, &structPtr->list); return LT_INC_AND_PAUSE; case 3: if (sub_81C83E0()) @@ -160,53 +160,53 @@ u32 LoopedTask_sub_81C8254(s32 state) return LT_INC_AND_CONTINUE; } case 4: - sub_81C8EF8(&structPtr->unk888, &structPtr->unk0); + CreateMatchCallArrowSprites(&structPtr->unk888, &structPtr->list); return LT_FINISH; default: return LT_FINISH; } } -void sub_81C82E4(struct PokenavSub17 *a0) +void sub_81C82E4(struct PokenavSub17 *matchCall) { - u16 tileNum = (a0->unk0.unk0.unk1 << 12) | a0->unk0.unk0.unk6; - sub_8199DF0(a0->unk0.unk0.bg, PIXEL_FILL(1), a0->unk0.unk0.unk6, 1); - sub_8199DF0(a0->unk0.unk0.bg, PIXEL_FILL(4), a0->unk0.unk0.unk6 + 1, 1); - SetBgTilemapBuffer(a0->unk0.unk0.bg, a0->tilemapBuffer); - FillBgTilemapBufferRect_Palette0(a0->unk0.unk0.bg, tileNum, 0, 0, 32, 32); - ChangeBgY(a0->unk0.unk0.bg, 0, 0); - ChangeBgX(a0->unk0.unk0.bg, 0, 0); - ChangeBgY(a0->unk0.unk0.bg, a0->unk0.unk0.unk3 << 11, 2); - CopyBgTilemapBufferToVram(a0->unk0.unk0.bg); + u16 tileNum = (matchCall->list.listWindow.unk1 << 12) | matchCall->list.listWindow.unk6; + sub_8199DF0(matchCall->list.listWindow.bg, PIXEL_FILL(1), matchCall->list.listWindow.unk6, 1); + sub_8199DF0(matchCall->list.listWindow.bg, PIXEL_FILL(4), matchCall->list.listWindow.unk6 + 1, 1); + SetBgTilemapBuffer(matchCall->list.listWindow.bg, matchCall->tilemapBuffer); + FillBgTilemapBufferRect_Palette0(matchCall->list.listWindow.bg, tileNum, 0, 0, 32, 32); + ChangeBgY(matchCall->list.listWindow.bg, 0, 0); + ChangeBgX(matchCall->list.listWindow.bg, 0, 0); + ChangeBgY(matchCall->list.listWindow.bg, matchCall->list.listWindow.unk3 << 11, 2); + CopyBgTilemapBufferToVram(matchCall->list.listWindow.bg); } -void sub_81C835C(struct UnknownSubSubStruct_0203CF40 *a0) +void sub_81C835C(struct PokenavListMenuWindow *listWindow) { - FillWindowPixelBuffer(a0->windowId, PIXEL_FILL(1)); - PutWindowTilemap(a0->windowId); - CopyWindowToVram(a0->windowId, 1); + FillWindowPixelBuffer(listWindow->windowId, PIXEL_FILL(1)); + PutWindowTilemap(listWindow->windowId); + CopyWindowToVram(listWindow->windowId, 1); } -void sub_81C837C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1) +void sub_81C837C(struct MatchCallWindowState *state, struct PokenavSub17Substruct *a1) { - s32 arg2 = a0->listLength - a0->windowTopIndex; - if (arg2 > a0->visibleEntries) - arg2 = a0->visibleEntries; + s32 arg2 = state->listLength - state->windowTopIndex; + if (arg2 > state->visibleEntries) + arg2 = state->visibleEntries; - sub_81C83AC(a0->unk10, a0->windowTopIndex, arg2, a0->unkC, 0, a1); + sub_81C83AC(state->unk10, state->windowTopIndex, arg2, state->unkC, 0, a1); } -void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *a5) +void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *list) { if (a2 == 0) return; - a5->unk1C = a0 + a1 * a3; - a5->unk18 = a3; - a5->unk0.unkC = 0; - a5->unk0.unkE = a2; - a5->unk14 = a1; - a5->unk10 = a4; + list->unk1C = a0 + a1 * a3; + list->unk18 = a3; + list->listWindow.unkC = 0; + list->listWindow.unkE = a2; + list->unk14 = a1; + list->unk10 = a4; CreateLoopedTask(LoopedTask_sub_81C83F0, 5); } @@ -218,23 +218,23 @@ bool32 sub_81C83E0(void) u32 LoopedTask_sub_81C83F0(s32 state) { u32 v1; - struct PokenavSub17Substruct *structPtr = GetSubstructPtr(17); + struct PokenavSub17Substruct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); switch (state) { case 0: - v1 = (structPtr->unk0.unkA + structPtr->unk0.unkC + structPtr->unk10) & 0xF; + v1 = (structPtr->listWindow.unkA + structPtr->listWindow.unkC + structPtr->unk10) & 0xF; structPtr->unk34(structPtr->unk1C, structPtr->unkTextBuffer); if (structPtr->unk38 != NULL) - structPtr->unk38(structPtr->unk0.windowId, structPtr->unk14, v1); + structPtr->unk38(structPtr->listWindow.windowId, structPtr->unk14, v1); - AddTextPrinterParameterized(structPtr->unk0.windowId, structPtr->unk0.fontId, structPtr->unkTextBuffer, 8, (v1 << 4) + 1, 255, NULL); - if (++structPtr->unk0.unkC >= structPtr->unk0.unkE) + AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->unkTextBuffer, 8, (v1 << 4) + 1, 255, NULL); + if (++structPtr->listWindow.unkC >= structPtr->listWindow.unkE) { if (structPtr->unk38 != NULL) - CopyWindowToVram(structPtr->unk0.windowId, 3); + CopyWindowToVram(structPtr->listWindow.windowId, 3); else - CopyWindowToVram(structPtr->unk0.windowId, 2); + CopyWindowToVram(structPtr->listWindow.windowId, 2); return LT_INC_AND_PAUSE; } else @@ -253,14 +253,14 @@ u32 LoopedTask_sub_81C83F0(s32 state) bool32 ShouldShowUpArrow(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); return (structPtr->unk888.windowTopIndex != 0); } bool32 ShouldShowDownArrow(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); struct MatchCallWindowState *subPtr = &structPtr->unk888; return (subPtr->windowTopIndex + subPtr->visibleEntries < subPtr->listLength); @@ -268,7 +268,7 @@ bool32 ShouldShowDownArrow(void) void MatchCall_MoveWindow(s32 a0, bool32 a1) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); struct MatchCallWindowState *subPtr = &structPtr->unk888; if (a0 < 0) @@ -276,7 +276,7 @@ void MatchCall_MoveWindow(s32 a0, bool32 a1) if (subPtr->windowTopIndex + a0 < 0) a0 = -1 * subPtr->windowTopIndex; if (a1) - sub_81C83AC(subPtr->unk10, subPtr->windowTopIndex + a0, a0 * -1, subPtr->unkC, a0, &structPtr->unk0); + sub_81C83AC(subPtr->unk10, subPtr->windowTopIndex + a0, a0 * -1, subPtr->unkC, a0, &structPtr->list); } else if (a1) { @@ -284,31 +284,31 @@ void MatchCall_MoveWindow(s32 a0, bool32 a1) if (temp + a0 >= subPtr->listLength) a0 = subPtr->listLength - temp; - sub_81C83AC(subPtr->unk10, gUnknown_0203CF44, a0, subPtr->unkC, subPtr->visibleEntries, &structPtr->unk0); + sub_81C83AC(subPtr->unk10, gUnknown_0203CF44, a0, subPtr->unkC, subPtr->visibleEntries, &structPtr->list); } - sub_81C8568(a0, &structPtr->unk0); + sub_81C8568(a0, &structPtr->list); subPtr->windowTopIndex += a0; } -void sub_81C8568(s32 a0, struct PokenavSub17Substruct *a1) +void sub_81C8568(s32 a0, struct PokenavSub17Substruct *list) { - a1->unk20 = GetBgY(a1->unk0.bg); - a1->unk24 = a1->unk20 + (a0 << 12); + list->unk20 = GetBgY(list->listWindow.bg); + list->unk24 = list->unk20 + (a0 << 12); if (a0 > 0) - a1->unk30 = 1; + list->unk30 = 1; else - a1->unk30 = 2; - a1->unk2C = a0; - a1->unk28 = CreateLoopedTask(LoopedTask_sub_81C85A0, 6); + list->unk30 = 2; + list->unk2C = a0; + list->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C85A0, 6); } u32 LoopedTask_sub_81C85A0(s32 state) { s32 y, v1; bool32 flag; - struct PokenavSub17 *structPtr = GetSubstructPtr(17); - struct PokenavSub17Substruct *subPtr = &structPtr->unk0; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + struct PokenavSub17Substruct *subPtr = &structPtr->list; switch (state) { @@ -318,8 +318,8 @@ u32 LoopedTask_sub_81C85A0(s32 state) return LT_PAUSE; case 1: flag = FALSE; - y = GetBgY(subPtr->unk0.bg); - v1 = ChangeBgY(subPtr->unk0.bg, 0x1000, subPtr->unk30); + y = GetBgY(subPtr->listWindow.bg); + v1 = ChangeBgY(subPtr->listWindow.bg, 0x1000, subPtr->unk30); if (subPtr->unk30 == 2) { if ((y > subPtr->unk24 || y <= subPtr->unk20) && v1 <= subPtr->unk24) @@ -333,8 +333,8 @@ u32 LoopedTask_sub_81C85A0(s32 state) if (flag) { - subPtr->unk0.unkA = (subPtr->unk0.unkA + subPtr->unk2C) & 0xF; - ChangeBgY(subPtr->unk0.bg, subPtr->unk24, 0); + subPtr->listWindow.unkA = (subPtr->listWindow.unkA + subPtr->unk2C) & 0xF; + ChangeBgY(subPtr->listWindow.bg, subPtr->unk24, 0); return LT_FINISH; } return LT_PAUSE; @@ -342,15 +342,15 @@ u32 LoopedTask_sub_81C85A0(s32 state) return LT_FINISH; } -bool32 sub_81C8630(void) +bool32 IsMonListLoopedTaskActive(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); - return IsLoopedTaskActive(structPtr->unk0.unk28); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + return IsLoopedTaskActive(structPtr->list.loopedTaskId); } struct MatchCallWindowState *GetMatchCallWindowStruct(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); return &structPtr->unk888; } @@ -448,7 +448,7 @@ int MatchCall_PageDown(void) } } -u32 GetSelectedMatchCall(void) +u32 GetSelectedPokenavListIndex(void) { struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct(); @@ -464,53 +464,53 @@ u32 GetMatchCallListTopIndex(void) void sub_81C877C(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); structPtr->unk89C = 0; - structPtr->unk8A0 = CreateLoopedTask(LoopedTask_sub_81C8870, 6); + structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8870, 6); } void PrintCheckPageInfo(s16 a0) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); structPtr->unk888.windowTopIndex += a0; structPtr->unk89C = 0; - structPtr->unk8A0 = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); + structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); } void sub_81C87F0(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); structPtr->unk89C = 0; - structPtr->unk8A0 = CreateLoopedTask(LoopedTask_sub_81C8A28, 6); + structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8A28, 6); } -bool32 sub_81C8820(void) +bool32 IsMatchCallListTaskActive(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); - return IsLoopedTaskActive(structPtr->unk8A0); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + return IsLoopedTaskActive(structPtr->loopedTaskId); } void sub_81C8838(void) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); struct MatchCallWindowState *subPtr = &structPtr->unk888; - structPtr->unk0.unk38(structPtr->unk0.unk0.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->unk0.unk0.unkA + subPtr->selectedIndexOffset) & 0xF); - CopyWindowToVram(structPtr->unk0.unk0.windowId, 1); + structPtr->list.unk38(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF); + CopyWindowToVram(structPtr->list.listWindow.windowId, 1); } // TODO: u32 LoopedTask_sub_81C8870(s32 state) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); switch (state) { case 0: - ToggleMatchCallArrows(&structPtr->unk0, 1); + ToggleMatchCallArrows(&structPtr->list, 1); // fall-through case 1: if (structPtr->unk89C != structPtr->unk888.selectedIndexOffset) - sub_81C8B70(&structPtr->unk0.unk0, structPtr->unk89C, 1); + sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, 1); structPtr->unk89C++; return LT_INC_AND_PAUSE; @@ -520,7 +520,7 @@ u32 LoopedTask_sub_81C8870(s32 state) if (structPtr->unk89C != structPtr->unk888.visibleEntries) return 6; if (structPtr->unk888.selectedIndexOffset != 0) - sub_81C8B70(&structPtr->unk0.unk0, structPtr->unk89C, structPtr->unk888.selectedIndexOffset); + sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, structPtr->unk888.selectedIndexOffset); return LT_INC_AND_PAUSE; } @@ -537,7 +537,7 @@ u32 LoopedTask_sub_81C8870(s32 state) } return LT_PAUSE; case 4: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; structPtr->unk888.selectedIndexOffset = 0; @@ -548,35 +548,35 @@ u32 LoopedTask_sub_81C8870(s32 state) u32 LoopedTask_PrintCheckPageInfo(s32 state) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; switch (state) { case 0: - sub_81C8CB4(&structPtr->unk888, &structPtr->unk0); + sub_81C8CB4(&structPtr->unk888, &structPtr->list); break; case 1: - PrintMatchCallFieldNames(&structPtr->unk0, 0); + PrintMatchCallFieldNames(&structPtr->list, 0); break; case 2: - PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->unk0, CHECK_PAGE_STRATEGY); + PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_STRATEGY); break; case 3: - PrintMatchCallFieldNames(&structPtr->unk0, 1); + PrintMatchCallFieldNames(&structPtr->list, 1); break; case 4: - PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->unk0, CHECK_PAGE_POKEMON); + PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_POKEMON); break; case 5: - PrintMatchCallFieldNames(&structPtr->unk0, 2); + PrintMatchCallFieldNames(&structPtr->list, 2); break; case 6: - PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->unk0, CHECK_PAGE_INTRO_1); + PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_INTRO_1); break; case 7: - PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->unk0, CHECK_PAGE_INTRO_2); + PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_INTRO_2); break; default: return LT_FINISH; @@ -594,9 +594,9 @@ u32 LoopedTask_sub_81C8A28(s32 state) if (IsDma3ManagerBusyWithBgCopy()) return LT_PAUSE; - structPtr = GetSubstructPtr(17); + structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); subPtr888 = &structPtr->unk888; - subPtr0 = &structPtr->unk0; + subPtr0 = &structPtr->list; switch (state) { @@ -607,7 +607,7 @@ u32 LoopedTask_sub_81C8A28(s32 state) ptr = &structPtr->unk89C; if (++(*ptr) < structPtr->unk888.visibleEntries) { - sub_81C8B70(&subPtr0->unk0, *ptr, 1); + sub_81C8B70(&subPtr0->listWindow, *ptr, 1); return LT_PAUSE; } @@ -618,7 +618,7 @@ u32 LoopedTask_sub_81C8A28(s32 state) { s32 r4 = subPtr888->windowTopIndex; r5 = -r4; - sub_81C8B70(&subPtr0->unk0, r5, r4); + sub_81C8B70(&subPtr0->listWindow, r5, r4); subPtr888->selectedIndexOffset = r4; *ptr = r5; return LT_INC_AND_PAUSE; @@ -630,7 +630,7 @@ u32 LoopedTask_sub_81C8A28(s32 state) { s32 r4 = subPtr888->windowTopIndex + subPtr888->visibleEntries - subPtr888->listLength; r5 = -r4; - sub_81C8B70(&subPtr0->unk0, r5, r4); + sub_81C8B70(&subPtr0->listWindow, r5, r4); subPtr888->selectedIndexOffset = r4; *ptr = r5; return LT_INC_AND_PAUSE; @@ -641,14 +641,14 @@ u32 LoopedTask_sub_81C8A28(s32 state) MatchCall_MoveWindow(structPtr->unk89C, FALSE); return LT_INC_AND_PAUSE; case 3: - if (!sub_81C8630()) + if (!IsMonListLoopedTaskActive()) { structPtr->unk89C = 0; return 1; } return 2; case 4: - sub_81C83AC(subPtr888->unk10, subPtr888->windowTopIndex + structPtr->unk89C, 1, subPtr888->unkC, structPtr->unk89C, &structPtr->unk0); + sub_81C83AC(subPtr888->unk10, subPtr888->windowTopIndex + structPtr->unk89C, 1, subPtr888->unkC, structPtr->unk89C, &structPtr->list); return LT_INC_AND_PAUSE; case 5: if (sub_81C83E0()) @@ -664,16 +664,16 @@ u32 LoopedTask_sub_81C8A28(s32 state) return LT_FINISH; } -void sub_81C8B70(struct UnknownSubSubStruct_0203CF40 *a0, s32 a1, s32 a2) +void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) { - u8 *v1 = (u8*)GetWindowAttribute(a0->windowId, WINDOW_TILE_DATA); - u32 v2 = a0->unk4 * 64; + u8 *v1 = (u8*)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA); + u32 v2 = listWindow->unk4 * 64; - a1 = (a0->unkA + a1) & 0xF; + a1 = (listWindow->unkA + a1) & 0xF; if (a1 + a2 <= 16) { CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, a2 * v2); - CopyWindowToVram(a0->windowId, 2); + CopyWindowToVram(listWindow->windowId, 2); } else { @@ -682,63 +682,63 @@ void sub_81C8B70(struct UnknownSubSubStruct_0203CF40 *a0, s32 a1, s32 a2) CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, v3 * v2); CpuFastFill8(PIXEL_FILL(1), v1, v4 * v2); - CopyWindowToVram(a0->windowId, 2); + CopyWindowToVram(listWindow->windowId, 2); } for (a2--; a2 != -1; a1 = (a1 + 1) & 0xF, a2--) - ClearRematchPokeballIcon(a0->windowId, a1); + ClearRematchPokeballIcon(listWindow->windowId, a1); - CopyWindowToVram(a0->windowId, 1); + CopyWindowToVram(listWindow->windowId, 1); } -void sub_81C8C64(struct UnknownSubSubStruct_0203CF40 *a0, u32 a1) +void sub_81C8C64(struct PokenavListMenuWindow *listWindow, u32 a1) { u16 var; - u16 *v1 = (u16*)GetBgTilemapBuffer(GetWindowAttribute(a0->windowId, WINDOW_BG)); - v1 += ((a0->unkA << 6) + a0->unk2) - 1; + u16 *v1 = (u16*)GetBgTilemapBuffer(GetWindowAttribute(listWindow->windowId, WINDOW_BG)); + v1 += ((listWindow->unkA << 6) + listWindow->unk2) - 1; if (a1 != 0) - var = (a0->unk1 << 12) | (a0->unk6 + 1); + var = (listWindow->unk1 << 12) | (listWindow->unk6 + 1); else - var = (a0->unk1 << 12) | (a0->unk6); + var = (listWindow->unk1 << 12) | (listWindow->unk6); v1[0] = var; v1[0x20] = var; } -void sub_81C8CB4(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1) +void sub_81C8CB4(struct MatchCallWindowState *state, struct PokenavSub17Substruct *list) { u8 colors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_RED}; - a1->unk34(a0->unk10 + a0->unkC * a0->windowTopIndex, a1->unkTextBuffer); - a1->unk38(a1->unk0.windowId, a0->windowTopIndex, a1->unk0.unkA); - FillWindowPixelRect(a1->unk0.windowId, PIXEL_FILL(4), 0, a1->unk0.unkA * 16, a1->unk0.unk4 * 8, 16); - AddTextPrinterParameterized3(a1->unk0.windowId, a1->unk0.fontId, 8, (a1->unk0.unkA * 16) + 1, colors, TEXT_SPEED_FF, a1->unkTextBuffer); - sub_81C8C64(&a1->unk0, 1); - CopyWindowRectToVram(a1->unk0.windowId, 3, 0, a1->unk0.unkA * 2, a1->unk0.unk4, 2); + list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer); + list->unk38(list->listWindow.windowId, state->windowTopIndex, list->listWindow.unkA); + FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(4), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16); + AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SPEED_FF, list->unkTextBuffer); + sub_81C8C64(&list->listWindow, 1); + CopyWindowRectToVram(list->listWindow.windowId, 3, 0, list->listWindow.unkA * 2, list->listWindow.unk4, 2); } -void sub_81C8D4C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1) +void sub_81C8D4C(struct MatchCallWindowState *state, struct PokenavSub17Substruct *list) { - a1->unk34(a0->unk10 + a0->unkC * a0->windowTopIndex, a1->unkTextBuffer); - FillWindowPixelRect(a1->unk0.windowId, PIXEL_FILL(1), 0, a1->unk0.unkA * 16, a1->unk0.unk4 * 8, 16); - AddTextPrinterParameterized(a1->unk0.windowId, a1->unk0.fontId, a1->unkTextBuffer, 8, a1->unk0.unkA * 16 + 1, TEXT_SPEED_FF, NULL); - sub_81C8C64(&a1->unk0, 0); - CopyWindowToVram(a1->unk0.windowId, 3); + list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer); + FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16); + AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->unkTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SPEED_FF, NULL); + sub_81C8C64(&list->listWindow, 0); + CopyWindowToVram(list->listWindow.windowId, 3); } -void PrintMatchCallFieldNames(struct PokenavSub17Substruct *a0, u32 fieldId) +void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fieldId) { const u8 *fieldNames[] = {gText_PokenavMatchCall_Strategy, gText_PokenavMatchCall_TrainerPokemon, gText_PokenavMatchCall_SelfIntroduction}; u8 colors[3] = {TEXT_COLOR_WHITE, TEXT_COLOR_RED, TEXT_COLOR_LIGHT_RED}; - u32 top = (a0->unk0.unkA + 1 + (fieldId * 2)) & 0xF; + u32 top = (list->listWindow.unkA + 1 + (fieldId * 2)) & 0xF; - FillWindowPixelRect(a0->unk0.windowId, PIXEL_FILL(1), 0, top << 4, a0->unk0.unk4, 16); - AddTextPrinterParameterized3(a0->unk0.windowId, 7, 2, (top << 4) + 1, colors, -1, fieldNames[fieldId]); - CopyWindowRectToVram(a0->unk0.windowId, 2, 0, top << 1, a0->unk0.unk4, 2); + FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, top << 4, list->listWindow.unk4, 16); + AddTextPrinterParameterized3(list->listWindow.windowId, 7, 2, (top << 4) + 1, colors, -1, fieldNames[fieldId]); + CopyWindowRectToVram(list->listWindow.windowId, 2, 0, top << 1, list->listWindow.unk4, 2); } -static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1, u32 checkPageEntry) +static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *list, u32 checkPageEntry) { // lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] = @@ -749,14 +749,14 @@ static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct Pok [CHECK_PAGE_INTRO_2] = 7 }; - u32 r6 = (a1->unk0.unkA + lineOffsets[checkPageEntry]) & 0xF; + u32 r6 = (list->listWindow.unkA + lineOffsets[checkPageEntry]) & 0xF; const u8 *str = GetMatchCallFlavorText(a0->windowTopIndex, checkPageEntry); if (str != NULL) { - sub_81DB620(a1->unk0.windowId, 1, r6 * 2, a1->unk0.unk4 - 1, 2); - AddTextPrinterParameterized(a1->unk0.windowId, 7, str, 2, (r6 << 4) + 1, TEXT_SPEED_FF, NULL); - CopyWindowRectToVram(a1->unk0.windowId, 2, 0, r6 * 2, a1->unk0.unk4, 2); + sub_81DB620(list->listWindow.windowId, 1, r6 * 2, list->listWindow.unk4 - 1, 2); + AddTextPrinterParameterized(list->listWindow.windowId, 7, str, 2, (r6 << 4) + 1, TEXT_SPEED_FF, NULL); + CopyWindowRectToVram(list->listWindow.windowId, 2, 0, r6 * 2, list->listWindow.unk4, 2); } } @@ -839,57 +839,57 @@ void sub_81C8ED0(void) Pokenav_AllocAndLoadPalettes(sMatchcallArrowPalettes); } -void sub_81C8EF8(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1) +void CreateMatchCallArrowSprites(struct MatchCallWindowState *windowState, struct PokenavSub17Substruct *list) { u32 spriteId; s16 x; - spriteId = CreateSprite(&sMatchCallRightArrowSprite, a1->unk0.unk2 * 8 + 3, (a1->unk0.unk3 + 1) * 8, 7); - a1->rightArrow = &gSprites[spriteId]; + spriteId = CreateSprite(&sMatchCallRightArrowSprite, list->listWindow.unk2 * 8 + 3, (list->listWindow.unk3 + 1) * 8, 7); + list->rightArrow = &gSprites[spriteId]; - x = a1->unk0.unk2 * 8 + (a1->unk0.unk4 - 1) * 4; - spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, a1->unk0.unk3 * 8 + a0->visibleEntries * 16, 7); - a1->downArrow = &gSprites[spriteId]; - a1->downArrow->oam.tileNum += 2; - a1->downArrow->callback = SpriteCB_MatchCallDownArrow; + x = list->listWindow.unk2 * 8 + (list->listWindow.unk4 - 1) * 4; + spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, list->listWindow.unk3 * 8 + windowState->visibleEntries * 16, 7); + list->downArrow = &gSprites[spriteId]; + list->downArrow->oam.tileNum += 2; + list->downArrow->callback = SpriteCB_MatchCallDownArrow; - spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, a1->unk0.unk3 * 8, 7); - a1->upArrow = &gSprites[spriteId]; - a1->upArrow->oam.tileNum += 4; - a1->upArrow->callback = SpriteCB_MatchCallUpArrow; + spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, list->listWindow.unk3 * 8, 7); + list->upArrow = &gSprites[spriteId]; + list->upArrow->oam.tileNum += 4; + list->upArrow->callback = SpriteCB_MatchCallUpArrow; } -void sub_81C8FE0(struct PokenavSub17Substruct *a0) +void DestroyMatchCallListArrows(struct PokenavSub17Substruct *list) { - DestroySprite(a0->rightArrow); - DestroySprite(a0->upArrow); - DestroySprite(a0->downArrow); + DestroySprite(list->rightArrow); + DestroySprite(list->upArrow); + DestroySprite(list->downArrow); FreeSpriteTilesByTag(0xA); FreeSpritePaletteByTag(0x14); } -void ToggleMatchCallArrows(struct PokenavSub17Substruct *a0, bool32 shouldHide) +void ToggleMatchCallArrows(struct PokenavSub17Substruct *list, bool32 shouldHide) { if (shouldHide) { - a0->rightArrow->callback = SpriteCallbackDummy; - a0->upArrow->callback = SpriteCallbackDummy; - a0->downArrow->callback = SpriteCallbackDummy; + list->rightArrow->callback = SpriteCallbackDummy; + list->upArrow->callback = SpriteCallbackDummy; + list->downArrow->callback = SpriteCallbackDummy; } else { - a0->rightArrow->callback = SpriteCB_MatchCallRightArrow; - a0->upArrow->callback = SpriteCB_MatchCallUpArrow; - a0->downArrow->callback = SpriteCB_MatchCallDownArrow; + list->rightArrow->callback = SpriteCB_MatchCallRightArrow; + list->upArrow->callback = SpriteCB_MatchCallUpArrow; + list->downArrow->callback = SpriteCB_MatchCallDownArrow; } - a0->rightArrow->invisible = shouldHide; - a0->upArrow->invisible = shouldHide; - a0->downArrow->invisible = shouldHide; + list->rightArrow->invisible = shouldHide; + list->upArrow->invisible = shouldHide; + list->downArrow->invisible = shouldHide; } void SpriteCB_MatchCallRightArrow(struct Sprite *sprite) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); sprite->pos2.y = structPtr->unk888.selectedIndexOffset << 4; } @@ -931,68 +931,68 @@ void SpriteCB_MatchCallUpArrow(struct Sprite *sprite) void ToggleMatchCallVerticalArrows(bool32 shouldHide) { - struct PokenavSub17 *structPtr = GetSubstructPtr(17); - structPtr->unk0.upArrow->data[7] = shouldHide; - structPtr->unk0.downArrow->data[7] = shouldHide; + struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); + structPtr->list.upArrow->data[7] = shouldHide; + structPtr->list.downArrow->data[7] = shouldHide; } -void sub_81C9160(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1) +void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavListTemplate *template) { - a0->unk10 = a1->list.matchCallEntries; - a0->windowTopIndex = a1->unk6; - a0->listLength = a1->unk4; - a0->unkC = a1->unk8; - a0->visibleEntries = a1->unkC; - if (a0->visibleEntries >= a0->listLength) + dst->unk10 = template->list.matchCallEntries; + dst->windowTopIndex = template->unk6; + dst->listLength = template->count; + dst->unkC = template->unk8; + dst->visibleEntries = template->maxShowed; + if (dst->visibleEntries >= dst->listLength) { - a0->windowTopIndex = 0; - a0->unk4 = 0; - a0->selectedIndexOffset = a1->unk6; + dst->windowTopIndex = 0; + dst->unk4 = 0; + dst->selectedIndexOffset = template->unk6; } else { - a0->unk4 = a0->listLength - a0->visibleEntries; - if (a0->windowTopIndex + a0->visibleEntries > a0->listLength) + dst->unk4 = dst->listLength - dst->visibleEntries; + if (dst->windowTopIndex + dst->visibleEntries > dst->listLength) { - a0->selectedIndexOffset = a0->windowTopIndex + a0->visibleEntries - a0->listLength; - a0->windowTopIndex = a1->unk6 - a0->selectedIndexOffset; + dst->selectedIndexOffset = dst->windowTopIndex + dst->visibleEntries - dst->listLength; + dst->windowTopIndex = template->unk6 - dst->selectedIndexOffset; } else { - a0->selectedIndexOffset = 0; + dst->selectedIndexOffset = 0; } } } -bool32 sub_81C91AC(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3) +bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 a3) { struct WindowTemplate window; - a0->unk0.bg = a1->bg; - a0->unk0.unk6 = a3; - a0->unk34 = a2->listFunc.unk10_2; - a0->unk38 = a2->unk14; - a0->unk0.unk1 = a2->unkD; - a0->unk0.unk2 = a2->unk9; - a0->unk0.unk3 = a2->unkB; - a0->unk0.unk4 = a2->unkA; - a0->unk0.fontId = a2->unkE; + dest->listWindow.bg = bgTemplate->bg; + dest->listWindow.unk6 = a3; + dest->unk34 = template->listFunc.unk10_2; + dest->unk38 = template->unk14; + dest->listWindow.unk1 = template->fillValue; + dest->listWindow.unk2 = template->item_X; + dest->listWindow.unk3 = template->listTop; + dest->listWindow.unk4 = template->windowWidth; + dest->listWindow.fontId = template->fontId; - window.bg = a1->bg; - window.tilemapLeft = a2->unk9; + window.bg = bgTemplate->bg; + window.tilemapLeft = template->item_X; window.tilemapTop = 0; - window.width = a2->unkA; + window.width = template->windowWidth; window.height = 32; - window.paletteNum = a2->unkD; + window.paletteNum = template->fillValue; window.baseBlock = a3 + 2; - a0->unk0.windowId = AddWindow(&window); - if (a0->unk0.windowId == 0xFF) + dest->listWindow.windowId = AddWindow(&window); + if (dest->listWindow.windowId == 0xFF) return FALSE; - a0->unk0.unkA = 0; - a0->rightArrow = NULL; - a0->upArrow = NULL; - a0->downArrow = NULL; + dest->listWindow.unkA = 0; + dest->rightArrow = NULL; + dest->upArrow = NULL; + dest->downArrow = NULL; return 1; } diff --git a/src/pokenav_menu_handler_1.c b/src/pokenav_menu_handler_1.c index 6002d731b..c8820ac38 100644 --- a/src/pokenav_menu_handler_1.c +++ b/src/pokenav_menu_handler_1.c @@ -99,12 +99,12 @@ static u8 GetPokenavMainMenuType(void) bool32 PokenavCallback_Init_MainMenuCursorOnMap(void) { - struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); + struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); if (!state) return FALSE; state->menuType = GetPokenavMainMenuType(); - state->cursorPos = 0; + state->cursorPos = POKENAV_MENUITEM_MAP; state->currMenuItem = POKENAV_MENUITEM_MAP; state->helpBarIndex = HELPBAR_NONE; SetMenuInputHandler(state); @@ -113,12 +113,12 @@ bool32 PokenavCallback_Init_MainMenuCursorOnMap(void) bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void) { - struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); + struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); if (!state) return FALSE; state->menuType = GetPokenavMainMenuType(); - state->cursorPos = 2; + state->cursorPos = POKENAV_MENUITEM_MATCH_CALL; state->currMenuItem = POKENAV_MENUITEM_MATCH_CALL; state->helpBarIndex = HELPBAR_NONE; SetMenuInputHandler(state); @@ -127,12 +127,12 @@ bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void) bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void) { - struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); + struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); if (!state) return FALSE; state->menuType = GetPokenavMainMenuType(); - state->cursorPos = 3; + state->cursorPos = POKENAV_MENUITEM_RIBBONS; state->currMenuItem = POKENAV_MENUITEM_RIBBONS; SetMenuInputHandler(state); return TRUE; @@ -140,12 +140,12 @@ bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void) bool32 PokenavCallback_Init_ConditionMenu(void) { - struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); + struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); if (!state) return FALSE; state->menuType = POKENAV_MENU_TYPE_CONDITION; - state->cursorPos = 0; + state->cursorPos = 0; //party state->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY; state->helpBarIndex = HELPBAR_NONE; SetMenuInputHandler(state); @@ -154,7 +154,7 @@ bool32 PokenavCallback_Init_ConditionMenu(void) bool32 PokenavCallback_Init_ConditionSearchMenu(void) { - struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); + struct Pokenav1Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, sizeof(struct Pokenav1Struct)); if (!state) return FALSE; @@ -202,13 +202,13 @@ static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*) u32 GetMenuHandlerCallback(void) { - struct Pokenav1Struct *state = GetSubstructPtr(1); + struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); return state->callback(state); } void FreeMenuHandlerSubstruct1(void) { - FreePokenavSubstruct(1); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); } static u32 HandleMainMenuInput(struct Pokenav1Struct *state) @@ -247,12 +247,12 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_NO_RIBBON_WINNERS; } case POKENAV_MENUITEM_SWITCH_OFF: - return -1; + return POKENAV_MENU_FUNC_EXIT; } } if (JOY_NEW(B_BUTTON)) - return -1; + return POKENAV_MENU_FUNC_EXIT; return POKENAV_MENU_FUNC_NONE; } @@ -488,26 +488,26 @@ static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state) int GetPokenavMenuType(void) { - struct Pokenav1Struct *state = GetSubstructPtr(1); + struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); return state->menuType; } // Position of cursor relative to number of current menu options int GetPokenavCursorPos(void) { - struct Pokenav1Struct *state = GetSubstructPtr(1); + struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); return state->cursorPos; } // ID of menu item the cursor is currently on int GetCurrentMenuItemId(void) { - struct Pokenav1Struct *state = GetSubstructPtr(1); + struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); return state->currMenuItem; } u16 GetHelpBarTextId(void) { - struct Pokenav1Struct *state = GetSubstructPtr(1); + struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER); return state->helpBarIndex; } diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index 2be92013f..0e819ecac 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -27,7 +27,7 @@ struct Pokenav2Struct bool8 otherIconsInMotion; bool8 pokenavAlreadyOpen; bool32 iconVisible[MAX_POKENAV_MENUITEMS]; - struct Sprite * field_028; + struct Sprite * blueLightSpriteId; struct Sprite * iconSprites[MAX_POKENAV_MENUITEMS][4]; u16 bg1TilemapBuffer[0x400]; }; @@ -43,54 +43,54 @@ static u32 LoopedTask_ReturnToConditionMenu(s32 state); static u32 LoopedTask_SelectRibbonsNoWinners(s32 state); static u32 LoopedTask_ReShowDescription(s32 state); static u32 LoopedTask_OpenPokenavFeature(s32 state); -static void sub_81C9FC4(void); -static void sub_81C9FEC(void); +static void LoadPokenavOptionPalettes(void); +static void FreeAndDestroyMainMenuSprites(void); static void CreateMenuOptionSprites(void); -static void sub_81CA094(void); +static void DestroyMenuOptionSprites(void); static void sub_81CA0C8(void); -static void sub_81CA0EC(const u16 *const * a0, s32 a1, s32 a2); -static void sub_81CA20C(void); -static void sub_81CA278(void); -static void sub_81CA35C(struct Sprite ** sprites, s32 a1, s32 a2, s32 a3); -static void sub_81CA3B4(struct Sprite ** sprites); -static void sub_81CA2DC(void); +static void DrawOptionLabelGfx(const u16 *const * a0, s32 yPos, s32 a2); +static void SetupCurrentMenuOptionsGfx(void); +static void SetMenuOptionGfxParams_CursorMoved(void); +static void SetMenuOptionGfxParamsInactive(struct Sprite ** sprites, s32 x, s32 a2, s32 a3); +static void SetMenuOptionGfxParamsActive(struct Sprite ** sprites); +static void SetupPokenavMenuOptions(void); static bool32 AreMenuOptionSpritesMoving(void); -static void sub_81CA448(struct Sprite ** sprites, bool32 a1); +static void SetMenuOptionGfxInvisibility(struct Sprite ** sprites, bool32 a1); static void sub_81CA474(struct Sprite * sprite); static void sub_81CA4AC(struct Sprite * sprite); static void sub_81CA580(u8 taskId); -static void sub_81CA640(void); -static void sub_81CA6AC(struct Sprite * sprite); -static void sub_81CA698(void); +static void CreateMatchCallBlueLightSprite(void); +static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite); +static void DestroyRematchBlueLightSpriteId(void); static void AddOptionDescriptionWindow(void); static void PrintCurrentOptionDescription(void); static void PrintNoRibbonWinners(void); -static bool32 sub_81CA7C4(void); -static void sub_81CA7D4(void); -static void sub_81CA7F4(void); -static void sub_81CA808(u8 taskId); -static void sub_81CA818(void); -static void sub_81CA850(void); -static void sub_81CA864(void); -static bool32 sub_81CA89C(void); -static void sub_81CA8B0(u8 taskId); -static void sub_81CA92C(void); -static void sub_81CA994(void); -static void sub_81CA9C8(void); -static void sub_81CA9D8(void); -static void sub_81CA9EC(u8 taskId); -static void sub_81CAA3C(void); +static bool32 IsDma3ManagerBusyWithBgCopy_(void); +static void CreateMovingBgDotsTask(void); +static void DestroyMovingDotsBgTask(void); +static void Task_MoveBgDots(u8 taskId); +static void CreateBgDotPurplePalTask(void); +static void ChangeBgDotsColorToPurple(void); +static void CreateBgDotLightBluePalTask(void); +static bool32 IsTaskActive_UpdateBgDotsPalette(void); +static void Task_UpdateBgDotsPalette(u8 taskId); +static void SetupPokenavMenuScanlineEffects(void); +static void DestroyMenuOptionGlowTask(void); +static void ResetBldCnt(void); +static void InitMenuOptionGlow(void); +static void Task_CurrentMenuOptionGlow(u8 taskId); +static void SetMenuOptionGlow(void); -static const u16 gUnknown_0861FC78[] = INCBIN_U16("graphics/pokenav/bg.gbapal"); -static const u32 gUnknown_0861FC98[] = INCBIN_U32("graphics/pokenav/bg.4bpp.lz"); -static const u32 gUnknown_0861FCAC[] = INCBIN_U32("graphics/pokenav/bg.bin.lz"); -static const u16 gUnknown_0861FD4C[] = INCBIN_U16("graphics/pokenav/outline.gbapal"); -static const u32 gUnknown_0861FD6C[] = INCBIN_U32("graphics/pokenav/outline.4bpp.lz"); -static const u32 gUnknown_0861FFF4[] = INCBIN_U32("graphics/pokenav/outline_map.bin.lz"); +static const u16 sPokenavBgDotsPal[] = INCBIN_U16("graphics/pokenav/bg.gbapal"); +static const u32 sPokenavBgDotsTiles[] = INCBIN_U32("graphics/pokenav/bg.4bpp.lz"); +static const u32 sPokenavBgDotsTilemap[] = INCBIN_U32("graphics/pokenav/bg.bin.lz"); +static const u16 sPokenavDeviceBgPal[] = INCBIN_U16("graphics/pokenav/outline.gbapal"); +static const u32 sPokenavDeviceBgTiles[] = INCBIN_U32("graphics/pokenav/outline.4bpp.lz"); +static const u32 sPokenavDeviceBgTilemap[] = INCBIN_U32("graphics/pokenav/outline_map.bin.lz"); static const u16 gUnknown_08620104[] = INCBIN_U16("graphics/pokenav/blue_light.gbapal"); static const u32 gUnknown_08620124[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz"); -static const struct BgTemplate gUnknown_08620194[] = { +static const struct BgTemplate sPokenavMainMenuBgTemplates[] = { { .bg = 1, .charBaseIndex = 1, @@ -130,7 +130,7 @@ static const LoopedTask sMenuHandlerLoopTaskFuncs[] = { [POKENAV_MENU_FUNC_OPEN_FEATURE] = LoopedTask_OpenPokenavFeature }; -static const struct CompressedSpriteSheet gUnknown_086201C4[] = +static const struct CompressedSpriteSheet sPokenavOptionsSpriteSheets[] = { { .data = gPokenavOptions_Gfx, @@ -144,7 +144,7 @@ static const struct CompressedSpriteSheet gUnknown_086201C4[] = } }; -static const struct SpritePalette gUnknown_086201D4[] = +static const struct SpritePalette sPokenavOptionsSpritePalettes[] = { {gPokenavOptions_Pal + 0x00, 4}, {gPokenavOptions_Pal + 0x10, 5}, @@ -155,59 +155,58 @@ static const struct SpritePalette gUnknown_086201D4[] = {} }; -static const u16 gUnknown_0862020C[] = {0, 0}; -static const u16 gUnknown_08620210[] = {0x20, 1}; -static const u16 gUnknown_08620214[] = {0x40, 4}; -static const u16 gUnknown_08620218[] = {0x60, 2}; -static const u16 gUnknown_0862021C[] = {0x80, 3}; -static const u16 gUnknown_08620220[] = {0xA0, 1}; -static const u16 gUnknown_08620224[] = {0xC0, 1}; -static const u16 gUnknown_08620228[] = {0xE0, 4}; -static const u16 gUnknown_0862022C[] = {0x100, 1}; -static const u16 gUnknown_08620230[] = {0x120, 2}; -static const u16 gUnknown_08620234[] = {0x140, 0}; -static const u16 gUnknown_08620238[] = {0x160, 0}; -static const u16 gUnknown_0862023C[] = {0x180, 3}; +static const u16 sOptionsLabelGfx_RegionMap[] = {0, 0}; +static const u16 sOptionsLabelGfx_Condition[] = {0x20, 1}; +static const u16 sOptionsLabelGfx_MatchCall[] = {0x40, 4}; +static const u16 sOptionsLabelGfx_Ribbons[] = {0x60, 2}; +static const u16 sOptionsLabelGfx_SwitchOff[] = {0x80, 3}; +static const u16 sOptionsLabelGfx_Party[] = {0xA0, 1}; +static const u16 sOptionsLabelGfx_Search[] = {0xC0, 1}; +static const u16 sOptionsLabelGfx_Cool[] = {0xE0, 4}; +static const u16 sOptionsLabelGfx_Beauty[] = {0x100, 1}; +static const u16 sOptionsLabelGfx_Cute[] = {0x120, 2}; +static const u16 sOptionsLabelGfx_Smart[] = {0x140, 0}; +static const u16 sOptionsLabelGfx_Tough[] = {0x160, 0}; +static const u16 sOptionsLabelGfx_Cancel[] = {0x180, 3}; -struct UnkStruct_08620240 +struct OptionsLabelGfx { - u16 unk0; - u16 unk2; - const u16 *unk4[MAX_POKENAV_MENUITEMS]; + u16 yStart; + u16 deltaY; + const u16 *tiles[MAX_POKENAV_MENUITEMS]; }; -// TODO -static const struct UnkStruct_08620240 gUnknown_08620240[POKENAV_MENU_TYPE_COUNT] = +static const struct OptionsLabelGfx sPokenavMenuOptionLabelGfx[POKENAV_MENU_TYPE_COUNT] = { [POKENAV_MENU_TYPE_DEFAULT] = { - 0x2A, - 0x14, - {gUnknown_0862020C, gUnknown_08620210, gUnknown_0862021C} + .yStart = 42, + .deltaY = 20, + {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_SwitchOff} }, [POKENAV_MENU_TYPE_UNLOCK_MC] = { - 0x2A, - 0x14, - {gUnknown_0862020C, gUnknown_08620210, gUnknown_08620214, gUnknown_0862021C} + .yStart = 42, + .deltaY = 20, + {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_MatchCall, sOptionsLabelGfx_SwitchOff} }, [POKENAV_MENU_TYPE_UNLOCK_MC_RIBBONS] = { - 0x2A, - 0x14, - {gUnknown_0862020C, gUnknown_08620210, gUnknown_08620214, gUnknown_08620218, gUnknown_0862021C} + .yStart = 42, + .deltaY = 20, + {sOptionsLabelGfx_RegionMap, sOptionsLabelGfx_Condition, sOptionsLabelGfx_MatchCall, sOptionsLabelGfx_Ribbons, sOptionsLabelGfx_SwitchOff} }, [POKENAV_MENU_TYPE_CONDITION] = { - 0x38, - 0x14, - {gUnknown_08620220, gUnknown_08620224, gUnknown_0862023C} + .yStart = 56, + .deltaY = 20, + {sOptionsLabelGfx_Party, sOptionsLabelGfx_Search, sOptionsLabelGfx_Cancel} }, [POKENAV_MENU_TYPE_CONDITION_SEARCH] = { - 0x28, - 0x10, - {gUnknown_08620228, gUnknown_0862022C, gUnknown_08620230, gUnknown_08620234, gUnknown_08620238, gUnknown_0862023C} + .yStart = 40, + .deltaY = 16, + {sOptionsLabelGfx_Cool, sOptionsLabelGfx_Beauty, sOptionsLabelGfx_Cute, sOptionsLabelGfx_Smart, sOptionsLabelGfx_Tough, sOptionsLabelGfx_Cancel} }, }; @@ -287,7 +286,7 @@ static const struct SpriteTemplate sMenuOptionSpriteTemplate = .callback = SpriteCallbackDummy, }; -static const struct OamData gUnknown_08620364 = +static const struct OamData sBlueLightOamData = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -301,18 +300,18 @@ static const struct OamData gUnknown_08620364 = .paletteNum = 0, }; -static const struct SpriteTemplate gUnknown_0862036C = +static const struct SpriteTemplate sMatchCallBlueLightSpriteTemplate = { .tileTag = 1, .paletteTag = 3, - .oam = &gUnknown_08620364, + .oam = &sBlueLightOamData, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy, }; -static const struct ScanlineEffectParams gUnknown_08620384 = +static const struct ScanlineEffectParams sPokenavMainMenuScanlineEffectParams = { (void *)REG_ADDR_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, @@ -320,13 +319,13 @@ static const struct ScanlineEffectParams gUnknown_08620384 = 0 }; -static bool32 sub_81C98D4(void) +static bool32 PlayerHasTrainerRematches(void) { s32 i; for (i = 0; i < REMATCH_TABLE_ENTRIES; i++) { - if (sub_81CB0C8(i) == gMapHeader.regionMapSectionId + if (GetMatchTableMapSectionId(i) == gMapHeader.regionMapSectionId && IsRematchEntryRegistered(i) && gSaveBlock1Ptr->trainerRematches[i]) return TRUE; @@ -373,43 +372,43 @@ static struct Pokenav2Struct * OpenPokenavMenu(void) void CreateMenuHandlerLoopedTask(s32 ltIdx) { - struct Pokenav2Struct * state = GetSubstructPtr(2); + struct Pokenav2Struct * state = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); state->loopedTaskId = CreateLoopedTask(sMenuHandlerLoopTaskFuncs[ltIdx], 1); state->isTaskActiveCB = GetCurrentLoopedTaskActive; } bool32 IsMenuHandlerLoopedTaskActive(void) { - struct Pokenav2Struct * state = GetSubstructPtr(2); + struct Pokenav2Struct * state = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); return state->isTaskActiveCB(); } void FreeMenuHandlerSubstruct2(void) { - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); - sub_81CA7F4(); + DestroyMovingDotsBgTask(); RemoveWindow(unk->optionDescWindowId); - sub_81C9FEC(); - sub_81CA994(); - FreePokenavSubstruct(2); + FreeAndDestroyMainMenuSprites(); + DestroyMenuOptionGlowTask(); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MENU_ICONS); } static bool32 GetCurrentLoopedTaskActive(void) { - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); return IsLoopedTaskActive(unk->loopedTaskId); } static u32 LoopedTask_OpenMenu(s32 state) { - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); switch (state) { case 0: - InitBgTemplates(gUnknown_08620194, ARRAY_COUNT(gUnknown_08620194)); + InitBgTemplates(sPokenavMainMenuBgTemplates, ARRAY_COUNT(sPokenavMainMenuBgTemplates)); DecompressAndCopyTileDataToVram(1, gPokenavMessageBox_Gfx, 0, 0, 0); SetBgTilemapBuffer(1, unk->bg1TilemapBuffer); CopyToBgTilemapBuffer(1, gPokenavMessageBox_Tilemap, 0, 0); @@ -425,36 +424,36 @@ static u32 LoopedTask_OpenMenu(s32 state) case 1: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - DecompressAndCopyTileDataToVram(2, gUnknown_0861FD6C, 0, 0, 0); - DecompressAndCopyTileDataToVram(2, gUnknown_0861FFF4, 0, 0, 1); - CopyPaletteIntoBufferUnfaded(gUnknown_0861FD4C, 0x20, 0x20); + DecompressAndCopyTileDataToVram(2, sPokenavDeviceBgTiles, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, sPokenavDeviceBgTilemap, 0, 0, 1); + CopyPaletteIntoBufferUnfaded(sPokenavDeviceBgPal, 0x20, 0x20); return LT_INC_AND_PAUSE; case 2: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - DecompressAndCopyTileDataToVram(3, gUnknown_0861FC98, 0, 0, 0); - DecompressAndCopyTileDataToVram(3, gUnknown_0861FCAC, 0, 0, 1); - CopyPaletteIntoBufferUnfaded(gUnknown_0861FC78, 0x30, 0x20); + DecompressAndCopyTileDataToVram(3, sPokenavBgDotsTiles, 0, 0, 0); + DecompressAndCopyTileDataToVram(3, sPokenavBgDotsTilemap, 0, 0, 1); + CopyPaletteIntoBufferUnfaded(sPokenavBgDotsPal, 0x30, 0x20); if (GetPokenavMenuType() == POKENAV_MENU_TYPE_CONDITION || GetPokenavMenuType() == POKENAV_MENU_TYPE_CONDITION_SEARCH) - sub_81CA850(); + ChangeBgDotsColorToPurple(); return LT_INC_AND_PAUSE; case 3: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; AddOptionDescriptionWindow(); - sub_81CA7D4(); + CreateMovingBgDotsTask(); return LT_INC_AND_CONTINUE; case 4: - sub_81C9FC4(); + LoadPokenavOptionPalettes(); return LT_INC_AND_CONTINUE; case 5: PrintCurrentOptionDescription(); CreateMenuOptionSprites(); - sub_81CA640(); + CreateMatchCallBlueLightSprite(); sub_81CA0C8(); return LT_INC_AND_PAUSE; case 6: - if (sub_81CA7C4()) + if (IsDma3ManagerBusyWithBgCopy_()) return LT_PAUSE; return LT_INC_AND_CONTINUE; case 7: @@ -487,22 +486,22 @@ static u32 LoopedTask_OpenMenu(s32 state) switch (GetPokenavMenuType()) { case POKENAV_MENU_TYPE_CONDITION_SEARCH: - sub_81C7FA0(7, FALSE, FALSE); + ShowLeftHeaderGfx(7, FALSE, FALSE); // fallthrough case POKENAV_MENU_TYPE_CONDITION: - sub_81C7FA0(1, FALSE, FALSE); + ShowLeftHeaderGfx(1, FALSE, FALSE); break; default: - sub_81C7FA0(0, FALSE, FALSE); + ShowLeftHeaderGfx(0, FALSE, FALSE); break; } - sub_81CA20C(); - sub_81CA92C(); + SetupCurrentMenuOptionsGfx(); + SetupPokenavMenuScanlineEffects(); return LT_INC_AND_CONTINUE; case 9: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; break; } @@ -514,15 +513,15 @@ static u32 LoopedTask_MoveMenuCursor(s32 state) switch (state) { case 0: - sub_81CAA3C(); - sub_81CA278(); + SetMenuOptionGlow(); + SetMenuOptionGfxParams_CursorMoved(); PrintCurrentOptionDescription(); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; case 1: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81CA7C4()) + if (IsDma3ManagerBusyWithBgCopy_()) return LT_PAUSE; break; } @@ -534,35 +533,35 @@ static u32 LoopedTask_OpenConditionMenu(s32 state) switch (state) { case 0: - sub_81CA9C8(); - sub_81CA2DC(); - sub_81C7FC4(0, 0); + ResetBldCnt(); + SetupPokenavMenuOptions(); + HideMainOrSubMenuLeftHeader(POKENAV_GFX_MAIN_MENU, 0); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; case 1: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; sub_81CA0C8(); LoadLeftHeaderGfxForIndex(1); return LT_INC_AND_PAUSE; case 2: - sub_81CA20C(); - sub_81C7FA0(1, FALSE, FALSE); - sub_81CA818(); + SetupCurrentMenuOptionsGfx(); + ShowLeftHeaderGfx(1, FALSE, FALSE); + CreateBgDotPurplePalTask(); PrintCurrentOptionDescription(); return LT_INC_AND_PAUSE; case 3: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - if (sub_81CA89C()) + if (IsTaskActive_UpdateBgDotsPalette()) return LT_PAUSE; - if (sub_81CA7C4()) + if (IsDma3ManagerBusyWithBgCopy_()) return LT_PAUSE; - sub_81CA9D8(); + InitMenuOptionGlow(); break; } return LT_FINISH; @@ -573,34 +572,34 @@ static u32 LoopedTask_ReturnToMainMenu(s32 state) switch (state) { case 0: - sub_81CA9C8(); - sub_81CA2DC(); - sub_81C7FC4(1, 0); + ResetBldCnt(); + SetupPokenavMenuOptions(); + HideMainOrSubMenuLeftHeader(POKENAV_GFX_CONDITION_MENU, 0); return LT_INC_AND_PAUSE; case 1: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; sub_81CA0C8(); LoadLeftHeaderGfxForIndex(0); return LT_INC_AND_PAUSE; case 2: - sub_81CA20C(); - sub_81C7FA0(0, FALSE, FALSE); - sub_81CA864(); + SetupCurrentMenuOptionsGfx(); + ShowLeftHeaderGfx(0, FALSE, FALSE); + CreateBgDotLightBluePalTask(); PrintCurrentOptionDescription(); return LT_INC_AND_PAUSE; case 3: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - if (sub_81CA89C()) + if (IsTaskActive_UpdateBgDotsPalette()) return LT_PAUSE; - if (sub_81CA7C4()) + if (IsDma3ManagerBusyWithBgCopy_()) return LT_PAUSE; - sub_81CA9D8(); + InitMenuOptionGlow(); break; } return LT_FINISH; @@ -611,8 +610,8 @@ static u32 LoopedTask_OpenConditionSearchMenu(s32 state) switch (state) { case 0: - sub_81CA9C8(); - sub_81CA2DC(); + ResetBldCnt(); + SetupPokenavMenuOptions(); PlaySE(SE_SELECT); return LT_INC_AND_PAUSE; case 1: @@ -622,18 +621,18 @@ static u32 LoopedTask_OpenConditionSearchMenu(s32 state) sub_81CA0C8(); return LT_INC_AND_PAUSE; case 2: - sub_81CA20C(); - sub_81C7FA0(7, FALSE, FALSE); + SetupCurrentMenuOptionsGfx(); + ShowLeftHeaderGfx(7, FALSE, FALSE); PrintCurrentOptionDescription(); return LT_INC_AND_PAUSE; case 3: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; - if (sub_81CA89C()) + if (IsTaskActive_UpdateBgDotsPalette()) return LT_PAUSE; - sub_81CA9D8(); + InitMenuOptionGlow(); break; } return LT_FINISH; @@ -644,27 +643,27 @@ static u32 LoopedTask_ReturnToConditionMenu(s32 state) switch (state) { case 0: - sub_81CA9C8(); - sub_81CA2DC(); - sub_81C7FC4(7, 0); + ResetBldCnt(); + SetupPokenavMenuOptions(); + HideMainOrSubMenuLeftHeader(POKENAV_GFX_SEARCH_MENU, 0); return LT_INC_AND_PAUSE; case 1: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; sub_81CA0C8(); return LT_INC_AND_PAUSE; case 2: - sub_81CA20C(); + SetupCurrentMenuOptionsGfx(); PrintCurrentOptionDescription(); return LT_INC_AND_PAUSE; case 3: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81CA89C()) + if (IsTaskActive_UpdateBgDotsPalette()) return LT_PAUSE; - sub_81CA9D8(); + InitMenuOptionGlow(); break; } return LT_FINISH; @@ -714,19 +713,19 @@ static u32 LoopedTask_OpenPokenavFeature(s32 state) case 1: if (WaitForHelpBar()) return LT_PAUSE; - sub_81C7880(); - sub_81CA9C8(); - sub_81CA2DC(); + SlideMenuHeaderUp(); + ResetBldCnt(); + SetupPokenavMenuOptions(); switch (GetPokenavMenuType()) { case POKENAV_MENU_TYPE_CONDITION_SEARCH: - sub_81C7FC4(7, FALSE); + HideMainOrSubMenuLeftHeader(POKENAV_GFX_SEARCH_MENU, FALSE); // fallthrough case POKENAV_MENU_TYPE_CONDITION: - sub_81C7FC4(1, FALSE); + HideMainOrSubMenuLeftHeader(POKENAV_GFX_CONDITION_MENU, FALSE); break; default: - sub_81C7FC4(0, FALSE); + HideMainOrSubMenuLeftHeader(POKENAV_GFX_MAIN_MENU, FALSE); break; } PlaySE(SE_SELECT); @@ -734,7 +733,7 @@ static u32 LoopedTask_OpenPokenavFeature(s32 state) case 2: if (AreMenuOptionSpritesMoving()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; PokenavFadeScreen(0); return LT_INC_AND_PAUSE; @@ -746,16 +745,16 @@ static u32 LoopedTask_OpenPokenavFeature(s32 state) return LT_FINISH; } -static void sub_81C9FC4(void) +static void LoadPokenavOptionPalettes(void) { s32 i; - for (i = 0; i < NELEMS(gUnknown_086201C4); i++) - LoadCompressedSpriteSheet(&gUnknown_086201C4[i]); - Pokenav_AllocAndLoadPalettes(gUnknown_086201D4); + for (i = 0; i < NELEMS(sPokenavOptionsSpriteSheets); i++) + LoadCompressedSpriteSheet(&sPokenavOptionsSpriteSheets[i]); + Pokenav_AllocAndLoadPalettes(sPokenavOptionsSpritePalettes); } -static void sub_81C9FEC(void) +static void FreeAndDestroyMainMenuSprites(void) { FreeSpriteTilesByTag(3); FreeSpriteTilesByTag(1); @@ -765,14 +764,14 @@ static void sub_81C9FEC(void) FreeSpritePaletteByTag(7); FreeSpritePaletteByTag(8); FreeSpritePaletteByTag(3); - sub_81CA094(); - sub_81CA698(); + DestroyMenuOptionSprites(); + DestroyRematchBlueLightSpriteId(); } static void CreateMenuOptionSprites(void) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { @@ -786,10 +785,10 @@ static void CreateMenuOptionSprites(void) } } -static void sub_81CA094(void) +static void DestroyMenuOptionSprites(void) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { @@ -804,25 +803,25 @@ static void sub_81CA094(void) static void sub_81CA0C8(void) { s32 menuType = GetPokenavMenuType(); - sub_81CA0EC(gUnknown_08620240[menuType].unk4, gUnknown_08620240[menuType].unk0, gUnknown_08620240[menuType].unk2); + DrawOptionLabelGfx(sPokenavMenuOptionLabelGfx[menuType].tiles, sPokenavMenuOptionLabelGfx[menuType].yStart, sPokenavMenuOptionLabelGfx[menuType].deltaY); } -static void sub_81CA0EC(const u16 *const *a0, s32 a1, s32 a2) +static void DrawOptionLabelGfx(const u16 *const *tiles, s32 yPos, s32 deltaY) { s32 i, j; - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); s32 sp04 = GetSpriteTileStartByTag(3); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (*a0 != NULL) + if (*tiles != NULL) { for (j = 0; j < 4; j++) { - unk->iconSprites[i][j]->oam.tileNum = (*a0)[0] + sp04 + 8 * j; - unk->iconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag((*a0)[1] + 4); + unk->iconSprites[i][j]->oam.tileNum = (*tiles)[0] + sp04 + 8 * j; + unk->iconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag((*tiles)[1] + 4); unk->iconSprites[i][j]->invisible = TRUE; - unk->iconSprites[i][j]->pos1.y = a1; + unk->iconSprites[i][j]->pos1.y = yPos; unk->iconSprites[i][j]->pos1.x = 0x8c; unk->iconSprites[i][j]->pos2.x = 32 * j; } @@ -836,76 +835,78 @@ static void sub_81CA0EC(const u16 *const *a0, s32 a1, s32 a2) } unk->iconVisible[i] = FALSE; } - a0++; - a1 += a2; + tiles++; + yPos += deltaY; } } -static void sub_81CA20C(void) +static void SetupCurrentMenuOptionsGfx(void) { s32 i; - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); s32 r8 = GetPokenavCursorPos(); s32 r7 = 0; s32 r2; for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (unk->iconVisible[i]) + if (icons->iconVisible[i]) { if (r7++ == r8) { r2 = 0x82; - unk->cursorPos = i; + icons->cursorPos = i; } else r2 = 0x8c; - sub_81CA35C(unk->iconSprites[i], 0x100, r2, 0xC); - sub_81CA448(unk->iconSprites[i], FALSE); + SetMenuOptionGfxParamsInactive(icons->iconSprites[i], 0x100, r2, 0xC); + SetMenuOptionGfxInvisibility(icons->iconSprites[i], FALSE); } else - sub_81CA448(unk->iconSprites[i], TRUE); + { + SetMenuOptionGfxInvisibility(icons->iconSprites[i], TRUE); + } } } -static void sub_81CA278(void) +static void SetMenuOptionGfxParams_CursorMoved(void) { s32 i; - struct Pokenav2Struct * unk = GetSubstructPtr(2); - s32 r3 = GetPokenavCursorPos(); - s32 r5; + struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + s32 prevPos = GetPokenavCursorPos(); + s32 newPos; - for (i = 0, r5 = 0; i < MAX_POKENAV_MENUITEMS; i++) + for (i = 0, newPos = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (unk->iconVisible[i]) + if (icons->iconVisible[i]) { - if (r5 == r3) + if (newPos == prevPos) { - r5 = i; + newPos = i; break; } - r5++; + newPos++; } } - sub_81CA35C(unk->iconSprites[unk->cursorPos], 0x82, 0x8c, 0x4); - sub_81CA35C(unk->iconSprites[r5], 0x8c, 0x82, 0x4); - unk->cursorPos = r5; + SetMenuOptionGfxParamsInactive(icons->iconSprites[icons->cursorPos], 0x82, 0x8c, 0x4); + SetMenuOptionGfxParamsInactive(icons->iconSprites[newPos], 0x8c, 0x82, 0x4); + icons->cursorPos = newPos; } -static void sub_81CA2DC(void) +static void SetupPokenavMenuOptions(void) { s32 i; - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct *optionIcons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (unk->iconVisible[i]) + if (optionIcons->iconVisible[i]) { - if (unk->cursorPos != i) - sub_81CA35C(unk->iconSprites[i], 0x8C, 0x100, 0x8); + if (optionIcons->cursorPos != i) + SetMenuOptionGfxParamsInactive(optionIcons->iconSprites[i], 0x8C, 0x100, 0x8); else - sub_81CA3B4(unk->iconSprites[i]); + SetMenuOptionGfxParamsActive(optionIcons->iconSprites[i]); } } } @@ -913,40 +914,40 @@ static void sub_81CA2DC(void) static bool32 AreMenuOptionSpritesMoving(void) { s32 i; - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct *icons = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); for (i = 0; i < MAX_POKENAV_MENUITEMS; i++) { - if (unk->iconSprites[i][0]->callback != SpriteCallbackDummy) + if (icons->iconSprites[i][0]->callback != SpriteCallbackDummy) return TRUE; } - if (unk->otherIconsInMotion) + if (icons->otherIconsInMotion) return TRUE; return FALSE; } -static void sub_81CA35C(struct Sprite ** sprites, s32 a1, s32 a2, s32 a3) +static void SetMenuOptionGfxParamsInactive(struct Sprite ** sprites, s32 x, s32 a2, s32 a3) { s32 i; for (i = 0; i < 4; i++) { - (*sprites)->pos1.x = a1; + (*sprites)->pos1.x = x; (*sprites)->data[0] = a3; - (*sprites)->data[1] = 16 * (a2 - a1) / a3; - (*sprites)->data[2] = 16 * a1; + (*sprites)->data[1] = 16 * (a2 - x) / a3; + (*sprites)->data[2] = 16 * x; (*sprites)->data[7] = a2; (*sprites)->callback = sub_81CA474; sprites++; } } -static void sub_81CA3B4(struct Sprite ** sprites) +static void SetMenuOptionGfxParamsActive(struct Sprite ** sprites) { s32 i; - struct Pokenav2Struct * unk = GetSubstructPtr(2); + struct Pokenav2Struct * unk = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); u8 taskId; for (i = 0; i < 4; i++) @@ -968,13 +969,13 @@ static void sub_81CA3B4(struct Sprite ** sprites) unk->otherIconsInMotion++; } -static void sub_81CA448(struct Sprite ** sprites, bool32 a1) +static void SetMenuOptionGfxInvisibility(struct Sprite ** sprites, bool32 invisible) { s32 i; for (i = 0; i < 4; i++) { - (*sprites)->invisible = a1; + (*sprites)->invisible = invisible; sprites++; } } @@ -1078,7 +1079,7 @@ static void sub_81CA580(u8 taskId) data[4]++; if (data[4] == 12) { - ((struct Pokenav2Struct *)GetSubstructPtr(2))->otherIconsInMotion--; + ((struct Pokenav2Struct *)GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS))->otherIconsInMotion--; SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x00, 0x10)); DestroyTask(taskId); } @@ -1089,24 +1090,24 @@ static void sub_81CA580(u8 taskId) data[0]--; } -static void sub_81CA640(void) +static void CreateMatchCallBlueLightSprite(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(2); - u8 spriteId = CreateSprite(&gUnknown_0862036C, 0x10, 0x60, 4); - ptr->field_028 = &gSprites[spriteId]; - if (sub_81C98D4()) - ptr->field_028->callback = sub_81CA6AC; + struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + u8 spriteId = CreateSprite(&sMatchCallBlueLightSpriteTemplate, 0x10, 0x60, 4); + ptr->blueLightSpriteId = &gSprites[spriteId]; + if (PlayerHasTrainerRematches()) + ptr->blueLightSpriteId->callback = SpriteCB_BlinkingBlueLight; else - ptr->field_028->invisible = TRUE; + ptr->blueLightSpriteId->invisible = TRUE; } -static void sub_81CA698(void) +static void DestroyRematchBlueLightSpriteId(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(2); - DestroySprite(ptr->field_028); + struct Pokenav2Struct *ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + DestroySprite(ptr->blueLightSpriteId); } -static void sub_81CA6AC(struct Sprite * sprite) +static void SpriteCB_BlinkingBlueLight(struct Sprite * sprite) { sprite->data[0]++; if (sprite->data[0] > 8) @@ -1118,7 +1119,7 @@ static void sub_81CA6AC(struct Sprite * sprite) static void AddOptionDescriptionWindow(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(2); + struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); ptr->optionDescWindowId = AddWindow(&sOptionDescWindowTemplate); PutWindowTilemap(ptr->optionDescWindowId); @@ -1128,7 +1129,7 @@ static void AddOptionDescriptionWindow(void) static void PrintCurrentOptionDescription(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(2); + struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); int menuItem = GetCurrentMenuItemId(); const u8 * s = sPageDescriptions[menuItem]; u32 width = GetStringWidth(1, s, -1); @@ -1140,73 +1141,73 @@ static void PrintCurrentOptionDescription(void) // Can occur by obtaining a mon with a ribbon and then releasing all ribbon winners static void PrintNoRibbonWinners(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(2); + struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); const u8 * s = gText_NoRibbonWinners; u32 width = GetStringWidth(1, s, -1); FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); AddTextPrinterParameterized3(ptr->optionDescWindowId, 1, (192 - width) / 2, 1, sOptionDescTextColors2, 0, s); } -static bool32 sub_81CA7C4(void) +static bool32 IsDma3ManagerBusyWithBgCopy_(void) { return IsDma3ManagerBusyWithBgCopy(); } -static void sub_81CA7D4(void) +static void CreateMovingBgDotsTask(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(2); - ptr->bg3ScrollTaskId = CreateTask(sub_81CA808, 2); + struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); + ptr->bg3ScrollTaskId = CreateTask(Task_MoveBgDots, 2); } -static void sub_81CA7F4(void) +static void DestroyMovingDotsBgTask(void) { - struct Pokenav2Struct * ptr = GetSubstructPtr(2); + struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); DestroyTask(ptr->bg3ScrollTaskId); } -static void sub_81CA808(u8 taskId) +static void Task_MoveBgDots(u8 taskId) { ChangeBgX(3, 0x80, 1); } -static void sub_81CA818(void) +static void CreateBgDotPurplePalTask(void) { - u8 taskId = CreateTask(sub_81CA8B0, 3); - SetWordTaskArg(taskId, 1, (uintptr_t)(gUnknown_0861FC78 + 1)); - SetWordTaskArg(taskId, 3, (uintptr_t)(gUnknown_0861FC78 + 7)); + u8 taskId = CreateTask(Task_UpdateBgDotsPalette, 3); + SetWordTaskArg(taskId, 1, (uintptr_t)(sPokenavBgDotsPal + 1)); + SetWordTaskArg(taskId, 3, (uintptr_t)(sPokenavBgDotsPal + 7)); } -static void sub_81CA850(void) +static void ChangeBgDotsColorToPurple(void) { - CopyPaletteIntoBufferUnfaded(gUnknown_0861FC78 + 7, 0x31, 4); + CopyPaletteIntoBufferUnfaded(sPokenavBgDotsPal + 7, 0x31, 4); } -static void sub_81CA864(void) +static void CreateBgDotLightBluePalTask(void) { - u8 taskId = CreateTask(sub_81CA8B0, 3); - SetWordTaskArg(taskId, 1, (uintptr_t)(gUnknown_0861FC78 + 7)); - SetWordTaskArg(taskId, 3, (uintptr_t)(gUnknown_0861FC78 + 1)); + u8 taskId = CreateTask(Task_UpdateBgDotsPalette, 3); + SetWordTaskArg(taskId, 1, (uintptr_t)(sPokenavBgDotsPal + 7)); + SetWordTaskArg(taskId, 3, (uintptr_t)(sPokenavBgDotsPal + 1)); } -static bool32 sub_81CA89C(void) +static bool32 IsTaskActive_UpdateBgDotsPalette(void) { - return FuncIsActiveTask(sub_81CA8B0); + return FuncIsActiveTask(Task_UpdateBgDotsPalette); } -static void sub_81CA8B0(u8 taskId) +static void Task_UpdateBgDotsPalette(u8 taskId) { u16 sp8[2]; s16 * data = gTasks[taskId].data; const u16 * pal1 = (const u16 *)GetWordTaskArg(taskId, 1); const u16 * pal2 = (const u16 *)GetWordTaskArg(taskId, 3); - sub_81C79BC(pal1, pal2, 2, 12, ++data[0], sp8); + PokenavCopyPalette(pal1, pal2, 2, 12, ++data[0], sp8); LoadPalette(sp8, 0x31, 4); if (data[0] == 12) DestroyTask(taskId); } -static void sub_81CA914(void) +static void VBlankCB_PokenavMainMenu(void) { TransferPlttBuffer(); LoadOam(); @@ -1214,7 +1215,7 @@ static void sub_81CA914(void) ScanlineEffect_InitHBlankDmaTransfer(); } -static void sub_81CA92C(void) +static void SetupPokenavMenuScanlineEffects(void) { SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_LIGHTEN); SetGpuReg(REG_OFFSET_BLDY, 0); @@ -1223,33 +1224,33 @@ static void sub_81CA92C(void) SetGpuRegBits(REG_OFFSET_WINOUT, 0x1F); SetGpuRegBits(REG_OFFSET_WIN0V, 0xA0); ScanlineEffect_Stop(); - sub_81CAA3C(); - ScanlineEffect_SetParams(gUnknown_08620384); - SetVBlankCallback_(sub_81CA914); - CreateTask(sub_81CA9EC, 3); + SetMenuOptionGlow(); + ScanlineEffect_SetParams(sPokenavMainMenuScanlineEffectParams); + SetVBlankCallback_(VBlankCB_PokenavMainMenu); + CreateTask(Task_CurrentMenuOptionGlow, 3); } -static void sub_81CA994(void) +static void DestroyMenuOptionGlowTask(void) { SetGpuReg(REG_OFFSET_BLDCNT, 0); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); ScanlineEffect_Stop(); - DestroyTask(FindTaskIdByFunc(sub_81CA9EC)); + DestroyTask(FindTaskIdByFunc(Task_CurrentMenuOptionGlow)); SetPokenavVBlankCallback(); } -static void sub_81CA9C8(void) +static void ResetBldCnt(void) { SetGpuReg(REG_OFFSET_BLDCNT, 0); } -static void sub_81CA9D8(void) +static void InitMenuOptionGlow(void) { - sub_81CAA3C(); + SetMenuOptionGlow(); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_LIGHTEN); } -static void sub_81CA9EC(u8 taskId) +static void Task_CurrentMenuOptionGlow(u8 taskId) { s16 * data = gTasks[taskId].data; data[0]++; @@ -1262,18 +1263,18 @@ static void sub_81CA9EC(u8 taskId) } } -static void sub_81CAA3C(void) +static void SetMenuOptionGlow(void) { int menuType = GetPokenavMenuType(); int cursorPos = GetPokenavCursorPos(); - int r4 = gUnknown_08620240[menuType].unk2 * cursorPos + gUnknown_08620240[menuType].unk0 - 8; + int r4 = sPokenavMenuOptionLabelGfx[menuType].deltaY * cursorPos + sPokenavMenuOptionLabelGfx[menuType].yStart - 8; CpuFill16(0, gScanlineEffectRegBuffers[0], 0x140); CpuFill16(0, gScanlineEffectRegBuffers[1], 0x140); CpuFill16(RGB(16, 23, 28), &gScanlineEffectRegBuffers[0][r4], 0x20); CpuFill16(RGB(16, 23, 28), &gScanlineEffectRegBuffers[1][r4], 0x20); } -void sub_81CAADC(void) +void ResetBldCnt_(void) { - sub_81CA9C8(); + ResetBldCnt(); } diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index 394b40907..2dd2e4408 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -170,11 +170,11 @@ static const struct SpriteTemplate sCityZoomTextSpriteTemplate = u32 PokenavCallback_Init_RegionMap(void) { - struct Pokenav5Struct *state = AllocSubstruct(3, sizeof(struct Pokenav5Struct)); + struct Pokenav5Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE, sizeof(struct Pokenav5Struct)); if (!state) return FALSE; - if (!AllocSubstruct(16, sizeof(struct RegionMap))) + if (!AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP, sizeof(struct RegionMap))) return FALSE; state->zoomDisabled = IsEventIslandMapSecId(gMapHeader.regionMapSectionId); @@ -189,13 +189,13 @@ u32 PokenavCallback_Init_RegionMap(void) void FreeRegionMapSubstruct1(void) { gSaveBlock2Ptr->regionMapZoom = IsRegionMapZoomed(); - FreePokenavSubstruct(16); - FreePokenavSubstruct(3); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_REGION_MAP); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE); } u32 GetRegionMapCallback(void) { - struct Pokenav5Struct *state = GetSubstructPtr(3); + struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE); return state->callback(state); } @@ -235,13 +235,13 @@ static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *state) bool32 GetZoomDisabled(void) { - struct Pokenav5Struct *state = GetSubstructPtr(3); + struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE); return state->zoomDisabled; } bool32 OpenPokenavRegionMap(void) { - struct Pokenav5Struct_2 *state = AllocSubstruct(4, sizeof(struct Pokenav5Struct_2)); + struct Pokenav5Struct_2 *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, sizeof(struct Pokenav5Struct_2)); if (!state) return FALSE; @@ -252,25 +252,25 @@ bool32 OpenPokenavRegionMap(void) void CreateRegionMapLoopedTask(s32 index) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); state->loopTaskId = CreateLoopedTask(sRegionMapLoopTaskFuncs[index], 1); state->isTaskActiveCB = GetCurrentLoopedTaskActive; } bool32 IsRegionMapLoopedTaskActive(void) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); return state->isTaskActiveCB(); } void FreeRegionMapSubstruct2(void) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); FreeRegionMapIconResources(); FreeCityZoomViewGfx(); RemoveWindow(state->infoWindowId); - FreePokenavSubstruct(16); - FreePokenavSubstruct(4); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_REGION_MAP); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); SetPokenavVBlankCallback(); SetBgMode(0); } @@ -285,7 +285,7 @@ static void VBlankCB_RegionMap(void) static bool32 GetCurrentLoopedTaskActive(void) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); return IsLoopedTaskActive(state->loopTaskId); } @@ -301,7 +301,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) { int menuGfxId; struct RegionMap *regionMap; - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); switch (taskState) { case 0: @@ -311,7 +311,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) HideBg(3); SetBgMode(1); InitBgTemplates(sRegionMapBgTemplates, ARRAY_COUNT(sRegionMapBgTemplates) - 1); - regionMap = GetSubstructPtr(16); + regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); InitRegionMapData(regionMap, &sRegionMapBgTemplates[1], ShouldOpenRegionMapZoomed()); LoadCityZoomViewGfx(); return LT_INC_AND_PAUSE; @@ -361,11 +361,11 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) menuGfxId = POKENAV_GFX_MAP_MENU_ZOOMED_IN; LoadLeftHeaderGfxForIndex(menuGfxId); - sub_81C7FA0(menuGfxId, 1, 1); + ShowLeftHeaderGfx(menuGfxId, 1, 1); PokenavFadeScreen(1); return LT_INC_AND_PAUSE; case 7: - if (IsPaletteFadeActive() || sub_81C8010()) + if (IsPaletteFadeActive() || AreLeftHeaderSpritesMoving()) return LT_PAUSE; return LT_INC_AND_CONTINUE; default: @@ -375,7 +375,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) static u32 LoopedTask_UpdateInfoAfterCursorMove(s32 taskState) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); switch (taskState) { case 0: @@ -409,7 +409,7 @@ static u32 LoopedTask_RegionMapZoomOut(s32 taskState) if (WaitForHelpBar()) return LT_PAUSE; - sub_81C7E14(POKENAV_GFX_MAP_MENU_ZOOMED_OUT); + UpdateRegionMapRightHeaderTiles(POKENAV_GFX_MAP_MENU_ZOOMED_OUT); break; } @@ -418,7 +418,7 @@ static u32 LoopedTask_RegionMapZoomOut(s32 taskState) static u32 LoopedTask_RegionMapZoomIn(s32 taskState) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); switch (taskState) { case 0: @@ -442,7 +442,7 @@ static u32 LoopedTask_RegionMapZoomIn(s32 taskState) if (WaitForHelpBar()) return LT_PAUSE; - sub_81C7E14(POKENAV_GFX_MAP_MENU_ZOOMED_IN); + UpdateRegionMapRightHeaderTiles(POKENAV_GFX_MAP_MENU_ZOOMED_IN); break; } @@ -461,8 +461,8 @@ static u32 LoopedTask_ExitRegionMap(s32 taskState) if (IsPaletteFadeActive()) return LT_PAUSE; - sub_81C7FDC(); - sub_81C78A0(); + SetLeftHeaderSpritesInvisibility(); + SlideMenuHeaderDown(); return LT_INC_AND_PAUSE; case 2: if (MainMenuLoopedTaskIsBusy()) @@ -490,7 +490,7 @@ static void LoadCityZoomViewGfx(void) static void FreeCityZoomViewGfx(void) { int i; - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); FreeSpriteTilesByTag(6); FreeSpritePaletteByTag(11); for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) @@ -527,7 +527,7 @@ static bool32 TryFreeTempTileDataBuffers(void) static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state) { - struct RegionMap *regionMap = GetSubstructPtr(16); + struct RegionMap *regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); switch (regionMap->mapSecType) { case MAPSECTYPE_CITY_CANFLY: @@ -619,7 +619,7 @@ static bool32 IsDecompressCityMapsActive(void) static u32 LoopedTask_DecompressCityMaps(s32 taskState) { - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); if (taskState < NUM_CITY_MAPS) { LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]); @@ -662,7 +662,7 @@ static void CreateCityZoomTextSprites(void) int i; int y; struct Sprite *sprite; - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); // When not zoomed in the text is still created but its pushed off screen if (!IsRegionMapZoomed()) @@ -722,7 +722,7 @@ static void SpriteCB_CityZoomText(struct Sprite *sprite) static void UpdateCityZoomTextPosition(void) { int i; - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); int y = 132 - (GetBgY(1) >> 8); for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) state->cityZoomTextSprites[i]->pos1.y = y; @@ -731,7 +731,7 @@ static void UpdateCityZoomTextPosition(void) static void SetCityZoomTextInvisibility(bool32 invisible) { int i; - struct Pokenav5Struct_2 *state = GetSubstructPtr(4); + struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) state->cityZoomTextSprites[i]->invisible = invisible; } diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_1.c index fd47b27ad..9c171dd45 100644 --- a/src/pokenav_ribbons_1.c +++ b/src/pokenav_ribbons_1.c @@ -8,16 +8,28 @@ #include "international_string_util.h" #include "constants/songs.h" +enum +{ + RIBBONS_MON_LIST_FUNC_NONE, + RIBBONS_MON_LIST_FUNC_MOVE_UP, + RIBBONS_MON_LIST_FUNC_MOVE_DOWN, + RIBBONS_MON_LIST_FUNC_PAGE_UP, + RIBBONS_MON_LIST_FUNC_PAGE_DOWN, + RIBBONS_MON_LIST_FUNC_EXIT, + RIBBONS_MON_LIST_FUNC_OPEN_RIBBONS_SUMMARY +}; + + struct PokenavSub9 { - u32 (*unk0)(struct PokenavSub9*); + u32 (*callback)(struct PokenavSub9*); u32 loopedTaskId; u16 winid; - s32 unkC; - s32 unk10; - u32 unk14; - u32 unk18; - struct PokenavSub18 *unk1C; + s32 boxId; + s32 monId; + u32 changeBgs; + u32 saveMonList; + struct PokenavSub18 *monList; }; struct PokenavSub10 @@ -25,46 +37,46 @@ struct PokenavSub10 bool32 (*callback)(void); u32 ltid; u16 winid; - bool32 unkC; + bool32 fromSummary; u8 buff[BG_SCREEN_SIZE]; }; -static u32 sub_81CFA68(struct PokenavSub9 *structPtr); -static u32 sub_81CFA88(struct PokenavSub9 *structPtr); -static u32 sub_81CFB08(struct PokenavSub9 *structPtr); +static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr); +static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr); +static u32 RibbonsMonMenu_ReturnToMainMenu(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 u32 BuildPartyMonRibbonList(s32 state); +static u32 InitBoxMonRibbonList(s32 state); +static u32 BuildBoxMonRibbonList(s32 state); +static u32 GetMonRibbonListLoopTaskFunc(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 u32 LoopedTask_OpenRibbonsMonList(s32 state); +static bool32 GetRibbonsMonCurrentLoopedTaskActive(void); +static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state); +static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state); +static u32 LoopedTask_RibbonsListMovePageUp(s32 state); +static u32 LoopedTask_RibbonsListMovePageDown(s32 state); +static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state); +static u32 LoopedTask_RibbonsListOpenSummary(s32 state); static void sub_81D02B0(s32 windowId, s32 val1, s32 val2); -static void sub_81D024C(struct PokenavSub10 *ptr); +static void AddRibbonsMonListWindow(struct PokenavSub10 *ptr); static void sub_81D0288(struct PokenavSub10 *ptr); -static void sub_81D0304(void); +static void InitMonRibbonPokenavListMenuTemplate(void); static void BufferRibbonMonInfoText(struct PokenavMonList *, u8 *); -static const LoopedTask gUnknown_086235D8[] = +static const LoopedTask sMonRibbonListLoopTaskFuncs[] = { - sub_81CFB8C, - sub_81CFC2C, - sub_81CFC40 + BuildPartyMonRibbonList, + InitBoxMonRibbonList, + BuildBoxMonRibbonList }; -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 sMonRibbonListFramePal[] = INCBIN_U16("graphics/pokenav/ui_ribbons.gbapal"); +static const u32 sMonRibbonListFrameTiles[] = INCBIN_U32("graphics/pokenav/ui_ribbons.4bpp.lz"); +static const u32 sMonRibbonListFrameTilemap[] = INCBIN_U32("graphics/pokenav/ui_ribbons.bin.lz"); static const u16 gUnknown_08623790[] = INCBIN_U16("graphics/pokenav/8623790.gbapal"); -static const struct BgTemplate gUnknown_086237B0[] = +static const struct BgTemplate sMonRibbonListBgTemplates[] = { { .bg = 1, @@ -85,18 +97,18 @@ static const struct BgTemplate gUnknown_086237B0[] = } }; -static const LoopedTask gUnknown_086237B8[] = +static const LoopedTask sRibbonsMonMenuLoopTaskFuncs[] = { - NULL, - sub_81CFFFC, - sub_81D0074, - sub_81D00EC, - sub_81D0164, - sub_81D01DC, - sub_81D021C + [RIBBONS_MON_LIST_FUNC_NONE] = NULL, + [RIBBONS_MON_LIST_FUNC_MOVE_UP] = LoopedTask_RibbonsListMoveCursorUp, + [RIBBONS_MON_LIST_FUNC_MOVE_DOWN] = LoopedTask_RibbonsListMoveCursorDown, + [RIBBONS_MON_LIST_FUNC_PAGE_UP] = LoopedTask_RibbonsListMovePageUp, + [RIBBONS_MON_LIST_FUNC_PAGE_DOWN] = LoopedTask_RibbonsListMovePageDown, + [RIBBONS_MON_LIST_FUNC_EXIT] = LoopedTask_RibbonsListReturnToMainMenu, + [RIBBONS_MON_LIST_FUNC_OPEN_RIBBONS_SUMMARY] = LoopedTask_RibbonsListOpenSummary }; -static const struct WindowTemplate gUnknown_086237D4 = +static const struct WindowTemplate sRibbonsMonListWindowTemplate = { .bg = 1, .tilemapLeft = 1, @@ -111,135 +123,136 @@ static const u8 sText_MaleSymbol[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHIT static const u8 sText_FemaleSymbol[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}"); -bool32 PokenavCallback_Init_12(void) +bool32 PokenavCallback_Init_MonRibbonList(void) { - struct PokenavSub9 *structPtr = AllocSubstruct(9, sizeof(struct PokenavSub9)); + struct PokenavSub9 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct PokenavSub9)); if (structPtr == NULL) return FALSE; - structPtr->unk1C = AllocSubstruct(18, sizeof(struct PokenavSub18)); - if (structPtr->unk1C == NULL) + structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); + if (structPtr->monList == NULL) return FALSE; - structPtr->unk0 = sub_81CFA68; - structPtr->loopedTaskId = CreateLoopedTask(sub_81CFB74, 1); - structPtr->unk14 = 0; + structPtr->callback = HandleRibbonsMonListInput_WaitListInit; + structPtr->loopedTaskId = CreateLoopedTask(GetMonRibbonListLoopTaskFunc, 1); + structPtr->changeBgs = 0; return TRUE; } -bool32 PokenavCallback_Init_14(void) +bool32 PokenavCallback_Init_RibbonsMonListFromSummary(void) { - struct PokenavSub9 *structPtr = AllocSubstruct(9, sizeof(struct PokenavSub9)); + struct PokenavSub9 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct PokenavSub9)); if (structPtr == NULL) return FALSE; - structPtr->unk1C = GetSubstructPtr(18); - structPtr->unk0 = sub_81CFA88; - structPtr->unk14 = 1; + structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + structPtr->callback = HandleRibbonsMonListInput; + structPtr->changeBgs = 1; return TRUE; } -u32 sub_81CFA34(void) +u32 GetRibbonsMonListCallback(void) { - struct PokenavSub9 *structPtr = GetSubstructPtr(9); - return structPtr->unk0(structPtr); + struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return structPtr->callback(structPtr); } -void sub_81CFA48(void) +void FreeRibbonsMonList1(void) { - struct PokenavSub9 *structPtr = GetSubstructPtr(9); - if (!structPtr->unk18) - FreePokenavSubstruct(18); - FreePokenavSubstruct(9); + struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + if (!structPtr->saveMonList) + FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); } -static u32 sub_81CFA68(struct PokenavSub9 *structPtr) +static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr) { if (!IsLoopedTaskActive(structPtr->loopedTaskId)) - structPtr->unk0 = sub_81CFA88; + structPtr->callback = HandleRibbonsMonListInput; return 0; } -static u32 sub_81CFA88(struct PokenavSub9 *structPtr) +static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr) { if (JOY_REPEAT(DPAD_UP)) - return 1; + return RIBBONS_MON_LIST_FUNC_MOVE_UP; if (JOY_REPEAT(DPAD_DOWN)) - return 2; + return RIBBONS_MON_LIST_FUNC_MOVE_DOWN; if (JOY_NEW(DPAD_LEFT)) - return 3; + return RIBBONS_MON_LIST_FUNC_PAGE_UP; if (JOY_NEW(DPAD_RIGHT)) - return 4; + return RIBBONS_MON_LIST_FUNC_PAGE_DOWN; if (JOY_NEW(B_BUTTON)) { - structPtr->unk18 = 0; - structPtr->unk0 = sub_81CFB08; - return 5; + structPtr->saveMonList = 0; + structPtr->callback = RibbonsMonMenu_ReturnToMainMenu; + return RIBBONS_MON_LIST_FUNC_EXIT; } if (JOY_NEW(A_BUTTON)) { - structPtr->unk1C->unk2 = GetSelectedMatchCall(); - structPtr->unk18 = 1; - structPtr->unk0 = sub_81CFB10; - return 6; + structPtr->monList->currIndex = GetSelectedPokenavListIndex(); + structPtr->saveMonList = 1; + structPtr->callback = sub_81CFB10; + return RIBBONS_MON_LIST_FUNC_OPEN_RIBBONS_SUMMARY; } - return 0; + return RIBBONS_MON_LIST_FUNC_NONE; } -static u32 sub_81CFB08(struct PokenavSub9 *structPtr) +static u32 RibbonsMonMenu_ReturnToMainMenu(struct PokenavSub9 *structPtr) { return POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS; } static u32 sub_81CFB10(struct PokenavSub9 *structPtr) { - return POKENAV_MENU_D; + return POKENAV_RIBBONS_SUMMARY_SCREEN; } -static u32 sub_81CFB18(void) +static u32 UpdateMonListBgs(void) { - struct PokenavSub9 *structPtr = GetSubstructPtr(9); - return structPtr->unk14; + struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return structPtr->changeBgs; } -static struct PokenavMonList * sub_81CFB28(void) +static struct PokenavMonList *GetMonRibbonMonListData(void) { - struct PokenavSub9 * ptr = GetSubstructPtr(9); - return ptr->unk1C->unk4; + struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return ptr->monList->monData; } -static s32 sub_81CFB38(void) +static s32 GetRibbonsMonListCount(void) { - struct PokenavSub9 * ptr = GetSubstructPtr(9); - return ptr->unk1C->unk0; + struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return ptr->monList->listCount; } -static s32 sub_81CFB48(void) +//unused +static s32 GetMonRibbonSelectedMonData(void) { - struct PokenavSub9 * ptr = GetSubstructPtr(9); - s32 idx = GetSelectedMatchCall(); - return ptr->unk1C->unk4[idx].data; + struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + s32 idx = GetSelectedPokenavListIndex(); + return ptr->monList->monData[idx].data; } -static s32 sub_81CFB64(void) +static s32 GetRibbonListMenuCurrIndex(void) { - struct PokenavSub9 * ptr = GetSubstructPtr(9); - return ptr->unk1C->unk2; + struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + return ptr->monList->currIndex; } -static u32 sub_81CFB74(s32 state) +static u32 GetMonRibbonListLoopTaskFunc(s32 state) { - return gUnknown_086235D8[state](state); + return sMonRibbonListLoopTaskFuncs[state](state); } -static u32 sub_81CFB8C(s32 state) +static u32 BuildPartyMonRibbonList(s32 state) { s32 i; struct PokenavMonList item; - struct PokenavSub9 * ptr = GetSubstructPtr(9); + struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); - ptr->unk1C->unk0 = 0; - ptr->unk1C->unk2 = 0; + ptr->monList->listCount = 0; + ptr->monList->currIndex = 0; item.boxId = TOTAL_BOXES_COUNT; for (i = 0; i < PARTY_SIZE; i++) { @@ -261,19 +274,19 @@ static u32 sub_81CFB8C(s32 state) return LT_INC_AND_CONTINUE; } -static u32 sub_81CFC2C(s32 state) +static u32 InitBoxMonRibbonList(s32 state) { - struct PokenavSub9 * ptr = GetSubstructPtr(9); - ptr->unk10 = 0; - ptr->unkC = 0; + struct PokenavSub9 *ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + ptr->monId = 0; + ptr->boxId = 0; return LT_INC_AND_CONTINUE; } -static u32 sub_81CFC40(s32 state) +static u32 BuildBoxMonRibbonList(s32 state) { - struct PokenavSub9 * ptr = GetSubstructPtr(9); - s32 boxId = ptr->unkC; - s32 monId = ptr->unk10; + struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST); + s32 boxId = ptr->boxId; + s32 monId = ptr->monId; s32 boxCount = 0; struct PokenavMonList item; @@ -296,8 +309,8 @@ static u32 sub_81CFC40(s32 state) monId++; if (boxCount > TOTAL_BOXES_COUNT) { - ptr->unkC = boxId; - ptr->unk10 = monId; + ptr->boxId = boxId; + ptr->monId = monId; return LT_CONTINUE; } } @@ -305,37 +318,38 @@ static u32 sub_81CFC40(s32 state) boxId++; } - ptr->unk14 = 1; + ptr->changeBgs = 1; return LT_FINISH; } static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item) { u32 left = 0; - u32 right = structPtr->unk1C->unk0; + u32 right = structPtr->monList->listCount; u32 insertionIdx = left + (right - left) / 2; while (right != insertionIdx) { - if (item->data > structPtr->unk1C->unk4[insertionIdx].data) + if (item->data > structPtr->monList->monData[insertionIdx].data) 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++; + for (right = structPtr->monList->listCount; right > insertionIdx; right--) + structPtr->monList->monData[right] = structPtr->monList->monData[right - 1]; + structPtr->monList->monData[insertionIdx] = *item; + structPtr->monList->listCount++; } -static bool32 sub_81CFD58(void) +//unused +static bool32 Unused_PlayerHasRibbonsMon(void) { s32 i, j; for (i = 0; i < PARTY_SIZE; i++) { - struct Pokemon * mon = &gPlayerParty[i]; + struct Pokemon *mon = &gPlayerParty[i]; if (!GetMonData(mon, MON_DATA_SANITY_HAS_SPECIES)) continue; if (GetMonData(mon, MON_DATA_SANITY_IS_EGG)) @@ -358,72 +372,72 @@ static bool32 sub_81CFD58(void) return FALSE; } -bool32 sub_81CFDD0(void) +bool32 OpenRibbonsMonList(void) { - struct PokenavSub10 * ptr = AllocSubstruct(10, sizeof(struct PokenavSub10)); + struct PokenavSub10 *ptr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10)); if (ptr == NULL) return FALSE; - ptr->ltid = CreateLoopedTask(sub_81CFEB8, 1); - ptr->callback = sub_81CFE84; - ptr->unkC = FALSE; + ptr->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1); + ptr->callback = GetRibbonsMonCurrentLoopedTaskActive; + ptr->fromSummary = FALSE; return TRUE; } -bool32 sub_81CFE08(void) +bool32 OpenRibbonsMonListFromRibbonsSummary(void) { - struct PokenavSub10 * ptr = AllocSubstruct(10, sizeof(struct PokenavSub10)); - if (ptr == NULL) + struct PokenavSub10 *monMenu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10)); + if (monMenu == NULL) return FALSE; - ptr->ltid = CreateLoopedTask(sub_81CFEB8, 1); - ptr->callback = sub_81CFE84; - ptr->unkC = TRUE; + monMenu->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1); + monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive; + monMenu->fromSummary = TRUE; return TRUE; } -void sub_81CFE40(s32 idx) +void CreateRibbonsMonListLoopedTask(s32 idx) { - struct PokenavSub10 * ptr = GetSubstructPtr(10); - ptr->ltid = CreateLoopedTask(gUnknown_086237B8[idx], 1); - ptr->callback = sub_81CFE84; + struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + monMenu->ltid = CreateLoopedTask(sRibbonsMonMenuLoopTaskFuncs[idx], 1); + monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive; } -bool32 sub_81CFE70(void) +bool32 IsRibbonsMonListLoopedTaskActive(void) { - struct PokenavSub10 * ptr = GetSubstructPtr(10); - return ptr->callback(); + struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); + return monMenu->callback(); } -bool32 sub_81CFE84(void) +bool32 GetRibbonsMonCurrentLoopedTaskActive(void) { - struct PokenavSub10 * ptr = GetSubstructPtr(10); + struct PokenavSub10 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); return IsLoopedTaskActive(ptr->ltid); } -void sub_81CFE98(void) +void FreeRibbonsMonList2(void) { - struct PokenavSub10 * ptr = GetSubstructPtr(10); + struct PokenavSub10 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); sub_81C8234(); RemoveWindow(ptr->winid); - FreePokenavSubstruct(10); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); } -static u32 sub_81CFEB8(s32 state) +static u32 LoopedTask_OpenRibbonsMonList(s32 state) { - struct PokenavSub10 * unk = GetSubstructPtr(10); + struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: - InitBgTemplates(gUnknown_086237B0, NELEMS(gUnknown_086237B0)); - DecompressAndCopyTileDataToVram(1, gUnknown_08623604, 0, 0, 0); - SetBgTilemapBuffer(1, unk->buff); - CopyToBgTilemapBuffer(1, gUnknown_086236CC, 0, 0); - CopyPaletteIntoBufferUnfaded(gUnknown_086235E4, 0x10, 0x20); + InitBgTemplates(sMonRibbonListBgTemplates, NELEMS(sMonRibbonListBgTemplates)); + DecompressAndCopyTileDataToVram(1, sMonRibbonListFrameTiles, 0, 0, 0); + SetBgTilemapBuffer(1, monMenu->buff); + CopyToBgTilemapBuffer(1, sMonRibbonListFrameTilemap, 0, 0); + CopyPaletteIntoBufferUnfaded(sMonRibbonListFramePal, 0x10, 0x20); CopyBgTilemapBufferToVram(1); return LT_INC_AND_PAUSE; case 1: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - if (!sub_81CFB18()) + if (!UpdateMonListBgs()) return LT_PAUSE; ChangeBgX(1, 0, 0); ChangeBgY(1, 0, 0); @@ -433,12 +447,12 @@ static u32 sub_81CFEB8(s32 state) if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; CopyPaletteIntoBufferUnfaded(gUnknown_08623790, 0x20, 0x20); - sub_81D0304(); + InitMonRibbonPokenavListMenuTemplate(); return LT_INC_AND_PAUSE; case 3: if (sub_81C8224()) return LT_PAUSE; - sub_81D024C(unk); + AddRibbonsMonListWindow(monMenu); return LT_INC_AND_PAUSE; case 4: if (FreeTempTileDataBuffersIfPossible()) @@ -447,25 +461,25 @@ static u32 sub_81CFEB8(s32 state) HideBg(3); PrintHelpBarText(HELPBAR_RIBBONS_MON_LIST); PokenavFadeScreen(1); - if (!unk->unkC) + if (!monMenu->fromSummary) { - LoadLeftHeaderGfxForIndex(2); - sub_81C7FA0(2, 1, 0); + LoadLeftHeaderGfxForIndex(POKENAV_GFX_RIBBONS_MENU); + ShowLeftHeaderGfx(POKENAV_GFX_RIBBONS_MENU, 1, 0); } return LT_INC_AND_PAUSE; case 5: if (IsPaletteFadeActive()) return LT_PAUSE; - if (sub_81C8010()) + if (AreLeftHeaderSpritesMoving()) return LT_PAUSE; break; } return LT_FINISH; } -static u32 sub_81CFFFC(s32 state) +static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state) { - struct PokenavSub10 * unk = GetSubstructPtr(10); + struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: @@ -482,11 +496,11 @@ static u32 sub_81CFFFC(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; // fallthrough case 2: - sub_81D0288(unk); + sub_81D0288(monMenu); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -496,9 +510,9 @@ static u32 sub_81CFFFC(s32 state) return LT_FINISH; } -static u32 sub_81D0074(s32 state) +static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state) { - struct PokenavSub10 * unk = GetSubstructPtr(10); + struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: @@ -515,11 +529,11 @@ static u32 sub_81D0074(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; // fallthrough case 2: - sub_81D0288(unk); + sub_81D0288(monMenu); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -529,9 +543,9 @@ static u32 sub_81D0074(s32 state) return LT_FINISH; } -static u32 sub_81D00EC(s32 state) +static u32 LoopedTask_RibbonsListMovePageUp(s32 state) { - struct PokenavSub10 * unk = GetSubstructPtr(10); + struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: @@ -548,11 +562,11 @@ static u32 sub_81D00EC(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; // fallthrough case 2: - sub_81D0288(unk); + sub_81D0288(monMenu); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -562,9 +576,9 @@ static u32 sub_81D00EC(s32 state) return LT_FINISH; } -static u32 sub_81D0164(s32 state) +static u32 LoopedTask_RibbonsListMovePageDown(s32 state) { - struct PokenavSub10 * unk = GetSubstructPtr(10); + struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU); switch (state) { case 0: @@ -581,11 +595,11 @@ static u32 sub_81D0164(s32 state) } return LT_INC_AND_PAUSE; case 1: - if (sub_81C8630()) + if (IsMonListLoopedTaskActive()) return LT_PAUSE; // fallthrough case 2: - sub_81D0288(unk); + sub_81D0288(monMenu); return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) @@ -595,27 +609,27 @@ static u32 sub_81D0164(s32 state) return LT_FINISH; } -static u32 sub_81D01DC(s32 state) +static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state) { switch (state) { case 0: PlaySE(SE_SELECT); PokenavFadeScreen(0); - sub_81C78A0(); + SlideMenuHeaderDown(); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) return LT_PAUSE; if (MainMenuLoopedTaskIsBusy()) return LT_PAUSE; - sub_81C7FDC(); + SetLeftHeaderSpritesInvisibility(); break; } return LT_FINISH; } -static u32 sub_81D021C(s32 state) +static u32 LoopedTask_RibbonsListOpenSummary(s32 state) { switch (state) { @@ -631,23 +645,23 @@ static u32 sub_81D021C(s32 state) return LT_FINISH; } -static void sub_81D024C(struct PokenavSub10 * ptr) +static void AddRibbonsMonListWindow(struct PokenavSub10 *monMenu) { 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); + monMenu->winid = AddWindow(&sRibbonsMonListWindowTemplate); + PutWindowTilemap(monMenu->winid); + r2 = GetRibbonsMonListCount(); + sub_81D02B0(monMenu->winid, 0, r2); + CopyWindowToVram(monMenu->winid, 1); + sub_81D0288(monMenu); } -static void sub_81D0288(struct PokenavSub10 * ptr) +static void sub_81D0288(struct PokenavSub10 *monMenu) { - s32 r4 = GetSelectedMatchCall(); - s32 r2 = sub_81CFB38(); - sub_81D02B0(ptr->winid, r4 + 1, r2); - CopyWindowToVram(ptr->winid, 2); + s32 r4 = GetSelectedPokenavListIndex(); + s32 r2 = GetRibbonsMonListCount(); + sub_81D02B0(monMenu->winid, r4 + 1, r2); + CopyWindowToVram(monMenu->winid, 2); } static void sub_81D02B0(s32 windowId, s32 val1, s32 val2) @@ -663,22 +677,22 @@ static void sub_81D02B0(s32 windowId, s32 val1, s32 val2) AddTextPrinterParameterized(windowId, 1, strbuf, x, 1, 0xFF, NULL); } -static void sub_81D0304(void) +static void InitMonRibbonPokenavListMenuTemplate(void) { struct PokenavListTemplate template; - template.list.monList = sub_81CFB28(); - template.unk4 = sub_81CFB38(); + template.list.monList = GetMonRibbonMonListData(); + template.count = GetRibbonsMonListCount(); 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.listFunc.unk10_1 = BufferRibbonMonInfoText; + template.unk6 = GetRibbonListMenuCurrIndex(); + template.item_X = 13; + template.windowWidth = 17; + template.listTop = 1; + template.maxShowed = 8; + template.fillValue = 2; + template.fontId = 1; + template.listFunc.printMonFunc = BufferRibbonMonInfoText; template.unk14 = NULL; - sub_81C81D4(&gUnknown_086237B0[1], &template, 0); + sub_81C81D4(&sMonRibbonListBgTemplates[1], &template, 0); } // Buffers the "Nickname gender/level" text for the ribbon mon list diff --git a/src/pokenav_ribbons_2.c b/src/pokenav_ribbons_2.c index 6eabc9b33..f33d90e51 100644 --- a/src/pokenav_ribbons_2.c +++ b/src/pokenav_ribbons_2.c @@ -13,28 +13,38 @@ #include "window.h" #include "constants/songs.h" +enum +{ + RIBBONS_SUMMARY_FUNC_NONE, + RIBBONS_SUMMARY_FUNC_MOVED_CURSOR, + RIBBONS_SUMMARY_FUNC_SELECT_RIBBON, + RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE, + RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL, + RIBBONS_SUMMARY_FUNC_EXIT, +}; + struct PokenavSub13 { u8 filler0[0x8]; - struct PokenavSub18 *field_8; + struct PokenavSub18 *monList; u16 field_C; u16 field_E; u16 field_10; u16 field_12; u32 field_14[25]; u32 field_78[8]; - u32 (*field_98)(struct PokenavSub13 *structPtr); + u32 (*callback)(struct PokenavSub13 *structPtr); }; struct PokenavSub14 { - u32 (*field_0)(void); + u32 (*callback)(void); u32 loopedTaskId; - u16 field_8; - u16 field_A; - u16 field_C; + u16 nameWindowId; + u16 ribbonCountWindowId; + u16 listIdxWindowId; u16 field_E; - u16 field_10; + u16 monSpriteId; struct Sprite *field_14; u32 filler; u8 tilemapBuffers[2][BG_SCREEN_SIZE]; @@ -43,48 +53,48 @@ struct PokenavSub14 static u32 gUnknown_030012C0; static u32 gUnknown_030012C4; -void sub_81D0E84(struct PokenavSub14 *structPtr); -void sub_81D0FF0(struct PokenavSub14 *structPtr); -void sub_81D10D0(struct PokenavSub14 *structPtr); +void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr); +void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr); +void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr); void sub_81D1500(struct PokenavSub14 *structPtr); void sub_81D0EFC(struct PokenavSub14 *structPtr); -void sub_81D1148(struct PokenavSub14 *structPtr); -void sub_81D10A4(struct PokenavSub14 *structPtr); -void sub_81D1178(struct PokenavSub14 *structPtr); +void ResetSpritesAndDrawRibbonsMonFrontPic(struct PokenavSub14 *structPtr); +void AddRibbonListIndexWindow(struct PokenavSub14 *structPtr); +void DestroyRibbonsMonFrontPic(struct PokenavSub14 *structPtr); void sub_81D11D8(struct PokenavSub14 *structPtr); void sub_81D11FC(struct PokenavSub14 *structPtr); -void sub_81D0E60(struct PokenavSub14 *structPtr); +void AddRibbonCountWindow(struct PokenavSub14 *structPtr); void sub_81D1448(struct PokenavSub14 *structPtr); void sub_81D13FC(struct PokenavSub14 *structPtr); -void sub_81D0FCC(struct PokenavSub14 *structPtr); +void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *structPtr); void sub_81D12D8(struct PokenavSub14 *structPtr); bool32 sub_81D1524(struct PokenavSub14 *structPtr); bool32 sub_81D1234(struct PokenavSub14 *structPtr); void sub_81D0814(struct PokenavSub13 *structPtr); -u32 sub_81D0548(struct PokenavSub13 *structPtr); -u32 sub_81D04C4(struct PokenavSub13 *structPtr); -u32 sub_81D05D4(struct PokenavSub13 *structPtr); +u32 HandleExpandedRibbonInput(struct PokenavSub13 *structPtr); +u32 RibbonsSummaryHandleInput(struct PokenavSub13 *structPtr); +u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *structPtr); bool32 sub_81D05DC(struct PokenavSub13 *structPtr); bool32 sub_81D0688(struct PokenavSub13 *structPtr); bool32 sub_81D0664(struct PokenavSub13 *structPtr); bool32 sub_81D061C(struct PokenavSub13 *structPtr); bool32 sub_81D0688(struct PokenavSub13 *structPtr); -bool32 sub_81D0A58(void); -u32 sub_81D06C4(void); -u32 sub_81D06D4(void); -u16 sub_81D1184(s32 unused0, s32 unused1); +bool32 GetCurrentLoopedTaskActive(void); +u32 GetRibbonsSummaryCurrentIndex(void); +u32 GetRibbonsSummaryMonListCount(void); +u16 DrawRibbonsMonFrontPic(s32 unused0, s32 unused1); void sub_81D1258(struct Sprite *sprite, s32 arg1, s32 arg2, s32 arg3); void sub_81D1284(struct Sprite *sprite); void sub_81D1350(void); void sub_81D13BC(u16 *dst, u32 id); void sub_81D1370(u32 arg0, u32 id); void sub_81D1538(struct Sprite *sprite); -u32 sub_81D0A6C(s32 state); -u32 sub_81D0C84(s32 state); -u32 sub_81D0D2C(s32 state); -u32 sub_81D0D8C(s32 state); -u32 sub_81D0E00(s32 state); -u32 sub_81D0C54(s32 state); +u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state); +u32 LoopedTask_UpdateRibbonsSummaryInfo(s32 state); +u32 LoopedTask_ExpandSelectedRibbon(s32 state); +u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state); +u32 LoopedTask_ShrinkExpandedRibbon(s32 state); +u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state); struct { @@ -147,95 +157,95 @@ static const struct BgTemplate gUnknown_08624B98[] = } }; -static const LoopedTask gUnknown_08624BA0[] = +static const LoopedTask sRibbonsSummaryMenuLoopTaskFuncs[] = { - NULL, - sub_81D0C84, - sub_81D0D2C, - sub_81D0D8C, - sub_81D0E00, - sub_81D0C54 + [RIBBONS_SUMMARY_FUNC_NONE] = NULL, + [RIBBONS_SUMMARY_FUNC_MOVED_CURSOR] = LoopedTask_UpdateRibbonsSummaryInfo, + [RIBBONS_SUMMARY_FUNC_SELECT_RIBBON] = LoopedTask_ExpandSelectedRibbon, + [RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE] = LoopedTask_MoveRibbonsCursorExpanded, + [RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL] = LoopedTask_ShrinkExpandedRibbon, + [RIBBONS_SUMMARY_FUNC_EXIT] = LoopedTask_ExitRibbonsSummaryMenu }; // code -bool32 PokenavCallback_Init_13(void) +bool32 PokenavCallback_Init_RibbonsSummaryMenu(void) { - struct PokenavSub13 *structPtr = AllocSubstruct(13, sizeof(struct PokenavSub13)); + struct PokenavSub13 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, sizeof(struct PokenavSub13)); if (structPtr == NULL) return FALSE; - structPtr->field_8 = GetSubstructPtr(18); - if (structPtr->field_8 == NULL) + structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); + if (structPtr->monList == NULL) return FALSE; sub_81D0814(structPtr); - structPtr->field_98 = sub_81D04C4; + structPtr->callback = RibbonsSummaryHandleInput; gKeyRepeatContinueDelay = 3; gKeyRepeatStartDelay = 10; return TRUE; } -u32 sub_81D04A0(void) +u32 GetRibbonsSummaryMenuCallback(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); - return structPtr->field_98(structPtr); + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + return structPtr->callback(structPtr); } -void sub_81D04B8(void) +void FreeRibbonsSummaryScreen1(void) { - FreePokenavSubstruct(13); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); } -u32 sub_81D04C4(struct PokenavSub13 *structPtr) +u32 RibbonsSummaryHandleInput(struct PokenavSub13 *structPtr) { - if (JOY_REPEAT(DPAD_UP) && structPtr->field_8->unk2 != 0) + if (JOY_REPEAT(DPAD_UP) && structPtr->monList->currIndex != 0) { - structPtr->field_8->unk2--; + structPtr->monList->currIndex--; structPtr->field_C = 0; sub_81D0814(structPtr); - return 1; + return RIBBONS_SUMMARY_FUNC_MOVED_CURSOR; } - if (JOY_REPEAT(DPAD_DOWN) && structPtr->field_8->unk2 < structPtr->field_8->unk0 - 1) + if (JOY_REPEAT(DPAD_DOWN) && structPtr->monList->currIndex < structPtr->monList->listCount - 1) { - structPtr->field_8->unk2++; + structPtr->monList->currIndex++; structPtr->field_C = 0; sub_81D0814(structPtr); - return 1; + return RIBBONS_SUMMARY_FUNC_MOVED_CURSOR; } if (JOY_NEW(A_BUTTON)) { - structPtr->field_98 = sub_81D0548; - return 2; + structPtr->callback = HandleExpandedRibbonInput; + return RIBBONS_SUMMARY_FUNC_SELECT_RIBBON; } if (JOY_NEW(B_BUTTON)) { - structPtr->field_98 = sub_81D05D4; - return 5; + structPtr->callback = ReturnToRibbonsListFromSummary; + return RIBBONS_SUMMARY_FUNC_EXIT; } - return 0; + return RIBBONS_SUMMARY_FUNC_NONE; } -u32 sub_81D0548(struct PokenavSub13 *structPtr) +u32 HandleExpandedRibbonInput(struct PokenavSub13 *structPtr) { if (JOY_REPEAT(DPAD_UP) && sub_81D05DC(structPtr)) - return 3; + return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE; if (JOY_REPEAT(DPAD_DOWN) && sub_81D061C(structPtr)) - return 3; + return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE; if (JOY_REPEAT(DPAD_LEFT) && sub_81D0664(structPtr)) - return 3; + return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE; if (JOY_REPEAT(DPAD_RIGHT) && sub_81D0688(structPtr)) - return 3; + return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE; if (JOY_NEW(B_BUTTON)) { - structPtr->field_98 = sub_81D04C4; - return 4; + structPtr->callback = RibbonsSummaryHandleInput; + return RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL; } - return 0; + return RIBBONS_SUMMARY_FUNC_NONE; } -u32 sub_81D05D4(struct PokenavSub13 *structPtr) +u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *structPtr) { - return POKENAV_MENU_E; + return POKENAV_RIBBONS_RETURN_TO_MON_LIST; } bool32 sub_81D05DC(struct PokenavSub13 *structPtr) @@ -320,23 +330,23 @@ bool32 sub_81D0688(struct PokenavSub13 *structPtr) return FALSE; } -u32 sub_81D06C4(void) +u32 GetRibbonsSummaryCurrentIndex(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); - return structPtr->field_8->unk2; + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + return structPtr->monList->currIndex; } -u32 sub_81D06D4(void) +u32 GetRibbonsSummaryMonListCount(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); - return structPtr->field_8->unk0; + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + return structPtr->monList->listCount; } static void GetCurrMonInfo1(u8 *nick, u8 *level, u8 *gender) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); - struct PokenavSub18 *mons = structPtr->field_8; - struct PokenavMonList *monInfo = &mons->unk4[mons->unk2]; + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + struct PokenavSub18 *mons = structPtr->monList; + struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) { @@ -357,9 +367,9 @@ static void GetCurrMonInfo1(u8 *nick, u8 *level, u8 *gender) static void GetCurrMonInfo2(u16 *species, u32 *personality, u32 *otId) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); - struct PokenavSub18 *mons = structPtr->field_8; - struct PokenavMonList *monInfo = &mons->unk4[mons->unk2]; + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + struct PokenavSub18 *mons = structPtr->monList; + struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) { @@ -379,9 +389,9 @@ static void GetCurrMonInfo2(u16 *species, u32 *personality, u32 *otId) static u32 GetCurrMonRibbonCount(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); - struct PokenavSub18 *mons = structPtr->field_8; - struct PokenavMonList *monInfo = &mons->unk4[mons->unk2]; + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); + struct PokenavSub18 *mons = structPtr->monList; + struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) return GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBON_COUNT); @@ -393,8 +403,8 @@ void sub_81D0814(struct PokenavSub13 *structPtr) { u32 ribbons; s32 i, j; - struct PokenavSub18 *mons = structPtr->field_8; - struct PokenavMonList *monInfo = &mons->unk4[mons->unk2]; + struct PokenavSub18 *mons = structPtr->monList; + struct PokenavMonList *monInfo = &mons->monData[mons->currIndex]; if (monInfo->boxId == TOTAL_BOXES_COUNT) ribbons = GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBONS); @@ -433,27 +443,27 @@ void sub_81D0814(struct PokenavSub13 *structPtr) u32 *sub_81D0914(u32 *arg0) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); *arg0 = structPtr->field_10; return structPtr->field_14; } u32 *sub_81D092C(u32 *arg0) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); *arg0 = structPtr->field_12; return structPtr->field_78; } u16 sub_81D0944(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); return structPtr->field_C; } u32 sub_81D0954(void) { - struct PokenavSub13 *structPtr = GetSubstructPtr(13); + struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST); int var = structPtr->field_C; if (var <= 24) return structPtr->field_14[var]; @@ -461,38 +471,38 @@ u32 sub_81D0954(void) return structPtr->field_78[var - 27]; } -bool32 sub_81D0978(void) +bool32 OpenRibbonsSummaryMenu(void) { - struct PokenavSub14 *structPtr = AllocSubstruct(14, sizeof(struct PokenavSub14)); + struct PokenavSub14 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, sizeof(struct PokenavSub14)); if (structPtr == NULL) return FALSE; - structPtr->loopedTaskId = CreateLoopedTask(sub_81D0A6C, 1); - structPtr->field_0 = sub_81D0A58; + structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsSummaryMenu, 1); + structPtr->callback = GetCurrentLoopedTaskActive; return TRUE; } -void sub_81D09B0(s32 id) +void CreateRibbonsSummaryLoopedTask(s32 id) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); - structPtr->loopedTaskId = CreateLoopedTask(gUnknown_08624BA0[id], 1); - structPtr->field_0 = sub_81D0A58; + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + structPtr->loopedTaskId = CreateLoopedTask(sRibbonsSummaryMenuLoopTaskFuncs[id], 1); + structPtr->callback = GetCurrentLoopedTaskActive; } -u32 sub_81D09E0(void) +u32 IsRibbonsSummaryLoopedTaskActive(void) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); - return structPtr->field_0(); + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + return structPtr->callback(); } -void sub_81D09F4(void) +void FreeRibbonsSummaryScreen2(void) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); - RemoveWindow(structPtr->field_A); - RemoveWindow(structPtr->field_8); - RemoveWindow(structPtr->field_C); + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); + RemoveWindow(structPtr->ribbonCountWindowId); + RemoveWindow(structPtr->nameWindowId); + RemoveWindow(structPtr->listIdxWindowId); RemoveWindow(structPtr->field_E); - sub_81D1178(structPtr); + DestroyRibbonsMonFrontPic(structPtr); FreeSpriteTilesByTag(9); FreeSpritePaletteByTag(0xF); FreeSpritePaletteByTag(0x10); @@ -501,18 +511,18 @@ void sub_81D09F4(void) FreeSpritePaletteByTag(0x13); FreeSpriteOamMatrix(structPtr->field_14); DestroySprite(structPtr->field_14); - FreePokenavSubstruct(14); + FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); } -bool32 sub_81D0A58(void) +bool32 GetCurrentLoopedTaskActive(void) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); return IsLoopedTaskActive(structPtr->loopedTaskId); } -u32 sub_81D0A6C(s32 state) +u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: @@ -539,21 +549,21 @@ u32 sub_81D0A6C(s32 state) case 2: if (!FreeTempTileDataBuffersIfPossible()) { - sub_81D0E60(structPtr); + AddRibbonCountWindow(structPtr); return LT_INC_AND_PAUSE; } return LT_PAUSE; case 3: if (!FreeTempTileDataBuffersIfPossible()) { - sub_81D0FCC(structPtr); + AddRibbonSummaryMonNameWindow(structPtr); return LT_INC_AND_PAUSE; } return LT_PAUSE; case 4: if (!FreeTempTileDataBuffersIfPossible()) { - sub_81D10A4(structPtr); + AddRibbonListIndexWindow(structPtr); return LT_INC_AND_PAUSE; } return LT_PAUSE; @@ -567,7 +577,7 @@ u32 sub_81D0A6C(s32 state) case 6: if (!IsDma3ManagerBusyWithBgCopy()) { - sub_81D1148(structPtr); + ResetSpritesAndDrawRibbonsMonFrontPic(structPtr); return LT_INC_AND_CONTINUE; } return LT_PAUSE; @@ -598,7 +608,7 @@ u32 sub_81D0A6C(s32 state) return LT_FINISH; } -u32 sub_81D0C54(s32 state) +u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state) { switch (state) { @@ -614,9 +624,9 @@ u32 sub_81D0C54(s32 state) return LT_FINISH; } -u32 sub_81D0C84(s32 state) +u32 LoopedTask_UpdateRibbonsSummaryInfo(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: @@ -626,7 +636,7 @@ u32 sub_81D0C84(s32 state) case 1: if (!sub_81D1234(structPtr)) { - sub_81D0FF0(structPtr); + PrintRibbbonsSummaryMonInfo(structPtr); return LT_INC_AND_CONTINUE; } return LT_PAUSE; @@ -634,10 +644,10 @@ u32 sub_81D0C84(s32 state) sub_81D12D8(structPtr); return LT_INC_AND_CONTINUE; case 3: - sub_81D10D0(structPtr); + PrintRibbonsMonListIndex(structPtr); return LT_INC_AND_CONTINUE; case 4: - sub_81D0E84(structPtr); + PrintCurrentMonRibbonCount(structPtr); return LT_INC_AND_CONTINUE; case 5: if (!IsDma3ManagerBusyWithBgCopy()) @@ -654,9 +664,9 @@ u32 sub_81D0C84(s32 state) return LT_FINISH; } -u32 sub_81D0D2C(s32 state) +u32 LoopedTask_ExpandSelectedRibbon(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: @@ -678,9 +688,9 @@ u32 sub_81D0D2C(s32 state) return LT_FINISH; } -u32 sub_81D0D8C(s32 state) +u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: @@ -708,9 +718,9 @@ u32 sub_81D0D8C(s32 state) return LT_FINISH; } -u32 sub_81D0E00(s32 state) +u32 LoopedTask_ShrinkExpandedRibbon(s32 state) { - struct PokenavSub14 *structPtr = GetSubstructPtr(14); + struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU); switch (state) { case 0: @@ -720,7 +730,7 @@ u32 sub_81D0E00(s32 state) case 1: if (!sub_81D1524(structPtr)) { - sub_81D0E84(structPtr); + PrintCurrentMonRibbonCount(structPtr); PrintHelpBarText(HELPBAR_RIBBONS_LIST); return LT_INC_AND_PAUSE; } @@ -732,7 +742,7 @@ u32 sub_81D0E00(s32 state) return LT_FINISH; } -static const struct WindowTemplate gUnknown_08624BB8 = +static const struct WindowTemplate sRibbonCountWindowTemplate = { .bg = 2, .tilemapLeft = 12, @@ -743,14 +753,14 @@ static const struct WindowTemplate gUnknown_08624BB8 = .baseBlock = 0x14, }; -void sub_81D0E60(struct PokenavSub14 *structPtr) +void AddRibbonCountWindow(struct PokenavSub14 *structPtr) { - structPtr->field_A = AddWindow(&gUnknown_08624BB8); - PutWindowTilemap(structPtr->field_A); - sub_81D0E84(structPtr); + structPtr->ribbonCountWindowId = AddWindow(&sRibbonCountWindowTemplate); + PutWindowTilemap(structPtr->ribbonCountWindowId); + PrintCurrentMonRibbonCount(structPtr); } -void sub_81D0E84(struct PokenavSub14 *structPtr) +void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr) { u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY}; @@ -758,9 +768,9 @@ void sub_81D0E84(struct PokenavSub14 *structPtr) DynamicPlaceholderTextUtil_Reset(); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_RibbonsF700); - FillWindowPixelBuffer(structPtr->field_A, PIXEL_FILL(4)); - AddTextPrinterParameterized3(structPtr->field_A, 1, 0, 1, color, -1, gStringVar4); - CopyWindowToVram(structPtr->field_A, 2); + FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4)); + AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, 1, 0, 1, color, -1, gStringVar4); + CopyWindowToVram(structPtr->ribbonCountWindowId, 2); } void sub_81D0EFC(struct PokenavSub14 *structPtr) @@ -769,11 +779,11 @@ void sub_81D0EFC(struct PokenavSub14 *structPtr) u32 ribbonId = sub_81D0954(); u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY}; - FillWindowPixelBuffer(structPtr->field_A, PIXEL_FILL(4)); + FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4)); if (ribbonId < 25) { for (i = 0; i < 2; i++) - AddTextPrinterParameterized3(structPtr->field_A, 1, 0, (i * 16) + 1, color, -1, gRibbonDescriptionPointers[ribbonId][i]); + AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, 1, 0, (i * 16) + 1, color, -1, gRibbonDescriptionPointers[ribbonId][i]); } else { @@ -783,13 +793,13 @@ void sub_81D0EFC(struct PokenavSub14 *structPtr) ribbonId--; for (i = 0; i < 2; i++) - AddTextPrinterParameterized3(structPtr->field_A, 1, 0, (i * 16) + 1, color, -1, gGiftRibbonDescriptionPointers[ribbonId][i]); + AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, 1, 0, (i * 16) + 1, color, -1, gGiftRibbonDescriptionPointers[ribbonId][i]); } - CopyWindowToVram(structPtr->field_A, 2); + CopyWindowToVram(structPtr->ribbonCountWindowId, 2); } -static const struct WindowTemplate gUnknown_08624BC4 = +static const struct WindowTemplate sRibbonSummaryMonNameWindowTemplate = { .bg = 2, .tilemapLeft = 14, @@ -800,23 +810,23 @@ static const struct WindowTemplate gUnknown_08624BC4 = .baseBlock = 0x54, }; -void sub_81D0FCC(struct PokenavSub14 *structPtr) +void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *structPtr) { - structPtr->field_8 = AddWindow(&gUnknown_08624BC4); - PutWindowTilemap(structPtr->field_8); - sub_81D0FF0(structPtr); + structPtr->nameWindowId = AddWindow(&sRibbonSummaryMonNameWindowTemplate); + PutWindowTilemap(structPtr->nameWindowId); + PrintRibbbonsSummaryMonInfo(structPtr); } static const u8 sMaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); static const u8 sFemaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); static const u8 sGenderlessIconString[] = _("{UNK_SPACER}"); -void sub_81D0FF0(struct PokenavSub14 *structPtr) +void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr) { const u8 *genderTxt; u8 *txtPtr; u8 level, gender; - u16 windowId = structPtr->field_8; + u16 windowId = structPtr->nameWindowId; FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); GetCurrMonInfo1(gStringVar3, &level, &gender); @@ -843,7 +853,7 @@ void sub_81D0FF0(struct PokenavSub14 *structPtr) CopyWindowToVram(windowId, 2); } -static const struct WindowTemplate gUnknown_08624BE8[] = +static const struct WindowTemplate sRibbonMonListIndexWindowTemplate[] = { { .bg = 2, @@ -857,46 +867,46 @@ static const struct WindowTemplate gUnknown_08624BE8[] = {}, }; -void sub_81D10A4(struct PokenavSub14 *structPtr) +void AddRibbonListIndexWindow(struct PokenavSub14 *structPtr) { - structPtr->field_C = AddWindow(gUnknown_08624BE8); - FillWindowPixelBuffer(structPtr->field_C, PIXEL_FILL(1)); - PutWindowTilemap(structPtr->field_C); - sub_81D10D0(structPtr); + structPtr->listIdxWindowId = AddWindow(sRibbonMonListIndexWindowTemplate); + FillWindowPixelBuffer(structPtr->listIdxWindowId, PIXEL_FILL(1)); + PutWindowTilemap(structPtr->listIdxWindowId); + PrintRibbonsMonListIndex(structPtr); } -void sub_81D10D0(struct PokenavSub14 *structPtr) +void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr) { s32 x; u8 *txtPtr; - u32 id = sub_81D06C4() + 1; - u32 count = sub_81D06D4(); + u32 id = GetRibbonsSummaryCurrentIndex() + 1; + u32 count = GetRibbonsSummaryMonListCount(); txtPtr = ConvertIntToDecimalStringN(gStringVar1, id, STR_CONV_MODE_RIGHT_ALIGN, 3); *(txtPtr++) = CHAR_SLASH; ConvertIntToDecimalStringN(txtPtr, count, STR_CONV_MODE_RIGHT_ALIGN, 3); x = GetStringCenterAlignXOffset(1, gStringVar1, 56); - AddTextPrinterParameterized(structPtr->field_C, 1, gStringVar1, x, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(structPtr->field_C, 2); + AddTextPrinterParameterized(structPtr->listIdxWindowId, 1, gStringVar1, x, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(structPtr->listIdxWindowId, 2); } -void sub_81D1148(struct PokenavSub14 *structPtr) +void ResetSpritesAndDrawRibbonsMonFrontPic(struct PokenavSub14 *structPtr) { u16 species; u32 personality, otId; GetCurrMonInfo2(&species, &personality, &otId); ResetAllPicSprites(); - structPtr->field_10 = sub_81D1184(40, 104); - sub_81C7990(15, 0); + structPtr->monSpriteId = DrawRibbonsMonFrontPic(40, 104); + PokenavFillPalette(15, 0); } -void sub_81D1178(struct PokenavSub14 *structPtr) +void DestroyRibbonsMonFrontPic(struct PokenavSub14 *structPtr) { - FreeAndDestroyMonPicSprite(structPtr->field_10); + FreeAndDestroyMonPicSprite(structPtr->monSpriteId); } -u16 sub_81D1184(s32 unused0, s32 unused1) +u16 DrawRibbonsMonFrontPic(s32 unused0, s32 unused1) { u16 species, spriteId; u32 personality, otId; @@ -909,19 +919,19 @@ u16 sub_81D1184(s32 unused0, s32 unused1) void sub_81D11D8(struct PokenavSub14 *structPtr) { - sub_81D1258(&gSprites[structPtr->field_10], 40, -32, 6); + sub_81D1258(&gSprites[structPtr->monSpriteId], 40, -32, 6); } void sub_81D11FC(struct PokenavSub14 *structPtr) { - FreeAndDestroyMonPicSprite(structPtr->field_10); - structPtr->field_10 = sub_81D1184(-32, 104); - sub_81D1258(&gSprites[structPtr->field_10], -32, 40, 6); + FreeAndDestroyMonPicSprite(structPtr->monSpriteId); + structPtr->monSpriteId = DrawRibbonsMonFrontPic(-32, 104); + sub_81D1258(&gSprites[structPtr->monSpriteId], -32, 40, 6); } bool32 sub_81D1234(struct PokenavSub14 *structPtr) { - return (gSprites[structPtr->field_10].callback != SpriteCallbackDummy); + return (gSprites[structPtr->monSpriteId].callback != SpriteCallbackDummy); } void sub_81D1258(struct Sprite *sprite, s32 arg1, s32 arg2, s32 arg3) diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index ebb237d54..1af157b90 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -486,7 +486,7 @@ static void LoadUsePokeblockMenu(void) { case 0: sMenu->curMonSpriteId = 0xFF; - sub_81D1ED4(&sMenu->graph); + InitConditionGraphData(&sMenu->graph); sInfo->mainState++; break; case 1: @@ -536,12 +536,12 @@ static void LoadUsePokeblockMenu(void) sInfo->mainState++; break; case 11: - sub_81D2754(sMenu->graph.unk0[0], sMenu->graph.unk14[0]); - sub_81D20AC(&sMenu->graph); + sub_81D2754(sMenu->graph.stat[0], sMenu->graph.unk14[0]); + InitConditionGraphState(&sMenu->graph); sInfo->mainState++; break; case 12: - if (!sub_81D20BC(&sMenu->graph)) + if (!SetupConditionGraphScanlineParams(&sMenu->graph)) { sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[0], sMenu->graph.unk14[0]); sInfo->mainState++; @@ -1368,7 +1368,7 @@ static bool8 LoadUsePokeblockMenuGfx(void) LoadBgTilemap(2, sMenu->tilemapBuffer, 1280, 0); LoadPalette(gConditionGraphData_Pal, 48, 32); LoadPalette(gConditionText_Pal, 240, 32); - sub_81D21DC(2); + SetConditionGraphIOWindows(2); break; default: sMenu->info.helperState = 0; From 52ebc4252e0752ab3b918d4637c4c2672f033610 Mon Sep 17 00:00:00 2001 From: kageru Date: Wed, 7 Oct 2020 23:03:46 +0200 Subject: [PATCH 2/5] Document gUnknown_03006298 --- common_syms/battle_tower.txt | 2 +- include/battle_tower.h | 4 +++- src/battle_factory.c | 12 ++++++------ src/battle_tent.c | 2 +- src/battle_tower.c | 34 +++++++++++++++++----------------- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/common_syms/battle_tower.txt b/common_syms/battle_tower.txt index dd198e229..7371109d5 100644 --- a/common_syms/battle_tower.txt +++ b/common_syms/battle_tower.txt @@ -1 +1 @@ -gUnknown_03006298 +gFrontierTempParty diff --git a/include/battle_tower.h b/include/battle_tower.h index 3bf2f004b..30649719b 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -43,7 +43,9 @@ extern const struct BattleFrontierTrainer gBattleFrontierTrainers[]; extern const struct FacilityMon gSlateportBattleTentMons[]; extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[]; -extern u16 gUnknown_03006298[]; +// Temporary storage for monIds of the opponent team +// during team generation in battle factory and similar facilities. +extern u16 gFrontierTempParty[]; extern const struct BattleFrontierTrainer *gFacilityTrainers; extern const struct FacilityMon *gFacilityTrainerMons; diff --git a/src/battle_factory.c b/src/battle_factory.c index 021081483..a2b1d337a 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -207,7 +207,7 @@ static void InitFactoryChallenge(void) for (i = 0; i < 6; i++) gSaveBlock2Ptr->frontier.rentalMons[i].monId = 0xFFFF; for (i = 0; i < FRONTIER_PARTY_SIZE; i++) - gUnknown_03006298[i] = 0xFFFF; + gFrontierTempParty[i] = 0xFFFF; SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); gTrainerBattleOpponent_A = 0; @@ -355,7 +355,7 @@ static void GenerateOpponentMons(void) species[i] = gFacilityTrainerMons[monId].species; heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]; - gUnknown_03006298[i] = monId; + gFrontierTempParty[i] = monId; i++; } } @@ -376,11 +376,11 @@ static void SetRentalsToOpponentParty(void) for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { - gSaveBlock2Ptr->frontier.rentalMons[i + 3].monId = gUnknown_03006298[i]; + gSaveBlock2Ptr->frontier.rentalMons[i + 3].monId = gFrontierTempParty[i]; gSaveBlock2Ptr->frontier.rentalMons[i + 3].ivs = GetBoxMonData(&gEnemyParty[i].box, MON_DATA_ATK_IV, NULL); gSaveBlock2Ptr->frontier.rentalMons[i + 3].personality = GetMonData(&gEnemyParty[i], MON_DATA_PERSONALITY, NULL); gSaveBlock2Ptr->frontier.rentalMons[i + 3].abilityNum = GetBoxMonData(&gEnemyParty[i].box, MON_DATA_ABILITY_NUM, NULL); - SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[gUnknown_03006298[i]].itemTableId]); + SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[gFrontierTempParty[i]].itemTableId]); } } @@ -595,7 +595,7 @@ static void GetOpponentMostCommonMonType(void) typesCount[i] = 0; for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { - u32 species = gFacilityTrainerMons[gUnknown_03006298[i]].species; + u32 species = gFacilityTrainerMons[gFrontierTempParty[i]].species; typesCount[gBaseStats[species].type1]++; if (gBaseStats[species].type1 != gBaseStats[species].type2) @@ -631,7 +631,7 @@ static void GetOpponentBattleStyle(void) for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { - u16 monId = gUnknown_03006298[i]; + u16 monId = gFrontierTempParty[i]; for (j = 0; j < MAX_MON_MOVES; j++) { u8 battleStyle = GetMoveBattleStyle(gFacilityTrainerMons[monId].moves[j]); diff --git a/src/battle_tent.c b/src/battle_tent.c index ba0c14dff..de0ecea98 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -420,7 +420,7 @@ static void GenerateOpponentMons(void) species[i] = gFacilityTrainerMons[sRandMonSetId].species; heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId]; - gUnknown_03006298[i] = sRandMonSetId; + gFrontierTempParty[i] = sRandMonSetId; i++; } } diff --git a/src/battle_tower.c b/src/battle_tower.c index 9852a0eac..046362105 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -46,7 +46,7 @@ EWRAM_DATA const struct BattleFrontierTrainer *gFacilityTrainers = NULL; EWRAM_DATA const struct FacilityMon *gFacilityTrainerMons = NULL; // IWRAM common -u16 gUnknown_03006298[MAX_FRONTIER_PARTY_SIZE]; +u16 gFrontierTempParty[MAX_FRONTIER_PARTY_SIZE]; // This file's functions. static void InitTowerChallenge(void); @@ -1856,7 +1856,7 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId) otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId); for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { - u16 monId = gUnknown_03006298[i]; + u16 monId = gFrontierTempParty[i]; CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i], gFacilityTrainerMons[monId].species, level, @@ -1884,7 +1884,7 @@ static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId) for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { - u16 monId = gUnknown_03006298[i]; + u16 monId = gFrontierTempParty[i]; CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i], gFacilityTrainerMons[monId].species, level, @@ -2224,11 +2224,11 @@ static void GetApprenticeMultiPartnerParty(u16 trainerId) } } - gUnknown_03006298[0] = validSpecies[Random() % count]; + gFrontierTempParty[0] = validSpecies[Random() % count]; do { - gUnknown_03006298[1] = validSpecies[Random() % count]; - } while (gUnknown_03006298[0] == gUnknown_03006298[1]); + gFrontierTempParty[1] = validSpecies[Random() % count]; + } while (gFrontierTempParty[0] == gFrontierTempParty[1]); } static void GetRecordMixFriendMultiPartnerParty(u16 trainerId) @@ -2252,11 +2252,11 @@ static void GetRecordMixFriendMultiPartnerParty(u16 trainerId) } } - gUnknown_03006298[2] = validSpecies[Random() % count]; + gFrontierTempParty[2] = validSpecies[Random() % count]; do { - gUnknown_03006298[3] = validSpecies[Random() % count]; - } while (gUnknown_03006298[2] == gUnknown_03006298[3]); + gFrontierTempParty[3] = validSpecies[Random() % count]; + } while (gFrontierTempParty[2] == gFrontierTempParty[3]); } static void LoadMultiPartnerCandidatesData(void) @@ -2420,15 +2420,15 @@ static void sub_81646BC(u16 trainerId, u16 monId) } else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) { - move = gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[gUnknown_03006298[gSpecialVar_0x8005 + 1]].moves[0]; - species = gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[gUnknown_03006298[gSpecialVar_0x8005 + 1]].species; + move = gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[gFrontierTempParty[gSpecialVar_0x8005 + 1]].moves[0]; + species = gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[gFrontierTempParty[gSpecialVar_0x8005 + 1]].species; } else { s32 i; - move = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[gUnknown_03006298[gSpecialVar_0x8005 - 1]].moves[0]; - species = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[gUnknown_03006298[gSpecialVar_0x8005 - 1]].species; + move = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[gFrontierTempParty[gSpecialVar_0x8005 - 1]].moves[0]; + species = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[gFrontierTempParty[gSpecialVar_0x8005 - 1]].species; for (i = 0; i < PLAYER_NAME_LENGTH; i++) gStringVar3[i] = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].playerName[i]; gStringVar3[i] = EOS; @@ -2497,13 +2497,13 @@ static void ShowPartnerCandidateMessage(void) } else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) { - gSaveBlock2Ptr->frontier.trainerIds[18] = gUnknown_03006298[2]; - gSaveBlock2Ptr->frontier.trainerIds[19] = gUnknown_03006298[3]; + gSaveBlock2Ptr->frontier.trainerIds[18] = gFrontierTempParty[2]; + gSaveBlock2Ptr->frontier.trainerIds[19] = gFrontierTempParty[3]; } else { - gSaveBlock2Ptr->frontier.trainerIds[18] = gUnknown_03006298[0]; - gSaveBlock2Ptr->frontier.trainerIds[19] = gUnknown_03006298[1]; + gSaveBlock2Ptr->frontier.trainerIds[18] = gFrontierTempParty[0]; + gSaveBlock2Ptr->frontier.trainerIds[19] = gFrontierTempParty[1]; } for (k = 0; k < 14; k++) { From f4909b4d964100b2e2dde75582ad647ef80fc6a8 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 11 Oct 2020 08:50:58 -0600 Subject: [PATCH 3/5] align pokenav task funcs and update some pokenav menu bg gfx files --- graphics/pokenav/{bg.bin => bg_dots.bin} | 0 graphics/pokenav/{bg.png => bg_dots.png} | Bin .../{outline.png => device_outline.png} | Bin ...outline_map.bin => device_outline_map.bin} | Bin include/pokenav.h | 2 +- src/pokenav.c | 2 +- src/pokenav_conditions_2.c | 14 ++++---- src/pokenav_conditions_3.c | 30 +++++++++--------- src/pokenav_match_call_2.c | 30 +++++++++--------- src/pokenav_menu_handler_2.c | 21 ++++++------ src/pokenav_ribbons_2.c | 10 +++--- 11 files changed, 55 insertions(+), 54 deletions(-) rename graphics/pokenav/{bg.bin => bg_dots.bin} (100%) rename graphics/pokenav/{bg.png => bg_dots.png} (100%) rename graphics/pokenav/{outline.png => device_outline.png} (100%) rename graphics/pokenav/{outline_map.bin => device_outline_map.bin} (100%) diff --git a/graphics/pokenav/bg.bin b/graphics/pokenav/bg_dots.bin similarity index 100% rename from graphics/pokenav/bg.bin rename to graphics/pokenav/bg_dots.bin diff --git a/graphics/pokenav/bg.png b/graphics/pokenav/bg_dots.png similarity index 100% rename from graphics/pokenav/bg.png rename to graphics/pokenav/bg_dots.png diff --git a/graphics/pokenav/outline.png b/graphics/pokenav/device_outline.png similarity index 100% rename from graphics/pokenav/outline.png rename to graphics/pokenav/device_outline.png diff --git a/graphics/pokenav/outline_map.bin b/graphics/pokenav/device_outline_map.bin similarity index 100% rename from graphics/pokenav/outline_map.bin rename to graphics/pokenav/device_outline_map.bin diff --git a/include/pokenav.h b/include/pokenav.h index 34692236d..3fc01ede3 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -122,7 +122,7 @@ enum POKENAV_REGION_MAP, POKENAV_CONDITION_PARTY, POKENAV_CONDITION_SEARCH_RESULTS, - POKENAV_MENU_CONDITION_GRAPH_FROM_SEARCH, // opening condition graph from search list + POKENAV_CONDITION_GRAPH_FROM_SEARCH, // opening condition graph from search list POKENAV_RETURN_CONDITION_SEARCH, //return to search list from condition graph POKENAV_MATCH_CALL, POKENAV_RIBBONS_MON_LIST, diff --git a/src/pokenav.c b/src/pokenav.c index 12a13509b..9f9cf7dee 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -142,7 +142,7 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] = .free1 = FreeSearchResultSubstruct1, .free2 = FreeSearchResultSubstruct2, }, - [POKENAV_MENU_CONDITION_GRAPH_FROM_SEARCH - POKENAV_MENU_IDS_START] = + [POKENAV_CONDITION_GRAPH_FROM_SEARCH - POKENAV_MENU_IDS_START] = { .init = PokenavCallback_Init_ConditionGraphFromSearch, .callback = GetPartyConditionCallback, diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index dc845ecab..c0e8c7d6d 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -107,12 +107,12 @@ const struct WindowTemplate sUnusedWindowTemplate2 = const LoopedTask sPartyConditionLoopedTaskFuncs[] = { - [PARTY_CONDITION_FUNC_NONE] = NULL, - [PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons, - [PARTY_CONDITION_FUNC_RETURN] = LoopedTask_ExitPartyConditionMenu, - [PARTY_CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition, - [PARTY_CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut, - [PARTY_CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow, + [PARTY_CONDITION_FUNC_NONE] = NULL, + [PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons, + [PARTY_CONDITION_FUNC_RETURN] = LoopedTask_ExitPartyConditionMenu, + [PARTY_CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition, + [PARTY_CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut, + [PARTY_CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow, [PARTY_CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow }; @@ -139,7 +139,7 @@ struct Pokenav7Struct u8 filler2[0x38ac - 0x2909]; }; -extern s8 GetMonMarkIndex(void); // This function's declaration here is different than its definition in pokenav_unk_6. u8/s8 +extern s8 GetMonMarkIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c u32 LoopedTask_OpenPartyConditionGraph(s32 state); u32 GetPartyConditionLoopedTaskActive(void); diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index c93544c52..196484df7 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -29,7 +29,7 @@ struct PokenavSub7 s32 boxId; s32 monId; u32 conditionDataId; - u32 unk18; + u32 returnFromGraph; u32 isPartyCondition; struct PokenavSub18 *monList; }; @@ -45,7 +45,7 @@ struct PokenavSub8 static u32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr); static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr); -static u32 sub_81CF0B8(struct PokenavSub7 *structPtr); +static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr); static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr); static u32 GetConditionSearchLoopedTask(s32 state); static u32 BuildPartyMonSearchResults(s32 state); @@ -104,12 +104,12 @@ static const struct BgTemplate sConditionSearchResultBgTemplates[] = static const LoopedTask sSearchResultLoopTaskFuncs[] = { - [CONDITION_SEARCH_FUNC_NONE] = NULL, - [CONDITION_SEARCH_FUNC_MOVE_UP] = LoopedTask_MoveSearchListCursorUp, - [CONDITION_SEARCH_FUNC_MOVE_DOWN] = LoopedTask_MoveSearchListCursorDown, - [CONDITION_SEARCH_FUNC_PAGE_UP] = LoopedTask_MoveSearchListPageUp, - [CONDITION_SEARCH_FUNC_PAGE_DOWN] = LoopedTask_MoveSearchListPageDown, - [CONDITION_SEARCH_FUNC_EXIT] = LoopedTask_ExitConditionSearchMenu, + [CONDITION_SEARCH_FUNC_NONE] = NULL, + [CONDITION_SEARCH_FUNC_MOVE_UP] = LoopedTask_MoveSearchListCursorUp, + [CONDITION_SEARCH_FUNC_MOVE_DOWN] = LoopedTask_MoveSearchListCursorDown, + [CONDITION_SEARCH_FUNC_PAGE_UP] = LoopedTask_MoveSearchListPageUp, + [CONDITION_SEARCH_FUNC_PAGE_DOWN] = LoopedTask_MoveSearchListPageDown, + [CONDITION_SEARCH_FUNC_EXIT] = LoopedTask_ExitConditionSearchMenu, [CONDITION_SEARCH_FUNC_SELECT_MON] = LoopedTask_SelectSearchResult }; @@ -140,7 +140,7 @@ bool32 PokenavCallback_Init_ConditionSearch(void) structPtr->callback = HandleConditionSearchInput_WaitSetup; structPtr->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1); - structPtr->unk18 = 0; + structPtr->returnFromGraph = 0; structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; return TRUE; } @@ -154,7 +154,7 @@ bool32 PokenavCallback_Init_ReturnToMonSearchList(void) structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); structPtr->callback = HandleConditionSearchInput; - structPtr->unk18 = 1; + structPtr->returnFromGraph = 1; structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; return TRUE; } @@ -200,7 +200,7 @@ static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr) { structPtr->monList->currIndex = GetSelectedPokenavListIndex(); structPtr->isPartyCondition = 1; - structPtr->callback = sub_81CF0B8; + structPtr->callback = OpenConditionGraphFromSearchList; return CONDITION_SEARCH_FUNC_SELECT_MON; } return CONDITION_SEARCH_FUNC_NONE; @@ -211,15 +211,15 @@ static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr) return POKENAV_CONDITION_SEARCH_MENU; } -static u32 sub_81CF0B8(struct PokenavSub7 *structPtr) +static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr) { - return POKENAV_MENU_CONDITION_GRAPH_FROM_SEARCH; + return POKENAV_CONDITION_GRAPH_FROM_SEARCH; } static u32 sub_81CF0C0(void) { struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); - return structPtr->unk18; + return structPtr->returnFromGraph; } static struct PokenavMonList * GetSearchResultsMonDataList(void) @@ -339,7 +339,7 @@ static u32 sub_81CF278(s32 state) ptr->monList->monData[i].data = i + 1; } } - ptr->unk18 = 1; + ptr->returnFromGraph = 1; return LT_FINISH; } diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 63426199c..adcd889d3 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -152,22 +152,22 @@ const struct BgTemplate sMatchCallBgTemplates[3] = static const LoopedTask sMatchCallLoopTaskFuncs[] = { - [POKENAV_MC_FUNC_NONE] = NULL, - [POKENAV_MC_FUNC_DOWN] = MatchCallListCursorDown, - [POKENAV_MC_FUNC_UP] = MatchCallListCursorUp, - [POKENAV_MC_FUNC_PG_DOWN] = MatchCallListPageDown, - [POKENAV_MC_FUNC_PG_UP] = MatchCallListPageUp, - [POKENAV_MC_FUNC_SELECT] = SelectMatchCallEntry, + [POKENAV_MC_FUNC_NONE] = NULL, + [POKENAV_MC_FUNC_DOWN] = MatchCallListCursorDown, + [POKENAV_MC_FUNC_UP] = MatchCallListCursorUp, + [POKENAV_MC_FUNC_PG_DOWN] = MatchCallListPageDown, + [POKENAV_MC_FUNC_PG_UP] = MatchCallListPageUp, + [POKENAV_MC_FUNC_SELECT] = SelectMatchCallEntry, [POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR] = MoveMatchCallOptionsCursor, - [POKENAV_MC_FUNC_CANCEL] = CancelMatchCallSelection, - [POKENAV_MC_FUNC_CALL_MSG] = DoMatchCallMessage, - [POKENAV_MC_FUNC_NEARBY_MSG] = DoTrainerCloseByMessage, - [POKENAV_MC_FUNC_10] = sub_81CB888, - [POKENAV_MC_FUNC_SHOW_CHECK_PAGE] = ShowCheckPage, - [POKENAV_MC_FUNC_CHECK_PAGE_UP] = ShowCheckPageUp, - [POKENAV_MC_FUNC_CHECK_PAGE_DOWN] = ShowCheckPageDown, - [POKENAV_MC_FUNC_EXIT_CHECK_PAGE] = ExitCheckPage, - [POKENAV_MC_FUNC_EXIT] = ExitMatchCall + [POKENAV_MC_FUNC_CANCEL] = CancelMatchCallSelection, + [POKENAV_MC_FUNC_CALL_MSG] = DoMatchCallMessage, + [POKENAV_MC_FUNC_NEARBY_MSG] = DoTrainerCloseByMessage, + [POKENAV_MC_FUNC_10] = sub_81CB888, + [POKENAV_MC_FUNC_SHOW_CHECK_PAGE] = ShowCheckPage, + [POKENAV_MC_FUNC_CHECK_PAGE_UP] = ShowCheckPageUp, + [POKENAV_MC_FUNC_CHECK_PAGE_DOWN] = ShowCheckPageDown, + [POKENAV_MC_FUNC_EXIT_CHECK_PAGE] = ExitCheckPage, + [POKENAV_MC_FUNC_EXIT] = ExitMatchCall }; static const struct WindowTemplate sMatchCallLocationWindowTemplate = diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index 0e819ecac..d37c897b5 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -81,14 +81,14 @@ static void InitMenuOptionGlow(void); static void Task_CurrentMenuOptionGlow(u8 taskId); static void SetMenuOptionGlow(void); -static const u16 sPokenavBgDotsPal[] = INCBIN_U16("graphics/pokenav/bg.gbapal"); -static const u32 sPokenavBgDotsTiles[] = INCBIN_U32("graphics/pokenav/bg.4bpp.lz"); +static const u16 sPokenavBgDotsPal[] = INCBIN_U16("graphics/pokenav/bg_dots.gbapal"); +static const u32 sPokenavBgDotsTiles[] = INCBIN_U32("graphics/pokenav/bg_dots.4bpp.lz"); static const u32 sPokenavBgDotsTilemap[] = INCBIN_U32("graphics/pokenav/bg.bin.lz"); -static const u16 sPokenavDeviceBgPal[] = INCBIN_U16("graphics/pokenav/outline.gbapal"); -static const u32 sPokenavDeviceBgTiles[] = INCBIN_U32("graphics/pokenav/outline.4bpp.lz"); -static const u32 sPokenavDeviceBgTilemap[] = INCBIN_U32("graphics/pokenav/outline_map.bin.lz"); -static const u16 gUnknown_08620104[] = INCBIN_U16("graphics/pokenav/blue_light.gbapal"); -static const u32 gUnknown_08620124[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz"); +static const u16 sPokenavDeviceBgPal[] = INCBIN_U16("graphics/pokenav/device_outline.gbapal"); +static const u32 sPokenavDeviceBgTiles[] = INCBIN_U32("graphics/pokenav/device_outline.4bpp.lz"); +static const u32 sPokenavDeviceBgTilemap[] = INCBIN_U32("graphics/pokenav/device_outline_map.bin.lz"); +static const u16 sMatchCallBlueLightPal[] = INCBIN_U16("graphics/pokenav/blue_light.gbapal"); +static const u32 sMatchCallBlueLightTiles[] = INCBIN_U32("graphics/pokenav/blue_light.4bpp.lz"); static const struct BgTemplate sPokenavMainMenuBgTemplates[] = { { @@ -118,7 +118,8 @@ static const struct BgTemplate sPokenavMainMenuBgTemplates[] = { } }; -static const LoopedTask sMenuHandlerLoopTaskFuncs[] = { +static const LoopedTask sMenuHandlerLoopTaskFuncs[] = +{ [POKENAV_MENU_FUNC_NONE] = NULL, [POKENAV_MENU_FUNC_MOVE_CURSOR] = LoopedTask_MoveMenuCursor, [POKENAV_MENU_FUNC_OPEN_CONDITION] = LoopedTask_OpenConditionMenu, @@ -138,7 +139,7 @@ static const struct CompressedSpriteSheet sPokenavOptionsSpriteSheets[] = .tag = 0x0003 }, { - .data = gUnknown_08620124, + .data = sMatchCallBlueLightTiles, .size = 0x0100, .tag = 0x0001 } @@ -151,7 +152,7 @@ static const struct SpritePalette sPokenavOptionsSpritePalettes[] = {gPokenavOptions_Pal + 0x20, 6}, {gPokenavOptions_Pal + 0x30, 7}, {gPokenavOptions_Pal + 0x40, 8}, - {gUnknown_08620104, 3}, + {sMatchCallBlueLightPal, 3}, {} }; diff --git a/src/pokenav_ribbons_2.c b/src/pokenav_ribbons_2.c index f33d90e51..203aa19e5 100644 --- a/src/pokenav_ribbons_2.c +++ b/src/pokenav_ribbons_2.c @@ -159,12 +159,12 @@ static const struct BgTemplate gUnknown_08624B98[] = static const LoopedTask sRibbonsSummaryMenuLoopTaskFuncs[] = { - [RIBBONS_SUMMARY_FUNC_NONE] = NULL, - [RIBBONS_SUMMARY_FUNC_MOVED_CURSOR] = LoopedTask_UpdateRibbonsSummaryInfo, - [RIBBONS_SUMMARY_FUNC_SELECT_RIBBON] = LoopedTask_ExpandSelectedRibbon, + [RIBBONS_SUMMARY_FUNC_NONE] = NULL, + [RIBBONS_SUMMARY_FUNC_MOVED_CURSOR] = LoopedTask_UpdateRibbonsSummaryInfo, + [RIBBONS_SUMMARY_FUNC_SELECT_RIBBON] = LoopedTask_ExpandSelectedRibbon, [RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE] = LoopedTask_MoveRibbonsCursorExpanded, - [RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL] = LoopedTask_ShrinkExpandedRibbon, - [RIBBONS_SUMMARY_FUNC_EXIT] = LoopedTask_ExitRibbonsSummaryMenu + [RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL] = LoopedTask_ShrinkExpandedRibbon, + [RIBBONS_SUMMARY_FUNC_EXIT] = LoopedTask_ExitRibbonsSummaryMenu }; // code From 280c68b531dd6dfa4c4a539dbb6602580a36c16a Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 11 Oct 2020 09:11:12 -0600 Subject: [PATCH 4/5] renamed pokenav graphics file fixes --- graphics_file_rules.mk | 2 +- src/pokenav_menu_handler_2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 630aaa3fc..f9ea40532 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -709,7 +709,7 @@ $(PKNAVOPTIONSGFXDIR)/options.4bpp: $(PKNAVOPTIONSGFXDIR)/hoenn_map.4bpp \ $(PKNAVGFXDIR)/header.4bpp: %.4bpp: %.png $(GFX) $< $@ -num_tiles 53 -$(PKNAVGFXDIR)/outline.4bpp: %.4bpp: %.png +$(PKNAVGFXDIR)/device_outline.4bpp: %.4bpp: %.png $(GFX) $< $@ -num_tiles 53 $(PKNAVGFXDIR)/ui_matchcall.4bpp: %.4bpp: %.png diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index d37c897b5..3fcd41dc9 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -83,7 +83,7 @@ static void SetMenuOptionGlow(void); static const u16 sPokenavBgDotsPal[] = INCBIN_U16("graphics/pokenav/bg_dots.gbapal"); static const u32 sPokenavBgDotsTiles[] = INCBIN_U32("graphics/pokenav/bg_dots.4bpp.lz"); -static const u32 sPokenavBgDotsTilemap[] = INCBIN_U32("graphics/pokenav/bg.bin.lz"); +static const u32 sPokenavBgDotsTilemap[] = INCBIN_U32("graphics/pokenav/bg_dots.bin.lz"); static const u16 sPokenavDeviceBgPal[] = INCBIN_U16("graphics/pokenav/device_outline.gbapal"); static const u32 sPokenavDeviceBgTiles[] = INCBIN_U32("graphics/pokenav/device_outline.4bpp.lz"); static const u32 sPokenavDeviceBgTilemap[] = INCBIN_U32("graphics/pokenav/device_outline_map.bin.lz"); From 1472111c5d158e72f4cf80c075a221e98d814250 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 11 Oct 2020 19:02:10 -0400 Subject: [PATCH 5/5] Fix PutAwayDecorationLoop UB comment --- data/scripts/secret_base.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/scripts/secret_base.inc b/data/scripts/secret_base.inc index 132bdd19c..4a20de9a6 100644 --- a/data/scripts/secret_base.inc +++ b/data/scripts/secret_base.inc @@ -308,7 +308,7 @@ SecretBase_EventScript_PutAwayDecorationLoop:: @ 8275D39 compare VAR_0x8005, 0 goto_if_eq SecretBase_EventScript_PutAwayDecorationLoop removeobject VAR_0x8006 - setflag VAR_0x8005 @ UB: GF likely meant setvar here; setflag 0x8005 is out of bounds + setflag VAR_0x8005 @ UB: VAR_0x8005 is set to a flag by PutAwayDecorationIteration, but ScrCmd_setflag doesn't use VarGet goto SecretBase_EventScript_PutAwayDecorationLoop end