Merge pull request #1229 from ghoulslash/document

start pokenav documentation
This commit is contained in:
GriffinR 2020-10-11 11:59:40 -04:00 committed by GitHub
commit 17a77c9018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 2072 additions and 1996 deletions

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
$(GFX) $< $@ -num_tiles 53
$(PKNAVGFXDIR)/outline.4bpp: %.4bpp: %.png
$(PKNAVGFXDIR)/device_outline.4bpp: %.4bpp: %.png
$(GFX) $< $@ -num_tiles 53
$(PKNAVGFXDIR)/ui_matchcall.4bpp: %.4bpp: %.png

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3976,7 +3976,7 @@ static void StopPokemonAnimations(void) // A subtle effect, this function stops
static void CreateMonMarkingsSprite(struct Pokemon *mon)
{
struct Sprite *sprite = sub_811FF94(TAG_MON_MARKINGS, TAG_MON_MARKINGS, sSummaryMarkingsPalette);
struct Sprite *sprite = CreateMonMarkingsSpriteWithPal(TAG_MON_MARKINGS, TAG_MON_MARKINGS, sSummaryMarkingsPalette);
sMonSummaryScreen->markingsSprite = sprite;
if (sprite != NULL)

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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