Merge branch 'master' of https://github.com/pret/pokeemerald into sync-item-expansion

This commit is contained in:
ExpoSeed 2020-10-12 12:43:55 -05:00
commit d649bcabbc
32 changed files with 2101 additions and 2023 deletions

View File

@ -1 +1 @@
gUnknown_03006298 gFrontierTempParty

View File

@ -308,7 +308,7 @@ SecretBase_EventScript_PutAwayDecorationLoop:: @ 8275D39
compare VAR_0x8005, 0 compare VAR_0x8005, 0
goto_if_eq SecretBase_EventScript_PutAwayDecorationLoop goto_if_eq SecretBase_EventScript_PutAwayDecorationLoop
removeobject VAR_0x8006 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 goto SecretBase_EventScript_PutAwayDecorationLoop
end end

View File

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

View File

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 596 B

View File

@ -709,7 +709,7 @@ $(PKNAVOPTIONSGFXDIR)/options.4bpp: $(PKNAVOPTIONSGFXDIR)/hoenn_map.4bpp \
$(PKNAVGFXDIR)/header.4bpp: %.4bpp: %.png $(PKNAVGFXDIR)/header.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 53 $(GFX) $< $@ -num_tiles 53
$(PKNAVGFXDIR)/outline.4bpp: %.4bpp: %.png $(PKNAVGFXDIR)/device_outline.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 53 $(GFX) $< $@ -num_tiles 53
$(PKNAVGFXDIR)/ui_matchcall.4bpp: %.4bpp: %.png $(PKNAVGFXDIR)/ui_matchcall.4bpp: %.4bpp: %.png

View File

@ -43,7 +43,9 @@ extern const struct BattleFrontierTrainer gBattleFrontierTrainers[];
extern const struct FacilityMon gSlateportBattleTentMons[]; extern const struct FacilityMon gSlateportBattleTentMons[];
extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[]; 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 BattleFrontierTrainer *gFacilityTrainers;
extern const struct FacilityMon *gFacilityTrainerMons; extern const struct FacilityMon *gFacilityTrainerMons;

View File

@ -23,7 +23,7 @@ struct UnknownSubStruct_81D1ED4
struct ConditionGraph struct ConditionGraph
{ {
/*0x000*/ u8 unk0[4][FLAVOR_COUNT]; /*0x000*/ u8 stat[4][FLAVOR_COUNT];
/*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][FLAVOR_COUNT]; /*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][FLAVOR_COUNT];
/*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[10][FLAVOR_COUNT]; /*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[10][FLAVOR_COUNT];
/*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[FLAVOR_COUNT]; /*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[FLAVOR_COUNT];
@ -32,7 +32,7 @@ struct ConditionGraph
/*0x350*/ u16 unk350; /*0x350*/ u16 unk350;
/*0x352*/ u16 unk352; /*0x352*/ u16 unk352;
/*0x354*/ u8 unk354; /*0x354*/ u8 unk354;
/*0x355*/ u8 unk355; /*0x355*/ u8 state;
}; };
bool8 sub_81D1C44(u8 count); bool8 sub_81D1C44(u8 count);
@ -41,12 +41,12 @@ u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page);
void sub_81D1E90(struct PlayerPCItemPageStruct *page); void sub_81D1E90(struct PlayerPCItemPageStruct *page);
void sub_81D1EC0(void); void sub_81D1EC0(void);
void sub_81D1D04(u8 a0); void sub_81D1D04(u8 a0);
void sub_81D1ED4(struct ConditionGraph *graph); void InitConditionGraphData(struct ConditionGraph *graph);
void sub_81D2108(struct ConditionGraph *graph); void sub_81D2108(struct ConditionGraph *graph);
void sub_81D21DC(u8 bg); void SetConditionGraphIOWindows(u8 bg);
void sub_81D20AC(struct ConditionGraph *graph); void InitConditionGraphState(struct ConditionGraph *graph);
void sub_81D2230(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); bool32 TransitionConditionGraph(struct ConditionGraph *graph);
void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1); void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1);
void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2); void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2);

View File

@ -29,8 +29,8 @@ bool8 sub_811F960(void);
void sub_811FA90(void); void sub_811FA90(void);
void sub_811FAA4(u8 markings, s16 x, s16 y); void sub_811FAA4(u8 markings, s16 x, s16 y);
void sub_811FAF8(void); void sub_811FAF8(void);
bool8 sub_811FBA4(void); bool8 MonMarkingsMenuHandleInput(void);
struct Sprite *sub_811FF94(u16 tileTag, u16 paletteTag, const u16 *palette); struct Sprite *CreateMonMarkingsSpriteWithPal(u16 tileTag, u16 paletteTag, const u16 *palette);
struct Sprite *sub_811FFB4(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); void sub_8120084(u8 markings, void *dest);

View File

@ -27,17 +27,17 @@ struct PokenavListTemplate
struct PokenavMonList *monList; struct PokenavMonList *monList;
struct PokenavMatchCallEntries *matchCallEntries; struct PokenavMatchCallEntries *matchCallEntries;
} list; } list;
u16 unk4; u16 count;
u16 unk6; u16 unk6;
u8 unk8; u8 unk8;
u8 unk9; u8 item_X;
u8 unkA; u8 windowWidth;
u8 unkB; u8 listTop;
u8 unkC; u8 maxShowed;
u8 unkD; u8 fillValue;
u8 unkE; u8 fontId;
union { union {
void (*unk10_1)(struct PokenavMonList *, u8 *a1); void (*printMonFunc)(struct PokenavMonList *item, u8 *dest);
void (*unk10_2)(struct PokenavMatchCallEntries *, u8 *a1); void (*unk10_2)(struct PokenavMatchCallEntries *, u8 *a1);
} listFunc; } listFunc;
void (*unk14)(u16 a0, u32 a1, u32 a2); void (*unk14)(u16 a0, u32 a1, u32 a2);
@ -45,9 +45,9 @@ struct PokenavListTemplate
struct PokenavSub18 struct PokenavSub18
{ {
u16 unk0; u16 listCount;
u16 unk2; u16 currIndex;
struct PokenavMonList unk4[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE]; struct PokenavMonList monData[TOTAL_BOXES_COUNT * IN_BOX_COUNT + PARTY_SIZE];
}; };
// Return values of LoopedTask functions. // Return values of LoopedTask functions.
@ -65,6 +65,31 @@ enum
POKENAV_MODE_FORCE_CALL_EXIT, // Pokenav tutorial after calling Mr. Stone 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 enum
{ {
POKENAV_GFX_MAIN_MENU, POKENAV_GFX_MAIN_MENU,
@ -97,12 +122,12 @@ enum
POKENAV_REGION_MAP, POKENAV_REGION_MAP,
POKENAV_CONDITION_PARTY, POKENAV_CONDITION_PARTY,
POKENAV_CONDITION_SEARCH_RESULTS, POKENAV_CONDITION_SEARCH_RESULTS,
POKENAV_MENU_9, // Condition POKENAV_CONDITION_GRAPH_FROM_SEARCH, // opening condition graph from search list
POKENAV_MENU_A, // Condition POKENAV_RETURN_CONDITION_SEARCH, //return to search list from condition graph
POKENAV_MATCH_CALL, POKENAV_MATCH_CALL,
POKENAV_RIBBONS_MON_LIST, POKENAV_RIBBONS_MON_LIST,
POKENAV_MENU_D, // Ribbons POKENAV_RIBBONS_SUMMARY_SCREEN,
POKENAV_MENU_E, // Ribbons POKENAV_RIBBONS_RETURN_TO_MON_LIST,
}; };
enum enum
@ -207,7 +232,7 @@ enum
// Pokenav Function IDs // Pokenav Function IDs
// Indices into the LoopedTask tables for each of the main Pokenav features // Indices into the LoopedTask tables for each of the main Pokenav features
enum enum RegionMapFuncIds
{ {
POKENAV_MENU_FUNC_NONE, POKENAV_MENU_FUNC_NONE,
POKENAV_MENU_FUNC_MOVE_CURSOR, POKENAV_MENU_FUNC_MOVE_CURSOR,
@ -220,6 +245,19 @@ enum
POKENAV_MENU_FUNC_OPEN_FEATURE, 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 enum
{ {
POKENAV_MC_FUNC_NONE, POKENAV_MC_FUNC_NONE,
@ -268,17 +306,17 @@ void SetPokenavVBlankCallback(void);
void SetVBlankCallback_(IntrCallback callback); void SetVBlankCallback_(IntrCallback callback);
// pokenav_match_call_ui.c // pokenav_match_call_ui.c
u32 GetSelectedMatchCall(void); u32 GetSelectedPokenavListIndex(void);
bool32 sub_81C8224(void); bool32 sub_81C8224(void);
int MatchCall_MoveCursorUp(void); int MatchCall_MoveCursorUp(void);
int MatchCall_MoveCursorDown(void); int MatchCall_MoveCursorDown(void);
int MatchCall_PageDown(void); int MatchCall_PageDown(void);
int MatchCall_PageUp(void); int MatchCall_PageUp(void);
bool32 sub_81C8630(void); bool32 IsMonListLoopedTaskActive(void);
void ToggleMatchCallVerticalArrows(bool32 shouldHide); void ToggleMatchCallVerticalArrows(bool32 shouldHide);
void sub_81C8838(void); void sub_81C8838(void);
void sub_81C877C(void); void sub_81C877C(void);
bool32 sub_81C8820(void); bool32 IsMatchCallListTaskActive(void);
void PrintCheckPageInfo(s16 a0); void PrintCheckPageInfo(s16 a0);
u32 GetMatchCallListTopIndex(void); u32 GetMatchCallListTopIndex(void);
void sub_81C87F0(void); void sub_81C87F0(void);
@ -300,30 +338,30 @@ void MatchCall_GetNameAndDesc(u32 idx, const u8 **desc, const u8 **name);
// pokenav_main_menu.c // pokenav_main_menu.c
bool32 InitPokenavMainMenu(void); bool32 InitPokenavMainMenu(void);
void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size); void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size);
void sub_81C7850(u32 a0); void RunMainMenuLoopedTask(u32 a0);
u32 sub_81C786C(void); u32 IsActiveMenuLoopTaskActive(void);
void LoadLeftHeaderGfxForIndex(u32 arg0); 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); void PokenavFadeScreen(s32 fadeType);
bool32 sub_81C8010(void); bool32 AreLeftHeaderSpritesMoving(void);
void InitBgTemplates(const struct BgTemplate *templates, int count); void InitBgTemplates(const struct BgTemplate *templates, int count);
bool32 IsPaletteFadeActive(void); bool32 IsPaletteFadeActive(void);
void PrintHelpBarText(u32 textId); void PrintHelpBarText(u32 textId);
bool32 WaitForHelpBar(void); bool32 WaitForHelpBar(void);
void sub_81C78A0(void); void SlideMenuHeaderDown(void);
bool32 MainMenuLoopedTaskIsBusy(void); bool32 MainMenuLoopedTaskIsBusy(void);
void sub_81C7FDC(void); void SetLeftHeaderSpritesInvisibility(void);
void sub_81C79BC(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette); void PokenavCopyPalette(const u16 *a0, const u16 *a1, int a2, int a3, int a4, u16 *palette);
void sub_81C7B40(void); void sub_81C7B40(void);
struct Sprite *PauseSpinningPokenavSprite(void); struct Sprite *PauseSpinningPokenavSprite(void);
void ResumeSpinningPokenavSprite(void); void ResumeSpinningPokenavSprite(void);
void sub_81C7E14(u32 arg0); void UpdateRegionMapRightHeaderTiles(u32 arg0);
void sub_81C7FC4(u32 arg0, bool32 arg1); void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide);
void sub_81C7880(void); void SlideMenuHeaderUp(void);
void sub_81C7990(u32 a0, u16 a1); void PokenavFillPalette(u32 palIndex, u16 fillValue);
u32 PokenavMainMenuLoopedTaskIsActive(void); u32 PokenavMainMenuLoopedTaskIsActive(void);
bool32 WaitForPokenavShutdownFade(void); bool32 WaitForPokenavShutdownFade(void);
void sub_81C7834(void *func1, void *func2); void SetActiveMenuLoopTasks(void *func1, void *func2);
void ShutdownPokenav(void); void ShutdownPokenav(void);
// pokenav_menu_handler_1.c // pokenav_menu_handler_1.c
@ -345,7 +383,7 @@ bool32 OpenPokenavMenuNotInitial(void);
void CreateMenuHandlerLoopedTask(s32 ltIdx); void CreateMenuHandlerLoopedTask(s32 ltIdx);
bool32 IsMenuHandlerLoopedTaskActive(void); bool32 IsMenuHandlerLoopedTaskActive(void);
void FreeMenuHandlerSubstruct2(void); void FreeMenuHandlerSubstruct2(void);
void sub_81CAADC(void); void ResetBldCnt_(void);
// pokenav_match_call_1.c // pokenav_match_call_1.c
bool32 PokenavCallback_Init_MatchCall(void); bool32 PokenavCallback_Init_MatchCall(void);
@ -364,7 +402,7 @@ const u8 *GetMatchCallMessageText(int index, u8 *arg1);
u16 GetMatchCallOptionCursorPos(void); u16 GetMatchCallOptionCursorPos(void);
u16 GetMatchCallOptionId(int arg0); u16 GetMatchCallOptionId(int arg0);
void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries * arg0, u8 *str); void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries * arg0, u8 *str);
u8 sub_81CB0C8(int rematchIndex); u8 GetMatchTableMapSectionId(int rematchIndex);
int GetIndexDeltaOfNextCheckPageDown(int index); int GetIndexDeltaOfNextCheckPageDown(int index);
int GetIndexDeltaOfNextCheckPageUp(int index); int GetIndexDeltaOfNextCheckPageUp(int index);
bool32 IsRematchEntryRegistered(int index); bool32 IsRematchEntryRegistered(int index);
@ -385,60 +423,60 @@ void FreeRegionMapSubstruct1(void);
void FreeRegionMapSubstruct2(void); void FreeRegionMapSubstruct2(void);
// pokenav_conditions_1.c // pokenav_conditions_1.c
u32 PokenavCallback_Init_7(void); u32 PokenavCallback_Init_PartyCondition(void);
u32 PokenavCallback_Init_9(void); u32 PokenavCallback_Init_ConditionGraphFromSearch(void);
u32 sub_81CD070(void); u32 GetPartyConditionCallback(void);
void sub_81CD1C0(void); void FreePartyConditionSubstruct1(void);
bool32 sub_81CD3C4(void); bool32 LoadPartyConditionMenuGfx(void);
bool32 sub_81CDD5C(void); bool32 IsConditionMenuSearchMode(void);
struct ConditionGraph *sub_81CDC70(void); struct ConditionGraph *GetConditionGraphDataPtr(void);
u16 sub_81CDC60(void); u16 GetConditionGraphCurrentMonIndex(void);
u16 sub_81CDC50(void); u16 GetMonListCount(void);
u8 sub_81CDDB0(void); u8 GetMonSheen(void);
bool32 sub_81CD548(u8 arg0); bool32 SetConditionGraphData(u8 arg0);
u8 sub_81CDD7C(void); u8 TryGetMonMarkId(void);
u8 *sub_81CDD04(u8 id); u8 *GetConditionMonNameBuffer(u8 id);
u8 *sub_81CDD24(u8 id); u8 *GetConditionMonLocationBuffer(u8 id);
u16 sub_81CDD48(void); u16 GetConditionMonDataBuffer(void);
void *sub_81CDCB4(u8 id); void *GetConditionMonPicGfx(u8 id);
void *sub_81CDCD4(u8 id); void *GetConditionMonPal(u8 id);
// pokenav_conditions_2.c // pokenav_conditions_2.c
bool32 sub_81CDDD4(void); bool32 OpenPartyConditionMenu(void);
void sub_81CDE2C(s32); void CreatePartyConditionLoopedTask(s32);
u32 sub_81CDE64(void); u32 IsPartyConditionLoopedTaskActive(void);
void sub_81CECA0(void); void FreePartyConditionSubstruct2(void);
u8 sub_81CEF14(void); u8 GetMonMarkingsData(void);
// pokenav_conditions_3.c // pokenav_conditions_3.c
u32 PokenavCallback_Init_8(void); u32 PokenavCallback_Init_ConditionSearch(void);
u32 PokenavCallback_Init_10(void); u32 PokenavCallback_Init_ReturnToMonSearchList(void);
u32 sub_81CEFDC(void); u32 GetConditionSearchResultsCallback(void);
void sub_81CEFF0(void); void FreeSearchResultSubstruct1(void);
bool32 sub_81CF330(void); bool32 OpenConditionSearchResults(void);
bool32 sub_81CF368(void); bool32 OpenConditionSearchListFromGraph(void);
void sub_81CF3A0(s32); void CreateSearchResultsLoopedTask(s32);
u32 sub_81CF3D0(void); u32 IsSearchResultLoopedTaskActive(void);
void sub_81CF3F8(void); void FreeSearchResultSubstruct2(void);
// pokenav_ribbons_1.c // pokenav_ribbons_1.c
u32 PokenavCallback_Init_12(void); u32 PokenavCallback_Init_MonRibbonList(void);
u32 PokenavCallback_Init_14(void); u32 PokenavCallback_Init_RibbonsMonListFromSummary(void);
u32 sub_81CFA34(void); u32 GetRibbonsMonListCallback(void);
void sub_81CFA48(void); void FreeRibbonsMonList1(void);
bool32 sub_81CFDD0(void); bool32 OpenRibbonsMonList(void);
bool32 sub_81CFE08(void); bool32 OpenRibbonsMonListFromRibbonsSummary(void);
void sub_81CFE40(s32); void CreateRibbonsMonListLoopedTask(s32);
u32 sub_81CFE70(void); u32 IsRibbonsMonListLoopedTaskActive(void);
void sub_81CFE98(void); void FreeRibbonsMonList2(void);
// pokenav_ribbons_2.c // pokenav_ribbons_2.c
u32 PokenavCallback_Init_13(void); u32 PokenavCallback_Init_RibbonsSummaryMenu(void);
u32 sub_81D04A0(void); u32 GetRibbonsSummaryMenuCallback(void);
void sub_81D04B8(void); void FreeRibbonsSummaryScreen1(void);
bool32 sub_81D0978(void); bool32 OpenRibbonsSummaryMenu(void);
void sub_81D09B0(s32); void CreateRibbonsSummaryLoopedTask(s32);
u32 sub_81D09E0(void); u32 IsRibbonsSummaryLoopedTaskActive(void);
void sub_81D09F4(void); void FreeRibbonsSummaryScreen2(void);
#endif // GUARD_POKENAV_H #endif // GUARD_POKENAV_H

View File

@ -207,7 +207,7 @@ static void InitFactoryChallenge(void)
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
gSaveBlock2Ptr->frontier.rentalMons[i].monId = 0xFFFF; gSaveBlock2Ptr->frontier.rentalMons[i].monId = 0xFFFF;
for (i = 0; i < FRONTIER_PARTY_SIZE; i++) for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
gUnknown_03006298[i] = 0xFFFF; gFrontierTempParty[i] = 0xFFFF;
SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
gTrainerBattleOpponent_A = 0; gTrainerBattleOpponent_A = 0;
@ -355,7 +355,7 @@ static void GenerateOpponentMons(void)
species[i] = gFacilityTrainerMons[monId].species; species[i] = gFacilityTrainerMons[monId].species;
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]; heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId];
gUnknown_03006298[i] = monId; gFrontierTempParty[i] = monId;
i++; i++;
} }
} }
@ -376,11 +376,11 @@ static void SetRentalsToOpponentParty(void)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++) 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].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].personality = GetMonData(&gEnemyParty[i], MON_DATA_PERSONALITY, NULL);
gSaveBlock2Ptr->frontier.rentalMons[i + 3].abilityNum = GetBoxMonData(&gEnemyParty[i].box, MON_DATA_ABILITY_NUM, 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; typesCount[i] = 0;
for (i = 0; i < FRONTIER_PARTY_SIZE; i++) 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]++; typesCount[gBaseStats[species].type1]++;
if (gBaseStats[species].type1 != gBaseStats[species].type2) if (gBaseStats[species].type1 != gBaseStats[species].type2)
@ -631,7 +631,7 @@ static void GetOpponentBattleStyle(void)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++) 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++) for (j = 0; j < MAX_MON_MOVES; j++)
{ {
u8 battleStyle = GetMoveBattleStyle(gFacilityTrainerMons[monId].moves[j]); u8 battleStyle = GetMoveBattleStyle(gFacilityTrainerMons[monId].moves[j]);

View File

@ -420,7 +420,7 @@ static void GenerateOpponentMons(void)
species[i] = gFacilityTrainerMons[sRandMonSetId].species; species[i] = gFacilityTrainerMons[sRandMonSetId].species;
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId]; heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId];
gUnknown_03006298[i] = sRandMonSetId; gFrontierTempParty[i] = sRandMonSetId;
i++; i++;
} }
} }

View File

@ -46,7 +46,7 @@ EWRAM_DATA const struct BattleFrontierTrainer *gFacilityTrainers = NULL;
EWRAM_DATA const struct FacilityMon *gFacilityTrainerMons = NULL; EWRAM_DATA const struct FacilityMon *gFacilityTrainerMons = NULL;
// IWRAM common // IWRAM common
u16 gUnknown_03006298[MAX_FRONTIER_PARTY_SIZE]; u16 gFrontierTempParty[MAX_FRONTIER_PARTY_SIZE];
// This file's functions. // This file's functions.
static void InitTowerChallenge(void); static void InitTowerChallenge(void);
@ -1856,7 +1856,7 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId)
otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId); otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
for (i = 0; i < FRONTIER_PARTY_SIZE; i++) for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{ {
u16 monId = gUnknown_03006298[i]; u16 monId = gFrontierTempParty[i];
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i], CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i],
gFacilityTrainerMons[monId].species, gFacilityTrainerMons[monId].species,
level, level,
@ -1884,7 +1884,7 @@ static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId)
for (i = 0; i < FRONTIER_PARTY_SIZE; i++) for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{ {
u16 monId = gUnknown_03006298[i]; u16 monId = gFrontierTempParty[i];
CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i], CreateMonWithEVSpreadNatureOTID(&gEnemyParty[firstMonId + i],
gFacilityTrainerMons[monId].species, gFacilityTrainerMons[monId].species,
level, level,
@ -2224,11 +2224,11 @@ static void GetApprenticeMultiPartnerParty(u16 trainerId)
} }
} }
gUnknown_03006298[0] = validSpecies[Random() % count]; gFrontierTempParty[0] = validSpecies[Random() % count];
do do
{ {
gUnknown_03006298[1] = validSpecies[Random() % count]; gFrontierTempParty[1] = validSpecies[Random() % count];
} while (gUnknown_03006298[0] == gUnknown_03006298[1]); } while (gFrontierTempParty[0] == gFrontierTempParty[1]);
} }
static void GetRecordMixFriendMultiPartnerParty(u16 trainerId) 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 do
{ {
gUnknown_03006298[3] = validSpecies[Random() % count]; gFrontierTempParty[3] = validSpecies[Random() % count];
} while (gUnknown_03006298[2] == gUnknown_03006298[3]); } while (gFrontierTempParty[2] == gFrontierTempParty[3]);
} }
static void LoadMultiPartnerCandidatesData(void) static void LoadMultiPartnerCandidatesData(void)
@ -2420,15 +2420,15 @@ static void sub_81646BC(u16 trainerId, u16 monId)
} }
else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE)
{ {
move = gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[gUnknown_03006298[gSpecialVar_0x8005 + 1]].moves[0]; 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[gUnknown_03006298[gSpecialVar_0x8005 + 1]].species; species = gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[gFrontierTempParty[gSpecialVar_0x8005 + 1]].species;
} }
else else
{ {
s32 i; s32 i;
move = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[gUnknown_03006298[gSpecialVar_0x8005 - 1]].moves[0]; move = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[gFrontierTempParty[gSpecialVar_0x8005 - 1]].moves[0];
species = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[gUnknown_03006298[gSpecialVar_0x8005 - 1]].species; species = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[gFrontierTempParty[gSpecialVar_0x8005 - 1]].species;
for (i = 0; i < PLAYER_NAME_LENGTH; i++) for (i = 0; i < PLAYER_NAME_LENGTH; i++)
gStringVar3[i] = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].playerName[i]; gStringVar3[i] = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].playerName[i];
gStringVar3[i] = EOS; gStringVar3[i] = EOS;
@ -2497,13 +2497,13 @@ static void ShowPartnerCandidateMessage(void)
} }
else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE)
{ {
gSaveBlock2Ptr->frontier.trainerIds[18] = gUnknown_03006298[2]; gSaveBlock2Ptr->frontier.trainerIds[18] = gFrontierTempParty[2];
gSaveBlock2Ptr->frontier.trainerIds[19] = gUnknown_03006298[3]; gSaveBlock2Ptr->frontier.trainerIds[19] = gFrontierTempParty[3];
} }
else else
{ {
gSaveBlock2Ptr->frontier.trainerIds[18] = gUnknown_03006298[0]; gSaveBlock2Ptr->frontier.trainerIds[18] = gFrontierTempParty[0];
gSaveBlock2Ptr->frontier.trainerIds[19] = gUnknown_03006298[1]; gSaveBlock2Ptr->frontier.trainerIds[19] = gFrontierTempParty[1];
} }
for (k = 0; k < 14; k++) for (k = 0; k < 14; k++)
{ {

View File

@ -319,7 +319,7 @@ void sub_81D1EC0(void)
Free(sUnknown_0203CF4C); Free(sUnknown_0203CF4C);
} }
void sub_81D1ED4(struct ConditionGraph *a0) void InitConditionGraphData(struct ConditionGraph *graph)
{ {
u8 i, j; u8 i, j;
@ -327,22 +327,22 @@ void sub_81D1ED4(struct ConditionGraph *a0)
{ {
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
{ {
a0->unk64[i][j].unk0 = 0; graph->unk64[i][j].unk0 = 0;
a0->unk64[i][j].unk2 = 0; graph->unk64[i][j].unk2 = 0;
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
a0->unk0[i][j] = 0; graph->stat[i][j] = 0;
a0->unk14[i][j].unk0 = 0x9B; graph->unk14[i][j].unk0 = 155;
a0->unk14[i][j].unk2 = 0x5B; graph->unk14[i][j].unk2 = 91;
} }
a0->unk12C[j].unk0 = 0; graph->unk12C[j].unk0 = 0;
a0->unk12C[j].unk2 = 0; graph->unk12C[j].unk2 = 0;
} }
a0->unk354 = 0; graph->unk354 = 0;
a0->unk352 = 0; graph->unk352 = 0;
} }
void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2) 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; u16 i, j;
s32 r5, r6; s32 r5, r6;
for (i = 0; i < 5; i++) for (i = 0; i < FLAVOR_COUNT; i++)
{ {
r5 = arg1[i].unk0 << 8; r5 = arg1[i].unk0 << 8;
r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / 10; 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; struct ScanlineEffectParams params;
switch (graph->unk355) switch (graph->state)
{ {
case 0: case 0:
ScanlineEffect_Clear(); ScanlineEffect_Clear();
graph->unk355++; graph->state++;
return TRUE; return TRUE;
case 1: case 1:
params = sConditionGraphScanline; params = sConditionGraphScanline;
ScanlineEffect_SetParams(params); ScanlineEffect_SetParams(params);
graph->unk355++; graph->state++;
return FALSE; return FALSE;
default: default:
return FALSE; return FALSE;
@ -431,7 +431,7 @@ void sub_81D2108(struct ConditionGraph *graph)
graph->unk354 = 0; graph->unk354 = 0;
} }
void sub_81D21DC(u8 bg) void SetConditionGraphIOWindows(u8 bg)
{ {
u32 flags; u32 flags;
@ -1025,23 +1025,23 @@ void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16
if (partyId != numMons) if (partyId != numMons)
{ {
graph->unk0[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); graph->stat[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
graph->unk0[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); graph->stat[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
graph->unk0[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); graph->stat[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
graph->unk0[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); graph->stat[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
graph->unk0[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); graph->stat[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF) sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF)
? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u
: 9; : 9;
sub_81D2754(graph->unk0[id], graph->unk14[id]); sub_81D2754(graph->stat[id], graph->unk14[id]);
} }
else else
{ {
for (i = 0; i < FLAVOR_COUNT; i++) 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].unk0 = 155;
graph->unk14[id][i].unk2 = 91; graph->unk14[id][i].unk2 = 91;
} }

View File

@ -390,7 +390,7 @@ void sub_811FAF8(void)
} }
} }
bool8 sub_811FBA4(void) bool8 MonMarkingsMenuHandleInput(void)
{ {
u16 i; u16 i;
@ -564,7 +564,7 @@ static void sub_811FF7C(struct Sprite *sprite)
sprite->pos1.y = (16 * sMenu->cursorPos) + sprite->data[0]; 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) if (!palette)
palette = gUnknown_0859E65C; palette = gUnknown_0859E65C;

View File

@ -3183,7 +3183,7 @@ static void Cb_ShowMarkMenu(u8 taskId)
sPSSData->state++; sPSSData->state++;
break; break;
case 1: case 1:
if (!sub_811FBA4()) if (!MonMarkingsMenuHandleInput())
{ {
sub_811FAF8(); sub_811FAF8();
ClearBottomWindow(); ClearBottomWindow();

View File

@ -3976,7 +3976,7 @@ static void StopPokemonAnimations(void) // A subtle effect, this function stops
static void CreateMonMarkingsSprite(struct Pokemon *mon) 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; sMonSummaryScreen->markingsSprite = sprite;
if (sprite != NULL) if (sprite != NULL)

View File

@ -14,8 +14,6 @@
#define LOOPED_TASK_PRIMARY_ID(taskId) (taskId & 0xFFFF) #define LOOPED_TASK_PRIMARY_ID(taskId) (taskId & 0xFFFF)
#define LOOPED_TASK_SECONDARY_ID(taskId) (taskId >> 16) #define LOOPED_TASK_SECONDARY_ID(taskId) (taskId >> 16)
#define SUBSTRUCT_COUNT 19
struct PokenavResources struct PokenavResources
{ {
u32 (*currentMenuCb1)(void); u32 (*currentMenuCb1)(void);
@ -23,7 +21,7 @@ struct PokenavResources
u16 mode; u16 mode;
u16 conditionSearchId; u16 conditionSearchId;
bool32 hasAnyRibbons; bool32 hasAnyRibbons;
void *field10[SUBSTRUCT_COUNT]; void *substructPtrs[POKENAV_SUBSTRUCT_COUNT];
}; };
struct PokenavCallbacks struct PokenavCallbacks
@ -38,7 +36,7 @@ struct PokenavCallbacks
}; };
static u32 GetCurrentMenuCB(void); static u32 GetCurrentMenuCB(void);
static u32 sub_81C75D4(void); static u32 IsActiveMenuLoopTaskActive_(void);
static bool32 SetActivePokenavMenu(u32 menuId); static bool32 SetActivePokenavMenu(u32 menuId);
static bool32 AnyMonHasRibbon(void); static bool32 AnyMonHasRibbon(void);
static void InitPokenavResources(struct PokenavResources *a0); static void InitPokenavResources(struct PokenavResources *a0);
@ -126,43 +124,43 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
}, },
[POKENAV_CONDITION_PARTY - POKENAV_MENU_IDS_START] = [POKENAV_CONDITION_PARTY - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_7, .init = PokenavCallback_Init_PartyCondition,
.callback = sub_81CD070, .callback = GetPartyConditionCallback,
.open = sub_81CDDD4, .open = OpenPartyConditionMenu,
.createLoopTask = sub_81CDE2C, .createLoopTask = CreatePartyConditionLoopedTask,
.isLoopTaskActive = sub_81CDE64, .isLoopTaskActive = IsPartyConditionLoopedTaskActive,
.free1 = sub_81CD1C0, .free1 = FreePartyConditionSubstruct1,
.free2 = sub_81CECA0, .free2 = FreePartyConditionSubstruct2,
}, },
[POKENAV_CONDITION_SEARCH_RESULTS - POKENAV_MENU_IDS_START] = [POKENAV_CONDITION_SEARCH_RESULTS - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_8, .init = PokenavCallback_Init_ConditionSearch,
.callback = sub_81CEFDC, .callback = GetConditionSearchResultsCallback,
.open = sub_81CF330, .open = OpenConditionSearchResults,
.createLoopTask = sub_81CF3A0, .createLoopTask = CreateSearchResultsLoopedTask,
.isLoopTaskActive = sub_81CF3D0, .isLoopTaskActive = IsSearchResultLoopedTaskActive,
.free1 = sub_81CEFF0, .free1 = FreeSearchResultSubstruct1,
.free2 = sub_81CF3F8, .free2 = FreeSearchResultSubstruct2,
}, },
[POKENAV_MENU_9 - POKENAV_MENU_IDS_START] = [POKENAV_CONDITION_GRAPH_FROM_SEARCH - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_9, .init = PokenavCallback_Init_ConditionGraphFromSearch,
.callback = sub_81CD070, .callback = GetPartyConditionCallback,
.open = sub_81CDDD4, .open = OpenPartyConditionMenu,
.createLoopTask = sub_81CDE2C, .createLoopTask = CreatePartyConditionLoopedTask,
.isLoopTaskActive = sub_81CDE64, .isLoopTaskActive = IsPartyConditionLoopedTaskActive,
.free1 = sub_81CD1C0, .free1 = FreePartyConditionSubstruct1,
.free2 = sub_81CECA0, .free2 = FreePartyConditionSubstruct2,
}, },
[POKENAV_MENU_A - POKENAV_MENU_IDS_START] = [POKENAV_RETURN_CONDITION_SEARCH - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_10, .init = PokenavCallback_Init_ReturnToMonSearchList,
.callback = sub_81CEFDC, .callback = GetConditionSearchResultsCallback,
.open = sub_81CF368, .open = OpenConditionSearchListFromGraph,
.createLoopTask = sub_81CF3A0, .createLoopTask = CreateSearchResultsLoopedTask,
.isLoopTaskActive = sub_81CF3D0, .isLoopTaskActive = IsSearchResultLoopedTaskActive,
.free1 = sub_81CEFF0, .free1 = FreeSearchResultSubstruct1,
.free2 = sub_81CF3F8, .free2 = FreeSearchResultSubstruct2,
}, },
[POKENAV_MATCH_CALL - POKENAV_MENU_IDS_START] = [POKENAV_MATCH_CALL - POKENAV_MENU_IDS_START] =
{ {
@ -176,33 +174,33 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
}, },
[POKENAV_RIBBONS_MON_LIST - POKENAV_MENU_IDS_START] = [POKENAV_RIBBONS_MON_LIST - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_12, .init = PokenavCallback_Init_MonRibbonList,
.callback = sub_81CFA34, .callback = GetRibbonsMonListCallback,
.open = sub_81CFDD0, .open = OpenRibbonsMonList,
.createLoopTask = sub_81CFE40, .createLoopTask = CreateRibbonsMonListLoopedTask,
.isLoopTaskActive = sub_81CFE70, .isLoopTaskActive = IsRibbonsMonListLoopedTaskActive,
.free1 = sub_81CFA48, .free1 = FreeRibbonsMonList1,
.free2 = sub_81CFE98, .free2 = FreeRibbonsMonList2,
}, },
[POKENAV_MENU_D - POKENAV_MENU_IDS_START] = [POKENAV_RIBBONS_SUMMARY_SCREEN - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_13, .init = PokenavCallback_Init_RibbonsSummaryMenu,
.callback = sub_81D04A0, .callback = GetRibbonsSummaryMenuCallback,
.open = sub_81D0978, .open = OpenRibbonsSummaryMenu,
.createLoopTask = sub_81D09B0, .createLoopTask = CreateRibbonsSummaryLoopedTask,
.isLoopTaskActive = sub_81D09E0, .isLoopTaskActive = IsRibbonsSummaryLoopedTaskActive,
.free1 = sub_81D04B8, .free1 = FreeRibbonsSummaryScreen1,
.free2 = sub_81D09F4, .free2 = FreeRibbonsSummaryScreen2,
}, },
[POKENAV_MENU_E - POKENAV_MENU_IDS_START] = [POKENAV_RIBBONS_RETURN_TO_MON_LIST - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_14, .init = PokenavCallback_Init_RibbonsMonListFromSummary,
.callback = sub_81CFA34, .callback = GetRibbonsMonListCallback,
.open = sub_81CFE08, .open = OpenRibbonsMonListFromRibbonsSummary,
.createLoopTask = sub_81CFE40, .createLoopTask = CreateRibbonsMonListLoopedTask,
.isLoopTaskActive = sub_81CFE70, .isLoopTaskActive = IsRibbonsMonListLoopedTaskActive,
.free1 = sub_81CFA48, .free1 = FreeRibbonsMonList1,
.free2 = sub_81CFE98, .free2 = FreeRibbonsMonList2,
}, },
}; };
@ -368,24 +366,24 @@ static void FreePokenavResources(void)
{ {
int i; int i;
for (i = 0; i < SUBSTRUCT_COUNT; i++) for (i = 0; i < POKENAV_SUBSTRUCT_COUNT; i++)
FreePokenavSubstruct(i); FreePokenavSubstruct(i);
FREE_AND_SET_NULL(gPokenavResources); FREE_AND_SET_NULL(gPokenavResources);
InitKeys(); InitKeys();
} }
static void InitPokenavResources(struct PokenavResources *a0) static void InitPokenavResources(struct PokenavResources *resources)
{ {
int i; int i;
for (i = 0; i < SUBSTRUCT_COUNT; i++) for (i = 0; i < POKENAV_SUBSTRUCT_COUNT; i++)
a0->field10[i] = NULL; resources->substructPtrs[i] = NULL;
a0->mode = POKENAV_MODE_NORMAL; resources->mode = POKENAV_MODE_NORMAL;
a0->currentMenuIndex = 0; resources->currentMenuIndex = 0;
a0->hasAnyRibbons = AnyMonHasRibbon(); resources->hasAnyRibbons = AnyMonHasRibbon();
a0->currentMenuCb1 = NULL; resources->currentMenuCb1 = NULL;
} }
static bool32 AnyMonHasRibbon(void) static bool32 AnyMonHasRibbon(void)
@ -453,12 +451,12 @@ static void Task_Pokenav(u8 taskId)
tState = 4; tState = 4;
break; break;
case 2: case 2:
if (sub_81C786C()) if (IsActiveMenuLoopTaskActive())
break; break;
tState = 3; tState = 3;
case 3: case 3:
menuId = GetCurrentMenuCB(); menuId = GetCurrentMenuCB();
if (menuId == -1) if (menuId == POKENAV_MENU_FUNC_EXIT)
{ {
ShutdownPokenav(); ShutdownPokenav();
tState = 5; tState = 5;
@ -479,13 +477,13 @@ static void Task_Pokenav(u8 taskId)
} }
else if (menuId != 0) else if (menuId != 0)
{ {
sub_81C7850(menuId); RunMainMenuLoopedTask(menuId);
if (sub_81C786C()) if (IsActiveMenuLoopTaskActive())
tState = 2; tState = 2;
} }
break; break;
case 4: case 4:
if (!sub_81C75D4()) if (!IsActiveMenuLoopTaskActive_())
tState = 3; tState = 3;
break; break;
case 5: case 5:
@ -516,15 +514,15 @@ static bool32 SetActivePokenavMenu(u32 menuId)
if (!PokenavMenuCallbacks[index].open()) if (!PokenavMenuCallbacks[index].open())
return FALSE; return FALSE;
sub_81C7834(PokenavMenuCallbacks[index].createLoopTask, PokenavMenuCallbacks[index].isLoopTaskActive); SetActiveMenuLoopTasks(PokenavMenuCallbacks[index].createLoopTask, PokenavMenuCallbacks[index].isLoopTaskActive);
gPokenavResources->currentMenuCb1 = PokenavMenuCallbacks[index].callback; gPokenavResources->currentMenuCb1 = PokenavMenuCallbacks[index].callback;
gPokenavResources->currentMenuIndex = index; gPokenavResources->currentMenuIndex = index;
return TRUE; return TRUE;
} }
static u32 sub_81C75D4(void) static u32 IsActiveMenuLoopTaskActive_(void)
{ {
return sub_81C786C(); return IsActiveMenuLoopTaskActive();
} }
static u32 GetCurrentMenuCB(void) static u32 GetCurrentMenuCB(void)
@ -549,19 +547,19 @@ void SetPokenavVBlankCallback(void)
void *AllocSubstruct(u32 index, u32 size) void *AllocSubstruct(u32 index, u32 size)
{ {
gPokenavResources->field10[index] = Alloc(size); gPokenavResources->substructPtrs[index] = Alloc(size);
return gPokenavResources->field10[index]; return gPokenavResources->substructPtrs[index];
} }
void *GetSubstructPtr(u32 index) void *GetSubstructPtr(u32 index)
{ {
return gPokenavResources->field10[index]; return gPokenavResources->substructPtrs[index];
} }
void FreePokenavSubstruct(u32 index) void FreePokenavSubstruct(u32 index)
{ {
if (gPokenavResources->field10[index] != NULL) if (gPokenavResources->substructPtrs[index] != NULL)
FREE_AND_SET_NULL(gPokenavResources->field10[index]); FREE_AND_SET_NULL(gPokenavResources->substructPtrs[index]);
} }
u32 GetPokenavMode(void) u32 GetPokenavMode(void)

View File

@ -18,98 +18,98 @@ struct PokenavSub11
u32 monPal[3][0x20]; u32 monPal[3][0x20];
u8 fill[0x180]; u8 fill[0x180];
u32 monPicGfx[3][0x800]; u32 monPicGfx[3][0x800];
u8 unk6300; u8 searchMode;
s16 unk6302; s16 monIndex;
u32 (*unk6304)(struct PokenavSub11 *); u32 (*callback)(struct PokenavSub11 *);
u8 fill2[0x6320 - 0x6308]; u8 fill2[0x6320 - 0x6308];
u8 unk6320[3][24]; u8 searchLocBuffer[3][24];
u8 unk6368[3][64]; u8 nameBuffer[3][64];
struct ConditionGraph unk6428; struct ConditionGraph conditionData;
u8 unk6780[3]; u8 sheen[3];
u8 unk6783[3]; u8 monMarks[3];
s8 unk6786; s8 mark;
s8 unk6787; s8 unk6787;
s8 unk6788; s8 unk6788;
s8 unk6789; s8 unk6789;
u8 unk678A; u8 state;
}; };
void sub_81CD970(void); void InitPartyConditionListParameters(void);
void sub_81CD9F8(void); void sub_81CD9F8(void);
u32 sub_81CD08C(struct PokenavSub11 *structPtr); u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr);
u32 sub_81CD19C(struct PokenavSub11 *structPtr); u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr);
u32 sub_81CD110(struct PokenavSub11 *structPtr); u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr);
u8 sub_81CD1E4(struct PokenavSub11 *structPtr); u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr);
u8 sub_81CD258(u8 arg0); u8 SwitchConditionSummaryIndex(u8 moveUp);
void sub_81CD824(s16 arg0, u8 arg1); void CopyMonNameGenderLocation(s16 id, u8 arg1);
void sub_81CDA1C(s16 arg0, u8 arg1); void GetMonConditionGraphData(s16 id, u8 arg1);
void sub_81CDB98(s16 arg0, u8 arg1); void ConditionGraphDrawMonPic(s16 id, u8 arg1);
// code // 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) if (structPtr == NULL)
return FALSE; return FALSE;
sub_81D1ED4(&structPtr->unk6428); InitConditionGraphData(&structPtr->conditionData);
sub_81CD970(); InitPartyConditionListParameters();
gKeyRepeatStartDelay = 20; gKeyRepeatStartDelay = 20;
structPtr->unk6304 = sub_81CD08C; structPtr->callback = HandlePartyConditionInput;
return TRUE; 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) if (structPtr == NULL)
return FALSE; return FALSE;
sub_81D1ED4(&structPtr->unk6428); InitConditionGraphData(&structPtr->conditionData);
sub_81CD9F8(); sub_81CD9F8();
gKeyRepeatStartDelay = 20; gKeyRepeatStartDelay = 20;
structPtr->unk6304 = sub_81CD08C; structPtr->callback = HandlePartyConditionInput;
return TRUE; 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); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u32 ret = sub_81CD1E4(structPtr); u32 ret = ConditionGraphHandleDpadInput(structPtr);
if (ret == 0) if (ret == PARTY_CONDITION_FUNC_NONE)
{ {
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
structPtr->unk6304 = sub_81CD19C; structPtr->callback = GetConditionReturnCallback;
ret = 2; ret = PARTY_CONDITION_FUNC_RETURN;
} }
else if (JOY_NEW(A_BUTTON)) 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); PlaySE(SE_SELECT);
structPtr->unk6304 = sub_81CD19C; structPtr->callback = GetConditionReturnCallback;
ret = 2; ret = PARTY_CONDITION_FUNC_RETURN;
} }
} }
else else
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ret = 5; ret = PARTY_CONDITION_FUNC_ADD_MARKINGS;
structPtr->unk6304 = sub_81CD110; structPtr->callback = ConditionMenu_OpenMarkingsMenu;
} }
} }
} }
@ -117,204 +117,204 @@ u32 sub_81CD08C(struct PokenavSub11 *structPtr)
return ret; return ret;
} }
u32 sub_81CD110(struct PokenavSub11 *structPtr) u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr)
{ {
struct PokenavSub18 *unkPtr; struct PokenavSub18 *monListPtr;
u8 markings; 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(); structPtr->monMarks[structPtr->mark] = GetMonMarkingsData();
unkPtr = GetSubstructPtr(18); monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = unkPtr->unk4[unkPtr->unk2].boxId; boxId = monListPtr->monData[monListPtr->currIndex].boxId;
monId = unkPtr->unk4[unkPtr->unk2].monId; monId = monListPtr->monData[monListPtr->currIndex].monId;
markings = structPtr->unk6783[structPtr->unk6786]; markings = structPtr->monMarks[structPtr->mark];
if (boxId == TOTAL_BOXES_COUNT) if (boxId == TOTAL_BOXES_COUNT)
SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings); SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings);
else else
SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings); SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings);
structPtr->unk6304 = sub_81CD08C; structPtr->callback = HandlePartyConditionInput;
ret = 6; ret = PARTY_CONDITION_FUNC_CLOSE_MARKINGS;
} }
return ret; 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; return POKENAV_CONDITION_MENU;
else else
return POKENAV_MENU_A; return POKENAV_RETURN_CONDITION_SEARCH;
} }
void sub_81CD1C0(void) void FreePartyConditionSubstruct1(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->unk6300 == 0) if (structPtr->searchMode == 0)
FreePokenavSubstruct(18); 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; u8 ret = 0;
if (JOY_HELD(DPAD_UP)) if (JOY_HELD(DPAD_UP))
{ {
if (structPtr->unk6300 == 0 || unkPtr->unk2 != 0) if (structPtr->searchMode == 0 || monListPtr->currIndex != 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ret = sub_81CD258(1); ret = SwitchConditionSummaryIndex(1);
} }
} }
else if (JOY_HELD(DPAD_DOWN)) 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); PlaySE(SE_SELECT);
ret = sub_81CD258(0); ret = SwitchConditionSummaryIndex(0);
} }
} }
return ret; return ret;
} }
u8 sub_81CD258(u8 arg0) u8 SwitchConditionSummaryIndex(u8 moveUp)
{ {
u16 r7; u16 r7;
bool8 r6, r0; bool8 wasNotLastMon, isNotLastMon;
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
r7 = (arg0) ? structPtr->unk6788 : structPtr->unk6787; r7 = (moveUp) ? structPtr->unk6788 : structPtr->unk6787;
sub_81D1F84(&structPtr->unk6428, structPtr->unk6428.unk14[structPtr->unk6786], structPtr->unk6428.unk14[r7]); sub_81D1F84(&structPtr->conditionData, structPtr->conditionData.unk14[structPtr->mark], structPtr->conditionData.unk14[r7]);
r6 = (unkPtr->unk2 != ((sub_81CDD5C() != 0) ? unkPtr->unk0 : unkPtr->unk0 - 1)); wasNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1));
if (arg0) if (moveUp)
{ {
structPtr->unk6788 = structPtr->unk6787; structPtr->unk6788 = structPtr->unk6787;
structPtr->unk6787 = structPtr->unk6786; structPtr->unk6787 = structPtr->mark;
structPtr->unk6786 = r7; structPtr->mark = r7;
structPtr->unk6789 = structPtr->unk6788; structPtr->unk6789 = structPtr->unk6788;
unkPtr->unk2 = (unkPtr->unk2 == 0) ? unkPtr->unk0 - 1 : unkPtr->unk2 - 1; monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1;
structPtr->unk6302 = (unkPtr->unk2 != 0) ? unkPtr->unk2 - 1 : unkPtr->unk0 - 1; structPtr->monIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1;
} }
else else
{ {
structPtr->unk6787 = structPtr->unk6788; structPtr->unk6787 = structPtr->unk6788;
structPtr->unk6788 = structPtr->unk6786; structPtr->unk6788 = structPtr->mark;
structPtr->unk6786 = r7; structPtr->mark = r7;
structPtr->unk6789 = structPtr->unk6787; structPtr->unk6789 = structPtr->unk6787;
unkPtr->unk2 = (unkPtr->unk2 < unkPtr->unk0 - 1) ? unkPtr->unk2 + 1 : 0; monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
structPtr->unk6302 = (unkPtr->unk2 < unkPtr->unk0 - 1) ? unkPtr->unk2 + 1 : 0; structPtr->monIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
} }
r0 = (unkPtr->unk2 != ((sub_81CDD5C() != 0) ? unkPtr->unk0 : unkPtr->unk0 - 1)); isNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1));
if (!r6) if (!wasNotLastMon)
return 3; return PARTY_CONDITION_FUNC_NO_TRANSITION;
else if (!r0) else if (!isNotLastMon)
return 4; return PARTY_CONDITION_FUNC_SLIDE_MON_OUT;
else else
return 1; return PARTY_CONDITION_FUNC_SLIDE_MON_IN;
} }
bool32 sub_81CD3C4(void) bool32 LoadPartyConditionMenuGfx(void)
{ {
s32 var; s32 var;
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
switch (structPtr->unk678A) switch (structPtr->state)
{ {
case 0: case 0:
sub_81CD824(unkPtr->unk2, 0); CopyMonNameGenderLocation(monListPtr->currIndex, 0);
break; break;
case 1: case 1:
sub_81CDA1C(unkPtr->unk2, 0); GetMonConditionGraphData(monListPtr->currIndex, 0);
break; break;
case 2: case 2:
sub_81CDB98(unkPtr->unk2, 0); ConditionGraphDrawMonPic(monListPtr->currIndex, 0);
break; break;
case 3: case 3:
if (unkPtr->unk0 == 1) if (monListPtr->listCount == 1)
{ {
structPtr->unk6786 = 0; structPtr->mark = 0;
structPtr->unk6787 = 0; structPtr->unk6787 = 0;
structPtr->unk6788 = 0; structPtr->unk6788 = 0;
structPtr->unk678A = 0; structPtr->state = 0;
return TRUE; return TRUE;
} }
else else
{ {
structPtr->unk6786 = 0; structPtr->mark = 0;
structPtr->unk6787 = 1; structPtr->unk6787 = 1;
structPtr->unk6788 = 2; structPtr->unk6788 = 2;
} }
break; break;
// These were probably ternaries just like cases 7-9, but couldn't match it any other way. // These were probably ternaries just like cases 7-9, but couldn't match it any other way.
case 4: case 4:
var = unkPtr->unk2 + 1; var = monListPtr->currIndex + 1;
if (var >= unkPtr->unk0) if (var >= monListPtr->listCount)
var = 0; var = 0;
sub_81CD824(var, 1); CopyMonNameGenderLocation(var, 1);
break; break;
case 5: case 5:
var = unkPtr->unk2 + 1; var = monListPtr->currIndex + 1;
if (var >= unkPtr->unk0) if (var >= monListPtr->listCount)
var = 0; var = 0;
sub_81CDA1C(var, 1); GetMonConditionGraphData(var, 1);
break; break;
case 6: case 6:
var = unkPtr->unk2 + 1; var = monListPtr->currIndex + 1;
if (var >= unkPtr->unk0) if (var >= monListPtr->listCount)
var = 0; var = 0;
sub_81CDB98(var, 1); ConditionGraphDrawMonPic(var, 1);
break; break;
case 7: 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; break;
case 8: 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; break;
case 9: case 9:
sub_81CDB98((unkPtr->unk2 - 1 >= 0) ? unkPtr->unk2 - 1 : unkPtr->unk0 - 1, 2); ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
structPtr->unk678A = 0; structPtr->state = 0;
return TRUE; return TRUE;
} }
structPtr->unk678A++; structPtr->state++;
return FALSE; 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: case 0:
sub_81CD824(structPtr->unk6302, structPtr->unk6789); CopyMonNameGenderLocation(structPtr->monIndex, structPtr->unk6789);
break; break;
case 1: case 1:
sub_81CDA1C(structPtr->unk6302, structPtr->unk6789); GetMonConditionGraphData(structPtr->monIndex, structPtr->unk6789);
break; break;
case 2: case 2:
sub_81CDB98(structPtr->unk6302, structPtr->unk6789); ConditionGraphDrawMonPic(structPtr->monIndex, structPtr->unk6789);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
u8 *sub_81CD5CC(u8 *dst, const u8 *src, s16 n) u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n)
{ {
while (*src != EOS) while (*src != EOS)
*dst++ = *src++, n--; *dst++ = *src++, n--;
@ -326,15 +326,15 @@ u8 *sub_81CD5CC(u8 *dst, const u8 *src, s16 n)
return dst; 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; u16 boxId, monId, gender, species, level, lvlDigits;
struct BoxPokemon *boxMon; struct BoxPokemon *boxMon;
u8 *txtPtr, *str_; u8 *txtPtr, *str_;
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = unkPtr->unk4[id].boxId; boxId = monListPtr->monData[id].boxId;
monId = unkPtr->unk4[id].monId; monId = monListPtr->monData[id].monId;
*(str++) = EXT_CTRL_CODE_BEGIN; *(str++) = EXT_CTRL_CODE_BEGIN;
*(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; *(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str++) = TEXT_COLOR_BLUE; *(str++) = TEXT_COLOR_BLUE;
@ -417,115 +417,115 @@ u8 *sub_81CD624(u8 *str, u16 id, bool8 arg3)
return str_; return str_;
} }
void sub_81CD824(s16 arg0, u8 arg1) void CopyMonNameGenderLocation(s16 id, u8 arg1)
{ {
u16 boxId, i; u16 boxId, i;
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); 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); CopyMonConditionNameGender(structPtr->nameBuffer[arg1], id, FALSE);
boxId = unkPtr->unk4[arg0].boxId; boxId = monListPtr->monData[id].boxId;
structPtr->unk6320[arg1][0] = EXT_CTRL_CODE_BEGIN; structPtr->searchLocBuffer[arg1][0] = EXT_CTRL_CODE_BEGIN;
structPtr->unk6320[arg1][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; structPtr->searchLocBuffer[arg1][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
structPtr->unk6320[arg1][2] = TEXT_COLOR_BLUE; structPtr->searchLocBuffer[arg1][2] = TEXT_COLOR_BLUE;
structPtr->unk6320[arg1][3] = TEXT_COLOR_TRANSPARENT; structPtr->searchLocBuffer[arg1][3] = TEXT_COLOR_TRANSPARENT;
structPtr->unk6320[arg1][4] = TEXT_COLOR_LIGHT_BLUE; structPtr->searchLocBuffer[arg1][4] = TEXT_COLOR_LIGHT_BLUE;
if (boxId == TOTAL_BOXES_COUNT) if (boxId == TOTAL_BOXES_COUNT)
sub_81CD5CC(&structPtr->unk6320[arg1][5], gText_InParty, 8); CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], gText_InParty, 8);
else else
sub_81CD5CC(&structPtr->unk6320[arg1][5], GetBoxNamePtr(boxId), 8); CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], GetBoxNamePtr(boxId), 8);
} }
else else
{ {
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
structPtr->unk6368[arg1][i] = CHAR_SPACE; structPtr->nameBuffer[arg1][i] = CHAR_SPACE;
structPtr->unk6368[arg1][i] = EOS; structPtr->nameBuffer[arg1][i] = EOS;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
structPtr->unk6320[arg1][i] = CHAR_SPACE; structPtr->searchLocBuffer[arg1][i] = CHAR_SPACE;
structPtr->unk6320[arg1][i] = EOS; structPtr->searchLocBuffer[arg1][i] = EOS;
} }
} }
void sub_81CD970(void) void InitPartyConditionListParameters(void)
{ {
u16 i, count; u16 i, count;
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *unkPtr = AllocSubstruct(18, sizeof(struct PokenavSub18)); 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++) for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++)
{ {
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
{ {
unkPtr->unk4[count].boxId = TOTAL_BOXES_COUNT; monListPtr->monData[count].boxId = TOTAL_BOXES_COUNT;
unkPtr->unk4[count].monId = i; monListPtr->monData[count].monId = i;
unkPtr->unk4[count].data = 0; monListPtr->monData[count].data = 0;
count++; count++;
} }
} }
unkPtr->unk4[count].boxId = 0; monListPtr->monData[count].boxId = 0;
unkPtr->unk4[count].monId = 0; monListPtr->monData[count].monId = 0;
unkPtr->unk4[count].data = 0; monListPtr->monData[count].data = 0;
unkPtr->unk2 = 0; monListPtr->currIndex = 0;
unkPtr->unk0 = count + 1; monListPtr->listCount = count + 1;
structPtr->unk678A = 0; structPtr->state = 0;
} }
void sub_81CD9F8(void) void sub_81CD9F8(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
structPtr->unk6300 = 1; structPtr->searchMode = 1;
structPtr->unk678A = 0; structPtr->state = 0;
} }
void sub_81CDA1C(s16 arg0, u8 arg1) void GetMonConditionGraphData(s16 id, u8 arg1)
{ {
u16 boxId, monId, i; u16 boxId, monId, i;
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); 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; boxId = monListPtr->monData[id].boxId;
monId = unkPtr->unk4[arg0].monId; monId = monListPtr->monData[id].monId;
structPtr->unk6428.unk0[arg1][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); structPtr->conditionData.stat[arg1][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
structPtr->unk6428.unk0[arg1][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); structPtr->conditionData.stat[arg1][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
structPtr->unk6428.unk0[arg1][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); structPtr->conditionData.stat[arg1][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
structPtr->unk6428.unk0[arg1][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); structPtr->conditionData.stat[arg1][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
structPtr->unk6428.unk0[arg1][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); structPtr->conditionData.stat[arg1][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
structPtr->unk6780[arg1] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 255) structPtr->sheen[arg1] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 255)
? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u
: 9; : 9;
structPtr->unk6783[arg1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); structPtr->monMarks[arg1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
sub_81D2754(structPtr->unk6428.unk0[arg1], structPtr->unk6428.unk14[arg1]); sub_81D2754(structPtr->conditionData.stat[arg1], structPtr->conditionData.unk14[arg1]);
} }
else else
{ {
for (i = 0; i < 5; i++) for (i = 0; i < FLAVOR_COUNT; i++)
{ {
structPtr->unk6428.unk0[arg1][i] = 0; structPtr->conditionData.stat[arg1][i] = 0;
structPtr->unk6428.unk14[arg1][i].unk0 = 155; structPtr->conditionData.unk14[arg1][i].unk0 = 155;
structPtr->unk6428.unk14[arg1][i].unk2 = 91; structPtr->conditionData.unk14[arg1][i].unk2 = 91;
} }
} }
} }
void sub_81CDB98(s16 arg0, u8 arg1) void ConditionGraphDrawMonPic(s16 index, u8 arg1)
{ {
u16 boxId, monId, species; u16 boxId, monId, species;
u32 personality, tid; u32 personality, tid;
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); 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; return;
boxId = unkPtr->unk4[arg0].boxId; boxId = monListPtr->monData[index].boxId;
monId = unkPtr->unk4[arg0].monId; monId = monListPtr->monData[index].monId;
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL);
tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL);
personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, 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]); LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[arg1]);
} }
u16 sub_81CDC50(void) u16 GetMonListCount(void)
{ {
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return unkPtr->unk0; return monListPtr->listCount;
} }
u16 sub_81CDC60(void) u16 GetConditionGraphCurrentMonIndex(void)
{ {
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return unkPtr->unk2; return monListPtr->currIndex;
} }
struct ConditionGraph *sub_81CDC70(void) struct ConditionGraph *GetConditionGraphDataPtr(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return &structPtr->unk6428; return &structPtr->conditionData;
} }
u8 sub_81CDC84(void) u8 GetMonMarkIndex(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->unk6786; return structPtr->mark;
} }
u8 sub_81CDC9C(void) u8 sub_81CDC9C(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->unk6302; 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]; 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]; return structPtr->monPal[id];
} }
u8 sub_81CDCEC(void) u8 sub_81CDCEC(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->unk6789; return structPtr->unk6789;
} }
u8 *sub_81CDD04(u8 id) u8 *GetConditionMonNameBuffer(u8 id)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->unk6368[id]; return structPtr->nameBuffer[id];
} }
u8 *sub_81CDD24(u8 id) u8 *GetConditionMonLocationBuffer(u8 id)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->unk6320[id]; return structPtr->searchLocBuffer[id];
} }
u16 sub_81CDD48(void) u16 GetConditionMonDataBuffer(void)
{ {
struct PokenavSub18 *unkPtr = GetSubstructPtr(18); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return unkPtr->unk4[unkPtr->unk2].data; return monListPtr->monData[monListPtr->currIndex].data;
} }
bool32 sub_81CDD5C(void) bool32 IsConditionMenuSearchMode(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->unk6300 == 1) if (structPtr->searchMode == 1)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
u8 sub_81CDD7C(void) u8 TryGetMonMarkId(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->unk6300 == 1) if (structPtr->searchMode == 1)
return structPtr->unk6783[structPtr->unk6786]; return structPtr->monMarks[structPtr->mark];
else else
return 0; return 0;
} }
u8 sub_81CDDB0(void) u8 GetMonSheen(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(11); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->unk6780[structPtr->unk6786]; return structPtr->sheen[structPtr->mark];
} }

File diff suppressed because it is too large Load Diff

View File

@ -10,67 +10,78 @@
#include "international_string_util.h" #include "international_string_util.h"
#include "constants/songs.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 struct PokenavSub7
{ {
u32 (*unk0)(struct PokenavSub7 *); u32 (*callback)(struct PokenavSub7 *);
u32 loopedTaskId; u32 loopedTaskId;
u8 fill1[4]; u8 fill1[4];
s32 unkC; s32 boxId;
s32 unk10; s32 monId;
u32 unk14; u32 conditionDataId;
u32 unk18; u32 returnFromGraph;
u32 unk1C; u32 isPartyCondition;
struct PokenavSub18 *unkPtr; struct PokenavSub18 *monList;
}; };
struct PokenavSub8 struct PokenavSub8
{ {
bool32 (*callback)(void); bool32 (*callback)(void);
u32 ltid; u32 ltid; //looped task Id
u16 winid; u16 winid;
bool32 unkC; bool32 fromGraph;
u8 buff[BG_SCREEN_SIZE]; u8 buff[BG_SCREEN_SIZE];
}; // size: 0x810 }; // size: 0x810
static u32 sub_81CF010(struct PokenavSub7 *structPtr); static u32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr);
static u32 sub_81CF030(struct PokenavSub7 *structPtr); static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr);
static u32 sub_81CF0B8(struct PokenavSub7 *structPtr); static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr);
static u32 sub_81CF0B0(struct PokenavSub7 *structPtr); static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr);
static u32 sub_81CF11C(s32 state); static u32 GetConditionSearchLoopedTask(s32 state);
static u32 sub_81CF134(s32 state); static u32 BuildPartyMonSearchResults(s32 state);
static u32 sub_81CF1C4(s32 state); static u32 InitBoxMonSearchResults(s32 state);
static u32 sub_81CF1D8(s32 state); static u32 BuildBoxMonSearchResults(s32 state);
static u32 sub_81CF278(s32 state); static u32 sub_81CF278(s32 state);
static u32 sub_81CF578(s32 state); static u32 LoopedTask_MoveSearchListCursorUp(s32 state);
static u32 sub_81CF5F0(s32 state); static u32 LoopedTask_MoveSearchListCursorDown(s32 state);
static u32 sub_81CF668(s32 state); static u32 LoopedTask_MoveSearchListPageUp(s32 state);
static u32 sub_81CF6E0(s32 state); static u32 LoopedTask_MoveSearchListPageDown(s32 state);
static u32 sub_81CF758(s32 state); static u32 LoopedTask_ExitConditionSearchMenu(s32 state);
static u32 sub_81CF798(s32 state); static u32 LoopedTask_SelectSearchResult(s32 state);
static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item); static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item);
static bool32 sub_81CF3E4(void); static bool32 GetSearchResultCurrentLoopedTaskActive(void);
static u32 sub_81CF418(s32 state); static u32 LoopedTask_OpenConditionSearchResults(s32 state);
static void sub_81CF7C8(struct PokenavSub8 *); static void AddSearchResultListMenuWindow(struct PokenavSub8 *);
static void sub_81CF7F4(struct PokenavSub8 *); static void PrintSearchResultListMenuItems(struct PokenavSub8 *);
static void sub_81CF88C(void); static void InitConditionSearchListMenuTemplate(void);
static void sub_81CF8E4(struct PokenavMonList *, u8 *); 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, BuildPartyMonSearchResults,
sub_81CF1C4, InitBoxMonSearchResults,
sub_81CF1D8, BuildBoxMonSearchResults,
sub_81CF278 sub_81CF278
}; };
static const u16 gUnknown_086233C4[] = INCBIN_U16("graphics/pokenav/condition_search2.gbapal"); static const u16 sConditionSearchResultFramePal[] = INCBIN_U16("graphics/pokenav/condition_search2.gbapal");
static const u32 gUnknown_086233E4[] = INCBIN_U32("graphics/pokenav/condition_search2.4bpp.lz"); static const u32 sConditionSearchResultTiles[] = INCBIN_U32("graphics/pokenav/condition_search2.4bpp.lz");
static const u32 gUnknown_086234AC[] = INCBIN_U32("graphics/pokenav/condition_search2.bin.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 u16 gUnknown_08623570[] = INCBIN_U16("graphics/pokenav/8623570.gbapal");
static const struct BgTemplate gUnknown_08623590[] = static const struct BgTemplate sConditionSearchResultBgTemplates[] =
{ {
{ {
.bg = 1, .bg = 1,
@ -91,18 +102,18 @@ static const struct BgTemplate gUnknown_08623590[] =
} }
}; };
static const LoopedTask gUnknown_08623598[] = static const LoopedTask sSearchResultLoopTaskFuncs[] =
{ {
NULL, [CONDITION_SEARCH_FUNC_NONE] = NULL,
sub_81CF578, [CONDITION_SEARCH_FUNC_MOVE_UP] = LoopedTask_MoveSearchListCursorUp,
sub_81CF5F0, [CONDITION_SEARCH_FUNC_MOVE_DOWN] = LoopedTask_MoveSearchListCursorDown,
sub_81CF668, [CONDITION_SEARCH_FUNC_PAGE_UP] = LoopedTask_MoveSearchListPageUp,
sub_81CF6E0, [CONDITION_SEARCH_FUNC_PAGE_DOWN] = LoopedTask_MoveSearchListPageDown,
sub_81CF758, [CONDITION_SEARCH_FUNC_EXIT] = LoopedTask_ExitConditionSearchMenu,
sub_81CF798 [CONDITION_SEARCH_FUNC_SELECT_MON] = LoopedTask_SelectSearchResult
}; };
static const struct WindowTemplate gUnknown_086235B4 = static const struct WindowTemplate sSearchResultListMenuWindowTemplate =
{ {
.bg = 1, .bg = 1,
.tilemapLeft = 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_FemaleSymbol[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}");
static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}"); 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)); struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7));
if (structPtr == NULL) if (structPtr == NULL)
return FALSE; return FALSE;
structPtr->unkPtr = AllocSubstruct(18, sizeof(struct PokenavSub18)); structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
if (structPtr->unkPtr == NULL) if (structPtr->monList == NULL)
return FALSE; return FALSE;
structPtr->unk0 = sub_81CF010; structPtr->callback = HandleConditionSearchInput_WaitSetup;
structPtr->loopedTaskId = CreateLoopedTask(sub_81CF11C, 1); structPtr->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1);
structPtr->unk18 = 0; structPtr->returnFromGraph = 0;
structPtr->unk14 = gUnknown_086233A0[GetSelectedConditionSearch()]; structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()];
return TRUE; 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) if (structPtr == NULL)
return FALSE; return FALSE;
structPtr->unkPtr = GetSubstructPtr(18); structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
structPtr->unk0 = sub_81CF030; structPtr->callback = HandleConditionSearchInput;
structPtr->unk18 = 1; structPtr->returnFromGraph = 1;
structPtr->unk14 = gUnknown_086233A0[GetSelectedConditionSearch()]; structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()];
return TRUE; return TRUE;
} }
u32 sub_81CEFDC(void) u32 GetConditionSearchResultsCallback(void)
{ {
struct PokenavSub7 *structPtr = GetSubstructPtr(7); struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return structPtr->unk0(structPtr); return structPtr->callback(structPtr);
} }
void sub_81CEFF0(void) void FreeSearchResultSubstruct1(void)
{ {
struct PokenavSub7 *structPtr = GetSubstructPtr(7); struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
if (structPtr->unk1C == 0) if (structPtr->isPartyCondition == 0)
FreePokenavSubstruct(18); FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(7); FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
} }
static bool32 sub_81CF010(struct PokenavSub7 *structPtr) static bool32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr)
{ {
if (!IsLoopedTaskActive(structPtr->loopedTaskId)) if (!IsLoopedTaskActive(structPtr->loopedTaskId))
structPtr->unk0 = sub_81CF030; structPtr->callback = HandleConditionSearchInput;
return FALSE; return FALSE;
} }
static u32 sub_81CF030(struct PokenavSub7 *structPtr) static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr)
{ {
if (JOY_REPEAT(DPAD_UP)) if (JOY_REPEAT(DPAD_UP))
return 1; return CONDITION_SEARCH_FUNC_MOVE_UP;
if (JOY_REPEAT(DPAD_DOWN)) if (JOY_REPEAT(DPAD_DOWN))
return 2; return CONDITION_SEARCH_FUNC_MOVE_DOWN;
if (JOY_NEW(DPAD_LEFT)) if (JOY_NEW(DPAD_LEFT))
return 3; return CONDITION_SEARCH_FUNC_PAGE_UP;
if (JOY_NEW(DPAD_RIGHT)) if (JOY_NEW(DPAD_RIGHT))
return 4; return CONDITION_SEARCH_FUNC_PAGE_DOWN;
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
{ {
structPtr->unk1C = 0; structPtr->isPartyCondition = 0;
structPtr->unk0 = sub_81CF0B0; structPtr->callback = ReturnToConditionSearchList;
return 5; return CONDITION_SEARCH_FUNC_EXIT;
} }
if (JOY_NEW(A_BUTTON)) if (JOY_NEW(A_BUTTON))
{ {
structPtr->unkPtr->unk2 = GetSelectedMatchCall(); structPtr->monList->currIndex = GetSelectedPokenavListIndex();
structPtr->unk1C = 1; structPtr->isPartyCondition = 1;
structPtr->unk0 = sub_81CF0B8; structPtr->callback = OpenConditionGraphFromSearchList;
return 6; 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; return POKENAV_CONDITION_SEARCH_MENU;
} }
static u32 sub_81CF0B8(struct PokenavSub7 *structPtr) static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr)
{ {
return POKENAV_MENU_9; return POKENAV_CONDITION_GRAPH_FROM_SEARCH;
} }
static u32 sub_81CF0C0(void) static u32 sub_81CF0C0(void)
{ {
struct PokenavSub7 *structPtr = GetSubstructPtr(7); struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return structPtr->unk18; return structPtr->returnFromGraph;
} }
static struct PokenavMonList * sub_81CF0D0(void) static struct PokenavMonList * GetSearchResultsMonDataList(void)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(7); struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->unkPtr->unk4; return ptr->monList->monData;
} }
static u16 sub_81CF0E0(void) static u16 GetSearchResultsMonListCount(void)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(7); struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->unkPtr->unk0; return ptr->monList->listCount;
} }
static s32 sub_81CF0F0(void) static s32 GetSearchResultsSelectedMonData(void)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(7); struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 i = GetSelectedMatchCall(); s32 i = GetSelectedPokenavListIndex();
return ptr->unkPtr->unk4[i].data; return ptr->monList->monData[i].data;
} }
static u16 sub_81CF10C(void) static u16 sub_81CF10C(void)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(7); struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->unkPtr->unk2; 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; s32 i;
struct PokenavMonList item; struct PokenavMonList item;
struct PokenavSub7 * ptr = GetSubstructPtr(7); struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
ptr->unkPtr->unk0 = 0; ptr->monList->listCount = 0;
ptr->unkPtr->unk2 = 0; ptr->monList->currIndex = 0;
item.boxId = 14; item.boxId = 14;
for (i = 0; i < PARTY_SIZE; i++) 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)) if (!GetMonData(pokemon, MON_DATA_SANITY_IS_EGG))
{ {
item.monId = i; item.monId = i;
item.data = GetMonData(pokemon, ptr->unk14); item.data = GetMonData(pokemon, ptr->conditionDataId);
sub_81CF2C4(ptr, &item); sub_81CF2C4(ptr, &item);
} }
} }
@ -265,19 +277,19 @@ static u32 sub_81CF134(s32 state)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
static u32 sub_81CF1C4(s32 state) static u32 InitBoxMonSearchResults(s32 state)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(7); struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
ptr->unk10 = 0; ptr->monId = 0;
ptr->unkC = 0; ptr->boxId = 0;
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
static u32 sub_81CF1D8(s32 state) static u32 BuildBoxMonSearchResults(s32 state)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(7); struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 boxId = ptr->unkC; s32 boxId = ptr->boxId;
s32 monId = ptr->unk10; s32 monId = ptr->monId;
s32 boxCount = 0; s32 boxCount = 0;
struct PokenavMonList item; struct PokenavMonList item;
@ -289,15 +301,15 @@ static u32 sub_81CF1D8(s32 state)
{ {
item.boxId = boxId; item.boxId = boxId;
item.monId = monId; item.monId = monId;
item.data = GetBoxMonDataAt(boxId, monId, ptr->unk14); item.data = GetBoxMonDataAt(boxId, monId, ptr->conditionDataId);
sub_81CF2C4(ptr, &item); sub_81CF2C4(ptr, &item);
} }
boxCount++; boxCount++;
monId++; monId++;
if (boxCount > 14) if (boxCount > 14)
{ {
ptr->unkC = boxId; ptr->boxId = boxId;
ptr->unk10 = monId; ptr->monId = monId;
return LT_CONTINUE; return LT_CONTINUE;
} }
} }
@ -310,108 +322,108 @@ static u32 sub_81CF1D8(s32 state)
static u32 sub_81CF278(s32 state) static u32 sub_81CF278(s32 state)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(7); struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 r6 = ptr->unkPtr->unk0; s32 r6 = ptr->monList->listCount;
s32 r4 = ptr->unkPtr->unk4[0].data; s32 r4 = ptr->monList->monData[0].data;
s32 i; s32 i;
ptr->unkPtr->unk4[0].data = 1; ptr->monList->monData[0].data = 1;
for (i = 1; i < r6; i++) 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 else
{ {
r4 = ptr->unkPtr->unk4[i].data; r4 = ptr->monList->monData[i].data;
ptr->unkPtr->unk4[i].data = i + 1; ptr->monList->monData[i].data = i + 1;
} }
} }
ptr->unk18 = 1; ptr->returnFromGraph = 1;
return LT_FINISH; return LT_FINISH;
} }
static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item) static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item)
{ {
u32 left = 0; u32 left = 0;
u32 right = structPtr->unkPtr->unk0; u32 right = structPtr->monList->listCount;
u32 insertionIdx = left + (right - left) / 2; u32 insertionIdx = left + (right - left) / 2;
while (right != insertionIdx) while (right != insertionIdx)
{ {
if (item->data > structPtr->unkPtr->unk4[insertionIdx].data) if (item->data > structPtr->monList->monData[insertionIdx].data)
right = insertionIdx; right = insertionIdx;
else else
left = insertionIdx + 1; left = insertionIdx + 1;
insertionIdx = left + (right - left) / 2; insertionIdx = left + (right - left) / 2;
} }
for (right = structPtr->unkPtr->unk0; right > insertionIdx; right--) for (right = structPtr->monList->listCount; right > insertionIdx; right--)
structPtr->unkPtr->unk4[right] = structPtr->unkPtr->unk4[right - 1]; structPtr->monList->monData[right] = structPtr->monList->monData[right - 1];
structPtr->unkPtr->unk4[insertionIdx] = *item; structPtr->monList->monData[insertionIdx] = *item;
structPtr->unkPtr->unk0++; structPtr->monList->listCount++;
} }
bool32 sub_81CF330(void) bool32 OpenConditionSearchResults(void)
{ {
struct PokenavSub8 * unk = AllocSubstruct(8, sizeof(struct PokenavSub8)); struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8));
if (unk == NULL) if (searchList == NULL)
return FALSE; return FALSE;
unk->ltid = CreateLoopedTask(sub_81CF418, 1); searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1);
unk->callback = sub_81CF3E4; searchList->callback = GetSearchResultCurrentLoopedTaskActive;
unk->unkC = FALSE; searchList->fromGraph = FALSE;
return TRUE; return TRUE;
} }
bool32 sub_81CF368(void) bool32 OpenConditionSearchListFromGraph(void)
{ {
struct PokenavSub8 * unk = AllocSubstruct(8, sizeof(struct PokenavSub8)); struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8));
if (unk == NULL) if (searchList == NULL)
return FALSE; return FALSE;
unk->ltid = CreateLoopedTask(sub_81CF418, 1); searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1);
unk->callback = sub_81CF3E4; searchList->callback = GetSearchResultCurrentLoopedTaskActive;
unk->unkC = TRUE; searchList->fromGraph = TRUE;
return TRUE; return TRUE;
} }
void sub_81CF3A0(s32 idx) void CreateSearchResultsLoopedTask(s32 idx)
{ {
struct PokenavSub8 * unk = GetSubstructPtr(8); struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
unk->ltid = CreateLoopedTask(gUnknown_08623598[idx], 1); searchList->ltid = CreateLoopedTask(sSearchResultLoopTaskFuncs[idx], 1);
unk->callback = sub_81CF3E4; searchList->callback = GetSearchResultCurrentLoopedTaskActive;
} }
bool32 sub_81CF3D0(void) bool32 IsSearchResultLoopedTaskActive(void)
{ {
struct PokenavSub8 * unk = GetSubstructPtr(8); struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
return unk->callback(); return searchList->callback();
} }
bool32 sub_81CF3E4(void) bool32 GetSearchResultCurrentLoopedTaskActive(void)
{ {
struct PokenavSub8 * unk = GetSubstructPtr(8); struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST);
return IsLoopedTaskActive(unk->ltid); 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(); sub_81C8234();
RemoveWindow(unk->winid); RemoveWindow(searchList->winid);
FreePokenavSubstruct(8); 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) switch (state)
{ {
case 0: case 0:
InitBgTemplates(gUnknown_08623590, NELEMS(gUnknown_08623590)); InitBgTemplates(sConditionSearchResultBgTemplates, NELEMS(sConditionSearchResultBgTemplates));
DecompressAndCopyTileDataToVram(1, gUnknown_086233E4, 0, 0, 0); DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0);
SetBgTilemapBuffer(1, unk->buff); SetBgTilemapBuffer(1, searchList->buff);
CopyToBgTilemapBuffer(1, gUnknown_086234AC, 0, 0); CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyPaletteIntoBufferUnfaded(gUnknown_086233C4, 0x10, 0x20); CopyPaletteIntoBufferUnfaded(sConditionSearchResultFramePal, 0x10, 0x20);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
@ -423,13 +435,13 @@ static u32 sub_81CF418(s32 state)
case 2: case 2:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 0x20); CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 32);
sub_81CF88C(); InitConditionSearchListMenuTemplate();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (sub_81C8224()) if (sub_81C8224())
return LT_PAUSE; return LT_PAUSE;
sub_81CF7C8(unk); AddSearchResultListMenuWindow(searchList);
PrintHelpBarText(HELPBAR_CONDITION_MON_LIST); PrintHelpBarText(HELPBAR_CONDITION_MON_LIST);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 4: case 4:
@ -440,28 +452,28 @@ static u32 sub_81CF418(s32 state)
ShowBg(1); ShowBg(1);
ShowBg(2); ShowBg(2);
HideBg(3); HideBg(3);
if (!unk->unkC) if (!searchList->fromGraph)
{ {
u8 r4 = GetSelectedConditionSearch() + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; u8 searchGfxId = GetSelectedConditionSearch() + POKENAV_MENUITEM_CONDITION_SEARCH_COOL;
LoadLeftHeaderGfxForIndex(r4); LoadLeftHeaderGfxForIndex(searchGfxId);
sub_81C7FA0(r4, 1, 0); ShowLeftHeaderGfx(searchGfxId, 1, 0);
sub_81C7FA0(1, 1, 0); ShowLeftHeaderGfx(POKENAV_GFX_CONDITION_MENU, 1, 0);
} }
PokenavFadeScreen(1); PokenavFadeScreen(1);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 5: case 5:
if (IsPaletteFadeActive()) if (IsPaletteFadeActive())
return LT_PAUSE; return LT_PAUSE;
if (sub_81C8010()) if (AreLeftHeaderSpritesMoving())
return LT_PAUSE; return LT_PAUSE;
break; break;
} }
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -478,11 +490,11 @@ static u32 sub_81CF578(s32 state)
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
sub_81CF7F4(unk); PrintSearchResultListMenuItems(searchList);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -492,9 +504,9 @@ static u32 sub_81CF578(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -511,11 +523,11 @@ static u32 sub_81CF5F0(s32 state)
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
sub_81CF7F4(unk); PrintSearchResultListMenuItems(searchList);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -525,9 +537,9 @@ static u32 sub_81CF5F0(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -544,11 +556,11 @@ static u32 sub_81CF668(s32 state)
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
sub_81CF7F4(unk); PrintSearchResultListMenuItems(searchList);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -558,9 +570,9 @@ static u32 sub_81CF668(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -577,11 +589,11 @@ static u32 sub_81CF6E0(s32 state)
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
sub_81CF7F4(unk); PrintSearchResultListMenuItems(searchList);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -591,27 +603,27 @@ static u32 sub_81CF6E0(s32 state)
return LT_FINISH; return LT_FINISH;
} }
static u32 sub_81CF758(s32 state) static u32 LoopedTask_ExitConditionSearchMenu(s32 state)
{ {
switch (state) switch (state)
{ {
case 0: case 0:
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
PokenavFadeScreen(0); PokenavFadeScreen(0);
sub_81C78A0(); SlideMenuHeaderDown();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (IsPaletteFadeActive()) if (IsPaletteFadeActive())
return LT_PAUSE; return LT_PAUSE;
if (MainMenuLoopedTaskIsBusy()) if (MainMenuLoopedTaskIsBusy())
return LT_PAUSE; return LT_PAUSE;
sub_81C7FDC(); SetLeftHeaderSpritesInvisibility();
break; break;
} }
return LT_FINISH; return LT_FINISH;
} }
static u32 sub_81CF798(s32 state) static u32 LoopedTask_SelectSearchResult(s32 state)
{ {
switch (state) switch (state)
{ {
@ -627,46 +639,47 @@ static u32 sub_81CF798(s32 state)
return LT_FINISH; return LT_FINISH;
} }
static void sub_81CF7C8(struct PokenavSub8 * ptr) static void AddSearchResultListMenuWindow(struct PokenavSub8 *searchList)
{ {
ptr->winid = AddWindow(&gUnknown_086235B4); searchList->winid = AddWindow(&sSearchResultListMenuWindowTemplate);
PutWindowTilemap(ptr->winid); PutWindowTilemap(searchList->winid);
CopyWindowToVram(ptr->winid, 1); CopyWindowToVram(searchList->winid, 1);
sub_81CF7F4(ptr); 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_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
*gStringVar1 = EOS; *gStringVar1 = EOS;
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberF700); 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); ConvertIntToDecimalStringN(gStringVar1, r7, STR_CONV_MODE_RIGHT_ALIGN, 3);
AddTextPrinterParameterized(ptr->winid, 1, gStringVar1, 34, 1, 0xFF, NULL); AddTextPrinterParameterized(searchList->winid, 1, gStringVar1, 34, 1, 0xFF, NULL);
CopyWindowToVram(ptr->winid, 2); CopyWindowToVram(searchList->winid, 2);
} }
static void sub_81CF88C(void) static void InitConditionSearchListMenuTemplate(void)
{ {
struct PokenavListTemplate template; struct PokenavListTemplate template;
template.list.monList = sub_81CF0D0();
template.unk4 = sub_81CF0E0(); template.list.monList = GetSearchResultsMonDataList();
template.count = GetSearchResultsMonListCount();
template.unk8 = 4; template.unk8 = 4;
template.unk6 = sub_81CF10C(); template.unk6 = sub_81CF10C();
template.unk9 = 13; template.item_X = 13;
template.unkA = 17; template.windowWidth = 17;
template.unkB = 1; template.listTop = 1;
template.unkC = 8; template.maxShowed = 8;
template.unkD = 2; template.fillValue = 2;
template.unkE = 1; template.fontId = 1;
template.listFunc.unk10_1 = sub_81CF8E4; template.listFunc.printMonFunc = PrintSearchMonListItem;
template.unk14 = NULL; 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 gender;
u8 level; u8 level;

View File

@ -15,9 +15,9 @@
struct PokenavMainMenuResources struct PokenavMainMenuResources
{ {
void (*unk0)(u32); void (*loopTask)(u32);
u32 (*unk4)(void); u32 (*isLoopTaskActiveFunc)(void);
u32 unk8; u32 unused;
u32 currentTaskId; u32 currentTaskId;
u32 helpBarWindowId; u32 helpBarWindowId;
u32 palettes; u32 palettes;
@ -47,8 +47,8 @@ static void SpriteCB_MoveLeftHeader(struct Sprite *sprite);
static void InitPokenavMainMenuResources(void); static void InitPokenavMainMenuResources(void);
static void InitHoennMapHeaderSprites(void); static void InitHoennMapHeaderSprites(void);
static void InitHelpBar(void); static void InitHelpBar(void);
static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0); static u32 LoopedTask_SlideMenuHeaderUp(s32 a0);
static u32 LoopedTask_ScrollMenuHeaderUp(s32 a0); static u32 LoopedTask_SlideMenuHeaderDown(s32 a0);
static void DrawHelpBar(u32 windowId); static void DrawHelpBar(u32 windowId);
static void SpriteCB_SpinningPokenav(struct Sprite* sprite); static void SpriteCB_SpinningPokenav(struct Sprite* sprite);
static u32 LoopedTask_InitPokenavMenu(s32 a0); static u32 LoopedTask_InitPokenavMenu(s32 a0);
@ -294,7 +294,7 @@ bool32 InitPokenavMainMenu(void)
{ {
struct PokenavMainMenuResources *structPtr; struct PokenavMainMenuResources *structPtr;
structPtr = AllocSubstruct(0, sizeof(struct PokenavMainMenuResources)); structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU, sizeof(struct PokenavMainMenuResources));
if (structPtr == NULL) if (structPtr == NULL)
return FALSE; return FALSE;
@ -306,14 +306,14 @@ bool32 InitPokenavMainMenu(void)
u32 PokenavMainMenuLoopedTaskIsActive(void) u32 PokenavMainMenuLoopedTaskIsActive(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return IsLoopedTaskActive(structPtr->currentTaskId); return IsLoopedTaskActive(structPtr->currentTaskId);
} }
void ShutdownPokenav(void) void ShutdownPokenav(void)
{ {
PlaySE(SE_POKENAV_OFF); PlaySE(SE_POKENAV_OFF);
sub_81CAADC(); ResetBldCnt_();
BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK);
} }
@ -345,7 +345,7 @@ static u32 LoopedTask_InitPokenavMenu(s32 a0)
ResetTempTileDataBuffers(); ResetTempTileDataBuffers();
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 1: case 1:
structPtr = GetSubstructPtr(0); structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0); DecompressAndCopyTileDataToVram(0, &gPokenavHeader_Gfx, 0, 0, 0);
SetBgTilemapBuffer(0, structPtr->tilemapBuffer); SetBgTilemapBuffer(0, structPtr->tilemapBuffer);
CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0); 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); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->unk0 = func1; structPtr->loopTask = createLoopTask;
structPtr->unk4 = func2; structPtr->isLoopTaskActiveFunc = isLoopTaskActive;
structPtr->unk8 = 0; structPtr->unused = 0;
} }
void sub_81C7850(u32 a0) void RunMainMenuLoopedTask(u32 a0)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->unk8 = 0; structPtr->unused = 0;
structPtr->unk0(a0); structPtr->loopTask(a0);
} }
u32 sub_81C786C(void) u32 IsActiveMenuLoopTaskActive(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return structPtr->unk4(); return structPtr->isLoopTaskActiveFunc();
} }
void sub_81C7880(void) void SlideMenuHeaderUp(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->currentTaskId = CreateLoopedTask(LoopedTask_ScrollMenuHeaderDown, 4); structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderUp, 4);
} }
void sub_81C78A0(void) void SlideMenuHeaderDown(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->currentTaskId = CreateLoopedTask(LoopedTask_ScrollMenuHeaderUp, 4); structPtr->currentTaskId = CreateLoopedTask(LoopedTask_SlideMenuHeaderDown, 4);
} }
bool32 MainMenuLoopedTaskIsBusy(void) bool32 MainMenuLoopedTaskIsBusy(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
return IsLoopedTaskActive(structPtr->currentTaskId); return IsLoopedTaskActive(structPtr->currentTaskId);
} }
static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0) static u32 LoopedTask_SlideMenuHeaderUp(s32 a0)
{ {
switch (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) 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) if (a4 == 0)
{ {
CpuCopy16(a0, palette, a2 * 2); CpuCopy16(src, palette, size * 2);
} }
else if (a4 >= a3) else if (a4 >= a3)
{ {
CpuCopy16(a1, palette, a2 * 2); CpuCopy16(dest, palette, size * 2);
} }
else else
{ {
int r, g, b; int r, g, b;
int r1, g1, b1; int r1, g1, b1;
while (a2--) while (size--)
{ {
r = GET_R(*a0); r = GET_R(*src);
g = GET_G(*a0); g = GET_G(*src);
b = GET_B(*a0); b = GET_B(*src);
r1 = ((((GET_R(*a1) << 8) - (r << 8)) / a3) * a4) >> 8; r1 = ((((GET_R(*dest) << 8) - (r << 8)) / a3) * a4) >> 8;
g1 = ((((GET_G(*a1) << 8) - (g << 8)) / a3) * a4) >> 8; g1 = ((((GET_G(*dest) << 8) - (g << 8)) / a3) * a4) >> 8;
b1 = ((((GET_B(*a1) << 8) - (b << 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 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 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 *palette = RGB2(r, g, b); //See above comment
a0++, a1++; src++, dest++;
palette++; 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) void PokenavFadeScreen(s32 fadeType)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
switch (fadeType) switch (fadeType)
{ {
@ -548,7 +548,7 @@ void InitBgTemplates(const struct BgTemplate *templates, int count)
static void InitHelpBar(void) static void InitHelpBar(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
InitWindows(&sHelpBarWindowTemplate[0]); InitWindows(&sHelpBarWindowTemplate[0]);
structPtr->helpBarWindowId = 0; structPtr->helpBarWindowId = 0;
@ -559,7 +559,7 @@ static void InitHelpBar(void)
void PrintHelpBarText(u32 textId) void PrintHelpBarText(u32 textId)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
DrawHelpBar(structPtr->helpBarWindowId); DrawHelpBar(structPtr->helpBarWindowId);
AddTextPrinterParameterized3(structPtr->helpBarWindowId, 1, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]); AddTextPrinterParameterized3(structPtr->helpBarWindowId, 1, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]);
@ -580,7 +580,7 @@ static void InitPokenavMainMenuResources(void)
{ {
s32 i; s32 i;
u8 spriteId; u8 spriteId;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
for (i = 0; i < ARRAY_COUNT(gSpinningPokenavSpriteSheet); i++) for (i = 0; i < ARRAY_COUNT(gSpinningPokenavSpriteSheet); i++)
LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]); LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]);
@ -593,7 +593,7 @@ static void InitPokenavMainMenuResources(void)
static void CleanupPokenavMainMenuResources(void) static void CleanupPokenavMainMenuResources(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
DestroySprite(structPtr->spinningPokenav); DestroySprite(structPtr->spinningPokenav);
FreeSpriteTilesByTag(0); FreeSpriteTilesByTag(0);
@ -608,7 +608,7 @@ static void SpriteCB_SpinningPokenav(struct Sprite *sprite)
struct Sprite *PauseSpinningPokenavSprite(void) struct Sprite *PauseSpinningPokenavSprite(void)
{ {
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
structPtr->spinningPokenav->callback = SpriteCallbackDummy; structPtr->spinningPokenav->callback = SpriteCallbackDummy;
return structPtr->spinningPokenav; return structPtr->spinningPokenav;
@ -616,7 +616,7 @@ struct Sprite *PauseSpinningPokenavSprite(void)
void ResumeSpinningPokenavSprite(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.x = 220;
structPtr->spinningPokenav->pos1.y = 12; structPtr->spinningPokenav->pos1.y = 12;
@ -629,7 +629,7 @@ void ResumeSpinningPokenavSprite(void)
static void InitHoennMapHeaderSprites(void) static void InitHoennMapHeaderSprites(void)
{ {
s32 i, spriteId; s32 i, spriteId;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet); LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet);
AllocSpritePalette(1); AllocSpritePalette(1);
@ -658,9 +658,9 @@ void LoadLeftHeaderGfxForIndex(u32 menuGfxId)
LoadLeftHeaderGfxForSubMenu(menuGfxId - POKENAV_GFX_SUBMENUS_START); 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) if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT)
structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32; structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32;
@ -676,7 +676,7 @@ static void LoadLeftHeaderGfxForMenu(u32 menuGfxId)
if (menuGfxId >= POKENAV_GFX_SUBMENUS_START) if (menuGfxId >= POKENAV_GFX_SUBMENUS_START)
return; return;
structPtr = GetSubstructPtr(0); structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
tag = sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].tag; tag = sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].tag;
size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data); size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data);
LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20); 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); 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) if (!isMain)
var = 0x30; tileTop = 0x30;
else else
var = 0x10; tileTop = 0x10;
if (menuGfxId < POKENAV_GFX_SUBMENUS_START) if (menuGfxId < POKENAV_GFX_SUBMENUS_START)
ShowLeftHeaderSprites(var, arg2); ShowLeftHeaderSprites(tileTop, isOnRightSide);
else else
ShowLeftHeaderSubmenuSprites(var, arg2); ShowLeftHeaderSubmenuSprites(tileTop, isOnRightSide);
} }
void sub_81C7FC4(u32 arg0, bool32 arg1) void HideMainOrSubMenuLeftHeader(u32 id, bool32 onRightSide)
{ {
if (arg0 < 6) if (id < POKENAV_GFX_PARTY_MENU)
HideLeftHeaderSprites(arg1); HideLeftHeaderSprites(onRightSide);
else else
HideLeftHeaderSubmenuSprites(arg1); HideLeftHeaderSubmenuSprites(onRightSide);
} }
void sub_81C7FDC(void) void SetLeftHeaderSpritesInvisibility(void)
{ {
s32 i; 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++) 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) if (structPtr->leftHeaderSprites[0]->callback == SpriteCallbackDummy && structPtr->submenuLeftHeaderSprites[0]->callback == SpriteCallbackDummy)
return FALSE; return FALSE;
@ -752,7 +752,7 @@ bool32 sub_81C8010(void)
static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
{ {
s32 start, end, i; s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (!isOnRightSide) if (!isOnRightSide)
start = -96, end = 32; start = -96, end = 32;
@ -769,7 +769,7 @@ static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
{ {
s32 start, end, i; s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (!isOnRightSide) if (!isOnRightSide)
start = -96, end = 16; start = -96, end = 16;
@ -786,7 +786,7 @@ static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
static void HideLeftHeaderSprites(bool32 isOnRightSide) static void HideLeftHeaderSprites(bool32 isOnRightSide)
{ {
s32 start, end, i; s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (!isOnRightSide) if (!isOnRightSide)
start = 32, end = -96; start = 32, end = -96;
@ -802,7 +802,7 @@ static void HideLeftHeaderSprites(bool32 isOnRightSide)
static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide) static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide)
{ {
s32 start, end, i; s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU);
if (!isOnRightSide) if (!isOnRightSide)
start = 16, end = -96; start = 16, end = -96;

View File

@ -53,7 +53,7 @@ static const u8 sMatchCallOptionsHasCheckPage[] =
bool32 PokenavCallback_Init_MatchCall(void) 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) if (!state)
return FALSE; return FALSE;
@ -66,13 +66,13 @@ bool32 PokenavCallback_Init_MatchCall(void)
u32 GetMatchCallCallback(void) u32 GetMatchCallCallback(void)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->callback(state); return state->callback(state);
} }
void FreeMatchCallSubstruct1(void) void FreeMatchCallSubstruct1(void)
{ {
FreePokenavSubstruct(5); FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
} }
static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state)
@ -92,7 +92,7 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state)
{ {
state->callback = CB2_HandleMatchCallOptionsInput; state->callback = CB2_HandleMatchCallOptionsInput;
state->optionCursorPos = 0; state->optionCursorPos = 0;
selection = GetSelectedMatchCall(); selection = GetSelectedPokenavListIndex();
if (!state->matchCallEntries[selection].isSpecialTrainer || MatchCall_HasCheckPage(state->matchCallEntries[selection].headerId)) 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) static u32 sub_81CAD20(s32 taskState)
{ {
int i, j; int i, j;
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -239,7 +239,7 @@ static u32 sub_81CAD20(s32 taskState)
{ {
state->matchCallEntries[state->numRegistered].headerId = state->headerId; state->matchCallEntries[state->numRegistered].headerId = state->headerId;
state->matchCallEntries[state->numRegistered].isSpecialTrainer = FALSE; state->matchCallEntries[state->numRegistered].isSpecialTrainer = FALSE;
state->matchCallEntries[state->numRegistered].mapSec = sub_81CB0C8(j); state->matchCallEntries[state->numRegistered].mapSec = GetMatchTableMapSectionId(j);
state->numRegistered++; state->numRegistered++;
} }
@ -266,31 +266,31 @@ bool32 IsRematchEntryRegistered(int rematchIndex)
int sub_81CAE28(void) int sub_81CAE28(void)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->unk10; return state->unk10;
} }
int GetNumberRegistered(void) int GetNumberRegistered(void)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->numRegistered; return state->numRegistered;
} }
int sub_81CAE48(void) int sub_81CAE48(void)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->unkC; return state->unkC;
} }
int unref_sub_81CAE58(void) int unref_sub_81CAE58(void)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->numRegistered - state->unkC; return state->numRegistered - state->unkC;
} }
int unref_sub_81CAE6C(int arg0) int unref_sub_81CAE6C(int arg0)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
arg0 += state->unkC; arg0 += state->unkC;
if (arg0 >= state->numRegistered) if (arg0 >= state->numRegistered)
return REMATCH_TABLE_ENTRIES; return REMATCH_TABLE_ENTRIES;
@ -300,19 +300,19 @@ int unref_sub_81CAE6C(int arg0)
struct PokenavMatchCallEntries *sub_81CAE94(void) struct PokenavMatchCallEntries *sub_81CAE94(void)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->matchCallEntries; return state->matchCallEntries;
} }
u16 GetMatchCallMapSec(int index) u16 GetMatchCallMapSec(int index)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->matchCallEntries[index].mapSec; return state->matchCallEntries[index].mapSec;
} }
bool32 ShouldDrawRematchPokeballIcon(int index) bool32 ShouldDrawRematchPokeballIcon(int index)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
if (!state->matchCallEntries[index].isSpecialTrainer) if (!state->matchCallEntries[index].isSpecialTrainer)
index = state->matchCallEntries[index].headerId; index = state->matchCallEntries[index].headerId;
else else
@ -327,7 +327,7 @@ bool32 ShouldDrawRematchPokeballIcon(int index)
int GetMatchCallTrainerPic(int index) int GetMatchCallTrainerPic(int index)
{ {
int headerId; int headerId;
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
if (!state->matchCallEntries[index].isSpecialTrainer) if (!state->matchCallEntries[index].isSpecialTrainer)
{ {
index = GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId); index = GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId);
@ -348,7 +348,7 @@ int GetMatchCallTrainerPic(int index)
const u8 *GetMatchCallMessageText(int index, u8 *arg1) const u8 *GetMatchCallMessageText(int index, u8 *arg1)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
*arg1 = 0; *arg1 = 0;
if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType)) if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType))
return gText_CallCantBeMadeHere; return gText_CallCantBeMadeHere;
@ -364,7 +364,7 @@ const u8 *GetMatchCallMessageText(int index, u8 *arg1)
const u8 *GetMatchCallFlavorText(int index, int checkPageEntry) const u8 *GetMatchCallFlavorText(int index, int checkPageEntry)
{ {
int rematchId; int rematchId;
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
if (state->matchCallEntries[index].isSpecialTrainer) if (state->matchCallEntries[index].isSpecialTrainer)
{ {
rematchId = MatchCall_GetRematchTableIdx(state->matchCallEntries[index].headerId); rematchId = MatchCall_GetRematchTableIdx(state->matchCallEntries[index].headerId);
@ -381,13 +381,13 @@ const u8 *GetMatchCallFlavorText(int index, int checkPageEntry)
u16 GetMatchCallOptionCursorPos(void) u16 GetMatchCallOptionCursorPos(void)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->optionCursorPos; return state->optionCursorPos;
} }
u16 GetMatchCallOptionId(int optionId) u16 GetMatchCallOptionId(int optionId)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
if (state->maxOptionId < optionId) if (state->maxOptionId < optionId)
return MATCH_CALL_OPTION_COUNT; 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 mapGroup = gRematchTable[rematchIndex].mapGroup;
int mapNum = gRematchTable[rematchIndex].mapNum; int mapNum = gRematchTable[rematchIndex].mapNum;
@ -431,7 +431,7 @@ u8 sub_81CB0C8(int rematchIndex)
int GetIndexDeltaOfNextCheckPageDown(int index) int GetIndexDeltaOfNextCheckPageDown(int index)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
int count = 1; int count = 1;
while (++index < state->numRegistered) while (++index < state->numRegistered)
{ {
@ -448,7 +448,7 @@ int GetIndexDeltaOfNextCheckPageDown(int index)
int GetIndexDeltaOfNextCheckPageUp(int index) int GetIndexDeltaOfNextCheckPageUp(int index)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
int count = -1; int count = -1;
while (--index >= 0) while (--index >= 0)
{ {
@ -488,8 +488,8 @@ bool32 unref_sub_81CB16C(void)
static bool32 sub_81CB1D0(void) static bool32 sub_81CB1D0(void)
{ {
struct Pokenav3Struct *state = GetSubstructPtr(5); struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
int selection = GetSelectedMatchCall(); int selection = GetSelectedPokenavListIndex();
if (!state->matchCallEntries[selection].isSpecialTrainer) if (!state->matchCallEntries[selection].isSpecialTrainer)
{ {
if (GetMatchCallMapSec(selection) == gMapHeader.regionMapSectionId) if (GetMatchCallMapSec(selection) == gMapHeader.regionMapSectionId)

View File

@ -36,7 +36,7 @@ struct Pokenav4Struct
u16 msgBoxWindowId; u16 msgBoxWindowId;
s16 unk16; s16 unk16;
u8 unused18; u8 unused18;
u8 unk19; u8 unused19;
u16 unk1A; u16 unk1A;
struct Sprite *optionsCursorSprite; struct Sprite *optionsCursorSprite;
struct Sprite *trainerPicSprite; struct Sprite *trainerPicSprite;
@ -50,9 +50,9 @@ struct Pokenav4Struct
static bool32 GetCurrentLoopedTaskActive(void); static bool32 GetCurrentLoopedTaskActive(void);
static u32 LoopedTask_OpenMatchCall(s32); static u32 LoopedTask_OpenMatchCall(s32);
static void sub_81CBBB8(void); static void InitMatchCallPokenavListMenuTemplate(void);
static void sub_81CBC1C(void); static void sub_81CBC1C(void);
static void sub_81CC2B4(void); static void RemoveMatchCallSprites(void);
static void sub_81CC034(struct Pokenav4Struct *); static void sub_81CC034(struct Pokenav4Struct *);
static void DrawMatchCallLeftColumnWindows(struct Pokenav4Struct *); static void DrawMatchCallLeftColumnWindows(struct Pokenav4Struct *);
static void UpdateMatchCallInfoBox(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 u16 gUnknown_08622720[] = INCBIN_U16("graphics/pokenav/pokeball_matchcall.gbapal");
static const u32 gUnknown_08622760[] = INCBIN_U32("graphics/pokenav/pokeball_matchcall.4bpp.lz"); 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, .bg = 1,
@ -152,22 +152,22 @@ const struct BgTemplate gUnknown_0862278C[3] =
static const LoopedTask sMatchCallLoopTaskFuncs[] = static const LoopedTask sMatchCallLoopTaskFuncs[] =
{ {
[POKENAV_MC_FUNC_NONE] = NULL, [POKENAV_MC_FUNC_NONE] = NULL,
[POKENAV_MC_FUNC_DOWN] = MatchCallListCursorDown, [POKENAV_MC_FUNC_DOWN] = MatchCallListCursorDown,
[POKENAV_MC_FUNC_UP] = MatchCallListCursorUp, [POKENAV_MC_FUNC_UP] = MatchCallListCursorUp,
[POKENAV_MC_FUNC_PG_DOWN] = MatchCallListPageDown, [POKENAV_MC_FUNC_PG_DOWN] = MatchCallListPageDown,
[POKENAV_MC_FUNC_PG_UP] = MatchCallListPageUp, [POKENAV_MC_FUNC_PG_UP] = MatchCallListPageUp,
[POKENAV_MC_FUNC_SELECT] = SelectMatchCallEntry, [POKENAV_MC_FUNC_SELECT] = SelectMatchCallEntry,
[POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR] = MoveMatchCallOptionsCursor, [POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR] = MoveMatchCallOptionsCursor,
[POKENAV_MC_FUNC_CANCEL] = CancelMatchCallSelection, [POKENAV_MC_FUNC_CANCEL] = CancelMatchCallSelection,
[POKENAV_MC_FUNC_CALL_MSG] = DoMatchCallMessage, [POKENAV_MC_FUNC_CALL_MSG] = DoMatchCallMessage,
[POKENAV_MC_FUNC_NEARBY_MSG] = DoTrainerCloseByMessage, [POKENAV_MC_FUNC_NEARBY_MSG] = DoTrainerCloseByMessage,
[POKENAV_MC_FUNC_10] = sub_81CB888, [POKENAV_MC_FUNC_10] = sub_81CB888,
[POKENAV_MC_FUNC_SHOW_CHECK_PAGE] = ShowCheckPage, [POKENAV_MC_FUNC_SHOW_CHECK_PAGE] = ShowCheckPage,
[POKENAV_MC_FUNC_CHECK_PAGE_UP] = ShowCheckPageUp, [POKENAV_MC_FUNC_CHECK_PAGE_UP] = ShowCheckPageUp,
[POKENAV_MC_FUNC_CHECK_PAGE_DOWN] = ShowCheckPageDown, [POKENAV_MC_FUNC_CHECK_PAGE_DOWN] = ShowCheckPageDown,
[POKENAV_MC_FUNC_EXIT_CHECK_PAGE] = ExitCheckPage, [POKENAV_MC_FUNC_EXIT_CHECK_PAGE] = ExitCheckPage,
[POKENAV_MC_FUNC_EXIT] = ExitMatchCall [POKENAV_MC_FUNC_EXIT] = ExitMatchCall
}; };
static const struct WindowTemplate sMatchCallLocationWindowTemplate = static const struct WindowTemplate sMatchCallLocationWindowTemplate =
@ -275,11 +275,11 @@ static const struct SpriteTemplate sTrainerPicSpriteTemplate =
bool32 OpenMatchCall(void) 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) if (!state)
return FALSE; return FALSE;
state->unk19 = 0; state->unused19 = 0;
state->loopTaskId = CreateLoopedTask(LoopedTask_OpenMatchCall, 1); state->loopTaskId = CreateLoopedTask(LoopedTask_OpenMatchCall, 1);
state->isTaskActiveCB = GetCurrentLoopedTaskActive; state->isTaskActiveCB = GetCurrentLoopedTaskActive;
return TRUE; return TRUE;
@ -287,21 +287,21 @@ bool32 OpenMatchCall(void)
void CreateMatchCallLoopedTask(s32 index) 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->loopTaskId = CreateLoopedTask(sMatchCallLoopTaskFuncs[index], 1);
state->isTaskActiveCB = GetCurrentLoopedTaskActive; state->isTaskActiveCB = GetCurrentLoopedTaskActive;
} }
bool32 IsMatchCallLoopedTaskActive(void) bool32 IsMatchCallLoopedTaskActive(void)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
return state->isTaskActiveCB(); return state->isTaskActiveCB();
} }
void FreeMatchCallSubstruct2(void) void FreeMatchCallSubstruct2(void)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
sub_81CC2B4(); RemoveMatchCallSprites();
sub_81CBC1C(); sub_81CBC1C();
RemoveWindow(state->infoBoxWindowId); RemoveWindow(state->infoBoxWindowId);
RemoveWindow(state->locWindowId); RemoveWindow(state->locWindowId);
@ -311,17 +311,17 @@ void FreeMatchCallSubstruct2(void)
static bool32 GetCurrentLoopedTaskActive(void) static bool32 GetCurrentLoopedTaskActive(void)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
return IsLoopedTaskActive(state->loopTaskId); return IsLoopedTaskActive(state->loopTaskId);
} }
static u32 LoopedTask_OpenMatchCall(s32 taskState) static u32 LoopedTask_OpenMatchCall(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
InitBgTemplates(gUnknown_0862278C, ARRAY_COUNT(gUnknown_0862278C)); InitBgTemplates(sMatchCallBgTemplates, ARRAY_COUNT(sMatchCallBgTemplates));
ChangeBgX(2, 0, 0); ChangeBgX(2, 0, 0);
ChangeBgY(2, 0, 0); ChangeBgY(2, 0, 0);
DecompressAndCopyTileDataToVram(2, sMatchCallUI_Gfx, 0, 0, 0); DecompressAndCopyTileDataToVram(2, sMatchCallUI_Gfx, 0, 0, 0);
@ -354,7 +354,7 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState)
if (FreeTempTileDataBuffersIfPossible() || !sub_81CAE28()) if (FreeTempTileDataBuffersIfPossible() || !sub_81CAE28())
return LT_PAUSE; return LT_PAUSE;
sub_81CBBB8(); InitMatchCallPokenavListMenuTemplate();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 4: case 4:
if (sub_81C8224()) if (sub_81C8224())
@ -374,11 +374,11 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState)
ShowBg(1); ShowBg(1);
sub_81CC214(); sub_81CC214();
LoadLeftHeaderGfxForIndex(3); LoadLeftHeaderGfxForIndex(3);
sub_81C7FA0(3, 1, 0); ShowLeftHeaderGfx(POKENAV_GFX_MATCH_CALL_MENU, 1, 0);
PokenavFadeScreen(1); PokenavFadeScreen(1);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 7: case 7:
if (IsPaletteFadeActive() || sub_81C8010()) if (IsPaletteFadeActive() || AreLeftHeaderSpritesMoving())
return LT_PAUSE; return LT_PAUSE;
sub_81CBC38(1); sub_81CBC38(1);
@ -390,7 +390,7 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState)
u32 MatchCallListCursorDown(s32 taskState) u32 MatchCallListCursorDown(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -409,7 +409,7 @@ u32 MatchCallListCursorDown(s32 taskState)
} }
break; break;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
PrintMatchCallLocation(state, 0); PrintMatchCallLocation(state, 0);
@ -427,7 +427,7 @@ u32 MatchCallListCursorDown(s32 taskState)
u32 MatchCallListCursorUp(s32 taskState) u32 MatchCallListCursorUp(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -446,7 +446,7 @@ u32 MatchCallListCursorUp(s32 taskState)
} }
break; break;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
PrintMatchCallLocation(state, 0); PrintMatchCallLocation(state, 0);
@ -464,7 +464,7 @@ u32 MatchCallListCursorUp(s32 taskState)
u32 MatchCallListPageDown(s32 taskState) u32 MatchCallListPageDown(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -483,7 +483,7 @@ u32 MatchCallListPageDown(s32 taskState)
} }
break; break;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
PrintMatchCallLocation(state, 0); PrintMatchCallLocation(state, 0);
@ -501,7 +501,7 @@ u32 MatchCallListPageDown(s32 taskState)
u32 MatchCallListPageUp(s32 taskState) u32 MatchCallListPageUp(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -520,7 +520,7 @@ u32 MatchCallListPageUp(s32 taskState)
} }
break; break;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
PrintMatchCallLocation(state, 0); PrintMatchCallLocation(state, 0);
@ -538,7 +538,7 @@ u32 MatchCallListPageUp(s32 taskState)
u32 SelectMatchCallEntry(s32 taskState) u32 SelectMatchCallEntry(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -561,7 +561,7 @@ u32 MoveMatchCallOptionsCursor(s32 taskState)
u16 cursorPos; u16 cursorPos;
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
state = GetSubstructPtr(6); state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
cursorPos = GetMatchCallOptionCursorPos(); cursorPos = GetMatchCallOptionCursorPos();
UpdateCursorGfxPos(state, cursorPos); UpdateCursorGfxPos(state, cursorPos);
return LT_FINISH; return LT_FINISH;
@ -569,7 +569,7 @@ u32 MoveMatchCallOptionsCursor(s32 taskState)
u32 CancelMatchCallSelection(s32 taskState) u32 CancelMatchCallSelection(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -588,7 +588,7 @@ u32 CancelMatchCallSelection(s32 taskState)
u32 DoMatchCallMessage(s32 taskState) u32 DoMatchCallMessage(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -620,7 +620,7 @@ u32 DoMatchCallMessage(s32 taskState)
u32 DoTrainerCloseByMessage(s32 taskState) u32 DoTrainerCloseByMessage(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -646,7 +646,7 @@ u32 DoTrainerCloseByMessage(s32 taskState)
u32 sub_81CB888(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; u32 result = LT_INC_AND_PAUSE;
switch (taskState) switch (taskState)
@ -710,7 +710,7 @@ u32 sub_81CB888(s32 taskState)
u32 ShowCheckPage(s32 taskState) u32 ShowCheckPage(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -719,7 +719,7 @@ u32 ShowCheckPage(s32 taskState)
UpdateWindowsToShowCheckPage(state); UpdateWindowsToShowCheckPage(state);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8820() || IsDma3ManagerBusyWithBgCopy1(state)) if (IsMatchCallListTaskActive() || IsDma3ManagerBusyWithBgCopy1(state))
return LT_PAUSE; return LT_PAUSE;
PrintHelpBarText(HELPBAR_MC_CHECK_PAGE); PrintHelpBarText(HELPBAR_MC_CHECK_PAGE);
@ -729,7 +729,7 @@ u32 ShowCheckPage(s32 taskState)
LoadCheckPageTrainerPic(state); LoadCheckPageTrainerPic(state);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (sub_81C8820() || WaitForTrainerPic(state) || WaitForHelpBar()) if (IsMatchCallListTaskActive() || WaitForTrainerPic(state) || WaitForHelpBar())
return LT_PAUSE; return LT_PAUSE;
break; break;
} }
@ -741,7 +741,7 @@ u32 ShowCheckPageDown(s32 taskState)
{ {
int topId; int topId;
int delta; int delta;
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -768,7 +768,7 @@ u32 ShowCheckPageDown(s32 taskState)
LoadCheckPageTrainerPic(state); LoadCheckPageTrainerPic(state);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 4: case 4:
if (sub_81C8820() || WaitForTrainerPic(state)) if (IsMatchCallListTaskActive() || WaitForTrainerPic(state))
return LT_PAUSE; return LT_PAUSE;
break; break;
} }
@ -778,7 +778,7 @@ u32 ShowCheckPageDown(s32 taskState)
u32 ExitCheckPage(s32 taskState) u32 ExitCheckPage(s32 taskState)
{ {
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -787,7 +787,7 @@ u32 ExitCheckPage(s32 taskState)
sub_81C87F0(); sub_81C87F0();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8820() || WaitForTrainerPic(state)) if (IsMatchCallListTaskActive() || WaitForTrainerPic(state))
return LT_PAUSE; return LT_PAUSE;
PrintHelpBarText(HELPBAR_MC_TRAINER_LIST); PrintHelpBarText(HELPBAR_MC_TRAINER_LIST);
@ -806,7 +806,7 @@ u32 ShowCheckPageUp(s32 taskState)
{ {
int topId; int topId;
int delta; int delta;
struct Pokenav4Struct *state = GetSubstructPtr(6); struct Pokenav4Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_OPEN);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -833,7 +833,7 @@ u32 ShowCheckPageUp(s32 taskState)
LoadCheckPageTrainerPic(state); LoadCheckPageTrainerPic(state);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 4: case 4:
if (sub_81C8820() || WaitForTrainerPic(state)) if (IsMatchCallListTaskActive() || WaitForTrainerPic(state))
return LT_PAUSE; return LT_PAUSE;
break; break;
} }
@ -849,35 +849,35 @@ u32 ExitMatchCall(s32 taskState)
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
sub_81CBC38(0); sub_81CBC38(0);
PokenavFadeScreen(0); PokenavFadeScreen(0);
sub_81C78A0(); SlideMenuHeaderDown();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy()) if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy())
return LT_PAUSE; return LT_PAUSE;
sub_81C7FDC(); SetLeftHeaderSpritesInvisibility();
break; break;
} }
return LT_FINISH; return LT_FINISH;
} }
static void sub_81CBBB8(void) static void InitMatchCallPokenavListMenuTemplate(void)
{ {
struct PokenavListTemplate template; struct PokenavListTemplate template;
template.list.matchCallEntries = sub_81CAE94(); template.list.matchCallEntries = sub_81CAE94();
template.unk4 = GetNumberRegistered(); template.count = GetNumberRegistered();
template.unk8 = 4; template.unk8 = 4;
template.unk6 = 0; template.unk6 = 0;
template.unk9 = 13; template.item_X = 13;
template.unkA = 16; template.windowWidth = 16;
template.unkB = 1; template.listTop = 1;
template.unkC = 8; template.maxShowed = 8;
template.unkD = 3; template.fillValue = 3;
template.unkE = 7; template.fontId = 7;
template.listFunc.unk10_2 = BufferMatchCallNameAndDesc; template.listFunc.unk10_2 = BufferMatchCallNameAndDesc;
template.unk14 = TryDrawRematchPokeballIcon; template.unk14 = TryDrawRematchPokeballIcon;
sub_81C81D4(&gUnknown_0862278C[2], &template, 2); sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2);
CreateTask(sub_81CBC64, 7); CreateTask(sub_81CBC64, 7);
} }
@ -902,7 +902,7 @@ static void sub_81CBC64(u8 taskId)
taskData[0] += 4; taskData[0] += 4;
taskData[0] &= 0x7F; taskData[0] &= 0x7F;
taskData[1] = gSineTable[taskData[0]] >> 4; 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) if (!gPaletteFade.active)
CpuCopy32(gPlttBufferUnfaded + 0x50, gPlttBufferFaded + 0x50, 0x20); CpuCopy32(gPlttBufferUnfaded + 0x50, gPlttBufferFaded + 0x50, 0x20);
} }
@ -1000,7 +1000,7 @@ static void PrintMatchCallLocation(struct Pokenav4Struct *state, int arg1)
{ {
u8 mapName[32]; u8 mapName[32];
int x; int x;
int index = GetSelectedMatchCall() + arg1; int index = GetSelectedPokenavListIndex() + arg1;
int mapSec = GetMatchCallMapSec(index); int mapSec = GetMatchCallMapSec(index);
if (mapSec != MAPSEC_NONE) if (mapSec != MAPSEC_NONE)
GetMapName(mapName, mapSec, 0); GetMapName(mapName, mapSec, 0);
@ -1117,7 +1117,7 @@ static bool32 WaitForTrainerIsCloseByText(struct Pokenav4Struct *state)
static void PrintMatchCallMessage(struct Pokenav4Struct *state) static void PrintMatchCallMessage(struct Pokenav4Struct *state)
{ {
int index = GetSelectedMatchCall(); int index = GetSelectedPokenavListIndex();
const u8 *str = GetMatchCallMessageText(index, &state->unkF); const u8 *str = GetMatchCallMessageText(index, &state->unkF);
u8 speed = GetPlayerTextSpeedDelay(); u8 speed = GetPlayerTextSpeedDelay();
AddTextPrinterParameterized(state->msgBoxWindowId, 1, str, 32, 1, speed, NULL); AddTextPrinterParameterized(state->msgBoxWindowId, 1, str, 32, 1, speed, NULL);
@ -1151,7 +1151,7 @@ static void sub_81CC214(void)
int i; int i;
u8 paletteNum; u8 paletteNum;
struct SpriteSheet spriteSheet; 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++) for (i = 0; i < ARRAY_COUNT(gUnknown_08622810); i++)
LoadCompressedSpriteSheet(&gUnknown_08622810[i]); LoadCompressedSpriteSheet(&gUnknown_08622810[i]);
@ -1168,9 +1168,9 @@ static void sub_81CC214(void)
state->trainerPicSprite->invisible = TRUE; 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) if (state->optionsCursorSprite)
DestroySprite(state->optionsCursorSprite); DestroySprite(state->optionsCursorSprite);
if (state->trainerPicSprite) if (state->trainerPicSprite)
@ -1221,7 +1221,7 @@ static struct Sprite *CreateTrainerPicSprite(void)
static void LoadCheckPageTrainerPic(struct Pokenav4Struct *state) static void LoadCheckPageTrainerPic(struct Pokenav4Struct *state)
{ {
u16 cursor; u16 cursor;
int trainerPic = GetMatchCallTrainerPic(GetSelectedMatchCall()); int trainerPic = GetMatchCallTrainerPic(GetSelectedPokenavListIndex());
if (trainerPic >= 0) if (trainerPic >= 0)
{ {
DecompressPicFromTable(&gTrainerFrontPicTable[trainerPic], state->unk1828, SPECIES_NONE); DecompressPicFromTable(&gTrainerFrontPicTable[trainerPic], state->unk1828, SPECIES_NONE);

View File

@ -9,7 +9,7 @@
// TODO: This UI isnt just for match call, seems to be the general pokenav list UI // TODO: This UI isnt just for match call, seems to be the general pokenav list UI
struct UnknownSubSubStruct_0203CF40 { struct PokenavListMenuWindow {
u8 bg; u8 bg;
u8 unk1; u8 unk1;
u8 unk2; u8 unk2;
@ -38,14 +38,14 @@ struct MatchCallWindowState {
struct PokenavSub17Substruct struct PokenavSub17Substruct
{ {
struct UnknownSubSubStruct_0203CF40 unk0; struct PokenavListMenuWindow listWindow;
u32 unk10; u32 unk10;
u32 unk14; u32 unk14;
u32 unk18; u32 unk18;
void * unk1C; void * unk1C;
s32 unk20; s32 unk20;
s32 unk24; s32 unk24;
u32 unk28; u32 loopedTaskId;
s32 unk2C; s32 unk2C;
u32 unk30; u32 unk30;
void (*unk34)(struct PokenavMatchCallEntries *, u8*); void (*unk34)(struct PokenavMatchCallEntries *, u8*);
@ -59,34 +59,34 @@ struct PokenavSub17Substruct
// Generally at index 0x11 (17) // Generally at index 0x11 (17)
struct PokenavSub17 struct PokenavSub17
{ {
struct PokenavSub17Substruct unk0; struct PokenavSub17Substruct list;
u8 tilemapBuffer[0x800]; u8 tilemapBuffer[0x800];
struct MatchCallWindowState unk888; struct MatchCallWindowState unk888;
s32 unk89C; s32 unk89C;
u32 unk8A0; u32 loopedTaskId;
}; };
extern void sub_81DB620(u32 windowId, u32 a1, u32 a2, u32 a3, u32 a4); extern void sub_81DB620(u32 windowId, u32 a1, u32 a2, u32 a3, u32 a4);
void sub_81C82E4(struct PokenavSub17 *a0); void sub_81C82E4(struct PokenavSub17 *matchCall);
bool32 sub_81C91AC(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3); bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3);
void sub_81C9160(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1); void InitMatchCallWindowState(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1);
void SpriteCB_MatchCallUpArrow(struct Sprite *sprite); void SpriteCB_MatchCallUpArrow(struct Sprite *sprite);
void SpriteCB_MatchCallDownArrow(struct Sprite *sprite); void SpriteCB_MatchCallDownArrow(struct Sprite *sprite);
void SpriteCB_MatchCallRightArrow(struct Sprite *sprite); void SpriteCB_MatchCallRightArrow(struct Sprite *sprite);
void ToggleMatchCallArrows(struct PokenavSub17Substruct *a0, u32 a1); void ToggleMatchCallArrows(struct PokenavSub17Substruct *a0, u32 a1);
void sub_81C8FE0(struct PokenavSub17Substruct *a0); void DestroyMatchCallListArrows(struct PokenavSub17Substruct *a0);
void sub_81C8EF8(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); void CreateMatchCallArrowSprites(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1);
void sub_81C8ED0(void); void sub_81C8ED0(void);
static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1, u32 a2); static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1, u32 a2);
void PrintMatchCallFieldNames(struct PokenavSub17Substruct *a0, u32 a1); void PrintMatchCallFieldNames(struct PokenavSub17Substruct *a0, u32 a1);
void sub_81C8D4C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); void sub_81C8D4C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1);
void sub_81C8CB4(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_81C8568(s32 a0, struct PokenavSub17Substruct *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 *a5);
void sub_81C837C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); 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); u32 LoopedTask_sub_81C8254(s32 state);
bool32 sub_81C83E0(void); bool32 sub_81C83E0(void);
u32 LoopedTask_sub_81C83F0(s32 state); 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) 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) if (structPtr == NULL)
return FALSE; return FALSE;
sub_81C9160(&structPtr->unk888, arg1); InitMatchCallWindowState(&structPtr->unk888, arg1);
if (!sub_81C91AC(&structPtr->unk0, arg0, arg1, arg2)) if (!CopyPokenavListMenuTemplate(&structPtr->list, arg0, arg1, arg2))
return FALSE; return FALSE;
CreateLoopedTask(LoopedTask_sub_81C8254, 6); CreateLoopedTask(LoopedTask_sub_81C8254, 6);
@ -123,10 +123,10 @@ void sub_81C8234(void)
{ {
struct PokenavSub17 *structPtr; struct PokenavSub17 *structPtr;
structPtr = GetSubstructPtr(17); structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
sub_81C8FE0(&structPtr->unk0); DestroyMatchCallListArrows(&structPtr->list);
RemoveWindow(structPtr->unk0.unk0.windowId); RemoveWindow(structPtr->list.listWindow.windowId);
FreePokenavSubstruct(17); FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
} }
u32 LoopedTask_sub_81C8254(s32 state) u32 LoopedTask_sub_81C8254(s32 state)
@ -134,9 +134,9 @@ u32 LoopedTask_sub_81C8254(s32 state)
struct PokenavSub17 *structPtr; struct PokenavSub17 *structPtr;
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
return 2; return LT_PAUSE;
structPtr = GetSubstructPtr(17); structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
switch (state) switch (state)
{ {
@ -144,10 +144,10 @@ u32 LoopedTask_sub_81C8254(s32 state)
sub_81C82E4(structPtr); sub_81C82E4(structPtr);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
sub_81C835C(&structPtr->unk0.unk0); sub_81C835C(&structPtr->list.listWindow);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 2: case 2:
sub_81C837C(&structPtr->unk888, &structPtr->unk0); sub_81C837C(&structPtr->unk888, &structPtr->list);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (sub_81C83E0()) if (sub_81C83E0())
@ -160,53 +160,53 @@ u32 LoopedTask_sub_81C8254(s32 state)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
case 4: case 4:
sub_81C8EF8(&structPtr->unk888, &structPtr->unk0); CreateMatchCallArrowSprites(&structPtr->unk888, &structPtr->list);
return LT_FINISH; return LT_FINISH;
default: default:
return LT_FINISH; 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; u16 tileNum = (matchCall->list.listWindow.unk1 << 12) | matchCall->list.listWindow.unk6;
sub_8199DF0(a0->unk0.unk0.bg, PIXEL_FILL(1), a0->unk0.unk0.unk6, 1); sub_8199DF0(matchCall->list.listWindow.bg, PIXEL_FILL(1), matchCall->list.listWindow.unk6, 1);
sub_8199DF0(a0->unk0.unk0.bg, PIXEL_FILL(4), a0->unk0.unk0.unk6 + 1, 1); sub_8199DF0(matchCall->list.listWindow.bg, PIXEL_FILL(4), matchCall->list.listWindow.unk6 + 1, 1);
SetBgTilemapBuffer(a0->unk0.unk0.bg, a0->tilemapBuffer); SetBgTilemapBuffer(matchCall->list.listWindow.bg, matchCall->tilemapBuffer);
FillBgTilemapBufferRect_Palette0(a0->unk0.unk0.bg, tileNum, 0, 0, 32, 32); FillBgTilemapBufferRect_Palette0(matchCall->list.listWindow.bg, tileNum, 0, 0, 32, 32);
ChangeBgY(a0->unk0.unk0.bg, 0, 0); ChangeBgY(matchCall->list.listWindow.bg, 0, 0);
ChangeBgX(a0->unk0.unk0.bg, 0, 0); ChangeBgX(matchCall->list.listWindow.bg, 0, 0);
ChangeBgY(a0->unk0.unk0.bg, a0->unk0.unk0.unk3 << 11, 2); ChangeBgY(matchCall->list.listWindow.bg, matchCall->list.listWindow.unk3 << 11, 2);
CopyBgTilemapBufferToVram(a0->unk0.unk0.bg); CopyBgTilemapBufferToVram(matchCall->list.listWindow.bg);
} }
void sub_81C835C(struct UnknownSubSubStruct_0203CF40 *a0) void sub_81C835C(struct PokenavListMenuWindow *listWindow)
{ {
FillWindowPixelBuffer(a0->windowId, PIXEL_FILL(1)); FillWindowPixelBuffer(listWindow->windowId, PIXEL_FILL(1));
PutWindowTilemap(a0->windowId); PutWindowTilemap(listWindow->windowId);
CopyWindowToVram(a0->windowId, 1); 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; s32 arg2 = state->listLength - state->windowTopIndex;
if (arg2 > a0->visibleEntries) if (arg2 > state->visibleEntries)
arg2 = a0->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) if (a2 == 0)
return; return;
a5->unk1C = a0 + a1 * a3; list->unk1C = a0 + a1 * a3;
a5->unk18 = a3; list->unk18 = a3;
a5->unk0.unkC = 0; list->listWindow.unkC = 0;
a5->unk0.unkE = a2; list->listWindow.unkE = a2;
a5->unk14 = a1; list->unk14 = a1;
a5->unk10 = a4; list->unk10 = a4;
CreateLoopedTask(LoopedTask_sub_81C83F0, 5); CreateLoopedTask(LoopedTask_sub_81C83F0, 5);
} }
@ -218,23 +218,23 @@ bool32 sub_81C83E0(void)
u32 LoopedTask_sub_81C83F0(s32 state) u32 LoopedTask_sub_81C83F0(s32 state)
{ {
u32 v1; u32 v1;
struct PokenavSub17Substruct *structPtr = GetSubstructPtr(17); struct PokenavSub17Substruct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
switch (state) switch (state)
{ {
case 0: 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); structPtr->unk34(structPtr->unk1C, structPtr->unkTextBuffer);
if (structPtr->unk38 != NULL) 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); AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->unkTextBuffer, 8, (v1 << 4) + 1, 255, NULL);
if (++structPtr->unk0.unkC >= structPtr->unk0.unkE) if (++structPtr->listWindow.unkC >= structPtr->listWindow.unkE)
{ {
if (structPtr->unk38 != NULL) if (structPtr->unk38 != NULL)
CopyWindowToVram(structPtr->unk0.windowId, 3); CopyWindowToVram(structPtr->listWindow.windowId, 3);
else else
CopyWindowToVram(structPtr->unk0.windowId, 2); CopyWindowToVram(structPtr->listWindow.windowId, 2);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
} }
else else
@ -253,14 +253,14 @@ u32 LoopedTask_sub_81C83F0(s32 state)
bool32 ShouldShowUpArrow(void) bool32 ShouldShowUpArrow(void)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
return (structPtr->unk888.windowTopIndex != 0); return (structPtr->unk888.windowTopIndex != 0);
} }
bool32 ShouldShowDownArrow(void) bool32 ShouldShowDownArrow(void)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
struct MatchCallWindowState *subPtr = &structPtr->unk888; struct MatchCallWindowState *subPtr = &structPtr->unk888;
return (subPtr->windowTopIndex + subPtr->visibleEntries < subPtr->listLength); return (subPtr->windowTopIndex + subPtr->visibleEntries < subPtr->listLength);
@ -268,7 +268,7 @@ bool32 ShouldShowDownArrow(void)
void MatchCall_MoveWindow(s32 a0, bool32 a1) 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; struct MatchCallWindowState *subPtr = &structPtr->unk888;
if (a0 < 0) if (a0 < 0)
@ -276,7 +276,7 @@ void MatchCall_MoveWindow(s32 a0, bool32 a1)
if (subPtr->windowTopIndex + a0 < 0) if (subPtr->windowTopIndex + a0 < 0)
a0 = -1 * subPtr->windowTopIndex; a0 = -1 * subPtr->windowTopIndex;
if (a1) 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) else if (a1)
{ {
@ -284,31 +284,31 @@ void MatchCall_MoveWindow(s32 a0, bool32 a1)
if (temp + a0 >= subPtr->listLength) if (temp + a0 >= subPtr->listLength)
a0 = subPtr->listLength - temp; 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; 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); list->unk20 = GetBgY(list->listWindow.bg);
a1->unk24 = a1->unk20 + (a0 << 12); list->unk24 = list->unk20 + (a0 << 12);
if (a0 > 0) if (a0 > 0)
a1->unk30 = 1; list->unk30 = 1;
else else
a1->unk30 = 2; list->unk30 = 2;
a1->unk2C = a0; list->unk2C = a0;
a1->unk28 = CreateLoopedTask(LoopedTask_sub_81C85A0, 6); list->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C85A0, 6);
} }
u32 LoopedTask_sub_81C85A0(s32 state) u32 LoopedTask_sub_81C85A0(s32 state)
{ {
s32 y, v1; s32 y, v1;
bool32 flag; bool32 flag;
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
struct PokenavSub17Substruct *subPtr = &structPtr->unk0; struct PokenavSub17Substruct *subPtr = &structPtr->list;
switch (state) switch (state)
{ {
@ -318,8 +318,8 @@ u32 LoopedTask_sub_81C85A0(s32 state)
return LT_PAUSE; return LT_PAUSE;
case 1: case 1:
flag = FALSE; flag = FALSE;
y = GetBgY(subPtr->unk0.bg); y = GetBgY(subPtr->listWindow.bg);
v1 = ChangeBgY(subPtr->unk0.bg, 0x1000, subPtr->unk30); v1 = ChangeBgY(subPtr->listWindow.bg, 0x1000, subPtr->unk30);
if (subPtr->unk30 == 2) if (subPtr->unk30 == 2)
{ {
if ((y > subPtr->unk24 || y <= subPtr->unk20) && v1 <= subPtr->unk24) if ((y > subPtr->unk24 || y <= subPtr->unk20) && v1 <= subPtr->unk24)
@ -333,8 +333,8 @@ u32 LoopedTask_sub_81C85A0(s32 state)
if (flag) if (flag)
{ {
subPtr->unk0.unkA = (subPtr->unk0.unkA + subPtr->unk2C) & 0xF; subPtr->listWindow.unkA = (subPtr->listWindow.unkA + subPtr->unk2C) & 0xF;
ChangeBgY(subPtr->unk0.bg, subPtr->unk24, 0); ChangeBgY(subPtr->listWindow.bg, subPtr->unk24, 0);
return LT_FINISH; return LT_FINISH;
} }
return LT_PAUSE; return LT_PAUSE;
@ -342,15 +342,15 @@ u32 LoopedTask_sub_81C85A0(s32 state)
return LT_FINISH; return LT_FINISH;
} }
bool32 sub_81C8630(void) bool32 IsMonListLoopedTaskActive(void)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
return IsLoopedTaskActive(structPtr->unk0.unk28); return IsLoopedTaskActive(structPtr->list.loopedTaskId);
} }
struct MatchCallWindowState *GetMatchCallWindowStruct(void) struct MatchCallWindowState *GetMatchCallWindowStruct(void)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
return &structPtr->unk888; return &structPtr->unk888;
} }
@ -448,7 +448,7 @@ int MatchCall_PageDown(void)
} }
} }
u32 GetSelectedMatchCall(void) u32 GetSelectedPokenavListIndex(void)
{ {
struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct(); struct MatchCallWindowState *structPtr = GetMatchCallWindowStruct();
@ -464,53 +464,53 @@ u32 GetMatchCallListTopIndex(void)
void sub_81C877C(void) void sub_81C877C(void)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
structPtr->unk89C = 0; structPtr->unk89C = 0;
structPtr->unk8A0 = CreateLoopedTask(LoopedTask_sub_81C8870, 6); structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8870, 6);
} }
void PrintCheckPageInfo(s16 a0) void PrintCheckPageInfo(s16 a0)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
structPtr->unk888.windowTopIndex += a0; structPtr->unk888.windowTopIndex += a0;
structPtr->unk89C = 0; structPtr->unk89C = 0;
structPtr->unk8A0 = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6); structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6);
} }
void sub_81C87F0(void) void sub_81C87F0(void)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
structPtr->unk89C = 0; 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); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
return IsLoopedTaskActive(structPtr->unk8A0); return IsLoopedTaskActive(structPtr->loopedTaskId);
} }
void sub_81C8838(void) void sub_81C8838(void)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
struct MatchCallWindowState *subPtr = &structPtr->unk888; struct MatchCallWindowState *subPtr = &structPtr->unk888;
structPtr->unk0.unk38(structPtr->unk0.unk0.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->unk0.unk0.unkA + subPtr->selectedIndexOffset) & 0xF); structPtr->list.unk38(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF);
CopyWindowToVram(structPtr->unk0.unk0.windowId, 1); CopyWindowToVram(structPtr->list.listWindow.windowId, 1);
} }
// TODO: // TODO:
u32 LoopedTask_sub_81C8870(s32 state) u32 LoopedTask_sub_81C8870(s32 state)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
switch (state) switch (state)
{ {
case 0: case 0:
ToggleMatchCallArrows(&structPtr->unk0, 1); ToggleMatchCallArrows(&structPtr->list, 1);
// fall-through // fall-through
case 1: case 1:
if (structPtr->unk89C != structPtr->unk888.selectedIndexOffset) if (structPtr->unk89C != structPtr->unk888.selectedIndexOffset)
sub_81C8B70(&structPtr->unk0.unk0, structPtr->unk89C, 1); sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, 1);
structPtr->unk89C++; structPtr->unk89C++;
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
@ -520,7 +520,7 @@ u32 LoopedTask_sub_81C8870(s32 state)
if (structPtr->unk89C != structPtr->unk888.visibleEntries) if (structPtr->unk89C != structPtr->unk888.visibleEntries)
return 6; return 6;
if (structPtr->unk888.selectedIndexOffset != 0) 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; return LT_INC_AND_PAUSE;
} }
@ -537,7 +537,7 @@ u32 LoopedTask_sub_81C8870(s32 state)
} }
return LT_PAUSE; return LT_PAUSE;
case 4: case 4:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
structPtr->unk888.selectedIndexOffset = 0; structPtr->unk888.selectedIndexOffset = 0;
@ -548,35 +548,35 @@ u32 LoopedTask_sub_81C8870(s32 state)
u32 LoopedTask_PrintCheckPageInfo(s32 state) u32 LoopedTask_PrintCheckPageInfo(s32 state)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE; return LT_PAUSE;
switch (state) switch (state)
{ {
case 0: case 0:
sub_81C8CB4(&structPtr->unk888, &structPtr->unk0); sub_81C8CB4(&structPtr->unk888, &structPtr->list);
break; break;
case 1: case 1:
PrintMatchCallFieldNames(&structPtr->unk0, 0); PrintMatchCallFieldNames(&structPtr->list, 0);
break; break;
case 2: case 2:
PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->unk0, CHECK_PAGE_STRATEGY); PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_STRATEGY);
break; break;
case 3: case 3:
PrintMatchCallFieldNames(&structPtr->unk0, 1); PrintMatchCallFieldNames(&structPtr->list, 1);
break; break;
case 4: case 4:
PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->unk0, CHECK_PAGE_POKEMON); PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_POKEMON);
break; break;
case 5: case 5:
PrintMatchCallFieldNames(&structPtr->unk0, 2); PrintMatchCallFieldNames(&structPtr->list, 2);
break; break;
case 6: case 6:
PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->unk0, CHECK_PAGE_INTRO_1); PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_INTRO_1);
break; break;
case 7: case 7:
PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->unk0, CHECK_PAGE_INTRO_2); PrintMatchCallFlavorText(&structPtr->unk888, &structPtr->list, CHECK_PAGE_INTRO_2);
break; break;
default: default:
return LT_FINISH; return LT_FINISH;
@ -594,9 +594,9 @@ u32 LoopedTask_sub_81C8A28(s32 state)
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE; return LT_PAUSE;
structPtr = GetSubstructPtr(17); structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
subPtr888 = &structPtr->unk888; subPtr888 = &structPtr->unk888;
subPtr0 = &structPtr->unk0; subPtr0 = &structPtr->list;
switch (state) switch (state)
{ {
@ -607,7 +607,7 @@ u32 LoopedTask_sub_81C8A28(s32 state)
ptr = &structPtr->unk89C; ptr = &structPtr->unk89C;
if (++(*ptr) < structPtr->unk888.visibleEntries) if (++(*ptr) < structPtr->unk888.visibleEntries)
{ {
sub_81C8B70(&subPtr0->unk0, *ptr, 1); sub_81C8B70(&subPtr0->listWindow, *ptr, 1);
return LT_PAUSE; return LT_PAUSE;
} }
@ -618,7 +618,7 @@ u32 LoopedTask_sub_81C8A28(s32 state)
{ {
s32 r4 = subPtr888->windowTopIndex; s32 r4 = subPtr888->windowTopIndex;
r5 = -r4; r5 = -r4;
sub_81C8B70(&subPtr0->unk0, r5, r4); sub_81C8B70(&subPtr0->listWindow, r5, r4);
subPtr888->selectedIndexOffset = r4; subPtr888->selectedIndexOffset = r4;
*ptr = r5; *ptr = r5;
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
@ -630,7 +630,7 @@ u32 LoopedTask_sub_81C8A28(s32 state)
{ {
s32 r4 = subPtr888->windowTopIndex + subPtr888->visibleEntries - subPtr888->listLength; s32 r4 = subPtr888->windowTopIndex + subPtr888->visibleEntries - subPtr888->listLength;
r5 = -r4; r5 = -r4;
sub_81C8B70(&subPtr0->unk0, r5, r4); sub_81C8B70(&subPtr0->listWindow, r5, r4);
subPtr888->selectedIndexOffset = r4; subPtr888->selectedIndexOffset = r4;
*ptr = r5; *ptr = r5;
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
@ -641,14 +641,14 @@ u32 LoopedTask_sub_81C8A28(s32 state)
MatchCall_MoveWindow(structPtr->unk89C, FALSE); MatchCall_MoveWindow(structPtr->unk89C, FALSE);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (!sub_81C8630()) if (!IsMonListLoopedTaskActive())
{ {
structPtr->unk89C = 0; structPtr->unk89C = 0;
return 1; return 1;
} }
return 2; return 2;
case 4: 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; return LT_INC_AND_PAUSE;
case 5: case 5:
if (sub_81C83E0()) if (sub_81C83E0())
@ -664,16 +664,16 @@ u32 LoopedTask_sub_81C8A28(s32 state)
return LT_FINISH; 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); u8 *v1 = (u8*)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA);
u32 v2 = a0->unk4 * 64; u32 v2 = listWindow->unk4 * 64;
a1 = (a0->unkA + a1) & 0xF; a1 = (listWindow->unkA + a1) & 0xF;
if (a1 + a2 <= 16) if (a1 + a2 <= 16)
{ {
CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, a2 * v2); CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, a2 * v2);
CopyWindowToVram(a0->windowId, 2); CopyWindowToVram(listWindow->windowId, 2);
} }
else 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 + a1 * v2, v3 * v2);
CpuFastFill8(PIXEL_FILL(1), v1, v4 * 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--) 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 var;
u16 *v1 = (u16*)GetBgTilemapBuffer(GetWindowAttribute(a0->windowId, WINDOW_BG)); u16 *v1 = (u16*)GetBgTilemapBuffer(GetWindowAttribute(listWindow->windowId, WINDOW_BG));
v1 += ((a0->unkA << 6) + a0->unk2) - 1; v1 += ((listWindow->unkA << 6) + listWindow->unk2) - 1;
if (a1 != 0) if (a1 != 0)
var = (a0->unk1 << 12) | (a0->unk6 + 1); var = (listWindow->unk1 << 12) | (listWindow->unk6 + 1);
else else
var = (a0->unk1 << 12) | (a0->unk6); var = (listWindow->unk1 << 12) | (listWindow->unk6);
v1[0] = var; v1[0] = var;
v1[0x20] = 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}; u8 colors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_RED};
a1->unk34(a0->unk10 + a0->unkC * a0->windowTopIndex, a1->unkTextBuffer); list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer);
a1->unk38(a1->unk0.windowId, a0->windowTopIndex, a1->unk0.unkA); list->unk38(list->listWindow.windowId, state->windowTopIndex, list->listWindow.unkA);
FillWindowPixelRect(a1->unk0.windowId, PIXEL_FILL(4), 0, a1->unk0.unkA * 16, a1->unk0.unk4 * 8, 16); FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(4), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16);
AddTextPrinterParameterized3(a1->unk0.windowId, a1->unk0.fontId, 8, (a1->unk0.unkA * 16) + 1, colors, TEXT_SPEED_FF, a1->unkTextBuffer); AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SPEED_FF, list->unkTextBuffer);
sub_81C8C64(&a1->unk0, 1); sub_81C8C64(&list->listWindow, 1);
CopyWindowRectToVram(a1->unk0.windowId, 3, 0, a1->unk0.unkA * 2, a1->unk0.unk4, 2); 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); list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer);
FillWindowPixelRect(a1->unk0.windowId, PIXEL_FILL(1), 0, a1->unk0.unkA * 16, a1->unk0.unk4 * 8, 16); FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16);
AddTextPrinterParameterized(a1->unk0.windowId, a1->unk0.fontId, a1->unkTextBuffer, 8, a1->unk0.unkA * 16 + 1, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->unkTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SPEED_FF, NULL);
sub_81C8C64(&a1->unk0, 0); sub_81C8C64(&list->listWindow, 0);
CopyWindowToVram(a1->unk0.windowId, 3); 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}; 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}; 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); FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, top << 4, list->listWindow.unk4, 16);
AddTextPrinterParameterized3(a0->unk0.windowId, 7, 2, (top << 4) + 1, colors, -1, fieldNames[fieldId]); AddTextPrinterParameterized3(list->listWindow.windowId, 7, 2, (top << 4) + 1, colors, -1, fieldNames[fieldId]);
CopyWindowRectToVram(a0->unk0.windowId, 2, 0, top << 1, a0->unk0.unk4, 2); 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 // lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames
static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] = 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 [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); const u8 *str = GetMatchCallFlavorText(a0->windowTopIndex, checkPageEntry);
if (str != NULL) if (str != NULL)
{ {
sub_81DB620(a1->unk0.windowId, 1, r6 * 2, a1->unk0.unk4 - 1, 2); sub_81DB620(list->listWindow.windowId, 1, r6 * 2, list->listWindow.unk4 - 1, 2);
AddTextPrinterParameterized(a1->unk0.windowId, 7, str, 2, (r6 << 4) + 1, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(list->listWindow.windowId, 7, str, 2, (r6 << 4) + 1, TEXT_SPEED_FF, NULL);
CopyWindowRectToVram(a1->unk0.windowId, 2, 0, r6 * 2, a1->unk0.unk4, 2); CopyWindowRectToVram(list->listWindow.windowId, 2, 0, r6 * 2, list->listWindow.unk4, 2);
} }
} }
@ -839,57 +839,57 @@ void sub_81C8ED0(void)
Pokenav_AllocAndLoadPalettes(sMatchcallArrowPalettes); Pokenav_AllocAndLoadPalettes(sMatchcallArrowPalettes);
} }
void sub_81C8EF8(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1) void CreateMatchCallArrowSprites(struct MatchCallWindowState *windowState, struct PokenavSub17Substruct *list)
{ {
u32 spriteId; u32 spriteId;
s16 x; s16 x;
spriteId = CreateSprite(&sMatchCallRightArrowSprite, a1->unk0.unk2 * 8 + 3, (a1->unk0.unk3 + 1) * 8, 7); spriteId = CreateSprite(&sMatchCallRightArrowSprite, list->listWindow.unk2 * 8 + 3, (list->listWindow.unk3 + 1) * 8, 7);
a1->rightArrow = &gSprites[spriteId]; list->rightArrow = &gSprites[spriteId];
x = a1->unk0.unk2 * 8 + (a1->unk0.unk4 - 1) * 4; x = list->listWindow.unk2 * 8 + (list->listWindow.unk4 - 1) * 4;
spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, a1->unk0.unk3 * 8 + a0->visibleEntries * 16, 7); spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, list->listWindow.unk3 * 8 + windowState->visibleEntries * 16, 7);
a1->downArrow = &gSprites[spriteId]; list->downArrow = &gSprites[spriteId];
a1->downArrow->oam.tileNum += 2; list->downArrow->oam.tileNum += 2;
a1->downArrow->callback = SpriteCB_MatchCallDownArrow; list->downArrow->callback = SpriteCB_MatchCallDownArrow;
spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, a1->unk0.unk3 * 8, 7); spriteId = CreateSprite(&sMatchCallUpDownArrowSprite, x, list->listWindow.unk3 * 8, 7);
a1->upArrow = &gSprites[spriteId]; list->upArrow = &gSprites[spriteId];
a1->upArrow->oam.tileNum += 4; list->upArrow->oam.tileNum += 4;
a1->upArrow->callback = SpriteCB_MatchCallUpArrow; list->upArrow->callback = SpriteCB_MatchCallUpArrow;
} }
void sub_81C8FE0(struct PokenavSub17Substruct *a0) void DestroyMatchCallListArrows(struct PokenavSub17Substruct *list)
{ {
DestroySprite(a0->rightArrow); DestroySprite(list->rightArrow);
DestroySprite(a0->upArrow); DestroySprite(list->upArrow);
DestroySprite(a0->downArrow); DestroySprite(list->downArrow);
FreeSpriteTilesByTag(0xA); FreeSpriteTilesByTag(0xA);
FreeSpritePaletteByTag(0x14); FreeSpritePaletteByTag(0x14);
} }
void ToggleMatchCallArrows(struct PokenavSub17Substruct *a0, bool32 shouldHide) void ToggleMatchCallArrows(struct PokenavSub17Substruct *list, bool32 shouldHide)
{ {
if (shouldHide) if (shouldHide)
{ {
a0->rightArrow->callback = SpriteCallbackDummy; list->rightArrow->callback = SpriteCallbackDummy;
a0->upArrow->callback = SpriteCallbackDummy; list->upArrow->callback = SpriteCallbackDummy;
a0->downArrow->callback = SpriteCallbackDummy; list->downArrow->callback = SpriteCallbackDummy;
} }
else else
{ {
a0->rightArrow->callback = SpriteCB_MatchCallRightArrow; list->rightArrow->callback = SpriteCB_MatchCallRightArrow;
a0->upArrow->callback = SpriteCB_MatchCallUpArrow; list->upArrow->callback = SpriteCB_MatchCallUpArrow;
a0->downArrow->callback = SpriteCB_MatchCallDownArrow; list->downArrow->callback = SpriteCB_MatchCallDownArrow;
} }
a0->rightArrow->invisible = shouldHide; list->rightArrow->invisible = shouldHide;
a0->upArrow->invisible = shouldHide; list->upArrow->invisible = shouldHide;
a0->downArrow->invisible = shouldHide; list->downArrow->invisible = shouldHide;
} }
void SpriteCB_MatchCallRightArrow(struct Sprite *sprite) 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; sprite->pos2.y = structPtr->unk888.selectedIndexOffset << 4;
} }
@ -931,68 +931,68 @@ void SpriteCB_MatchCallUpArrow(struct Sprite *sprite)
void ToggleMatchCallVerticalArrows(bool32 shouldHide) void ToggleMatchCallVerticalArrows(bool32 shouldHide)
{ {
struct PokenavSub17 *structPtr = GetSubstructPtr(17); struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST);
structPtr->unk0.upArrow->data[7] = shouldHide; structPtr->list.upArrow->data[7] = shouldHide;
structPtr->unk0.downArrow->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; dst->unk10 = template->list.matchCallEntries;
a0->windowTopIndex = a1->unk6; dst->windowTopIndex = template->unk6;
a0->listLength = a1->unk4; dst->listLength = template->count;
a0->unkC = a1->unk8; dst->unkC = template->unk8;
a0->visibleEntries = a1->unkC; dst->visibleEntries = template->maxShowed;
if (a0->visibleEntries >= a0->listLength) if (dst->visibleEntries >= dst->listLength)
{ {
a0->windowTopIndex = 0; dst->windowTopIndex = 0;
a0->unk4 = 0; dst->unk4 = 0;
a0->selectedIndexOffset = a1->unk6; dst->selectedIndexOffset = template->unk6;
} }
else else
{ {
a0->unk4 = a0->listLength - a0->visibleEntries; dst->unk4 = dst->listLength - dst->visibleEntries;
if (a0->windowTopIndex + a0->visibleEntries > a0->listLength) if (dst->windowTopIndex + dst->visibleEntries > dst->listLength)
{ {
a0->selectedIndexOffset = a0->windowTopIndex + a0->visibleEntries - a0->listLength; dst->selectedIndexOffset = dst->windowTopIndex + dst->visibleEntries - dst->listLength;
a0->windowTopIndex = a1->unk6 - a0->selectedIndexOffset; dst->windowTopIndex = template->unk6 - dst->selectedIndexOffset;
} }
else 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; struct WindowTemplate window;
a0->unk0.bg = a1->bg; dest->listWindow.bg = bgTemplate->bg;
a0->unk0.unk6 = a3; dest->listWindow.unk6 = a3;
a0->unk34 = a2->listFunc.unk10_2; dest->unk34 = template->listFunc.unk10_2;
a0->unk38 = a2->unk14; dest->unk38 = template->unk14;
a0->unk0.unk1 = a2->unkD; dest->listWindow.unk1 = template->fillValue;
a0->unk0.unk2 = a2->unk9; dest->listWindow.unk2 = template->item_X;
a0->unk0.unk3 = a2->unkB; dest->listWindow.unk3 = template->listTop;
a0->unk0.unk4 = a2->unkA; dest->listWindow.unk4 = template->windowWidth;
a0->unk0.fontId = a2->unkE; dest->listWindow.fontId = template->fontId;
window.bg = a1->bg; window.bg = bgTemplate->bg;
window.tilemapLeft = a2->unk9; window.tilemapLeft = template->item_X;
window.tilemapTop = 0; window.tilemapTop = 0;
window.width = a2->unkA; window.width = template->windowWidth;
window.height = 32; window.height = 32;
window.paletteNum = a2->unkD; window.paletteNum = template->fillValue;
window.baseBlock = a3 + 2; window.baseBlock = a3 + 2;
a0->unk0.windowId = AddWindow(&window); dest->listWindow.windowId = AddWindow(&window);
if (a0->unk0.windowId == 0xFF) if (dest->listWindow.windowId == 0xFF)
return FALSE; return FALSE;
a0->unk0.unkA = 0; dest->listWindow.unkA = 0;
a0->rightArrow = NULL; dest->rightArrow = NULL;
a0->upArrow = NULL; dest->upArrow = NULL;
a0->downArrow = NULL; dest->downArrow = NULL;
return 1; return 1;
} }

View File

@ -99,12 +99,12 @@ static u8 GetPokenavMainMenuType(void)
bool32 PokenavCallback_Init_MainMenuCursorOnMap(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) if (!state)
return FALSE; return FALSE;
state->menuType = GetPokenavMainMenuType(); state->menuType = GetPokenavMainMenuType();
state->cursorPos = 0; state->cursorPos = POKENAV_MENUITEM_MAP;
state->currMenuItem = POKENAV_MENUITEM_MAP; state->currMenuItem = POKENAV_MENUITEM_MAP;
state->helpBarIndex = HELPBAR_NONE; state->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(state); SetMenuInputHandler(state);
@ -113,12 +113,12 @@ bool32 PokenavCallback_Init_MainMenuCursorOnMap(void)
bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(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) if (!state)
return FALSE; return FALSE;
state->menuType = GetPokenavMainMenuType(); state->menuType = GetPokenavMainMenuType();
state->cursorPos = 2; state->cursorPos = POKENAV_MENUITEM_MATCH_CALL;
state->currMenuItem = POKENAV_MENUITEM_MATCH_CALL; state->currMenuItem = POKENAV_MENUITEM_MATCH_CALL;
state->helpBarIndex = HELPBAR_NONE; state->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(state); SetMenuInputHandler(state);
@ -127,12 +127,12 @@ bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void)
bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(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) if (!state)
return FALSE; return FALSE;
state->menuType = GetPokenavMainMenuType(); state->menuType = GetPokenavMainMenuType();
state->cursorPos = 3; state->cursorPos = POKENAV_MENUITEM_RIBBONS;
state->currMenuItem = POKENAV_MENUITEM_RIBBONS; state->currMenuItem = POKENAV_MENUITEM_RIBBONS;
SetMenuInputHandler(state); SetMenuInputHandler(state);
return TRUE; return TRUE;
@ -140,12 +140,12 @@ bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void)
bool32 PokenavCallback_Init_ConditionMenu(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) if (!state)
return FALSE; return FALSE;
state->menuType = POKENAV_MENU_TYPE_CONDITION; state->menuType = POKENAV_MENU_TYPE_CONDITION;
state->cursorPos = 0; state->cursorPos = 0; //party
state->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY; state->currMenuItem = POKENAV_MENUITEM_CONDITION_PARTY;
state->helpBarIndex = HELPBAR_NONE; state->helpBarIndex = HELPBAR_NONE;
SetMenuInputHandler(state); SetMenuInputHandler(state);
@ -154,7 +154,7 @@ bool32 PokenavCallback_Init_ConditionMenu(void)
bool32 PokenavCallback_Init_ConditionSearchMenu(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) if (!state)
return FALSE; return FALSE;
@ -202,13 +202,13 @@ static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*)
u32 GetMenuHandlerCallback(void) u32 GetMenuHandlerCallback(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->callback(state); return state->callback(state);
} }
void FreeMenuHandlerSubstruct1(void) void FreeMenuHandlerSubstruct1(void)
{ {
FreePokenavSubstruct(1); FreePokenavSubstruct(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
} }
static u32 HandleMainMenuInput(struct Pokenav1Struct *state) static u32 HandleMainMenuInput(struct Pokenav1Struct *state)
@ -247,12 +247,12 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state)
return POKENAV_MENU_FUNC_NO_RIBBON_WINNERS; return POKENAV_MENU_FUNC_NO_RIBBON_WINNERS;
} }
case POKENAV_MENUITEM_SWITCH_OFF: case POKENAV_MENUITEM_SWITCH_OFF:
return -1; return POKENAV_MENU_FUNC_EXIT;
} }
} }
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
return -1; return POKENAV_MENU_FUNC_EXIT;
return POKENAV_MENU_FUNC_NONE; return POKENAV_MENU_FUNC_NONE;
} }
@ -488,26 +488,26 @@ static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state)
int GetPokenavMenuType(void) int GetPokenavMenuType(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->menuType; return state->menuType;
} }
// Position of cursor relative to number of current menu options // Position of cursor relative to number of current menu options
int GetPokenavCursorPos(void) int GetPokenavCursorPos(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->cursorPos; return state->cursorPos;
} }
// ID of menu item the cursor is currently on // ID of menu item the cursor is currently on
int GetCurrentMenuItemId(void) int GetCurrentMenuItemId(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->currMenuItem; return state->currMenuItem;
} }
u16 GetHelpBarTextId(void) u16 GetHelpBarTextId(void)
{ {
struct Pokenav1Struct *state = GetSubstructPtr(1); struct Pokenav1Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER);
return state->helpBarIndex; return state->helpBarIndex;
} }

File diff suppressed because it is too large Load Diff

View File

@ -170,11 +170,11 @@ static const struct SpriteTemplate sCityZoomTextSpriteTemplate =
u32 PokenavCallback_Init_RegionMap(void) 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) if (!state)
return FALSE; return FALSE;
if (!AllocSubstruct(16, sizeof(struct RegionMap))) if (!AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP, sizeof(struct RegionMap)))
return FALSE; return FALSE;
state->zoomDisabled = IsEventIslandMapSecId(gMapHeader.regionMapSectionId); state->zoomDisabled = IsEventIslandMapSecId(gMapHeader.regionMapSectionId);
@ -189,13 +189,13 @@ u32 PokenavCallback_Init_RegionMap(void)
void FreeRegionMapSubstruct1(void) void FreeRegionMapSubstruct1(void)
{ {
gSaveBlock2Ptr->regionMapZoom = IsRegionMapZoomed(); gSaveBlock2Ptr->regionMapZoom = IsRegionMapZoomed();
FreePokenavSubstruct(16); FreePokenavSubstruct(POKENAV_SUBSTRUCT_REGION_MAP);
FreePokenavSubstruct(3); FreePokenavSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
} }
u32 GetRegionMapCallback(void) u32 GetRegionMapCallback(void)
{ {
struct Pokenav5Struct *state = GetSubstructPtr(3); struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
return state->callback(state); return state->callback(state);
} }
@ -235,13 +235,13 @@ static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *state)
bool32 GetZoomDisabled(void) bool32 GetZoomDisabled(void)
{ {
struct Pokenav5Struct *state = GetSubstructPtr(3); struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
return state->zoomDisabled; return state->zoomDisabled;
} }
bool32 OpenPokenavRegionMap(void) 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) if (!state)
return FALSE; return FALSE;
@ -252,25 +252,25 @@ bool32 OpenPokenavRegionMap(void)
void CreateRegionMapLoopedTask(s32 index) 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->loopTaskId = CreateLoopedTask(sRegionMapLoopTaskFuncs[index], 1);
state->isTaskActiveCB = GetCurrentLoopedTaskActive; state->isTaskActiveCB = GetCurrentLoopedTaskActive;
} }
bool32 IsRegionMapLoopedTaskActive(void) bool32 IsRegionMapLoopedTaskActive(void)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(4); struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
return state->isTaskActiveCB(); return state->isTaskActiveCB();
} }
void FreeRegionMapSubstruct2(void) void FreeRegionMapSubstruct2(void)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(4); struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
FreeRegionMapIconResources(); FreeRegionMapIconResources();
FreeCityZoomViewGfx(); FreeCityZoomViewGfx();
RemoveWindow(state->infoWindowId); RemoveWindow(state->infoWindowId);
FreePokenavSubstruct(16); FreePokenavSubstruct(POKENAV_SUBSTRUCT_REGION_MAP);
FreePokenavSubstruct(4); FreePokenavSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
SetPokenavVBlankCallback(); SetPokenavVBlankCallback();
SetBgMode(0); SetBgMode(0);
} }
@ -285,7 +285,7 @@ static void VBlankCB_RegionMap(void)
static bool32 GetCurrentLoopedTaskActive(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); return IsLoopedTaskActive(state->loopTaskId);
} }
@ -301,7 +301,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
{ {
int menuGfxId; int menuGfxId;
struct RegionMap *regionMap; struct RegionMap *regionMap;
struct Pokenav5Struct_2 *state = GetSubstructPtr(4); struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@ -311,7 +311,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
HideBg(3); HideBg(3);
SetBgMode(1); SetBgMode(1);
InitBgTemplates(sRegionMapBgTemplates, ARRAY_COUNT(sRegionMapBgTemplates) - 1); InitBgTemplates(sRegionMapBgTemplates, ARRAY_COUNT(sRegionMapBgTemplates) - 1);
regionMap = GetSubstructPtr(16); regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP);
InitRegionMapData(regionMap, &sRegionMapBgTemplates[1], ShouldOpenRegionMapZoomed()); InitRegionMapData(regionMap, &sRegionMapBgTemplates[1], ShouldOpenRegionMapZoomed());
LoadCityZoomViewGfx(); LoadCityZoomViewGfx();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
@ -361,11 +361,11 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
menuGfxId = POKENAV_GFX_MAP_MENU_ZOOMED_IN; menuGfxId = POKENAV_GFX_MAP_MENU_ZOOMED_IN;
LoadLeftHeaderGfxForIndex(menuGfxId); LoadLeftHeaderGfxForIndex(menuGfxId);
sub_81C7FA0(menuGfxId, 1, 1); ShowLeftHeaderGfx(menuGfxId, 1, 1);
PokenavFadeScreen(1); PokenavFadeScreen(1);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 7: case 7:
if (IsPaletteFadeActive() || sub_81C8010()) if (IsPaletteFadeActive() || AreLeftHeaderSpritesMoving())
return LT_PAUSE; return LT_PAUSE;
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
default: default:
@ -375,7 +375,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
static u32 LoopedTask_UpdateInfoAfterCursorMove(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) switch (taskState)
{ {
case 0: case 0:
@ -409,7 +409,7 @@ static u32 LoopedTask_RegionMapZoomOut(s32 taskState)
if (WaitForHelpBar()) if (WaitForHelpBar())
return LT_PAUSE; return LT_PAUSE;
sub_81C7E14(POKENAV_GFX_MAP_MENU_ZOOMED_OUT); UpdateRegionMapRightHeaderTiles(POKENAV_GFX_MAP_MENU_ZOOMED_OUT);
break; break;
} }
@ -418,7 +418,7 @@ static u32 LoopedTask_RegionMapZoomOut(s32 taskState)
static u32 LoopedTask_RegionMapZoomIn(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) switch (taskState)
{ {
case 0: case 0:
@ -442,7 +442,7 @@ static u32 LoopedTask_RegionMapZoomIn(s32 taskState)
if (WaitForHelpBar()) if (WaitForHelpBar())
return LT_PAUSE; return LT_PAUSE;
sub_81C7E14(POKENAV_GFX_MAP_MENU_ZOOMED_IN); UpdateRegionMapRightHeaderTiles(POKENAV_GFX_MAP_MENU_ZOOMED_IN);
break; break;
} }
@ -461,8 +461,8 @@ static u32 LoopedTask_ExitRegionMap(s32 taskState)
if (IsPaletteFadeActive()) if (IsPaletteFadeActive())
return LT_PAUSE; return LT_PAUSE;
sub_81C7FDC(); SetLeftHeaderSpritesInvisibility();
sub_81C78A0(); SlideMenuHeaderDown();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 2: case 2:
if (MainMenuLoopedTaskIsBusy()) if (MainMenuLoopedTaskIsBusy())
@ -490,7 +490,7 @@ static void LoadCityZoomViewGfx(void)
static void FreeCityZoomViewGfx(void) static void FreeCityZoomViewGfx(void)
{ {
int i; int i;
struct Pokenav5Struct_2 *state = GetSubstructPtr(4); struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
FreeSpriteTilesByTag(6); FreeSpriteTilesByTag(6);
FreeSpritePaletteByTag(11); FreeSpritePaletteByTag(11);
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) 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) static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state)
{ {
struct RegionMap *regionMap = GetSubstructPtr(16); struct RegionMap *regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP);
switch (regionMap->mapSecType) switch (regionMap->mapSecType)
{ {
case MAPSECTYPE_CITY_CANFLY: case MAPSECTYPE_CITY_CANFLY:
@ -619,7 +619,7 @@ static bool32 IsDecompressCityMapsActive(void)
static u32 LoopedTask_DecompressCityMaps(s32 taskState) 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) if (taskState < NUM_CITY_MAPS)
{ {
LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]); LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]);
@ -662,7 +662,7 @@ static void CreateCityZoomTextSprites(void)
int i; int i;
int y; int y;
struct Sprite *sprite; 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 // When not zoomed in the text is still created but its pushed off screen
if (!IsRegionMapZoomed()) if (!IsRegionMapZoomed())
@ -722,7 +722,7 @@ static void SpriteCB_CityZoomText(struct Sprite *sprite)
static void UpdateCityZoomTextPosition(void) static void UpdateCityZoomTextPosition(void)
{ {
int i; int i;
struct Pokenav5Struct_2 *state = GetSubstructPtr(4); struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
int y = 132 - (GetBgY(1) >> 8); int y = 132 - (GetBgY(1) >> 8);
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
state->cityZoomTextSprites[i]->pos1.y = y; state->cityZoomTextSprites[i]->pos1.y = y;
@ -731,7 +731,7 @@ static void UpdateCityZoomTextPosition(void)
static void SetCityZoomTextInvisibility(bool32 invisible) static void SetCityZoomTextInvisibility(bool32 invisible)
{ {
int i; 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++) for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
state->cityZoomTextSprites[i]->invisible = invisible; state->cityZoomTextSprites[i]->invisible = invisible;
} }

View File

@ -8,16 +8,28 @@
#include "international_string_util.h" #include "international_string_util.h"
#include "constants/songs.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 struct PokenavSub9
{ {
u32 (*unk0)(struct PokenavSub9*); u32 (*callback)(struct PokenavSub9*);
u32 loopedTaskId; u32 loopedTaskId;
u16 winid; u16 winid;
s32 unkC; s32 boxId;
s32 unk10; s32 monId;
u32 unk14; u32 changeBgs;
u32 unk18; u32 saveMonList;
struct PokenavSub18 *unk1C; struct PokenavSub18 *monList;
}; };
struct PokenavSub10 struct PokenavSub10
@ -25,46 +37,46 @@ struct PokenavSub10
bool32 (*callback)(void); bool32 (*callback)(void);
u32 ltid; u32 ltid;
u16 winid; u16 winid;
bool32 unkC; bool32 fromSummary;
u8 buff[BG_SCREEN_SIZE]; u8 buff[BG_SCREEN_SIZE];
}; };
static u32 sub_81CFA68(struct PokenavSub9 *structPtr); static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr);
static u32 sub_81CFA88(struct PokenavSub9 *structPtr); static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr);
static u32 sub_81CFB08(struct PokenavSub9 *structPtr); static u32 RibbonsMonMenu_ReturnToMainMenu(struct PokenavSub9 *structPtr);
static u32 sub_81CFB10(struct PokenavSub9 *structPtr); static u32 sub_81CFB10(struct PokenavSub9 *structPtr);
static u32 sub_81CFB8C(s32 state); static u32 BuildPartyMonRibbonList(s32 state);
static u32 sub_81CFC2C(s32 state); static u32 InitBoxMonRibbonList(s32 state);
static u32 sub_81CFC40(s32 state); static u32 BuildBoxMonRibbonList(s32 state);
static u32 sub_81CFB74(s32 state); static u32 GetMonRibbonListLoopTaskFunc(s32 state);
static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item); static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item);
static u32 sub_81CFEB8(s32 state); static u32 LoopedTask_OpenRibbonsMonList(s32 state);
static bool32 sub_81CFE84(void); static bool32 GetRibbonsMonCurrentLoopedTaskActive(void);
static u32 sub_81CFFFC(s32 state); static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state);
static u32 sub_81D0074(s32 state); static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state);
static u32 sub_81D00EC(s32 state); static u32 LoopedTask_RibbonsListMovePageUp(s32 state);
static u32 sub_81D0164(s32 state); static u32 LoopedTask_RibbonsListMovePageDown(s32 state);
static u32 sub_81D01DC(s32 state); static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state);
static u32 sub_81D021C(s32 state); static u32 LoopedTask_RibbonsListOpenSummary(s32 state);
static void sub_81D02B0(s32 windowId, s32 val1, s32 val2); 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_81D0288(struct PokenavSub10 *ptr);
static void sub_81D0304(void); static void InitMonRibbonPokenavListMenuTemplate(void);
static void BufferRibbonMonInfoText(struct PokenavMonList *, u8 *); static void BufferRibbonMonInfoText(struct PokenavMonList *, u8 *);
static const LoopedTask gUnknown_086235D8[] = static const LoopedTask sMonRibbonListLoopTaskFuncs[] =
{ {
sub_81CFB8C, BuildPartyMonRibbonList,
sub_81CFC2C, InitBoxMonRibbonList,
sub_81CFC40 BuildBoxMonRibbonList
}; };
static const u16 gUnknown_086235E4[] = INCBIN_U16("graphics/pokenav/ui_ribbons.gbapal"); static const u16 sMonRibbonListFramePal[] = INCBIN_U16("graphics/pokenav/ui_ribbons.gbapal");
static const u32 gUnknown_08623604[] = INCBIN_U32("graphics/pokenav/ui_ribbons.4bpp.lz"); static const u32 sMonRibbonListFrameTiles[] = INCBIN_U32("graphics/pokenav/ui_ribbons.4bpp.lz");
static const u32 gUnknown_086236CC[] = INCBIN_U32("graphics/pokenav/ui_ribbons.bin.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 u16 gUnknown_08623790[] = INCBIN_U16("graphics/pokenav/8623790.gbapal");
static const struct BgTemplate gUnknown_086237B0[] = static const struct BgTemplate sMonRibbonListBgTemplates[] =
{ {
{ {
.bg = 1, .bg = 1,
@ -85,18 +97,18 @@ static const struct BgTemplate gUnknown_086237B0[] =
} }
}; };
static const LoopedTask gUnknown_086237B8[] = static const LoopedTask sRibbonsMonMenuLoopTaskFuncs[] =
{ {
NULL, [RIBBONS_MON_LIST_FUNC_NONE] = NULL,
sub_81CFFFC, [RIBBONS_MON_LIST_FUNC_MOVE_UP] = LoopedTask_RibbonsListMoveCursorUp,
sub_81D0074, [RIBBONS_MON_LIST_FUNC_MOVE_DOWN] = LoopedTask_RibbonsListMoveCursorDown,
sub_81D00EC, [RIBBONS_MON_LIST_FUNC_PAGE_UP] = LoopedTask_RibbonsListMovePageUp,
sub_81D0164, [RIBBONS_MON_LIST_FUNC_PAGE_DOWN] = LoopedTask_RibbonsListMovePageDown,
sub_81D01DC, [RIBBONS_MON_LIST_FUNC_EXIT] = LoopedTask_RibbonsListReturnToMainMenu,
sub_81D021C [RIBBONS_MON_LIST_FUNC_OPEN_RIBBONS_SUMMARY] = LoopedTask_RibbonsListOpenSummary
}; };
static const struct WindowTemplate gUnknown_086237D4 = static const struct WindowTemplate sRibbonsMonListWindowTemplate =
{ {
.bg = 1, .bg = 1,
.tilemapLeft = 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_FemaleSymbol[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}");
static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}"); 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) if (structPtr == NULL)
return FALSE; return FALSE;
structPtr->unk1C = AllocSubstruct(18, sizeof(struct PokenavSub18)); structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
if (structPtr->unk1C == NULL) if (structPtr->monList == NULL)
return FALSE; return FALSE;
structPtr->unk0 = sub_81CFA68; structPtr->callback = HandleRibbonsMonListInput_WaitListInit;
structPtr->loopedTaskId = CreateLoopedTask(sub_81CFB74, 1); structPtr->loopedTaskId = CreateLoopedTask(GetMonRibbonListLoopTaskFunc, 1);
structPtr->unk14 = 0; structPtr->changeBgs = 0;
return TRUE; 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) if (structPtr == NULL)
return FALSE; return FALSE;
structPtr->unk1C = GetSubstructPtr(18); structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
structPtr->unk0 = sub_81CFA88; structPtr->callback = HandleRibbonsMonListInput;
structPtr->unk14 = 1; structPtr->changeBgs = 1;
return TRUE; return TRUE;
} }
u32 sub_81CFA34(void) u32 GetRibbonsMonListCallback(void)
{ {
struct PokenavSub9 *structPtr = GetSubstructPtr(9); struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return structPtr->unk0(structPtr); return structPtr->callback(structPtr);
} }
void sub_81CFA48(void) void FreeRibbonsMonList1(void)
{ {
struct PokenavSub9 *structPtr = GetSubstructPtr(9); struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
if (!structPtr->unk18) if (!structPtr->saveMonList)
FreePokenavSubstruct(18); FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(9); FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
} }
static u32 sub_81CFA68(struct PokenavSub9 *structPtr) static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr)
{ {
if (!IsLoopedTaskActive(structPtr->loopedTaskId)) if (!IsLoopedTaskActive(structPtr->loopedTaskId))
structPtr->unk0 = sub_81CFA88; structPtr->callback = HandleRibbonsMonListInput;
return 0; return 0;
} }
static u32 sub_81CFA88(struct PokenavSub9 *structPtr) static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr)
{ {
if (JOY_REPEAT(DPAD_UP)) if (JOY_REPEAT(DPAD_UP))
return 1; return RIBBONS_MON_LIST_FUNC_MOVE_UP;
if (JOY_REPEAT(DPAD_DOWN)) if (JOY_REPEAT(DPAD_DOWN))
return 2; return RIBBONS_MON_LIST_FUNC_MOVE_DOWN;
if (JOY_NEW(DPAD_LEFT)) if (JOY_NEW(DPAD_LEFT))
return 3; return RIBBONS_MON_LIST_FUNC_PAGE_UP;
if (JOY_NEW(DPAD_RIGHT)) if (JOY_NEW(DPAD_RIGHT))
return 4; return RIBBONS_MON_LIST_FUNC_PAGE_DOWN;
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
{ {
structPtr->unk18 = 0; structPtr->saveMonList = 0;
structPtr->unk0 = sub_81CFB08; structPtr->callback = RibbonsMonMenu_ReturnToMainMenu;
return 5; return RIBBONS_MON_LIST_FUNC_EXIT;
} }
if (JOY_NEW(A_BUTTON)) if (JOY_NEW(A_BUTTON))
{ {
structPtr->unk1C->unk2 = GetSelectedMatchCall(); structPtr->monList->currIndex = GetSelectedPokenavListIndex();
structPtr->unk18 = 1; structPtr->saveMonList = 1;
structPtr->unk0 = sub_81CFB10; structPtr->callback = sub_81CFB10;
return 6; 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; return POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS;
} }
static u32 sub_81CFB10(struct PokenavSub9 *structPtr) 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); struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return structPtr->unk14; return structPtr->changeBgs;
} }
static struct PokenavMonList * sub_81CFB28(void) static struct PokenavMonList *GetMonRibbonMonListData(void)
{ {
struct PokenavSub9 * ptr = GetSubstructPtr(9); struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->unk1C->unk4; return ptr->monList->monData;
} }
static s32 sub_81CFB38(void) static s32 GetRibbonsMonListCount(void)
{ {
struct PokenavSub9 * ptr = GetSubstructPtr(9); struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->unk1C->unk0; return ptr->monList->listCount;
} }
static s32 sub_81CFB48(void) //unused
static s32 GetMonRibbonSelectedMonData(void)
{ {
struct PokenavSub9 * ptr = GetSubstructPtr(9); struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 idx = GetSelectedMatchCall(); s32 idx = GetSelectedPokenavListIndex();
return ptr->unk1C->unk4[idx].data; return ptr->monList->monData[idx].data;
} }
static s32 sub_81CFB64(void) static s32 GetRibbonListMenuCurrIndex(void)
{ {
struct PokenavSub9 * ptr = GetSubstructPtr(9); struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->unk1C->unk2; 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; s32 i;
struct PokenavMonList item; struct PokenavMonList item;
struct PokenavSub9 * ptr = GetSubstructPtr(9); struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
ptr->unk1C->unk0 = 0; ptr->monList->listCount = 0;
ptr->unk1C->unk2 = 0; ptr->monList->currIndex = 0;
item.boxId = TOTAL_BOXES_COUNT; item.boxId = TOTAL_BOXES_COUNT;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
@ -261,19 +274,19 @@ static u32 sub_81CFB8C(s32 state)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
static u32 sub_81CFC2C(s32 state) static u32 InitBoxMonRibbonList(s32 state)
{ {
struct PokenavSub9 * ptr = GetSubstructPtr(9); struct PokenavSub9 *ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
ptr->unk10 = 0; ptr->monId = 0;
ptr->unkC = 0; ptr->boxId = 0;
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
static u32 sub_81CFC40(s32 state) static u32 BuildBoxMonRibbonList(s32 state)
{ {
struct PokenavSub9 * ptr = GetSubstructPtr(9); struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 boxId = ptr->unkC; s32 boxId = ptr->boxId;
s32 monId = ptr->unk10; s32 monId = ptr->monId;
s32 boxCount = 0; s32 boxCount = 0;
struct PokenavMonList item; struct PokenavMonList item;
@ -296,8 +309,8 @@ static u32 sub_81CFC40(s32 state)
monId++; monId++;
if (boxCount > TOTAL_BOXES_COUNT) if (boxCount > TOTAL_BOXES_COUNT)
{ {
ptr->unkC = boxId; ptr->boxId = boxId;
ptr->unk10 = monId; ptr->monId = monId;
return LT_CONTINUE; return LT_CONTINUE;
} }
} }
@ -305,37 +318,38 @@ static u32 sub_81CFC40(s32 state)
boxId++; boxId++;
} }
ptr->unk14 = 1; ptr->changeBgs = 1;
return LT_FINISH; return LT_FINISH;
} }
static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item) static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item)
{ {
u32 left = 0; u32 left = 0;
u32 right = structPtr->unk1C->unk0; u32 right = structPtr->monList->listCount;
u32 insertionIdx = left + (right - left) / 2; u32 insertionIdx = left + (right - left) / 2;
while (right != insertionIdx) while (right != insertionIdx)
{ {
if (item->data > structPtr->unk1C->unk4[insertionIdx].data) if (item->data > structPtr->monList->monData[insertionIdx].data)
right = insertionIdx; right = insertionIdx;
else else
left = insertionIdx + 1; left = insertionIdx + 1;
insertionIdx = left + (right - left) / 2; insertionIdx = left + (right - left) / 2;
} }
for (right = structPtr->unk1C->unk0; right > insertionIdx; right--) for (right = structPtr->monList->listCount; right > insertionIdx; right--)
structPtr->unk1C->unk4[right] = structPtr->unk1C->unk4[right - 1]; structPtr->monList->monData[right] = structPtr->monList->monData[right - 1];
structPtr->unk1C->unk4[insertionIdx] = *item; structPtr->monList->monData[insertionIdx] = *item;
structPtr->unk1C->unk0++; structPtr->monList->listCount++;
} }
static bool32 sub_81CFD58(void) //unused
static bool32 Unused_PlayerHasRibbonsMon(void)
{ {
s32 i, j; s32 i, j;
for (i = 0; i < PARTY_SIZE; i++) 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)) if (!GetMonData(mon, MON_DATA_SANITY_HAS_SPECIES))
continue; continue;
if (GetMonData(mon, MON_DATA_SANITY_IS_EGG)) if (GetMonData(mon, MON_DATA_SANITY_IS_EGG))
@ -358,72 +372,72 @@ static bool32 sub_81CFD58(void)
return FALSE; 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) if (ptr == NULL)
return FALSE; return FALSE;
ptr->ltid = CreateLoopedTask(sub_81CFEB8, 1); ptr->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
ptr->callback = sub_81CFE84; ptr->callback = GetRibbonsMonCurrentLoopedTaskActive;
ptr->unkC = FALSE; ptr->fromSummary = FALSE;
return TRUE; return TRUE;
} }
bool32 sub_81CFE08(void) bool32 OpenRibbonsMonListFromRibbonsSummary(void)
{ {
struct PokenavSub10 * ptr = AllocSubstruct(10, sizeof(struct PokenavSub10)); struct PokenavSub10 *monMenu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10));
if (ptr == NULL) if (monMenu == NULL)
return FALSE; return FALSE;
ptr->ltid = CreateLoopedTask(sub_81CFEB8, 1); monMenu->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
ptr->callback = sub_81CFE84; monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive;
ptr->unkC = TRUE; monMenu->fromSummary = TRUE;
return TRUE; return TRUE;
} }
void sub_81CFE40(s32 idx) void CreateRibbonsMonListLoopedTask(s32 idx)
{ {
struct PokenavSub10 * ptr = GetSubstructPtr(10); struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
ptr->ltid = CreateLoopedTask(gUnknown_086237B8[idx], 1); monMenu->ltid = CreateLoopedTask(sRibbonsMonMenuLoopTaskFuncs[idx], 1);
ptr->callback = sub_81CFE84; monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive;
} }
bool32 sub_81CFE70(void) bool32 IsRibbonsMonListLoopedTaskActive(void)
{ {
struct PokenavSub10 * ptr = GetSubstructPtr(10); struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return ptr->callback(); 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); 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(); sub_81C8234();
RemoveWindow(ptr->winid); 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) switch (state)
{ {
case 0: case 0:
InitBgTemplates(gUnknown_086237B0, NELEMS(gUnknown_086237B0)); InitBgTemplates(sMonRibbonListBgTemplates, NELEMS(sMonRibbonListBgTemplates));
DecompressAndCopyTileDataToVram(1, gUnknown_08623604, 0, 0, 0); DecompressAndCopyTileDataToVram(1, sMonRibbonListFrameTiles, 0, 0, 0);
SetBgTilemapBuffer(1, unk->buff); SetBgTilemapBuffer(1, monMenu->buff);
CopyToBgTilemapBuffer(1, gUnknown_086236CC, 0, 0); CopyToBgTilemapBuffer(1, sMonRibbonListFrameTilemap, 0, 0);
CopyPaletteIntoBufferUnfaded(gUnknown_086235E4, 0x10, 0x20); CopyPaletteIntoBufferUnfaded(sMonRibbonListFramePal, 0x10, 0x20);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
if (!sub_81CFB18()) if (!UpdateMonListBgs())
return LT_PAUSE; return LT_PAUSE;
ChangeBgX(1, 0, 0); ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0); ChangeBgY(1, 0, 0);
@ -433,12 +447,12 @@ static u32 sub_81CFEB8(s32 state)
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
CopyPaletteIntoBufferUnfaded(gUnknown_08623790, 0x20, 0x20); CopyPaletteIntoBufferUnfaded(gUnknown_08623790, 0x20, 0x20);
sub_81D0304(); InitMonRibbonPokenavListMenuTemplate();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (sub_81C8224()) if (sub_81C8224())
return LT_PAUSE; return LT_PAUSE;
sub_81D024C(unk); AddRibbonsMonListWindow(monMenu);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 4: case 4:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
@ -447,25 +461,25 @@ static u32 sub_81CFEB8(s32 state)
HideBg(3); HideBg(3);
PrintHelpBarText(HELPBAR_RIBBONS_MON_LIST); PrintHelpBarText(HELPBAR_RIBBONS_MON_LIST);
PokenavFadeScreen(1); PokenavFadeScreen(1);
if (!unk->unkC) if (!monMenu->fromSummary)
{ {
LoadLeftHeaderGfxForIndex(2); LoadLeftHeaderGfxForIndex(POKENAV_GFX_RIBBONS_MENU);
sub_81C7FA0(2, 1, 0); ShowLeftHeaderGfx(POKENAV_GFX_RIBBONS_MENU, 1, 0);
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 5: case 5:
if (IsPaletteFadeActive()) if (IsPaletteFadeActive())
return LT_PAUSE; return LT_PAUSE;
if (sub_81C8010()) if (AreLeftHeaderSpritesMoving())
return LT_PAUSE; return LT_PAUSE;
break; break;
} }
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -482,11 +496,11 @@ static u32 sub_81CFFFC(s32 state)
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
sub_81D0288(unk); sub_81D0288(monMenu);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -496,9 +510,9 @@ static u32 sub_81CFFFC(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -515,11 +529,11 @@ static u32 sub_81D0074(s32 state)
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
sub_81D0288(unk); sub_81D0288(monMenu);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -529,9 +543,9 @@ static u32 sub_81D0074(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -548,11 +562,11 @@ static u32 sub_81D00EC(s32 state)
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
sub_81D0288(unk); sub_81D0288(monMenu);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -562,9 +576,9 @@ static u32 sub_81D00EC(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -581,11 +595,11 @@ static u32 sub_81D0164(s32 state)
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (sub_81C8630()) if (IsMonListLoopedTaskActive())
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
sub_81D0288(unk); sub_81D0288(monMenu);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -595,27 +609,27 @@ static u32 sub_81D0164(s32 state)
return LT_FINISH; return LT_FINISH;
} }
static u32 sub_81D01DC(s32 state) static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state)
{ {
switch (state) switch (state)
{ {
case 0: case 0:
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
PokenavFadeScreen(0); PokenavFadeScreen(0);
sub_81C78A0(); SlideMenuHeaderDown();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
if (IsPaletteFadeActive()) if (IsPaletteFadeActive())
return LT_PAUSE; return LT_PAUSE;
if (MainMenuLoopedTaskIsBusy()) if (MainMenuLoopedTaskIsBusy())
return LT_PAUSE; return LT_PAUSE;
sub_81C7FDC(); SetLeftHeaderSpritesInvisibility();
break; break;
} }
return LT_FINISH; return LT_FINISH;
} }
static u32 sub_81D021C(s32 state) static u32 LoopedTask_RibbonsListOpenSummary(s32 state)
{ {
switch (state) switch (state)
{ {
@ -631,23 +645,23 @@ static u32 sub_81D021C(s32 state)
return LT_FINISH; return LT_FINISH;
} }
static void sub_81D024C(struct PokenavSub10 * ptr) static void AddRibbonsMonListWindow(struct PokenavSub10 *monMenu)
{ {
s32 r2; s32 r2;
ptr->winid = AddWindow(&gUnknown_086237D4); monMenu->winid = AddWindow(&sRibbonsMonListWindowTemplate);
PutWindowTilemap(ptr->winid); PutWindowTilemap(monMenu->winid);
r2 = sub_81CFB38(); r2 = GetRibbonsMonListCount();
sub_81D02B0(ptr->winid, 0, r2); sub_81D02B0(monMenu->winid, 0, r2);
CopyWindowToVram(ptr->winid, 1); CopyWindowToVram(monMenu->winid, 1);
sub_81D0288(ptr); sub_81D0288(monMenu);
} }
static void sub_81D0288(struct PokenavSub10 * ptr) static void sub_81D0288(struct PokenavSub10 *monMenu)
{ {
s32 r4 = GetSelectedMatchCall(); s32 r4 = GetSelectedPokenavListIndex();
s32 r2 = sub_81CFB38(); s32 r2 = GetRibbonsMonListCount();
sub_81D02B0(ptr->winid, r4 + 1, r2); sub_81D02B0(monMenu->winid, r4 + 1, r2);
CopyWindowToVram(ptr->winid, 2); CopyWindowToVram(monMenu->winid, 2);
} }
static void sub_81D02B0(s32 windowId, s32 val1, s32 val2) 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); AddTextPrinterParameterized(windowId, 1, strbuf, x, 1, 0xFF, NULL);
} }
static void sub_81D0304(void) static void InitMonRibbonPokenavListMenuTemplate(void)
{ {
struct PokenavListTemplate template; struct PokenavListTemplate template;
template.list.monList = sub_81CFB28(); template.list.monList = GetMonRibbonMonListData();
template.unk4 = sub_81CFB38(); template.count = GetRibbonsMonListCount();
template.unk8 = 4; template.unk8 = 4;
template.unk6 = sub_81CFB64(); template.unk6 = GetRibbonListMenuCurrIndex();
template.unk9 = 13; template.item_X = 13;
template.unkA = 17; template.windowWidth = 17;
template.unkB = 1; template.listTop = 1;
template.unkC = 8; template.maxShowed = 8;
template.unkD = 2; template.fillValue = 2;
template.unkE = 1; template.fontId = 1;
template.listFunc.unk10_1 = BufferRibbonMonInfoText; template.listFunc.printMonFunc = BufferRibbonMonInfoText;
template.unk14 = NULL; 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 // Buffers the "Nickname gender/level" text for the ribbon mon list

View File

@ -13,28 +13,38 @@
#include "window.h" #include "window.h"
#include "constants/songs.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 struct PokenavSub13
{ {
u8 filler0[0x8]; u8 filler0[0x8];
struct PokenavSub18 *field_8; struct PokenavSub18 *monList;
u16 field_C; u16 field_C;
u16 field_E; u16 field_E;
u16 field_10; u16 field_10;
u16 field_12; u16 field_12;
u32 field_14[25]; u32 field_14[25];
u32 field_78[8]; u32 field_78[8];
u32 (*field_98)(struct PokenavSub13 *structPtr); u32 (*callback)(struct PokenavSub13 *structPtr);
}; };
struct PokenavSub14 struct PokenavSub14
{ {
u32 (*field_0)(void); u32 (*callback)(void);
u32 loopedTaskId; u32 loopedTaskId;
u16 field_8; u16 nameWindowId;
u16 field_A; u16 ribbonCountWindowId;
u16 field_C; u16 listIdxWindowId;
u16 field_E; u16 field_E;
u16 field_10; u16 monSpriteId;
struct Sprite *field_14; struct Sprite *field_14;
u32 filler; u32 filler;
u8 tilemapBuffers[2][BG_SCREEN_SIZE]; u8 tilemapBuffers[2][BG_SCREEN_SIZE];
@ -43,48 +53,48 @@ struct PokenavSub14
static u32 gUnknown_030012C0; static u32 gUnknown_030012C0;
static u32 gUnknown_030012C4; static u32 gUnknown_030012C4;
void sub_81D0E84(struct PokenavSub14 *structPtr); void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr);
void sub_81D0FF0(struct PokenavSub14 *structPtr); void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr);
void sub_81D10D0(struct PokenavSub14 *structPtr); void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr);
void sub_81D1500(struct PokenavSub14 *structPtr); void sub_81D1500(struct PokenavSub14 *structPtr);
void sub_81D0EFC(struct PokenavSub14 *structPtr); void sub_81D0EFC(struct PokenavSub14 *structPtr);
void sub_81D1148(struct PokenavSub14 *structPtr); void ResetSpritesAndDrawRibbonsMonFrontPic(struct PokenavSub14 *structPtr);
void sub_81D10A4(struct PokenavSub14 *structPtr); void AddRibbonListIndexWindow(struct PokenavSub14 *structPtr);
void sub_81D1178(struct PokenavSub14 *structPtr); void DestroyRibbonsMonFrontPic(struct PokenavSub14 *structPtr);
void sub_81D11D8(struct PokenavSub14 *structPtr); void sub_81D11D8(struct PokenavSub14 *structPtr);
void sub_81D11FC(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_81D1448(struct PokenavSub14 *structPtr);
void sub_81D13FC(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); void sub_81D12D8(struct PokenavSub14 *structPtr);
bool32 sub_81D1524(struct PokenavSub14 *structPtr); bool32 sub_81D1524(struct PokenavSub14 *structPtr);
bool32 sub_81D1234(struct PokenavSub14 *structPtr); bool32 sub_81D1234(struct PokenavSub14 *structPtr);
void sub_81D0814(struct PokenavSub13 *structPtr); void sub_81D0814(struct PokenavSub13 *structPtr);
u32 sub_81D0548(struct PokenavSub13 *structPtr); u32 HandleExpandedRibbonInput(struct PokenavSub13 *structPtr);
u32 sub_81D04C4(struct PokenavSub13 *structPtr); u32 RibbonsSummaryHandleInput(struct PokenavSub13 *structPtr);
u32 sub_81D05D4(struct PokenavSub13 *structPtr); u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *structPtr);
bool32 sub_81D05DC(struct PokenavSub13 *structPtr); bool32 sub_81D05DC(struct PokenavSub13 *structPtr);
bool32 sub_81D0688(struct PokenavSub13 *structPtr); bool32 sub_81D0688(struct PokenavSub13 *structPtr);
bool32 sub_81D0664(struct PokenavSub13 *structPtr); bool32 sub_81D0664(struct PokenavSub13 *structPtr);
bool32 sub_81D061C(struct PokenavSub13 *structPtr); bool32 sub_81D061C(struct PokenavSub13 *structPtr);
bool32 sub_81D0688(struct PokenavSub13 *structPtr); bool32 sub_81D0688(struct PokenavSub13 *structPtr);
bool32 sub_81D0A58(void); bool32 GetCurrentLoopedTaskActive(void);
u32 sub_81D06C4(void); u32 GetRibbonsSummaryCurrentIndex(void);
u32 sub_81D06D4(void); u32 GetRibbonsSummaryMonListCount(void);
u16 sub_81D1184(s32 unused0, s32 unused1); u16 DrawRibbonsMonFrontPic(s32 unused0, s32 unused1);
void sub_81D1258(struct Sprite *sprite, s32 arg1, s32 arg2, s32 arg3); void sub_81D1258(struct Sprite *sprite, s32 arg1, s32 arg2, s32 arg3);
void sub_81D1284(struct Sprite *sprite); void sub_81D1284(struct Sprite *sprite);
void sub_81D1350(void); void sub_81D1350(void);
void sub_81D13BC(u16 *dst, u32 id); void sub_81D13BC(u16 *dst, u32 id);
void sub_81D1370(u32 arg0, u32 id); void sub_81D1370(u32 arg0, u32 id);
void sub_81D1538(struct Sprite *sprite); void sub_81D1538(struct Sprite *sprite);
u32 sub_81D0A6C(s32 state); u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state);
u32 sub_81D0C84(s32 state); u32 LoopedTask_UpdateRibbonsSummaryInfo(s32 state);
u32 sub_81D0D2C(s32 state); u32 LoopedTask_ExpandSelectedRibbon(s32 state);
u32 sub_81D0D8C(s32 state); u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state);
u32 sub_81D0E00(s32 state); u32 LoopedTask_ShrinkExpandedRibbon(s32 state);
u32 sub_81D0C54(s32 state); u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state);
struct struct
{ {
@ -147,95 +157,95 @@ static const struct BgTemplate gUnknown_08624B98[] =
} }
}; };
static const LoopedTask gUnknown_08624BA0[] = static const LoopedTask sRibbonsSummaryMenuLoopTaskFuncs[] =
{ {
NULL, [RIBBONS_SUMMARY_FUNC_NONE] = NULL,
sub_81D0C84, [RIBBONS_SUMMARY_FUNC_MOVED_CURSOR] = LoopedTask_UpdateRibbonsSummaryInfo,
sub_81D0D2C, [RIBBONS_SUMMARY_FUNC_SELECT_RIBBON] = LoopedTask_ExpandSelectedRibbon,
sub_81D0D8C, [RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE] = LoopedTask_MoveRibbonsCursorExpanded,
sub_81D0E00, [RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL] = LoopedTask_ShrinkExpandedRibbon,
sub_81D0C54 [RIBBONS_SUMMARY_FUNC_EXIT] = LoopedTask_ExitRibbonsSummaryMenu
}; };
// code // 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) if (structPtr == NULL)
return FALSE; return FALSE;
structPtr->field_8 = GetSubstructPtr(18); structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (structPtr->field_8 == NULL) if (structPtr->monList == NULL)
return FALSE; return FALSE;
sub_81D0814(structPtr); sub_81D0814(structPtr);
structPtr->field_98 = sub_81D04C4; structPtr->callback = RibbonsSummaryHandleInput;
gKeyRepeatContinueDelay = 3; gKeyRepeatContinueDelay = 3;
gKeyRepeatStartDelay = 10; gKeyRepeatStartDelay = 10;
return TRUE; return TRUE;
} }
u32 sub_81D04A0(void) u32 GetRibbonsSummaryMenuCallback(void)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->field_98(structPtr); 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; structPtr->field_C = 0;
sub_81D0814(structPtr); 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; structPtr->field_C = 0;
sub_81D0814(structPtr); sub_81D0814(structPtr);
return 1; return RIBBONS_SUMMARY_FUNC_MOVED_CURSOR;
} }
if (JOY_NEW(A_BUTTON)) if (JOY_NEW(A_BUTTON))
{ {
structPtr->field_98 = sub_81D0548; structPtr->callback = HandleExpandedRibbonInput;
return 2; return RIBBONS_SUMMARY_FUNC_SELECT_RIBBON;
} }
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
{ {
structPtr->field_98 = sub_81D05D4; structPtr->callback = ReturnToRibbonsListFromSummary;
return 5; 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)) 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)) 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)) 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)) if (JOY_REPEAT(DPAD_RIGHT) && sub_81D0688(structPtr))
return 3; return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
{ {
structPtr->field_98 = sub_81D04C4; structPtr->callback = RibbonsSummaryHandleInput;
return 4; 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) bool32 sub_81D05DC(struct PokenavSub13 *structPtr)
@ -320,23 +330,23 @@ bool32 sub_81D0688(struct PokenavSub13 *structPtr)
return FALSE; return FALSE;
} }
u32 sub_81D06C4(void) u32 GetRibbonsSummaryCurrentIndex(void)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->field_8->unk2; return structPtr->monList->currIndex;
} }
u32 sub_81D06D4(void) u32 GetRibbonsSummaryMonListCount(void)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->field_8->unk0; return structPtr->monList->listCount;
} }
static void GetCurrMonInfo1(u8 *nick, u8 *level, u8 *gender) static void GetCurrMonInfo1(u8 *nick, u8 *level, u8 *gender)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->field_8; struct PokenavSub18 *mons = structPtr->monList;
struct PokenavMonList *monInfo = &mons->unk4[mons->unk2]; struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT) 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) static void GetCurrMonInfo2(u16 *species, u32 *personality, u32 *otId)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->field_8; struct PokenavSub18 *mons = structPtr->monList;
struct PokenavMonList *monInfo = &mons->unk4[mons->unk2]; struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT) if (monInfo->boxId == TOTAL_BOXES_COUNT)
{ {
@ -379,9 +389,9 @@ static void GetCurrMonInfo2(u16 *species, u32 *personality, u32 *otId)
static u32 GetCurrMonRibbonCount(void) static u32 GetCurrMonRibbonCount(void)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->field_8; struct PokenavSub18 *mons = structPtr->monList;
struct PokenavMonList *monInfo = &mons->unk4[mons->unk2]; struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT) if (monInfo->boxId == TOTAL_BOXES_COUNT)
return GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBON_COUNT); return GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBON_COUNT);
@ -393,8 +403,8 @@ void sub_81D0814(struct PokenavSub13 *structPtr)
{ {
u32 ribbons; u32 ribbons;
s32 i, j; s32 i, j;
struct PokenavSub18 *mons = structPtr->field_8; struct PokenavSub18 *mons = structPtr->monList;
struct PokenavMonList *monInfo = &mons->unk4[mons->unk2]; struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT) if (monInfo->boxId == TOTAL_BOXES_COUNT)
ribbons = GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBONS); ribbons = GetMonData(&gPlayerParty[monInfo->monId], MON_DATA_RIBBONS);
@ -433,27 +443,27 @@ void sub_81D0814(struct PokenavSub13 *structPtr)
u32 *sub_81D0914(u32 *arg0) u32 *sub_81D0914(u32 *arg0)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*arg0 = structPtr->field_10; *arg0 = structPtr->field_10;
return structPtr->field_14; return structPtr->field_14;
} }
u32 *sub_81D092C(u32 *arg0) u32 *sub_81D092C(u32 *arg0)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*arg0 = structPtr->field_12; *arg0 = structPtr->field_12;
return structPtr->field_78; return structPtr->field_78;
} }
u16 sub_81D0944(void) u16 sub_81D0944(void)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->field_C; return structPtr->field_C;
} }
u32 sub_81D0954(void) u32 sub_81D0954(void)
{ {
struct PokenavSub13 *structPtr = GetSubstructPtr(13); struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
int var = structPtr->field_C; int var = structPtr->field_C;
if (var <= 24) if (var <= 24)
return structPtr->field_14[var]; return structPtr->field_14[var];
@ -461,38 +471,38 @@ u32 sub_81D0954(void)
return structPtr->field_78[var - 27]; 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) if (structPtr == NULL)
return FALSE; return FALSE;
structPtr->loopedTaskId = CreateLoopedTask(sub_81D0A6C, 1); structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsSummaryMenu, 1);
structPtr->field_0 = sub_81D0A58; structPtr->callback = GetCurrentLoopedTaskActive;
return TRUE; return TRUE;
} }
void sub_81D09B0(s32 id) void CreateRibbonsSummaryLoopedTask(s32 id)
{ {
struct PokenavSub14 *structPtr = GetSubstructPtr(14); struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
structPtr->loopedTaskId = CreateLoopedTask(gUnknown_08624BA0[id], 1); structPtr->loopedTaskId = CreateLoopedTask(sRibbonsSummaryMenuLoopTaskFuncs[id], 1);
structPtr->field_0 = sub_81D0A58; structPtr->callback = GetCurrentLoopedTaskActive;
} }
u32 sub_81D09E0(void) u32 IsRibbonsSummaryLoopedTaskActive(void)
{ {
struct PokenavSub14 *structPtr = GetSubstructPtr(14); struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return structPtr->field_0(); return structPtr->callback();
} }
void sub_81D09F4(void) void FreeRibbonsSummaryScreen2(void)
{ {
struct PokenavSub14 *structPtr = GetSubstructPtr(14); struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
RemoveWindow(structPtr->field_A); RemoveWindow(structPtr->ribbonCountWindowId);
RemoveWindow(structPtr->field_8); RemoveWindow(structPtr->nameWindowId);
RemoveWindow(structPtr->field_C); RemoveWindow(structPtr->listIdxWindowId);
RemoveWindow(structPtr->field_E); RemoveWindow(structPtr->field_E);
sub_81D1178(structPtr); DestroyRibbonsMonFrontPic(structPtr);
FreeSpriteTilesByTag(9); FreeSpriteTilesByTag(9);
FreeSpritePaletteByTag(0xF); FreeSpritePaletteByTag(0xF);
FreeSpritePaletteByTag(0x10); FreeSpritePaletteByTag(0x10);
@ -501,18 +511,18 @@ void sub_81D09F4(void)
FreeSpritePaletteByTag(0x13); FreeSpritePaletteByTag(0x13);
FreeSpriteOamMatrix(structPtr->field_14); FreeSpriteOamMatrix(structPtr->field_14);
DestroySprite(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); 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) switch (state)
{ {
case 0: case 0:
@ -539,21 +549,21 @@ u32 sub_81D0A6C(s32 state)
case 2: case 2:
if (!FreeTempTileDataBuffersIfPossible()) if (!FreeTempTileDataBuffersIfPossible())
{ {
sub_81D0E60(structPtr); AddRibbonCountWindow(structPtr);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
} }
return LT_PAUSE; return LT_PAUSE;
case 3: case 3:
if (!FreeTempTileDataBuffersIfPossible()) if (!FreeTempTileDataBuffersIfPossible())
{ {
sub_81D0FCC(structPtr); AddRibbonSummaryMonNameWindow(structPtr);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
} }
return LT_PAUSE; return LT_PAUSE;
case 4: case 4:
if (!FreeTempTileDataBuffersIfPossible()) if (!FreeTempTileDataBuffersIfPossible())
{ {
sub_81D10A4(structPtr); AddRibbonListIndexWindow(structPtr);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
} }
return LT_PAUSE; return LT_PAUSE;
@ -567,7 +577,7 @@ u32 sub_81D0A6C(s32 state)
case 6: case 6:
if (!IsDma3ManagerBusyWithBgCopy()) if (!IsDma3ManagerBusyWithBgCopy())
{ {
sub_81D1148(structPtr); ResetSpritesAndDrawRibbonsMonFrontPic(structPtr);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
return LT_PAUSE; return LT_PAUSE;
@ -598,7 +608,7 @@ u32 sub_81D0A6C(s32 state)
return LT_FINISH; return LT_FINISH;
} }
u32 sub_81D0C54(s32 state) u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state)
{ {
switch (state) switch (state)
{ {
@ -614,9 +624,9 @@ u32 sub_81D0C54(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -626,7 +636,7 @@ u32 sub_81D0C84(s32 state)
case 1: case 1:
if (!sub_81D1234(structPtr)) if (!sub_81D1234(structPtr))
{ {
sub_81D0FF0(structPtr); PrintRibbbonsSummaryMonInfo(structPtr);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
return LT_PAUSE; return LT_PAUSE;
@ -634,10 +644,10 @@ u32 sub_81D0C84(s32 state)
sub_81D12D8(structPtr); sub_81D12D8(structPtr);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 3: case 3:
sub_81D10D0(structPtr); PrintRibbonsMonListIndex(structPtr);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 4: case 4:
sub_81D0E84(structPtr); PrintCurrentMonRibbonCount(structPtr);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 5: case 5:
if (!IsDma3ManagerBusyWithBgCopy()) if (!IsDma3ManagerBusyWithBgCopy())
@ -654,9 +664,9 @@ u32 sub_81D0C84(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -678,9 +688,9 @@ u32 sub_81D0D2C(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -708,9 +718,9 @@ u32 sub_81D0D8C(s32 state)
return LT_FINISH; 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) switch (state)
{ {
case 0: case 0:
@ -720,7 +730,7 @@ u32 sub_81D0E00(s32 state)
case 1: case 1:
if (!sub_81D1524(structPtr)) if (!sub_81D1524(structPtr))
{ {
sub_81D0E84(structPtr); PrintCurrentMonRibbonCount(structPtr);
PrintHelpBarText(HELPBAR_RIBBONS_LIST); PrintHelpBarText(HELPBAR_RIBBONS_LIST);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
} }
@ -732,7 +742,7 @@ u32 sub_81D0E00(s32 state)
return LT_FINISH; return LT_FINISH;
} }
static const struct WindowTemplate gUnknown_08624BB8 = static const struct WindowTemplate sRibbonCountWindowTemplate =
{ {
.bg = 2, .bg = 2,
.tilemapLeft = 12, .tilemapLeft = 12,
@ -743,14 +753,14 @@ static const struct WindowTemplate gUnknown_08624BB8 =
.baseBlock = 0x14, .baseBlock = 0x14,
}; };
void sub_81D0E60(struct PokenavSub14 *structPtr) void AddRibbonCountWindow(struct PokenavSub14 *structPtr)
{ {
structPtr->field_A = AddWindow(&gUnknown_08624BB8); structPtr->ribbonCountWindowId = AddWindow(&sRibbonCountWindowTemplate);
PutWindowTilemap(structPtr->field_A); PutWindowTilemap(structPtr->ribbonCountWindowId);
sub_81D0E84(structPtr); 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}; 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_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_RibbonsF700); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_RibbonsF700);
FillWindowPixelBuffer(structPtr->field_A, PIXEL_FILL(4)); FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4));
AddTextPrinterParameterized3(structPtr->field_A, 1, 0, 1, color, -1, gStringVar4); AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, 1, 0, 1, color, -1, gStringVar4);
CopyWindowToVram(structPtr->field_A, 2); CopyWindowToVram(structPtr->ribbonCountWindowId, 2);
} }
void sub_81D0EFC(struct PokenavSub14 *structPtr) void sub_81D0EFC(struct PokenavSub14 *structPtr)
@ -769,11 +779,11 @@ void sub_81D0EFC(struct PokenavSub14 *structPtr)
u32 ribbonId = sub_81D0954(); u32 ribbonId = sub_81D0954();
u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY}; 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) if (ribbonId < 25)
{ {
for (i = 0; i < 2; i++) 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 else
{ {
@ -783,13 +793,13 @@ void sub_81D0EFC(struct PokenavSub14 *structPtr)
ribbonId--; ribbonId--;
for (i = 0; i < 2; i++) 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, .bg = 2,
.tilemapLeft = 14, .tilemapLeft = 14,
@ -800,23 +810,23 @@ static const struct WindowTemplate gUnknown_08624BC4 =
.baseBlock = 0x54, .baseBlock = 0x54,
}; };
void sub_81D0FCC(struct PokenavSub14 *structPtr) void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *structPtr)
{ {
structPtr->field_8 = AddWindow(&gUnknown_08624BC4); structPtr->nameWindowId = AddWindow(&sRibbonSummaryMonNameWindowTemplate);
PutWindowTilemap(structPtr->field_8); PutWindowTilemap(structPtr->nameWindowId);
sub_81D0FF0(structPtr); PrintRibbbonsSummaryMonInfo(structPtr);
} }
static const u8 sMaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}"); 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 sFemaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GREY}{WHITE}{LIGHT_GREY}");
static const u8 sGenderlessIconString[] = _("{UNK_SPACER}"); static const u8 sGenderlessIconString[] = _("{UNK_SPACER}");
void sub_81D0FF0(struct PokenavSub14 *structPtr) void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr)
{ {
const u8 *genderTxt; const u8 *genderTxt;
u8 *txtPtr; u8 *txtPtr;
u8 level, gender; u8 level, gender;
u16 windowId = structPtr->field_8; u16 windowId = structPtr->nameWindowId;
FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
GetCurrMonInfo1(gStringVar3, &level, &gender); GetCurrMonInfo1(gStringVar3, &level, &gender);
@ -843,7 +853,7 @@ void sub_81D0FF0(struct PokenavSub14 *structPtr)
CopyWindowToVram(windowId, 2); CopyWindowToVram(windowId, 2);
} }
static const struct WindowTemplate gUnknown_08624BE8[] = static const struct WindowTemplate sRibbonMonListIndexWindowTemplate[] =
{ {
{ {
.bg = 2, .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); structPtr->listIdxWindowId = AddWindow(sRibbonMonListIndexWindowTemplate);
FillWindowPixelBuffer(structPtr->field_C, PIXEL_FILL(1)); FillWindowPixelBuffer(structPtr->listIdxWindowId, PIXEL_FILL(1));
PutWindowTilemap(structPtr->field_C); PutWindowTilemap(structPtr->listIdxWindowId);
sub_81D10D0(structPtr); PrintRibbonsMonListIndex(structPtr);
} }
void sub_81D10D0(struct PokenavSub14 *structPtr) void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr)
{ {
s32 x; s32 x;
u8 *txtPtr; u8 *txtPtr;
u32 id = sub_81D06C4() + 1; u32 id = GetRibbonsSummaryCurrentIndex() + 1;
u32 count = sub_81D06D4(); u32 count = GetRibbonsSummaryMonListCount();
txtPtr = ConvertIntToDecimalStringN(gStringVar1, id, STR_CONV_MODE_RIGHT_ALIGN, 3); txtPtr = ConvertIntToDecimalStringN(gStringVar1, id, STR_CONV_MODE_RIGHT_ALIGN, 3);
*(txtPtr++) = CHAR_SLASH; *(txtPtr++) = CHAR_SLASH;
ConvertIntToDecimalStringN(txtPtr, count, STR_CONV_MODE_RIGHT_ALIGN, 3); ConvertIntToDecimalStringN(txtPtr, count, STR_CONV_MODE_RIGHT_ALIGN, 3);
x = GetStringCenterAlignXOffset(1, gStringVar1, 56); x = GetStringCenterAlignXOffset(1, gStringVar1, 56);
AddTextPrinterParameterized(structPtr->field_C, 1, gStringVar1, x, 1, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(structPtr->listIdxWindowId, 1, gStringVar1, x, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(structPtr->field_C, 2); CopyWindowToVram(structPtr->listIdxWindowId, 2);
} }
void sub_81D1148(struct PokenavSub14 *structPtr) void ResetSpritesAndDrawRibbonsMonFrontPic(struct PokenavSub14 *structPtr)
{ {
u16 species; u16 species;
u32 personality, otId; u32 personality, otId;
GetCurrMonInfo2(&species, &personality, &otId); GetCurrMonInfo2(&species, &personality, &otId);
ResetAllPicSprites(); ResetAllPicSprites();
structPtr->field_10 = sub_81D1184(40, 104); structPtr->monSpriteId = DrawRibbonsMonFrontPic(40, 104);
sub_81C7990(15, 0); 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; u16 species, spriteId;
u32 personality, otId; u32 personality, otId;
@ -909,19 +919,19 @@ u16 sub_81D1184(s32 unused0, s32 unused1)
void sub_81D11D8(struct PokenavSub14 *structPtr) 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) void sub_81D11FC(struct PokenavSub14 *structPtr)
{ {
FreeAndDestroyMonPicSprite(structPtr->field_10); FreeAndDestroyMonPicSprite(structPtr->monSpriteId);
structPtr->field_10 = sub_81D1184(-32, 104); structPtr->monSpriteId = DrawRibbonsMonFrontPic(-32, 104);
sub_81D1258(&gSprites[structPtr->field_10], -32, 40, 6); sub_81D1258(&gSprites[structPtr->monSpriteId], -32, 40, 6);
} }
bool32 sub_81D1234(struct PokenavSub14 *structPtr) 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) void sub_81D1258(struct Sprite *sprite, s32 arg1, s32 arg2, s32 arg3)

View File

@ -486,7 +486,7 @@ static void LoadUsePokeblockMenu(void)
{ {
case 0: case 0:
sMenu->curMonSpriteId = 0xFF; sMenu->curMonSpriteId = 0xFF;
sub_81D1ED4(&sMenu->graph); InitConditionGraphData(&sMenu->graph);
sInfo->mainState++; sInfo->mainState++;
break; break;
case 1: case 1:
@ -536,12 +536,12 @@ static void LoadUsePokeblockMenu(void)
sInfo->mainState++; sInfo->mainState++;
break; break;
case 11: case 11:
sub_81D2754(sMenu->graph.unk0[0], sMenu->graph.unk14[0]); sub_81D2754(sMenu->graph.stat[0], sMenu->graph.unk14[0]);
sub_81D20AC(&sMenu->graph); InitConditionGraphState(&sMenu->graph);
sInfo->mainState++; sInfo->mainState++;
break; break;
case 12: case 12:
if (!sub_81D20BC(&sMenu->graph)) if (!SetupConditionGraphScanlineParams(&sMenu->graph))
{ {
sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[0], sMenu->graph.unk14[0]); sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[0], sMenu->graph.unk14[0]);
sInfo->mainState++; sInfo->mainState++;
@ -1368,7 +1368,7 @@ static bool8 LoadUsePokeblockMenuGfx(void)
LoadBgTilemap(2, sMenu->tilemapBuffer, 1280, 0); LoadBgTilemap(2, sMenu->tilemapBuffer, 1280, 0);
LoadPalette(gConditionGraphData_Pal, 48, 32); LoadPalette(gConditionGraphData_Pal, 48, 32);
LoadPalette(gConditionText_Pal, 240, 32); LoadPalette(gConditionText_Pal, 240, 32);
sub_81D21DC(2); SetConditionGraphIOWindows(2);
break; break;
default: default:
sMenu->info.helperState = 0; sMenu->info.helperState = 0;