From 576d1b3474e9ebec6a16d3ca68378d0f92fb4026 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 19 Jan 2019 23:04:33 +0100 Subject: [PATCH] Document and match somne trainer card --- asm/trainer_card.s | 4 +- data/maps/LilycoveCity/scripts.inc | 2 +- .../LilycoveCity_ContestLobby/scripts.inc | 2 +- .../LilycoveCity_CoveLilyMotel_2F/scripts.inc | 2 +- .../scripts.inc | 2 +- .../scripts.inc | 2 +- data/specials.inc | 4 +- include/pokedex.h | 1 + include/script_pokemon_util_80F87D8.h | 1 + include/trainer_card.h | 17 +- src/pokedex.c | 106 +- src/script_pokemon_util_80F87D8.c | 8 +- src/start_menu.c | 9 +- src/trainer_card.c | 1285 ++++++----------- 14 files changed, 519 insertions(+), 926 deletions(-) diff --git a/asm/trainer_card.s b/asm/trainer_card.s index e78b2fec2..b1fd740ec 100644 --- a/asm/trainer_card.s +++ b/asm/trainer_card.s @@ -209,13 +209,13 @@ _080C4B6C: ldrb r0, [r0, 0x8] cmp r0, 0 bne _080C4B80 - bl sub_80C34B0 + bl PrintStringsOnCardPage2 lsls r0, 24 cmp r0, 0 bne _080C4BF6 b _080C4C08 _080C4B80: - bl sub_80C3438 + bl PrintAllOnCardPage1 lsls r0, 24 cmp r0, 0 bne _080C4BF6 diff --git a/data/maps/LilycoveCity/scripts.inc b/data/maps/LilycoveCity/scripts.inc index 02319e8cf..c1cec509f 100644 --- a/data/maps/LilycoveCity/scripts.inc +++ b/data/maps/LilycoveCity/scripts.inc @@ -157,7 +157,7 @@ LilycoveCity_EventScript_1E2D11:: @ 81E2D11 LilycoveCity_EventScript_1E2D1A:: @ 81E2D1A lockall - specialvar VAR_0x8004, sub_80F8940 + specialvar VAR_0x8004, CountPlayerContestPaintings switch VAR_0x8004 case 0, LilycoveCity_EventScript_1E2D3A msgbox LilycoveCity_Text_1E4571, MSGBOX_DEFAULT diff --git a/data/maps/LilycoveCity_ContestLobby/scripts.inc b/data/maps/LilycoveCity_ContestLobby/scripts.inc index 74bee15d3..42ce7beeb 100644 --- a/data/maps/LilycoveCity_ContestLobby/scripts.inc +++ b/data/maps/LilycoveCity_ContestLobby/scripts.inc @@ -100,7 +100,7 @@ LilycoveCity_ContestLobby_EventScript_21A314:: @ 821A314 return LilycoveCity_ContestLobby_EventScript_21A360:: @ 821A360 - specialvar VAR_0x8004, sub_80F8940 + specialvar VAR_0x8004, CountPlayerContestPaintings switch VAR_0x8004 case 1, LilycoveCity_ContestLobby_EventScript_21A3A2 case 2, LilycoveCity_ContestLobby_EventScript_21A3A6 diff --git a/data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc b/data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc index f7fd5f453..03ac733f9 100644 --- a/data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc +++ b/data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc @@ -6,7 +6,7 @@ LilycoveCity_CoveLilyMotel_2F_EventScript_2186D3:: @ 82186D3 faceplayer call_if_unset FLAG_TEMP_2, LilycoveCity_CoveLilyMotel_2F_EventScript_2186F9 call_if_set FLAG_TEMP_2, LilycoveCity_CoveLilyMotel_2F_EventScript_21870F - specialvar VAR_RESULT, sub_80C08E4 + specialvar VAR_RESULT, HasAllHoennMons compare VAR_RESULT, 1 goto_if_eq LilycoveCity_CoveLilyMotel_2F_EventScript_218702 release diff --git a/data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc b/data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc index da39ee655..f73fbf092 100644 --- a/data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc +++ b/data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc @@ -92,7 +92,7 @@ LilycoveCity_LilycoveMuseum_2F_Movement_219863: @ 8219863 LilycoveCity_LilycoveMuseum_2F_EventScript_219866:: @ 8219866 lockall goto_if_set FLAG_RECEIVED_GLASS_ORNAMENT, LilycoveCity_LilycoveMuseum_2F_EventScript_219921 - specialvar VAR_0x8004, sub_80F8940 + specialvar VAR_0x8004, CountPlayerContestPaintings switch VAR_0x8004 case 1, LilycoveCity_LilycoveMuseum_2F_EventScript_2198BA case 2, LilycoveCity_LilycoveMuseum_2F_EventScript_2198BA diff --git a/data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc b/data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc index 8568a72ef..1f65beda3 100644 --- a/data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc +++ b/data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc @@ -16,7 +16,7 @@ LittlerootTown_ProfessorBirchsLab_MapScript1_1F9CA1: @ 81F9CA1 end LittlerootTown_ProfessorBirchsLab_EventScript_1F9CCD:: @ 81F9CCD - specialvar VAR_RESULT, sub_80C08E4 + specialvar VAR_RESULT, HasAllHoennMons compare VAR_RESULT, 1 goto_if_eq LittlerootTown_ProfessorBirchsLab_EventScript_1F9CE9 setobjectmovementtype 3, 3 diff --git a/data/specials.inc b/data/specials.inc index a5f272dc9..83e56106f 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -148,7 +148,7 @@ gSpecials:: @ 81DBA64 def_special sub_80F88E8 def_special sub_80F88DC def_special sub_80F8864 - def_special sub_80F8940 + def_special CountPlayerContestPaintings def_special ShowContestWinner def_special MauvilleGymSpecial2 def_special MauvilleGymSpecial1 @@ -345,7 +345,7 @@ gSpecials:: @ 81DBA64 def_special sub_80B05B4 def_special SetPacifidlogTMReceivedDay def_special GetDaysUntilPacifidlogTMAvailable - def_special sub_80C08E4 + def_special HasAllHoennMons def_special MonOTNameMatchesPlayer def_special BufferLottoTicketNumber def_special sub_81653CC diff --git a/include/pokedex.h b/include/pokedex.h index b6d323fd3..91e9e37d4 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -41,5 +41,6 @@ u16 GetHoennPokedexCount(u8); u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 trainerId, u32 personality); s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId); u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16); +bool16 HasAllHoennMons(void); #endif // GUARD_POKEDEX_H diff --git a/include/script_pokemon_util_80F87D8.h b/include/script_pokemon_util_80F87D8.h index 02a35ecba..7d8d99628 100644 --- a/include/script_pokemon_util_80F87D8.h +++ b/include/script_pokemon_util_80F87D8.h @@ -4,5 +4,6 @@ u16 sub_80F903C(void); void ReducePlayerPartyToSelectedMons(void); void HealPlayerParty(void); +u8 CountPlayerContestPaintings(void); #endif // GUARD_SCRIPT_POKEMON_UTIL_80F87D8_H diff --git a/include/trainer_card.h b/include/trainer_card.h index a3d9160e0..df516510e 100644 --- a/include/trainer_card.h +++ b/include/trainer_card.h @@ -6,27 +6,27 @@ struct TrainerCard /*0x00*/ u8 gender; /*0x01*/ u8 stars; /*0x02*/ bool8 hasPokedex; - /*0x03*/ bool8 var_3; - /*0x04*/ bool8 var_4; + /*0x03*/ bool8 caughtAllHoenn; + /*0x04*/ bool8 hasAllPaintings; /*0x05*/ u8 var_5; - /*0x06*/ u16 firstHallOfFameA; - /*0x08*/ u16 firstHallOfFameB; - /*0x0A*/ u16 firstHallOfFameC; - /*0x0C*/ u16 pokedexCaught; + /*0x06*/ u16 hofDebutHours; + /*0x08*/ u16 hofDebutMinutes; + /*0x0A*/ u16 hofDebutSeconds; + /*0x0C*/ u16 caughtMonsCount; /*0x0E*/ u16 trainerId; /*0x10*/ u16 playTimeHours; /*0x12*/ u16 playTimeMinutes; /*0x14*/ u16 linkBattleWins; /*0x16*/ u16 linkBattleLosses; /*0x18*/ u16 battleTowerWins; - /*0x1A*/ u16 battleTowerLosses; + /*0x1A*/ u16 battleTowerLosses; // wrong name /*0x1C*/ u16 contestsWithFriends; /*0x1E*/ u16 pokeblocksWithFriends; /*0x20*/ u16 pokemonTrades; /*0x22*/ u16 var_22; /*0x24*/ u32 money; /*0x28*/ u16 var_28[4]; - /*0x30*/ u8 playerName[8]; + /*0x30*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x38*/ u8 var_38; /*0x39*/ u8 var_39; /*0x3A*/ u16 var_3A; @@ -43,7 +43,6 @@ struct TrainerCard /*0x62*/ u16 var_62; }; - extern struct TrainerCard gTrainerCards[4]; void sub_80C3120(struct TrainerCard *arg0, u16 *src, u8 gameVersion); diff --git a/src/pokedex.c b/src/pokedex.c index 3d294e9e9..f99a8226a 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -4271,46 +4271,46 @@ s8 GetSetPokedexFlag(u16 nationalDexNo, u8 caseID) retVal = 0; switch (caseID) { - case FLAG_GET_SEEN: - if (gSaveBlock2Ptr->pokedex.seen[index] & mask) + case FLAG_GET_SEEN: + if (gSaveBlock2Ptr->pokedex.seen[index] & mask) + { + if ((gSaveBlock2Ptr->pokedex.seen[index] & mask) == (gSaveBlock1Ptr->seen1[index] & mask) + && (gSaveBlock2Ptr->pokedex.seen[index] & mask) == (gSaveBlock1Ptr->seen2[index] & mask)) + retVal = 1; + else { - if ((gSaveBlock2Ptr->pokedex.seen[index] & mask) == (gSaveBlock1Ptr->seen1[index] & mask) - && (gSaveBlock2Ptr->pokedex.seen[index] & mask) == (gSaveBlock1Ptr->seen2[index] & mask)) - retVal = 1; - else - { - gSaveBlock2Ptr->pokedex.seen[index] &= ~mask; - gSaveBlock1Ptr->seen1[index] &= ~mask; - gSaveBlock1Ptr->seen2[index] &= ~mask; - retVal = 0; - } + gSaveBlock2Ptr->pokedex.seen[index] &= ~mask; + gSaveBlock1Ptr->seen1[index] &= ~mask; + gSaveBlock1Ptr->seen2[index] &= ~mask; + retVal = 0; } - break; - case FLAG_GET_CAUGHT: - if (gSaveBlock2Ptr->pokedex.owned[index] & mask) + } + break; + case FLAG_GET_CAUGHT: + if (gSaveBlock2Ptr->pokedex.owned[index] & mask) + { + if ((gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock2Ptr->pokedex.seen[index] & mask) + && (gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock1Ptr->seen1[index] & mask) + && (gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock1Ptr->seen2[index] & mask)) + retVal = 1; + else { - if ((gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock2Ptr->pokedex.seen[index] & mask) - && (gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock1Ptr->seen1[index] & mask) - && (gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock1Ptr->seen2[index] & mask)) - retVal = 1; - else - { - gSaveBlock2Ptr->pokedex.owned[index] &= ~mask; - gSaveBlock2Ptr->pokedex.seen[index] &= ~mask; - gSaveBlock1Ptr->seen1[index] &= ~mask; - gSaveBlock1Ptr->seen2[index] &= ~mask; - retVal = 0; - } + gSaveBlock2Ptr->pokedex.owned[index] &= ~mask; + gSaveBlock2Ptr->pokedex.seen[index] &= ~mask; + gSaveBlock1Ptr->seen1[index] &= ~mask; + gSaveBlock1Ptr->seen2[index] &= ~mask; + retVal = 0; } - break; - case FLAG_SET_SEEN: - gSaveBlock2Ptr->pokedex.seen[index] |= mask; - gSaveBlock1Ptr->seen1[index] |= mask; - gSaveBlock1Ptr->seen2[index] |= mask; - break; - case FLAG_SET_CAUGHT: - gSaveBlock2Ptr->pokedex.owned[index] |= mask; - break; + } + break; + case FLAG_SET_SEEN: + gSaveBlock2Ptr->pokedex.seen[index] |= mask; + gSaveBlock1Ptr->seen1[index] |= mask; + gSaveBlock1Ptr->seen2[index] |= mask; + break; + case FLAG_SET_CAUGHT: + gSaveBlock2Ptr->pokedex.owned[index] |= mask; + break; } return retVal; } @@ -4324,14 +4324,14 @@ u16 GetNationalPokedexCount(u8 caseID) { switch (caseID) { - case FLAG_GET_SEEN: - if (GetSetPokedexFlag(i + 1, FLAG_GET_SEEN)) - count++; - break; - case FLAG_GET_CAUGHT: - if (GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) - count++; - break; + case FLAG_GET_SEEN: + if (GetSetPokedexFlag(i + 1, FLAG_GET_SEEN)) + count++; + break; + case FLAG_GET_CAUGHT: + if (GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) + count++; + break; } } return count; @@ -4346,14 +4346,14 @@ u16 GetHoennPokedexCount(u8 caseID) { switch (caseID) { - case FLAG_GET_SEEN: - if (GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_SEEN)) - count++; - break; - case FLAG_GET_CAUGHT: - if (GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_CAUGHT)) - count++; - break; + case FLAG_GET_SEEN: + if (GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_SEEN)) + count++; + break; + case FLAG_GET_CAUGHT: + if (GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_CAUGHT)) + count++; + break; } } return count; @@ -4381,7 +4381,7 @@ u16 sub_80C089C(u8 caseID) return count; } -bool16 sub_80C08E4(void) +bool16 HasAllHoennMons(void) { u16 i; diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c index f3eaa7161..cade00b50 100755 --- a/src/script_pokemon_util_80F87D8.c +++ b/src/script_pokemon_util_80F87D8.c @@ -128,18 +128,18 @@ void sub_80F88E8(void) } } -u8 sub_80F8940(void) +u8 CountPlayerContestPaintings(void) { int i; - u8 var0 = 0; + u8 count = 0; for (i = 0; i < 5; i++) { if (gSaveBlock1Ptr->contestWinners[8 + i].species) - var0++; + count++; } - return var0; + return count; } void sub_80F8970(void) diff --git a/src/start_menu.c b/src/start_menu.c index 0f608b1d2..34d37e995 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -422,16 +422,19 @@ static bool32 PrintStartMenuActions(s8 *pIndex, u32 count) do { - if (sStartMenuItems[sCurrentStartMenuActions[index]].func.u8_void == StartMenuPlayerNameCallback) { + if (sStartMenuItems[sCurrentStartMenuActions[index]].func.u8_void == StartMenuPlayerNameCallback) + { PrintPlayerNameOnWindow(GetStartMenuWindowId(), sStartMenuItems[sCurrentStartMenuActions[index]].text, 8, (index << 4) + 9); } - else { + else + { StringExpandPlaceholders(gStringVar4, sStartMenuItems[sCurrentStartMenuActions[index]].text); AddTextPrinterParameterized(GetStartMenuWindowId(), 1, gStringVar4, 8, (index << 4) + 9, 0xFF, NULL); } index++; - if (index >= sNumStartMenuActions) { + if (index >= sNumStartMenuActions) + { *pIndex = index; return TRUE; } diff --git a/src/trainer_card.c b/src/trainer_card.c index 51ef20ddc..26a78ca08 100755 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -15,6 +15,7 @@ #include "constants/flags.h" #include "event_data.h" #include "constants/game_stat.h" +#include "constants/battle_frontier.h" #include "money.h" #include "string_util.h" #include "trainer_card.h" @@ -23,10 +24,9 @@ #include "pokedex.h" #include "graphics.h" #include "pokemon_icon.h" +#include "script_pokemon_util_80F87D8.h" //external functions -extern u8 sub_80F8940(void); -extern bool16 sub_80C08E4(void); extern u8 sub_80D30A0(u16); extern void TintPalette_CustomTone(u16 *palette, u16 count, u16 rTone, u16 gTone, u16 bTone); extern void TintPalette_SepiaTone(u16 *palette, u16 count); @@ -105,23 +105,23 @@ extern bool8 (*const gUnknown_0856FB28[])(struct Task *); /*static*/ void sub_80C48C8(void); /*static*/ void sub_80C2710(void); /*static*/ void sub_80C2728(u8 task); -/*static*/ bool8 sub_80C3438(void); +/*static*/ bool8 PrintAllOnCardPage1(void); /*static*/ void sub_80C438C(u8); /*static*/ void sub_80C4FF0(void); -/*static*/ void sub_80C4550(u8*); -/*static*/ void sub_80C45C0(u8*); +/*static*/ void sub_80C4550(u16*); +/*static*/ void sub_80C45C0(u16*); /*static*/ void sub_80C4630(void); -/*static*/ void sub_80C3880(void); +/*static*/ void PrintTimeOnCard(void); /*static*/ void sub_80C4918(void); /*static*/ bool8 sub_80C4940(void); /*static*/ bool8 sub_80C2AD8(void); /*static*/ void sub_80C2C80(void); -/*static*/ u32 sav12_xor_get_clamped_above(u8 stat, u32 max); -/*static*/ bool8 sub_80C2DFC(void); +/*static*/ u32 GetCappedGameStat(u8 statId, u32 maxValue); +/*static*/ bool8 HasAllFrontierSymbols(void); /*static*/ u32 sub_80C2E40(void); -/*static*/ u8 TrainerCard_GetStarCount(struct TrainerCard*); -/*static*/ u16 sub_80C376C(void); -/*static*/ void sub_80C2EC4(struct TrainerCard*, u8); +/*static*/ u8 sub_80C2E84(struct TrainerCard*); +/*static*/ u16 GetCaughtMonsCount(void); +/*static*/ void SetPlayerCardData(struct TrainerCard*, u8); /*static*/ void sub_80C3020(struct TrainerCard*); /*static*/ u8 sub_80C4FCC(u8); /*static*/ void sub_80C3190(void); @@ -131,33 +131,33 @@ extern bool8 (*const gUnknown_0856FB28[])(struct Task *); /*static*/ void sub_80C3404(void); /*static*/ void sub_80C3414(void); /*static*/ void sub_80C4EE4(void); -/*static*/ void sub_80C3574(void); -/*static*/ void sub_80C3608(void); -/*static*/ void sub_80C3684(void); -/*static*/ void sub_80C378C(void); -/*static*/ void sub_80C3A18(void); -/*static*/ bool8 sub_80C34B0(void); +/*static*/ void PrintNameOnCard(void); +/*static*/ void PrintIdOnCard(void); +/*static*/ void PrintMoneyOnCard(void); +/*static*/ void PrintPokedexOnCard(void); +/*static*/ void PrintProfilePhraseOnCard(void); +/*static*/ bool8 PrintStringsOnCardPage2(void); /*static*/ void sub_80C3B50(void); -/*static*/ void sub_80C3CCC(void); -/*static*/ void sub_80C3D60(void); -/*static*/ void sub_80C3DF0(void); -/*static*/ void sub_80C3E58(void); -/*static*/ void sub_80C3F64(void); -/*static*/ void sub_80C3ED4(void); -/*static*/ void sub_80C3FE0(void); +/*static*/ void PrintHofDebutStringOnCard(void); +/*static*/ void PrintWinsLossesStringOnCard(void); +/*static*/ void PrintTradesStringOnCard(void); +/*static*/ void PrintBerryCrushStringOnCard(void); +/*static*/ void PrintPokeblockStringOnCard(void); +/*static*/ void PrintUnionStringOnCard(void); +/*static*/ void PrintContestStringOnCard(void); /*static*/ void sub_80C4140(void); -/*static*/ void sub_80C40CC(void); +/*static*/ void PrintBattleFacilityStringOnCard(void); /*static*/ void sub_80C42A4(void); -/*static*/ void sub_80C3548(void); -/*static*/ void sub_80C3AF0(void); -/*static*/ void sub_80C3BC4(void); -/*static*/ void sub_80C3CF4(void); -/*static*/ void sub_80C3DC0(void); -/*static*/ void sub_80C3E20(void); -/*static*/ void sub_80C3E98(void); -/*static*/ void sub_80C3F14(void); -/*static*/ void sub_80C3FA4(void); -/*static*/ void sub_80C4020(void); +/*static*/ void PrintAllVariableNumsOnCardPage2(void); +/*static*/ void PrintNameOnCard2(void); +/*static*/ void PrintHofTimeOnCard(void); +/*static*/ void PrintLinkResultsNumsOnCard(void); +/*static*/ void PrintTradesNumOnCard(void); +/*static*/ void PrintBerryCrushNumOnCard(void); +/*static*/ void PrintUnionNumOnCard(void); +/*static*/ void PrintPokeblocksNumOnCard(void); +/*static*/ void PrintContestNumOnCard(void); +/*static*/ void PrintBattleFacilityNumsOnCard(void); /*static*/ void sub_80C3C34(u8 top, const u8* str1, u8* str2, const u8* color); /*static*/ void sub_80C4330(void); /*static*/ u8 sub_80C43A8(void); @@ -166,8 +166,10 @@ extern bool8 (*const gUnknown_0856FB28[])(struct Task *); /*static*/ bool8 sub_80C4998(struct Task* task); /*static*/ bool8 sub_80C49D8(struct Task* task); /*static*/ void sub_80C32EC(u16); +void sub_80C41D8(void); -extern struct UnknownStruct{ +extern struct UnknownStruct +{ u8 var_0; u8 var_1; u8 var_2; @@ -209,14 +211,14 @@ extern struct UnknownStruct{ u16 var_52C; void (*callback2)(void); struct TrainerCard var_534; - u8 var_598[0x4B0]; + u16 var_598[0x4B0 / 2]; u8 var_A48[0x4B0]; - u8 var_EF8[0x4B0]; + u16 var_EF8[0x4B0 / 2]; u8 var_13A8[0x400]; u8 var_17A8[0x200]; u8 var_19A8[0x2300]; - u8 var_3CA8[0x2000]; - u8 var_5CA8[0x2000]; + u16 var_3CA8[0x2000 / 2]; + u16 var_5CA8[0x2000 / 2]; u16 var_7CA8; u8 var_7CAA; }* gUnknown_02039CE8; @@ -227,7 +229,7 @@ void sub_80C2690(void) ProcessSpriteCopyRequests(); TransferPlttBuffer(); sub_80C48C8(); - if(gUnknown_02039CE8->var_9) + if (gUnknown_02039CE8->var_9) DmaCopy16(3, &gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 0x140); } @@ -235,7 +237,7 @@ void sub_80C26D4(void) { u16 backup; u16 bgVOffset; - + backup = REG_IME; REG_IME = 0; bgVOffset = gScanlineEffectRegBuffers[1][REG_VCOUNT & 0xFF]; @@ -258,21 +260,21 @@ void sub_80C2728(u8 taskId) Free(gUnknown_02039CE8); gUnknown_02039CE8 = NULL; DestroyTask(taskId); -} +} void sub_80C2760(u8 taskId) { - switch(gUnknown_02039CE8->var_0) + switch (gUnknown_02039CE8->var_0) { - case 0: - if(!IsDma3ManagerBusyWithBgCopy()) + case 0: + if (!IsDma3ManagerBusyWithBgCopy()) { FillWindowPixelBuffer(1, 0); gUnknown_02039CE8->var_0++; } break; case 1: - if(sub_80C3438()) + if (PrintAllOnCardPage1()) gUnknown_02039CE8->var_0++; break; case 2: @@ -298,7 +300,7 @@ void sub_80C2760(u8 taskId) gUnknown_02039CE8->var_0++; break; case 7: - if(gWirelessCommType == 1 && gReceivedRemoteLinkPlayers == TRUE) + if (gWirelessCommType == 1 && gReceivedRemoteLinkPlayers == TRUE) { sub_800E0E8(); CreateWirelessStatusIndicatorSprite(230, 150); @@ -309,53 +311,57 @@ void sub_80C2760(u8 taskId) gUnknown_02039CE8->var_0++; break; case 8: - if(!UpdatePaletteFade() && !IsDma3ManagerBusyWithBgCopy()) + if (!UpdatePaletteFade() && !IsDma3ManagerBusyWithBgCopy()) { PlaySE(SE_RG_CARD3); gUnknown_02039CE8->var_0 = 10; } break; case 9: - if(!IsSEPlaying()) + if (!IsSEPlaying()) gUnknown_02039CE8->var_0++; break; case 10: - if(!gReceivedRemoteLinkPlayers && gUnknown_02039CE8->var_529) + if (!gReceivedRemoteLinkPlayers && gUnknown_02039CE8->var_529) { - sub_80C3880(); + PrintTimeOnCard(); sub_80C438C(1); gUnknown_02039CE8->var_529 = 0; - } - if(gMain.newKeys & A_BUTTON) + } + if (gMain.newKeys & A_BUTTON) { sub_80C4918(); PlaySE(SE_RG_CARD1); gUnknown_02039CE8->var_0 = 12; } - else if(gMain.newKeys & B_BUTTON) + else if (gMain.newKeys & B_BUTTON) { - if(gReceivedRemoteLinkPlayers && gUnknown_02039CE8->var_5 && InUnionRoom() == TRUE) + if (gReceivedRemoteLinkPlayers && gUnknown_02039CE8->var_5 && InUnionRoom() == TRUE) + { gUnknown_02039CE8->var_0 = 15; + } else { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, gUnknown_02039CE8->var_52C); gUnknown_02039CE8->var_0 = 14; } - } + } break; case 12: - if(sub_80C4940() && sub_8087598() != TRUE) + if (sub_80C4940() && sub_8087598() != TRUE) { PlaySE(SE_RG_CARD3); gUnknown_02039CE8->var_0 = 11; - } - break; + } + break; case 11: - if(gMain.newKeys & B_BUTTON) + if (gMain.newKeys & B_BUTTON) { - if(gReceivedRemoteLinkPlayers && gUnknown_02039CE8->var_5 && InUnionRoom() == TRUE) + if (gReceivedRemoteLinkPlayers && gUnknown_02039CE8->var_5 && InUnionRoom() == TRUE) + { gUnknown_02039CE8->var_0 = 15; - else if(gReceivedRemoteLinkPlayers) + } + else if (gReceivedRemoteLinkPlayers) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, gUnknown_02039CE8->var_52C); gUnknown_02039CE8->var_0 = 14; @@ -364,20 +370,22 @@ void sub_80C2760(u8 taskId) { sub_80C4918(); gUnknown_02039CE8->var_0 = 13; - PlaySE(SE_RG_CARD1); + PlaySE(SE_RG_CARD1); } - } - else if(gMain.newKeys & A_BUTTON) + } + else if (gMain.newKeys & A_BUTTON) { - if(gReceivedRemoteLinkPlayers && gUnknown_02039CE8->var_5 && InUnionRoom() == TRUE) + if (gReceivedRemoteLinkPlayers && gUnknown_02039CE8->var_5 && InUnionRoom() == TRUE) + { gUnknown_02039CE8->var_0 = 15; + } else { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, gUnknown_02039CE8->var_52C); gUnknown_02039CE8->var_0 = 14; } } - break; + break; case 15: sub_800AC34(); NewMenuHelpers_DrawDialogueFrame(0, 1); @@ -386,71 +394,72 @@ void sub_80C2760(u8 taskId) gUnknown_02039CE8->var_0 = 16; break; case 16: - if(!gReceivedRemoteLinkPlayers) + if (!gReceivedRemoteLinkPlayers) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, gUnknown_02039CE8->var_52C); gUnknown_02039CE8->var_0 = 14; } break; - case 14: - if(!UpdatePaletteFade()) + case 14: + if (!UpdatePaletteFade()) sub_80C2728(taskId); break; case 13: - if(sub_80C4940() && sub_8087598() != TRUE) + if (sub_80C4940() && sub_8087598() != TRUE) { gUnknown_02039CE8->var_0 = 10; PlaySE(SE_RG_CARD3); } + break; } } bool8 sub_80C2AD8(void) { - switch(gUnknown_02039CE8->var_2) + switch (gUnknown_02039CE8->var_2) { case 0: - if(gUnknown_02039CE8->var_52A) + if (gUnknown_02039CE8->var_52A) LZ77UnCompWram(gUnknown_08DD1F78, gUnknown_02039CE8->var_EF8); else LZ77UnCompWram(gUnknown_08DD2AE0, gUnknown_02039CE8->var_EF8); break; case 1: - if(gUnknown_02039CE8->var_52A) + if (gUnknown_02039CE8->var_52A) LZ77UnCompWram(gUnknown_08DD21B0, gUnknown_02039CE8->var_A48); else LZ77UnCompWram(gUnknown_08DD2D30, gUnknown_02039CE8->var_A48); break; case 2: - if(!gUnknown_02039CE8->var_5) + if (!gUnknown_02039CE8->var_5) { - if(gUnknown_02039CE8->var_52A) + if (gUnknown_02039CE8->var_52A) LZ77UnCompWram(gUnknown_08DD2010, gUnknown_02039CE8->var_598); else LZ77UnCompWram(gUnknown_08DD2B78, gUnknown_02039CE8->var_598); } else { - if(gUnknown_02039CE8->var_52A) + if (gUnknown_02039CE8->var_52A) LZ77UnCompWram(gUnknown_08DD228C, gUnknown_02039CE8->var_598); else LZ77UnCompWram(gUnknown_08DD2E5C, gUnknown_02039CE8->var_598); } break; case 3: - if(gUnknown_02039CE8->var_52A) + if (gUnknown_02039CE8->var_52A) LZ77UnCompWram(gUnknown_0856F5CC, gUnknown_02039CE8->var_13A8); else LZ77UnCompWram(gUnknown_0856F814, gUnknown_02039CE8->var_13A8); break; case 4: - if(gUnknown_02039CE8->var_52A) + if (gUnknown_02039CE8->var_52A) LZ77UnCompWram(gEmeraldTrainerCard_Gfx, gUnknown_02039CE8->var_19A8); else LZ77UnCompWram(gFireRedTrainerCard_Gfx, gUnknown_02039CE8->var_19A8); break; case 5: - if(!gUnknown_02039CE8->var_52A) + if (!gUnknown_02039CE8->var_52A) LZ77UnCompWram(gUnknown_0856F018, gUnknown_02039CE8->var_17A8); break; default: @@ -461,215 +470,116 @@ bool8 sub_80C2AD8(void) return FALSE; } -NAKED -void sub_80C2C80(void) //not really a nonmatching, skipped it because of DMA macros +void sub_80C2C80(void) { - asm("\n\ - .syntax unified\n\ - push {lr}\n\ - sub sp, 0x8\n\ - ldr r1, =gMain\n\ - movs r2, 0x87\n\ - lsls r2, 3\n\ - adds r0, r1, r2\n\ - ldrb r0, [r0]\n\ - adds r3, r1, 0\n\ - cmp r0, 0xA\n\ - bls _080C2C96\n\ - b _080C2DD8\n\ -_080C2C96:\n\ - lsls r0, 2\n\ - ldr r1, =_080C2CA8\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_080C2CA8:\n\ - .4byte _080C2CD4\n\ - .4byte _080C2CEC\n\ - .4byte _080C2D14\n\ - .4byte _080C2D50\n\ - .4byte _080C2D6A\n\ - .4byte _080C2D74\n\ - .4byte _080C2D88\n\ - .4byte _080C2D8E\n\ - .4byte _080C2DA0\n\ - .4byte _080C2DA6\n\ - .4byte _080C2DB8\n\ -_080C2CD4:\n\ - bl sub_80C334C\n\ - bl sub_80C3414\n\ - ldr r1, =gMain\n\ - movs r0, 0x87\n\ - lsls r0, 3\n\ - adds r1, r0\n\ - b _080C2DCC\n\ - .pool\n\ -_080C2CEC:\n\ - movs r1, 0xE0\n\ - lsls r1, 19\n\ - movs r0, 0\n\ - str r0, [sp]\n\ - ldr r0, =0x040000d4\n\ - mov r2, sp\n\ - str r2, [r0]\n\ - str r1, [r0, 0x4]\n\ - ldr r1, =0x85000100\n\ - str r1, [r0, 0x8]\n\ - ldr r0, [r0, 0x8]\n\ - movs r0, 0x87\n\ - lsls r0, 3\n\ - adds r1, r3, r0\n\ - b _080C2DCC\n\ - .pool\n\ -_080C2D14:\n\ - ldr r0, =gUnknown_02039CE8\n\ - ldr r0, [r0]\n\ - ldr r1, =0x0000052c\n\ - adds r0, r1\n\ - ldrh r0, [r0]\n\ - cmp r0, 0\n\ - bne _080C2D36\n\ - movs r2, 0xA0\n\ - lsls r2, 19\n\ - add r1, sp, 0x4\n\ - strh r0, [r1]\n\ - ldr r0, =0x040000d4\n\ - str r1, [r0]\n\ - str r2, [r0, 0x4]\n\ - ldr r1, =0x81000200\n\ - str r1, [r0, 0x8]\n\ - ldr r0, [r0, 0x8]\n\ -_080C2D36:\n\ - movs r2, 0x87\n\ - lsls r2, 3\n\ - adds r1, r3, r2\n\ - b _080C2DCC\n\ - .pool\n\ -_080C2D50:\n\ - bl ResetSpriteData\n\ - bl FreeAllSpritePalettes\n\ - bl ResetPaletteFade\n\ - ldr r1, =gMain\n\ - movs r0, 0x87\n\ - lsls r0, 3\n\ - adds r1, r0\n\ - ldrb r0, [r1]\n\ - adds r0, 0x1\n\ - strb r0, [r1]\n\ -_080C2D6A:\n\ - bl sub_80C3388\n\ - b _080C2DC4\n\ - .pool\n\ -_080C2D74:\n\ - bl sub_80C41D8\n\ - ldr r1, =gMain\n\ - movs r0, 0x87\n\ - lsls r0, 3\n\ - adds r1, r0\n\ - b _080C2DCC\n\ - .pool\n\ -_080C2D88:\n\ - bl sub_80C2AD8\n\ - b _080C2DBC\n\ -_080C2D8E:\n\ - bl sub_80C4330\n\ - ldr r1, =gMain\n\ - movs r0, 0x87\n\ - lsls r0, 3\n\ - adds r1, r0\n\ - b _080C2DCC\n\ - .pool\n\ -_080C2DA0:\n\ - bl sub_80C3278\n\ - b _080C2DC4\n\ -_080C2DA6:\n\ - bl sub_80C3548\n\ - ldr r1, =gMain\n\ - movs r0, 0x87\n\ - lsls r0, 3\n\ - adds r1, r0\n\ - b _080C2DCC\n\ - .pool\n\ -_080C2DB8:\n\ - bl sub_80C43A8\n\ -_080C2DBC:\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x1\n\ - bne _080C2DDC\n\ -_080C2DC4:\n\ - ldr r1, =gMain\n\ - movs r2, 0x87\n\ - lsls r2, 3\n\ - adds r1, r2\n\ -_080C2DCC:\n\ - ldrb r0, [r1]\n\ - adds r0, 0x1\n\ - strb r0, [r1]\n\ - b _080C2DDC\n\ - .pool\n\ -_080C2DD8:\n\ - bl sub_80C3404\n\ -_080C2DDC:\n\ - add sp, 0x8\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided"); + switch (gMain.state) + { + case 0: + sub_80C334C(); + sub_80C3414(); + gMain.state++; + break; + case 1: + DmaClear32(3, (void *)OAM, OAM_SIZE); + gMain.state++; + break; + case 2: + if (!gUnknown_02039CE8->var_52C) + DmaClear16(3, (void *)PLTT, PLTT_SIZE); + gMain.state++; + break; + case 3: + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetPaletteFade(); + gMain.state++; + case 4: + sub_80C3388(); + gMain.state++; + break; + case 5: + sub_80C41D8(); + gMain.state++; + break; + case 6: + if (sub_80C2AD8() == TRUE) + gMain.state++; + break; + case 7: + sub_80C4330(); + gMain.state++; + break; + case 8: + sub_80C3278(); + gMain.state++; + break; + case 9: + PrintAllVariableNumsOnCardPage2(); + gMain.state++; + break; + case 10: + if (sub_80C43A8() == TRUE) + gMain.state++; + break; + default: + sub_80C3404(); + break; + } } -u32 sav12_xor_get_clamped_above(u8 stat, u32 max) +u32 GetCappedGameStat(u8 statId, u32 maxValue) { - u32 retStat = GetGameStat(stat); - return (retStat > max) ? max : retStat; + u32 statValue = GetGameStat(statId); + + return min(maxValue, statValue); } -bool8 sub_80C2DFC(void) +bool8 HasAllFrontierSymbols(void) { u8 i; - for(i = 0; i <= 6; i++) + for (i = 0; i < NUM_FRONTIER_FACILITIES; i++) { - if(!FlagGet(FLAG_SYS_TOWER_SILVER + 2 * i) || !FlagGet(FLAG_SYS_TOWER_GOLD + 2 * i)) + if (!FlagGet(FLAG_SYS_TOWER_SILVER + 2 * i) || !FlagGet(FLAG_SYS_TOWER_GOLD + 2 * i)) return FALSE; } - return TRUE; + return TRUE; } u32 sub_80C2E40(void) { - u32 stat = GetGameStat(GAME_STAT_ENTERED_HOF); - u8 r4 = (stat | -stat) >> 31; - - if(sub_80C08E4()) - r4++; - if(sub_80F8940() > 4) - r4++; - if(sub_80C2DFC()) - r4++; - return r4; + u8 stars = 0; + + if (GetGameStat(GAME_STAT_ENTERED_HOF)) + stars++; + if (HasAllHoennMons()) + stars++; + if (CountPlayerContestPaintings() > 4) + stars++; + if (HasAllFrontierSymbols()) + stars++; + + return stars; } -u8 TrainerCard_GetStarCount(struct TrainerCard *trainerCard) +u8 sub_80C2E84(struct TrainerCard *trainerCard) { - u8 value = 0; + u8 stars = 0; - if (trainerCard->firstHallOfFameA || trainerCard->firstHallOfFameB || trainerCard->firstHallOfFameC) - value++; - if (trainerCard->var_3) - value++; + if (trainerCard->hofDebutHours || trainerCard->hofDebutMinutes || trainerCard->hofDebutSeconds) + stars++; + if (trainerCard->caughtAllHoenn) + stars++; if (trainerCard->battleTowerLosses > 49) - value++; - if (trainerCard->var_4) - value++; - - return value; + stars++; + if (trainerCard->hasAllPaintings) + stars++; + + return stars; } -void sub_80C2EC4(struct TrainerCard *trainerCard, u8 arg1) +void SetPlayerCardData(struct TrainerCard *trainerCard, u8 arg1) { u32 playTime; - bool32 enteredHallOfFame; u8 i; trainerCard->gender = gSaveBlock2Ptr->playerGender; @@ -677,233 +587,101 @@ void sub_80C2EC4(struct TrainerCard *trainerCard, u8 arg1) trainerCard->playTimeMinutes = gSaveBlock2Ptr->playTimeMinutes; playTime = GetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME); - enteredHallOfFame = GetGameStat(GAME_STAT_ENTERED_HOF); - if (!enteredHallOfFame) + if (!GetGameStat(GAME_STAT_ENTERED_HOF)) playTime = 0; - - trainerCard->firstHallOfFameA = playTime >> 16; - trainerCard->firstHallOfFameB = (playTime >> 8) & 0xFF; - trainerCard->firstHallOfFameC = playTime & 0xFF; - if((playTime >> 16) > 999) + + trainerCard->hofDebutHours = playTime >> 16; + trainerCard->hofDebutMinutes = (playTime >> 8) & 0xFF; + trainerCard->hofDebutSeconds = playTime & 0xFF; + if ((playTime >> 16) > 999) { - trainerCard->firstHallOfFameA = 999; - trainerCard->firstHallOfFameB = 59; - trainerCard->firstHallOfFameC = 59; + trainerCard->hofDebutHours = 999; + trainerCard->hofDebutMinutes = 59; + trainerCard->hofDebutSeconds = 59; } - + trainerCard->hasPokedex = FlagGet(FLAG_SYS_POKEDEX_GET); - trainerCard->var_3 = sub_80C08E4(); - trainerCard->pokedexCaught = sub_80C376C(); + trainerCard->caughtAllHoenn = HasAllHoennMons(); + trainerCard->caughtMonsCount = GetCaughtMonsCount(); trainerCard->trainerId = (gSaveBlock2Ptr->playerTrainerId[1] << 8) | gSaveBlock2Ptr->playerTrainerId[0]; - trainerCard->linkBattleWins = sav12_xor_get_clamped_above(GAME_STAT_LINK_BATTLE_WINS, 9999); - trainerCard->linkBattleLosses = sav12_xor_get_clamped_above(GAME_STAT_LINK_BATTLE_LOSSES, 9999); - - trainerCard->pokemonTrades = sav12_xor_get_clamped_above(GAME_STAT_POKEMON_TRADES, 0xFFFF); - + trainerCard->linkBattleWins = GetCappedGameStat(GAME_STAT_LINK_BATTLE_WINS, 9999); + trainerCard->linkBattleLosses = GetCappedGameStat(GAME_STAT_LINK_BATTLE_LOSSES, 9999); + + trainerCard->pokemonTrades = GetCappedGameStat(GAME_STAT_POKEMON_TRADES, 0xFFFF); + trainerCard->money = GetMoney(&gSaveBlock1Ptr->money); for (i = 0; i < 4; i++) trainerCard->var_28[i] = gSaveBlock1Ptr->unk2BB0[i]; - + StringCopy(trainerCard->playerName, gSaveBlock2Ptr->playerName); - - switch(arg1) + + switch (arg1) { case 2: trainerCard->battleTowerWins = 0; trainerCard->battleTowerLosses = 0; case 0: - trainerCard->contestsWithFriends = sav12_xor_get_clamped_above(GAME_STAT_WON_LINK_CONTEST, 999); - trainerCard->pokeblocksWithFriends = sav12_xor_get_clamped_above(GAME_STAT_POKEBLOCKS_WITH_FRIENDS, 0xFFFF); - if(sub_80F8940() > 4) - trainerCard->var_4 = TRUE; - trainerCard->stars = TrainerCard_GetStarCount(trainerCard); + trainerCard->contestsWithFriends = GetCappedGameStat(GAME_STAT_WON_LINK_CONTEST, 999); + trainerCard->pokeblocksWithFriends = GetCappedGameStat(GAME_STAT_POKEBLOCKS_WITH_FRIENDS, 0xFFFF); + if (CountPlayerContestPaintings() > 4) + trainerCard->hasAllPaintings = TRUE; + trainerCard->stars = sub_80C2E84(trainerCard); break; case 1: trainerCard->battleTowerWins = 0; trainerCard->battleTowerLosses = 0; trainerCard->contestsWithFriends = 0; trainerCard->pokeblocksWithFriends = 0; - trainerCard->var_4 = 0; + trainerCard->hasAllPaintings = 0; trainerCard->stars = 0; + break; } } -#ifdef NONMATCHING //r0 and r1 swapped void sub_80C3020(struct TrainerCard *trainerCard) { memset(trainerCard, 0, sizeof(struct TrainerCard)); trainerCard->var_38 = 3; - sub_80C2EC4(trainerCard, 2); - trainerCard->var_60 = sub_80C2DFC(); + SetPlayerCardData(trainerCard, 2); + trainerCard->var_60 = HasAllFrontierSymbols(); trainerCard->var_62 = gSaveBlock2Ptr->frontier.field_EBA; - if(trainerCard->var_60) + if (trainerCard->var_60) trainerCard->stars++; - if(trainerCard->gender == FEMALE) - trainerCard->var_4F = gUnknown_08329D54[(trainerCard->trainerId & 7) + 8]; - else - trainerCard->var_4F = gUnknown_08329D54[trainerCard->trainerId & 7]; -} -#else -NAKED -void sub_80C3020(struct TrainerCard *trainerCard) -{ - asm("\n\ - .syntax unified\n\ - push {r4,lr}\n\ - adds r4, r0, 0\n\ - movs r1, 0\n\ - movs r2, 0x64\n\ - bl memset\n\ - adds r1, r4, 0\n\ - adds r1, 0x38\n\ - movs r0, 0x3\n\ - strb r0, [r1]\n\ - adds r0, r4, 0\n\ - movs r1, 0x2\n\ - bl sub_80C2EC4\n\ - bl sub_80C2DFC\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - adds r1, r4, 0\n\ - adds r1, 0x60\n\ - strh r0, [r1]\n\ - ldr r0, =gSaveBlock2Ptr\n\ - ldr r0, [r0]\n\ - ldr r2, =0x00000eba\n\ - adds r0, r2\n\ - ldrh r0, [r0]\n\ - adds r2, r4, 0\n\ - adds r2, 0x62\n\ - strh r0, [r2]\n\ - ldrh r0, [r1]\n\ - cmp r0, 0\n\ - beq _080C3066\n\ - ldrb r0, [r4, 0x1]\n\ - adds r0, 0x1\n\ - strb r0, [r4, 0x1]\n\ -_080C3066:\n\ - ldrb r0, [r4]\n\ - cmp r0, 0x1\n\ - bne _080C3084\n\ - ldr r2, =gUnknown_08329D54\n\ - ldrh r0, [r4, 0xE]\n\ - movs r1, 0x7\n\ - ands r0, r1\n\ - adds r0, 0x8\n\ - b _080C308C\n\ - .pool\n\ -_080C3084:\n\ - ldr r2, =gUnknown_08329D54\n\ - ldrh r0, [r4, 0xE]\n\ - movs r1, 0x7\n\ - ands r0, r1\n\ -_080C308C:\n\ - lsls r0, 1\n\ - adds r0, r2\n\ - ldrh r1, [r0]\n\ - adds r0, r4, 0\n\ - adds r0, 0x4F\n\ - strb r1, [r0]\n\ - pop {r4}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided"); -} -#endif // NONMATCHING -#ifdef NONMATCHING //r0 and r1 swapped + if (trainerCard->gender == FEMALE) + trainerCard->var_4F = gUnknown_08329D54[(trainerCard->trainerId % 8) + 8]; + else + trainerCard->var_4F = gUnknown_08329D54[trainerCard->trainerId % 8]; +} + void TrainerCard_GenerateCardForPlayer(struct TrainerCard *trainerCard) { - u8 temp; memset(trainerCard, 0, 0x60); trainerCard->var_38 = 3; - sub_80C2EC4(trainerCard, 2); - temp = sub_80C2DFC(); - trainerCard->var_3A = temp; + SetPlayerCardData(trainerCard, 2); + trainerCard->var_3A = HasAllFrontierSymbols(); *((u16*)&trainerCard->var_3C) = gSaveBlock2Ptr->frontier.field_EBA; - if(temp) + if (trainerCard->var_3A) trainerCard->stars++; - if(trainerCard->gender == FEMALE) - trainerCard->var_4F = gUnknown_08329D54[(trainerCard->trainerId & 7) + 8]; + + if (trainerCard->gender == FEMALE) + trainerCard->var_4F = gUnknown_08329D54[(trainerCard->trainerId % 8) + 8]; else - trainerCard->var_4F = gUnknown_08329D54[trainerCard->trainerId & 7]; + trainerCard->var_4F = gUnknown_08329D54[trainerCard->trainerId % 8]; } -#else -NAKED -void TrainerCard_GenerateCardForPlayer(struct TrainerCard *trainerCard) -{ - asm("\n\ - .syntax unified\n\ - push {r4,lr}\n\ - adds r4, r0, 0\n\ - movs r1, 0\n\ - movs r2, 0x60\n\ - bl memset\n\ - adds r1, r4, 0\n\ - adds r1, 0x38\n\ - movs r0, 0x3\n\ - strb r0, [r1]\n\ - adds r0, r4, 0\n\ - movs r1, 0x2\n\ - bl sub_80C2EC4\n\ - bl sub_80C2DFC\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - strh r0, [r4, 0x3A]\n\ - ldr r1, =gSaveBlock2Ptr\n\ - ldr r1, [r1]\n\ - ldr r2, =0x00000eba\n\ - adds r1, r2\n\ - ldrh r1, [r1]\n\ - strh r1, [r4, 0x3C]\n\ - cmp r0, 0\n\ - beq _080C30E0\n\ - ldrb r0, [r4, 0x1]\n\ - adds r0, 0x1\n\ - strb r0, [r4, 0x1]\n\ -_080C30E0:\n\ - ldrb r0, [r4]\n\ - cmp r0, 0x1\n\ - bne _080C3100\n\ - ldr r2, =gUnknown_08329D54\n\ - ldrh r0, [r4, 0xE]\n\ - movs r1, 0x7\n\ - ands r0, r1\n\ - adds r0, 0x8\n\ - b _080C3108\n\ - .pool\n\ -_080C3100:\n\ - ldr r2, =gUnknown_08329D54\n\ - ldrh r0, [r4, 0xE]\n\ - movs r1, 0x7\n\ - ands r0, r1\n\ -_080C3108:\n\ - lsls r0, 1\n\ - adds r0, r2\n\ - ldrh r1, [r0]\n\ - adds r0, r4, 0\n\ - adds r0, 0x4F\n\ - strb r1, [r0]\n\ - pop {r4}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided"); -} -#endif // NONMATCHING void sub_80C3120(struct TrainerCard *trainerCard, u16 *src, u8 gameVersion) { memset(trainerCard, 0, sizeof(struct TrainerCard)); trainerCard->var_38 = gameVersion; - switch(sub_80C4FCC(gameVersion)) + + switch (sub_80C4FCC(gameVersion)) { case 0: - memcpy(trainerCard, src, 0x60); + memcpy(trainerCard, src, 0x60); break; case 1: memcpy(trainerCard, src, 0x38); @@ -913,6 +691,7 @@ void sub_80C3120(struct TrainerCard *trainerCard, u16 *src, u8 gameVersion) trainerCard->var_3C = 0; trainerCard->var_60 = src[29]; trainerCard->var_62 = src[30]; + break; } } @@ -920,7 +699,7 @@ void sub_80C3190(void) { u8 i; u32 badgeFlag; - + gUnknown_02039CE8->var_A = 0; gUnknown_02039CE8->var_B = 0; gUnknown_02039CE8->var_C = 0; @@ -928,27 +707,27 @@ void sub_80C3190(void) gUnknown_02039CE8->var_E = 0; gUnknown_02039CE8->var_F = 0; gUnknown_02039CE8->var_10 = 0; - memset(gUnknown_02039CE8->badgeCount, 0, 8); - if(gUnknown_02039CE8->var_534.hasPokedex) + memset(gUnknown_02039CE8->badgeCount, 0, sizeof(gUnknown_02039CE8->badgeCount)); + if (gUnknown_02039CE8->var_534.hasPokedex) gUnknown_02039CE8->var_A++; - - if(gUnknown_02039CE8->var_534.firstHallOfFameA - ||gUnknown_02039CE8->var_534.firstHallOfFameB - ||gUnknown_02039CE8->var_534.firstHallOfFameC) + + if (gUnknown_02039CE8->var_534.hofDebutHours + || gUnknown_02039CE8->var_534.hofDebutMinutes + || gUnknown_02039CE8->var_534.hofDebutSeconds) gUnknown_02039CE8->var_B++; - - if(gUnknown_02039CE8->var_534.linkBattleWins || gUnknown_02039CE8->var_534.linkBattleLosses) + + if (gUnknown_02039CE8->var_534.linkBattleWins || gUnknown_02039CE8->var_534.linkBattleLosses) gUnknown_02039CE8->var_C++; - if(gUnknown_02039CE8->var_534.pokemonTrades) + if (gUnknown_02039CE8->var_534.pokemonTrades) gUnknown_02039CE8->var_10++; - if(gUnknown_02039CE8->var_534.battleTowerWins || gUnknown_02039CE8->var_534.battleTowerLosses) + if (gUnknown_02039CE8->var_534.battleTowerWins || gUnknown_02039CE8->var_534.battleTowerLosses) gUnknown_02039CE8->var_D++; - + i = 0; badgeFlag = FLAG_BADGE01_GET; while (1) { - if(FlagGet(badgeFlag)) + if (FlagGet(badgeFlag)) gUnknown_02039CE8->badgeCount[i]++; badgeFlag++; i++; @@ -970,7 +749,7 @@ void sub_80C3278(void) SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WIN0V, 160); SetGpuReg(REG_OFFSET_WIN0H, 240); - if(gReceivedRemoteLinkPlayers) + if (gReceivedRemoteLinkPlayers) EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK | INTR_FLAG_VCOUNT | INTR_FLAG_TIMER3 | INTR_FLAG_SERIAL); else EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK); @@ -978,9 +757,9 @@ void sub_80C3278(void) void sub_80C32EC(u16 arg0) { - u8 quotient = (arg0 + 40) / 10; - - if((s8)quotient <= 4) + s8 quotient = (arg0 + 40) / 10; + + if (quotient <= 4) quotient = 0; gUnknown_02039CE8->var_528 = quotient; SetGpuReg(REG_OFFSET_BLDY, gUnknown_02039CE8->var_528); @@ -1029,27 +808,27 @@ void sub_80C3414(void) sub_80C3190(); } -bool8 sub_80C3438(void) +bool8 PrintAllOnCardPage1(void) { - switch(gUnknown_02039CE8->var_1) + switch (gUnknown_02039CE8->var_1) { case 0: - sub_80C3574(); + PrintNameOnCard(); break; case 1: - sub_80C3608(); + PrintIdOnCard(); break; case 2: - sub_80C3684(); + PrintMoneyOnCard(); break; case 3: - sub_80C378C(); + PrintPokedexOnCard(); break; case 4: - sub_80C3880(); + PrintTimeOnCard(); break; case 5: - sub_80C3A18(); + PrintProfilePhraseOnCard(); break; default: gUnknown_02039CE8->var_1 = 0; @@ -1059,33 +838,33 @@ bool8 sub_80C3438(void) return FALSE; } -bool8 sub_80C34B0(void) +bool8 PrintStringsOnCardPage2(void) { - switch(gUnknown_02039CE8->var_1) + switch (gUnknown_02039CE8->var_1) { case 0: sub_80C3B50(); break; case 1: - sub_80C3CCC(); + PrintHofDebutStringOnCard(); break; case 2: - sub_80C3D60(); + PrintWinsLossesStringOnCard(); break; case 3: - sub_80C3DF0(); + PrintTradesStringOnCard(); break; case 4: - sub_80C3E58(); - sub_80C3F64(); + PrintBerryCrushStringOnCard(); + PrintPokeblockStringOnCard(); break; case 5: - sub_80C3ED4(); - sub_80C3FE0(); + PrintUnionStringOnCard(); + PrintContestStringOnCard(); break; case 6: sub_80C4140(); - sub_80C40CC(); + PrintBattleFacilityStringOnCard(); break; case 7: sub_80C42A4(); @@ -1098,33 +877,33 @@ bool8 sub_80C34B0(void) return FALSE; } -void sub_80C3548(void) +void PrintAllVariableNumsOnCardPage2(void) { - sub_80C3AF0(); - sub_80C3BC4(); - sub_80C3CF4(); - sub_80C3DC0(); - sub_80C3E20(); - sub_80C3E98(); - sub_80C3F14(); - sub_80C3FA4(); - sub_80C4020(); + PrintNameOnCard2(); + PrintHofTimeOnCard(); + PrintLinkResultsNumsOnCard(); + PrintTradesNumOnCard(); + PrintBerryCrushNumOnCard(); + PrintUnionNumOnCard(); + PrintPokeblocksNumOnCard(); + PrintContestNumOnCard(); + PrintBattleFacilityNumsOnCard(); } -void sub_80C3574(void) +void PrintNameOnCard(void) { u8 buffer[32]; u8* txtPtr; txtPtr = StringCopy(buffer, gText_TrainerCardName); StringCopy(txtPtr, gUnknown_02039CE8->var_534.playerName); ConvertInternationalString(txtPtr, gUnknown_02039CE8->var_7CAA); - if(!gUnknown_02039CE8->var_52A) + if (!gUnknown_02039CE8->var_52A) AddTextPrinterParameterized3(1, 1, 20, 28, gUnknown_0856FB0C, -1, buffer); else AddTextPrinterParameterized3(1, 1, 16, 33, gUnknown_0856FB0C, -1, buffer); } -void sub_80C3608(void) +void PrintIdOnCard(void) { u8 buffer[32]; u8* txtPtr; @@ -1132,9 +911,9 @@ void sub_80C3608(void) u32 top; txtPtr = StringCopy(buffer, gText_TrainerCardIDNo); ConvertIntToDecimalStringN(txtPtr, gUnknown_02039CE8->var_534.trainerId, STR_CONV_MODE_LEADING_ZEROS, 5); - if(!gUnknown_02039CE8->var_52A) + if (!gUnknown_02039CE8->var_52A) { - xPos = GetStringCenterAlignXOffset(1, buffer, 80) + 132; + xPos = GetStringCenterAlignXOffset(1, buffer, 80) + 132; top = 9; } else @@ -1142,21 +921,23 @@ void sub_80C3608(void) xPos = GetStringCenterAlignXOffset(1, buffer, 96) + 120; top = 9; } - + AddTextPrinterParameterized3(1, 1, xPos, top, gUnknown_0856FB0C, -1, buffer); } -void sub_80C3684(void) +void PrintMoneyOnCard(void) { s32 xOffset; u8 top; - if(!gUnknown_02039CE8->var_52B) + + if (!gUnknown_02039CE8->var_52B) AddTextPrinterParameterized3(1, 1, 20, 56, gUnknown_0856FB0C, -1, gText_TrainerCardMoney); else AddTextPrinterParameterized3(1, 1, 16, 57, gUnknown_0856FB0C, -1, gText_TrainerCardMoney); + ConvertIntToDecimalStringN(gStringVar1, gUnknown_02039CE8->var_534.money, 0, 6); StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1); - if(!gUnknown_02039CE8->var_52B) + if (!gUnknown_02039CE8->var_52B) { xOffset = GetStringRightAlignXOffset(1, gStringVar4, 144); top = 56; @@ -1165,30 +946,30 @@ void sub_80C3684(void) { xOffset = GetStringRightAlignXOffset(1, gStringVar4, 128); top = 57; - } + } AddTextPrinterParameterized3(1, 1, xOffset, top, gUnknown_0856FB0C, -1, gStringVar4); } -u16 sub_80C376C(void) +u16 GetCaughtMonsCount(void) { - if(IsNationalPokedexEnabled()) + if (IsNationalPokedexEnabled()) return GetNationalPokedexCount(FLAG_GET_CAUGHT); - - return GetHoennPokedexCount(FLAG_GET_CAUGHT); + else + return GetHoennPokedexCount(FLAG_GET_CAUGHT); } -void sub_80C378C(void) +void PrintPokedexOnCard(void) { s32 xOffset; u8 top; - if(FlagGet(FLAG_SYS_POKEDEX_GET)) + if (FlagGet(FLAG_SYS_POKEDEX_GET)) { - if(!gUnknown_02039CE8->var_52B) + if (!gUnknown_02039CE8->var_52B) AddTextPrinterParameterized3(1, 1, 20, 72, gUnknown_0856FB0C, -1, gText_TrainerCardPokedex); else AddTextPrinterParameterized3(1, 1, 16, 73, gUnknown_0856FB0C, -1,gText_TrainerCardPokedex); - StringCopy(ConvertIntToDecimalStringN(gStringVar4, gUnknown_02039CE8->var_534.pokedexCaught, 0, 3), gText_EmptyString6); - if(!gUnknown_02039CE8->var_52B) + StringCopy(ConvertIntToDecimalStringN(gStringVar4, gUnknown_02039CE8->var_534.caughtMonsCount, 0, 3), gText_EmptyString6); + if (!gUnknown_02039CE8->var_52B) { xOffset = GetStringRightAlignXOffset(1, gStringVar4, 144); top = 72; @@ -1197,42 +978,45 @@ void sub_80C378C(void) { xOffset = GetStringRightAlignXOffset(1, gStringVar4, 128); top = 73; - } + } AddTextPrinterParameterized3(1, 1, xOffset, top, gUnknown_0856FB0C, -1, gStringVar4); } } -void sub_80C3880(void) +void PrintTimeOnCard(void) { u16 hours; u16 minutes; s32 width; u32 r7, r4, r10; - if(!gUnknown_02039CE8->var_52B) + + if (!gUnknown_02039CE8->var_52B) AddTextPrinterParameterized3(1, 1, 20, 88, gUnknown_0856FB0C, -1, gText_TrainerCardTime); else AddTextPrinterParameterized3(1, 1, 16, 89, gUnknown_0856FB0C, -1, gText_TrainerCardTime); - if(gUnknown_02039CE8->var_5) + + if (gUnknown_02039CE8->var_5) { hours = gUnknown_02039CE8->var_534.playTimeHours; - minutes = gUnknown_02039CE8->var_534.playTimeMinutes; + minutes = gUnknown_02039CE8->var_534.playTimeMinutes; } else { hours = gSaveBlock2Ptr->playTimeHours; minutes = gSaveBlock2Ptr->playTimeMinutes; } - if(hours > 999) + + if (hours > 999) hours = 999; - if(minutes > 59) + if (minutes > 59) minutes = 59; width = GetStringWidth(1, gText_Colon2, 0); - - if(!gUnknown_02039CE8->var_52B) + + if (!gUnknown_02039CE8->var_52B) { r7 = 144; r4 = 88; - } + } else { r7 = 128; @@ -1240,7 +1024,7 @@ void sub_80C3880(void) } r10 = width + 30; r7 -= r10; - + FillWindowPixelRect(1, 0, r7, r4, r10, 15); ConvertIntToDecimalStringN(gStringVar4, hours, 1, 3); AddTextPrinterParameterized3(1, 1, r7, r4, gUnknown_0856FB0C, -1, gStringVar4); @@ -1251,9 +1035,9 @@ void sub_80C3880(void) AddTextPrinterParameterized3(1, 1, r7, r4, gUnknown_0856FB0C, -1, gStringVar4); } -void sub_80C3A18(void) +void PrintProfilePhraseOnCard(void) { - if(gUnknown_02039CE8->var_5) + if (gUnknown_02039CE8->var_5) { AddTextPrinterParameterized3(1, 1, 8, gUnknown_0856FB48[gUnknown_02039CE8->var_52B], gUnknown_0856FB0C, -1, gUnknown_02039CE8->var_19); AddTextPrinterParameterized3(1, 1, GetStringWidth(1, gUnknown_02039CE8->var_19, 0) + 14, gUnknown_0856FB48[gUnknown_02039CE8->var_52B], gUnknown_0856FB0C, -1, gUnknown_02039CE8->var_26); @@ -1262,11 +1046,11 @@ void sub_80C3A18(void) } } -void sub_80C3AF0(void) +void PrintNameOnCard2(void) { StringCopy(gUnknown_02039CE8->var_4D, gUnknown_02039CE8->var_534.playerName); ConvertInternationalString(gUnknown_02039CE8->var_4D, gUnknown_02039CE8->var_7CAA); - if(gUnknown_02039CE8->var_52A) + if (gUnknown_02039CE8->var_52A) { StringCopy(gStringVar1, gUnknown_02039CE8->var_4D); StringExpandPlaceholders(gUnknown_02039CE8->var_4D, gText_Var1sTrainerCard); @@ -1275,19 +1059,19 @@ void sub_80C3AF0(void) void sub_80C3B50(void) { - if(!gUnknown_02039CE8->var_52B) + if (!gUnknown_02039CE8->var_52B) AddTextPrinterParameterized3(1, 1, 136, 9, gUnknown_0856FB0C, -1, gUnknown_02039CE8->var_4D); else AddTextPrinterParameterized3(1, 1, GetStringRightAlignXOffset(1, gUnknown_02039CE8->var_4D, 216), 9, gUnknown_0856FB0C, -1, gUnknown_02039CE8->var_4D); } -void sub_80C3BC4(void) +void PrintHofTimeOnCard(void) { - if(gUnknown_02039CE8->var_B) + if (gUnknown_02039CE8->var_B) { - ConvertIntToDecimalStringN(gStringVar1, gUnknown_02039CE8->var_534.firstHallOfFameA, 1, 3); - ConvertIntToDecimalStringN(gStringVar2, gUnknown_02039CE8->var_534.firstHallOfFameB, 2, 2); - ConvertIntToDecimalStringN(gStringVar3, gUnknown_02039CE8->var_534.firstHallOfFameC, 2, 2); + ConvertIntToDecimalStringN(gStringVar1, gUnknown_02039CE8->var_534.hofDebutHours, 1, 3); + ConvertIntToDecimalStringN(gStringVar2, gUnknown_02039CE8->var_534.hofDebutMinutes, 2, 2); + ConvertIntToDecimalStringN(gStringVar3, gUnknown_02039CE8->var_534.hofDebutSeconds, 2, 2); StringExpandPlaceholders(gUnknown_02039CE8->var_93, gUnknown_0856FB4C); } } @@ -1298,15 +1082,15 @@ void sub_80C3C34(u8 top, const u8* str1, u8* str2, const u8* color) AddTextPrinterParameterized3(1, 1, GetStringRightAlignXOffset(1, str2, gUnknown_0856FB57[gUnknown_02039CE8->var_52B]), top * 16 + 33, color, -1, str2); } -void sub_80C3CCC(void) +void PrintHofDebutStringOnCard(void) { - if(gUnknown_02039CE8->var_B) - sub_80C3C34(0, gText_HallOfFameDebut, gUnknown_02039CE8->var_93, gUnknown_0856FB0F); + if (gUnknown_02039CE8->var_B) + sub_80C3C34(0, gText_HallOfFameDebut, gUnknown_02039CE8->var_93, gUnknown_0856FB0F); } -void sub_80C3CF4(void) +void PrintLinkResultsNumsOnCard(void) { - if(gUnknown_02039CE8->var_C) + if (gUnknown_02039CE8->var_C) { StringCopy(gUnknown_02039CE8->var_D9, gUnknown_0856FB5C[gUnknown_02039CE8->var_52A]); ConvertIntToDecimalStringN(gUnknown_02039CE8->var_165, gUnknown_02039CE8->var_534.linkBattleWins, 0, 4); @@ -1314,9 +1098,9 @@ void sub_80C3CF4(void) } } -void sub_80C3D60(void) +void PrintWinsLossesStringOnCard(void) { - if(gUnknown_02039CE8->var_C) + if (gUnknown_02039CE8->var_C) { StringCopy(gStringVar1, gUnknown_02039CE8->var_165); StringCopy(gStringVar2, gUnknown_02039CE8->var_1AB); @@ -1325,105 +1109,108 @@ void sub_80C3D60(void) } } -void sub_80C3DC0(void) +void PrintTradesNumOnCard(void) { - if(gUnknown_02039CE8->var_10) + if (gUnknown_02039CE8->var_10) ConvertIntToDecimalStringN(gUnknown_02039CE8->var_237, gUnknown_02039CE8->var_534.pokemonTrades, 1, 5); } -void sub_80C3DF0(void) +void PrintTradesStringOnCard(void) { - if(gUnknown_02039CE8->var_10) + if (gUnknown_02039CE8->var_10) sub_80C3C34(2, gText_PokemonTrades, gUnknown_02039CE8->var_237, gUnknown_0856FB0F); } -void sub_80C3E20(void) +void PrintBerryCrushNumOnCard(void) { - if(!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_3C) + if (!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_3C) ConvertIntToDecimalStringN(gUnknown_02039CE8->var_2C3, gUnknown_02039CE8->var_534.var_3C, 1, 5); } -void sub_80C3E58(void) +void PrintBerryCrushStringOnCard(void) { - if(!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_3C) + if (!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_3C) sub_80C3C34(4, gText_BerryCrush, gUnknown_02039CE8->var_2C3, gUnknown_0856FB0F); } -void sub_80C3E98(void) +void PrintUnionNumOnCard(void) { - if(!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_40) + if (!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_40) ConvertIntToDecimalStringN(gUnknown_02039CE8->var_34F, gUnknown_02039CE8->var_534.var_40, 1, 5); } -void sub_80C3ED4(void) +void PrintUnionStringOnCard(void) { - if(!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_40) + if (!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_40) sub_80C3C34(3, gText_UnionTradesAndBattles, gUnknown_02039CE8->var_34F, gUnknown_0856FB0F); } -void sub_80C3F14(void) +void PrintPokeblocksNumOnCard(void) { - if(gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.pokeblocksWithFriends) + if (gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.pokeblocksWithFriends) { ConvertIntToDecimalStringN(gStringVar1, gUnknown_02039CE8->var_534.pokeblocksWithFriends, 1, 5); StringExpandPlaceholders(gUnknown_02039CE8->var_395, gText_Var1DarkGreyShadowLightGrey); } } -void sub_80C3F64(void) +void PrintPokeblockStringOnCard(void) { - if(gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.pokeblocksWithFriends) + if (gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.pokeblocksWithFriends) sub_80C3C34(3, gText_PokeblocksWithFriends, gUnknown_02039CE8->var_395, gUnknown_0856FB0F); } -void sub_80C3FA4(void) +void PrintContestNumOnCard(void) { - if(gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.contestsWithFriends) + if (gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.contestsWithFriends) ConvertIntToDecimalStringN(gUnknown_02039CE8->var_3DB, gUnknown_02039CE8->var_534.contestsWithFriends, 1, 5); } -void sub_80C3FE0(void) +void PrintContestStringOnCard(void) { - if(gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.contestsWithFriends) + if (gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.contestsWithFriends) sub_80C3C34(4, gText_WonContestsWFriends, gUnknown_02039CE8->var_3DB, gUnknown_0856FB0F); } -void sub_80C4020(void) +void PrintBattleFacilityNumsOnCard(void) { - switch(gUnknown_02039CE8->var_52A) + switch (gUnknown_02039CE8->var_52A) { case 1: - if(gUnknown_02039CE8->var_D) + if (gUnknown_02039CE8->var_D) { ConvertIntToDecimalStringN(gStringVar1, gUnknown_02039CE8->var_534.battleTowerWins, 1, 4); ConvertIntToDecimalStringN(gStringVar2, gUnknown_02039CE8->var_534.battleTowerLosses, 1, 4); StringExpandPlaceholders(gUnknown_02039CE8->var_421, gText_WSlashStraightSlash); } break; - case 2: - if(gUnknown_02039CE8->var_534.var_62) + if (gUnknown_02039CE8->var_534.var_62) { ConvertIntToDecimalStringN(gStringVar1, gUnknown_02039CE8->var_534.var_62, 1, 5); StringExpandPlaceholders(gUnknown_02039CE8->var_421, gText_Var1DarkLightGreyBP); } + break; case 0: + break; } } -void sub_80C40CC(void) +void PrintBattleFacilityStringOnCard(void) { - switch(gUnknown_02039CE8->var_52A) + switch (gUnknown_02039CE8->var_52A) { case 1: - if(gUnknown_02039CE8->var_D) + if (gUnknown_02039CE8->var_D) sub_80C3C34(5, gText_BattleTower, gUnknown_02039CE8->var_421, gUnknown_0856FB0C); break; case 2: - if(gUnknown_02039CE8->var_534.var_62) + if (gUnknown_02039CE8->var_534.var_62) sub_80C3C34(5, gText_BattlePtsWon, gUnknown_02039CE8->var_421, gUnknown_0856FB0F); + break; case 0: - } + break; + } } void sub_80C4140(void) @@ -1433,26 +1220,29 @@ void sub_80C4140(void) u8 buffer2[8]; memcpy(buffer, gUnknown_0856FB68, sizeof(gUnknown_0856FB68)); memcpy(buffer2, gUnknown_0856FB6E, sizeof(gUnknown_0856FB6E)); - - if(!gUnknown_02039CE8->var_52A) + + if (!gUnknown_02039CE8->var_52A) { - for(i = 0; i < 6; i++) + for (i = 0; i < 6; i++) { - if(gUnknown_02039CE8->var_534.monSpecies[i]) + if (gUnknown_02039CE8->var_534.monSpecies[i]) { u8 monSpecies = sub_80D30A0(gUnknown_02039CE8->var_534.monSpecies[i]); WriteSequenceToBgTilemapBuffer(3, 16 * i + 224, buffer2[i] + 3, 15, 4, 4, buffer[monSpecies], 1); } } - } + } } void sub_80C41D8(void) { u8 i; + CpuSet(gMonIconPalettes, gUnknown_02039CE8->var_468, 0x60); - switch(gUnknown_02039CE8->var_534.var_4E) + switch (gUnknown_02039CE8->var_534.var_4E) { + case 0: + break; case 1: TintPalette_CustomTone(gUnknown_02039CE8->var_468, 96, 0, 0, 0); break; @@ -1461,15 +1251,15 @@ void sub_80C41D8(void) break; case 3: TintPalette_SepiaTone(gUnknown_02039CE8->var_468, 96); - case 0: + break; } LoadPalette(gUnknown_02039CE8->var_468, 80, 192); - - for(i = 0; i < 6; i++) + + for (i = 0; i < 6; i++) { - if(gUnknown_02039CE8->var_534.monSpecies[i]) + if (gUnknown_02039CE8->var_534.monSpecies[i]) LoadBgTiles(3, GetMonIconTiles(gUnknown_02039CE8->var_534.monSpecies[i], 0), 512, 16 * i + 32); - } + } } void sub_80C42A4(void) @@ -1477,12 +1267,12 @@ void sub_80C42A4(void) u8 i; u8 buffer[4]; memcpy(buffer, gUnknown_0856FB74, sizeof(gUnknown_0856FB74)); - if(!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_4C == 1) + if (!gUnknown_02039CE8->var_52A && gUnknown_02039CE8->var_534.var_4C == 1) { - for(i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { u8 var_50 = gUnknown_02039CE8->var_534.var_50[i]; - if(gUnknown_02039CE8->var_534.var_50[i]) + if (gUnknown_02039CE8->var_534.var_50[i]) WriteSequenceToBgTilemapBuffer(3, i * 4 + 320, i * 3 + 2, 2, 2, 2, buffer[var_50 - 1], 1); } } @@ -1505,7 +1295,7 @@ void sub_80C438C(u8 windowId) u8 sub_80C43A8(void) { - switch(gUnknown_02039CE8->var_3) + switch (gUnknown_02039CE8->var_3) { case 0: LoadBgTiles(3, gUnknown_02039CE8->var_13A8, 1024, 0); @@ -1514,18 +1304,18 @@ u8 sub_80C43A8(void) LoadBgTiles(0, gUnknown_02039CE8->var_19A8, 6144, 0); break; case 2: - if(gUnknown_02039CE8->var_52A) + if (gUnknown_02039CE8->var_52A) { LoadPalette(gEmeraldTrainerCardStarPals[gUnknown_02039CE8->var_534.stars], 0, 96); LoadPalette(gUnknown_0856F4EC, 48, 32); - if(gUnknown_02039CE8->var_534.gender) + if (gUnknown_02039CE8->var_534.gender) LoadPalette(gUnknown_0856F4AC, 16, 32); } else { LoadPalette(gFireRedTrainerCardStarPals[gUnknown_02039CE8->var_534.stars], 0, 96); LoadPalette(gUnknown_0856F50C, 48, 32); - if(gUnknown_02039CE8->var_534.gender) + if (gUnknown_02039CE8->var_534.gender) LoadPalette(gUnknown_0856F4CC, 16, 32); } LoadPalette(gUnknown_0856F52C, 64, 32); @@ -1545,284 +1335,81 @@ u8 sub_80C43A8(void) return 0; } -NAKED -void sub_80C4550(u8* ptr) //nested loop +void sub_80C4550(u16 *ptr) { - asm("\n\ - .syntax unified\n\ - push {r4-r7,lr}\n\ - adds r7, r0, 0\n\ - ldr r0, =gUnknown_02039CE8\n\ - ldr r0, [r0]\n\ - ldr r1, =0x00005ca8\n\ - adds r6, r0, r1\n\ - movs r1, 0\n\ -_080C455E:\n\ - movs r2, 0\n\ - lsls r5, r1, 16\n\ - asrs r1, r5, 16\n\ - lsls r3, r1, 5\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r4, r0, 1\n\ -_080C456C:\n\ - lsls r0, r2, 16\n\ - asrs r1, r0, 16\n\ - adds r2, r0, 0\n\ - cmp r1, 0x1D\n\ - bgt _080C4590\n\ - adds r0, r3, r1\n\ - lsls r0, 1\n\ - adds r0, r6\n\ - adds r1, r4, r1\n\ - lsls r1, 1\n\ - adds r1, r7\n\ - ldrh r1, [r1]\n\ - b _080C4598\n\ - .pool\n\ -_080C4590:\n\ - adds r0, r3, r1\n\ - lsls r0, 1\n\ - adds r0, r6\n\ - ldrh r1, [r7]\n\ -_080C4598:\n\ - strh r1, [r0]\n\ - movs r1, 0x80\n\ - lsls r1, 9\n\ - adds r0, r2, r1\n\ - lsrs r2, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x1F\n\ - ble _080C456C\n\ - adds r0, r5, r1\n\ - lsrs r1, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x13\n\ - ble _080C455E\n\ - movs r0, 0x2\n\ - bl CopyBgTilemapBufferToVram\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided"); + s16 i, j; + u16 *dst = gUnknown_02039CE8->var_5CA8; + + for (i = 0; i < 20; i++) + { + for (j = 0; j < 32; j++) + { + if (j < 30) + dst[32 * i + j] = ptr[30 * i + j]; + else + dst[32 * i + j] = ptr[0]; + } + } + CopyBgTilemapBufferToVram(2); } -NAKED -void sub_80C45C0(u8* ptr) //nested loop +void sub_80C45C0(u16* ptr) { - asm("\n\ - .syntax unified\n\ - push {r4-r7,lr}\n\ - adds r7, r0, 0\n\ - ldr r0, =gUnknown_02039CE8\n\ - ldr r0, [r0]\n\ - ldr r1, =0x00003ca8\n\ - adds r6, r0, r1\n\ - movs r1, 0\n\ -_080C45CE:\n\ - movs r2, 0\n\ - lsls r5, r1, 16\n\ - asrs r1, r5, 16\n\ - lsls r3, r1, 5\n\ - lsls r0, r1, 4\n\ - subs r0, r1\n\ - lsls r4, r0, 1\n\ -_080C45DC:\n\ - lsls r0, r2, 16\n\ - asrs r1, r0, 16\n\ - adds r2, r0, 0\n\ - cmp r1, 0x1D\n\ - bgt _080C4600\n\ - adds r0, r3, r1\n\ - lsls r0, 1\n\ - adds r0, r6\n\ - adds r1, r4, r1\n\ - lsls r1, 1\n\ - adds r1, r7\n\ - ldrh r1, [r1]\n\ - b _080C4608\n\ - .pool\n\ -_080C4600:\n\ - adds r0, r3, r1\n\ - lsls r0, 1\n\ - adds r0, r6\n\ - ldrh r1, [r7]\n\ -_080C4608:\n\ - strh r1, [r0]\n\ - movs r1, 0x80\n\ - lsls r1, 9\n\ - adds r0, r2, r1\n\ - lsrs r2, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x1F\n\ - ble _080C45DC\n\ - adds r0, r5, r1\n\ - lsrs r1, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x13\n\ - ble _080C45CE\n\ - movs r0, 0\n\ - bl CopyBgTilemapBufferToVram\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided"); + s16 i, j; + u16 *dst = gUnknown_02039CE8->var_3CA8; + + for (i = 0; i < 20; i++) + { + for (j = 0; j < 32; j++) + { + if (j < 30) + dst[32 * i + j] = ptr[30 * i + j]; + else + dst[32 * i + j] = ptr[0]; + } + } + CopyBgTilemapBufferToVram(0); } -NAKED void sub_80C4630(void) { - asm("\n\ - .syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0xC\n\ - movs r0, 0xC0\n\ - mov r8, r0\n\ - movs r2, 0x3\n\ - mov r10, r2\n\ - ldr r2, =gUnknown_0856FB78\n\ - ldr r4, =gUnknown_02039CE8\n\ - ldr r1, [r4]\n\ - ldr r3, =0x0000052b\n\ - adds r0, r1, r3\n\ - ldrb r0, [r0]\n\ - adds r0, r2\n\ - ldrb r3, [r0]\n\ - ldr r0, =0x00000535\n\ - adds r1, r0\n\ - ldrb r0, [r1]\n\ - str r0, [sp]\n\ - movs r0, 0x1\n\ - str r0, [sp, 0x4]\n\ - movs r0, 0x4\n\ - str r0, [sp, 0x8]\n\ - movs r0, 0x3\n\ - movs r1, 0x8F\n\ - movs r2, 0xF\n\ - bl FillBgTilemapBufferRect\n\ - ldr r0, [r4]\n\ - ldrb r0, [r0, 0x5]\n\ - cmp r0, 0\n\ - bne _080C4724\n\ - movs r2, 0x4\n\ - mov r9, r2\n\ - movs r2, 0\n\ - movs r6, 0x1\n\ -_080C467E:\n\ - ldr r0, =gUnknown_02039CE8\n\ - ldr r1, [r0]\n\ - lsls r0, r2, 16\n\ - asrs r7, r0, 16\n\ - adds r1, 0x11\n\ - adds r1, r7\n\ - ldrb r0, [r1]\n\ - cmp r0, 0\n\ - beq _080C4700\n\ - mov r3, r9\n\ - lsls r5, r3, 24\n\ - lsrs r5, 24\n\ - str r6, [sp]\n\ - str r6, [sp, 0x4]\n\ - mov r0, r10\n\ - str r0, [sp, 0x8]\n\ - movs r0, 0x3\n\ - mov r1, r8\n\ - adds r2, r5, 0\n\ - movs r3, 0xF\n\ - bl FillBgTilemapBufferRect\n\ - mov r1, r8\n\ - adds r1, 0x1\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - mov r4, r9\n\ - adds r4, 0x1\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - str r6, [sp]\n\ - str r6, [sp, 0x4]\n\ - mov r2, r10\n\ - str r2, [sp, 0x8]\n\ - movs r0, 0x3\n\ - adds r2, r4, 0\n\ - movs r3, 0xF\n\ - bl FillBgTilemapBufferRect\n\ - mov r1, r8\n\ - adds r1, 0x10\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - str r6, [sp]\n\ - str r6, [sp, 0x4]\n\ - mov r3, r10\n\ - str r3, [sp, 0x8]\n\ - movs r0, 0x3\n\ - adds r2, r5, 0\n\ - movs r3, 0x10\n\ - bl FillBgTilemapBufferRect\n\ - mov r1, r8\n\ - adds r1, 0x11\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - str r6, [sp]\n\ - str r6, [sp, 0x4]\n\ - mov r0, r10\n\ - str r0, [sp, 0x8]\n\ - movs r0, 0x3\n\ - adds r2, r4, 0\n\ - movs r3, 0x10\n\ - bl FillBgTilemapBufferRect\n\ -_080C4700:\n\ - adds r0, r7, 0x1\n\ - lsls r0, 16\n\ - mov r1, r8\n\ - adds r1, 0x2\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - mov r8, r1\n\ - mov r2, r9\n\ - lsls r1, r2, 16\n\ - movs r3, 0xC0\n\ - lsls r3, 10\n\ - adds r1, r3\n\ - lsrs r1, 16\n\ - mov r9, r1\n\ - lsrs r2, r0, 16\n\ - asrs r0, 16\n\ - cmp r0, 0x7\n\ - ble _080C467E\n\ -_080C4724:\n\ - movs r0, 0x3\n\ - bl CopyBgTilemapBufferToVram\n\ - add sp, 0xC\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided"); + s16 i, x; + u16 tileNum = 192; + u8 palNum = 3; + + FillBgTilemapBufferRect(3, 143, 15, gUnknown_0856FB78[gUnknown_02039CE8->var_52B], gUnknown_02039CE8->var_534.stars, 1, 4); + if (!gUnknown_02039CE8->var_5) + { + x = 4; + for (i = 0; i < 8; i++, tileNum += 2, x += 3) + { + if (gUnknown_02039CE8->badgeCount[i]) + { + FillBgTilemapBufferRect(3, tileNum, x, 15, 1, 1, palNum); + FillBgTilemapBufferRect(3, tileNum + 1, x + 1, 15, 1, 1, palNum); + FillBgTilemapBufferRect(3, tileNum + 16, x, 16, 1, 1, palNum); + FillBgTilemapBufferRect(3, tileNum + 17, x + 1, 16, 1, 1, palNum); + } + } + } + CopyBgTilemapBufferToVram(3); } void sub_80C474C(void) { - if(!gUnknown_02039CE8->var_52A) + if (!gUnknown_02039CE8->var_52A) { - if(gUnknown_02039CE8->var_10) + if (gUnknown_02039CE8->var_10) { FillBgTilemapBufferRect(3, 141, 27, 9, 1, 1, 1); FillBgTilemapBufferRect(3, 157, 27, 10, 1, 1, 1); } - if(gUnknown_02039CE8->var_534.var_3C) + if (gUnknown_02039CE8->var_534.var_3C) { FillBgTilemapBufferRect(3, 141, 21, 13, 1, 1, 1); FillBgTilemapBufferRect(3, 157, 21, 14, 1, 1, 1); } - if(gUnknown_02039CE8->var_534.var_40) + if (gUnknown_02039CE8->var_534.var_40) { FillBgTilemapBufferRect(3, 141, 27, 11, 1, 1, 1); FillBgTilemapBufferRect(3, 157, 27, 12, 1, 1, 1); @@ -1830,17 +1417,17 @@ void sub_80C474C(void) } else { - if(gUnknown_02039CE8->var_10) + if (gUnknown_02039CE8->var_10) { FillBgTilemapBufferRect(3, 141, 27, 9, 1, 1, 0); FillBgTilemapBufferRect(3, 157, 27, 10, 1, 1, 0); } - if(gUnknown_02039CE8->var_534.contestsWithFriends) + if (gUnknown_02039CE8->var_534.contestsWithFriends) { FillBgTilemapBufferRect(3, 141, 27, 13, 1, 1, 0); FillBgTilemapBufferRect(3, 157, 27, 14, 1, 1, 0); } - if(gUnknown_02039CE8->var_D) + if (gUnknown_02039CE8->var_D) { FillBgTilemapBufferRect(3, 141, 17, 15, 1, 1, 0); FillBgTilemapBufferRect(3, 157, 17, 16, 1, 1, 0); @@ -1853,7 +1440,7 @@ void sub_80C474C(void) void sub_80C48C8(void) { - if(++gUnknown_02039CE8->var_6 > 60) + if (++gUnknown_02039CE8->var_6 > 60) { gUnknown_02039CE8->var_6 = 0; gUnknown_02039CE8->var_7 ^= 1; @@ -1876,9 +1463,10 @@ void sub_80C4918(void) bool8 sub_80C4940(void) { - if(FindTaskIdByFunc(sub_80C4960) == 0xFF) + if (FindTaskIdByFunc(sub_80C4960) == 0xFF) return TRUE; - return FALSE; + else + return FALSE; } void sub_80C4960(u8 taskId) @@ -1890,11 +1478,12 @@ void sub_80C4960(u8 taskId) bool8 sub_80C4998(struct Task* task) { u32 i; + HideBg(1); HideBg(3); ScanlineEffect_Stop(); ScanlineEffect_Clear(); - for(i = 0; i < 160; i++) + for (i = 0; i < 160; i++) gScanlineEffectRegBuffers[1][i] = 0; task->data[0]++; return FALSE;