pokeemerald/src/pokenav_conditions_1.c

625 lines
20 KiB
C
Raw Normal View History

2019-07-25 18:56:08 +02:00
#include "global.h"
#include "data.h"
#include "decompress.h"
#include "main.h"
#include "menu_specialized.h"
#include "mon_markings.h"
#include "pokenav.h"
#include "pokemon.h"
#include "pokemon_storage_system.h"
#include "sound.h"
#include "string_util.h"
#include "strings.h"
#include "text.h"
#include "constants/songs.h"
struct PokenavSub11
{
u32 monPal[3][0x20];
u8 fill[0x180];
2021-03-29 15:38:19 +02:00
u32 monPicGfx[3][MON_PIC_SIZE];
2020-10-11 00:17:34 +02:00
u8 searchMode;
s16 monIndex;
u32 (*callback)(struct PokenavSub11 *);
2019-07-25 18:56:08 +02:00
u8 fill2[0x6320 - 0x6308];
2020-10-11 00:17:34 +02:00
u8 searchLocBuffer[3][24];
u8 nameBuffer[3][64];
struct ConditionGraph conditionData;
u8 sheen[3];
u8 monMarks[3];
s8 mark;
2019-07-25 18:56:08 +02:00
s8 unk6787;
s8 unk6788;
s8 unk6789;
2020-10-11 00:17:34 +02:00
u8 state;
2019-07-25 18:56:08 +02:00
};
2020-10-11 00:17:34 +02:00
void InitPartyConditionListParameters(void);
2019-07-25 18:56:08 +02:00
void sub_81CD9F8(void);
2020-10-11 00:17:34 +02:00
u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr);
u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr);
u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr);
u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr);
u8 SwitchConditionSummaryIndex(u8 moveUp);
void CopyMonNameGenderLocation(s16 id, u8 arg1);
void GetMonConditionGraphData(s16 id, u8 arg1);
void ConditionGraphDrawMonPic(s16 id, u8 arg1);
2019-07-25 18:56:08 +02:00
// code
2020-10-11 00:17:34 +02:00
bool32 PokenavCallback_Init_PartyCondition(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11));
2019-07-25 18:56:08 +02:00
if (structPtr == NULL)
return FALSE;
2020-10-11 00:17:34 +02:00
InitConditionGraphData(&structPtr->conditionData);
InitPartyConditionListParameters();
2019-07-25 18:56:08 +02:00
gKeyRepeatStartDelay = 20;
2020-10-11 00:17:34 +02:00
structPtr->callback = HandlePartyConditionInput;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2020-10-11 00:17:34 +02:00
bool32 PokenavCallback_Init_ConditionGraphFromSearch(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11));
2019-07-25 18:56:08 +02:00
if (structPtr == NULL)
return FALSE;
2020-10-11 00:17:34 +02:00
InitConditionGraphData(&structPtr->conditionData);
2019-07-25 18:56:08 +02:00
sub_81CD9F8();
gKeyRepeatStartDelay = 20;
2020-10-11 00:17:34 +02:00
structPtr->callback = HandlePartyConditionInput;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2020-10-11 00:17:34 +02:00
u32 GetPartyConditionCallback(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
return structPtr->callback(structPtr);
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u32 ret = ConditionGraphHandleDpadInput(structPtr);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
if (ret == PARTY_CONDITION_FUNC_NONE)
2019-07-25 18:56:08 +02:00
{
2020-09-05 03:11:55 +02:00
if (JOY_NEW(B_BUTTON))
2019-07-25 18:56:08 +02:00
{
PlaySE(SE_SELECT);
2020-10-11 00:17:34 +02:00
structPtr->callback = GetConditionReturnCallback;
ret = PARTY_CONDITION_FUNC_RETURN;
2019-07-25 18:56:08 +02:00
}
2020-09-05 03:11:55 +02:00
else if (JOY_NEW(A_BUTTON))
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (structPtr->searchMode == 0)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (monListPtr->currIndex == monListPtr->listCount - 1)
2019-07-25 18:56:08 +02:00
{
PlaySE(SE_SELECT);
2020-10-11 00:17:34 +02:00
structPtr->callback = GetConditionReturnCallback;
ret = PARTY_CONDITION_FUNC_RETURN;
2019-07-25 18:56:08 +02:00
}
}
else
{
PlaySE(SE_SELECT);
2020-10-11 00:17:34 +02:00
ret = PARTY_CONDITION_FUNC_ADD_MARKINGS;
structPtr->callback = ConditionMenu_OpenMarkingsMenu;
2019-07-25 18:56:08 +02:00
}
}
}
return ret;
}
2020-10-11 00:17:34 +02:00
u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr;
2019-07-25 18:56:08 +02:00
u8 markings;
2020-10-11 00:17:34 +02:00
u32 ret = PARTY_CONDITION_FUNC_NONE, boxId, monId;
2019-07-25 18:56:08 +02:00
2021-02-28 23:22:26 +01:00
if (!HandleMonMarkingsMenuInput())
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
structPtr->monMarks[structPtr->mark] = GetMonMarkingsData();
monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[monListPtr->currIndex].boxId;
monId = monListPtr->monData[monListPtr->currIndex].monId;
markings = structPtr->monMarks[structPtr->mark];
2019-07-25 18:56:08 +02:00
if (boxId == TOTAL_BOXES_COUNT)
SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings);
else
SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings);
2020-10-11 00:17:34 +02:00
structPtr->callback = HandlePartyConditionInput;
ret = PARTY_CONDITION_FUNC_CLOSE_MARKINGS;
2019-07-25 18:56:08 +02:00
}
return ret;
}
2020-10-11 00:17:34 +02:00
u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (structPtr->searchMode == 0)
2020-02-05 08:47:32 +01:00
return POKENAV_CONDITION_MENU;
2019-07-25 18:56:08 +02:00
else
2020-10-11 00:17:34 +02:00
return POKENAV_RETURN_CONDITION_SEARCH;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
void FreePartyConditionSubstruct1(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 0)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
u8 ret = 0;
2020-09-05 03:11:55 +02:00
if (JOY_HELD(DPAD_UP))
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (structPtr->searchMode == 0 || monListPtr->currIndex != 0)
2019-07-25 18:56:08 +02:00
{
PlaySE(SE_SELECT);
2020-10-11 00:17:34 +02:00
ret = SwitchConditionSummaryIndex(1);
2019-07-25 18:56:08 +02:00
}
}
2020-09-05 03:11:55 +02:00
else if (JOY_HELD(DPAD_DOWN))
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1)
2019-07-25 18:56:08 +02:00
{
PlaySE(SE_SELECT);
2020-10-11 00:17:34 +02:00
ret = SwitchConditionSummaryIndex(0);
2019-07-25 18:56:08 +02:00
}
}
return ret;
}
2020-10-11 00:17:34 +02:00
u8 SwitchConditionSummaryIndex(u8 moveUp)
2019-07-25 18:56:08 +02:00
{
u16 r7;
2020-10-11 00:17:34 +02:00
bool8 wasNotLastMon, isNotLastMon;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
r7 = (moveUp) ? structPtr->unk6788 : structPtr->unk6787;
sub_81D1F84(&structPtr->conditionData, structPtr->conditionData.unk14[structPtr->mark], structPtr->conditionData.unk14[r7]);
wasNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1));
if (moveUp)
2019-07-25 18:56:08 +02:00
{
structPtr->unk6788 = structPtr->unk6787;
2020-10-11 00:17:34 +02:00
structPtr->unk6787 = structPtr->mark;
structPtr->mark = r7;
2019-07-25 18:56:08 +02:00
structPtr->unk6789 = structPtr->unk6788;
2020-10-11 00:17:34 +02:00
monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1;
structPtr->monIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1;
2019-07-25 18:56:08 +02:00
}
else
{
structPtr->unk6787 = structPtr->unk6788;
2020-10-11 00:17:34 +02:00
structPtr->unk6788 = structPtr->mark;
structPtr->mark = r7;
2019-07-25 18:56:08 +02:00
structPtr->unk6789 = structPtr->unk6787;
2020-10-11 00:17:34 +02:00
monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
structPtr->monIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
isNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1));
if (!wasNotLastMon)
return PARTY_CONDITION_FUNC_NO_TRANSITION;
else if (!isNotLastMon)
return PARTY_CONDITION_FUNC_SLIDE_MON_OUT;
2019-07-25 18:56:08 +02:00
else
2020-10-11 00:17:34 +02:00
return PARTY_CONDITION_FUNC_SLIDE_MON_IN;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
bool32 LoadPartyConditionMenuGfx(void)
2019-07-25 18:56:08 +02:00
{
s32 var;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
switch (structPtr->state)
2019-07-25 18:56:08 +02:00
{
case 0:
2020-10-11 00:17:34 +02:00
CopyMonNameGenderLocation(monListPtr->currIndex, 0);
2019-07-25 18:56:08 +02:00
break;
case 1:
2020-10-11 00:17:34 +02:00
GetMonConditionGraphData(monListPtr->currIndex, 0);
2019-07-25 18:56:08 +02:00
break;
case 2:
2020-10-11 00:17:34 +02:00
ConditionGraphDrawMonPic(monListPtr->currIndex, 0);
2019-07-25 18:56:08 +02:00
break;
case 3:
2020-10-11 00:17:34 +02:00
if (monListPtr->listCount == 1)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
structPtr->mark = 0;
2019-07-25 18:56:08 +02:00
structPtr->unk6787 = 0;
structPtr->unk6788 = 0;
2020-10-11 00:17:34 +02:00
structPtr->state = 0;
2019-07-25 18:56:08 +02:00
return TRUE;
}
else
{
2020-10-11 00:17:34 +02:00
structPtr->mark = 0;
2019-07-25 18:56:08 +02:00
structPtr->unk6787 = 1;
structPtr->unk6788 = 2;
}
break;
// These were probably ternaries just like cases 7-9, but couldn't match it any other way.
case 4:
2020-10-11 00:17:34 +02:00
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
2019-07-25 18:56:08 +02:00
var = 0;
2020-10-11 00:17:34 +02:00
CopyMonNameGenderLocation(var, 1);
2019-07-25 18:56:08 +02:00
break;
case 5:
2020-10-11 00:17:34 +02:00
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
2019-07-25 18:56:08 +02:00
var = 0;
2020-10-11 00:17:34 +02:00
GetMonConditionGraphData(var, 1);
2019-07-25 18:56:08 +02:00
break;
case 6:
2020-10-11 00:17:34 +02:00
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
2019-07-25 18:56:08 +02:00
var = 0;
2020-10-11 00:17:34 +02:00
ConditionGraphDrawMonPic(var, 1);
2019-07-25 18:56:08 +02:00
break;
case 7:
2020-10-11 00:17:34 +02:00
CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
2019-07-25 18:56:08 +02:00
break;
case 8:
2020-10-11 00:17:34 +02:00
GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
2019-07-25 18:56:08 +02:00
break;
case 9:
2020-10-11 00:17:34 +02:00
ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
structPtr->state = 0;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2020-10-11 00:17:34 +02:00
structPtr->state++;
2019-07-25 18:56:08 +02:00
return FALSE;
}
2020-10-11 00:17:34 +02:00
bool32 SetConditionGraphData(u8 mode)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
switch (mode)
2019-07-25 18:56:08 +02:00
{
case 0:
2020-10-11 00:17:34 +02:00
CopyMonNameGenderLocation(structPtr->monIndex, structPtr->unk6789);
2019-07-25 18:56:08 +02:00
break;
case 1:
2020-10-11 00:17:34 +02:00
GetMonConditionGraphData(structPtr->monIndex, structPtr->unk6789);
2019-07-25 18:56:08 +02:00
break;
case 2:
2020-10-11 00:17:34 +02:00
ConditionGraphDrawMonPic(structPtr->monIndex, structPtr->unk6789);
2019-07-25 18:56:08 +02:00
return TRUE;
}
return FALSE;
}
2020-10-11 00:17:34 +02:00
u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n)
2019-07-25 18:56:08 +02:00
{
while (*src != EOS)
*dst++ = *src++, n--;
while (n-- > 0)
*dst++ = CHAR_SPACE;
*dst = EOS;
return dst;
}
2020-10-11 00:17:34 +02:00
u8 *CopyMonConditionNameGender(u8 *str, u16 id, bool8 arg3)
2019-07-25 18:56:08 +02:00
{
u16 boxId, monId, gender, species, level, lvlDigits;
struct BoxPokemon *boxMon;
u8 *txtPtr, *str_;
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
boxId = monListPtr->monData[id].boxId;
monId = monListPtr->monData[id].monId;
2019-07-25 18:56:08 +02:00
*(str++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str++) = TEXT_COLOR_BLUE;
*(str++) = TEXT_COLOR_TRANSPARENT;
*(str++) = TEXT_COLOR_LIGHT_BLUE;
2019-07-25 18:56:08 +02:00
if (GetBoxOrPartyMonData(boxId, monId, MON_DATA_IS_EGG, NULL))
return StringCopyPadded(str, gText_EggNickname, CHAR_SPACE, 12);
GetBoxOrPartyMonData(boxId, monId, MON_DATA_NICKNAME, str);
StringGetEnd10(str);
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES, NULL);
if (boxId == TOTAL_BOXES_COUNT)
{
level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
gender = GetMonGender(&gPlayerParty[monId]);
}
else
{
boxMon = GetBoxedMonPtr(boxId, monId);
gender = GetBoxMonGender(boxMon);
level = GetLevelFromBoxMonExp(boxMon);
}
if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(str, gSpeciesNames[species]))
gender = MON_GENDERLESS;
str_ = str; // For some reason, a variable is needed to match.
while (*str_ != EOS)
2019-08-05 21:49:05 +02:00
(str_++);
2019-07-25 18:56:08 +02:00
*(str_++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str_++) = EXT_CTRL_CODE_SKIP;
*(str_++) = 60;
2019-07-25 18:56:08 +02:00
switch (gender)
{
default:
2020-08-11 05:50:49 +02:00
*(str_++) = CHAR_UNK_SPACER;
2019-07-25 18:56:08 +02:00
break;
case MON_MALE:
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR;
2020-08-11 05:50:49 +02:00
*(str_++) = TEXT_COLOR_RED;
2019-07-25 18:56:08 +02:00
*(str_++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str_++) = EXT_CTRL_CODE_SHADOW;
*(str_++) = TEXT_COLOR_LIGHT_RED;
2019-07-25 18:56:08 +02:00
*(str_++) = CHAR_MALE;
break;
case MON_FEMALE:
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR;
2020-08-11 05:50:49 +02:00
*(str_++) = TEXT_COLOR_GREEN;
2019-07-25 18:56:08 +02:00
*(str_++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str_++) = EXT_CTRL_CODE_SHADOW;
*(str_++) = TEXT_COLOR_LIGHT_GREEN;
2019-07-25 18:56:08 +02:00
*(str_++) = CHAR_FEMALE;
break;
}
*(str_++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str_++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str_++) = TEXT_COLOR_BLUE;
*(str_++) = TEXT_COLOR_TRANSPARENT;
*(str_++) = TEXT_COLOR_LIGHT_BLUE;
2019-07-25 18:56:08 +02:00
*(str_++) = CHAR_SLASH;
2020-08-11 05:50:49 +02:00
*(str_++) = CHAR_EXTRA_SYMBOL;
2020-02-01 06:25:50 +01:00
*(str_++) = CHAR_LV_2;
2019-07-25 18:56:08 +02:00
txtPtr = str_;
str_ = ConvertIntToDecimalStringN(str_, level, STR_CONV_MODE_LEFT_ALIGN, 3);
lvlDigits = str_ - txtPtr;
*(str_++) = CHAR_SPACE;
if (!arg3)
{
lvlDigits = 3 - lvlDigits;
while (lvlDigits-- != 0)
*(str_++) = CHAR_SPACE;
}
*str_ = EOS;
return str_;
}
2020-10-11 00:17:34 +02:00
void CopyMonNameGenderLocation(s16 id, u8 arg1)
2019-07-25 18:56:08 +02:00
{
u16 boxId, i;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
CopyMonConditionNameGender(structPtr->nameBuffer[arg1], id, FALSE);
boxId = monListPtr->monData[id].boxId;
structPtr->searchLocBuffer[arg1][0] = EXT_CTRL_CODE_BEGIN;
structPtr->searchLocBuffer[arg1][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
structPtr->searchLocBuffer[arg1][2] = TEXT_COLOR_BLUE;
structPtr->searchLocBuffer[arg1][3] = TEXT_COLOR_TRANSPARENT;
structPtr->searchLocBuffer[arg1][4] = TEXT_COLOR_LIGHT_BLUE;
2019-07-25 18:56:08 +02:00
if (boxId == TOTAL_BOXES_COUNT)
2020-10-11 00:17:34 +02:00
CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], gText_InParty, 8);
2019-07-25 18:56:08 +02:00
else
2020-10-11 00:17:34 +02:00
CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], GetBoxNamePtr(boxId), 8);
2019-07-25 18:56:08 +02:00
}
else
{
for (i = 0; i < 12; i++)
2020-10-11 00:17:34 +02:00
structPtr->nameBuffer[arg1][i] = CHAR_SPACE;
structPtr->nameBuffer[arg1][i] = EOS;
2019-07-25 18:56:08 +02:00
for (i = 0; i < 8; i++)
2020-10-11 00:17:34 +02:00
structPtr->searchLocBuffer[arg1][i] = CHAR_SPACE;
structPtr->searchLocBuffer[arg1][i] = EOS;
2019-07-25 18:56:08 +02:00
}
}
2020-10-11 00:17:34 +02:00
void InitPartyConditionListParameters(void)
2019-07-25 18:56:08 +02:00
{
u16 i, count;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
structPtr->searchMode = 0;
2019-07-25 18:56:08 +02:00
for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++)
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
{
2020-10-11 00:17:34 +02:00
monListPtr->monData[count].boxId = TOTAL_BOXES_COUNT;
monListPtr->monData[count].monId = i;
monListPtr->monData[count].data = 0;
2019-07-25 18:56:08 +02:00
count++;
}
}
2020-10-11 00:17:34 +02:00
monListPtr->monData[count].boxId = 0;
monListPtr->monData[count].monId = 0;
monListPtr->monData[count].data = 0;
monListPtr->currIndex = 0;
monListPtr->listCount = count + 1;
structPtr->state = 0;
2019-07-25 18:56:08 +02:00
}
void sub_81CD9F8(void)
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
structPtr->searchMode = 1;
structPtr->state = 0;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
void GetMonConditionGraphData(s16 id, u8 arg1)
2019-07-25 18:56:08 +02:00
{
u16 boxId, monId, i;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
boxId = monListPtr->monData[id].boxId;
monId = monListPtr->monData[id].monId;
structPtr->conditionData.stat[arg1][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
structPtr->conditionData.stat[arg1][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
structPtr->conditionData.stat[arg1][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
structPtr->conditionData.stat[arg1][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
structPtr->conditionData.stat[arg1][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
structPtr->sheen[arg1] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 255)
2019-07-25 18:56:08 +02:00
? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u
: 9;
2020-10-11 00:17:34 +02:00
structPtr->monMarks[arg1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
sub_81D2754(structPtr->conditionData.stat[arg1], structPtr->conditionData.unk14[arg1]);
2019-07-25 18:56:08 +02:00
}
else
{
2020-10-11 00:17:34 +02:00
for (i = 0; i < FLAVOR_COUNT; i++)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
structPtr->conditionData.stat[arg1][i] = 0;
structPtr->conditionData.unk14[arg1][i].unk0 = 155;
structPtr->conditionData.unk14[arg1][i].unk2 = 91;
2019-07-25 18:56:08 +02:00
}
}
}
2020-10-11 00:17:34 +02:00
void ConditionGraphDrawMonPic(s16 index, u8 arg1)
2019-07-25 18:56:08 +02:00
{
u16 boxId, monId, species;
u32 personality, tid;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
if (index == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
2019-07-25 18:56:08 +02:00
return;
2020-10-11 00:17:34 +02:00
boxId = monListPtr->monData[index].boxId;
monId = monListPtr->monData[index].monId;
2019-07-25 18:56:08 +02:00
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL);
tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL);
personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL);
LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[arg1], species, personality, TRUE);
LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[arg1]);
}
2020-10-11 00:17:34 +02:00
u16 GetMonListCount(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->listCount;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u16 GetConditionGraphCurrentMonIndex(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->currIndex;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
struct ConditionGraph *GetConditionGraphDataPtr(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return &structPtr->conditionData;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u8 GetMonMarkIndex(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->mark;
2019-07-25 18:56:08 +02:00
}
u8 sub_81CDC9C(void)
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->monIndex;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
void *GetConditionMonPicGfx(u8 id)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
return structPtr->monPicGfx[id];
}
2020-10-11 00:17:34 +02:00
void *GetConditionMonPal(u8 id)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
return structPtr->monPal[id];
}
u8 sub_81CDCEC(void)
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
return structPtr->unk6789;
}
2020-10-11 00:17:34 +02:00
u8 *GetConditionMonNameBuffer(u8 id)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->nameBuffer[id];
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u8 *GetConditionMonLocationBuffer(u8 id)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->searchLocBuffer[id];
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u16 GetConditionMonDataBuffer(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->monData[monListPtr->currIndex].data;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
bool32 IsConditionMenuSearchMode(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 1)
2019-07-25 18:56:08 +02:00
return TRUE;
else
return FALSE;
}
2020-10-11 00:17:34 +02:00
u8 TryGetMonMarkId(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 1)
return structPtr->monMarks[structPtr->mark];
2019-07-25 18:56:08 +02:00
else
return 0;
}
2020-10-11 00:17:34 +02:00
u8 GetMonSheen(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->sheen[structPtr->mark];
2019-07-25 18:56:08 +02:00
}