diff --git a/include/battle_setup.h b/include/battle_setup.h index 984c820bbb..dacd1fa710 100644 --- a/include/battle_setup.h +++ b/include/battle_setup.h @@ -4,7 +4,6 @@ #include "gym_leader_rematch.h" #define REMATCHES_COUNT 5 -#define REMATCH_ELITE_FOUR_ENTRIES REMATCH_SIDNEY struct RematchTrainer { diff --git a/include/gym_leader_rematch.h b/include/gym_leader_rematch.h index 473d7b1c13..ac365a41a1 100644 --- a/include/gym_leader_rematch.h +++ b/include/gym_leader_rematch.h @@ -66,7 +66,7 @@ enum { REMATCH_TRENT, REMATCH_SAWYER, REMATCH_KIRA_AND_DAN, - REMATCH_WALLY_3, + REMATCH_WALLY_3, // Entries above WALLY are considered normal NPCs REMATCH_ROXANNE, REMATCH_BRAWLY, REMATCH_WATTSON, @@ -83,6 +83,9 @@ enum { REMATCH_TABLE_ENTRIES // The total number of rematch entries. Must be last in enum }; +#define REMATCH_NORMAL_NPC_END REMATCH_WALLY_3 +#define REMATCH_ELITE_FOUR_ENTRIES REMATCH_SIDNEY + void UpdateGymLeaderRematch(void); #endif //GUARD_TRAINER_REMATCH_H diff --git a/include/pokenav.h b/include/pokenav.h index 5edde59008..c497c4b85f 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -105,6 +105,23 @@ enum [CHECK_PAGE_INTRO_1] = gText_MatchCall##name##_Intro1, \ [CHECK_PAGE_INTRO_2] = gText_MatchCall##name##_Intro2} +#define POKENAV_MC_FUNC_NONE 0 +#define POKENAV_MC_FUNC_DOWN 1 +#define POKENAV_MC_FUNC_UP 2 +#define POKENAV_MC_FUNC_PG_DOWN 3 +#define POKENAV_MC_FUNC_PG_UP 4 +#define POKENAV_MC_FUNC_SELECT 5 +#define POKENAV_MC_FUNC_6 6 +#define POKENAV_MC_FUNC_7 7 +#define POKENAV_MC_FUNC_CALL_MSG 8 +#define POKENAV_MC_FUNC_NEARBY_MSG 9 +#define POKENAV_MC_FUNC_10 10 +#define POKENAV_MC_FUNC_11 11 +#define POKENAV_MC_FUNC_12 12 +#define POKENAV_MC_FUNC_13 13 +#define POKENAV_MC_FUNC_14 14 +#define POKENAV_MC_FUNC_EXIT 15 + // pokenav.c void sub_81C7694(u32); u32 sub_81C76AC(void); @@ -207,7 +224,6 @@ bool32 PokenavCallback_Init_3(void); u32 sub_81C941C(void); void sub_81C9430(void); int sub_81C9894(void); -const u8 *sub_81CAF78(int index, u8 *arg1); int sub_81C98A4(void); int sub_81C98B4(void); u16 sub_81C98C4(void); @@ -232,6 +248,7 @@ u16 sub_81CAEA4(int); bool32 sub_81CAEBC(int index); int GetMatchCallTrainerPic(int index); const u8 *GetMatchCallFlavorText(int index, int textType); +const u8 *GetMatchCallMessageText(int index, u8 *arg1); u16 sub_81CB01C(void); u16 sub_81CB02C(int arg0); void sub_81CB050(struct PokenavMonList * arg0, u8 *str); @@ -240,7 +257,7 @@ int sub_81CB0E4(int index); bool32 IsRematchEntryRegistered(int index); int sub_81CB128(int index); -// pokenav_unk_4.c +// POKENAV_MC.c bool32 sub_81CB260(void); void sub_81CB29C(s32 index); u32 sub_81CB2CC(void); diff --git a/src/battle_setup.c b/src/battle_setup.c index b98b5df06f..817f699f25 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1582,7 +1582,7 @@ static bool32 UpdateRandomTrainerRematches(const struct RematchTrainer *table, u s32 i; bool32 ret = FALSE; - for (i = 0; i <= REMATCH_WALLY_3; i++) + for (i = 0; i <= REMATCH_NORMAL_NPC_END; i++) { if (table[i].mapGroup == mapGroup && table[i].mapNum == mapNum && !sub_80B1D94(i)) { diff --git a/src/match_call.c b/src/match_call.c index 646b14cea7..8458bb31d6 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1060,7 +1060,7 @@ static bool32 SelectMatchCallTrainer(void) static u32 GetNumRegisteredNPCs(void) { u32 i, count; - for (i = 0, count = 0; i < 64; i++) + for (i = 0, count = 0; i < REMATCH_NORMAL_NPC_END; i++) { if (FlagGet(FLAG_MATCH_CALL_REGISTERED + i)) count++; @@ -1072,7 +1072,7 @@ static u32 GetNumRegisteredNPCs(void) static u32 GetActiveMatchCallTrainerId(u32 activeMatchCallId) { u32 i; - for (i = 0; i < 64; i++) + for (i = 0; i < REMATCH_NORMAL_NPC_END; i++) { if (FlagGet(FLAG_MATCH_CALL_REGISTERED + i)) { @@ -1384,7 +1384,7 @@ static u16 GetRematchTrainerLocation(int matchCallId) static u32 GetNumRematchTrainersFought(void) { u32 i, count; - for (i = 0, count = 0; i < 64; i++) + for (i = 0, count = 0; i < REMATCH_NORMAL_NPC_END; i++) { if (HasTrainerBeenFought(gRematchTable[i].trainerIds[0])) count++; diff --git a/src/pokenav_match_call_data.c b/src/pokenav_match_call_data.c index 15374ca898..2460a2f370 100644 --- a/src/pokenav_match_call_data.c +++ b/src/pokenav_match_call_data.c @@ -11,6 +11,16 @@ #include "constants/region_map_sections.h" #include "constants/trainers.h" +enum +{ + MC_TYPE_0, + MC_TYPE_1, + MC_TYPE_WALLY, + MC_TYPE_BIRCH, + MC_TYPE_RIVAL, + MC_TYPE_5 +}; + // Static type declarations typedef struct MatchCallTextDataStruct { @@ -49,17 +59,17 @@ struct MatchCallSubstruct2 { u8 mapSec; }; -struct MatchCallStruct2 { +struct MatchCallWally { u8 type; u8 mapSec; u16 flag; u16 rematchTableIdx; const u8 *desc; const match_call_text_data_t *textData; - const struct MatchCallSubstruct2 *v10; + const struct MatchCallSubstruct2 *locationData; }; -struct MatchCallStruct3 { +struct MatchCallBirch { u8 type; u8 mapSec; u16 flag; @@ -67,9 +77,9 @@ struct MatchCallStruct3 { const u8 *name; }; -struct MatchCallStruct4 { +struct MatchCallRival { u8 type; - u8 gender; + u8 playerGender; u16 flag; const u8 *desc; const u8 *name; @@ -91,9 +101,9 @@ typedef union { const struct MatchCallStructCommon *common; const struct MatchCallStruct0 *type0; const struct MatchCallStruct1 *type1; - const struct MatchCallStruct2 *type2; - const struct MatchCallStruct3 *type3; - const struct MatchCallStruct4 *type4; + const struct MatchCallWally *wally; + const struct MatchCallBirch *birch; + const struct MatchCallRival *rival; const struct MatchCallStruct5 *type5; } match_call_t; @@ -110,47 +120,47 @@ struct MatchCallOverride { static bool32 MatchCallGetFlag_Type0(match_call_t); static bool32 MatchCallGetFlag_Type1(match_call_t); -static bool32 MatchCallGetFlag_Type2(match_call_t); -static bool32 MatchCallGetFlag_Type3(match_call_t); -static bool32 MatchCallGetFlag_Type4(match_call_t); +static bool32 MatchCallGetFlag_Wally(match_call_t); +static bool32 MatchCallGetFlag_Birch(match_call_t); +static bool32 MatchCallGetFlag_Rival(match_call_t); static u8 MatchCallGetMapSec_Type0(match_call_t); static u8 MatchCallGetMapSec_Type1(match_call_t); -static u8 MatchCallGetMapSec_Type2(match_call_t); -static u8 MatchCallGetMapSec_Type3(match_call_t); -static u8 MatchCallGetMapSec_Type4(match_call_t); +static u8 MatchCallGetMapSec_Wally(match_call_t); +static u8 MatchCallGetMapSec_Birch(match_call_t); +static u8 MatchCallGetMapSec_Rival(match_call_t); static bool32 MatchCall_IsRematchable_Type0(match_call_t); static bool32 MatchCall_IsRematchable_Type1(match_call_t); -static bool32 MatchCall_IsRematchable_Type2(match_call_t); -static bool32 MatchCall_IsRematchable_Type3(match_call_t); -static bool32 MatchCall_IsRematchable_Type4(match_call_t); +static bool32 MatchCall_IsRematchable_Wally(match_call_t); +static bool32 MatchCall_IsRematchable_Birch(match_call_t); +static bool32 MatchCall_IsRematchable_Rival(match_call_t); static bool32 MatchCall_HasCheckPage_Type0(match_call_t); static bool32 MatchCall_HasCheckPage_Type1(match_call_t); -static bool32 MatchCall_HasCheckPage_Type2(match_call_t); -static bool32 MatchCall_HasCheckPage_Type3(match_call_t); -static bool32 MatchCall_HasCheckPage_Type4(match_call_t); +static bool32 MatchCall_HasCheckPage_Wally(match_call_t); +static bool32 MatchCall_HasCheckPage_Birch(match_call_t); +static bool32 MatchCall_HasCheckPage_Rival(match_call_t); static u32 MatchCall_GetRematchTableIdx_Type0(match_call_t); static u32 MatchCall_GetRematchTableIdx_Type1(match_call_t); -static u32 MatchCall_GetRematchTableIdx_Type2(match_call_t); -static u32 MatchCall_GetRematchTableIdx_Type3(match_call_t); -static u32 MatchCall_GetRematchTableIdx_Type4(match_call_t); +static u32 MatchCall_GetRematchTableIdx_Wally(match_call_t); +static u32 MatchCall_GetRematchTableIdx_Birch(match_call_t); +static u32 MatchCall_GetRematchTableIdx_Rival(match_call_t); static void MatchCall_GetMessage_Type0(match_call_t, u8 *); static void MatchCall_GetMessage_Type1(match_call_t, u8 *); -static void MatchCall_GetMessage_Type2(match_call_t, u8 *); -static void MatchCall_GetMessage_Type3(match_call_t, u8 *); -static void MatchCall_GetMessage_Type4(match_call_t, u8 *); +static void MatchCall_GetMessage_Wally(match_call_t, u8 *); +static void MatchCall_GetMessage_Birch(match_call_t, u8 *); +static void MatchCall_GetMessage_Rival(match_call_t, u8 *); static void MatchCall_GetNameAndDesc_Type0(match_call_t, const u8 **, const u8 **); static void MatchCall_GetNameAndDesc_Type1(match_call_t, const u8 **, const u8 **); -static void MatchCall_GetNameAndDesc_Type2(match_call_t, const u8 **, const u8 **); -static void MatchCall_GetNameAndDesc_Type3(match_call_t, const u8 **, const u8 **); -static void MatchCall_GetNameAndDesc_Type4(match_call_t, const u8 **, const u8 **); +static void MatchCall_GetNameAndDesc_Wally(match_call_t, const u8 **, const u8 **); +static void MatchCall_GetNameAndDesc_Birch(match_call_t, const u8 **, const u8 **); +static void MatchCall_GetNameAndDesc_Rival(match_call_t, const u8 **, const u8 **); -static void sub_81D1920(const match_call_text_data_t *, u8 *); +static void MatchCall_BufferCallMessageText(const match_call_text_data_t *, u8 *); static void sub_81D199C(const match_call_text_data_t *, u16, u8 *); static void MatchCall_GetNameAndDescByRematchIdx(u32, const u8 **, const u8 **); @@ -328,9 +338,9 @@ static const struct MatchCallStruct5 sNormanMatchCallHeader = .textData = sNormanTextScripts }; -static const struct MatchCallStruct3 sProfBirchMatchCallHeader = +static const struct MatchCallBirch sProfBirchMatchCallHeader = { - .type = 3, + .type = MC_TYPE_BIRCH, .mapSec = 0, .flag = FLAG_ENABLE_PROF_BIRCH_MATCH_CALL, .desc = gText_ProfBirchMatchCallDesc, @@ -394,10 +404,10 @@ static const match_call_text_data_t sMayTextScripts[] = { { NULL, 0xFFFF, 0xFFFF } }; -static const struct MatchCallStruct4 sMayMatchCallHeader = +static const struct MatchCallRival sMayMatchCallHeader = { - .type = 4, - .gender = MALE, //Gender of player + .type = MC_TYPE_RIVAL, + .playerGender = MALE, .flag = FLAG_ENABLE_RIVAL_MATCH_CALL, .desc = gText_MayBrendanMatchCallDesc, .name = gText_ExpandedPlaceholder_May, @@ -423,10 +433,10 @@ static const match_call_text_data_t sBrendanTextScripts[] = { { NULL, 0xFFFF, 0xFFFF } }; -static const struct MatchCallStruct4 sBrendanMatchCallHeader = +static const struct MatchCallRival sBrendanMatchCallHeader = { - .type = 4, - .gender = FEMALE, //Gender of player + .type = MC_TYPE_RIVAL, + .playerGender = FEMALE, .flag = FLAG_ENABLE_RIVAL_MATCH_CALL, .desc = gText_MayBrendanMatchCallDesc, .name = gText_ExpandedPlaceholder_Brendan, @@ -444,22 +454,22 @@ static const match_call_text_data_t sWallyTextScripts[] = { { NULL, 0xFFFF, 0xFFFF } }; -const struct MatchCallSubstruct2 sWallyAdditionalData[] = { +const struct MatchCallSubstruct2 sWallyLocationData[] = { { FLAG_HIDE_MAUVILLE_CITY_WALLY, MAPSEC_VERDANTURF_TOWN }, { FLAG_GROUDON_AWAKENED_MAGMA_HIDEOUT, MAPSEC_NONE }, { FLAG_HIDE_VICTORY_ROAD_ENTRANCE_WALLY, MAPSEC_VICTORY_ROAD }, { 0xFFFF, MAPSEC_NONE } }; -static const struct MatchCallStruct2 sWallyMatchCallHeader = +static const struct MatchCallWally sWallyMatchCallHeader = { - .type = 2, + .type = MC_TYPE_WALLY, .mapSec = 0, .flag = FLAG_ENABLE_WALLY_MATCH_CALL, .rematchTableIdx = REMATCH_WALLY_3, .desc = gText_WallyMatchCallDesc, .textData = sWallyTextScripts, - .v10 = sWallyAdditionalData + .locationData = sWallyLocationData }; static const match_call_text_data_t sScottTextScripts[] = { @@ -699,10 +709,10 @@ static const struct MatchCallStruct5 sWallaceMatchCallHeader = static const match_call_t sMatchCallHeaders[] = { [MC_HEADER_MR_STONE] = {.type0 = &sMrStoneMatchCallHeader}, - [MC_HEADER_PROF_BIRCH] = {.type3 = &sProfBirchMatchCallHeader}, - [MC_HEADER_BRENDAN] = {.type4 = &sBrendanMatchCallHeader}, - [MC_HEADER_MAY] = {.type4 = &sMayMatchCallHeader}, - [MC_HEADER_WALLY] = {.type2 = &sWallyMatchCallHeader}, + [MC_HEADER_PROF_BIRCH] = {.birch = &sProfBirchMatchCallHeader}, + [MC_HEADER_BRENDAN] = {.rival = &sBrendanMatchCallHeader}, + [MC_HEADER_MAY] = {.rival = &sMayMatchCallHeader}, + [MC_HEADER_WALLY] = {.wally = &sWallyMatchCallHeader}, [MC_HEADER_NORMAN] = {.type5 = &sNormanMatchCallHeader}, [MC_HEADER_MOM] = {.type0 = &sMomMatchCallHeader}, [MC_HEADER_STEVEN] = {.type0 = &sStevenMatchCallHeader}, @@ -724,57 +734,57 @@ static const match_call_t sMatchCallHeaders[] = { static bool32 (*const sMatchCallGetFlagFuncs[])(match_call_t) = { MatchCallGetFlag_Type0, MatchCallGetFlag_Type1, - MatchCallGetFlag_Type2, - MatchCallGetFlag_Type4, - MatchCallGetFlag_Type3 + MatchCallGetFlag_Wally, + MatchCallGetFlag_Rival, + MatchCallGetFlag_Birch }; static u8 (*const sMatchCallGetMapSecFuncs[])(match_call_t) = { MatchCallGetMapSec_Type0, MatchCallGetMapSec_Type1, - MatchCallGetMapSec_Type2, - MatchCallGetMapSec_Type4, - MatchCallGetMapSec_Type3 + MatchCallGetMapSec_Wally, + MatchCallGetMapSec_Rival, + MatchCallGetMapSec_Birch }; static bool32 (*const sMatchCall_IsRematchableFunctions[])(match_call_t) = { MatchCall_IsRematchable_Type0, MatchCall_IsRematchable_Type1, - MatchCall_IsRematchable_Type2, - MatchCall_IsRematchable_Type4, - MatchCall_IsRematchable_Type3 + MatchCall_IsRematchable_Wally, + MatchCall_IsRematchable_Rival, + MatchCall_IsRematchable_Birch }; static bool32 (*const sMatchCall_HasCheckPageFunctions[])(match_call_t) = { MatchCall_HasCheckPage_Type0, MatchCall_HasCheckPage_Type1, - MatchCall_HasCheckPage_Type2, - MatchCall_HasCheckPage_Type4, - MatchCall_HasCheckPage_Type3 + MatchCall_HasCheckPage_Wally, + MatchCall_HasCheckPage_Rival, + MatchCall_HasCheckPage_Birch }; static u32 (*const sMatchCall_GetRematchTableIdxFunctions[])(match_call_t) = { MatchCall_GetRematchTableIdx_Type0, MatchCall_GetRematchTableIdx_Type1, - MatchCall_GetRematchTableIdx_Type2, - MatchCall_GetRematchTableIdx_Type4, - MatchCall_GetRematchTableIdx_Type3 + MatchCall_GetRematchTableIdx_Wally, + MatchCall_GetRematchTableIdx_Rival, + MatchCall_GetRematchTableIdx_Birch }; static void (*const sMatchCall_GetMessageFunctions[])(match_call_t, u8 *) = { MatchCall_GetMessage_Type0, MatchCall_GetMessage_Type1, - MatchCall_GetMessage_Type2, - MatchCall_GetMessage_Type4, - MatchCall_GetMessage_Type3 + MatchCall_GetMessage_Wally, + MatchCall_GetMessage_Rival, + MatchCall_GetMessage_Birch }; static void (*const sMatchCall_GetNameAndDescFunctions[])(match_call_t, const u8 **, const u8 **) = { MatchCall_GetNameAndDesc_Type0, MatchCall_GetNameAndDesc_Type1, - MatchCall_GetNameAndDesc_Type2, - MatchCall_GetNameAndDesc_Type4, - MatchCall_GetNameAndDesc_Type3 + MatchCall_GetNameAndDesc_Wally, + MatchCall_GetNameAndDesc_Rival, + MatchCall_GetNameAndDesc_Birch }; static const struct MatchCallOverride sMatchCallCheckPageOverrides[] = { @@ -820,17 +830,17 @@ static u32 MatchCallGetFunctionIndex(match_call_t matchCall) { switch (matchCall.common->type) { - case 0: + case MC_TYPE_0: default: return 0; - case 1: - case 5: + case MC_TYPE_1: + case MC_TYPE_5: return 1; - case 2: + case MC_TYPE_WALLY: return 2; - case 4: + case MC_TYPE_RIVAL: return 3; - case 3: + case MC_TYPE_BIRCH: return 4; } } @@ -878,25 +888,25 @@ static bool32 MatchCallGetFlag_Type1(match_call_t matchCall) return FlagGet(matchCall.type1->flag); } -static bool32 MatchCallGetFlag_Type2(match_call_t matchCall) +static bool32 MatchCallGetFlag_Wally(match_call_t matchCall) { - if (matchCall.type2->flag == 0xFFFF) + if (matchCall.wally->flag == 0xFFFF) return TRUE; - return FlagGet(matchCall.type2->flag); + return FlagGet(matchCall.wally->flag); } -static bool32 MatchCallGetFlag_Type4(match_call_t matchCall) +static bool32 MatchCallGetFlag_Rival(match_call_t matchCall) { - if (matchCall.type4->gender != gSaveBlock2Ptr->playerGender) + if (matchCall.rival->playerGender != gSaveBlock2Ptr->playerGender) return FALSE; - if (matchCall.type4->flag == 0xFFFF) + if (matchCall.rival->flag == 0xFFFF) return TRUE; - return FlagGet(matchCall.type4->flag); + return FlagGet(matchCall.rival->flag); } -static bool32 MatchCallGetFlag_Type3(match_call_t matchCall) +static bool32 MatchCallGetFlag_Birch(match_call_t matchCall) { - return FlagGet(matchCall.type3->flag); + return FlagGet(matchCall.birch->flag); } u8 MatchCallMapSecGetByIndex(u32 idx) @@ -921,24 +931,24 @@ static u8 MatchCallGetMapSec_Type1(match_call_t matchCall) return matchCall.type1->mapSec; } -static u8 MatchCallGetMapSec_Type2(match_call_t matchCall) +static u8 MatchCallGetMapSec_Wally(match_call_t matchCall) { s32 i; - for (i = 0; matchCall.type2->v10[i].flag != 0xFFFF; i++) + for (i = 0; matchCall.wally->locationData[i].flag != 0xFFFF; i++) { - if (!FlagGet(matchCall.type2->v10[i].flag)) + if (!FlagGet(matchCall.wally->locationData[i].flag)) break; } - return matchCall.type2->v10[i].mapSec; + return matchCall.wally->locationData[i].mapSec; } -static u8 MatchCallGetMapSec_Type4(match_call_t matchCall) +static u8 MatchCallGetMapSec_Rival(match_call_t matchCall) { return MAPSEC_NONE; } -static u8 MatchCallGetMapSec_Type3(match_call_t matchCall) +static u8 MatchCallGetMapSec_Birch(match_call_t matchCall) { return MAPSEC_NONE; } @@ -967,17 +977,17 @@ static bool32 MatchCall_IsRematchable_Type1(match_call_t matchCall) return gSaveBlock1Ptr->trainerRematches[matchCall.type1->rematchTableIdx] ? TRUE : FALSE; } -static bool32 MatchCall_IsRematchable_Type2(match_call_t matchCall) +static bool32 MatchCall_IsRematchable_Wally(match_call_t matchCall) { - return gSaveBlock1Ptr->trainerRematches[matchCall.type2->rematchTableIdx] ? TRUE : FALSE; + return gSaveBlock1Ptr->trainerRematches[matchCall.wally->rematchTableIdx] ? TRUE : FALSE; } -static bool32 MatchCall_IsRematchable_Type4(match_call_t matchCall) +static bool32 MatchCall_IsRematchable_Rival(match_call_t matchCall) { return FALSE; } -static bool32 MatchCall_IsRematchable_Type3(match_call_t matchCall) +static bool32 MatchCall_IsRematchable_Birch(match_call_t matchCall) { return FALSE; } @@ -1011,17 +1021,17 @@ static bool32 MatchCall_HasCheckPage_Type1(match_call_t matchCall) return TRUE; } -static bool32 MatchCall_HasCheckPage_Type2(match_call_t matchCall) +static bool32 MatchCall_HasCheckPage_Wally(match_call_t matchCall) { return TRUE; } -static bool32 MatchCall_HasCheckPage_Type4(match_call_t matchCall) +static bool32 MatchCall_HasCheckPage_Rival(match_call_t matchCall) { return FALSE; } -static bool32 MatchCall_HasCheckPage_Type3(match_call_t matchCall) +static bool32 MatchCall_HasCheckPage_Birch(match_call_t matchCall) { return FALSE; } @@ -1048,17 +1058,17 @@ static u32 MatchCall_GetRematchTableIdx_Type1(match_call_t matchCall) return matchCall.type1->rematchTableIdx; } -static u32 MatchCall_GetRematchTableIdx_Type2(match_call_t matchCall) +static u32 MatchCall_GetRematchTableIdx_Wally(match_call_t matchCall) { - return matchCall.type2->rematchTableIdx; + return matchCall.wally->rematchTableIdx; } -static u32 MatchCall_GetRematchTableIdx_Type4(match_call_t matchCall) +static u32 MatchCall_GetRematchTableIdx_Rival(match_call_t matchCall) { return REMATCH_TABLE_ENTRIES; } -static u32 MatchCall_GetRematchTableIdx_Type3(match_call_t matchCall) +static u32 MatchCall_GetRematchTableIdx_Birch(match_call_t matchCall) { return REMATCH_TABLE_ENTRIES; } @@ -1077,67 +1087,67 @@ void MatchCall_GetMessage(u32 idx, u8 *dest) static void MatchCall_GetMessage_Type0(match_call_t matchCall, u8 *dest) { - sub_81D1920(matchCall.type0->textData, dest); + MatchCall_BufferCallMessageText(matchCall.type0->textData, dest); } static void MatchCall_GetMessage_Type1(match_call_t matchCall, u8 *dest) { - if (matchCall.common->type != 5) - sub_81D1920(matchCall.type1->textData, dest); + if (matchCall.common->type != MC_TYPE_5) + MatchCall_BufferCallMessageText(matchCall.type1->textData, dest); else sub_81D199C(matchCall.type5->textData, matchCall.type5->rematchTableIdx, dest); } -static void MatchCall_GetMessage_Type2(match_call_t matchCall, u8 *dest) +static void MatchCall_GetMessage_Wally(match_call_t matchCall, u8 *dest) { - sub_81D1920(matchCall.type2->textData, dest); + MatchCall_BufferCallMessageText(matchCall.wally->textData, dest); } -static void MatchCall_GetMessage_Type4(match_call_t matchCall, u8 *dest) +static void MatchCall_GetMessage_Rival(match_call_t matchCall, u8 *dest) { - sub_81D1920(matchCall.type4->textData, dest); + MatchCall_BufferCallMessageText(matchCall.rival->textData, dest); } -static void MatchCall_GetMessage_Type3(match_call_t matchCall, u8 *dest) +static void MatchCall_GetMessage_Birch(match_call_t matchCall, u8 *dest) { sub_8197080(dest); } -static void sub_81D1920(const match_call_text_data_t *sub0, u8 *dest) +static void MatchCall_BufferCallMessageText(const match_call_text_data_t *textData, u8 *dest) { u32 i; - for (i = 0; sub0[i].text != NULL; i++) + for (i = 0; textData[i].text != NULL; i++) ; if (i) i--; while (i) { - if (sub0[i].flag != 0xFFFF && FlagGet(sub0[i].flag) == TRUE) + if (textData[i].flag != 0xFFFF && FlagGet(textData[i].flag) == TRUE) break; i--; } - if (sub0[i].flag2 != 0xFFFF) - FlagSet(sub0[i].flag2); - StringExpandPlaceholders(dest, sub0[i].text); + if (textData[i].flag2 != 0xFFFF) + FlagSet(textData[i].flag2); + StringExpandPlaceholders(dest, textData[i].text); } -static void sub_81D199C(const match_call_text_data_t *sub0, u16 idx, u8 *dest) +static void sub_81D199C(const match_call_text_data_t *textData, u16 idx, u8 *dest) { u32 i; - for (i = 0; sub0[i].text != NULL; i++) + for (i = 0; textData[i].text != NULL; i++) { - if (sub0[i].flag == 0xfffe) + if (textData[i].flag == 0xFFFE) break; - if (sub0[i].flag != 0xFFFF && !FlagGet(sub0[i].flag)) + if (textData[i].flag != 0xFFFF && !FlagGet(textData[i].flag)) break; } - if (sub0[i].flag != 0xfffe) + if (textData[i].flag != 0xFFFE) { if (i) i--; - if (sub0[i].flag2 != 0xFFFF) - FlagSet(sub0[i].flag2); - StringExpandPlaceholders(dest, sub0[i].text); + if (textData[i].flag2 != 0xFFFF) + FlagSet(textData[i].flag2); + StringExpandPlaceholders(dest, textData[i].text); } else { @@ -1154,7 +1164,7 @@ static void sub_81D199C(const match_call_text_data_t *sub0, u16 idx, u8 *dest) } while (0); } - StringExpandPlaceholders(dest, sub0[i].text); + StringExpandPlaceholders(dest, textData[i].text); } } @@ -1186,22 +1196,22 @@ static void MatchCall_GetNameAndDesc_Type1(match_call_t matchCall, const u8 **de *desc = _matchCall.type1->desc; } -static void MatchCall_GetNameAndDesc_Type2(match_call_t matchCall, const u8 **desc, const u8 **name) +static void MatchCall_GetNameAndDesc_Wally(match_call_t matchCall, const u8 **desc, const u8 **name) { - MatchCall_GetNameAndDescByRematchIdx(matchCall.type2->rematchTableIdx, desc, name); - *desc = matchCall.type2->desc; + MatchCall_GetNameAndDescByRematchIdx(matchCall.wally->rematchTableIdx, desc, name); + *desc = matchCall.wally->desc; } -static void MatchCall_GetNameAndDesc_Type4(match_call_t matchCall, const u8 **desc, const u8 **name) +static void MatchCall_GetNameAndDesc_Rival(match_call_t matchCall, const u8 **desc, const u8 **name) { - *desc = matchCall.type4->desc; - *name = matchCall.type4->name; + *desc = matchCall.rival->desc; + *name = matchCall.rival->name; } -static void MatchCall_GetNameAndDesc_Type3(match_call_t matchCall, const u8 **desc, const u8 **name) +static void MatchCall_GetNameAndDesc_Birch(match_call_t matchCall, const u8 **desc, const u8 **name) { - *desc = matchCall.type3->desc; - *name = matchCall.type3->name; + *desc = matchCall.birch->desc; + *name = matchCall.birch->name; } static void MatchCall_GetNameAndDescByRematchIdx(u32 idx, const u8 **desc, const u8 **name) diff --git a/src/pokenav_unk_3.c b/src/pokenav_unk_3.c index 09aef6a0c5..6289bd2cb1 100755 --- a/src/pokenav_unk_3.c +++ b/src/pokenav_unk_3.c @@ -85,13 +85,13 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) int selection; if (gMain.newAndRepeatedKeys & DPAD_UP) - return 2; + return POKENAV_MC_FUNC_UP; if (gMain.newAndRepeatedKeys & DPAD_DOWN) - return 1; + return POKENAV_MC_FUNC_DOWN; if (gMain.newAndRepeatedKeys & DPAD_LEFT) - return 4; + return POKENAV_MC_FUNC_PG_UP; if (gMain.newAndRepeatedKeys & DPAD_RIGHT) - return 3; + return POKENAV_MC_FUNC_PG_DOWN; if (gMain.newKeys & A_BUTTON) { @@ -109,7 +109,7 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) state->unk2 = 1; } - return 5; + return POKENAV_MC_FUNC_SELECT; } if (gMain.newKeys & B_BUTTON) @@ -117,15 +117,16 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) if (GetPokenavMode() != POKENAV_MODE_FORCE_CALL_READY) { state->callback = sub_81CABFC; - return 15; + return POKENAV_MC_FUNC_EXIT; } else { + // Cant exit Match Call menu before calling Mr Stone during tutorial PlaySE(SE_HAZURE); } } - return 0; + return POKENAV_MC_FUNC_NONE; } static u32 sub_81CABFC(struct Pokenav3Struct *state) @@ -138,13 +139,13 @@ static u32 sub_81CAC04(struct Pokenav3Struct *state) if ((gMain.newKeys & DPAD_UP) && state->unk0) { state->unk0--; - return 6; + return POKENAV_MC_FUNC_6; } if ((gMain.newKeys & DPAD_DOWN) && state->unk0 < state->unk2) { state->unk0++; - return 6; + return POKENAV_MC_FUNC_6; } if (gMain.newKeys & A_BUTTON) @@ -153,45 +154,45 @@ static u32 sub_81CAC04(struct Pokenav3Struct *state) { case MATCH_CALL_OPTION_CANCEL: state->callback = CB2_HandleMatchCallInput; - return 7; + return POKENAV_MC_FUNC_7; case MATCH_CALL_OPTION_CALL: if (GetPokenavMode() == POKENAV_MODE_FORCE_CALL_READY) SetPokenavMode(POKENAV_MODE_FORCE_CALL_EXIT); state->callback = sub_81CACF8; if (sub_81CB1D0()) - return 9; + return POKENAV_MC_FUNC_NEARBY_MSG; - return 8; + return POKENAV_MC_FUNC_CALL_MSG; case MATCH_CALL_OPTION_CHECK: state->callback = sub_81CACB8; - return 11; + return POKENAV_MC_FUNC_11; } } if (gMain.newKeys & B_BUTTON) { state->callback = CB2_HandleMatchCallInput; - return 7; + return POKENAV_MC_FUNC_7; } - return 0; + return POKENAV_MC_FUNC_NONE; } static u32 sub_81CACB8(struct Pokenav3Struct *state) { if (gMain.newAndRepeatedKeys & DPAD_UP) - return 12; + return POKENAV_MC_FUNC_12; if (gMain.newAndRepeatedKeys & DPAD_DOWN) - return 13; + return POKENAV_MC_FUNC_13; if (gMain.newKeys & B_BUTTON) { state->callback = CB2_HandleMatchCallInput; - return 14; + return POKENAV_MC_FUNC_14; } - return 0; + return POKENAV_MC_FUNC_NONE; } static u32 sub_81CACF8(struct Pokenav3Struct *state) @@ -199,10 +200,10 @@ static u32 sub_81CACF8(struct Pokenav3Struct *state) if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { state->callback = CB2_HandleMatchCallInput; - return 10; + return POKENAV_MC_FUNC_10; } - return 0; + return POKENAV_MC_FUNC_NONE; } static u32 sub_81CAD20(s32 taskState) @@ -349,7 +350,7 @@ int GetMatchCallTrainerPic(int index) return gFacilityClassToPicIndex[index]; } -const u8 *sub_81CAF78(int index, u8 *arg1) +const u8 *GetMatchCallMessageText(int index, u8 *arg1) { struct Pokenav3Struct *state = GetSubstructPtr(5); *arg1 = 0; diff --git a/src/pokenav_unk_4.c b/src/pokenav_unk_4.c index 4ac2ed41e5..b1cabe1477 100755 --- a/src/pokenav_unk_4.c +++ b/src/pokenav_unk_4.c @@ -32,9 +32,9 @@ struct Pokenav4Struct u8 filler8[0x6]; u8 unkE; u8 unkF; - u16 unk10; - u16 unk12; - u16 unk14; + u16 locWindowId; + u16 infoBoxWindowId; + u16 msgBoxWindowId; //windowId s16 unk16; u8 unused18; u8 unk19; @@ -55,25 +55,25 @@ static void sub_81CBBB8(void); static void sub_81CBC1C(void); static void sub_81CC2B4(void); static void sub_81CC034(struct Pokenav4Struct *); -static void sub_81CBD78(struct Pokenav4Struct *); -static void sub_81CBDC0(struct Pokenav4Struct *); -static void sub_81CBEF8(struct Pokenav4Struct *, int); +static void DrawMatchCallLeftColumnWindows(struct Pokenav4Struct *); +static void UpdateMatchCallInfoBox(struct Pokenav4Struct *); +static void PrintMatchCallLocation(struct Pokenav4Struct *, int); static void sub_81CC214(void); static void sub_81CBC38(int); -static void sub_81CBF60(struct Pokenav4Struct *); +static void PrintMatchCallSelectionOptions(struct Pokenav4Struct *); static bool32 sub_81CBFC4(struct Pokenav4Struct *); static void sub_81CC344(struct Pokenav4Struct *, int); static bool32 sub_81CC004(struct Pokenav4Struct *); static void sub_81CBFF0(struct Pokenav4Struct *); static void sub_81CC058(struct Pokenav4Struct *); static bool32 sub_81CC0D0(struct Pokenav4Struct *); -static void sub_81CC0E0(struct Pokenav4Struct *); -static bool32 sub_81CC104(struct Pokenav4Struct *); -static void sub_81CC158(struct Pokenav4Struct *); -static bool32 sub_81CC194(struct Pokenav4Struct *); +static void PrintCallingDots(struct Pokenav4Struct *); +static bool32 WaitForCallingDotsText(struct Pokenav4Struct *); +static void PrintMatchCallMessage(struct Pokenav4Struct *); +static bool32 WaitForMatchCallMessageText(struct Pokenav4Struct *); static void sub_81CC09C(struct Pokenav4Struct *); -static void sub_81CC11C(struct Pokenav4Struct *); -static bool32 sub_81CC140(struct Pokenav4Struct *); +static void PrintTrainerIsCloseBy(struct Pokenav4Struct *); +static bool32 WaitForTrainerIsCloseByText(struct Pokenav4Struct *); static void sub_81CC1DC(struct Pokenav4Struct *); static bool32 sub_81CC204(struct Pokenav4Struct *); static void sub_81CC014(struct Pokenav4Struct *); @@ -82,27 +82,27 @@ static bool32 sub_81CC42C(struct Pokenav4Struct *); static void sub_81CC420(struct Pokenav4Struct *); static void sub_81CBC64(u8 taskId); static void sub_81CBCEC(u16 windowId, u32, u32); -static void sub_81CBDF4(u16 windowId); -static void sub_81CBE0C(u16 windowId); -static void sub_81CBE38(u16 windowId); -static void sub_81CBE50(u16 windowId); -static void sub_81CBE88(u16 windowId, const u8 *str, int top); -static void sub_81CBEB4(u16 windowId, const u8 *str, int top); +static void PrintNumberRegisteredLabel(u16 windowId); +static void PrintNumberRegistered(u16 windowId); +static void PrintNumberOfBattlesLabel(u16 windowId); +static void PrintNumberOfBattles(u16 windowId); +static void PrintMatchCallInfoLabel(u16 windowId, const u8 *str, int top); +static void PrintMatchCallInfoNumber(u16 windowId, const u8 *str, int top); static void sub_81CC2F0(struct Pokenav4Struct *, int); -static void sub_81CC330(struct Pokenav4Struct *); +static void CloseMatchCallSelectOptionsWindow(struct Pokenav4Struct *); static struct Sprite *sub_81CC370(void); static void sub_81CC440(struct Sprite *sprite); static void sub_81CC4A4(struct Sprite *sprite); void sub_81CC34C(struct Sprite *sprite); -u32 sub_81CB510(s32); -u32 sub_81CB588(s32); -u32 sub_81CB600(s32); -u32 sub_81CB678(s32); -u32 sub_81CB6F0(s32); +u32 MatchCallListCursorDown(s32); +u32 MatchCallListCursorUp(s32); +u32 MatchCallListPageDown(s32); +u32 MatchCallListPageUp(s32); +u32 SelectMatchCallEntry(s32); u32 sub_81CB734(s32); u32 sub_81CB75C(s32); -u32 sub_81CB7A0(s32); -u32 sub_81CB824(s32); +u32 DoMatchCallMessage(s32); +u32 DoTrainerCloseByMessage(s32); u32 sub_81CB888(s32); u32 sub_81CB93C(s32); u32 sub_81CBAD4(s32); @@ -157,25 +157,25 @@ const struct BgTemplate gUnknown_0862278C[3] = const LoopedTask gUnknown_08622798[] = { - NULL, - sub_81CB510, - sub_81CB588, - sub_81CB600, - sub_81CB678, - sub_81CB6F0, - sub_81CB734, - sub_81CB75C, - sub_81CB7A0, - sub_81CB824, - sub_81CB888, - sub_81CB93C, - sub_81CBAD4, - sub_81CB9C8, - sub_81CBA68, - sub_81CBB74 + [POKENAV_MC_FUNC_NONE] = NULL, + [POKENAV_MC_FUNC_DOWN] = MatchCallListCursorDown, + [POKENAV_MC_FUNC_UP] = MatchCallListCursorUp, + [POKENAV_MC_FUNC_PG_DOWN] = MatchCallListPageDown, + [POKENAV_MC_FUNC_PG_UP] = MatchCallListPageUp, + [POKENAV_MC_FUNC_SELECT] = SelectMatchCallEntry, + [POKENAV_MC_FUNC_6] = sub_81CB734, + [POKENAV_MC_FUNC_7] = sub_81CB75C, + [POKENAV_MC_FUNC_CALL_MSG] = DoMatchCallMessage, + [POKENAV_MC_FUNC_NEARBY_MSG] = DoTrainerCloseByMessage, + [POKENAV_MC_FUNC_10] = sub_81CB888, + [POKENAV_MC_FUNC_11] = sub_81CB93C, + [POKENAV_MC_FUNC_12] = sub_81CBAD4, + [POKENAV_MC_FUNC_13] = sub_81CB9C8, + [POKENAV_MC_FUNC_14] = sub_81CBA68, + [POKENAV_MC_FUNC_15] = sub_81CBB74 }; -const struct WindowTemplate gUnknown_086227D8 = +static const struct WindowTemplate sMatchCallLocationWindowTemplate = { .bg = 2, .tilemapLeft = 0, @@ -186,7 +186,7 @@ const struct WindowTemplate gUnknown_086227D8 = .baseBlock = 16 }; -const struct WindowTemplate gUnknown_086227E0 = +static const struct WindowTemplate sMatchCallInfoBoxWindowTemplate = { .bg = 2, .tilemapLeft = 0, @@ -204,7 +204,8 @@ static const u8 *const sMatchCallOptionTexts[MATCH_CALL_OPTION_COUNT] = [MATCH_CALL_OPTION_CANCEL] = gText_Cancel6 }; -const u8 gUnknown_086227F4[] = _("·{PAUSE 0x04}·{PAUSE 0x04}·{PAUSE 0x04}·{PAUSE 0x04}·\p"); +// The series of 5 dots that appear when someone is called with Match Call +const u8 gText_CallingDots[] = _("·{PAUSE 0x04}·{PAUSE 0x04}·{PAUSE 0x04}·{PAUSE 0x04}·\p"); const struct WindowTemplate gUnknown_08622808 = { @@ -308,9 +309,9 @@ void sub_81CB2E0(void) struct Pokenav4Struct *state = GetSubstructPtr(6); sub_81CC2B4(); sub_81CBC1C(); - RemoveWindow(state->unk12); - RemoveWindow(state->unk10); - RemoveWindow(state->unk14); + RemoveWindow(state->infoBoxWindowId); + RemoveWindow(state->locWindowId); + RemoveWindow(state->msgBoxWindowId); FreePokenavSubstruct(6); } @@ -335,42 +336,42 @@ static u32 sub_81CB324(s32 taskState) CopyBgTilemapBufferToVram(2); CopyPaletteIntoBufferUnfaded(gUnknown_08622510, 0x20, 0x20); CopyBgTilemapBufferToVram(2); - return 0; + return LT_INC_AND_PAUSE; case 1: if (free_temp_tile_data_buffers_if_possible()) - return 2; + return LT_PAUSE; sub_8199DF0(1, 0, 0, 1); SetBgTilemapBuffer(1, state->unk24); FillBgTilemapBufferRect_Palette0(1, 0x1000, 0, 0, 32, 20); CopyPaletteIntoBufferUnfaded(gUnknown_086226E0, 0x10, 0x20); CopyBgTilemapBufferToVram(1); - return 0; + return LT_INC_AND_PAUSE; case 2: if (free_temp_tile_data_buffers_if_possible()) - return 2; + return LT_PAUSE; sub_81CC034(state); decompress_and_copy_tile_data_to_vram(3, gUnknown_08622760, 0, 0, 0); CopyPaletteIntoBufferUnfaded(gUnknown_08622700, 0x30, 0x20); CopyPaletteIntoBufferUnfaded(gUnknown_08622720, 0x50, 0x20); - return 0; + return LT_INC_AND_PAUSE; case 3: if (free_temp_tile_data_buffers_if_possible() || !sub_81CAE28()) - return 2; + return LT_PAUSE; sub_81CBBB8(); - return 0; + return LT_INC_AND_PAUSE; case 4: if (sub_81C8224()) - return 2; + return LT_PAUSE; - sub_81CBD78(state); - return 0; + DrawMatchCallLeftColumnWindows(state); + return LT_INC_AND_PAUSE; case 5: - sub_81CBDC0(state); - sub_81CBEF8(state, 0); - return 0; + UpdateMatchCallInfoBox(state); + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 6: ChangeBgX(1, 0, 0); ChangeBgY(1, 0, 0); @@ -381,19 +382,19 @@ static u32 sub_81CB324(s32 taskState) LoadLeftHeaderGfxForIndex(3); sub_81C7FA0(3, 1, 0); sub_81C7AC0(1); - return 0; + return LT_INC_AND_PAUSE; case 7: if (IsPaletteFadeActive() || sub_81C8010()) - return 2; + return LT_PAUSE; sub_81CBC38(1); - return 4; + return LT_FINISH; default: - return 4; + return LT_FINISH; } } -u32 sub_81CB510(s32 taskState) +u32 MatchCallListCursorDown(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -410,27 +411,27 @@ u32 sub_81CB510(s32 taskState) PlaySE(SE_SELECT); // fall through default: - return 0; + return LT_INC_AND_PAUSE; } break; case 1: if (sub_81C8630()) - return 2; + return LT_PAUSE; - sub_81CBEF8(state, 0); - return 0; + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 2: - sub_81CBEF8(state, 0); - return 0; + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } -u32 sub_81CB588(s32 taskState) +u32 MatchCallListCursorUp(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -447,27 +448,27 @@ u32 sub_81CB588(s32 taskState) PlaySE(SE_SELECT); // fall through default: - return 0; + return LT_INC_AND_PAUSE; } break; case 1: if (sub_81C8630()) - return 2; + return LT_PAUSE; - sub_81CBEF8(state, 0); - return 0; + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 2: - sub_81CBEF8(state, 0); - return 0; + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } -u32 sub_81CB600(s32 taskState) +u32 MatchCallListPageDown(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -484,27 +485,27 @@ u32 sub_81CB600(s32 taskState) PlaySE(SE_SELECT); // fall through default: - return 0; + return LT_INC_AND_PAUSE; } break; case 1: if (sub_81C8630()) - return 2; + return LT_PAUSE; - sub_81CBEF8(state, 0); - return 0; + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 2: - sub_81CBEF8(state, 0); - return 0; + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } -u32 sub_81CB678(s32 taskState) +u32 MatchCallListPageUp(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -521,43 +522,43 @@ u32 sub_81CB678(s32 taskState) PlaySE(SE_SELECT); // fall through default: - return 0; + return LT_INC_AND_PAUSE; } break; case 1: if (sub_81C8630()) - return 2; + return LT_PAUSE; - sub_81CBEF8(state, 0); - return 0; + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 2: - sub_81CBEF8(state, 0); - return 0; + PrintMatchCallLocation(state, 0); + return LT_INC_AND_PAUSE; case 3: if (IsDma3ManagerBusyWithBgCopy()) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } -u32 sub_81CB6F0(s32 taskState) +u32 SelectMatchCallEntry(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) { case 0: PlaySE(SE_SELECT); - sub_81CBF60(state); + PrintMatchCallSelectionOptions(state); sub_81C7BA4(7); - return 0; + return LT_INC_AND_PAUSE; case 1: if (sub_81CBFC4(state)) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } u32 sub_81CB734(s32 taskState) @@ -569,7 +570,7 @@ u32 sub_81CB734(s32 taskState) state = GetSubstructPtr(6); var0 = sub_81CB01C(); sub_81CC344(state, var0); - return 4; + return LT_FINISH; } u32 sub_81CB75C(s32 taskState) @@ -581,17 +582,17 @@ u32 sub_81CB75C(s32 taskState) PlaySE(SE_SELECT); sub_81CBFF0(state); sub_81C7BA4(6); - return 0; + return LT_INC_AND_PAUSE; case 1: if (sub_81CC004(state)) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } -u32 sub_81CB7A0(s32 taskState) +u32 DoMatchCallMessage(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -599,31 +600,31 @@ u32 sub_81CB7A0(s32 taskState) case 0: ToggleMatchCallVerticalArrows(TRUE); sub_81CC058(state); - return 0; + return LT_INC_AND_PAUSE; case 1: if (sub_81CC0D0(state)) - return 2; + return LT_PAUSE; - sub_81CC0E0(state); + PrintCallingDots(state); PlaySE(SE_TOREEYE); state->unkE = 0; - return 0; + return LT_INC_AND_PAUSE; case 2: - if (sub_81CC104(state)) - return 2; + if (WaitForCallingDotsText(state)) + return LT_PAUSE; - sub_81CC158(state); - return 0; + PrintMatchCallMessage(state); + return LT_INC_AND_PAUSE; case 3: - if (sub_81CC194(state)) - return 2; + if (WaitForMatchCallMessageText(state)) + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } -u32 sub_81CB824(s32 taskState) +u32 DoTrainerCloseByMessage(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -633,26 +634,26 @@ u32 sub_81CB824(s32 taskState) sub_81CC09C(state); ToggleMatchCallVerticalArrows(TRUE); state->unkE = 1; - return 0; + return LT_INC_AND_PAUSE; case 1: if (sub_81CC0D0(state)) - return 2; + return LT_PAUSE; - sub_81CC11C(state); - return 0; + PrintTrainerIsCloseBy(state); + return LT_INC_AND_PAUSE; case 2: - if (sub_81CC140(state)) - return 2; + if (WaitForTrainerIsCloseByText(state)) + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } u32 sub_81CB888(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); - u32 result = 0; + u32 result = LT_INC_AND_PAUSE; switch (taskState) { @@ -667,45 +668,45 @@ u32 sub_81CB888(s32 taskState) break; case 2: if (sub_81CC204(state)) - result = 2; + result = LT_PAUSE; break; case 3: sub_81CBFF0(state); break; case 4: if (sub_81CC004(state)) - result = 2; + result = LT_PAUSE; sub_81C7BA4(6); break; case 5: if (IsDma3ManagerBusyWithBgCopy_()) { - result = 2; + result = LT_PAUSE; } else { if (state->unkF) { sub_81C8838(); - result = 1; + result = LT_INC_AND_CONTINUE; } else { ToggleMatchCallVerticalArrows(FALSE); - result = 4; + result = LT_FINISH; } } break; case 6: if (IsDma3ManagerBusyWithBgCopy()) { - result = 2; + result = LT_PAUSE; } else { ToggleMatchCallVerticalArrows(FALSE); - result = 4; + result = LT_FINISH; } break; } @@ -722,24 +723,24 @@ u32 sub_81CB93C(s32 taskState) PlaySE(SE_SELECT); sub_81C877C(); sub_81CC014(state); - return 0; + return LT_INC_AND_PAUSE; case 1: if (sub_81C8820() || sub_81CC004(state)) - return 2; + return LT_PAUSE; sub_81C7BA4(8); - return 0; + return LT_INC_AND_PAUSE; case 2: sub_81C87AC(0); sub_81CC39C(state); - return 0; + return LT_INC_AND_PAUSE; case 3: if (sub_81C8820() || sub_81CC42C(state) || IsDma3ManagerBusyWithBgCopy_()) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } u32 sub_81CB9C8(s32 taskState) @@ -757,28 +758,28 @@ u32 sub_81CB9C8(s32 taskState) PlaySE(SE_SELECT); state->unk16 = var0; sub_81CC420(state); - return 0; + return LT_INC_AND_PAUSE; } break; case 1: if (sub_81CC42C(state)) - return 2; + return LT_PAUSE; - sub_81CBEF8(state, state->unk16); - return 0; + PrintMatchCallLocation(state, state->unk16); + return LT_INC_AND_PAUSE; case 2: sub_81C87AC(state->unk16); - return 0; + return LT_INC_AND_PAUSE; case 3: sub_81CC39C(state); - return 0; + return LT_INC_AND_PAUSE; case 4: if (sub_81C8820() || sub_81CC42C(state)) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } u32 sub_81CBA68(s32 taskState) @@ -790,21 +791,21 @@ u32 sub_81CBA68(s32 taskState) PlaySE(SE_SELECT); sub_81CC420(state); sub_81C87F0(); - return 0; + return LT_INC_AND_PAUSE; case 1: if (sub_81C8820() || sub_81CC42C(state)) - return 2; + return LT_PAUSE; sub_81C7BA4(6); - sub_81CBDC0(state); - return 0; + UpdateMatchCallInfoBox(state); + return LT_INC_AND_PAUSE; case 2: if (IsDma3ManagerBusyWithBgCopy()) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } u32 sub_81CBAD4(s32 taskState) @@ -822,28 +823,28 @@ u32 sub_81CBAD4(s32 taskState) PlaySE(SE_SELECT); state->unk16 = var0; sub_81CC420(state); - return 0; + return LT_INC_AND_PAUSE; } break; case 1: if (sub_81CC42C(state)) - return 2; + return LT_PAUSE; - sub_81CBEF8(state, state->unk16); - return 0; + PrintMatchCallLocation(state, state->unk16); + return LT_INC_AND_PAUSE; case 2: sub_81C87AC(state->unk16); - return 0; + return LT_INC_AND_PAUSE; case 3: sub_81CC39C(state); - return 0; + return LT_INC_AND_PAUSE; case 4: if (sub_81C8820() || sub_81CC42C(state)) - return 2; + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } u32 sub_81CBB74(s32 taskState) @@ -855,16 +856,16 @@ u32 sub_81CBB74(s32 taskState) sub_81CBC38(0); sub_81C7AC0(0); sub_81C78A0(); - return 0; + return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy()) - return 2; + return LT_PAUSE; sub_81C7FDC(); break; } - return 4; + return LT_FINISH; } static void sub_81CBBB8(void) @@ -939,45 +940,45 @@ void sub_81CBD48(u16 windowId, u32 arg0) tilemap[0x20] = 0x5002; } -static void sub_81CBD78(struct Pokenav4Struct *state) +static void DrawMatchCallLeftColumnWindows(struct Pokenav4Struct *state) { - state->unk10 = AddWindow(&gUnknown_086227D8); - state->unk12 = AddWindow(&gUnknown_086227E0); - FillWindowPixelBuffer(state->unk10, PIXEL_FILL(1)); - PutWindowTilemap(state->unk10); - FillWindowPixelBuffer(state->unk12, PIXEL_FILL(1)); - PutWindowTilemap(state->unk12); - CopyWindowToVram(state->unk10, 1); + state->locWindowId = AddWindow(&sMatchCallLocationWindowTemplate); + state->infoBoxWindowId = AddWindow(&sMatchCallInfoBoxWindowTemplate); + FillWindowPixelBuffer(state->locWindowId, PIXEL_FILL(1)); + PutWindowTilemap(state->locWindowId); + FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); + PutWindowTilemap(state->infoBoxWindowId); + CopyWindowToVram(state->locWindowId, 1); } -static void sub_81CBDC0(struct Pokenav4Struct *state) +static void UpdateMatchCallInfoBox(struct Pokenav4Struct *state) { - FillWindowPixelBuffer(state->unk12, PIXEL_FILL(1)); - sub_81CBDF4(state->unk12); - sub_81CBE0C(state->unk12); - sub_81CBE38(state->unk12); - sub_81CBE50(state->unk12); - CopyWindowToVram(state->unk12, 2); + FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); + PrintNumberRegisteredLabel(state->infoBoxWindowId); + PrintNumberRegistered(state->infoBoxWindowId); + PrintNumberOfBattlesLabel(state->infoBoxWindowId); + PrintNumberOfBattles(state->infoBoxWindowId); + CopyWindowToVram(state->infoBoxWindowId, 2); } -static void sub_81CBDF4(u16 windowId) +static void PrintNumberRegisteredLabel(u16 windowId) { - sub_81CBE88(windowId, gText_NumberRegistered, 0); + PrintMatchCallInfoLabel(windowId, gText_NumberRegistered, 0); } -static void sub_81CBE0C(u16 windowId) +static void PrintNumberRegistered(u16 windowId) { u8 str[3]; ConvertIntToDecimalStringN(str, sub_81CAE38(), STR_CONV_MODE_LEFT_ALIGN, 3); - sub_81CBEB4(windowId, str, 1); + PrintMatchCallInfoNumber(windowId, str, 1); } -static void sub_81CBE38(u16 windowId) +static void PrintNumberOfBattlesLabel(u16 windowId) { - sub_81CBE88(windowId, gText_NumberOfBattles, 2); + PrintMatchCallInfoLabel(windowId, gText_NumberOfBattles, 2); } -static void sub_81CBE50(u16 windowId) +static void PrintNumberOfBattles(u16 windowId) { u8 str[5]; int numTrainerBattles = GetGameStat(GAME_STAT_TRAINER_BATTLES); @@ -985,23 +986,23 @@ static void sub_81CBE50(u16 windowId) numTrainerBattles = 99999; ConvertIntToDecimalStringN(str, numTrainerBattles, STR_CONV_MODE_LEFT_ALIGN, 5); - sub_81CBEB4(windowId, str, 3); + PrintMatchCallInfoNumber(windowId, str, 3); } -static void sub_81CBE88(u16 windowId, const u8 *str, int top) +static void PrintMatchCallInfoLabel(u16 windowId, const u8 *str, int top) { int y = top * 16 + 1; AddTextPrinterParameterized(windowId, 7, str, 2, y, TEXT_SPEED_FF, NULL); } -static void sub_81CBEB4(u16 windowId, const u8 *str, int top) +static void PrintMatchCallInfoNumber(u16 windowId, const u8 *str, int top) { int x = GetStringRightAlignXOffset(7, str, 86); int y = top * 16 + 1; AddTextPrinterParameterized(windowId, 7, str, x, y, TEXT_SPEED_FF, NULL); } -static void sub_81CBEF8(struct Pokenav4Struct *state, int arg1) +static void PrintMatchCallLocation(struct Pokenav4Struct *state, int arg1) { u8 mapName[32]; int x; @@ -1013,25 +1014,25 @@ static void sub_81CBEF8(struct Pokenav4Struct *state, int arg1) StringCopy(mapName, gText_Unknown); x = GetStringCenterAlignXOffset(7, mapName, 88); - FillWindowPixelBuffer(state->unk10, PIXEL_FILL(1)); - AddTextPrinterParameterized(state->unk10, 7, mapName, x, 1, 0, NULL); + FillWindowPixelBuffer(state->locWindowId, PIXEL_FILL(1)); + AddTextPrinterParameterized(state->locWindowId, 7, mapName, x, 1, 0, NULL); } -static void sub_81CBF60(struct Pokenav4Struct *state) +static void PrintMatchCallSelectionOptions(struct Pokenav4Struct *state) { u32 i; - FillWindowPixelBuffer(state->unk12, PIXEL_FILL(1)); + FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); for (i = 0; i < MATCH_CALL_OPTION_COUNT; i++) { int optionText = sub_81CB02C(i); if (optionText == MATCH_CALL_OPTION_COUNT) break; - AddTextPrinterParameterized(state->unk12, 7, sMatchCallOptionTexts[optionText], 16, i * 16 + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(state->infoBoxWindowId, 7, sMatchCallOptionTexts[optionText], 16, i * 16 + 1, TEXT_SPEED_FF, NULL); } - CopyWindowToVram(state->unk12, 2); + CopyWindowToVram(state->infoBoxWindowId, 2); } static bool32 sub_81CBFC4(struct Pokenav4Struct *state) @@ -1047,8 +1048,8 @@ static bool32 sub_81CBFC4(struct Pokenav4Struct *state) static void sub_81CBFF0(struct Pokenav4Struct *state) { - sub_81CC330(state); - sub_81CBDC0(state); + CloseMatchCallSelectOptionsWindow(state); + UpdateMatchCallInfoBox(state); } static bool32 sub_81CC004(struct Pokenav4Struct *state) @@ -1058,26 +1059,26 @@ static bool32 sub_81CC004(struct Pokenav4Struct *state) static void sub_81CC014(struct Pokenav4Struct *state) { - sub_81CC330(state); - FillWindowPixelBuffer(state->unk12, PIXEL_FILL(1)); - CopyWindowToVram(state->unk12, 2); + CloseMatchCallSelectOptionsWindow(state); + FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); + CopyWindowToVram(state->infoBoxWindowId, 2); } static void sub_81CC034(struct Pokenav4Struct *state) { - state->unk14 = AddWindow(&gUnknown_08622808); - sub_8197184(state->unk14, 1, 4); + state->msgBoxWindowId = AddWindow(&gUnknown_08622808); + sub_8197184(state->msgBoxWindowId, 1, 4); sub_81C7B40(); } static void sub_81CC058(struct Pokenav4Struct *state) { struct Sprite *sprite; - sub_8197184(state->unk14, 1, 4); - sub_81971C4(state->unk14, 1, 4); - FillWindowPixelBuffer(state->unk14, PIXEL_FILL(1)); - PutWindowTilemap(state->unk14); - CopyWindowToVram(state->unk14, 3); + sub_8197184(state->msgBoxWindowId, 1, 4); + sub_81971C4(state->msgBoxWindowId, 1, 4); + FillWindowPixelBuffer(state->msgBoxWindowId, PIXEL_FILL(1)); + PutWindowTilemap(state->msgBoxWindowId); + CopyWindowToVram(state->msgBoxWindowId, 3); sprite = PauseSpinningPokenavSprite(); sprite->pos1.x = 24; sprite->pos1.y = 112; @@ -1086,11 +1087,11 @@ static void sub_81CC058(struct Pokenav4Struct *state) static void sub_81CC09C(struct Pokenav4Struct *state) { - LoadUserWindowBorderGfx(state->unk14, 1, 0x40); - DrawTextBorderOuter(state->unk14, 1, 4); - FillWindowPixelBuffer(state->unk14, PIXEL_FILL(1)); - PutWindowTilemap(state->unk14); - CopyWindowToVram(state->unk14, 3); + LoadUserWindowBorderGfx(state->msgBoxWindowId, 1, 0x40); + DrawTextBorderOuter(state->msgBoxWindowId, 1, 4); + FillWindowPixelBuffer(state->msgBoxWindowId, PIXEL_FILL(1)); + PutWindowTilemap(state->msgBoxWindowId); + CopyWindowToVram(state->msgBoxWindowId, 3); } static bool32 sub_81CC0D0(struct Pokenav4Struct *state) @@ -1098,37 +1099,37 @@ static bool32 sub_81CC0D0(struct Pokenav4Struct *state) return IsDma3ManagerBusyWithBgCopy(); } -static void sub_81CC0E0(struct Pokenav4Struct *state) +static void PrintCallingDots(struct Pokenav4Struct *state) { - AddTextPrinterParameterized(state->unk14, 1, gUnknown_086227F4, 32, 1, 1, NULL); + AddTextPrinterParameterized(state->msgBoxWindowId, 1, gText_CallingDots, 32, 1, 1, NULL); } -static bool32 sub_81CC104(struct Pokenav4Struct *state) +static bool32 WaitForCallingDotsText(struct Pokenav4Struct *state) { RunTextPrinters(); - return IsTextPrinterActive(state->unk14); + return IsTextPrinterActive(state->msgBoxWindowId); } -static void sub_81CC11C(struct Pokenav4Struct *state) +static void PrintTrainerIsCloseBy(struct Pokenav4Struct *state) { - AddTextPrinterParameterized(state->unk14, 1, gText_TrainerCloseBy, 0, 1, 1, NULL); + AddTextPrinterParameterized(state->msgBoxWindowId, 1, gText_TrainerCloseBy, 0, 1, 1, NULL); } -static bool32 sub_81CC140(struct Pokenav4Struct *state) +static bool32 WaitForTrainerIsCloseByText(struct Pokenav4Struct *state) { RunTextPrinters(); - return IsTextPrinterActive(state->unk14); + return IsTextPrinterActive(state->msgBoxWindowId); } -static void sub_81CC158(struct Pokenav4Struct *state) +static void PrintMatchCallMessage(struct Pokenav4Struct *state) { int index = GetSelectedMatchCall(); - const u8 *str = sub_81CAF78(index, &state->unkF); + const u8 *str = GetMatchCallMessageText(index, &state->unkF); u8 speed = GetPlayerTextSpeedDelay(); - AddTextPrinterParameterized(state->unk14, 1, str, 32, 1, speed, NULL); + AddTextPrinterParameterized(state->msgBoxWindowId, 1, str, 32, 1, speed, NULL); } -static bool32 sub_81CC194(struct Pokenav4Struct *state) +static bool32 WaitForMatchCallMessageText(struct Pokenav4Struct *state) { if (gMain.heldKeys & A_BUTTON) gTextFlags.canABSpeedUpPrint = 1; @@ -1136,7 +1137,7 @@ static bool32 sub_81CC194(struct Pokenav4Struct *state) gTextFlags.canABSpeedUpPrint = 0; RunTextPrinters(); - return IsTextPrinterActive(state->unk14); + return IsTextPrinterActive(state->msgBoxWindowId); } static void sub_81CC1DC(struct Pokenav4Struct *state) @@ -1197,7 +1198,7 @@ static void sub_81CC2F0(struct Pokenav4Struct *state, int top) } } -static void sub_81CC330(struct Pokenav4Struct *state) +static void CloseMatchCallSelectOptionsWindow(struct Pokenav4Struct *state) { DestroySprite(state->unk1C); state->unk1C = NULL;