From f58465a274fbae2275766c50206be1a364f21abc Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 1 Apr 2021 02:35:14 -0400 Subject: [PATCH] Document match_call.c --- gflib/string_util.h | 8 +- graphics/interface/menu_border.png | Bin 150 -> 0 bytes graphics/pokenav/match_call_window.png | Bin 0 -> 209 bytes graphics/unknown/unknown_60EA4C.pal | 19 -- include/match_call.h | 4 +- src/match_call.c | 273 ++++++++++++++----------- src/pokenav_match_call_2.c | 6 +- 7 files changed, 165 insertions(+), 145 deletions(-) delete mode 100644 graphics/interface/menu_border.png create mode 100644 graphics/pokenav/match_call_window.png delete mode 100644 graphics/unknown/unknown_60EA4C.pal diff --git a/gflib/string_util.h b/gflib/string_util.h index b921d2391d..229193d52d 100644 --- a/gflib/string_util.h +++ b/gflib/string_util.h @@ -1,10 +1,10 @@ #ifndef GUARD_STRING_UTIL_H #define GUARD_STRING_UTIL_H -extern u8 gStringVar1[]; -extern u8 gStringVar2[]; -extern u8 gStringVar3[]; -extern u8 gStringVar4[]; +extern u8 gStringVar1[0x100]; +extern u8 gStringVar2[0x100]; +extern u8 gStringVar3[0x100]; +extern u8 gStringVar4[0x3E8]; enum StringConvertMode { diff --git a/graphics/interface/menu_border.png b/graphics/interface/menu_border.png deleted file mode 100644 index ba748b169d80ae574c96b36167a2db68e49b928a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^4nWMo0wfq#{`6)7Qn8*cjv*3LefzbA4j6E-?hMXN zjrBj_awRx=vQl>O!d)zCjoaB~MAm&NE)cEU_jgKGp>%}b8ph@eGQy{{C+}Xipnb8L yN5i2btvW#`)D9IY9*8>BJguQ!c;6P5n!U_!3+J}lY%GriS?KBN=d#Wzp$Py({4|^Z diff --git a/graphics/pokenav/match_call_window.png b/graphics/pokenav/match_call_window.png new file mode 100644 index 0000000000000000000000000000000000000000..0541bf1476eab2b74521d8d0ec02ba552b254aac GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^4nWMo!VDyL`#gCAqznRlLR^9L|NsAi0wL1zyiaLx~2FB|F-j96O|)8c*jL6fkOXv@)l#1~7y*JWvo( yFfmk+W)E*j(PiG$oWM0f_FTgo)fr4F>zNtsWfE(5`KsxHZ1i;Xb6Mw<&;$UxPD*|N literal 0 HcmV?d00001 diff --git a/graphics/unknown/unknown_60EA4C.pal b/graphics/unknown/unknown_60EA4C.pal deleted file mode 100644 index 87bb7840e2..0000000000 --- a/graphics/unknown/unknown_60EA4C.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -0 0 0 -255 255 255 -0 0 0 -197 197 205 -32 222 148 -106 238 180 -180 255 213 -213 197 255 -238 230 255 -255 189 180 -255 222 213 -189 148 0 -238 238 230 -0 0 0 -0 0 0 -0 0 0 diff --git a/include/match_call.h b/include/match_call.h index bc5f374bd1..8aebb3bc77 100644 --- a/include/match_call.h +++ b/include/match_call.h @@ -17,7 +17,7 @@ bool32 IsMatchCallTaskActive(void); void StartMatchCallFromScript(const u8 *message); void BufferPokedexRatingForMatchCall(u8 *destStr); bool32 SelectMatchCallMessage(int, u8 *); -void sub_8197184(u32 windowId, u32 destOffset, u32 paletteId); -void sub_81971C4(u32 windowId, u32 tileOffset, u32 paletteId); +void LoadMatchCallWindowGfx(u32 windowId, u32 destOffset, u32 paletteId); +void DrawMatchCallTextBoxBorder(u32 windowId, u32 tileOffset, u32 paletteId); #endif //GUARD_MATCH_CALL_H diff --git a/src/match_call.c b/src/match_call.c index b78441f931..c047ca123e 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -39,7 +39,7 @@ struct MatchCallState u32 minutes; u16 trainerId; u8 stepCounter; - u8 triggeredFromScript; + bool8 triggeredFromScript; }; struct MatchCallTrainerTextInfo @@ -82,27 +82,27 @@ static u16 GetRematchTrainerLocation(int); static bool32 TrainerIsEligibleForRematch(int); static void StartMatchCall(void); static void ExecuteMatchCall(u8); -static void DrawMatchCallTextBoxBorder(u32, u32, u32); -static void sub_8196694(u8); +static void DrawMatchCallTextBoxBorder_Internal(u32, u32, u32); +static void Task_SpinPokenavIcon(u8); static void InitMatchCallTextPrinter(int, const u8 *); -static bool32 ExecuteMatchCallTextPrinter(int); +static bool32 RunMatchCallTextPrinter(int); static const struct MatchCallText *GetSameRouteMatchCallText(int, u8 *); static const struct MatchCallText *GetDifferentRouteMatchCallText(int, u8 *); static const struct MatchCallText *GetBattleMatchCallText(int, u8 *); static const struct MatchCallText *GetGeneralMatchCallText(int, u8 *); -static bool32 sub_8196D74(int); +static bool32 ShouldTrainerRequestBattle(int); static void BuildMatchCallString(int, const struct MatchCallText *, u8 *); static u16 GetFrontierStreakInfo(u16, u32 *); static void PopulateMatchCallStringVars(int, const s8 *); static void PopulateMatchCallStringVar(int, int, u8 *); -static bool32 LoadMatchCallWindowGfx(u8); -static bool32 MoveMatchCallWindowToVram(u8); -static bool32 PrintMatchCallIntroEllipsis(u8); -static bool32 sub_81962B0(u8); -static bool32 sub_81962D8(u8); -static bool32 sub_8196330(u8); -static bool32 sub_8196390(u8); -static bool32 sub_81963F0(u8); +static bool32 MatchCall_LoadGfx(u8); +static bool32 MatchCall_DrawWindow(u8); +static bool32 MatchCall_ReadyIntro(u8); +static bool32 MatchCall_SlideWindowIn(u8); +static bool32 MatchCall_PrintIntro(u8); +static bool32 MatchCall_PrintMessage(u8); +static bool32 MatchCall_SlideWindowOut(u8); +static bool32 MatchCall_EndCall(u8); static void PopulateTrainerName(int, u8 *); static void PopulateMapName(int, u8 *); static void PopulateSpeciesFromTrainerLocation(int, u8 *); @@ -977,7 +977,7 @@ void InitMatchCallCounters(void) static u32 GetCurrentTotalMinutes(struct Time *time) { - return time->days * 1440 + time->hours * 60 + time->minutes; + return time->days * 24 * 60 + time->hours * 60 + time->minutes; } static bool32 UpdateMatchCallMinutesCounter(void) @@ -1041,11 +1041,11 @@ static bool32 SelectMatchCallTrainer(void) { u32 matchCallId; u32 numRegistered = GetNumRegisteredNPCs(); - if (!numRegistered) + if (numRegistered == 0) return FALSE; gMatchCallState.trainerId = GetActiveMatchCallTrainerId(Random() % numRegistered); - gMatchCallState.triggeredFromScript = 0; + gMatchCallState.triggeredFromScript = FALSE; if (gMatchCallState.trainerId == REMATCH_TABLE_ENTRIES) return FALSE; @@ -1085,10 +1085,23 @@ static u32 GetActiveMatchCallTrainerId(u32 activeMatchCallId) return REMATCH_TABLE_ENTRIES; } +/* + From the function calls below, a call can only be triggered... + - If the player has match call + - Every 10th step + - Every 10 minutes + - 1/3 of the time (or 2/3 of the time, if the lead party Pokémon has Lightning Rod) + - If in a valid outdoor map (not Safari Zone, not underwater, not Mt Chimney with Team Magma, not Sootopolis with legendaries) + - If an eligible trainer to call the player is selected +*/ bool32 TryStartMatchCall(void) { - if (FlagGet(FLAG_HAS_MATCH_CALL) && UpdateMatchCallStepCounter() && UpdateMatchCallMinutesCounter() - && CheckMatchCallChance() && MapAllowsMatchCall() && SelectMatchCallTrainer()) + if (FlagGet(FLAG_HAS_MATCH_CALL) + && UpdateMatchCallStepCounter() + && UpdateMatchCallMinutesCounter() + && CheckMatchCallChance() + && MapAllowsMatchCall() + && SelectMatchCallTrainer()) { StartMatchCall(); return TRUE; @@ -1099,7 +1112,7 @@ bool32 TryStartMatchCall(void) void StartMatchCallFromScript(const u8 *message) { - gMatchCallState.triggeredFromScript = 1; + gMatchCallState.triggeredFromScript = TRUE; StartMatchCall(); } @@ -1122,33 +1135,37 @@ static void StartMatchCall(void) CreateTask(ExecuteMatchCall, 1); } -static const u16 sUnknown_0860EA4C[] = INCBIN_U16("graphics/unknown/unknown_60EA4C.gbapal"); -static const u8 sUnknown_0860EA6C[] = INCBIN_U8("graphics/interface/menu_border.4bpp"); -static const u16 sPokeNavIconPalette[] = INCBIN_U16("graphics/pokenav/icon.gbapal"); -static const u32 sPokeNavIconGfx[] = INCBIN_U32("graphics/pokenav/icon.4bpp.lz"); +static const u16 sMatchCallWindow_Pal[] = INCBIN_U16("graphics/pokenav/match_call_window.gbapal"); +static const u8 sMatchCallWindow_Gfx[] = INCBIN_U8("graphics/pokenav/match_call_window.4bpp"); +static const u16 sPokenavIcon_Pal[] = INCBIN_U16("graphics/pokenav/icon.gbapal"); +static const u32 sPokenavIcon_Gfx[] = INCBIN_U32("graphics/pokenav/icon.4bpp.lz"); static const u8 sText_PokenavCallEllipsis[] = _("………………\p"); +#define tState data[0] +#define tWindowId data[2] +#define tIconTaskId data[5] + static bool32 (*const sMatchCallTaskFuncs[])(u8) = { - LoadMatchCallWindowGfx, - MoveMatchCallWindowToVram, - PrintMatchCallIntroEllipsis, - sub_81962B0, - sub_81962D8, - sub_8196330, - sub_8196390, - sub_81963F0, + MatchCall_LoadGfx, + MatchCall_DrawWindow, + MatchCall_ReadyIntro, + MatchCall_SlideWindowIn, + MatchCall_PrintIntro, + MatchCall_PrintMessage, + MatchCall_SlideWindowOut, + MatchCall_EndCall, }; static void ExecuteMatchCall(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - if (sMatchCallTaskFuncs[taskData[0]](taskId)) + s16 *data = gTasks[taskId].data; + if (sMatchCallTaskFuncs[tState](taskId)) { - taskData[0]++; - taskData[1] = 0; - if ((u16)taskData[0] > 7) + tState++; + data[1] = 0; // Never read + if ((u16)tState > 7) DestroyTask(taskId); } } @@ -1164,65 +1181,69 @@ static const struct WindowTemplate sMatchCallTextWindow = .baseBlock = 0x200 }; -static bool32 LoadMatchCallWindowGfx(u8 taskId) +#define TILE_MC_WINDOW 0x270 +#define TILE_POKENAV_ICON 0x279 + +static bool32 MatchCall_LoadGfx(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - taskData[2] = AddWindow(&sMatchCallTextWindow); - if (taskData[2] == WINDOW_NONE) + s16 *data = gTasks[taskId].data; + tWindowId = AddWindow(&sMatchCallTextWindow); + if (tWindowId == WINDOW_NONE) { DestroyTask(taskId); return FALSE; } - if (LoadBgTiles(0, sUnknown_0860EA6C, sizeof(sUnknown_0860EA6C), 0x270) == 0xFFFF) + if (LoadBgTiles(0, sMatchCallWindow_Gfx, sizeof(sMatchCallWindow_Gfx), TILE_MC_WINDOW) == 0xFFFF) { - RemoveWindow(taskData[2]); + RemoveWindow(tWindowId); DestroyTask(taskId); return FALSE; } - if (!DecompressAndCopyTileDataToVram(0, sPokeNavIconGfx, 0, 0x279, 0)) + if (!DecompressAndCopyTileDataToVram(0, sPokenavIcon_Gfx, 0, TILE_POKENAV_ICON, 0)) { - RemoveWindow(taskData[2]); + RemoveWindow(tWindowId); DestroyTask(taskId); return FALSE; } - FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8)); - LoadPalette(sUnknown_0860EA4C, 0xE0, 0x20); - LoadPalette(sPokeNavIconPalette, 0xF0, 0x20); + FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); + LoadPalette(sMatchCallWindow_Pal, 0xE0, sizeof(sMatchCallWindow_Pal)); + LoadPalette(sPokenavIcon_Pal, 0xF0, sizeof(sPokenavIcon_Pal)); ChangeBgY(0, -0x2000, 0); return TRUE; } -static bool32 MoveMatchCallWindowToVram(u8 taskId) +static bool32 MatchCall_DrawWindow(u8 taskId) { - s16 *taskData = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; if (FreeTempTileDataBuffersIfPossible()) return FALSE; - PutWindowTilemap(taskData[2]); - DrawMatchCallTextBoxBorder(taskData[2], 0x270, 14); - WriteSequenceToBgTilemapBuffer(0, 0xF279, 1, 15, 4, 4, 17, 1); - taskData[5] = CreateTask(sub_8196694, 10); - CopyWindowToVram(taskData[2], 2); + PutWindowTilemap(tWindowId); + DrawMatchCallTextBoxBorder_Internal(tWindowId, TILE_MC_WINDOW, 14); + WriteSequenceToBgTilemapBuffer(0, (0xF << 12) | TILE_POKENAV_ICON, 1, 15, 4, 4, 17, 1); + tIconTaskId = CreateTask(Task_SpinPokenavIcon, 10); + CopyWindowToVram(tWindowId, 2); CopyBgTilemapBufferToVram(0); return TRUE; } -static bool32 PrintMatchCallIntroEllipsis(u8 taskId) +static bool32 MatchCall_ReadyIntro(u8 taskId) { - s16 *taskData = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; if (!IsDma3ManagerBusyWithBgCopy()) { - InitMatchCallTextPrinter(taskData[2], sText_PokenavCallEllipsis); + // Note that "..." is not printed yet, just readied + InitMatchCallTextPrinter(tWindowId, sText_PokenavCallEllipsis); return TRUE; } return FALSE; } -static bool32 sub_81962B0(u8 taskId) +static bool32 MatchCall_SlideWindowIn(u8 taskId) { if (ChangeBgY(0, 0x600, 1) >= 0) { @@ -1233,29 +1254,30 @@ static bool32 sub_81962B0(u8 taskId) return FALSE; } -static bool32 sub_81962D8(u8 taskId) +static bool32 MatchCall_PrintIntro(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - if (!ExecuteMatchCallTextPrinter(taskData[2])) + s16 *data = gTasks[taskId].data; + if (!RunMatchCallTextPrinter(tWindowId)) { - FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8)); + FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); + + // Ready the message if (!gMatchCallState.triggeredFromScript) SelectMatchCallMessage(gMatchCallState.trainerId, gStringVar4); - - InitMatchCallTextPrinter(taskData[2], gStringVar4); + InitMatchCallTextPrinter(tWindowId, gStringVar4); return TRUE; } return FALSE; } -static bool32 sub_8196330(u8 taskId) +static bool32 MatchCall_PrintMessage(u8 taskId) { - s16 *taskData = gTasks[taskId].data; - if (!ExecuteMatchCallTextPrinter(taskData[2]) && !IsSEPlaying() && JOY_NEW(A_BUTTON | B_BUTTON)) + s16 *data = gTasks[taskId].data; + if (!RunMatchCallTextPrinter(tWindowId) && !IsSEPlaying() && JOY_NEW(A_BUTTON | B_BUTTON)) { - FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8)); - CopyWindowToVram(taskData[2], 2); + FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); + CopyWindowToVram(tWindowId, 2); PlaySE(SE_POKENAV_HANG_UP); return TRUE; } @@ -1263,14 +1285,14 @@ static bool32 sub_8196330(u8 taskId) return FALSE; } -static bool32 sub_8196390(u8 taskId) +static bool32 MatchCall_SlideWindowOut(u8 taskId) { - s16 *taskData = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; if (ChangeBgY(0, 0x600, 2) <= -0x2000) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 14, 30, 6); - DestroyTask(taskData[5]); - RemoveWindow(taskData[2]); + DestroyTask(tIconTaskId); + RemoveWindow(tWindowId); CopyBgTilemapBufferToVram(0); return TRUE; } @@ -1278,7 +1300,7 @@ static bool32 sub_8196390(u8 taskId) return FALSE; } -static bool32 sub_81963F0(u8 taskId) +static bool32 MatchCall_EndCall(u8 taskId) { u8 playerObjectId; if (!IsDma3ManagerBusyWithBgCopy() && !IsSEPlaying()) @@ -1300,7 +1322,7 @@ static bool32 sub_81963F0(u8 taskId) return FALSE; } -static void DrawMatchCallTextBoxBorder(u32 windowId, u32 tileOffset, u32 paletteId) +static void DrawMatchCallTextBoxBorder_Internal(u32 windowId, u32 tileOffset, u32 paletteId) { int bg, x, y, width, height; int tileNum; @@ -1335,40 +1357,48 @@ static void InitMatchCallTextPrinter(int windowId, const u8 *str) printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; printerTemplate.unk = 0; - printerTemplate.fgColor = 10; - printerTemplate.bgColor = 8; - printerTemplate.shadowColor = 14; - gTextFlags.useAlternateDownArrow = 0; + printerTemplate.fgColor = TEXT_DYNAMIC_COLOR_1; + printerTemplate.bgColor = TEXT_COLOR_BLUE; + printerTemplate.shadowColor = TEXT_DYNAMIC_COLOR_5; + gTextFlags.useAlternateDownArrow = FALSE; AddTextPrinter(&printerTemplate, GetPlayerTextSpeedDelay(), NULL); } -static bool32 ExecuteMatchCallTextPrinter(int windowId) +static bool32 RunMatchCallTextPrinter(int windowId) { if (JOY_HELD(A_BUTTON)) - gTextFlags.canABSpeedUpPrint = 1; + gTextFlags.canABSpeedUpPrint = TRUE; else - gTextFlags.canABSpeedUpPrint = 0; + gTextFlags.canABSpeedUpPrint = FALSE; RunTextPrinters(); return IsTextPrinterActive(windowId); } -static void sub_8196694(u8 taskId) -{ - s16 *taskData = gTasks[taskId].data; - if (++taskData[0] > 8) - { - taskData[0] = 0; - if (++taskData[1] > 7) - taskData[1] = 0; +#define tTimer data[0] +#define tSpinStage data[1] +#define tTileNum data[2] - taskData[2] = (taskData[1] * 16) + 0x279; - WriteSequenceToBgTilemapBuffer(0, taskData[2] | ~0xFFF, 1, 15, 4, 4, 17, 1); +static void Task_SpinPokenavIcon(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if (++tTimer > 8) + { + tTimer = 0; + if (++tSpinStage > 7) + tSpinStage = 0; + + tTileNum = (tSpinStage * 16) + TILE_POKENAV_ICON; + WriteSequenceToBgTilemapBuffer(0, tTileNum | ~0xFFF, 1, 15, 4, 4, 17, 1); CopyBgTilemapBufferToVram(0); } } +#undef tTimer +#undef tSpinStage +#undef tTileNum + static bool32 TrainerIsEligibleForRematch(int matchCallId) { return gSaveBlock1Ptr->trainerRematches[matchCallId] > 0; @@ -1392,7 +1422,10 @@ static u32 GetNumRematchTrainersFought(void) return count; } -static u32 sub_8196774(int arg0) +// Look through the rematch table for trainers that have been defeated once before. +// Return the index into the rematch table of the nth defeated trainer, +// or REMATCH_TABLE_ENTRIES if fewer than n rematch trainers have been defeated. +static u32 GetNthRematchTrainerFought(int n) { u32 i, count; @@ -1400,7 +1433,7 @@ static u32 sub_8196774(int arg0) { if (HasTrainerBeenFought(gRematchTable[i].trainerIds[0])) { - if (count == arg0) + if (count == n) return i; count++; @@ -1418,12 +1451,18 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str) matchCallId = GetTrainerMatchCallId(trainerId); gBattleFrontierStreakInfo.facilityId = 0; + + // If the player is on the same route as the trainer + // and they can be rematched, they will always request a battle if (TrainerIsEligibleForRematch(matchCallId) && GetRematchTrainerLocation(matchCallId) == gMapHeader.regionMapSectionId) { matchCallText = GetSameRouteMatchCallText(matchCallId, str); } - else if (sub_8196D74(matchCallId)) + // If the player is not on the same route as the trainer + // and they can be rematched, there is a random chance for + // the trainer to request a battle + else if (ShouldTrainerRequestBattle(matchCallId)) { matchCallText = GetDifferentRouteMatchCallText(matchCallId, str); retVal = TRUE; @@ -1431,10 +1470,12 @@ bool32 SelectMatchCallMessage(int trainerId, u8 *str) } else if (Random() % 3) { + // Message talking about a battle the NPC had matchCallText = GetBattleMatchCallText(matchCallId, str); } else { + // Message talking about something else matchCallText = GetGeneralMatchCallText(matchCallId, str); } @@ -1577,7 +1618,7 @@ static void PopulateTrainerName(int matchCallId, u8 *destStr) { u32 i; u16 trainerId = sMatchCallTrainers[matchCallId].trainerId; - for (i = 0; i < 6; i++) + for (i = 0; i < ARRAY_COUNT(sMultiTrainerMatchCallTexts); i++) { if (sMultiTrainerMatchCallTexts[i].trainerId == trainerId) { @@ -1769,13 +1810,14 @@ static int GetNumOwnedBadges(void) return i; } -static bool32 sub_8196D74(int matchCallId) +// Whether or not a trainer calling the player from a different route should request a battle +static bool32 ShouldTrainerRequestBattle(int matchCallId) { int dayCount; int otId; - u16 rand; + u16 dewfordRand; int numRematchTrainersFought; - int var0, var1, var2; + int max, rand, n; if (GetNumOwnedBadges() < 5) return FALSE; @@ -1783,14 +1825,14 @@ static bool32 sub_8196D74(int matchCallId) dayCount = RtcGetLocalDayCount(); otId = GetTrainerId(gSaveBlock2Ptr->playerTrainerId) & 0xFFFF; - rand = gSaveBlock1Ptr->dewfordTrends[0].rand; + dewfordRand = gSaveBlock1Ptr->dewfordTrends[0].rand; numRematchTrainersFought = GetNumRematchTrainersFought(); - var0 = (numRematchTrainersFought * 13) / 10; - var1 = ((dayCount ^ rand) + (rand ^ GetGameStat(GAME_STAT_TRAINER_BATTLES))) ^ otId; - var2 = var1 % var0; - if (var2 < numRematchTrainersFought) + max = (numRematchTrainersFought * 13) / 10; + rand = ((dayCount ^ dewfordRand) + (dewfordRand ^ GetGameStat(GAME_STAT_TRAINER_BATTLES))) ^ otId; + n = rand % max; + if (n < numRematchTrainersFought) { - if (sub_8196774(var2) == matchCallId) + if (GetNthRematchTrainerFought(n) == matchCallId) return TRUE; } @@ -1971,7 +2013,7 @@ void BufferPokedexRatingForMatchCall(u8 *destStr) u8 *str; u8 dexRatingLevel; - u8 *buffer = Alloc(0x3E8); + u8 *buffer = Alloc(sizeof(gStringVar4)); if (!buffer) { destStr[0] = EOS; @@ -1984,18 +2026,15 @@ void BufferPokedexRatingForMatchCall(u8 *destStr) ConvertIntToDecimalStringN(gStringVar2, numCaught, STR_CONV_MODE_LEFT_ALIGN, 3); dexRatingLevel = GetPokedexRatingLevel(numCaught); str = StringCopy(buffer, gBirchDexRatingText_AreYouCurious); - str[0] = CHAR_PROMPT_CLEAR; - str++; + *(str++) = CHAR_PROMPT_CLEAR; str = StringCopy(str, gBirchDexRatingText_SoYouveSeenAndCaught); - str[0] = CHAR_PROMPT_CLEAR; - str++; + *(str++) = CHAR_PROMPT_CLEAR; StringCopy(str, sBirchDexRatingTexts[dexRatingLevel]); str = StringExpandPlaceholders(destStr, buffer); if (IsNationalPokedexEnabled()) { - str[0] = CHAR_PROMPT_CLEAR; - str++; + *(str++) = CHAR_PROMPT_CLEAR; numSeen = GetNationalPokedexCount(FLAG_GET_SEEN); numCaught = GetNationalPokedexCount(FLAG_GET_CAUGHT); ConvertIntToDecimalStringN(gStringVar1, numSeen, STR_CONV_MODE_LEFT_ALIGN, 3); @@ -2006,14 +2045,14 @@ void BufferPokedexRatingForMatchCall(u8 *destStr) Free(buffer); } -void sub_8197184(u32 windowId, u32 destOffset, u32 paletteId) +void LoadMatchCallWindowGfx(u32 windowId, u32 destOffset, u32 paletteId) { u8 bg = GetWindowAttribute(windowId, WINDOW_BG); - LoadBgTiles(bg, sUnknown_0860EA6C, 0x100, destOffset); - LoadPalette(sUnknown_0860EA4C, paletteId << 4, 0x20); + LoadBgTiles(bg, sMatchCallWindow_Gfx, 0x100, destOffset); + LoadPalette(sMatchCallWindow_Pal, paletteId << 4, sizeof(sMatchCallWindow_Pal)); } -void sub_81971C4(u32 windowId, u32 tileOffset, u32 paletteId) +void DrawMatchCallTextBoxBorder(u32 windowId, u32 tileOffset, u32 paletteId) { - DrawMatchCallTextBoxBorder(windowId, tileOffset, paletteId); + DrawMatchCallTextBoxBorder_Internal(windowId, tileOffset, paletteId); } diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 593581d0e2..398e174d8f 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -1061,15 +1061,15 @@ static void UpdateWindowsToShowCheckPage(struct Pokenav4Struct *state) static void sub_81CC034(struct Pokenav4Struct *state) { state->msgBoxWindowId = AddWindow(&sCallMsgBoxWindowTemplate); - sub_8197184(state->msgBoxWindowId, 1, 4); + LoadMatchCallWindowGfx(state->msgBoxWindowId, 1, 4); sub_81C7B40(); } static void DrawMsgBoxForMatchCallMsg(struct Pokenav4Struct *state) { struct Sprite *sprite; - sub_8197184(state->msgBoxWindowId, 1, 4); - sub_81971C4(state->msgBoxWindowId, 1, 4); + LoadMatchCallWindowGfx(state->msgBoxWindowId, 1, 4); + DrawMatchCallTextBoxBorder(state->msgBoxWindowId, 1, 4); FillWindowPixelBuffer(state->msgBoxWindowId, PIXEL_FILL(1)); PutWindowTilemap(state->msgBoxWindowId); CopyWindowToVram(state->msgBoxWindowId, 3);