Finish pokenav conditions doc

This commit is contained in:
GriffinR 2021-11-11 16:50:36 -05:00
parent 7efdc0902b
commit f5152094a9
17 changed files with 604 additions and 572 deletions

View File

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 257 B

View File

@ -26,6 +26,11 @@ enum {
TAG_CONDITION_MARKINGS_MENU_2, // Used implicitly by CreateMonMarkingsMenuSprites TAG_CONDITION_MARKINGS_MENU_2, // Used implicitly by CreateMonMarkingsMenuSprites
}; };
enum {
CONDITION_ICON_SELECTED,
CONDITION_ICON_UNSELECTED,
};
#define MAX_CONDITION_SPARKLES 10 #define MAX_CONDITION_SPARKLES 10
// The number of extra sparkles shown on a Pokémon's condition screen. // The number of extra sparkles shown on a Pokémon's condition screen.

View File

@ -65,8 +65,7 @@ enum
POKENAV_MODE_FORCE_CALL_EXIT, // Pokenav tutorial after calling Mr. Stone POKENAV_MODE_FORCE_CALL_EXIT, // Pokenav tutorial after calling Mr. Stone
}; };
// TODO - refine these names enum
enum Substructures
{ {
POKENAV_SUBSTRUCT_MAIN_MENU, POKENAV_SUBSTRUCT_MAIN_MENU,
POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER, POKENAV_SUBSTRUCT_MAIN_MENU_HANDLER,
@ -76,11 +75,11 @@ enum Substructures
POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, POKENAV_SUBSTRUCT_MATCH_CALL_MAIN,
POKENAV_SUBSTRUCT_MATCH_CALL_OPEN, POKENAV_SUBSTRUCT_MATCH_CALL_OPEN,
POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS,
POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX,
POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, POKENAV_SUBSTRUCT_RIBBONS_MON_LIST,
POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, POKENAV_SUBSTRUCT_RIBBONS_MON_MENU,
POKENAV_SUBSTRUCT_CONDITION_GRAPH, POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU,
POKENAV_SUBSTRUCT_MON_MARK_MENU, POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX,
POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST,
POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU,
POKENAV_SUBSTRUCT_15, //unused POKENAV_SUBSTRUCT_15, //unused
@ -113,21 +112,21 @@ enum
#define POKENAV_MENU_IDS_START 100000 #define POKENAV_MENU_IDS_START 100000
enum enum
{ {
POKENAV_MAIN_MENU = POKENAV_MENU_IDS_START, POKENAV_MAIN_MENU = POKENAV_MENU_IDS_START, // The main menu where the player selects Hoenn Map/Condition/Match Call/Ribbons
POKENAV_MAIN_MENU_CURSOR_ON_MAP, POKENAV_MAIN_MENU_CURSOR_ON_MAP,
POKENAV_CONDITION_MENU, POKENAV_CONDITION_MENU, // The first Condition screen where the player selects Party or Search
POKENAV_CONDITION_SEARCH_MENU, POKENAV_CONDITION_SEARCH_MENU, // The Condition search menu where the player selects a search parameter
POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL, POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL,
POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS, POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS,
POKENAV_REGION_MAP, POKENAV_REGION_MAP,
POKENAV_CONDITION_PARTY, POKENAV_CONDITION_GRAPH_PARTY, // The Condition graph screen when Party has been selected
POKENAV_CONDITION_SEARCH_RESULTS, POKENAV_CONDITION_SEARCH_RESULTS, // The list of results from a Condition search
POKENAV_CONDITION_GRAPH_FROM_SEARCH, // opening condition graph from search list POKENAV_CONDITION_GRAPH_SEARCH, // The Condition graph screen when a search result has been selected
POKENAV_RETURN_CONDITION_SEARCH, //return to search list from condition graph POKENAV_RETURN_CONDITION_SEARCH, // Exited the graph screen back to the list of Condition search results
POKENAV_MATCH_CALL, POKENAV_MATCH_CALL,
POKENAV_RIBBONS_MON_LIST, POKENAV_RIBBONS_MON_LIST, // The list of Pokémon with ribbons
POKENAV_RIBBONS_SUMMARY_SCREEN, POKENAV_RIBBONS_SUMMARY_SCREEN, // The ribbon summary screen shown when a Pokémon has been selected
POKENAV_RIBBONS_RETURN_TO_MON_LIST, POKENAV_RIBBONS_RETURN_TO_MON_LIST, // Exited the summary screen back to the ribbon list
}; };
enum enum
@ -245,15 +244,15 @@ enum RegionMapFuncIds
POKENAV_MENU_FUNC_OPEN_FEATURE, POKENAV_MENU_FUNC_OPEN_FEATURE,
}; };
enum PartyConditionFuncIds enum
{ {
PARTY_CONDITION_FUNC_NONE, CONDITION_FUNC_NONE,
PARTY_CONDITION_FUNC_SLIDE_MON_IN, CONDITION_FUNC_SLIDE_MON_IN,
PARTY_CONDITION_FUNC_RETURN, CONDITION_FUNC_RETURN,
PARTY_CONDITION_FUNC_NO_TRANSITION, CONDITION_FUNC_NO_TRANSITION,
PARTY_CONDITION_FUNC_SLIDE_MON_OUT, CONDITION_FUNC_SLIDE_MON_OUT,
PARTY_CONDITION_FUNC_ADD_MARKINGS, CONDITION_FUNC_ADD_MARKINGS,
PARTY_CONDITION_FUNC_CLOSE_MARKINGS, CONDITION_FUNC_CLOSE_MARKINGS,
}; };
enum enum
@ -264,6 +263,13 @@ enum
NUM_CONDITION_MONS NUM_CONDITION_MONS
}; };
enum
{
CONDITION_LOAD_MON_INFO,
CONDITION_LOAD_GRAPH,
CONDITION_LOAD_MON_PIC,
};
#define POKENAV_MENU_FUNC_EXIT -1 #define POKENAV_MENU_FUNC_EXIT -1
enum enum
@ -431,17 +437,17 @@ void FreeRegionMapSubstruct1(void);
void FreeRegionMapSubstruct2(void); void FreeRegionMapSubstruct2(void);
// pokenav_conditions_1.c // pokenav_conditions_1.c
u32 PokenavCallback_Init_PartyCondition(void); u32 PokenavCallback_Init_ConditionGraph_Party(void);
u32 PokenavCallback_Init_ConditionGraphFromSearch(void); u32 PokenavCallback_Init_ConditionGraph_Search(void);
u32 GetPartyConditionCallback(void); u32 GetConditionGraphMenuCallback(void);
void FreePartyConditionSubstruct1(void); void FreeConditionGraphMenuSubstruct1(void);
bool32 LoadPartyConditionMenuGfx(void); bool32 LoadConditionGraphMenuGfx(void);
bool32 IsConditionMenuSearchMode(void); bool32 IsConditionMenuSearchMode(void);
struct ConditionGraph *GetConditionGraphPtr(void); struct ConditionGraph *GetConditionGraphPtr(void);
u16 GetConditionGraphCurrentMonIndex(void); u16 GetConditionGraphCurrentListIndex(void);
u16 GetMonListCount(void); u16 GetMonListCount(void);
u8 GetNumConditionMonSparkles(void); u8 GetNumConditionMonSparkles(void);
bool32 SetConditionGraphData(u8 mode); bool32 LoadNextConditionMenuMonData(u8 mode);
u8 TryGetMonMarkId(void); u8 TryGetMonMarkId(void);
u8 *GetConditionMonNameText(u8 id); u8 *GetConditionMonNameText(u8 id);
u8 *GetConditionMonLocationText(u8 id); u8 *GetConditionMonLocationText(u8 id);
@ -450,10 +456,10 @@ void *GetConditionMonPicGfx(u8 id);
void *GetConditionMonPal(u8 id); void *GetConditionMonPal(u8 id);
// pokenav_conditions_2.c // pokenav_conditions_2.c
bool32 OpenPartyConditionMenu(void); bool32 OpenConditionGraphMenu(void);
void CreatePartyConditionLoopedTask(s32); void CreateConditionGraphMenuLoopedTask(s32);
u32 IsPartyConditionLoopedTaskActive(void); u32 IsConditionGraphMenuLoopedTaskActive(void);
void FreePartyConditionSubstruct2(void); void FreeConditionGraphMenuSubstruct2(void);
u8 GetMonMarkingsData(void); u8 GetMonMarkingsData(void);
// pokenav_conditions_3.c // pokenav_conditions_3.c

View File

@ -2974,8 +2974,8 @@ extern const u8 gText_FindToughPokemon[];
extern const u8 gText_ReturnToConditionMenu[]; extern const u8 gText_ReturnToConditionMenu[];
extern const u8 gText_NoRibbonWinners[]; extern const u8 gText_NoRibbonWinners[];
// Pokenav Ribbons // Pokenav
extern const u8 gText_NumberF700[]; extern const u8 gText_NumberIndex[];
extern const u8 gText_RibbonsF700[]; extern const u8 gText_RibbonsF700[];
// use_pokeblock // use_pokeblock

View File

@ -318,7 +318,7 @@ void MailboxMenu_Free(void)
// filled with the graph color. // filled with the graph color.
//--------------------------------------- //---------------------------------------
#define UNK_VAL(n, s)(((n) >> (s)) + (((n) >> ((s) - 1)) & 1)) #define SHIFT_RIGHT_ADJUSTED(n, s)(((n) >> (s)) + (((n) >> ((s) - 1)) & 1))
void ConditionGraph_Init(struct ConditionGraph *graph) void ConditionGraph_Init(struct ConditionGraph *graph)
{ {
@ -360,7 +360,7 @@ void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords
increment = ((new[i].x - old[i].x) << 8) / CONDITION_GRAPH_UPDATE_STEPS; increment = ((new[i].x - old[i].x) << 8) / CONDITION_GRAPH_UPDATE_STEPS;
for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++) for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++)
{ {
graph->newPositions[j][i].x = UNK_VAL(coord, 8); graph->newPositions[j][i].x = SHIFT_RIGHT_ADJUSTED(coord, 8);
coord += increment; coord += increment;
} }
graph->newPositions[j][i].x = new[i].x; graph->newPositions[j][i].x = new[i].x;
@ -369,7 +369,7 @@ void ConditionGraph_SetNewPositions(struct ConditionGraph *graph, struct UCoords
increment = ((new[i].y - old[i].y) << 8) / CONDITION_GRAPH_UPDATE_STEPS; increment = ((new[i].y - old[i].y) << 8) / CONDITION_GRAPH_UPDATE_STEPS;
for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++) for (j = 0; j < CONDITION_GRAPH_UPDATE_STEPS - 1; j++)
{ {
graph->newPositions[j][i].y = UNK_VAL(coord, 8); graph->newPositions[j][i].y = SHIFT_RIGHT_ADJUSTED(coord, 8);
coord += increment; coord += increment;
} }
graph->newPositions[j][i].y = new[i].y; graph->newPositions[j][i].y = new[i].y;
@ -500,7 +500,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline,
scanline += (top - CONDITION_GRAPH_TOP_Y) * 2; scanline += (top - CONDITION_GRAPH_TOP_Y) * 2;
for (i = 0; i < height; i++) for (i = 0; i < height; i++)
{ {
scanline[dir] = UNK_VAL(x, 10) + dir; scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir;
x += xIncrement; x += xIncrement;
scanline += 2; scanline += 2;
} }
@ -511,7 +511,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline,
{ {
overflowScanline += (top - CONDITION_GRAPH_TOP_Y) * 2; overflowScanline += (top - CONDITION_GRAPH_TOP_Y) * 2;
// Less readable than the other loops, but it has to be written this way to match. // Less readable than the other loops, but it has to be written this way to match.
for (i = 0; i < height; overflowScanline[dir] = UNK_VAL(x, 10) + dir, x += xIncrement, overflowScanline += 2, i++) for (i = 0; i < height; overflowScanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir, x += xIncrement, overflowScanline += 2, i++)
{ {
if (x >= (CONDITION_GRAPH_CENTER_X << 10)) if (x >= (CONDITION_GRAPH_CENTER_X << 10))
break; break;
@ -521,7 +521,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline,
scanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2; scanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2;
for (; i < height; i++) for (; i < height; i++)
{ {
scanline[dir] = UNK_VAL(x, 10) + dir; scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir;
x += xIncrement; x += xIncrement;
scanline += 2; scanline += 2;
} }
@ -533,7 +533,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline,
scanline += (top - CONDITION_GRAPH_TOP_Y) * 2; scanline += (top - CONDITION_GRAPH_TOP_Y) * 2;
for (i = 0; i < height; i++) for (i = 0; i < height; i++)
{ {
scanline[dir] = UNK_VAL(x, 10) + dir; scanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir;
if (x < (CONDITION_GRAPH_CENTER_X << 10)) if (x < (CONDITION_GRAPH_CENTER_X << 10))
{ {
scanline[dir] = CONDITION_GRAPH_CENTER_X; scanline[dir] = CONDITION_GRAPH_CENTER_X;
@ -547,7 +547,7 @@ static void ConditionGraph_CalcLine(struct ConditionGraph *graph, u16 *scanline,
overflowScanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2; overflowScanline += (graph->bottom - CONDITION_GRAPH_TOP_Y) * 2;
for (; i < height; i++) for (; i < height; i++)
{ {
overflowScanline[dir] = UNK_VAL(x, 10) + dir; overflowScanline[dir] = SHIFT_RIGHT_ADJUSTED(x, 10) + dir;
x += xIncrement; x += xIncrement;
overflowScanline += 2; overflowScanline += 2;
} }
@ -1167,8 +1167,8 @@ static const union AnimCmd sAnim_ConditionSelectionIcon_Unselected[] =
static const union AnimCmd *const sAnims_ConditionSelectionIcon[] = static const union AnimCmd *const sAnims_ConditionSelectionIcon[] =
{ {
sAnim_ConditionSelectionIcon_Selected, [CONDITION_ICON_SELECTED] = sAnim_ConditionSelectionIcon_Selected,
sAnim_ConditionSelectionIcon_Unselected [CONDITION_ICON_UNSELECTED] = sAnim_ConditionSelectionIcon_Unselected
}; };
// Just loads the generic data, up to the caller to load the actual sheet/pal for the specific mon // Just loads the generic data, up to the caller to load the actual sheet/pal for the specific mon

View File

@ -122,15 +122,15 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
.free1 = FreeRegionMapSubstruct1, .free1 = FreeRegionMapSubstruct1,
.free2 = FreeRegionMapSubstruct2, .free2 = FreeRegionMapSubstruct2,
}, },
[POKENAV_CONDITION_PARTY - POKENAV_MENU_IDS_START] = [POKENAV_CONDITION_GRAPH_PARTY - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_PartyCondition, .init = PokenavCallback_Init_ConditionGraph_Party,
.callback = GetPartyConditionCallback, .callback = GetConditionGraphMenuCallback,
.open = OpenPartyConditionMenu, .open = OpenConditionGraphMenu,
.createLoopTask = CreatePartyConditionLoopedTask, .createLoopTask = CreateConditionGraphMenuLoopedTask,
.isLoopTaskActive = IsPartyConditionLoopedTaskActive, .isLoopTaskActive = IsConditionGraphMenuLoopedTaskActive,
.free1 = FreePartyConditionSubstruct1, .free1 = FreeConditionGraphMenuSubstruct1,
.free2 = FreePartyConditionSubstruct2, .free2 = FreeConditionGraphMenuSubstruct2,
}, },
[POKENAV_CONDITION_SEARCH_RESULTS - POKENAV_MENU_IDS_START] = [POKENAV_CONDITION_SEARCH_RESULTS - POKENAV_MENU_IDS_START] =
{ {
@ -142,15 +142,15 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
.free1 = FreeSearchResultSubstruct1, .free1 = FreeSearchResultSubstruct1,
.free2 = FreeSearchResultSubstruct2, .free2 = FreeSearchResultSubstruct2,
}, },
[POKENAV_CONDITION_GRAPH_FROM_SEARCH - POKENAV_MENU_IDS_START] = [POKENAV_CONDITION_GRAPH_SEARCH - POKENAV_MENU_IDS_START] =
{ {
.init = PokenavCallback_Init_ConditionGraphFromSearch, .init = PokenavCallback_Init_ConditionGraph_Search,
.callback = GetPartyConditionCallback, .callback = GetConditionGraphMenuCallback,
.open = OpenPartyConditionMenu, .open = OpenConditionGraphMenu,
.createLoopTask = CreatePartyConditionLoopedTask, .createLoopTask = CreateConditionGraphMenuLoopedTask,
.isLoopTaskActive = IsPartyConditionLoopedTaskActive, .isLoopTaskActive = IsConditionGraphMenuLoopedTaskActive,
.free1 = FreePartyConditionSubstruct1, .free1 = FreeConditionGraphMenuSubstruct1,
.free2 = FreePartyConditionSubstruct2, .free2 = FreeConditionGraphMenuSubstruct2,
}, },
[POKENAV_RETURN_CONDITION_SEARCH - POKENAV_MENU_IDS_START] = [POKENAV_RETURN_CONDITION_SEARCH - POKENAV_MENU_IDS_START] =
{ {

View File

@ -13,102 +13,105 @@
#include "text.h" #include "text.h"
#include "constants/songs.h" #include "constants/songs.h"
struct PokenavSub11 struct Pokenav_ConditionMenu
{ {
u32 monPal[NUM_CONDITION_MONS][0x20]; u32 monPal[NUM_CONDITION_MONS][0x20];
u8 fill[0x180]; u8 fill[0x180];
u32 monPicGfx[NUM_CONDITION_MONS][MON_PIC_SIZE]; u32 monPicGfx[NUM_CONDITION_MONS][MON_PIC_SIZE];
u8 searchMode; bool8 inSearchMode;
s16 monIndex; s16 toLoadListIndex;
u32 (*callback)(struct PokenavSub11 *); u32 (*callback)(struct Pokenav_ConditionMenu *);
u8 fill2[0x6320 - 0x6308]; u8 fill2[0x18];
u8 locationText[NUM_CONDITION_MONS][24]; u8 locationText[NUM_CONDITION_MONS][24];
u8 nameText[NUM_CONDITION_MONS][64]; u8 nameText[NUM_CONDITION_MONS][64];
struct ConditionGraph graph; struct ConditionGraph graph;
u8 numSparkles[NUM_CONDITION_MONS]; u8 numSparkles[NUM_CONDITION_MONS];
u8 monMarks[NUM_CONDITION_MONS]; u8 monMarks[NUM_CONDITION_MONS];
s8 mark; s8 loadId;
s8 unk6787; s8 nextLoadIdDown;
s8 unk6788; s8 nextLoadIdUp;
s8 unk6789; s8 toLoadId;
u8 state; u8 state;
}; };
static void InitPartyConditionListParameters(void); static void InitPartyConditionListParameters(void);
static void InitSearchResultsConditionList(void); static void InitSearchResultsConditionList(void);
static u32 HandlePartyConditionInput(struct PokenavSub11 *); static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *);
static u32 GetConditionReturnCallback(struct PokenavSub11 *); static u32 GetConditionReturnCallback(struct Pokenav_ConditionMenu *);
static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *); static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *);
static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *); static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *);
static u8 SwitchConditionSummaryIndex(bool8); static u8 SwitchConditionSummaryIndex(bool8);
static void CopyMonNameGenderLocation(s16, u8); static void CopyMonNameGenderLocation(s16, u8);
static void GetMonConditionGraphData(s16, u8); static void GetMonConditionGraphData(s16, u8);
static void ConditionGraphDrawMonPic(s16, u8); static void ConditionGraphDrawMonPic(s16, u8);
bool32 PokenavCallback_Init_PartyCondition(void) bool32 PokenavCallback_Init_ConditionGraph_Party(void)
{ {
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11)); struct Pokenav_ConditionMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, sizeof(struct Pokenav_ConditionMenu));
if (structPtr == NULL) if (menu == NULL)
return FALSE; return FALSE;
ConditionGraph_Init(&structPtr->graph); ConditionGraph_Init(&menu->graph);
InitPartyConditionListParameters(); InitPartyConditionListParameters();
gKeyRepeatStartDelay = 20; gKeyRepeatStartDelay = 20;
structPtr->callback = HandlePartyConditionInput; menu->callback = HandleConditionMenuInput;
return TRUE; return TRUE;
} }
bool32 PokenavCallback_Init_ConditionGraphFromSearch(void) bool32 PokenavCallback_Init_ConditionGraph_Search(void)
{ {
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11)); struct Pokenav_ConditionMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, sizeof(struct Pokenav_ConditionMenu));
if (structPtr == NULL) if (menu == NULL)
return FALSE; return FALSE;
ConditionGraph_Init(&structPtr->graph); ConditionGraph_Init(&menu->graph);
InitSearchResultsConditionList(); InitSearchResultsConditionList();
gKeyRepeatStartDelay = 20; gKeyRepeatStartDelay = 20;
structPtr->callback = HandlePartyConditionInput; menu->callback = HandleConditionMenuInput;
return TRUE; return TRUE;
} }
u32 GetPartyConditionCallback(void) u32 GetConditionGraphMenuCallback(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->callback(structPtr); return menu->callback(menu);
} }
static u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr) static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *menu)
{ {
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u32 ret = ConditionGraphHandleDpadInput(structPtr); u32 ret = ConditionGraphHandleDpadInput(menu);
if (ret == PARTY_CONDITION_FUNC_NONE) if (ret == CONDITION_FUNC_NONE)
{ {
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
structPtr->callback = GetConditionReturnCallback; menu->callback = GetConditionReturnCallback;
ret = PARTY_CONDITION_FUNC_RETURN; ret = CONDITION_FUNC_RETURN;
} }
else if (JOY_NEW(A_BUTTON)) else if (JOY_NEW(A_BUTTON))
{ {
if (structPtr->searchMode == 0) if (!menu->inSearchMode)
{ {
// In Party mode, pressing A only applies to the Cancel button
if (monListPtr->currIndex == monListPtr->listCount - 1) if (monListPtr->currIndex == monListPtr->listCount - 1)
{ {
// Cancel
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
structPtr->callback = GetConditionReturnCallback; menu->callback = GetConditionReturnCallback;
ret = PARTY_CONDITION_FUNC_RETURN; ret = CONDITION_FUNC_RETURN;
} }
} }
else else
{ {
// In Search mode pressing A brings up the markings menu
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ret = PARTY_CONDITION_FUNC_ADD_MARKINGS; ret = CONDITION_FUNC_ADD_MARKINGS;
structPtr->callback = ConditionMenu_OpenMarkingsMenu; menu->callback = OpenMarkingsMenu;
} }
} }
} }
@ -116,57 +119,58 @@ static u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr)
return ret; return ret;
} }
static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr) static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *menu)
{ {
struct PokenavSub18 *monListPtr; struct PokenavSub18 *monListPtr;
u8 markings; u8 markings;
u32 ret = PARTY_CONDITION_FUNC_NONE, boxId, monId; u32 ret = CONDITION_FUNC_NONE, boxId, monId;
if (!HandleMonMarkingsMenuInput()) if (!HandleMonMarkingsMenuInput())
{ {
structPtr->monMarks[structPtr->mark] = GetMonMarkingsData(); menu->monMarks[menu->loadId] = GetMonMarkingsData();
monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[monListPtr->currIndex].boxId; boxId = monListPtr->monData[monListPtr->currIndex].boxId;
monId = monListPtr->monData[monListPtr->currIndex].monId; monId = monListPtr->monData[monListPtr->currIndex].monId;
markings = structPtr->monMarks[structPtr->mark]; markings = menu->monMarks[menu->loadId];
if (boxId == TOTAL_BOXES_COUNT) if (boxId == TOTAL_BOXES_COUNT)
SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings); SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings);
else else
SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings); SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings);
structPtr->callback = HandlePartyConditionInput; menu->callback = HandleConditionMenuInput;
ret = PARTY_CONDITION_FUNC_CLOSE_MARKINGS; ret = CONDITION_FUNC_CLOSE_MARKINGS;
} }
return ret; return ret;
} }
static u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr) static u32 GetConditionReturnCallback(struct Pokenav_ConditionMenu *menu)
{ {
if (structPtr->searchMode == 0) if (!menu->inSearchMode)
return POKENAV_CONDITION_MENU; return POKENAV_CONDITION_MENU;
else else
return POKENAV_RETURN_CONDITION_SEARCH; return POKENAV_RETURN_CONDITION_SEARCH;
} }
void FreePartyConditionSubstruct1(void) void FreeConditionGraphMenuSubstruct1(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (structPtr->searchMode == 0) if (!menu->inSearchMode)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST); FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH); FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
} }
static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *menu)
{ {
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u8 ret = 0; u8 ret = CONDITION_FUNC_NONE;
if (JOY_HELD(DPAD_UP)) if (JOY_HELD(DPAD_UP))
{ {
if (structPtr->searchMode == 0 || monListPtr->currIndex != 0) // Prevent input wrapping in search mode
if (!menu->inSearchMode || monListPtr->currIndex != 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ret = SwitchConditionSummaryIndex(TRUE); ret = SwitchConditionSummaryIndex(TRUE);
@ -174,7 +178,8 @@ static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr)
} }
else if (JOY_HELD(DPAD_DOWN)) else if (JOY_HELD(DPAD_DOWN))
{ {
if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1) // Prevent input wrapping in search mode
if (!menu->inSearchMode || monListPtr->currIndex < monListPtr->listCount - 1)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ret = SwitchConditionSummaryIndex(FALSE); ret = SwitchConditionSummaryIndex(FALSE);
@ -186,52 +191,52 @@ static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr)
static u8 SwitchConditionSummaryIndex(u8 moveUp) static u8 SwitchConditionSummaryIndex(u8 moveUp)
{ {
u16 r7; u16 newLoadId;
bool8 wasNotLastMon, isNotLastMon; bool8 wasNotLastMon, isNotLastMon;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
r7 = (moveUp) ? structPtr->unk6788 : structPtr->unk6787; newLoadId = (moveUp) ? menu->nextLoadIdUp : menu->nextLoadIdDown;
ConditionGraph_SetNewPositions(&structPtr->graph, structPtr->graph.savedPositions[structPtr->mark], structPtr->graph.savedPositions[r7]); ConditionGraph_SetNewPositions(&menu->graph, menu->graph.savedPositions[menu->loadId], menu->graph.savedPositions[newLoadId]);
wasNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1)); wasNotLastMon = (monListPtr->currIndex != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1));
if (moveUp) if (moveUp)
{ {
structPtr->unk6788 = structPtr->unk6787; menu->nextLoadIdUp = menu->nextLoadIdDown;
structPtr->unk6787 = structPtr->mark; menu->nextLoadIdDown = menu->loadId;
structPtr->mark = r7; menu->loadId = newLoadId;
structPtr->unk6789 = structPtr->unk6788; menu->toLoadId = menu->nextLoadIdUp;
monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1; monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1;
structPtr->monIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1; menu->toLoadListIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1;
} }
else else
{ {
structPtr->unk6787 = structPtr->unk6788; menu->nextLoadIdDown = menu->nextLoadIdUp;
structPtr->unk6788 = structPtr->mark; menu->nextLoadIdUp = menu->loadId;
structPtr->mark = r7; menu->loadId = newLoadId;
structPtr->unk6789 = structPtr->unk6787; menu->toLoadId = menu->nextLoadIdDown;
monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0; monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
structPtr->monIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0; menu->toLoadListIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
} }
isNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1)); isNotLastMon = (monListPtr->currIndex != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1));
if (!wasNotLastMon) if (!wasNotLastMon)
return PARTY_CONDITION_FUNC_NO_TRANSITION; return CONDITION_FUNC_NO_TRANSITION;
else if (!isNotLastMon) else if (!isNotLastMon)
return PARTY_CONDITION_FUNC_SLIDE_MON_OUT; return CONDITION_FUNC_SLIDE_MON_OUT;
else else
return PARTY_CONDITION_FUNC_SLIDE_MON_IN; return CONDITION_FUNC_SLIDE_MON_IN;
} }
bool32 LoadPartyConditionMenuGfx(void) bool32 LoadConditionGraphMenuGfx(void)
{ {
s32 var; s32 var;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
switch (structPtr->state) switch (menu->state)
{ {
case 0: case 0:
CopyMonNameGenderLocation(monListPtr->currIndex, CONDITION_MON_0); CopyMonNameGenderLocation(monListPtr->currIndex, CONDITION_MON_0);
@ -245,17 +250,17 @@ bool32 LoadPartyConditionMenuGfx(void)
case 3: case 3:
if (monListPtr->listCount == 1) if (monListPtr->listCount == 1)
{ {
structPtr->mark = CONDITION_MON_0; menu->loadId = CONDITION_MON_0;
structPtr->unk6787 = CONDITION_MON_0; menu->nextLoadIdDown = CONDITION_MON_0;
structPtr->unk6788 = CONDITION_MON_0; menu->nextLoadIdUp = CONDITION_MON_0;
structPtr->state = 0; menu->state = 0;
return TRUE; return TRUE;
} }
else else
{ {
structPtr->mark = CONDITION_MON_0; menu->loadId = CONDITION_MON_0;
structPtr->unk6787 = CONDITION_MON_1; menu->nextLoadIdDown = CONDITION_MON_1;
structPtr->unk6788 = CONDITION_MON_2; menu->nextLoadIdUp = CONDITION_MON_2;
} }
break; break;
// These were probably ternaries just like cases 7-9, but couldn't match it any other way. // These were probably ternaries just like cases 7-9, but couldn't match it any other way.
@ -285,28 +290,28 @@ bool32 LoadPartyConditionMenuGfx(void)
break; break;
case 9: case 9:
ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2); ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2);
structPtr->state = 0; menu->state = 0;
return TRUE; return TRUE;
} }
structPtr->state++; menu->state++;
return FALSE; return FALSE;
} }
bool32 SetConditionGraphData(u8 mode) bool32 LoadNextConditionMenuMonData(u8 mode)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
switch (mode) switch (mode)
{ {
case 0: case CONDITION_LOAD_MON_INFO:
CopyMonNameGenderLocation(structPtr->monIndex, structPtr->unk6789); CopyMonNameGenderLocation(menu->toLoadListIndex, menu->toLoadId);
break; break;
case 1: case CONDITION_LOAD_GRAPH:
GetMonConditionGraphData(structPtr->monIndex, structPtr->unk6789); GetMonConditionGraphData(menu->toLoadListIndex, menu->toLoadId);
break; break;
case 2: case CONDITION_LOAD_MON_PIC:
ConditionGraphDrawMonPic(structPtr->monIndex, structPtr->unk6789); ConditionGraphDrawMonPic(menu->toLoadListIndex, menu->toLoadId);
return TRUE; return TRUE;
} }
@ -419,42 +424,42 @@ static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3)
static void CopyMonNameGenderLocation(s16 listId, u8 loadId) static void CopyMonNameGenderLocation(s16 listId, u8 loadId)
{ {
u16 boxId, i; u16 boxId, i;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1))
{ {
CopyConditionMonNameGender(structPtr->nameText[loadId], listId, FALSE); CopyConditionMonNameGender(menu->nameText[loadId], listId, FALSE);
boxId = monListPtr->monData[listId].boxId; boxId = monListPtr->monData[listId].boxId;
structPtr->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN; menu->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN;
structPtr->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; menu->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
structPtr->locationText[loadId][2] = TEXT_COLOR_BLUE; menu->locationText[loadId][2] = TEXT_COLOR_BLUE;
structPtr->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT; menu->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT;
structPtr->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE; menu->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE;
if (boxId == TOTAL_BOXES_COUNT) if (boxId == TOTAL_BOXES_COUNT)
CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH); CopyStringLeftAlignedToConditionData(&menu->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH);
else else
CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH); CopyStringLeftAlignedToConditionData(&menu->locationText[loadId][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH);
} }
else else
{ {
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
structPtr->nameText[loadId][i] = CHAR_SPACE; menu->nameText[loadId][i] = CHAR_SPACE;
structPtr->nameText[loadId][i] = EOS; menu->nameText[loadId][i] = EOS;
for (i = 0; i < BOX_NAME_LENGTH; i++) for (i = 0; i < BOX_NAME_LENGTH; i++)
structPtr->locationText[loadId][i] = CHAR_SPACE; menu->locationText[loadId][i] = CHAR_SPACE;
structPtr->locationText[loadId][i] = EOS; menu->locationText[loadId][i] = EOS;
} }
} }
static void InitPartyConditionListParameters(void) static void InitPartyConditionListParameters(void)
{ {
u16 i, count; u16 i, count;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavSub18 *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); struct PokenavSub18 *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
structPtr->searchMode = 0; menu->inSearchMode = FALSE;
for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++) for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++)
{ {
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
@ -471,42 +476,43 @@ static void InitPartyConditionListParameters(void)
monListPtr->monData[count].data = 0; monListPtr->monData[count].data = 0;
monListPtr->currIndex = 0; monListPtr->currIndex = 0;
monListPtr->listCount = count + 1; monListPtr->listCount = count + 1;
structPtr->state = 0; menu->state = 0;
} }
static void InitSearchResultsConditionList(void) static void InitSearchResultsConditionList(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
structPtr->searchMode = 1; menu->inSearchMode = TRUE;
structPtr->state = 0; menu->state = 0;
} }
static void GetMonConditionGraphData(s16 listId, u8 loadId) static void GetMonConditionGraphData(s16 listId, u8 loadId)
{ {
u16 boxId, monId, i; u16 boxId, monId, i;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1))
{ {
boxId = monListPtr->monData[listId].boxId; boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[listId].monId; monId = monListPtr->monData[listId].monId;
structPtr->graph.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); menu->graph.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
structPtr->graph.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); menu->graph.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
structPtr->graph.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); menu->graph.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
structPtr->graph.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); menu->graph.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
structPtr->graph.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); menu->graph.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
structPtr->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL)); menu->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL));
structPtr->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL); menu->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
ConditionGraph_CalcPositions(structPtr->graph.conditions[loadId], structPtr->graph.savedPositions[loadId]); ConditionGraph_CalcPositions(menu->graph.conditions[loadId], menu->graph.savedPositions[loadId]);
} }
else else
{ {
// Set empty graph point
for (i = 0; i < CONDITION_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
{ {
structPtr->graph.conditions[loadId][i] = 0; menu->graph.conditions[loadId][i] = 0;
structPtr->graph.savedPositions[loadId][i].x = CONDITION_GRAPH_CENTER_X; menu->graph.savedPositions[loadId][i].x = CONDITION_GRAPH_CENTER_X;
structPtr->graph.savedPositions[loadId][i].y = CONDITION_GRAPH_CENTER_Y; menu->graph.savedPositions[loadId][i].y = CONDITION_GRAPH_CENTER_Y;
} }
} }
} }
@ -515,10 +521,10 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId)
{ {
u16 boxId, monId, species; u16 boxId, monId, species;
u32 personality, tid; u32 personality, tid;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (listId == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) if (listId == (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1))
return; return;
boxId = monListPtr->monData[listId].boxId; boxId = monListPtr->monData[listId].boxId;
@ -526,8 +532,8 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId)
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL);
tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL);
personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL);
LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[loadId], species, personality, TRUE); LoadSpecialPokePic(&gMonFrontPicTable[species], menu->monPicGfx[loadId], species, personality, TRUE);
LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[loadId]); LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), menu->monPal[loadId]);
} }
u16 GetMonListCount(void) u16 GetMonListCount(void)
@ -536,7 +542,7 @@ u16 GetMonListCount(void)
return monListPtr->listCount; return monListPtr->listCount;
} }
u16 GetConditionGraphCurrentMonIndex(void) u16 GetConditionGraphCurrentListIndex(void)
{ {
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->currIndex; return monListPtr->currIndex;
@ -544,50 +550,50 @@ u16 GetConditionGraphCurrentMonIndex(void)
struct ConditionGraph *GetConditionGraphPtr(void) struct ConditionGraph *GetConditionGraphPtr(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return &structPtr->graph; return &menu->graph;
} }
u8 GetMonMarkIndex(void) u8 GetConditionGraphMenuCurrentLoadIndex(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->mark; return menu->loadId;
} }
u8 sub_81CDC9C(void) u8 GetConditionGraphMenuToLoadListIndex(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->monIndex; return menu->toLoadListIndex;
} }
void *GetConditionMonPicGfx(u8 loadId) void *GetConditionMonPicGfx(u8 loadId)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->monPicGfx[loadId]; return menu->monPicGfx[loadId];
} }
void *GetConditionMonPal(u8 loadId) void *GetConditionMonPal(u8 loadId)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->monPal[loadId]; return menu->monPal[loadId];
} }
u8 sub_81CDCEC(void) u8 GetConditionGraphMenuToLoadId(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->unk6789; return menu->toLoadId;
} }
u8 *GetConditionMonNameText(u8 loadId) u8 *GetConditionMonNameText(u8 loadId)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->nameText[loadId]; return menu->nameText[loadId];
} }
u8 *GetConditionMonLocationText(u8 loadId) u8 *GetConditionMonLocationText(u8 loadId)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->locationText[loadId]; return menu->locationText[loadId];
} }
u16 GetConditionMonDataBuffer(void) u16 GetConditionMonDataBuffer(void)
@ -598,24 +604,25 @@ u16 GetConditionMonDataBuffer(void)
bool32 IsConditionMenuSearchMode(void) bool32 IsConditionMenuSearchMode(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (structPtr->searchMode == 1) if (menu->inSearchMode == TRUE)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
// Markings are only shown in search mode
u8 TryGetMonMarkId(void) u8 TryGetMonMarkId(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (structPtr->searchMode == 1) if (menu->inSearchMode == TRUE)
return structPtr->monMarks[structPtr->mark]; return menu->monMarks[menu->loadId];
else else
return 0; return 0;
} }
u8 GetNumConditionMonSparkles(void) u8 GetNumConditionMonSparkles(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return structPtr->numSparkles[structPtr->mark]; return menu->numSparkles[menu->loadId];
} }

View File

@ -16,21 +16,21 @@
#include "text.h" #include "text.h"
static u32 LoopedTask_TransitionMons(s32); static u32 LoopedTask_TransitionMons(s32);
static u32 LoopedTask_ExitPartyConditionMenu(s32); static u32 LoopedTask_ExitConditionGraphMenu(s32);
static u32 LoopedTask_MoveCursorNoTransition(s32); static u32 LoopedTask_MoveCursorNoTransition(s32);
static u32 LoopedTask_SlideMonOut(s32); static u32 LoopedTask_SlideMonOut(s32);
static u32 LoopedTask_OpenMonMarkingsWindow(s32); static u32 LoopedTask_OpenMonMarkingsWindow(s32);
static u32 LoopedTask_CloseMonMarkingsWindow(s32); static u32 LoopedTask_CloseMonMarkingsWindow(s32);
static u8 sUnknown_030012BC; static u8 sInitialLoadId; // Never read
const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal"); const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal");
const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal"); const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal");
static const u32 sUnknown_08623228[] = INCBIN_U32("graphics/pokenav/condition/graph_data.4bpp.lz"); static const u32 sConditionGraphData_Gfx[] = INCBIN_U32("graphics/pokenav/condition/graph_data.4bpp.lz");
static const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz"); static const u32 sConditionGraphData_Tilemap[] = INCBIN_U32("graphics/pokenav/condition/graph_data.bin.lz");
static const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal"); static const u16 sMonMarkings_Pal[] = INCBIN_U16("graphics/pokenav/condition/mon_markings.gbapal");
static const struct BgTemplate sPartyConditionBgTemplates[3] = static const struct BgTemplate sMenuBgTemplates[3] =
{ {
{ {
.bg = 1, .bg = 1,
@ -72,7 +72,7 @@ static const struct WindowTemplate sMonNameGenderWindowTemplate =
.baseBlock = 2 .baseBlock = 2
}; };
static const struct WindowTemplate sConditionGraphListIdWindowTemplate = static const struct WindowTemplate sListIndexWindowTemplate =
{ {
.bg = 1, .bg = 1,
.tilemapLeft = 1, .tilemapLeft = 1,
@ -105,29 +105,29 @@ static const struct WindowTemplate sUnusedWindowTemplate2 =
.baseBlock = 0x44 .baseBlock = 0x44
}; };
static const LoopedTask sPartyConditionLoopedTaskFuncs[] = static const LoopedTask sLoopedTaskFuncs[] =
{ {
[PARTY_CONDITION_FUNC_NONE] = NULL, [CONDITION_FUNC_NONE] = NULL,
[PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons, [CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons,
[PARTY_CONDITION_FUNC_RETURN] = LoopedTask_ExitPartyConditionMenu, [CONDITION_FUNC_RETURN] = LoopedTask_ExitConditionGraphMenu,
[PARTY_CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition, [CONDITION_FUNC_NO_TRANSITION] = LoopedTask_MoveCursorNoTransition,
[PARTY_CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut, [CONDITION_FUNC_SLIDE_MON_OUT] = LoopedTask_SlideMonOut,
[PARTY_CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow, [CONDITION_FUNC_ADD_MARKINGS] = LoopedTask_OpenMonMarkingsWindow,
[PARTY_CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow [CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow
}; };
struct Pokenav7Struct struct Pokenav_ConditionMenuGfx
{ {
u32 loopedTaskId; u32 loopedTaskId;
u8 tilemapBuffers[3][BG_SCREEN_SIZE]; u8 tilemapBuffers[3][BG_SCREEN_SIZE];
u8 filler[2]; u8 filler[2];
u8 partyPokeballSpriteIds[10]; u8 partyPokeballSpriteIds[PARTY_SIZE + 1];
u32 (*callback)(void); u32 (*callback)(void);
s16 monTransitionX; s16 monTransitionX;
u8 monPicSpriteId; u8 monPicSpriteId;
u16 monPalIndex; u16 monPalIndex;
u16 monGfxTileStart; u16 monGfxTileStart;
void *unk181C; void *monGfxPtr;
u8 nameGenderWindowId; u8 nameGenderWindowId;
u8 listIndexWindowId; u8 listIndexWindowId;
u8 unusedWindowId1; u8 unusedWindowId1;
@ -139,66 +139,65 @@ struct Pokenav7Struct
u8 filler2[0xFA3]; u8 filler2[0xFA3];
}; };
extern s8 GetMonMarkIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c extern s8 GetConditionGraphMenuCurrentLoadIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c
static u32 LoopedTask_OpenPartyConditionGraph(s32 state); static u32 LoopedTask_OpenConditionGraphMenu(s32);
static u32 GetPartyConditionLoopedTaskActive(void); static u32 GetConditionGraphMenuLoopedTaskActive(void);
static void CreateConditionMonPic(u8 var); static void CreateConditionMonPic(u8);
static void CreateMonMarkingsOrPokeballIndicators(void); static void CreateMonMarkingsOrPokeballIndicators(void);
static void CopyUnusedConditionWindowsToVram(void); static void CopyUnusedConditionWindowsToVram(void);
static bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2); static bool32 UpdateConditionGraphMenuWindows(u8, u16, bool8);
static void VBlankCB_PokenavConditionGraph(void); static void VBlankCB_PokenavConditionGraph(void);
static void DoConditionGraphTransition(void); static void DoConditionGraphEnterTransition(void);
static void sub_81CEEC8(void); static void DoConditionGraphExitTransition(void);
static void sub_81CEE68(void); static void SetExitVBlank(void);
static void ToggleGraphData(bool8 showBg); static void ToggleGraphData(bool8);
// code bool32 OpenConditionGraphMenu(void)
bool32 OpenPartyConditionMenu(void)
{ {
struct Pokenav7Struct *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU, sizeof(struct Pokenav7Struct)); struct Pokenav_ConditionMenuGfx *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX, sizeof(struct Pokenav_ConditionMenuGfx));
if (structPtr == NULL) if (menu == NULL)
return FALSE; return FALSE;
structPtr->monPicSpriteId = SPRITE_NONE; menu->monPicSpriteId = SPRITE_NONE;
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenPartyConditionGraph, 1); menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionGraphMenu, 1);
structPtr->callback = GetPartyConditionLoopedTaskActive; menu->callback = GetConditionGraphMenuLoopedTaskActive;
structPtr->windowModeState = 0; menu->windowModeState = 0;
return TRUE; return TRUE;
} }
void CreatePartyConditionLoopedTask(s32 id) void CreateConditionGraphMenuLoopedTask(s32 id)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
structPtr->loopedTaskId = CreateLoopedTask(sPartyConditionLoopedTaskFuncs[id], 1); menu->loopedTaskId = CreateLoopedTask(sLoopedTaskFuncs[id], 1);
structPtr->callback = GetPartyConditionLoopedTaskActive; menu->callback = GetConditionGraphMenuLoopedTaskActive;
} }
u32 IsPartyConditionLoopedTaskActive(void) u32 IsConditionGraphMenuLoopedTaskActive(void)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
return structPtr->callback(); return menu->callback();
} }
static u32 GetPartyConditionLoopedTaskActive(void) static u32 GetConditionGraphMenuLoopedTaskActive(void)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
return IsLoopedTaskActive(structPtr->loopedTaskId); return IsLoopedTaskActive(menu->loopedTaskId);
} }
static u32 LoopedTask_OpenPartyConditionGraph(s32 state) static u32 LoopedTask_OpenConditionGraphMenu(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
if (LoadPartyConditionMenuGfx() != TRUE) if (LoadConditionGraphMenuGfx() != TRUE)
return LT_PAUSE; return LT_PAUSE;
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 1: case 1:
InitBgTemplates(sPartyConditionBgTemplates, ARRAY_COUNT(sPartyConditionBgTemplates)); InitBgTemplates(sMenuBgTemplates, ARRAY_COUNT(sMenuBgTemplates));
ChangeBgX(1, 0, BG_COORD_SET); ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET); ChangeBgY(1, 0, BG_COORD_SET);
ChangeBgX(2, 0, BG_COORD_SET); ChangeBgX(2, 0, BG_COORD_SET);
@ -213,28 +212,28 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state)
case 2: case 2:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
DecompressAndCopyTileDataToVram(2, sUnknown_08623228, 0, 0, 0); DecompressAndCopyTileDataToVram(2, sConditionGraphData_Gfx, 0, 0, 0);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
LZ77UnCompVram(gPokenavCondition_Tilemap, structPtr->tilemapBuffers[0]); LZ77UnCompVram(gPokenavCondition_Tilemap, menu->tilemapBuffers[0]);
SetBgTilemapBuffer(3, structPtr->tilemapBuffers[0]); SetBgTilemapBuffer(3, menu->tilemapBuffers[0]);
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
CopyToBgTilemapBufferRect(3, gPokenavOptions_Tilemap, 0, 5, 9, 4); CopyToBgTilemapBufferRect(3, gPokenavOptions_Tilemap, 0, 5, 9, 4);
CopyBgTilemapBufferToVram(3); CopyBgTilemapBufferToVram(3);
CopyPaletteIntoBufferUnfaded(gPokenavCondition_Pal, 0x10, 0x20); CopyPaletteIntoBufferUnfaded(gPokenavCondition_Pal, 0x10, 0x20);
CopyPaletteIntoBufferUnfaded(gConditionText_Pal, 0xF0, 0x20); CopyPaletteIntoBufferUnfaded(gConditionText_Pal, 0xF0, 0x20);
structPtr->monTransitionX = -80; menu->monTransitionX = -80;
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 4: case 4:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
LZ77UnCompVram(sConditionGraph_Tilemap, structPtr->tilemapBuffers[2]); LZ77UnCompVram(sConditionGraphData_Tilemap, menu->tilemapBuffers[2]);
SetBgTilemapBuffer(2, structPtr->tilemapBuffers[2]); SetBgTilemapBuffer(2, menu->tilemapBuffers[2]);
CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(2);
CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, 0x30, 0x20); CopyPaletteIntoBufferUnfaded(gConditionGraphData_Pal, 0x30, 0x20);
ConditionGraph_InitWindow(2); ConditionGraph_InitWindow(2);
@ -242,19 +241,19 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state)
case 5: case 5:
BgDmaFill(1, 0, 0, 1); BgDmaFill(1, 0, 0, 1);
BgDmaFill(1, 17, 1, 1); BgDmaFill(1, 17, 1, 1);
CpuFill32(0, structPtr->tilemapBuffers[1], BG_SCREEN_SIZE); CpuFill32(0, menu->tilemapBuffers[1], BG_SCREEN_SIZE);
SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]); SetBgTilemapBuffer(1, menu->tilemapBuffers[1]);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 6: case 6:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
structPtr->nameGenderWindowId = AddWindow(&sMonNameGenderWindowTemplate); menu->nameGenderWindowId = AddWindow(&sMonNameGenderWindowTemplate);
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
structPtr->listIndexWindowId = AddWindow(&sConditionGraphListIdWindowTemplate); menu->listIndexWindowId = AddWindow(&sListIndexWindowTemplate);
structPtr->unusedWindowId1 = AddWindow(&sUnusedWindowTemplate1); menu->unusedWindowId1 = AddWindow(&sUnusedWindowTemplate1);
structPtr->unusedWindowId2 = AddWindow(&sUnusedWindowTemplate2); menu->unusedWindowId2 = AddWindow(&sUnusedWindowTemplate2);
} }
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
@ -269,23 +268,23 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state)
CopyUnusedConditionWindowsToVram(); CopyUnusedConditionWindowsToVram();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 10: case 10:
UpdateConditionGraphWindows(0, GetMonMarkIndex(), TRUE); UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), TRUE);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 11: case 11:
UpdateConditionGraphWindows(1, GetMonMarkIndex(), TRUE); UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), TRUE);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 12: case 12:
UpdateConditionGraphWindows(2, GetMonMarkIndex(), TRUE); UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), TRUE);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 13: case 13:
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), TRUE) != TRUE) if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), TRUE) != TRUE)
return LT_PAUSE; return LT_PAUSE;
PutWindowTilemap(structPtr->nameGenderWindowId); PutWindowTilemap(menu->nameGenderWindowId);
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
PutWindowTilemap(structPtr->listIndexWindowId); PutWindowTilemap(menu->listIndexWindowId);
PutWindowTilemap(structPtr->unusedWindowId1); PutWindowTilemap(menu->unusedWindowId1);
PutWindowTilemap(structPtr->unusedWindowId2); PutWindowTilemap(menu->unusedWindowId2);
} }
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 14: case 14:
@ -312,7 +311,7 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state)
SetVBlankCallback_(VBlankCB_PokenavConditionGraph); SetVBlankCallback_(VBlankCB_PokenavConditionGraph);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 17: case 17:
DoConditionGraphTransition(); DoConditionGraphEnterTransition();
ConditionGraph_InitResetScanline(GetConditionGraphPtr()); ConditionGraph_InitResetScanline(GetConditionGraphPtr());
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 18: case 18:
@ -323,11 +322,11 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state)
ToggleGraphData(TRUE); ToggleGraphData(TRUE);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 20: case 20:
if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &structPtr->monTransitionX)) if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &menu->monTransitionX))
{ {
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); ResetConditionSparkleSprites(menu->conditionSparkleSprites);
if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount()) if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentListIndex() != GetMonListCount())
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles());
return LT_FINISH; return LT_FINISH;
} }
@ -337,18 +336,18 @@ static u32 LoopedTask_OpenPartyConditionGraph(s32 state)
return LT_FINISH; return LT_FINISH;
} }
static u32 LoopedTask_ExitPartyConditionMenu(s32 state) static u32 LoopedTask_ExitConditionGraphMenu(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
sub_81CEEC8(); DoConditionGraphExitTransition();
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); DestroyConditionSparkleSprites(menu->conditionSparkleSprites);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 1: case 1:
if (ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &structPtr->monTransitionX)) if (ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &menu->monTransitionX))
return 2; return 2;
ToggleGraphData(FALSE); ToggleGraphData(FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
@ -360,7 +359,7 @@ static u32 LoopedTask_ExitPartyConditionMenu(s32 state)
case 3: case 3:
if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy()) if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy())
return LT_PAUSE; return LT_PAUSE;
FreeConditionSparkles(structPtr->conditionSparkleSprites); FreeConditionSparkles(menu->conditionSparkleSprites);
HideBg(1); HideBg(1);
HideBg(2); HideBg(2);
HideBg(3); HideBg(3);
@ -372,53 +371,53 @@ static u32 LoopedTask_ExitPartyConditionMenu(s32 state)
static u32 LoopedTask_TransitionMons(s32 state) static u32 LoopedTask_TransitionMons(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
struct ConditionGraph *graph = GetConditionGraphPtr(); struct ConditionGraph *graph = GetConditionGraphPtr();
switch (state) switch (state)
{ {
case 0: case 0:
SetConditionGraphData(0); LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 1: case 1:
SetConditionGraphData(1); LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 2: case 2:
SetConditionGraphData(2); LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC);
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); DestroyConditionSparkleSprites(menu->conditionSparkleSprites);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 3: case 3:
ConditionGraph_TryUpdate(graph); ConditionGraph_TryUpdate(graph);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 4: case 4:
if (!MoveConditionMonOffscreen(&structPtr->monTransitionX)) if (!MoveConditionMonOffscreen(&menu->monTransitionX))
{ {
CreateConditionMonPic(GetMonMarkIndex()); CreateConditionMonPic(GetConditionGraphMenuCurrentLoadIndex());
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
return LT_PAUSE; return LT_PAUSE;
case 5: case 5:
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 6: case 6:
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 7: case 7:
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 8: case 8:
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
return LT_PAUSE; return LT_PAUSE;
case 9: case 9:
graph = GetConditionGraphPtr(); graph = GetConditionGraphPtr();
if (!ConditionMenu_UpdateMonEnter(graph, &structPtr->monTransitionX)) if (!ConditionMenu_UpdateMonEnter(graph, &menu->monTransitionX))
{ {
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); ResetConditionSparkleSprites(menu->conditionSparkleSprites);
if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount()) if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentListIndex() == GetMonListCount())
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles());
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
return LT_PAUSE; return LT_PAUSE;
@ -429,40 +428,40 @@ static u32 LoopedTask_TransitionMons(s32 state)
static u32 LoopedTask_MoveCursorNoTransition(s32 state) static u32 LoopedTask_MoveCursorNoTransition(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
SetConditionGraphData(0); LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 1: case 1:
SetConditionGraphData(1); LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 2: case 2:
SetConditionGraphData(2); LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 3: case 3:
CreateConditionMonPic(GetMonMarkIndex()); CreateConditionMonPic(GetConditionGraphMenuCurrentLoadIndex());
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 4: case 4:
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 5: case 5:
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 6: case 6:
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 7: case 7:
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
return LT_PAUSE; return LT_PAUSE;
case 8: case 8:
if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &structPtr->monTransitionX)) if (!ConditionMenu_UpdateMonEnter(GetConditionGraphPtr(), &menu->monTransitionX))
{ {
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); ResetConditionSparkleSprites(menu->conditionSparkleSprites);
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles()); CreateConditionSparkleSprites(menu->conditionSparkleSprites, menu->monPicSpriteId, GetNumConditionMonSparkles());
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
return LT_PAUSE; return LT_PAUSE;
@ -473,35 +472,35 @@ static u32 LoopedTask_MoveCursorNoTransition(s32 state)
static u32 LoopedTask_SlideMonOut(s32 state) static u32 LoopedTask_SlideMonOut(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
SetConditionGraphData(0); LoadNextConditionMenuMonData(CONDITION_LOAD_MON_INFO);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 1: case 1:
SetConditionGraphData(1); LoadNextConditionMenuMonData(CONDITION_LOAD_GRAPH);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 2: case 2:
SetConditionGraphData(2); LoadNextConditionMenuMonData(CONDITION_LOAD_MON_PIC);
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); DestroyConditionSparkleSprites(menu->conditionSparkleSprites);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 3: case 3:
if (!ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &structPtr->monTransitionX)) if (!ConditionMenu_UpdateMonExit(GetConditionGraphPtr(), &menu->monTransitionX))
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
return LT_PAUSE; return LT_PAUSE;
case 4: case 4:
UpdateConditionGraphWindows(0, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(0, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 5: case 5:
UpdateConditionGraphWindows(1, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(1, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 6: case 6:
UpdateConditionGraphWindows(2, GetMonMarkIndex(), FALSE); UpdateConditionGraphMenuWindows(2, GetConditionGraphMenuCurrentLoadIndex(), FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 7: case 7:
if (UpdateConditionGraphWindows(3, GetMonMarkIndex(), FALSE) == TRUE) if (UpdateConditionGraphMenuWindows(3, GetConditionGraphMenuCurrentLoadIndex(), FALSE) == TRUE)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
return LT_PAUSE; return LT_PAUSE;
} }
@ -555,68 +554,68 @@ static u8 *UnusedPrintNumberString(u8 *dst, u16 num)
return txtPtr; return txtPtr;
} }
static bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) static bool32 UpdateConditionGraphMenuWindows(u8 mode, u16 bufferIndex, bool8 winMode)
{ {
u8 text[32]; u8 text[32];
const u8 *str; const u8 *str;
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
switch (mode) switch (mode)
{ {
case 0: case 0:
FillWindowPixelBuffer(structPtr->nameGenderWindowId, 0); FillWindowPixelBuffer(menu->nameGenderWindowId, 0);
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
FillWindowPixelBuffer(structPtr->listIndexWindowId, 0); FillWindowPixelBuffer(menu->listIndexWindowId, 0);
break; break;
case 1: case 1:
if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE) if (GetConditionGraphCurrentListIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE)
{ {
str = GetConditionMonNameText(bufferIndex); str = GetConditionMonNameText(bufferIndex);
AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL); AddTextPrinterParameterized(menu->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL);
} }
break; break;
case 2: case 2:
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
str = GetConditionMonLocationText(bufferIndex); str = GetConditionMonLocationText(bufferIndex);
AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL); AddTextPrinterParameterized(menu->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL);
text[0] = EXT_CTRL_CODE_BEGIN; text[0] = EXT_CTRL_CODE_BEGIN;
text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
text[2] = TEXT_COLOR_BLUE; text[2] = TEXT_COLOR_BLUE;
text[3] = TEXT_COLOR_TRANSPARENT; text[3] = TEXT_COLOR_TRANSPARENT;
text[4] = TEXT_COLOR_LIGHT_BLUE; text[4] = TEXT_COLOR_LIGHT_BLUE;
StringCopy(&text[5], gText_Number2); StringCopy(&text[5], gText_Number2);
AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL); AddTextPrinterParameterized(menu->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL);
ConvertIntToDecimalStringN(&text[5], GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4); ConvertIntToDecimalStringN(&text[5], GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4);
AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL); AddTextPrinterParameterized(menu->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL);
} }
break; break;
case 3: case 3:
switch (structPtr->windowModeState) switch (menu->windowModeState)
{ {
case 0: case 0:
if (winMode) if (winMode)
CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_FULL); CopyWindowToVram(menu->nameGenderWindowId, COPYWIN_FULL);
else else
CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_GFX); CopyWindowToVram(menu->nameGenderWindowId, COPYWIN_GFX);
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
structPtr->windowModeState++; menu->windowModeState++;
return FALSE; return FALSE;
} }
else else
{ {
structPtr->windowModeState = 0; menu->windowModeState = 0;
return TRUE; return TRUE;
} }
case 1: case 1:
if (winMode) if (winMode)
CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_FULL); CopyWindowToVram(menu->listIndexWindowId, COPYWIN_FULL);
else else
CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_GFX); CopyWindowToVram(menu->listIndexWindowId, COPYWIN_GFX);
structPtr->windowModeState = 0; menu->windowModeState = 0;
return TRUE; return TRUE;
} }
} }
@ -626,23 +625,23 @@ static bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMod
static void CopyUnusedConditionWindowsToVram(void) static void CopyUnusedConditionWindowsToVram(void)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
CopyWindowToVram(structPtr->unusedWindowId1, COPYWIN_FULL); CopyWindowToVram(menu->unusedWindowId1, COPYWIN_FULL);
CopyWindowToVram(structPtr->unusedWindowId2, COPYWIN_FULL); CopyWindowToVram(menu->unusedWindowId2, COPYWIN_FULL);
} }
void sub_81CE964(struct Sprite *sprite) static void SpriteCB_PartyPokeball(struct Sprite *sprite)
{ {
if (sprite->data[0] == GetConditionGraphCurrentMonIndex()) if (sprite->data[0] == GetConditionGraphCurrentListIndex())
StartSpriteAnim(sprite, 0); StartSpriteAnim(sprite, CONDITION_ICON_SELECTED);
else else
StartSpriteAnim(sprite, 1); StartSpriteAnim(sprite, CONDITION_ICON_UNSELECTED);
} }
void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite) void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite)
{ {
if (GetConditionGraphCurrentMonIndex() == GetMonListCount() - 1) if (GetConditionGraphCurrentListIndex() == GetMonListCount() - 1)
sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_BALL); sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_BALL);
else else
sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_CANCEL); sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_CANCEL);
@ -661,71 +660,76 @@ static void CreateMonMarkingsOrPokeballIndicators(void)
struct SpriteSheet sprSheet; struct SpriteSheet sprSheet;
struct Sprite *sprite; struct Sprite *sprite;
u16 i, spriteId; u16 i, spriteId;
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals); LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals);
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
structPtr->marksMenu.baseTileTag = TAG_CONDITION_MARKINGS_MENU; // Search Mode, load markings menu
structPtr->marksMenu.basePaletteTag = TAG_CONDITION_MARKINGS_MENU; menu->marksMenu.baseTileTag = TAG_CONDITION_MARKINGS_MENU;
InitMonMarkingsMenu(&structPtr->marksMenu); menu->marksMenu.basePaletteTag = TAG_CONDITION_MARKINGS_MENU;
InitMonMarkingsMenu(&menu->marksMenu);
BufferMonMarkingsMenuTiles(); BufferMonMarkingsMenuTiles();
sprite = CreateMonMarkingAllCombosSprite(TAG_CONDITION_MON_MARKINGS, TAG_CONDITION_MON_MARKINGS, sConditionGraphMonMarkingsPal); sprite = CreateMonMarkingAllCombosSprite(TAG_CONDITION_MON_MARKINGS, TAG_CONDITION_MON_MARKINGS, sMonMarkings_Pal);
sprite->oam.priority = 3; sprite->oam.priority = 3;
sprite->x = 192; sprite->x = 192;
sprite->y = 32; sprite->y = 32;
sprite->callback = MonMarkingsCallback; sprite->callback = MonMarkingsCallback;
structPtr->monMarksSprite = sprite; menu->monMarksSprite = sprite;
PokenavFillPalette(IndexOfSpritePaletteTag(TAG_CONDITION_MON_MARKINGS), 0); PokenavFillPalette(IndexOfSpritePaletteTag(TAG_CONDITION_MON_MARKINGS), 0);
} }
else else
{ {
// party mode -> add pokeballs on right hand side // Party Mode, load Pokéball selection icons
LoadSpriteSheets(sprSheets); LoadSpriteSheets(sprSheets);
Pokenav_AllocAndLoadPalettes(sprPals); Pokenav_AllocAndLoadPalettes(sprPals);
// Add icons for occupied slots
for (i = 0; i < GetMonListCount() - 1; i++) for (i = 0; i < GetMonListCount() - 1; i++)
{ {
spriteId = CreateSprite(&sprTemplate, 226, (i * 20) + 8, 0); spriteId = CreateSprite(&sprTemplate, 226, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
structPtr->partyPokeballSpriteIds[i] = spriteId; menu->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].data[0] = i; gSprites[spriteId].data[0] = i;
gSprites[spriteId].callback = sub_81CE964; gSprites[spriteId].callback = SpriteCB_PartyPokeball;
} }
else else
{ {
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE; menu->partyPokeballSpriteIds[i] = SPRITE_NONE;
} }
} }
// Add icons for empty slots
sprTemplate.tileTag = TAG_CONDITION_BALL_PLACEHOLDER; sprTemplate.tileTag = TAG_CONDITION_BALL_PLACEHOLDER;
sprTemplate.callback = SpriteCallbackDummy; sprTemplate.callback = SpriteCallbackDummy;
for (; i < 6; i++) for (; i < PARTY_SIZE; i++)
{ {
spriteId = CreateSprite(&sprTemplate, 230, (i * 20) + 8, 0); spriteId = CreateSprite(&sprTemplate, 230, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
structPtr->partyPokeballSpriteIds[i] = spriteId; menu->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].oam.size = 0; gSprites[spriteId].oam.size = 0;
} }
else else
{ {
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE; menu->partyPokeballSpriteIds[i] = SPRITE_NONE;
} }
} }
// Add cancel icon
sprTemplate.tileTag = TAG_CONDITION_CANCEL; sprTemplate.tileTag = TAG_CONDITION_CANCEL;
sprTemplate.callback = HighlightCurrentPartyIndexPokeball; sprTemplate.callback = HighlightCurrentPartyIndexPokeball;
spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0); spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
structPtr->partyPokeballSpriteIds[i] = spriteId; menu->partyPokeballSpriteIds[i] = spriteId;
gSprites[spriteId].oam.shape = SPRITE_SHAPE(32x16); gSprites[spriteId].oam.shape = SPRITE_SHAPE(32x16);
gSprites[spriteId].oam.size = SPRITE_SIZE(32x16); gSprites[spriteId].oam.size = SPRITE_SIZE(32x16);
} }
else else
{ {
structPtr->partyPokeballSpriteIds[i] = SPRITE_NONE; menu->partyPokeballSpriteIds[i] = SPRITE_NONE;
} }
} }
@ -735,13 +739,13 @@ static void CreateMonMarkingsOrPokeballIndicators(void)
Pokenav_AllocAndLoadPalettes(sprPals); Pokenav_AllocAndLoadPalettes(sprPals);
} }
void sub_81CEBF4(struct Pokenav7Struct *structPtr) static void FreeConditionMenuGfx(struct Pokenav_ConditionMenuGfx *menu)
{ {
u8 i; u8 i;
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
DestroySprite(structPtr->monMarksSprite); DestroySprite(menu->monMarksSprite);
FreeSpriteTilesByTag(TAG_CONDITION_MARKINGS_MENU); FreeSpriteTilesByTag(TAG_CONDITION_MARKINGS_MENU);
FreeSpriteTilesByTag(TAG_CONDITION_MON_MARKINGS); FreeSpriteTilesByTag(TAG_CONDITION_MON_MARKINGS);
FreeSpritePaletteByTag(TAG_CONDITION_MARKINGS_MENU); FreeSpritePaletteByTag(TAG_CONDITION_MARKINGS_MENU);
@ -749,8 +753,8 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr)
} }
else else
{ {
for (i = 0; i < 7; i++) for (i = 0; i < PARTY_SIZE + 1; i++)
DestroySprite(&gSprites[structPtr->partyPokeballSpriteIds[i]]); DestroySprite(&gSprites[menu->partyPokeballSpriteIds[i]]);
FreeSpriteTilesByTag(TAG_CONDITION_BALL); FreeSpriteTilesByTag(TAG_CONDITION_BALL);
FreeSpriteTilesByTag(TAG_CONDITION_CANCEL); FreeSpriteTilesByTag(TAG_CONDITION_CANCEL);
@ -759,24 +763,24 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr)
FreeSpritePaletteByTag(TAG_CONDITION_CANCEL); FreeSpritePaletteByTag(TAG_CONDITION_CANCEL);
} }
if (structPtr->monPicSpriteId != SPRITE_NONE) if (menu->monPicSpriteId != SPRITE_NONE)
{ {
DestroySprite(&gSprites[structPtr->monPicSpriteId]); DestroySprite(&gSprites[menu->monPicSpriteId]);
FreeSpriteTilesByTag(TAG_CONDITION_MON); FreeSpriteTilesByTag(TAG_CONDITION_MON);
FreeSpritePaletteByTag(TAG_CONDITION_MON); FreeSpritePaletteByTag(TAG_CONDITION_MON);
} }
} }
void FreePartyConditionSubstruct2(void) void FreeConditionGraphMenuSubstruct2(void)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
RemoveWindow(structPtr->nameGenderWindowId); RemoveWindow(menu->nameGenderWindowId);
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
RemoveWindow(structPtr->listIndexWindowId); RemoveWindow(menu->listIndexWindowId);
RemoveWindow(structPtr->unusedWindowId1); RemoveWindow(menu->unusedWindowId1);
RemoveWindow(structPtr->unusedWindowId2); RemoveWindow(menu->unusedWindowId2);
} }
else else
{ {
@ -784,15 +788,15 @@ void FreePartyConditionSubstruct2(void)
} }
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP);
sub_81CEBF4(structPtr); FreeConditionMenuGfx(menu);
sub_81CEE68(); SetExitVBlank();
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_MARK_MENU); FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
} }
void MonPicGfxSpriteCallback(struct Sprite *sprite) void MonPicGfxSpriteCallback(struct Sprite *sprite)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
sprite->x = structPtr->monTransitionX + 38; sprite->x = menu->monTransitionX + 38;
} }
static void CreateConditionMonPic(u8 id) static void CreateConditionMonPic(u8 id)
@ -801,35 +805,35 @@ static void CreateConditionMonPic(u8 id)
struct SpriteSheet sprSheet; struct SpriteSheet sprSheet;
struct SpritePalette sprPal; struct SpritePalette sprPal;
u8 spriteId; u8 spriteId;
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
if (structPtr->monPicSpriteId == SPRITE_NONE) if (menu->monPicSpriteId == SPRITE_NONE)
{ {
LoadConditionMonPicTemplate(&sprSheet, &sprTemplate, &sprPal); LoadConditionMonPicTemplate(&sprSheet, &sprTemplate, &sprPal);
sprSheet.data = GetConditionMonPicGfx(id); sprSheet.data = GetConditionMonPicGfx(id);
sprPal.data = GetConditionMonPal(id); sprPal.data = GetConditionMonPal(id);
structPtr->monPalIndex = LoadSpritePalette(&sprPal); menu->monPalIndex = LoadSpritePalette(&sprPal);
structPtr->monGfxTileStart = LoadSpriteSheet(&sprSheet); menu->monGfxTileStart = LoadSpriteSheet(&sprSheet);
spriteId = CreateSprite(&sprTemplate, 38, 104, 0); spriteId = CreateSprite(&sprTemplate, 38, 104, 0);
structPtr->monPicSpriteId = spriteId; menu->monPicSpriteId = spriteId;
if (spriteId == MAX_SPRITES) if (spriteId == MAX_SPRITES)
{ {
FreeSpriteTilesByTag(TAG_CONDITION_MON); FreeSpriteTilesByTag(TAG_CONDITION_MON);
FreeSpritePaletteByTag(TAG_CONDITION_MON); FreeSpritePaletteByTag(TAG_CONDITION_MON);
structPtr->monPicSpriteId = SPRITE_NONE; menu->monPicSpriteId = SPRITE_NONE;
} }
else else
{ {
structPtr->monPicSpriteId = spriteId; menu->monPicSpriteId = spriteId;
gSprites[structPtr->monPicSpriteId].callback = MonPicGfxSpriteCallback; gSprites[menu->monPicSpriteId].callback = MonPicGfxSpriteCallback;
structPtr->unk181C = (void*)VRAM + BG_VRAM_SIZE + (structPtr->monGfxTileStart * 32); menu->monGfxPtr = (void*)VRAM + BG_VRAM_SIZE + (menu->monGfxTileStart * 32);
structPtr->monPalIndex = (structPtr->monPalIndex * 16) + 0x100; menu->monPalIndex = (menu->monPalIndex * 16) + 0x100;
} }
} }
else else
{ {
DmaCopy16Defvars(3, GetConditionMonPicGfx(id), structPtr->unk181C, MON_PIC_SIZE); DmaCopy16Defvars(3, GetConditionMonPicGfx(id), menu->monGfxPtr, MON_PIC_SIZE);
LoadPalette(GetConditionMonPal(id), structPtr->monPalIndex, 0x20); LoadPalette(GetConditionMonPal(id), menu->monPalIndex, 0x20);
} }
} }
@ -843,7 +847,7 @@ static void VBlankCB_PokenavConditionGraph(void)
ScanlineEffect_InitHBlankDmaTransfer(); ScanlineEffect_InitHBlankDmaTransfer();
} }
static void sub_81CEE68(void) static void SetExitVBlank(void)
{ {
SetPokenavVBlankCallback(); SetPokenavVBlankCallback();
} }
@ -856,30 +860,33 @@ static void ToggleGraphData(bool8 showBg)
HideBg(2); HideBg(2);
} }
static void DoConditionGraphTransition(void) static void DoConditionGraphEnterTransition(void)
{ {
struct ConditionGraph *graph = GetConditionGraphPtr(); struct ConditionGraph *graph = GetConditionGraphPtr();
u8 id = GetMonMarkIndex(); u8 id = GetConditionGraphMenuCurrentLoadIndex();
sUnknown_030012BC = id; sInitialLoadId = id;
ConditionGraph_SetNewPositions(graph, graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1], graph->savedPositions[id]); ConditionGraph_SetNewPositions(graph, graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1], graph->savedPositions[id]);
ConditionGraph_TryUpdate(graph); ConditionGraph_TryUpdate(graph);
} }
static void sub_81CEEC8(void) // Transition the graph back to empty before exiting.
// This is skipped if the player is in party mode and the cursor
// is on Cancel, in which case the graph is already empty.
static void DoConditionGraphExitTransition(void)
{ {
struct ConditionGraph *graph = GetConditionGraphPtr(); struct ConditionGraph *graph = GetConditionGraphPtr();
if (IsConditionMenuSearchMode() || GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1) if (IsConditionMenuSearchMode() || GetConditionGraphCurrentListIndex() != GetMonListCount() - 1)
ConditionGraph_SetNewPositions(graph, graph->savedPositions[GetMonMarkIndex()], graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]); ConditionGraph_SetNewPositions(graph, graph->savedPositions[GetConditionGraphMenuCurrentLoadIndex()], graph->savedPositions[CONDITION_GRAPH_LOAD_MAX - 1]);
} }
u8 GetMonMarkingsData(void) u8 GetMonMarkingsData(void)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav_ConditionMenuGfx *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU_GFX);
if (IsConditionMenuSearchMode() == 1) if (IsConditionMenuSearchMode() == 1)
return structPtr->marksMenu.markings; return menu->marksMenu.markings;
else else
return 0; return 0;
} }

View File

@ -21,48 +21,48 @@ enum
CONDITION_SEARCH_FUNC_SELECT_MON, CONDITION_SEARCH_FUNC_SELECT_MON,
}; };
struct PokenavSub7 struct Pokenav_SearchResults
{ {
u32 (*callback)(struct PokenavSub7 *); u32 (*callback)(struct Pokenav_SearchResults *);
u32 loopedTaskId; u32 loopedTaskId;
u8 fill1[4]; u8 fill1[4];
s32 boxId; s32 boxId;
s32 monId; s32 monId;
u32 conditionDataId; u32 conditionDataId;
u32 returnFromGraph; bool32 returnFromGraph;
u32 isPartyCondition; bool32 saveResultsList;
struct PokenavSub18 *monList; struct PokenavSub18 *monList;
}; };
struct PokenavSub8 struct Pokenav_SearchResultsGfx
{ {
bool32 (*callback)(void); bool32 (*callback)(void);
u32 ltid; //looped task Id u32 loopedTaskId;
u16 winid; u16 winid;
bool32 fromGraph; bool32 fromGraph;
u8 buff[BG_SCREEN_SIZE]; u8 buff[BG_SCREEN_SIZE];
}; // size: 0x810 }; // size: 0x810
static u32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr); static u32 HandleConditionSearchInput_WaitSetup(struct Pokenav_SearchResults *);
static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr); static u32 HandleConditionSearchInput(struct Pokenav_SearchResults *);
static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr); static u32 OpenConditionGraphFromSearchList(struct Pokenav_SearchResults *);
static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr); static u32 ReturnToConditionSearchList(struct Pokenav_SearchResults *);
static u32 GetConditionSearchLoopedTask(s32 state); static u32 GetConditionSearchLoopedTask(s32);
static u32 BuildPartyMonSearchResults(s32 state); static u32 BuildPartyMonSearchResults(s32);
static u32 InitBoxMonSearchResults(s32 state); static u32 InitBoxMonSearchResults(s32);
static u32 BuildBoxMonSearchResults(s32 state); static u32 BuildBoxMonSearchResults(s32);
static u32 sub_81CF278(s32 state); static u32 ConvertConditionsToListRanks(s32);
static u32 LoopedTask_MoveSearchListCursorUp(s32 state); static u32 LoopedTask_MoveSearchListCursorUp(s32);
static u32 LoopedTask_MoveSearchListCursorDown(s32 state); static u32 LoopedTask_MoveSearchListCursorDown(s32);
static u32 LoopedTask_MoveSearchListPageUp(s32 state); static u32 LoopedTask_MoveSearchListPageUp(s32);
static u32 LoopedTask_MoveSearchListPageDown(s32 state); static u32 LoopedTask_MoveSearchListPageDown(s32);
static u32 LoopedTask_ExitConditionSearchMenu(s32 state); static u32 LoopedTask_ExitConditionSearchMenu(s32);
static u32 LoopedTask_SelectSearchResult(s32 state); static u32 LoopedTask_SelectSearchResult(s32);
static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item); static void InsertMonListItem(struct Pokenav_SearchResults *, struct PokenavMonList *);
static bool32 GetSearchResultCurrentLoopedTaskActive(void); static bool32 GetSearchResultCurrentLoopedTaskActive(void);
static u32 LoopedTask_OpenConditionSearchResults(s32 state); static u32 LoopedTask_OpenConditionSearchResults(s32);
static void AddSearchResultListMenuWindow(struct PokenavSub8 *); static void AddSearchResultListMenuWindow(struct Pokenav_SearchResultsGfx *);
static void PrintSearchResultListMenuItems(struct PokenavSub8 *); static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *);
static void InitConditionSearchListMenuTemplate(void); static void InitConditionSearchListMenuTemplate(void);
static void PrintSearchMonListItem(struct PokenavMonList *, u8 *); static void PrintSearchMonListItem(struct PokenavMonList *, u8 *);
@ -73,13 +73,13 @@ static const LoopedTask sConditionSearchLoopedTaskFuncs[] =
BuildPartyMonSearchResults, BuildPartyMonSearchResults,
InitBoxMonSearchResults, InitBoxMonSearchResults,
BuildBoxMonSearchResults, BuildBoxMonSearchResults,
sub_81CF278 ConvertConditionsToListRanks
}; };
static const u16 sConditionSearchResultFramePal[] = INCBIN_U16("graphics/pokenav/condition_search2.gbapal"); static const u16 sConditionSearchResultFramePal[] = INCBIN_U16("graphics/pokenav/condition/search_results.gbapal");
static const u32 sConditionSearchResultTiles[] = INCBIN_U32("graphics/pokenav/condition_search2.4bpp.lz"); static const u32 sConditionSearchResultTiles[] = INCBIN_U32("graphics/pokenav/condition/search_results.4bpp.lz");
static const u32 sConditionSearchResultTilemap[] = INCBIN_U32("graphics/pokenav/condition_search2.bin.lz"); static const u32 sConditionSearchResultTilemap[] = INCBIN_U32("graphics/pokenav/condition/search_results.bin.lz");
static const u16 gUnknown_08623570[] = INCBIN_U16("graphics/pokenav/8623570.gbapal"); static const u16 sListBg_Pal[] = INCBIN_U16("graphics/pokenav/condition/search_results_list.gbapal");
static const struct BgTemplate sConditionSearchResultBgTemplates[] = static const struct BgTemplate sConditionSearchResultBgTemplates[] =
{ {
@ -130,57 +130,57 @@ static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}");
bool32 PokenavCallback_Init_ConditionSearch(void) bool32 PokenavCallback_Init_ConditionSearch(void)
{ {
struct PokenavSub7 *structPtr = AllocSubstruct(7, sizeof(struct PokenavSub7)); struct Pokenav_SearchResults *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct Pokenav_SearchResults));
if (structPtr == NULL) if (menu == NULL)
return FALSE; return FALSE;
structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18)); menu->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
if (structPtr->monList == NULL) if (menu->monList == NULL)
return FALSE; return FALSE;
structPtr->callback = HandleConditionSearchInput_WaitSetup; menu->callback = HandleConditionSearchInput_WaitSetup;
structPtr->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1); menu->loopedTaskId = CreateLoopedTask(GetConditionSearchLoopedTask, 1);
structPtr->returnFromGraph = 0; menu->returnFromGraph = FALSE;
structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; menu->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()];
return TRUE; return TRUE;
} }
// return to search results from condition graph // return to search results from condition graph
bool32 PokenavCallback_Init_ReturnToMonSearchList(void) bool32 PokenavCallback_Init_ReturnToMonSearchList(void)
{ {
struct PokenavSub7 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct PokenavSub7)); struct Pokenav_SearchResults *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS, sizeof(struct Pokenav_SearchResults));
if (structPtr == NULL) if (menu == NULL)
return FALSE; return FALSE;
structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); menu->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
structPtr->callback = HandleConditionSearchInput; menu->callback = HandleConditionSearchInput;
structPtr->returnFromGraph = 1; menu->returnFromGraph = TRUE;
structPtr->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()]; menu->conditionDataId = sSearchMonDataIds[GetSelectedConditionSearch()];
return TRUE; return TRUE;
} }
u32 GetConditionSearchResultsCallback(void) u32 GetConditionSearchResultsCallback(void)
{ {
struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return structPtr->callback(structPtr); return menu->callback(menu);
} }
void FreeSearchResultSubstruct1(void) void FreeSearchResultSubstruct1(void)
{ {
struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
if (structPtr->isPartyCondition == 0) if (!menu->saveResultsList)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST); FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
} }
static bool32 HandleConditionSearchInput_WaitSetup(struct PokenavSub7 *structPtr) static bool32 HandleConditionSearchInput_WaitSetup(struct Pokenav_SearchResults *menu)
{ {
if (!IsLoopedTaskActive(structPtr->loopedTaskId)) if (!IsLoopedTaskActive(menu->loopedTaskId))
structPtr->callback = HandleConditionSearchInput; menu->callback = HandleConditionSearchInput;
return FALSE; return FALSE;
} }
static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr) static u32 HandleConditionSearchInput(struct Pokenav_SearchResults *menu)
{ {
if (JOY_REPEAT(DPAD_UP)) if (JOY_REPEAT(DPAD_UP))
return CONDITION_SEARCH_FUNC_MOVE_UP; return CONDITION_SEARCH_FUNC_MOVE_UP;
@ -192,60 +192,63 @@ static u32 HandleConditionSearchInput(struct PokenavSub7 *structPtr)
return CONDITION_SEARCH_FUNC_PAGE_DOWN; return CONDITION_SEARCH_FUNC_PAGE_DOWN;
else if (JOY_NEW(B_BUTTON)) else if (JOY_NEW(B_BUTTON))
{ {
structPtr->isPartyCondition = 0; // Exiting back to main search menu
structPtr->callback = ReturnToConditionSearchList; menu->saveResultsList = FALSE;
menu->callback = ReturnToConditionSearchList;
return CONDITION_SEARCH_FUNC_EXIT; return CONDITION_SEARCH_FUNC_EXIT;
} }
else if (JOY_NEW(A_BUTTON)) else if (JOY_NEW(A_BUTTON))
{ {
structPtr->monList->currIndex = GetSelectedPokenavListIndex(); // Entering graph menu
structPtr->isPartyCondition = 1; menu->monList->currIndex = GetSelectedPokenavListIndex();
structPtr->callback = OpenConditionGraphFromSearchList; menu->saveResultsList = TRUE;
menu->callback = OpenConditionGraphFromSearchList;
return CONDITION_SEARCH_FUNC_SELECT_MON; return CONDITION_SEARCH_FUNC_SELECT_MON;
} }
else else
return CONDITION_SEARCH_FUNC_NONE; return CONDITION_SEARCH_FUNC_NONE;
} }
static u32 ReturnToConditionSearchList(struct PokenavSub7 *structPtr) static u32 ReturnToConditionSearchList(struct Pokenav_SearchResults *menu)
{ {
return POKENAV_CONDITION_SEARCH_MENU; return POKENAV_CONDITION_SEARCH_MENU;
} }
static u32 OpenConditionGraphFromSearchList(struct PokenavSub7 *structPtr) static u32 OpenConditionGraphFromSearchList(struct Pokenav_SearchResults *menu)
{ {
return POKENAV_CONDITION_GRAPH_FROM_SEARCH; return POKENAV_CONDITION_GRAPH_SEARCH;
} }
static u32 sub_81CF0C0(void) static u32 GetReturningFromGraph(void)
{ {
struct PokenavSub7 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return structPtr->returnFromGraph; return menu->returnFromGraph;
} }
static struct PokenavMonList * GetSearchResultsMonDataList(void) static struct PokenavMonList * GetSearchResultsMonDataList(void)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->monList->monData; return menu->monList->monData;
} }
static u16 GetSearchResultsMonListCount(void) static u16 GetSearchResultsMonListCount(void)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->monList->listCount; return menu->monList->listCount;
} }
static s32 GetSearchResultsSelectedMonData(void) // data below has been set by ConvertConditionsToListRanks
static s32 GetSearchResultsSelectedMonRank(void)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 i = GetSelectedPokenavListIndex(); s32 i = GetSelectedPokenavListIndex();
return ptr->monList->monData[i].data; return menu->monList->monData[i].data;
} }
static u16 sub_81CF10C(void) static u16 GetSearchResultsCurrentListIndex(void)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
return ptr->monList->currIndex; return menu->monList->currIndex;
} }
static u32 GetConditionSearchLoopedTask(s32 state) static u32 GetConditionSearchLoopedTask(s32 state)
@ -257,11 +260,11 @@ static u32 BuildPartyMonSearchResults(s32 state)
{ {
s32 i; s32 i;
struct PokenavMonList item; struct PokenavMonList item;
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
ptr->monList->listCount = 0; menu->monList->listCount = 0;
ptr->monList->currIndex = 0; menu->monList->currIndex = 0;
item.boxId = 14; item.boxId = TOTAL_BOXES_COUNT;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
struct Pokemon * pokemon = &gPlayerParty[i]; struct Pokemon * pokemon = &gPlayerParty[i];
@ -270,8 +273,8 @@ static u32 BuildPartyMonSearchResults(s32 state)
if (!GetMonData(pokemon, MON_DATA_SANITY_IS_EGG)) if (!GetMonData(pokemon, MON_DATA_SANITY_IS_EGG))
{ {
item.monId = i; item.monId = i;
item.data = GetMonData(pokemon, ptr->conditionDataId); item.data = GetMonData(pokemon, menu->conditionDataId);
sub_81CF2C4(ptr, &item); InsertMonListItem(menu, &item);
} }
} }
@ -280,17 +283,17 @@ static u32 BuildPartyMonSearchResults(s32 state)
static u32 InitBoxMonSearchResults(s32 state) static u32 InitBoxMonSearchResults(s32 state)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
ptr->monId = 0; menu->monId = 0;
ptr->boxId = 0; menu->boxId = 0;
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
static u32 BuildBoxMonSearchResults(s32 state) static u32 BuildBoxMonSearchResults(s32 state)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 boxId = ptr->boxId; s32 boxId = menu->boxId;
s32 monId = ptr->monId; s32 monId = menu->monId;
s32 boxCount = 0; s32 boxCount = 0;
struct PokenavMonList item; struct PokenavMonList item;
@ -302,15 +305,15 @@ static u32 BuildBoxMonSearchResults(s32 state)
{ {
item.boxId = boxId; item.boxId = boxId;
item.monId = monId; item.monId = monId;
item.data = GetBoxMonDataAt(boxId, monId, ptr->conditionDataId); item.data = GetBoxMonDataAt(boxId, monId, menu->conditionDataId);
sub_81CF2C4(ptr, &item); InsertMonListItem(menu, &item);
} }
boxCount++; boxCount++;
monId++; monId++;
if (boxCount > 14) if (boxCount > TOTAL_BOXES_COUNT)
{ {
ptr->boxId = boxId; menu->boxId = boxId;
ptr->monId = monId; menu->monId = monId;
return LT_CONTINUE; return LT_CONTINUE;
} }
} }
@ -321,107 +324,111 @@ static u32 BuildBoxMonSearchResults(s32 state)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
static u32 sub_81CF278(s32 state) // Data below is initially set by BuildPartyMonSearchResults / BuildBoxMonSearchResults, and
// is the Pokémon's condition value for the condition they are sorted by.
// The condition value in data is then overwritten with their ranking.
static u32 ConvertConditionsToListRanks(s32 state)
{ {
struct PokenavSub7 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS); struct Pokenav_SearchResults * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS);
s32 r6 = ptr->monList->listCount; s32 listCount = menu->monList->listCount;
s32 r4 = ptr->monList->monData[0].data; s32 prevCondition = menu->monList->monData[0].data;
s32 i; s32 i;
ptr->monList->monData[0].data = 1; menu->monList->monData[0].data = 1;
for (i = 1; i < r6; i++) for (i = 1; i < listCount; i++)
{ {
if (ptr->monList->monData[i].data == r4) if (menu->monList->monData[i].data == prevCondition)
{ {
ptr->monList->monData[i].data = ptr->monList->monData[i - 1].data; // Same condition value as prev, share rank
menu->monList->monData[i].data = menu->monList->monData[i - 1].data;
} }
else else
{ {
r4 = ptr->monList->monData[i].data; prevCondition = menu->monList->monData[i].data;
ptr->monList->monData[i].data = i + 1; menu->monList->monData[i].data = i + 1;
} }
} }
ptr->returnFromGraph = 1; menu->returnFromGraph = TRUE;
return LT_FINISH; return LT_FINISH;
} }
static void sub_81CF2C4(struct PokenavSub7 *structPtr, struct PokenavMonList *item) static void InsertMonListItem(struct Pokenav_SearchResults *menu, struct PokenavMonList *item)
{ {
u32 left = 0; u32 left = 0;
u32 right = structPtr->monList->listCount; u32 right = menu->monList->listCount;
u32 insertionIdx = left + (right - left) / 2; u32 insertionIdx = left + (right - left) / 2;
while (right != insertionIdx) while (right != insertionIdx)
{ {
if (item->data > structPtr->monList->monData[insertionIdx].data) if (item->data > menu->monList->monData[insertionIdx].data)
right = insertionIdx; right = insertionIdx;
else else
left = insertionIdx + 1; left = insertionIdx + 1;
insertionIdx = left + (right - left) / 2; insertionIdx = left + (right - left) / 2;
} }
for (right = structPtr->monList->listCount; right > insertionIdx; right--) for (right = menu->monList->listCount; right > insertionIdx; right--)
structPtr->monList->monData[right] = structPtr->monList->monData[right - 1]; menu->monList->monData[right] = menu->monList->monData[right - 1];
structPtr->monList->monData[insertionIdx] = *item; menu->monList->monData[insertionIdx] = *item;
structPtr->monList->listCount++; menu->monList->listCount++;
} }
bool32 OpenConditionSearchResults(void) bool32 OpenConditionSearchResults(void)
{ {
struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8)); struct Pokenav_SearchResultsGfx *gfx = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX, sizeof(struct Pokenav_SearchResultsGfx));
if (searchList == NULL) if (gfx == NULL)
return FALSE; return FALSE;
searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1); gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1);
searchList->callback = GetSearchResultCurrentLoopedTaskActive; gfx->callback = GetSearchResultCurrentLoopedTaskActive;
searchList->fromGraph = FALSE; gfx->fromGraph = FALSE;
return TRUE; return TRUE;
} }
bool32 OpenConditionSearchListFromGraph(void) bool32 OpenConditionSearchListFromGraph(void)
{ {
struct PokenavSub8 *searchList = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST, sizeof(struct PokenavSub8)); struct Pokenav_SearchResultsGfx *gfx = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX, sizeof(struct Pokenav_SearchResultsGfx));
if (searchList == NULL) if (gfx == NULL)
return FALSE; return FALSE;
searchList->ltid = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1); gfx->loopedTaskId = CreateLoopedTask(LoopedTask_OpenConditionSearchResults, 1);
searchList->callback = GetSearchResultCurrentLoopedTaskActive; gfx->callback = GetSearchResultCurrentLoopedTaskActive;
searchList->fromGraph = TRUE; gfx->fromGraph = TRUE;
return TRUE; return TRUE;
} }
void CreateSearchResultsLoopedTask(s32 idx) void CreateSearchResultsLoopedTask(s32 idx)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
searchList->ltid = CreateLoopedTask(sSearchResultLoopTaskFuncs[idx], 1); gfx->loopedTaskId = CreateLoopedTask(sSearchResultLoopTaskFuncs[idx], 1);
searchList->callback = GetSearchResultCurrentLoopedTaskActive; gfx->callback = GetSearchResultCurrentLoopedTaskActive;
} }
bool32 IsSearchResultLoopedTaskActive(void) bool32 IsSearchResultLoopedTaskActive(void)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
return searchList->callback(); return gfx->callback();
} }
bool32 GetSearchResultCurrentLoopedTaskActive(void) bool32 GetSearchResultCurrentLoopedTaskActive(void)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
return IsLoopedTaskActive(searchList->ltid); return IsLoopedTaskActive(gfx->loopedTaskId);
} }
void FreeSearchResultSubstruct2(void) void FreeSearchResultSubstruct2(void)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
sub_81C8234(); sub_81C8234();
RemoveWindow(searchList->winid); RemoveWindow(gfx->winid);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
} }
static u32 LoopedTask_OpenConditionSearchResults(s32 state) static u32 LoopedTask_OpenConditionSearchResults(s32 state)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
InitBgTemplates(sConditionSearchResultBgTemplates, ARRAY_COUNT(sConditionSearchResultBgTemplates)); InitBgTemplates(sConditionSearchResultBgTemplates, ARRAY_COUNT(sConditionSearchResultBgTemplates));
DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0); DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0);
SetBgTilemapBuffer(1, searchList->buff); SetBgTilemapBuffer(1, gfx->buff);
CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0); CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);
CopyPaletteIntoBufferUnfaded(sConditionSearchResultFramePal, 0x10, 0x20); CopyPaletteIntoBufferUnfaded(sConditionSearchResultFramePal, 0x10, 0x20);
@ -430,19 +437,19 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state)
case 1: case 1:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
if (!sub_81CF0C0()) if (!GetReturningFromGraph())
return LT_PAUSE; return LT_PAUSE;
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 2: case 2:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 32); CopyPaletteIntoBufferUnfaded(sListBg_Pal, 0x20, 32);
InitConditionSearchListMenuTemplate(); InitConditionSearchListMenuTemplate();
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (sub_81C8224()) if (sub_81C8224())
return LT_PAUSE; return LT_PAUSE;
AddSearchResultListMenuWindow(searchList); AddSearchResultListMenuWindow(gfx);
PrintHelpBarText(HELPBAR_CONDITION_MON_LIST); PrintHelpBarText(HELPBAR_CONDITION_MON_LIST);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 4: case 4:
@ -453,7 +460,7 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state)
ShowBg(1); ShowBg(1);
ShowBg(2); ShowBg(2);
HideBg(3); HideBg(3);
if (!searchList->fromGraph) if (!gfx->fromGraph)
{ {
u8 searchGfxId = GetSelectedConditionSearch() + POKENAV_MENUITEM_CONDITION_SEARCH_COOL; u8 searchGfxId = GetSelectedConditionSearch() + POKENAV_MENUITEM_CONDITION_SEARCH_COOL;
LoadLeftHeaderGfxForIndex(searchGfxId); LoadLeftHeaderGfxForIndex(searchGfxId);
@ -474,7 +481,7 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state)
static u32 LoopedTask_MoveSearchListCursorUp(s32 state) static u32 LoopedTask_MoveSearchListCursorUp(s32 state)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
@ -495,7 +502,7 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state)
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
PrintSearchResultListMenuItems(searchList); PrintSearchResultListMenuItems(gfx);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -507,7 +514,7 @@ static u32 LoopedTask_MoveSearchListCursorUp(s32 state)
static u32 LoopedTask_MoveSearchListCursorDown(s32 state) static u32 LoopedTask_MoveSearchListCursorDown(s32 state)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
@ -528,7 +535,7 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state)
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
PrintSearchResultListMenuItems(searchList); PrintSearchResultListMenuItems(gfx);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -540,7 +547,7 @@ static u32 LoopedTask_MoveSearchListCursorDown(s32 state)
static u32 LoopedTask_MoveSearchListPageUp(s32 state) static u32 LoopedTask_MoveSearchListPageUp(s32 state)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
@ -561,7 +568,7 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state)
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
PrintSearchResultListMenuItems(searchList); PrintSearchResultListMenuItems(gfx);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -573,7 +580,7 @@ static u32 LoopedTask_MoveSearchListPageUp(s32 state)
static u32 LoopedTask_MoveSearchListPageDown(s32 state) static u32 LoopedTask_MoveSearchListPageDown(s32 state)
{ {
struct PokenavSub8 *searchList = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULT_LIST); struct Pokenav_SearchResultsGfx *gfx = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_SEARCH_RESULTS_GFX);
switch (state) switch (state)
{ {
case 0: case 0:
@ -594,7 +601,7 @@ static u32 LoopedTask_MoveSearchListPageDown(s32 state)
return LT_PAUSE; return LT_PAUSE;
// fallthrough // fallthrough
case 2: case 2:
PrintSearchResultListMenuItems(searchList); PrintSearchResultListMenuItems(gfx);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@ -640,25 +647,25 @@ static u32 LoopedTask_SelectSearchResult(s32 state)
return LT_FINISH; return LT_FINISH;
} }
static void AddSearchResultListMenuWindow(struct PokenavSub8 *searchList) static void AddSearchResultListMenuWindow(struct Pokenav_SearchResultsGfx *gfx)
{ {
searchList->winid = AddWindow(&sSearchResultListMenuWindowTemplate); gfx->winid = AddWindow(&sSearchResultListMenuWindowTemplate);
PutWindowTilemap(searchList->winid); PutWindowTilemap(gfx->winid);
CopyWindowToVram(searchList->winid, COPYWIN_MAP); CopyWindowToVram(gfx->winid, COPYWIN_MAP);
PrintSearchResultListMenuItems(searchList); PrintSearchResultListMenuItems(gfx);
} }
static void PrintSearchResultListMenuItems(struct PokenavSub8 *searchList) static void PrintSearchResultListMenuItems(struct Pokenav_SearchResultsGfx *gfx)
{ {
s32 r7 = GetSearchResultsSelectedMonData(); s32 rank = GetSearchResultsSelectedMonRank();
DynamicPlaceholderTextUtil_Reset(); DynamicPlaceholderTextUtil_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
*gStringVar1 = EOS; *gStringVar1 = EOS;
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberF700); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberIndex);
AddTextPrinterParameterized(searchList->winid, FONT_NORMAL, gStringVar2, 4, 1, TEXT_SKIP_DRAW, NULL); AddTextPrinterParameterized(gfx->winid, FONT_NORMAL, gStringVar2, 4, 1, TEXT_SKIP_DRAW, NULL);
ConvertIntToDecimalStringN(gStringVar1, r7, STR_CONV_MODE_RIGHT_ALIGN, 3); ConvertIntToDecimalStringN(gStringVar1, rank, STR_CONV_MODE_RIGHT_ALIGN, 3);
AddTextPrinterParameterized(searchList->winid, FONT_NORMAL, gStringVar1, 34, 1, TEXT_SKIP_DRAW, NULL); AddTextPrinterParameterized(gfx->winid, FONT_NORMAL, gStringVar1, 34, 1, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(searchList->winid, COPYWIN_GFX); CopyWindowToVram(gfx->winid, COPYWIN_GFX);
} }
static void InitConditionSearchListMenuTemplate(void) static void InitConditionSearchListMenuTemplate(void)
@ -668,7 +675,7 @@ static void InitConditionSearchListMenuTemplate(void)
template.list.monList = GetSearchResultsMonDataList(); template.list.monList = GetSearchResultsMonDataList();
template.count = GetSearchResultsMonListCount(); template.count = GetSearchResultsMonListCount();
template.unk8 = 4; template.unk8 = 4;
template.unk6 = sub_81CF10C(); template.unk6 = GetSearchResultsCurrentListIndex();
template.item_X = 13; template.item_X = 13;
template.windowWidth = 17; template.windowWidth = 17;
template.listTop = 1; template.listTop = 1;

View File

@ -355,7 +355,7 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state)
return POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH; return POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH;
case POKENAV_MENUITEM_CONDITION_PARTY: case POKENAV_MENUITEM_CONDITION_PARTY:
state->helpBarIndex = 0; state->helpBarIndex = 0;
SetMenuIdAndCB(state, POKENAV_CONDITION_PARTY); SetMenuIdAndCB(state, POKENAV_CONDITION_GRAPH_PARTY);
return POKENAV_MENU_FUNC_OPEN_FEATURE; return POKENAV_MENU_FUNC_OPEN_FEATURE;
case POKENAV_MENUITEM_CONDITION_CANCEL: case POKENAV_MENUITEM_CONDITION_CANCEL:
PlaySE(SE_SELECT); PlaySE(SE_SELECT);

View File

@ -359,7 +359,7 @@ bool32 OpenPokenavMenuNotInitial(void)
static struct Pokenav2Struct * OpenPokenavMenu(void) static struct Pokenav2Struct * OpenPokenavMenu(void)
{ {
struct Pokenav2Struct * state = AllocSubstruct(2, sizeof(struct Pokenav2Struct)); struct Pokenav2Struct * state = AllocSubstruct(POKENAV_SUBSTRUCT_MENU_ICONS, sizeof(struct Pokenav2Struct));
if (state != NULL) if (state != NULL)
{ {

View File

@ -990,7 +990,7 @@ const u8 gText_Unknown[] = _("UNKNOWN");
const u8 gText_Call[] = _("CALL"); const u8 gText_Call[] = _("CALL");
const u8 gText_Check[] = _("CHECK"); const u8 gText_Check[] = _("CHECK");
const u8 gText_Cancel6[] = _("CANCEL"); const u8 gText_Cancel6[] = _("CANCEL");
const u8 gText_NumberF700[] = _("No. {DYNAMIC 0}"); const u8 gText_NumberIndex[] = _("No. {DYNAMIC 0}");
const u8 gText_RibbonsF700[] = _("RIBBONS {DYNAMIC 0}"); const u8 gText_RibbonsF700[] = _("RIBBONS {DYNAMIC 0}");
const u8 gText_PokemonMaleLv2[] = _("{DYNAMIC 0}{COLOR_HIGHLIGHT_SHADOW LIGHT_RED WHITE GREEN}♂{COLOR_HIGHLIGHT_SHADOW DARK_GRAY WHITE LIGHT_GRAY}/{LV}{DYNAMIC 1}{DYNAMIC 2}"); // Unused const u8 gText_PokemonMaleLv2[] = _("{DYNAMIC 0}{COLOR_HIGHLIGHT_SHADOW LIGHT_RED WHITE GREEN}♂{COLOR_HIGHLIGHT_SHADOW DARK_GRAY WHITE LIGHT_GRAY}/{LV}{DYNAMIC 1}{DYNAMIC 2}"); // Unused
const u8 gText_PokemonFemaleLv2[] = _("{DYNAMIC 0}{COLOR_HIGHLIGHT_SHADOW LIGHT_GREEN WHITE BLUE}♀{COLOR_HIGHLIGHT_SHADOW DARK_GRAY WHITE LIGHT_GRAY}/{LV}{DYNAMIC 1}{DYNAMIC 2}"); // Unused const u8 gText_PokemonFemaleLv2[] = _("{DYNAMIC 0}{COLOR_HIGHLIGHT_SHADOW LIGHT_GREEN WHITE BLUE}♀{COLOR_HIGHLIGHT_SHADOW DARK_GRAY WHITE LIGHT_GRAY}/{LV}{DYNAMIC 1}{DYNAMIC 2}"); // Unused

View File

@ -1577,9 +1577,9 @@ static void SpriteCB_MonPic(struct Sprite *sprite)
static void SpriteCB_SelectionIconPokeball(struct Sprite *sprite) static void SpriteCB_SelectionIconPokeball(struct Sprite *sprite)
{ {
if (sprite->data[0] == sMenu->info.curSelection) if (sprite->data[0] == sMenu->info.curSelection)
StartSpriteAnim(sprite, 0); StartSpriteAnim(sprite, CONDITION_ICON_SELECTED);
else else
StartSpriteAnim(sprite, 1); StartSpriteAnim(sprite, CONDITION_ICON_UNSELECTED);
} }
static void SpriteCB_SelectionIconCancel(struct Sprite *sprite) static void SpriteCB_SelectionIconCancel(struct Sprite *sprite)