2019-04-14 17:13:51 +02:00
|
|
|
#include "global.h"
|
2019-04-14 20:21:06 +02:00
|
|
|
#include "battle_setup.h"
|
|
|
|
#include "data.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "gym_leader_rematch.h"
|
|
|
|
#include "international_string_util.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "match_call.h"
|
|
|
|
#include "overworld.h"
|
|
|
|
#include "pokemon.h"
|
2019-04-14 17:13:51 +02:00
|
|
|
#include "pokenav.h"
|
2019-04-14 20:21:06 +02:00
|
|
|
#include "sound.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "constants/songs.h"
|
2019-04-14 17:13:51 +02:00
|
|
|
|
|
|
|
struct Pokenav3Struct
|
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
u16 optionCursorPos;
|
|
|
|
u16 maxOptionId;
|
2019-12-05 21:33:36 +01:00
|
|
|
const u8 *matchCallOptions;
|
|
|
|
u16 headerId;
|
2019-12-07 10:08:21 +01:00
|
|
|
u16 numRegistered;
|
2019-04-14 20:21:06 +02:00
|
|
|
u16 unkC;
|
2019-04-14 17:13:51 +02:00
|
|
|
u32 unk10;
|
|
|
|
u32 unk14;
|
2019-04-14 20:21:06 +02:00
|
|
|
u32 (*callback)(struct Pokenav3Struct*);
|
2019-12-15 16:25:47 +01:00
|
|
|
struct PokenavMatchCallEntries matchCallEntries[MAX_REMATCH_ENTRIES - 1];
|
2019-04-14 17:13:51 +02:00
|
|
|
};
|
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *);
|
2020-02-05 08:47:32 +01:00
|
|
|
static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *);
|
2019-12-07 10:08:21 +01:00
|
|
|
static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *);
|
|
|
|
static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *);
|
|
|
|
static u32 CB2_HandleCallInput(struct Pokenav3Struct *);
|
2019-07-19 02:46:00 +02:00
|
|
|
static u32 sub_81CAD20(s32);
|
2019-04-14 20:21:06 +02:00
|
|
|
static bool32 sub_81CB1D0(void);
|
|
|
|
|
2019-07-29 18:46:08 +02:00
|
|
|
#include "data/text/match_call_messages.h"
|
2019-07-20 00:31:42 +02:00
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
static const u8 sMatchCallOptionsNoCheckPage[] =
|
|
|
|
{
|
|
|
|
MATCH_CALL_OPTION_CALL,
|
|
|
|
MATCH_CALL_OPTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sMatchCallOptionsHasCheckPage[] =
|
|
|
|
{
|
|
|
|
MATCH_CALL_OPTION_CALL,
|
|
|
|
MATCH_CALL_OPTION_CHECK,
|
|
|
|
MATCH_CALL_OPTION_CANCEL
|
|
|
|
};
|
2019-04-14 17:13:51 +02:00
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
bool32 PokenavCallback_Init_MatchCall(void)
|
2019-04-14 17:13:51 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN, sizeof(struct Pokenav3Struct));
|
2019-04-14 17:13:51 +02:00
|
|
|
if (!state)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
state->callback = CB2_HandleMatchCallInput;
|
|
|
|
state->headerId = 0;
|
2019-04-14 17:13:51 +02:00
|
|
|
state->unk10 = 0;
|
|
|
|
state->unk14 = CreateLoopedTask(sub_81CAD20, 1);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
u32 GetMatchCallCallback(void)
|
2019-04-14 17:13:51 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 20:21:06 +02:00
|
|
|
return state->callback(state);
|
2019-04-14 17:13:51 +02:00
|
|
|
}
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
void FreeMatchCallSubstruct1(void)
|
2019-04-14 17:13:51 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 17:13:51 +02:00
|
|
|
}
|
2019-04-14 20:21:06 +02:00
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
int selection;
|
2019-04-14 20:21:06 +02:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_UP;
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_REPEAT(DPAD_DOWN))
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_DOWN;
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_REPEAT(DPAD_LEFT))
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_PG_UP;
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_REPEAT(DPAD_RIGHT))
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_PG_DOWN;
|
2019-04-14 20:21:06 +02:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
state->callback = CB2_HandleMatchCallOptionsInput;
|
|
|
|
state->optionCursorPos = 0;
|
2020-10-11 00:17:34 +02:00
|
|
|
selection = GetSelectedPokenavListIndex();
|
2019-12-07 10:08:21 +01:00
|
|
|
|
|
|
|
if (!state->matchCallEntries[selection].isSpecialTrainer || MatchCall_HasCheckPage(state->matchCallEntries[selection].headerId))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
state->matchCallOptions = sMatchCallOptionsHasCheckPage;
|
2019-12-07 10:08:21 +01:00
|
|
|
state->maxOptionId = ARRAY_COUNT(sMatchCallOptionsHasCheckPage) - 1;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
state->matchCallOptions = sMatchCallOptionsNoCheckPage;
|
2019-12-07 10:08:21 +01:00
|
|
|
state->maxOptionId = ARRAY_COUNT(sMatchCallOptionsNoCheckPage) - 1;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_SELECT;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
if (GetPokenavMode() != POKENAV_MODE_FORCE_CALL_READY)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-02-05 08:47:32 +01:00
|
|
|
state->callback = GetExitMatchCallMenuId;
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_EXIT;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-06 04:34:55 +01:00
|
|
|
// Cant exit Match Call menu before calling Mr Stone during tutorial
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_NONE;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *state)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-02-05 08:47:32 +01:00
|
|
|
return POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if ((JOY_NEW(DPAD_UP)) && state->optionCursorPos)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
state->optionCursorPos--;
|
|
|
|
return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if ((JOY_NEW(DPAD_DOWN)) && state->optionCursorPos < state->maxOptionId)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
state->optionCursorPos++;
|
|
|
|
return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
switch (state->matchCallOptions[state->optionCursorPos])
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
case MATCH_CALL_OPTION_CANCEL:
|
|
|
|
state->callback = CB2_HandleMatchCallInput;
|
2019-12-07 10:08:21 +01:00
|
|
|
return POKENAV_MC_FUNC_CANCEL;
|
2019-12-05 21:33:36 +01:00
|
|
|
case MATCH_CALL_OPTION_CALL:
|
|
|
|
if (GetPokenavMode() == POKENAV_MODE_FORCE_CALL_READY)
|
|
|
|
SetPokenavMode(POKENAV_MODE_FORCE_CALL_EXIT);
|
2019-04-14 20:21:06 +02:00
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
state->callback = CB2_HandleCallInput;
|
2019-04-14 20:21:06 +02:00
|
|
|
if (sub_81CB1D0())
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_NEARBY_MSG;
|
2019-04-14 20:21:06 +02:00
|
|
|
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_CALL_MSG;
|
2019-12-05 21:33:36 +01:00
|
|
|
case MATCH_CALL_OPTION_CHECK:
|
2019-12-07 10:08:21 +01:00
|
|
|
state->callback = CB2_HandleCheckPageInput;
|
|
|
|
return POKENAV_MC_FUNC_SHOW_CHECK_PAGE;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
state->callback = CB2_HandleMatchCallInput;
|
2019-12-07 10:08:21 +01:00
|
|
|
return POKENAV_MC_FUNC_CANCEL;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_NONE;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-12-07 10:08:21 +01:00
|
|
|
return POKENAV_MC_FUNC_CHECK_PAGE_UP;
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_REPEAT(DPAD_DOWN))
|
2019-12-07 10:08:21 +01:00
|
|
|
return POKENAV_MC_FUNC_CHECK_PAGE_DOWN;
|
2019-04-14 20:21:06 +02:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
state->callback = CB2_HandleMatchCallInput;
|
2019-12-07 10:08:21 +01:00
|
|
|
return POKENAV_MC_FUNC_EXIT_CHECK_PAGE;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_NONE;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
static u32 CB2_HandleCallInput(struct Pokenav3Struct *state)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
state->callback = CB2_HandleMatchCallInput;
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_10;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-06 04:34:55 +01:00
|
|
|
return POKENAV_MC_FUNC_NONE;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
static u32 sub_81CAD20(s32 taskState)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
|
|
|
int i, j;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 20:21:06 +02:00
|
|
|
switch (taskState)
|
|
|
|
{
|
|
|
|
case 0:
|
2019-12-05 21:33:36 +01:00
|
|
|
state->headerId = 0;
|
2019-12-07 10:08:21 +01:00
|
|
|
state->numRegistered = 0;
|
2019-04-14 20:21:06 +02:00
|
|
|
return LT_INC_AND_CONTINUE;
|
|
|
|
case 1:
|
2019-12-05 21:33:36 +01:00
|
|
|
for (i = 0, j = state->headerId; i < 30; i++, j++)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
if (MatchCall_GetEnabled(j))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
state->matchCallEntries[state->numRegistered].headerId = j;
|
|
|
|
state->matchCallEntries[state->numRegistered].isSpecialTrainer = TRUE;
|
|
|
|
state->matchCallEntries[state->numRegistered].mapSec = MatchCall_GetMapSec(j);
|
|
|
|
state->numRegistered++;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
if (++state->headerId >= MC_HEADER_COUNT)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
state->unkC = state->headerId;
|
|
|
|
state->headerId = 0;
|
2019-04-14 20:21:06 +02:00
|
|
|
return LT_INC_AND_CONTINUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return LT_CONTINUE;
|
|
|
|
case 2:
|
2019-12-05 21:33:36 +01:00
|
|
|
for (i = 0, j = state->headerId; i < 30; i++, j++)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
if (!MatchCall_HasRematchId(state->headerId) && IsRematchEntryRegistered(state->headerId))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
state->matchCallEntries[state->numRegistered].headerId = state->headerId;
|
|
|
|
state->matchCallEntries[state->numRegistered].isSpecialTrainer = FALSE;
|
2020-10-11 00:17:34 +02:00
|
|
|
state->matchCallEntries[state->numRegistered].mapSec = GetMatchTableMapSectionId(j);
|
2019-12-07 10:08:21 +01:00
|
|
|
state->numRegistered++;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
if (++state->headerId > REMATCH_TABLE_ENTRIES - 1)
|
2019-04-14 20:21:06 +02:00
|
|
|
return LT_INC_AND_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LT_CONTINUE;
|
|
|
|
case 3:
|
|
|
|
state->unk10 = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LT_FINISH;
|
|
|
|
}
|
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
bool32 IsRematchEntryRegistered(int rematchIndex)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
|
|
|
if (rematchIndex < REMATCH_TABLE_ENTRIES)
|
|
|
|
return FlagGet(FLAG_MATCH_CALL_REGISTERED + rematchIndex);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sub_81CAE28(void)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 20:21:06 +02:00
|
|
|
return state->unk10;
|
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
int GetNumberRegistered(void)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-07 10:08:21 +01:00
|
|
|
return state->numRegistered;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int sub_81CAE48(void)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 20:21:06 +02:00
|
|
|
return state->unkC;
|
|
|
|
}
|
|
|
|
|
|
|
|
int unref_sub_81CAE58(void)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-07 10:08:21 +01:00
|
|
|
return state->numRegistered - state->unkC;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int unref_sub_81CAE6C(int arg0)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 20:21:06 +02:00
|
|
|
arg0 += state->unkC;
|
2019-12-07 10:08:21 +01:00
|
|
|
if (arg0 >= state->numRegistered)
|
2019-04-14 20:21:06 +02:00
|
|
|
return REMATCH_TABLE_ENTRIES;
|
2019-05-26 12:42:01 +02:00
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
return state->matchCallEntries[arg0].headerId;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-15 16:25:47 +01:00
|
|
|
struct PokenavMatchCallEntries *sub_81CAE94(void)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-05 21:33:36 +01:00
|
|
|
return state->matchCallEntries;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
u16 GetMatchCallMapSec(int index)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-05 21:33:36 +01:00
|
|
|
return state->matchCallEntries[index].mapSec;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
bool32 ShouldDrawRematchPokeballIcon(int index)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-07 10:08:21 +01:00
|
|
|
if (!state->matchCallEntries[index].isSpecialTrainer)
|
2019-12-05 21:33:36 +01:00
|
|
|
index = state->matchCallEntries[index].headerId;
|
2019-04-14 20:21:06 +02:00
|
|
|
else
|
2019-12-05 21:33:36 +01:00
|
|
|
index = MatchCall_GetRematchTableIdx(state->matchCallEntries[index].headerId);
|
2019-04-14 20:21:06 +02:00
|
|
|
|
|
|
|
if (index == REMATCH_TABLE_ENTRIES)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return gSaveBlock1Ptr->trainerRematches[index] != 0;
|
|
|
|
}
|
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
int GetMatchCallTrainerPic(int index)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-08 21:49:36 +01:00
|
|
|
int headerId;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-07 10:08:21 +01:00
|
|
|
if (!state->matchCallEntries[index].isSpecialTrainer)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
index = GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId);
|
2019-04-14 20:21:06 +02:00
|
|
|
return gTrainers[index].trainerPic;
|
|
|
|
}
|
2019-05-26 12:42:01 +02:00
|
|
|
|
2019-12-08 21:49:36 +01:00
|
|
|
headerId = state->matchCallEntries[index].headerId;
|
|
|
|
index = MatchCall_GetRematchTableIdx(headerId);
|
2019-04-14 20:21:06 +02:00
|
|
|
if (index != REMATCH_TABLE_ENTRIES)
|
|
|
|
{
|
|
|
|
index = GetTrainerIdxByRematchIdx(index);
|
|
|
|
return gTrainers[index].trainerPic;
|
|
|
|
}
|
|
|
|
|
2019-12-08 21:49:36 +01:00
|
|
|
index = MatchCall_GetOverrideFacilityClass(headerId);
|
2019-04-14 20:21:06 +02:00
|
|
|
return gFacilityClassToPicIndex[index];
|
|
|
|
}
|
|
|
|
|
2019-12-06 04:34:55 +01:00
|
|
|
const u8 *GetMatchCallMessageText(int index, u8 *arg1)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 20:21:06 +02:00
|
|
|
*arg1 = 0;
|
|
|
|
if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType))
|
|
|
|
return gText_CallCantBeMadeHere;
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
if (!state->matchCallEntries[index].isSpecialTrainer)
|
2019-12-05 21:33:36 +01:00
|
|
|
*arg1 = SelectMatchCallMessage(GetTrainerIdxByRematchIdx(state->matchCallEntries[index].headerId), gStringVar4);
|
2019-04-14 20:21:06 +02:00
|
|
|
else
|
2019-12-05 21:33:36 +01:00
|
|
|
MatchCall_GetMessage(state->matchCallEntries[index].headerId, gStringVar4);
|
2019-04-14 20:21:06 +02:00
|
|
|
|
|
|
|
return gStringVar4;
|
|
|
|
}
|
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
const u8 *GetMatchCallFlavorText(int index, int checkPageEntry)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
int rematchId;
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-07 10:08:21 +01:00
|
|
|
if (state->matchCallEntries[index].isSpecialTrainer)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
rematchId = MatchCall_GetRematchTableIdx(state->matchCallEntries[index].headerId);
|
|
|
|
if (rematchId == REMATCH_TABLE_ENTRIES)
|
|
|
|
return MatchCall_GetOverrideFlavorText(state->matchCallEntries[index].headerId, checkPageEntry);
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
rematchId = state->matchCallEntries[index].headerId;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 21:33:36 +01:00
|
|
|
return gMatchCallFlavorTexts[rematchId][checkPageEntry];
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
u16 GetMatchCallOptionCursorPos(void)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-07 10:08:21 +01:00
|
|
|
return state->optionCursorPos;
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
u16 GetMatchCallOptionId(int optionId)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-12-07 10:08:21 +01:00
|
|
|
if (state->maxOptionId < optionId)
|
2019-12-05 21:33:36 +01:00
|
|
|
return MATCH_CALL_OPTION_COUNT;
|
2019-04-14 20:21:06 +02:00
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
return state->matchCallOptions[optionId];
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
2019-12-15 16:25:47 +01:00
|
|
|
void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries *matchCallEntry, u8 *str)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
|
|
|
const u8 *trainerName;
|
|
|
|
const u8 *className;
|
2019-12-07 10:08:21 +01:00
|
|
|
if (!matchCallEntry->isSpecialTrainer)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
int index = GetTrainerIdxByRematchIdx(matchCallEntry->headerId);
|
2019-04-14 20:21:06 +02:00
|
|
|
const struct Trainer *trainer = &gTrainers[index];
|
|
|
|
int class = trainer->trainerClass;
|
|
|
|
className = gTrainerClassNames[class];
|
|
|
|
trainerName = trainer->trainerName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
MatchCall_GetNameAndDesc(matchCallEntry->headerId, &className, &trainerName);
|
2019-04-14 20:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (className && trainerName)
|
|
|
|
{
|
|
|
|
u8 *str2 = sub_81DB494(str, 7, className, 69);
|
|
|
|
sub_81DB494(str2, 7, trainerName, 51);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_81DB494(str, 7, NULL, 120);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
u8 GetMatchTableMapSectionId(int rematchIndex)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
|
|
|
int mapGroup = gRematchTable[rematchIndex].mapGroup;
|
|
|
|
int mapNum = gRematchTable[rematchIndex].mapNum;
|
|
|
|
return Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->regionMapSectionId;
|
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
int GetIndexDeltaOfNextCheckPageDown(int index)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 20:21:06 +02:00
|
|
|
int count = 1;
|
2019-12-07 10:08:21 +01:00
|
|
|
while (++index < state->numRegistered)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
if (!state->matchCallEntries[index].isSpecialTrainer)
|
2019-04-14 20:21:06 +02:00
|
|
|
return count;
|
2019-12-05 21:33:36 +01:00
|
|
|
if (MatchCall_HasCheckPage(state->matchCallEntries[index].headerId))
|
2019-04-14 20:21:06 +02:00
|
|
|
return count;
|
|
|
|
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-07 10:08:21 +01:00
|
|
|
int GetIndexDeltaOfNextCheckPageUp(int index)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
2019-04-14 20:21:06 +02:00
|
|
|
int count = -1;
|
|
|
|
while (--index >= 0)
|
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
if (!state->matchCallEntries[index].isSpecialTrainer)
|
2019-04-14 20:21:06 +02:00
|
|
|
return count;
|
2019-12-05 21:33:36 +01:00
|
|
|
if (MatchCall_HasCheckPage(state->matchCallEntries[index].headerId))
|
2019-04-14 20:21:06 +02:00
|
|
|
return count;
|
|
|
|
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool32 unref_sub_81CB16C(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < REMATCH_TABLE_ENTRIES; i++)
|
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
if (IsRematchEntryRegistered(i) && gSaveBlock1Ptr->trainerRematches[i])
|
2019-04-14 20:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-08-09 22:28:22 +02:00
|
|
|
for (i = 0; i < MC_HEADER_COUNT; i++)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
if (MatchCall_GetEnabled(i))
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
|
|
|
int index = MatchCall_GetRematchTableIdx(i);
|
|
|
|
if (gSaveBlock1Ptr->trainerRematches[index])
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool32 sub_81CB1D0(void)
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct Pokenav3Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
|
|
|
|
int selection = GetSelectedPokenavListIndex();
|
2019-12-07 10:08:21 +01:00
|
|
|
if (!state->matchCallEntries[selection].isSpecialTrainer)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
if (GetMatchCallMapSec(selection) == gMapHeader.regionMapSectionId)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
if (!gSaveBlock1Ptr->trainerRematches[state->matchCallEntries[selection].headerId])
|
2019-04-14 20:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
if (state->matchCallEntries[selection].headerId == MC_HEADER_WATTSON)
|
2019-04-14 20:21:06 +02:00
|
|
|
{
|
2019-12-07 10:08:21 +01:00
|
|
|
if (GetMatchCallMapSec(selection) == gMapHeader.regionMapSectionId
|
2019-04-14 20:21:06 +02:00
|
|
|
&& FlagGet(FLAG_BADGE05_GET) == TRUE)
|
|
|
|
{
|
|
|
|
if (!FlagGet(FLAG_WATTSON_REMATCH_AVAILABLE))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|