From 52a4428ba624b19569418a9c72f60d3494fb71eb Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 11 Jul 2020 20:25:56 -0400 Subject: [PATCH] Begin new contest documentation --- data/contest_ai_scripts.s | 25 +- .../contest/{heart.png => slider_heart.png} | Bin include/constants/contest.h | 8 - include/constants/global.h | 8 + include/contest.h | 158 +++-- include/contest_link.h | 11 + include/contest_util.h | 1 - include/global.h | 4 +- include/graphics.h | 4 +- src/contest.c | 622 +++++++++--------- src/contest_ai.c | 85 +-- src/contest_effect.c | 84 +-- src/contest_link.c | 231 +++---- src/contest_link_util.c | 65 +- src/contest_util.c | 10 +- src/data/contest_opponents.h | 96 --- src/graphics.c | 4 +- src/pokemon.c | 4 +- 18 files changed, 685 insertions(+), 735 deletions(-) rename graphics/contest/{heart.png => slider_heart.png} (100%) diff --git a/data/contest_ai_scripts.s b/data/contest_ai_scripts.s index 7346876d7..252c39a3a 100644 --- a/data/contest_ai_scripts.s +++ b/data/contest_ai_scripts.s @@ -48,7 +48,7 @@ gContestAIChecks:: @ 82DE350 @ Unreferenced AI routine to encourage moves that improve condition on the first @ turn. Additionally, it checks the appeal order of the user and the effect -@ type, but the code is buggy and doesn't affect the score. +@ type, but the code is buggy and doesnt affect the score. if_turn_not_eq 0, ContestUnreferenced_80 if_effect_not_eq CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS, ContestUnreferenced_80 score +10 @@ -63,7 +63,7 @@ ContestUnreferenced_0D: ContestUnreferenced_end: end -@ Unreferenced AI routine that doesn't make much sense. +@ Unreferenced AI routine that doesnt make much sense. if_turn_eq 0, ContestUnreferenced_0F_1 if_turn_eq 1, ContestUnreferenced_0F_2 if_turn_eq 2, ContestUnreferenced_0F_3 @@ -122,25 +122,26 @@ ContestUnreferenced_score2: end AI_CheckBoring: - if_effect_eq CONTEST_EFFECT_REPETITION_NOT_BORING, AI_end_081DC27F - if_move_used_count_eq 1, AI_score1_081DC27F - if_move_used_count_eq 2, AI_score2_081DC27F - if_move_used_count_eq 3, AI_score3_081DC27F - if_move_used_count_eq 4, AI_score4_081DC27F + if_effect_eq CONTEST_EFFECT_REPETITION_NOT_BORING, AI_CheckBoring_NotBoring + if_move_used_count_eq 1, AI_CheckBoring_FirstRepeat + if_move_used_count_eq 2, AI_CheckBoring_SecondRepeat + if_move_used_count_eq 3, AI_CheckBoring_ThirdRepeat + if_move_used_count_eq 4, AI_CheckBoring_FourthRepeat + @ No repeats end -AI_score1_081DC27F: +AI_CheckBoring_FirstRepeat: score -5 end -AI_score2_081DC27F: +AI_CheckBoring_SecondRepeat: score -15 end -AI_score3_081DC27F: +AI_CheckBoring_ThirdRepeat: score -20 end -AI_score4_081DC27F: +AI_CheckBoring_FourthRepeat: score -25 end -AI_end_081DC27F: +AI_CheckBoring_NotBoring: end AI_CheckExcitement: diff --git a/graphics/contest/heart.png b/graphics/contest/slider_heart.png similarity index 100% rename from graphics/contest/heart.png rename to graphics/contest/slider_heart.png diff --git a/include/constants/contest.h b/include/constants/contest.h index 2de2866a3..5eabb5f46 100644 --- a/include/constants/contest.h +++ b/include/constants/contest.h @@ -1,7 +1,6 @@ #ifndef GUARD_CONSTANTS_CONTEST_H #define GUARD_CONSTANTS_CONTEST_H -#define CONTESTANT_COUNT 4 #define APPLAUSE_METER_SIZE 5 #define CONTEST_TURN_COUNT 5 @@ -22,13 +21,6 @@ #define CONTEST_TYPE_NPC_MASTER (CONTEST_RANK_MASTER + 1) #define CONTEST_TYPE_LINK (CONTEST_RANK_LINK + 1) -#define CONTEST_CATEGORY_COOL 0 -#define CONTEST_CATEGORY_BEAUTY 1 -#define CONTEST_CATEGORY_CUTE 2 -#define CONTEST_CATEGORY_SMART 3 -#define CONTEST_CATEGORY_TOUGH 4 -#define CONTEST_CATEGORIES_COUNT 5 - #define CONTEST_WINNER_ARTIST 0 // Winner shown by the artist, painting not necessarily saved #define CONTEST_WINNER_HALL_1 1 #define CONTEST_WINNER_HALL_2 2 diff --git a/include/constants/global.h b/include/constants/global.h index 956f86a05..7a7009fd5 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -62,6 +62,14 @@ #define MAX_MON_MOVES 4 #define NUM_STATS 6 +#define CONTESTANT_COUNT 4 +#define CONTEST_CATEGORY_COOL 0 +#define CONTEST_CATEGORY_BEAUTY 1 +#define CONTEST_CATEGORY_CUTE 2 +#define CONTEST_CATEGORY_SMART 3 +#define CONTEST_CATEGORY_TOUGH 4 +#define CONTEST_CATEGORIES_COUNT 5 + // party sizes #define PARTY_SIZE 6 #define MULTI_PARTY_SIZE PARTY_SIZE / 2 diff --git a/include/contest.h b/include/contest.h index a9b1db9ee..b6818f996 100644 --- a/include/contest.h +++ b/include/contest.h @@ -226,7 +226,9 @@ struct ContestPokemon /*0x29*/ u8 smart; // smart /*0x2A*/ u8 tough; // tough /*0x2B*/ u8 sheen; // sheen - /*0x2C*/ u8 unk2C[12]; + u8 highestRank; + bool8 gameCleared; + /*0x2C*/ u8 unk2C[10]; /*0x38*/ u32 personality; // personality /*0x3C*/ u32 otId; // otId }; @@ -252,85 +254,85 @@ struct ContestStruct_field_18 struct Contest { - /*0x0*/ u8 playerMoveChoice; - /*0x1*/ u8 turnNumber; - /*0x2*/ u8 unused2[CONTESTANT_COUNT]; - /*0x6*/ u16 unk1920A_0:1; // Task active flags? - u16 unk1920A_1:1; - u16 unk1920A_2:1; - u16 unk1920A_3:1; - u16 unk1920A_4:1; - u16 isShowingApplauseMeter:1; - u16 applauseMeterIsMoving:1; - u16 unk1920A_7:1; - /*0x7*/ u16 unk1920B_0:1; - u16 unk1920B_1:1; - u16 unk1920B_2:1; - /*0x8*/ u8 mainTaskId; - /*0x9*/ u8 unk1920D[4]; - /*0xD*/ u8 unk19211; - /*0xE*/ u8 unk19212; - /*0xF*/ u8 filler19213; - /*0x10*/ u8 unk19214; - /*0x11*/ u8 unk19215; - /*0x12*/ u8 unk19216; // sprite ID - /*0x13*/ s8 applauseLevel; - /*0x19218*/ u8 prevTurnOrder[CONTESTANT_COUNT]; - /*0x1921C*/ u32 unk1921C; // saved RNG value? + u8 playerMoveChoice; + u8 turnNumber; + u8 unused2[CONTESTANT_COUNT]; + bool16 unk1920A_0:1; // Task active flags? + bool16 unk1920A_1:1; + bool16 unk1920A_2:1; + bool16 unk1920A_3:1; + bool16 unk1920A_4:1; + bool16 isShowingApplauseMeter:1; + bool16 applauseMeterIsMoving:1; + bool16 unk1920A_7:1; + bool16 unk1920B_0:1; + bool16 sliderHeartsAnimating:1; // When the slider heart is appearing/disappearing + bool16 unk1920B_2:1; + u8 mainTaskId; + u8 unk1920D[4]; + u8 unk19211; + u8 unk19212; + u8 filler19213; + u8 unk19214; + u8 unk19215; + u8 unk19216; // sprite ID + s8 applauseLevel; + u8 prevTurnOrder[CONTESTANT_COUNT]; + u32 unk1921C; // saved RNG value? u16 moveHistory[CONTEST_TURN_COUNT][CONTESTANT_COUNT]; u8 excitementHistory[CONTEST_TURN_COUNT][CONTESTANT_COUNT]; u8 applauseMeterSpriteId; - /*0x1925D*/ u8 contestSetupState; - /*0x1925E*/ u8 unk1925E; + u8 contestSetupState; + u8 unk1925E; }; struct ContestantStatus { - /*0x00*/ s16 appeal1; // move appeal? - /*0x02*/ s16 appeal2; // final appeal after end of turn, maybe? - /*0x04*/ s16 pointTotal; - /*0x06*/ u16 currMove; - /*0x08*/ u16 prevMove; - /*0x0A*/ u8 moveCategory; - /*0x0B*/ u8 ranking:2; + s16 appeal1; // move appeal? + s16 appeal2; // final appeal after end of turn, maybe? + s16 pointTotal; + u16 currMove; + u16 prevMove; + u8 moveCategory; + u8 ranking:2; u8 unkB_2:2; u8 moveRepeatCount:3; - u8 noMoreTurns:1; // used a one-time move? - /*0x0C*/ u8 nervous:1; + bool8 noMoreTurns:1; // used a one-time move? + bool8 nervous:1; u8 numTurnsSkipped:2; - /*0x0D*/ s8 condition; - /*0x0E*/ u8 jam; - /*0x0F*/ u8 jamReduction; + s8 condition; + u8 jam; + u8 jamReduction; // Flags set by move effect - /*0x10*/ u8 resistant:1; - u8 immune:1; - u8 moreEasilyStartled:1; - u8 usedRepeatableMove:1; + bool8 resistant:1; + bool8 immune:1; + bool8 moreEasilyStartled:1; + bool8 usedRepeatableMove:1; u8 conditionMod:2; // 1: just raised condition; 2: appeal greatly improved by condition u8 turnOrderMod:2; // 1: defined; 2: random - /*0x11*/ u8 turnOrderModAction:2; // 1: made first; 2: made last; 3: made random - u8 turnSkipped:1; - u8 exploded:1; - u8 overrideCategoryExcitementMod:1; - u8 appealTripleCondition:1; + u8 turnOrderModAction:2; // 1: made first; 2: made last; 3: made random + bool8 turnSkipped:1; + bool8 exploded:1; + bool8 overrideCategoryExcitementMod:1; + bool8 appealTripleCondition:1; - /*0x12*/ u8 jamSafetyCount; - /*0x13*/ u8 effectStringId; // status action? - /*0x14*/ u8 effectStringId2; - /*0x15*/ u8 disappointedRepeat:1; - u8 unk15_1:1; - u8 unk15_2:1; - u8 unk15_3:1; - u8 hasJudgesAttention:1; - u8 judgesAttentionWasRemoved:1; - u8 unk15_6:1; - /*0x16*/ u8 unk16; - /*0x17*/ u8 unk17; - /*0x18*/ u8 unk18; - /*0x19*/ u8 nextTurnOrder; // turn position - /*0x1A*/ u8 attentionLevel; // How much the Pokemon "stood out" - /*0x1B*/ u8 unk1B; + u8 jamSafetyCount; + u8 effectStringId; // status action? + u8 effectStringId2; + bool8 repeatedMove:1; + bool8 unused:1; + bool8 repeatedPrevMove:1; // never read + bool8 unk15_3:1; + bool8 hasJudgesAttention:1; + bool8 judgesAttentionWasRemoved:1; + bool8 unk15_6:1; + u8 unk16; + u8 unk17; + u8 unk18; + u8 nextTurnOrder; // turn position + u8 attentionLevel; // How much the Pokemon "stood out" + u8 unk1B; }; struct UnknownContestStruct7 @@ -348,9 +350,9 @@ struct ContestAIInfo /*0x00*/ u8 aiState; /*0x02*/ u16 nextMove; /*0x04*/ u8 nextMoveIndex; - /*0x05*/ u8 unk5[4]; + /*0x05*/ u8 moveScores[MAX_MON_MOVES]; /*0x09*/ u8 aiAction; - /*0x0A*/ u8 fillerA[0x6]; // TODO: don't know what's here + /*0x0A*/ u8 filler[6]; /*0x10*/ u8 currentAICheck; /*0x14*/ u32 aiChecks; /*0x18*/ s16 scriptResult; @@ -370,9 +372,9 @@ struct UnknownContestStruct5 struct UnknownContestStruct4 { - u8 unk0; // sprite ID - u8 unk1; // sprite ID - u8 unk2_0:1; + u8 sliderHeartSpriteId; + u8 nextTurnSpriteId; + u8 sliderUpdating:1; u8 unk2_1:1; u8 unk2_2:1; }; @@ -454,7 +456,7 @@ extern u32 gContestRngValue; void ResetLinkContestBoolean(void); void LoadContestBgAfterMoveAnim(void); void CB2_StartContest(void); -void sub_80DA8C8(u8 partyIndex); +void CreateContestMonFromParty(u8 partyIndex); void sub_80DAB8C(u8 contestType, u8 rank); void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame); u8 GetContestEntryEligibility(struct Pokemon *pkmn); @@ -474,18 +476,6 @@ void ResetContestLinkResults(void); bool8 sub_80DEDA8(u8 a); u8 sub_80DEFA8(u8 a, u8 b); void ClearContestWinnerPicsInContestHall(void); -void sub_80DFA08(struct ContestPokemon *mon, s32 language); - -// contest link -void sub_81D9DE4(u8 taskId); -void sub_80FCF40(u8); -void sub_80FCFD0(u8); -void sub_80F8714(u8); -bool32 sub_80FC670(s16 *); -bool32 sub_80FC4F4(void *, u16); -bool8 sub_80FC55C(void); -bool8 sub_80FC530(u8); -u8 sub_80F86E0(u8 *); -void sub_80FC9F8(u8 taskId); +void StripPlayerAndMonNamesForLinkContest(struct ContestPokemon *mon, s32 language); #endif //GUARD_CONTEST_H diff --git a/include/contest_link.h b/include/contest_link.h index 4344d55ad..e52ebc426 100644 --- a/include/contest_link.h +++ b/include/contest_link.h @@ -9,5 +9,16 @@ void sub_80FC6BC(u8); void sub_80FC804(u8); void sub_80FCE48(u8); void sub_80FC894(u8); +void Task_LinkContest_CommunicateMonIdxs(u8 taskId); +void sub_81D9DE4(u8 taskId); +void sub_80FCF40(u8); +void sub_80FCFD0(u8); +void sub_80F8714(u8); +bool32 sub_80FC670(s16 *); +bool32 LinkContest_SendBlock(void *, u16); +bool8 LinkContest_GetBlockReceivedFromAllPlayers(void); +bool8 LinkContest_GetBlockReceived(u8); +u8 sub_80F86E0(u8 *); +void Task_LinkContest_CommunicateMoveSelections(u8 taskId); #endif //GUARD_CONTEST_LINK_H diff --git a/include/contest_util.h b/include/contest_util.h index c0d8df031..d0021153d 100644 --- a/include/contest_util.h +++ b/include/contest_util.h @@ -7,6 +7,5 @@ void StartContest(void); void BufferContestantMonSpecies(void); void ShowContestResults(void); void ContestLinkTransfer(u8); -void sub_80FC998(u8 taskId); #endif // GUARD_CONTEST_UTIL_H diff --git a/include/global.h b/include/global.h index abcf1d545..230a50f55 100644 --- a/include/global.h +++ b/include/global.h @@ -474,7 +474,7 @@ struct SaveBlock2 /*0x20C*/ struct BerryPickingResults berryPick; /*0x21C*/ struct RankingHall1P hallRecords1P[HALL_FACILITIES_COUNT][2][3]; // From record mixing. /*0x57C*/ struct RankingHall2P hallRecords2P[2][3]; // From record mixing. - /*0x624*/ u16 contestLinkResults[5][4]; // 4 positions for 5 categories. + /*0x624*/ u16 contestLinkResults[CONTEST_CATEGORIES_COUNT][CONTESTANT_COUNT]; /*0x64C*/ struct BattleFrontier frontier; }; // sizeof=0xF2C @@ -483,7 +483,7 @@ extern struct SaveBlock2 *gSaveBlock2Ptr; struct SecretBaseParty { u32 personality[PARTY_SIZE]; - u16 moves[PARTY_SIZE * 4]; + u16 moves[PARTY_SIZE * MAX_MON_MOVES]; u16 species[PARTY_SIZE]; u16 heldItems[PARTY_SIZE]; u8 levels[PARTY_SIZE]; diff --git a/include/graphics.h b/include/graphics.h index 8514d49bd..460572796 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4786,10 +4786,10 @@ extern const u32 gOldContestGfx[]; extern const u32 gOldContestPalette[]; extern const u32 gUnknown_08C17170[]; extern const u32 gUnknown_08C17980[]; -extern const u32 gTiles_8C19450[]; +extern const u32 gContestSliderHeart_Gfx[]; extern const u32 gContestNextTurnGfx[]; extern const u16 gContestPal[]; -extern const u32 gUnknown_08C19168[]; +extern const u32 gContestFaces_Gfx[]; extern const u32 gContestApplauseGfx[]; extern const u32 gContestJudgeGfx[]; extern const u32 gContestJudgeSymbolsGfx[]; diff --git a/src/contest.c b/src/contest.c index 314ebb381..76650da18 100644 --- a/src/contest.c +++ b/src/contest.c @@ -11,6 +11,7 @@ #include "battle.h" #include "battle_anim.h" #include "contest.h" +#include "contest_link.h" #include "data.h" #include "decompress.h" #include "graphics.h" @@ -45,56 +46,29 @@ #include "constants/rgb.h" #include "contest_ai.h" -#define APPLAUSE_METER_GFX_TAG 0xABE2 - -// An index into a palette where the text color for each contestant is stored. -// Contestant 0 will use palette color 10, contestant 1 will use color 11, etc. -#define CONTESTANT_TEXT_COLOR_START 10 - -enum -{ -// The "{Pokemon Name} / {Trainer Name}" windows. - CONTEST_WINDOW_CONTESTANT0_NAME, - CONTEST_WINDOW_CONTESTANT1_NAME, - CONTEST_WINDOW_CONTESTANT2_NAME, - CONTEST_WINDOW_CONTESTANT3_NAME, - CONTEST_WINDOW_GENERAL_TEXT, - // The available moves, from top to bottom - CONTEST_WINDOW_MOVE0, - CONTEST_WINDOW_MOVE1, - CONTEST_WINDOW_MOVE2, - CONTEST_WINDOW_MOVE3, - // The small "/" character between the move category and the - // appeal/jam display - CONTEST_WINDOW_SLASH, - CONTEST_WINDOW_MOVE_DESCRIPTION -}; - -#define MOVE_WINDOWS_START CONTEST_WINDOW_MOVE0 - // This file's functions. -static void sub_80D782C(void); -static void sub_80D7C7C(u8 taskId); -static void sub_80D7CB4(u8 taskId); -static void sub_80D7DAC(u8 taskId); -static void sub_80D7DC8(u8 taskId); +static void LoadContestPalettes(void); +static void Task_StartContestWaitFade(u8 taskId); +static void Task_TryStartLinkContest(u8 taskId); +static void Task_CommunicateMonIdxs(u8 taskId); +static void Task_EndCommunicateMonIdxs(u8 taskId); static void sub_80D7DE8(u8 taskId); static bool8 SetupContestGraphics(u8 *stateVar); static void sub_80D80C8(u8 taskId); static void sub_80D8108(u8 taskId); -static void vblank_cb_battle(void); +static void VBlankCB_Contest(void); static void CB2_ContestMain(void); -static void sub_80D833C(u8 taskId); -static void sub_80D8424(u8 taskId); -static void sub_80D8610(u8 taskId); -static void sub_80D8490(u8 taskId); -static void sub_80D880C(s8); -static void sub_80D883C(s8); -static void sub_80D8894(u8 taskId); -static void sub_80D892C(u8 taskId); -static void sub_80D895C(u8 taskId); -static void sub_80D8A04(u8 taskId); -static void sub_80D8A50(u8 taskId); +static void Task_DisplayAppealNumberText(u8 taskId); +static void Task_TryShowMoveSelectScreen(u8 taskId); +static void Task_ShowMoveSelectScreen(u8 taskId); +static void Task_HandleMoveSelectInput(u8 taskId); +static void DrawMoveSelectArrow(s8); +static void EraseMoveSelectArrow(s8); +static void Task_SelectMove(u8 taskId); +static void Task_EndCommunicateMoveSelections(u8 taskId); +static void Task_HideMoveSelectScreen(u8 taskId); +static void Task_HideApplauseMeterForAppealStart(u8 taskId); +static void Task_WaitHideApplauseMeterForAppealStart(u8 taskId); static void sub_80D8A88(u8 taskId); static void sub_80D8B38(u8 taskId); static void sub_80DA110(u8); @@ -135,9 +109,9 @@ static u16 GetChosenMove(u8); static void GetAllChosenMoves(void); static void ContestPrintLinkStandby(void); static void FillContestantWindowBgs(void); -static void sub_80DC2BC(void); -static void sub_80DC490(bool8); -static void sub_80DC4F0(void); +static void CreateSliderHeartSprites(void); +static void SetBottomSliderHeartsInvisibility(bool8); +static void CreateNextTurnSprites(void); static void CreateApplauseMeterSprite(void); static void sub_80DC5E8(void); static void sub_80DC7EC(void); @@ -149,7 +123,7 @@ static void TryMoveApplauseMeterOffscreen(void); static void sub_80DE224(void); static void sub_80DE350(void); static void sub_80DE424(u8); -static void sub_80DE69C(u8); +static void AnimateSliderHearts(u8); static void sub_80DEA20(void); static void Contest_StartTextPrinter(const u8 *, u32); static void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, s16); @@ -180,15 +154,15 @@ static void sub_80DDE0C(void); static void UpdateApplauseMeter(void); static void RankContestants(void); static void sub_80DBA18(void); -static void sub_80DC3AC(void); -static bool8 sub_80DC3C4(void); +static void UpdateHeartSliders(void); +static bool8 SlidersDoneUpdating(void); static void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8); static void Contest_PrintTextToBg0WindowStd(u32, const u8 *); static s16 GetContestantRound2Points(u8); static void DetermineFinalStandings(void); static bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *); static void sub_80DC0F4(u8); -static void sub_80DC408(struct Sprite *); +static void SpriteCB_UpdateHeartSlider(struct Sprite *); static void sub_80DC728(u8); static void sub_80DC6A4(u8); static void sub_80DC8D0(u8); @@ -208,16 +182,58 @@ static void sub_80DE464(u8); static void sub_80DE4A8(u8); static void sub_80DE5F4(u8); static void sub_80DE65C(u8); -static void sub_80DE794(u8); +static void Task_WaitForSliderHeartAnim(u8); static void sub_80DEA5C(void); static void sub_80DF250(void); static void sub_80DF4F8(void); static void sub_80DF080(u8); static void ContestDebugPrintBitStrings(void); -static void sub_80DF9D4(u8 *); -static void sub_80DF9E0(u8 *, s32); +static void StripPlayerNameForLinkContest(u8 *); +static void StripMonNameForLinkContest(u8 *, s32); static void SwapMoveDescAndContestTilemaps(void); +// An index into a palette where the text color for each contestant is stored. +// Contestant 0 will use palette color 10, contestant 1 will use color 11, etc. +#define CONTESTANT_TEXT_COLOR_START 10 + +enum +{ +// The "{Pokemon Name} / {Trainer Name}" windows. + CONTEST_WINDOW_CONTESTANT0_NAME, + CONTEST_WINDOW_CONTESTANT1_NAME, + CONTEST_WINDOW_CONTESTANT2_NAME, + CONTEST_WINDOW_CONTESTANT3_NAME, + CONTEST_WINDOW_GENERAL_TEXT, + // The available moves, from top to bottom + CONTEST_WINDOW_MOVE0, + CONTEST_WINDOW_MOVE1, + CONTEST_WINDOW_MOVE2, + CONTEST_WINDOW_MOVE3, + // The small "/" character between the move category and the + // appeal/jam display + CONTEST_WINDOW_SLASH, + CONTEST_WINDOW_MOVE_DESCRIPTION +}; + +#define MOVE_WINDOWS_START CONTEST_WINDOW_MOVE0 + +#define TAG_FACES_GFX 0xABE1 +#define TAG_APPLAUSE_METER 0xABE2 + +#define TAG_SLIDER_HEART 0x4E20 + +#define TAG_NEXT_TURN_PAL 0x4E22 +#define TAG_NEXT_TURN_1_GFX 0x4E22 +#define TAG_NEXT_TURN_2_GFX 0x4E23 +#define TAG_NEXT_TURN_3_GFX 0x4E24 +#define TAG_NEXT_TURN_4_GFX 0x4E25 + +enum { + SLIDER_HEART_ANIM_NORMAL, + SLIDER_HEART_ANIM_DISAPPEAR, + SLIDER_HEART_ANIM_APPEAR, +}; + // EWRAM vars. EWRAM_DATA struct ContestPokemon gContestMons[CONTESTANT_COUNT] = {0}; EWRAM_DATA s16 gContestMonConditions[CONTESTANT_COUNT] = {0}; @@ -250,24 +266,25 @@ extern const u8 gText_BDot[]; extern const u8 gText_CDot[]; extern void (*const gContestEffectFuncs[])(void); -static const u8 gUnknown_08587A6C[] = +static const u8 sSliderHeartYPositions[CONTESTANT_COUNT] = { - 0x24, 0x4C, 0x74, 0x9C + 36, 76, 116, 156 }; -static const u8 gUnknown_08587A70[] = +// The "Next Turn" sprites cover up the slider, so the y positions are the same as above +static const u8 sNextTurnSpriteYPositions[CONTESTANT_COUNT] = { - 0x24, 0x4C, 0x74, 0x9C + 36, 76, 116, 156 }; -static const struct SpriteSheet gUnknown_08587A74 = +static const struct SpriteSheet sSpriteSheet_SliderHeart = { - .data = gTiles_8C19450, + .data = gContestSliderHeart_Gfx, .size = 0x20, - .tag = 0x4E20 + .tag = TAG_SLIDER_HEART }; -static const struct OamData gOamData_8587A7C = +static const struct OamData sOam_SliderHeart = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -284,75 +301,75 @@ static const struct OamData gOamData_8587A7C = .affineParam = 0 }; -static const union AffineAnimCmd gSpriteAffineAnim_8587A84[] = +static const union AffineAnimCmd sAffineAnim_SliderHeart_Normal[] = { - AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gSpriteAffineAnim_8587A94[] = +static const union AffineAnimCmd sAffineAnim_SliderHeart_SpinDisappear[] = { - AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), - AFFINEANIMCMD_FRAME(0xFFF6, 0xFFF6, -20, 20), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_FRAME(-10, -10, -20, 20), AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_8587AAC[] = +static const union AffineAnimCmd sAffineAnim_SliderHeart_SpinAppear[] = { - AFFINEANIMCMD_FRAME(0x38, 0x38, 0, 0), + AFFINEANIMCMD_FRAME(56, 56, 0, 0), AFFINEANIMCMD_FRAME(10, 10, 20, 20), AFFINEANIMCMD_END }; -static const union AffineAnimCmd* const gSpriteAffineAnimTable_8587AC4[] = +static const union AffineAnimCmd* const sAffineAnims_SliderHeart[] = { - gSpriteAffineAnim_8587A84, - gSpriteAffineAnim_8587A94, - gSpriteAffineAnim_8587AAC + [SLIDER_HEART_ANIM_NORMAL] = sAffineAnim_SliderHeart_Normal, + [SLIDER_HEART_ANIM_DISAPPEAR] = sAffineAnim_SliderHeart_SpinDisappear, + [SLIDER_HEART_ANIM_APPEAR] = sAffineAnim_SliderHeart_SpinAppear }; -static const struct SpriteTemplate gSpriteTemplate_8587AD0 = +static const struct SpriteTemplate sSpriteTemplate_SliderHeart = { - .tileTag = 0x4E20, + .tileTag = TAG_SLIDER_HEART, .paletteTag = 0xABE0, - .oam = &gOamData_8587A7C, + .oam = &sOam_SliderHeart, .anims = gDummySpriteAnimTable, .images = NULL, - .affineAnims = gSpriteAffineAnimTable_8587AC4, + .affineAnims = sAffineAnims_SliderHeart, .callback = SpriteCallbackDummy }; -static const struct CompressedSpriteSheet gUnknown_08587AE8[] = +static const struct CompressedSpriteSheet sSpriteSheet_NextTurn[CONTESTANT_COUNT] = { { .data = gContestNextTurnGfx, .size = 0x100, - .tag = 0x4E22 + .tag = TAG_NEXT_TURN_1_GFX }, { .data = gContestNextTurnGfx, .size = 0x100, - .tag = 0x4E23 + .tag = TAG_NEXT_TURN_2_GFX }, { .data = gContestNextTurnGfx, .size = 0x100, - .tag = 0x4E24 + .tag = TAG_NEXT_TURN_3_GFX }, { .data = gContestNextTurnGfx, .size = 0x100, - .tag = 0x4E25 + .tag = TAG_NEXT_TURN_4_GFX } }; -static const struct SpritePalette gUnknown_08587B08 = +static const struct SpritePalette sSpritePalette_NextTurn = { .data = gContestPal, - .tag = 0x4E22 + .tag = TAG_NEXT_TURN_PAL }; -static const struct OamData gOamData_8587B10 = +static const struct OamData sOam_NextTurn = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -369,39 +386,39 @@ static const struct OamData gOamData_8587B10 = .affineParam = 0 }; -static const struct SpriteTemplate gSpriteTemplate_8587B18[] = +static const struct SpriteTemplate sSpriteTemplates_NextTurn[CONTESTANT_COUNT] = { { - .tileTag = 0x4E22, - .paletteTag = 0x4E22, - .oam = &gOamData_8587B10, + .tileTag = TAG_NEXT_TURN_1_GFX, + .paletteTag = TAG_NEXT_TURN_PAL, + .oam = &sOam_NextTurn, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy, }, { - .tileTag = 0x4E23, - .paletteTag = 0x4E22, - .oam = &gOamData_8587B10, + .tileTag = TAG_NEXT_TURN_2_GFX, + .paletteTag = TAG_NEXT_TURN_PAL, + .oam = &sOam_NextTurn, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy, }, { - .tileTag = 0x4E24, - .paletteTag = 0x4E22, - .oam = &gOamData_8587B10, + .tileTag = TAG_NEXT_TURN_3_GFX, + .paletteTag = TAG_NEXT_TURN_PAL, + .oam = &sOam_NextTurn, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy, }, { - .tileTag = 0x4E25, - .paletteTag = 0x4E22, - .oam = &gOamData_8587B10, + .tileTag = TAG_NEXT_TURN_4_GFX, + .paletteTag = TAG_NEXT_TURN_PAL, + .oam = &sOam_NextTurn, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -409,7 +426,7 @@ static const struct SpriteTemplate gSpriteTemplate_8587B18[] = } }; -const struct Subsprite gSubspriteTable_8587B78[] = +static const struct Subsprite sSubsprites_NextTurn[] = { { .x = -28, @@ -429,19 +446,19 @@ const struct Subsprite gSubspriteTable_8587B78[] = } }; -const struct SubspriteTable gSubspriteTables_8587B80[] = +static const struct SubspriteTable sSubspriteTable_NextTurn[] = { { - .subspriteCount = 2, - .subsprites = gSubspriteTable_8587B78 + .subspriteCount = ARRAY_COUNT(sSubsprites_NextTurn), + .subsprites = sSubsprites_NextTurn } }; const struct CompressedSpriteSheet gUnknown_08587B88 = { - .data = gUnknown_08C19168, + .data = gContestFaces_Gfx, .size = 0x180, - .tag = 0xABE1 + .tag = TAG_FACES_GFX }; const struct OamData gOamData_8587B90 = @@ -460,7 +477,7 @@ const struct OamData gOamData_8587B90 = const struct SpriteTemplate gSpriteTemplate_8587B98 = { - .tileTag = 0xABE1, + .tileTag = TAG_FACES_GFX, .paletteTag = 0xABE0, .oam = &gOamData_8587B90, .anims = gDummySpriteAnimTable, @@ -473,13 +490,13 @@ static const struct CompressedSpriteSheet sApplauseMeterSpriteSheet = { .data = gContestApplauseGfx, .size = 0x400, - .tag = APPLAUSE_METER_GFX_TAG + .tag = TAG_APPLAUSE_METER }; static const struct SpritePalette sApplauseMeterPalette = { .data = gContestPal, - .tag = APPLAUSE_METER_GFX_TAG + .tag = TAG_APPLAUSE_METER }; static const struct OamData sApplauseMeterOamData = @@ -498,8 +515,8 @@ static const struct OamData sApplauseMeterOamData = static const struct SpriteTemplate sApplauseMeterSpriteTemplate = { - .tileTag = APPLAUSE_METER_GFX_TAG, - .paletteTag = APPLAUSE_METER_GFX_TAG, + .tileTag = TAG_APPLAUSE_METER, + .paletteTag = TAG_APPLAUSE_METER, .oam = &sApplauseMeterOamData, .anims = gDummySpriteAnimTable, .images = NULL, @@ -887,7 +904,7 @@ void LoadContestBgAfterMoveAnim(void) CopyToBgTilemapBuffer(3, gOldContestGfx, 0, 0); CopyBgTilemapBufferToVram(3); LoadCompressedPalette(gOldContestPalette, 0, 0x200); - sub_80D782C(); + LoadContestPalettes(); for (i = 0; i < CONTESTANT_COUNT; i++) { u32 contestantWindowId = MOVE_WINDOWS_START + i; @@ -923,7 +940,7 @@ static void InitContestWindows(void) } } -static void sub_80D782C(void) +static void LoadContestPalettes(void) { s32 i; @@ -1060,8 +1077,8 @@ void CB2_StartContest(void) gBattle_BG1_Y = 0; BeginFastPaletteFade(2); gPaletteFade.bufferTransferDisabled = FALSE; - SetVBlankCallback(vblank_cb_battle); - eContest.mainTaskId = CreateTask(sub_80D7C7C, 10); + SetVBlankCallback(VBlankCB_Contest); + eContest.mainTaskId = CreateTask(Task_StartContestWaitFade, 10); SetMainCallback2(CB2_ContestMain); if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) { @@ -1072,16 +1089,16 @@ void CB2_StartContest(void) } } -static void sub_80D7C7C(u8 taskId) +static void Task_StartContestWaitFade(u8 taskId) { if (!gPaletteFade.active) { gTasks[taskId].data[0] = 0; - gTasks[taskId].func = sub_80D7CB4; + gTasks[taskId].func = Task_TryStartLinkContest; } } -static void sub_80D7CB4(u8 taskId) +static void Task_TryStartLinkContest(u8 taskId) { if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { @@ -1113,7 +1130,7 @@ static void sub_80D7CB4(u8 taskId) gPaletteFade.bufferTransferDisabled = FALSE; if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)) ContestPrintLinkStandby(); - CreateTask(sub_80D7DAC, 0); + CreateTask(Task_CommunicateMonIdxs, 0); gTasks[taskId].data[0] = 0; gTasks[taskId].func = TaskDummy1; } @@ -1124,12 +1141,12 @@ static void sub_80D7CB4(u8 taskId) } } -static void sub_80D7DAC(u8 taskId) +static void Task_CommunicateMonIdxs(u8 taskId) { - SetTaskFuncWithFollowupFunc(taskId, sub_80FC998, sub_80D7DC8); + SetTaskFuncWithFollowupFunc(taskId, Task_LinkContest_CommunicateMonIdxs, Task_EndCommunicateMonIdxs); } -static void sub_80D7DC8(u8 taskId) +static void Task_EndCommunicateMonIdxs(u8 taskId) { gTasks[taskId].data[0] = 1; gTasks[taskId].func = sub_80D7DE8; @@ -1137,6 +1154,7 @@ static void sub_80D7DC8(u8 taskId) static void sub_80D7DE8(u8 taskId) { + // data[0] always 1 here gTasks[taskId].data[0]--; if (gTasks[taskId].data[0] <= 0) { @@ -1184,15 +1202,15 @@ static bool8 SetupContestGraphics(u8 *stateVar) CpuCopy32(tempPalette2, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); CpuCopy32(tempPalette1, gPlttBufferUnfaded + (MOVE_WINDOWS_START + gContestPlayerMonIndex) * 16, 16 * sizeof(u16)); DmaCopy32Defvars(3, gPlttBufferUnfaded, eUnknownHeap1A004.cachedWindowPalettes, sizeof(eUnknownHeap1A004.cachedWindowPalettes)); - sub_80D782C(); + LoadContestPalettes(); break; case 6: DrawContestantWindows(); FillContestantWindowBgs(); SwapMoveDescAndContestTilemaps(); eContest.unk19216 = sub_80DB120(); - sub_80DC2BC(); - sub_80DC4F0(); + CreateSliderHeartSprites(); + CreateNextTurnSprites(); CreateApplauseMeterSprite(); sub_80DC5E8(); sub_80DC7EC(); @@ -1272,7 +1290,7 @@ static void sub_80D8108(u8 taskId) break; gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; - gTasks[taskId].func = sub_80D833C; + gTasks[taskId].func = Task_DisplayAppealNumberText; break; } } @@ -1294,7 +1312,7 @@ static void CB2_ContestMain(void) sContestBgCopyFlags = 0; } -static void vblank_cb_battle(void) +static void VBlankCB_Contest(void) { SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_X); SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_Y); @@ -1314,7 +1332,7 @@ static void vblank_cb_battle(void) ScanlineEffect_InitHBlankDmaTransfer(); } -static void sub_80D833C(u8 taskId) +static void Task_DisplayAppealNumberText(u8 taskId) { if (gTasks[taskId].data[0] == 0) { @@ -1337,67 +1355,69 @@ static void sub_80D833C(u8 taskId) if (!Contest_RunTextPrinters()) { gTasks[taskId].data[0] = 0; - gTasks[taskId].func = sub_80D8424; + gTasks[taskId].func = Task_TryShowMoveSelectScreen; } } } -static void sub_80D8424(u8 taskId) +static void Task_TryShowMoveSelectScreen(u8 taskId) { + // Wait for button press to show move select screen if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys == B_BUTTON)) { PlaySE(SE_SELECT); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) { - sub_80DC490(TRUE); - gTasks[taskId].func = sub_80D8490; + SetBottomSliderHeartsInvisibility(TRUE); + gTasks[taskId].func = Task_ShowMoveSelectScreen; } else { - gTasks[taskId].func = sub_80D8894; + // Skip move selection (selected move will be MOVE_NONE) + gTasks[taskId].func = Task_SelectMove; } } } -static void sub_80D8490(u8 taskId) +static void Task_ShowMoveSelectScreen(u8 taskId) { u8 i; - u8 sp8[32]; + u8 moveName[32]; - gBattle_BG0_Y = 0xA0; - gBattle_BG2_Y = 0xA0; + gBattle_BG0_Y = 160; + gBattle_BG2_Y = 160; for (i = 0; i < MAX_MON_MOVES; i++) { u16 move = gContestMons[gContestPlayerMonIndex].moves[i]; - u8 *r5 = sp8; + u8 *moveNameBuffer = moveName; if (eContestantStatus[gContestPlayerMonIndex].prevMove != MOVE_NONE && sub_80DE1E8(gContestPlayerMonIndex) && AreMovesContestCombo(eContestantStatus[gContestPlayerMonIndex].prevMove, move) != 0 && eContestantStatus[gContestPlayerMonIndex].hasJudgesAttention) { - r5 = StringCopy(sp8, gText_ColorLightShadowDarkGrey); + moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGrey); } - else if (move != 0 + else if (move != MOVE_NONE && eContestantStatus[gContestPlayerMonIndex].prevMove == move && gContestMoves[move].effect != CONTEST_EFFECT_REPETITION_NOT_BORING) { // Gray the text because it is a repeated move - r5 = StringCopy(sp8, gText_ColorBlue); + moveNameBuffer = StringCopy(moveName, gText_ColorBlue); } - r5 = StringCopy(r5, gMoveNames[move]); + moveNameBuffer = StringCopy(moveNameBuffer, gMoveNames[move]); FillWindowPixelBuffer(i + MOVE_WINDOWS_START, PIXEL_FILL(0)); - Contest_PrintTextToBg0WindowAt(i + MOVE_WINDOWS_START, sp8, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(i + MOVE_WINDOWS_START, moveName, 5, 1, 7); } - sub_80D880C(eContest.playerMoveChoice); + DrawMoveSelectArrow(eContest.playerMoveChoice); PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); - gTasks[taskId].func = sub_80D8610; + gTasks[taskId].func = Task_HandleMoveSelectInput; } -static void sub_80D8610(u8 taskId) +static void Task_HandleMoveSelectInput(u8 taskId) { u8 numMoves = 0; s32 i; @@ -1411,15 +1431,16 @@ static void sub_80D8610(u8 taskId) if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - gTasks[taskId].func = sub_80D8894; + gTasks[taskId].func = Task_SelectMove; } else { switch (gMain.newAndRepeatedKeys) { case B_BUTTON: + // Cancel move selection PlaySE(SE_SELECT); - sub_80DC490(FALSE); + SetBottomSliderHeartsInvisibility(FALSE); ConvertIntToDecimalStringN(gStringVar1, eContest.turnNumber + 1, STR_CONV_MODE_LEFT_ALIGN, 1); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) StringCopy(gDisplayedStringBattle, gText_AppealNumWhichMoveWillBePlayed); @@ -1430,29 +1451,29 @@ static void sub_80D8610(u8 taskId) Contest_StartTextPrinter(gStringVar4, 0); gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; - gTasks[taskId].func = sub_80D8424; + gTasks[taskId].func = Task_TryShowMoveSelectScreen; break; case DPAD_LEFT: case DPAD_RIGHT: break; case DPAD_UP: - sub_80D883C(eContest.playerMoveChoice); + EraseMoveSelectArrow(eContest.playerMoveChoice); if (eContest.playerMoveChoice == 0) eContest.playerMoveChoice = numMoves - 1; else eContest.playerMoveChoice--; - sub_80D880C(eContest.playerMoveChoice); + DrawMoveSelectArrow(eContest.playerMoveChoice); PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); if (numMoves > 1) PlaySE(SE_SELECT); break; case DPAD_DOWN: - sub_80D883C(eContest.playerMoveChoice); + EraseMoveSelectArrow(eContest.playerMoveChoice); if (eContest.playerMoveChoice == numMoves - 1) eContest.playerMoveChoice = 0; else eContest.playerMoveChoice++; - sub_80D880C(eContest.playerMoveChoice); + DrawMoveSelectArrow(eContest.playerMoveChoice); PrintContestMoveDescription(gContestMons[gContestPlayerMonIndex].moves[eContest.playerMoveChoice]); if (numMoves > 1) PlaySE(SE_SELECT); @@ -1461,18 +1482,18 @@ static void sub_80D8610(u8 taskId) } } -static void sub_80D880C(s8 a0) +static void DrawMoveSelectArrow(s8 moveIndex) { - ContestBG_FillBoxWithIncrementingTile(2, 55, 0, 31 + a0 * 2, 2, 2, 17, 1); + ContestBG_FillBoxWithIncrementingTile(2, 55, 0, 31 + moveIndex * 2, 2, 2, 17, 1); } -static void sub_80D883C(s8 a0) +static void EraseMoveSelectArrow(s8 moveIndex) { - ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 31 + a0 * 2, 2, 1, 17, 1); - ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 32 + a0 * 2, 2, 1, 17, 1); + ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 31 + moveIndex * 2, 2, 1, 17, 1); + ContestBG_FillBoxWithIncrementingTile(2, 11, 0, 32 + moveIndex * 2, 2, 1, 17, 1); } -static void sub_80D8894(u8 taskId) +static void Task_SelectMove(u8 taskId) { if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { @@ -1480,33 +1501,33 @@ static void sub_80D8894(u8 taskId) u8 taskId2; eContestantStatus[gContestPlayerMonIndex].currMove = move; - taskId2 = CreateTask(sub_80FC9F8, 0); - SetTaskFuncWithFollowupFunc(taskId2, sub_80FC9F8, sub_80D892C); + taskId2 = CreateTask(Task_LinkContest_CommunicateMoveSelections, 0); + SetTaskFuncWithFollowupFunc(taskId2, Task_LinkContest_CommunicateMoveSelections, Task_EndCommunicateMoveSelections); gTasks[taskId].func = TaskDummy1; ContestPrintLinkStandby(); - sub_80DC490(FALSE); + SetBottomSliderHeartsInvisibility(FALSE); } else { GetAllChosenMoves(); - gTasks[taskId].func = sub_80D895C; + gTasks[taskId].func = Task_HideMoveSelectScreen; } } -static void sub_80D892C(u8 taskId) +static void Task_EndCommunicateMoveSelections(u8 taskId) { DestroyTask(taskId); - gTasks[eContest.mainTaskId].func = sub_80D895C; + gTasks[eContest.mainTaskId].func = Task_HideMoveSelectScreen; } -static void sub_80D895C(u8 taskId) +static void Task_HideMoveSelectScreen(u8 taskId) { s32 i; ContestClearGeneralTextWindow(); gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; - sub_80DC490(FALSE); + SetBottomSliderHeartsInvisibility(FALSE); for (i = 0; i < CONTESTANT_COUNT; i++) { @@ -1520,10 +1541,10 @@ static void sub_80D895C(u8 taskId) LoadPalette(eUnknownHeap1A004.unk18204, 0, PLTT_BUFFER_SIZE * 2); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; - gTasks[taskId].func = sub_80D8A04; + gTasks[taskId].func = Task_HideApplauseMeterForAppealStart; } -static void sub_80D8A04(u8 taskId) +static void Task_HideApplauseMeterForAppealStart(u8 taskId) { if (++gTasks[taskId].data[0] > 2) { @@ -1531,15 +1552,15 @@ static void sub_80D8A04(u8 taskId) if (++gTasks[taskId].data[1] == 2) { TryMoveApplauseMeterOffscreen(); - sub_80DE69C(1); - gTasks[taskId].func = sub_80D8A50; + AnimateSliderHearts(SLIDER_HEART_ANIM_DISAPPEAR); + gTasks[taskId].func = Task_WaitHideApplauseMeterForAppealStart; } } } -static void sub_80D8A50(u8 taskId) +static void Task_WaitHideApplauseMeterForAppealStart(u8 taskId) { - if (!eContest.applauseMeterIsMoving && !eContest.unk1920B_1) + if (!eContest.applauseMeterIsMoving && !eContest.sliderHeartsAnimating) gTasks[taskId].func = sub_80D8A88; } @@ -1984,7 +2005,7 @@ static void sub_80D8B38(u8 taskId) } return; case 17: - if (eContestantStatus[r6].disappointedRepeat) + if (eContestantStatus[r6].repeatedMove) { ContestClearGeneralTextWindow(); StringCopy(gStringVar1, gContestMons[r6].nickname); @@ -2039,7 +2060,7 @@ static void sub_80D8B38(u8 taskId) } if (r3 > 0) { - if (eContestantStatus[r6].disappointedRepeat) + if (eContestantStatus[r6].repeatedMove) r3 = 0; } ContestClearGeneralTextWindow(); @@ -2354,13 +2375,13 @@ static void sub_80DA28C(u8 taskId) case 0: if (++gTasks[taskId].data[1] > 20) { - sub_80DE69C(2); + AnimateSliderHearts(SLIDER_HEART_ANIM_APPEAR); gTasks[taskId].data[1] = 0; gTasks[taskId].data[0]++; } break; case 1: - if (!eContest.unk1920B_1) + if (!eContest.sliderHeartsAnimating) { if (++gTasks[taskId].data[1] > 20) { @@ -2370,7 +2391,7 @@ static void sub_80DA28C(u8 taskId) } break; case 2: - sub_80DC3AC(); + UpdateHeartSliders(); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; gTasks[taskId].func = sub_80DA31C; @@ -2380,7 +2401,7 @@ static void sub_80DA28C(u8 taskId) static void sub_80DA31C(u8 taskId) { - if (sub_80DC3C4()) + if (SlidersDoneUpdating()) gTasks[taskId].func = sub_80DA348; } @@ -2430,14 +2451,14 @@ static void sub_80DA464(u8 taskId) if (gTasks[taskId].data[0]++ > 29) { gTasks[taskId].data[0] = 0; - sub_80DC3AC(); + UpdateHeartSliders(); gTasks[taskId].func = sub_80DA49C; } } static void sub_80DA49C(u8 taskId) { - if (sub_80DC3C4()) + if (SlidersDoneUpdating()) { gTasks[taskId].data[0] = 0; gTasks[taskId].func = sub_80DA4CC; @@ -2479,7 +2500,7 @@ static void sub_80DA51C(u8 taskId) static void sub_80DA5B4(u8 taskId) { if (!eContest.applauseMeterIsMoving) - gTasks[taskId].func = sub_80D833C; + gTasks[taskId].func = Task_DisplayAppealNumberText; } static void sub_80DA5E8(u8 taskId) @@ -2556,7 +2577,7 @@ static void sub_80DA7A0(u8 taskId) SetTaskFuncWithFollowupFunc(taskId2, sub_80FCACC, sub_80DA7EC); gTasks[taskId].func = TaskDummy1; ContestPrintLinkStandby(); - sub_80DC490(FALSE); + SetBottomSliderHeartsInvisibility(FALSE); } static void sub_80DA7EC(u8 taskId) @@ -2588,7 +2609,7 @@ static void sub_80DA874(void) static void TryPutPlayerLast(void) { if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)) - gContestPlayerMonIndex = 3; + gContestPlayerMonIndex = CONTESTANT_COUNT - 1; } static bool8 sub_80DA8A4(void) @@ -2598,7 +2619,7 @@ static bool8 sub_80DA8A4(void) return FALSE; } -void sub_80DA8C8(u8 partyIndex) +void CreateContestMonFromParty(u8 partyIndex) { u8 name[20]; u16 heldItem; @@ -2611,7 +2632,7 @@ void sub_80DA8C8(u8 partyIndex) StringCopy(name, gSaveBlock2Ptr->playerName); if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { - sub_80DF9D4(name); + StripPlayerNameForLinkContest(name); } memcpy(gContestMons[gContestPlayerMonIndex].trainerName, name, 8); if (gSaveBlock2Ptr->playerGender == MALE) @@ -2619,13 +2640,13 @@ void sub_80DA8C8(u8 partyIndex) else gContestMons[gContestPlayerMonIndex].trainerGfxId = OBJ_EVENT_GFX_LINK_MAY; gContestMons[gContestPlayerMonIndex].aiChecks = 0; - gContestMons[gContestPlayerMonIndex].unk2C[0] = 0; + gContestMons[gContestPlayerMonIndex].highestRank = 0; gContestMons[gContestPlayerMonIndex].species = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPECIES); GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, name); StringGetEnd10(name); if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { - sub_80DF9E0(name, GetMonData(&gPlayerParty[partyIndex], MON_DATA_LANGUAGE)); + StripMonNameForLinkContest(name, GetMonData(&gPlayerParty[partyIndex], MON_DATA_LANGUAGE)); } memcpy(gContestMons[gContestPlayerMonIndex].nickname, name, POKEMON_NAME_LENGTH + 1); StringCopy(gContestMons[gContestPlayerMonIndex].nickname, name); @@ -2730,7 +2751,7 @@ void sub_80DAB8C(u8 contestType, u8 rank) opponentsCount--; } - sub_80DA8C8(gContestMonPartyIndex); + CreateContestMonFromParty(gContestMonPartyIndex); } void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame) @@ -2770,8 +2791,8 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame) u16 rnd = GetContestRand() % opponentsCount; gContestMons[gNumLinkContestPlayers + i] = gContestOpponents[opponents[rnd]]; - sub_80DF9D4(gContestMons[gNumLinkContestPlayers + i].trainerName); - sub_80DF9E0(gContestMons[gNumLinkContestPlayers + i].nickname, GAME_LANGUAGE); + StripPlayerNameForLinkContest(gContestMons[gNumLinkContestPlayers + i].trainerName); + StripMonNameForLinkContest(gContestMons[gNumLinkContestPlayers + i].nickname, GAME_LANGUAGE); for (j = rnd; opponents[j] != 0xFF; j++) opponents[j] = opponents[j + 1]; opponentsCount--; @@ -3167,7 +3188,7 @@ static bool8 sub_80DB798(u8 a) u16 r8 = 0; u8 r7 = gContestantTurnOrder[a] * 5 + 2; - if (eContestantStatus[a].resistant != 0 || eContestantStatus[a].immune != 0 || eContestantStatus[a].jamSafetyCount != 0 || eContestantStatus[a].jamReduction != 0) + if (eContestantStatus[a].resistant || eContestantStatus[a].immune || eContestantStatus[a].jamSafetyCount != 0 || eContestantStatus[a].jamReduction != 0) r8 = sub_80DB748(0); else if (eContestantStatus[a].nervous) r8 = sub_80DB748(1); @@ -3205,7 +3226,7 @@ static void ContestClearGeneralTextWindow(void) static u16 GetChosenMove(u8 contestant) { if (Contest_IsMonsTurnDisabled(contestant)) - return 0; + return MOVE_NONE; if (contestant == gContestPlayerMonIndex) { return gContestMons[contestant].moves[eContest.playerMoveChoice]; @@ -3333,8 +3354,8 @@ static void sub_80DBAA0(void) eContestantStatus[i].effectStringId = CONTEST_STRING_NONE; eContestantStatus[i].effectStringId2 = CONTEST_STRING_NONE; eContestantStatus[i].conditionMod = 0; - eContestantStatus[i].unk15_2 = eContestantStatus[i].disappointedRepeat; - eContestantStatus[i].disappointedRepeat = FALSE; + eContestantStatus[i].repeatedPrevMove = eContestantStatus[i].repeatedMove; + eContestantStatus[i].repeatedMove = FALSE; eContestantStatus[i].turnOrderModAction = 0; eContestantStatus[i].appealTripleCondition = 0; if (eContestantStatus[i].turnSkipped) @@ -3344,8 +3365,8 @@ static void sub_80DBAA0(void) } if (eContestantStatus[i].exploded) { - eContestantStatus[i].noMoreTurns = 1; - eContestantStatus[i].exploded = 0; + eContestantStatus[i].noMoreTurns = TRUE; + eContestantStatus[i].exploded = FALSE; } eContestantStatus[i].overrideCategoryExcitementMod = 0; } @@ -3634,56 +3655,60 @@ static void sub_80DC0F4(u8 taskId) } } -static void sub_80DC2BC(void) +static void CreateSliderHeartSprites(void) { s32 i; - LoadSpriteSheet(&gUnknown_08587A74); + LoadSpriteSheet(&sSpriteSheet_SliderHeart); for (i = 0; i < CONTESTANT_COUNT; i++) { - u8 y = gUnknown_08587A6C[gContestantTurnOrder[i]]; + u8 y = sSliderHeartYPositions[gContestantTurnOrder[i]]; - gContestResources->field_14[i].unk0 = CreateSprite(&gSpriteTemplate_8587AD0, 180, y, 1); + gContestResources->field_14[i].sliderHeartSpriteId = CreateSprite(&sSpriteTemplate_SliderHeart, 180, y, 1); } } -static void sub_80DC308(u8 contestant) +#define sContestant data[0] +#define sTargetX data[1] +#define sMoveX data[2] + +static void UpdateHeartSlider(u8 contestant) { u8 spriteId; - s16 r5; + s16 slideTarget; - gContestResources->field_14[contestant].unk2_0 = 1; - spriteId = gContestResources->field_14[contestant].unk0; - r5 = eContestantStatus[contestant].pointTotal / 10 * 2; - if (r5 > 56) - r5 = 56; - else if (r5 < 0) - r5 = 0; + gContestResources->field_14[contestant].sliderUpdating = TRUE; + spriteId = gContestResources->field_14[contestant].sliderHeartSpriteId; + slideTarget = eContestantStatus[contestant].pointTotal / 10 * 2; + if (slideTarget > 56) + slideTarget = 56; + else if (slideTarget < 0) + slideTarget = 0; gSprites[spriteId].invisible = FALSE; - gSprites[spriteId].data[0] = contestant; - gSprites[spriteId].data[1] = r5; - if (gSprites[spriteId].data[1] > gSprites[spriteId].pos2.x) - gSprites[spriteId].data[2] = 1; + gSprites[spriteId].sContestant = contestant; + gSprites[spriteId].sTargetX = slideTarget; + if (gSprites[spriteId].sTargetX > gSprites[spriteId].pos2.x) + gSprites[spriteId].sMoveX = 1; else - gSprites[spriteId].data[2] = -1; - gSprites[spriteId].callback = sub_80DC408; + gSprites[spriteId].sMoveX = -1; + gSprites[spriteId].callback = SpriteCB_UpdateHeartSlider; } -static void sub_80DC3AC(void) +static void UpdateHeartSliders(void) { s32 i; for (i = 0; i < CONTESTANT_COUNT; i++) - sub_80DC308(i); + UpdateHeartSlider(i); } -static bool8 sub_80DC3C4(void) +static bool8 SlidersDoneUpdating(void) { s32 i; for (i = 0; i < CONTESTANT_COUNT; i++) { - if (gContestResources->field_14[i].unk2_0) + if (gContestResources->field_14[i].sliderUpdating) break; } if (i == CONTESTANT_COUNT) @@ -3692,57 +3717,64 @@ static bool8 sub_80DC3C4(void) return FALSE; } -static void sub_80DC408(struct Sprite *sprite) +static void SpriteCB_UpdateHeartSlider(struct Sprite *sprite) { - if (sprite->pos2.x == sprite->data[1]) + if (sprite->pos2.x == sprite->sTargetX) { - gContestResources->field_14[sprite->data[0]].unk2_0 = 0; + gContestResources->field_14[sprite->sContestant].sliderUpdating = FALSE; sprite->callback = SpriteCallbackDummy; } else { - sprite->pos2.x += sprite->data[2]; + sprite->pos2.x += sprite->sMoveX; } } -static void sub_80DC44C(void) +#undef sContestant +#undef sTargetX +#undef sMoveX + +// Y positions change as the contestants change order +static void UpdateSliderHeartSpriteYPositions(void) { s32 i; for (i = 0; i < CONTESTANT_COUNT; i++) - gSprites[gContestResources->field_14[i].unk0].pos1.y = gUnknown_08587A6C[gContestantTurnOrder[i]]; + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].pos1.y = sSliderHeartYPositions[gContestantTurnOrder[i]]; } -static void sub_80DC490(bool8 a) +// Used to hide (or subsequently reshow) the bottom two slider hearts that get hidden by text windows by moving them offscreen +static void SetBottomSliderHeartsInvisibility(bool8 invisible) { s32 i; for (i = 0; i < CONTESTANT_COUNT; i++) { + // The contestants that go 3rd and 4th should be moved if (gContestantTurnOrder[i] > 1) { - if (!a) - gSprites[gContestResources->field_14[i].unk0].pos1.x = 180; + if (!invisible) + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].pos1.x = 180; else - gSprites[gContestResources->field_14[i].unk0].pos1.x = 256; + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].pos1.x = 256; } } } -static void sub_80DC4F0(void) +static void CreateNextTurnSprites(void) { s32 i; - LoadSpritePalette(&gUnknown_08587B08); + LoadSpritePalette(&sSpritePalette_NextTurn); for (i = 0; i < CONTESTANT_COUNT; i++) { - LoadCompressedSpriteSheet(&gUnknown_08587AE8[i]); - gContestResources->field_14[i].unk1 = CreateSprite(&gSpriteTemplate_8587B18[i], + LoadCompressedSpriteSheet(&sSpriteSheet_NextTurn[i]); + gContestResources->field_14[i].nextTurnSpriteId = CreateSprite(&sSpriteTemplates_NextTurn[i], 204, - gUnknown_08587A70[gContestantTurnOrder[i]], + sNextTurnSpriteYPositions[gContestantTurnOrder[i]], 0); - SetSubspriteTables(&gSprites[gContestResources->field_14[i].unk1], gSubspriteTables_8587B80); - gSprites[gContestResources->field_14[i].unk1].invisible = TRUE; + SetSubspriteTables(&gSprites[gContestResources->field_14[i].nextTurnSpriteId], sSubspriteTable_NextTurn); + gSprites[gContestResources->field_14[i].nextTurnSpriteId].invisible = TRUE; } } @@ -4225,7 +4257,7 @@ static void sub_80DD080(u8 contestant) eContestantStatus[contestant].moveCategory = gContestMoves[eContestantStatus[contestant].currMove].contestCategory; if (eContestantStatus[contestant].currMove == eContestantStatus[contestant].prevMove && eContestantStatus[contestant].currMove != MOVE_NONE) { - eContestantStatus[contestant].disappointedRepeat = TRUE; + eContestantStatus[contestant].repeatedMove = TRUE; eContestantStatus[contestant].moveRepeatCount++; } else @@ -4258,25 +4290,25 @@ static void sub_80DD080(u8 contestant) eContestantStatus[contestant].appeal2 += eContestantStatus[contestant].condition; eContestantStatus[contestant].unk16 = 0; - eContestantStatus[contestant].unk15_6 = 0; + eContestantStatus[contestant].unk15_6 = FALSE; if (sub_80DE1E8(contestant)) { - u8 r2 = AreMovesContestCombo(eContestantStatus[contestant].prevMove, eContestantStatus[contestant].currMove); + bool8 usedCombo = AreMovesContestCombo(eContestantStatus[contestant].prevMove, eContestantStatus[contestant].currMove); - if (r2 != 0 && eContestantStatus[contestant].hasJudgesAttention) + if (usedCombo && eContestantStatus[contestant].hasJudgesAttention) { - eContestantStatus[contestant].unk16 = r2; - eContestantStatus[contestant].unk15_6 = 1; + eContestantStatus[contestant].unk16 = usedCombo; + eContestantStatus[contestant].unk15_6 = TRUE; eContestantStatus[contestant].hasJudgesAttention = 0; eContestantStatus[contestant].unk17 = eContestantStatus[contestant].appeal1 * eContestantStatus[contestant].unk16; - eContestantStatus[contestant].unk15_3 = 1; + eContestantStatus[contestant].unk15_3 = TRUE; } else { if (gContestMoves[eContestantStatus[contestant].currMove].comboStarterId != 0) { eContestantStatus[contestant].hasJudgesAttention = 1; - eContestantStatus[contestant].unk15_6 = 1; + eContestantStatus[contestant].unk15_6 = TRUE; } else { @@ -4284,7 +4316,7 @@ static void sub_80DD080(u8 contestant) } } } - if (eContestantStatus[contestant].disappointedRepeat) + if (eContestantStatus[contestant].repeatedMove) eContestantStatus[contestant].unk18 = (eContestantStatus[contestant].moveRepeatCount + 1) * 10; if (eContestantStatus[contestant].nervous) @@ -4309,7 +4341,7 @@ static void sub_80DD080(u8 contestant) eContestResources10.unk2 = 0; } - rnd = Random() % 3; + rnd = Random() % (CONTESTANT_COUNT - 1); for (i = 0; i < CONTESTANT_COUNT; i++) { if (i != contestant) @@ -4537,7 +4569,7 @@ static u8 StartApplauseOverflowAnimation(void) u8 taskId = CreateTask(Task_ApplauseOverflowAnimation, 10); gTasks[taskId].data[1] = 1; - gTasks[taskId].data[2] = IndexOfSpritePaletteTag(APPLAUSE_METER_GFX_TAG); + gTasks[taskId].data[2] = IndexOfSpritePaletteTag(TAG_APPLAUSE_METER); return taskId; } @@ -4661,14 +4693,14 @@ static void Task_ShowAndUpdateApplauseMeter(u8 taskId) } // Unused. -void HideApplauseMeterNoAnim(void) +static void HideApplauseMeterNoAnim(void) { gSprites[eContest.applauseMeterSpriteId].pos2.x = 0; gSprites[eContest.applauseMeterSpriteId].invisible = FALSE; } // Unused. -void ShowApplauseMeterNoAnim(void) +static void ShowApplauseMeterNoAnim(void) { gSprites[eContest.applauseMeterSpriteId].invisible = TRUE; } @@ -4779,13 +4811,13 @@ static void sub_80DE008(bool8 a) { if (eContestantStatus[i].turnOrderMod != 0 && a) { - CpuCopy32(GetTurnOrderNumberGfx(i), (void *)(VRAM + 0x10000 + (gSprites[gContestResources->field_14[i].unk1].oam.tileNum + 6) * 32), 32); - gSprites[gContestResources->field_14[i].unk1].pos1.y = gUnknown_08587A70[gContestantTurnOrder[i]]; - gSprites[gContestResources->field_14[i].unk1].invisible = FALSE; + CpuCopy32(GetTurnOrderNumberGfx(i), (void *)(VRAM + 0x10000 + (gSprites[gContestResources->field_14[i].nextTurnSpriteId].oam.tileNum + 6) * 32), 32); + gSprites[gContestResources->field_14[i].nextTurnSpriteId].pos1.y = sNextTurnSpriteYPositions[gContestantTurnOrder[i]]; + gSprites[gContestResources->field_14[i].nextTurnSpriteId].invisible = FALSE; } else { - gSprites[gContestResources->field_14[i].unk1].invisible = TRUE; + gSprites[gContestResources->field_14[i].nextTurnSpriteId].invisible = TRUE; } } } @@ -4800,21 +4832,17 @@ static const u8 *GetTurnOrderNumberGfx(u8 contestant) static void sub_80DE12C(void) { - s32 r7 = 0; - u8 r10 = 2; - u8 r8 = 1; - u8 r9 = 0x11; - - for (r7 = 0; r7 < CONTESTANT_COUNT; r7++) + s32 i = 0; + for (i = 0; i < CONTESTANT_COUNT; i++) { - if (eContestResources8.unnervedPokes[r7] != 0 && !Contest_IsMonsTurnDisabled(r7)) + if (eContestResources8.unnervedPokes[i] != 0 && !Contest_IsMonsTurnDisabled(i)) { - u32 r6 = gContestantTurnOrder[r7] * 5 + 2; + u32 r6 = gContestantTurnOrder[i] * 5 + 2; u16 var = sub_80DB748(3); - ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6, r10, r8, r9, r8); + ContestBG_FillBoxWithIncrementingTile(0, var, 20, r6, 2, 1, 17, 1); var += 16; - ContestBG_FillBoxWithIncrementingTile(0, var, 0x14, r6 + 1, r10, r8, r9, r8); + ContestBG_FillBoxWithIncrementingTile(0, var, 20, r6 + 1, 2, 1, 17, 1); PlaySE(SE_C_PASI); } } @@ -4822,7 +4850,7 @@ static void sub_80DE12C(void) bool8 sub_80DE1E8(u8 contestant) { - if (eContestantStatus[contestant].disappointedRepeat || eContestantStatus[contestant].nervous) + if (eContestantStatus[contestant].repeatedMove || eContestantStatus[contestant].nervous) return FALSE; else return TRUE; @@ -4859,10 +4887,10 @@ static void sub_80DE224(void) CopyToBgTilemapBuffer(1, gUnknown_08C17980, 0, 0); Contest_SetBgCopyFlags(1); - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - gSprites[gContestResources->field_14[i].unk0].oam.priority = 1; - gSprites[gContestResources->field_14[i].unk1].oam.priority = 1; + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].oam.priority = 1; + gSprites[gContestResources->field_14[i].nextTurnSpriteId].oam.priority = 1; } } @@ -4887,8 +4915,8 @@ static void sub_80DE350(void) for (i = 0; i < CONTESTANT_COUNT; i++) { - gSprites[gContestResources->field_14[i].unk0].oam.priority = 0; - gSprites[gContestResources->field_14[i].unk1].oam.priority = 0; + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].oam.priority = 0; + gSprites[gContestResources->field_14[i].nextTurnSpriteId].oam.priority = 0; } } @@ -4927,7 +4955,7 @@ static void sub_80DE4A8(u8 taskId) sub_80DB69C(); DrawContestantWindows(); sub_80DE008(TRUE); - sub_80DC44C(); + UpdateSliderHeartSpriteYPositions(); gTasks[taskId].data[0] = 1; break; case 1: @@ -5013,45 +5041,49 @@ static void sub_80DE65C(u8 taskId) } } -static void sub_80DE69C(u8 a) +#define tAnimId data[0] + +static void AnimateSliderHearts(u8 animId) { s32 i; u8 taskId; for (i = 0; i < CONTESTANT_COUNT; i++) { - gSprites[gContestResources->field_14[i].unk0].oam.matrixNum = AllocOamMatrix(); - gSprites[gContestResources->field_14[i].unk0].oam.affineMode = ST_OAM_AFFINE_NORMAL; - StartSpriteAffineAnim(&gSprites[gContestResources->field_14[i].unk0], a); - if (a == 2) + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].oam.matrixNum = AllocOamMatrix(); + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + StartSpriteAffineAnim(&gSprites[gContestResources->field_14[i].sliderHeartSpriteId], animId); + if (animId == SLIDER_HEART_ANIM_APPEAR) { - AnimateSprite(&gSprites[gContestResources->field_14[i].unk0]); - gSprites[gContestResources->field_14[i].unk0].invisible = FALSE; + AnimateSprite(&gSprites[gContestResources->field_14[i].sliderHeartSpriteId]); + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].invisible = FALSE; } } - taskId = CreateTask(sub_80DE794, 5); - gTasks[taskId].data[0] = a; - eContest.unk1920B_1 = 1; + taskId = CreateTask(Task_WaitForSliderHeartAnim, 5); + gTasks[taskId].tAnimId = animId; + eContest.sliderHeartsAnimating = TRUE; } -static void sub_80DE794(u8 taskId) +static void Task_WaitForSliderHeartAnim(u8 taskId) { s32 i; - if (gSprites[gContestResources->field_14[0].unk0].affineAnimEnded) + if (gSprites[gContestResources->field_14[0].sliderHeartSpriteId].affineAnimEnded) { - if ((u8)gTasks[taskId].data[0] == 1) + if ((u8)gTasks[taskId].tAnimId == SLIDER_HEART_ANIM_DISAPPEAR) { for (i = 0; i < CONTESTANT_COUNT; i++) - gSprites[gContestResources->field_14[i].unk0].invisible = TRUE; + gSprites[gContestResources->field_14[i].sliderHeartSpriteId].invisible = TRUE; } for (i = 0; i < CONTESTANT_COUNT; i++) - FreeSpriteOamMatrix(&gSprites[gContestResources->field_14[i].unk0]); - eContest.unk1920B_1 = 0; + FreeSpriteOamMatrix(&gSprites[gContestResources->field_14[i].sliderHeartSpriteId]); + eContest.sliderHeartsAnimating = FALSE; DestroyTask(taskId); } } +#undef tAnimId + static u16 SanitizeMove(u16 move) { if (move >= MOVES_COUNT) @@ -5073,7 +5105,7 @@ static void sub_80DE864(u8 a) u16 species = SanitizeSpecies(gContestMons[a].species); u8 r5_2; - memset(&gContestResources->field_18->species, 0, 0x14); + memset(&gContestResources->field_18->species, 0, 20); ClearBattleAnimationVars(); for (i = 0; i < CONTESTANT_COUNT; i++) gBattleMonForms[i] = 0; @@ -5277,7 +5309,7 @@ void ResetContestLinkResults(void) s32 j; for(i = 0; i < CONTEST_CATEGORIES_COUNT; i++) - for(j = 0; j < 4; j++) + for(j = 0; j < CONTESTANT_COUNT; j++) gSaveBlock2Ptr->contestLinkResults[i][j] = 0; } @@ -5391,7 +5423,7 @@ static void sub_80DF080(u8 contestant) if (!gContestResources->field_10->excitementFrozen && gContestResources->field_10->bits_0 > 0 - && !eContestantStatus[contestant].disappointedRepeat) + && !eContestantStatus[contestant].repeatedMove) { gContestResources->field_1c[contestant].unkC |= 1; gContestResources->field_1c[contestant].unkE_2 = 1; @@ -5434,7 +5466,7 @@ static void sub_80DF080(u8 contestant) gContestResources->field_1c[contestant].unk0[eContest.turnNumber] = eContestantStatus[contestant].currMove; } - if (eContestantStatus[contestant].disappointedRepeat) + if (eContestantStatus[contestant].repeatedMove) gContestResources->field_1c[contestant].unkD |= 2; if (eContest.applauseLevel == 4 @@ -5745,14 +5777,14 @@ static void ContestDebugPrintBitStrings(void) SwapMoveDescAndContestTilemaps(); } -static u8 sub_80DF940(u8 *nickname) +static u8 GetMonNicknameLanguage(u8 *nickname) { u8 ret = GAME_LANGUAGE; if (nickname[0] == EXT_CTRL_CODE_BEGIN && nickname[1] == EXT_CTRL_CODE_JPN) return LANGUAGE_ENGLISH; - if (StringLength(nickname) < 6) + if (StringLength(nickname) < PLAYER_NAME_LENGTH - 1) { while (*nickname != EOS) { @@ -5786,7 +5818,7 @@ static u8 sub_80DF940(u8 *nickname) return ret; } -static void sub_80DF9D4(u8 *playerName) +static void StripPlayerNameForLinkContest(u8 *playerName) { u8 chr = playerName[5]; @@ -5794,7 +5826,7 @@ static void sub_80DF9D4(u8 *playerName) playerName[PLAYER_NAME_LENGTH] = chr; } -static void sub_80DF9E0(u8 *monName, s32 language) +static void StripMonNameForLinkContest(u8 *monName, s32 language) { u8 chr; @@ -5812,13 +5844,13 @@ static void sub_80DF9E0(u8 *monName, s32 language) } } -void sub_80DFA08(struct ContestPokemon *mon, s32 language) +void StripPlayerAndMonNamesForLinkContest(struct ContestPokemon *mon, s32 language) { u8 *name = mon->nickname; if (language == LANGUAGE_JAPANESE) { - ConvertInternationalString(name, sub_80DF940(name)); + ConvertInternationalString(name, GetMonNicknameLanguage(name)); } else if (name[POKEMON_NAME_LENGTH] == EXT_CTRL_CODE_BEGIN) { diff --git a/src/contest_ai.c b/src/contest_ai.c index 723c503ab..e2afb2890 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -4,6 +4,7 @@ #include "random.h" #include "contest_ai.h" #include "contest_effect.h" +#include "constants/moves.h" extern const u8 *gAIScriptPtr; extern const u8 *gContestAIChecks[]; @@ -288,7 +289,7 @@ static const ContestAICmdFunc sContestAICmdTable[] = }; static void ContestAI_DoAIProcessing(void); -static bool8 sub_81563B0(u8); +static bool8 GetContestantIdByTurn(u8); static void AIStackPushVar(const u8 *); static u8 AIStackPop(void); @@ -297,8 +298,8 @@ void ContestAI_ResetAI(u8 contestantAI) int i; memset(&eContestAI, 0, sizeof(struct ContestAIInfo)); - for (i = 0; i < 4; i++) - eContestAI.unk5[i] = 100; + for (i = 0; i < MAX_MON_MOVES; i++) + eContestAI.moveScores[i] = 100; eContestAI.contestantId = contestantAI; eContestAI.stackSize = 0; @@ -321,16 +322,18 @@ u8 ContestAI_GetActionToUse(void) while (1) { - u8 rval = Random() & 3; - u8 r2 = eContestAI.unk5[rval]; + // Randomly choose a move index. If it's the move + // with the highest (or tied highest) score, return + u8 moveIdx = Random() & (MAX_MON_MOVES - 1); // % 4 doesn't match + u8 score = eContestAI.moveScores[moveIdx]; int i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_MON_MOVES; i++) { - if (r2 < eContestAI.unk5[i]) + if (score < eContestAI.moveScores[i]) break; } - if (i == 4) - return rval; + if (i == MAX_MON_MOVES) + return moveIdx; } } @@ -345,26 +348,26 @@ static void ContestAI_DoAIProcessing(void) case CONTESTAI_SETTING_UP: gAIScriptPtr = gContestAIChecks[eContestAI.currentAICheck]; - if (gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex] == 0) - eContestAI.nextMove = 0; // don't process a move that doesn't exist. + if (gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex] == MOVE_NONE) + eContestAI.nextMove = MOVE_NONE; // don't process a move that doesn't exist. else eContestAI.nextMove = gContestMons[eContestAI.contestantId].moves[eContestAI.nextMoveIndex]; eContestAI.aiState++; break; case CONTESTAI_PROCESSING: - if (eContestAI.nextMove != 0) + if (eContestAI.nextMove != MOVE_NONE) { sContestAICmdTable[*gAIScriptPtr](); // run the command. } else { - eContestAI.unk5[eContestAI.nextMoveIndex] = 0; // don't consider a move that doesn't exist. + eContestAI.moveScores[eContestAI.nextMoveIndex] = 0; // don't consider a move that doesn't exist. eContestAI.aiAction |= 1; } if (eContestAI.aiAction & 1) { eContestAI.nextMoveIndex++; - if (eContestAI.nextMoveIndex < 4) + if (eContestAI.nextMoveIndex < MAX_MON_MOVES) eContestAI.aiState = 0; else // aiState = CONTESTAI_FINISHED @@ -376,12 +379,12 @@ static void ContestAI_DoAIProcessing(void) } } -static u8 sub_81563B0(u8 var) +static u8 GetContestantIdByTurn(u8 turn) { int i; - for (i = 0; i < 4; i++) - if (eContestResources8.turnOrder[i] == var) + for (i = 0; i < CONTESTANT_COUNT; i++) + if (eContestResources8.turnOrder[i] == turn) break; return i; @@ -389,14 +392,14 @@ static u8 sub_81563B0(u8 var) static void ContestAICmd_score(void) { - s16 score = eContestAI.unk5[eContestAI.nextMoveIndex] + (s8)gAIScriptPtr[1]; + s16 score = eContestAI.moveScores[eContestAI.nextMoveIndex] + (s8)gAIScriptPtr[1]; if (score > 255) score = 255; else if (score < 0) score = 0; - eContestAI.unk5[eContestAI.nextMoveIndex] = score; + eContestAI.moveScores[eContestAI.nextMoveIndex] = score; gAIScriptPtr += 2; } @@ -1146,9 +1149,9 @@ static void ContestAICmd_if_would_not_finish_combo(void) static void ContestAICmd_get_condition(void) { - int var = sub_81563B0(gAIScriptPtr[1]); + u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - eContestAI.scriptResult = eContestantStatus[var].condition / 10; + eContestAI.scriptResult = eContestantStatus[contestant].condition / 10; gAIScriptPtr += 2; } @@ -1194,11 +1197,11 @@ static void ContestAICmd_if_condition_not_eq(void) static void ContestAICmd_get_used_combo_starter(void) { - u16 result = 0; - u8 var = sub_81563B0(gAIScriptPtr[1]); + u16 result = FALSE; + u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - if (sub_80DE1E8(var)) - result = gContestMoves[eContestantStatus[var].prevMove].comboStarterId ? 1 : 0; + if (sub_80DE1E8(contestant)) + result = gContestMoves[eContestantStatus[contestant].prevMove].comboStarterId ? TRUE : FALSE; eContestAI.scriptResult = result; gAIScriptPtr += 2; @@ -1246,7 +1249,7 @@ static void ContestAICmd_if_used_combo_starter_not_eq(void) static void ContestAICmd_check_can_participate(void) { - if (Contest_IsMonsTurnDisabled(sub_81563B0(gAIScriptPtr[1]))) + if (Contest_IsMonsTurnDisabled(GetContestantIdByTurn(gAIScriptPtr[1]))) eContestAI.scriptResult = FALSE; else eContestAI.scriptResult = TRUE; @@ -1276,9 +1279,9 @@ static void ContestAICmd_if_cannot_participate(void) static void ContestAICmd_get_val_812A188(void) { - u8 var = sub_81563B0(gAIScriptPtr[1]); + u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - eContestAI.scriptResult = eContestantStatus[var].unk15_3; + eContestAI.scriptResult = eContestantStatus[contestant].unk15_3; gAIScriptPtr += 2; } @@ -1304,9 +1307,9 @@ static void ContestAICmd_contest_58(void) static void ContestAICmd_unk_59(void) { - u8 var = sub_81563B0(gAIScriptPtr[1]); + u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - eContestAI.scriptResult = eContestantStatus[var].pointTotal - eContestantStatus[eContestAI.contestantId].pointTotal; + eContestAI.scriptResult = eContestantStatus[contestant].pointTotal - eContestantStatus[eContestAI.contestantId].pointTotal; gAIScriptPtr += 2; } @@ -1352,9 +1355,9 @@ static void ContestAICmd_unk_5D(void) static void ContestAICmd_unk_5E(void) { - u8 var = sub_81563B0(gAIScriptPtr[1]); + u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); - eContestAI.scriptResult = gContestMonConditions[var] - gContestMonConditions[eContestAI.contestantId]; + eContestAI.scriptResult = gContestMonConditions[contestant] - gContestMonConditions[eContestAI.contestantId]; gAIScriptPtr += 2; } @@ -1400,9 +1403,9 @@ static void ContestAICmd_unk_62(void) static void ContestAICmd_unk_63(void) { - u8 var = sub_81563B0(gAIScriptPtr[1]); - u8 var2 = gAIScriptPtr[2]; - u16 move = eContest.moveHistory[var2][var]; + u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); + u8 turn = gAIScriptPtr[2]; + u16 move = eContest.moveHistory[turn][contestant]; eContestAI.scriptResult = gContestMoves[move].effect; gAIScriptPtr += 3; @@ -1450,9 +1453,9 @@ static void ContestAICmd_unk_67(void) static void ContestAICmd_unk_68(void) { - u8 var = sub_81563B0(gAIScriptPtr[1]); - u8 var2 = gAIScriptPtr[2]; - s8 result = eContest.excitementHistory[var2][var]; + u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); + u8 turn = gAIScriptPtr[2]; + s8 result = eContest.excitementHistory[turn][contestant]; eContestAI.scriptResult = result; gAIScriptPtr += 3; @@ -1500,9 +1503,9 @@ static void ContestAICmd_unk_6C(void) static void ContestAICmd_unk_6D(void) { - u8 var = sub_81563B0(gAIScriptPtr[1]); - u8 var2 = gAIScriptPtr[2]; - u16 move = eContest.moveHistory[var2][var]; + u8 contestant = GetContestantIdByTurn(gAIScriptPtr[1]); + u8 turn = gAIScriptPtr[2]; + u16 move = eContest.moveHistory[turn][contestant]; eContestAI.scriptResult = gContestEffects[gContestMoves[move].effect].effectType; gAIScriptPtr += 3; diff --git a/src/contest_effect.c b/src/contest_effect.c index d6b06c3ba..1d3c81776 100644 --- a/src/contest_effect.c +++ b/src/contest_effect.c @@ -97,7 +97,7 @@ static void ContestEffect_GreatAppealButNoMoreMoves(void) static void ContestEffect_RepetitionNotBoring(void) { eContestantStatus[eContestResources8.contestant].usedRepeatableMove = TRUE; - eContestantStatus[eContestResources8.contestant].disappointedRepeat = FALSE; + eContestantStatus[eContestResources8.contestant].repeatedMove = FALSE; eContestantStatus[eContestResources8.contestant].moveRepeatCount = 0; } @@ -138,7 +138,7 @@ static void ContestEffect_StartleFrontMon(void) if (eContestResources8.turnOrder[a] != 0) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[a] - 1 == eContestResources8.turnOrder[i]) break; @@ -156,15 +156,15 @@ static void ContestEffect_StartleFrontMon(void) static void ContestEffect_StartlePrevMons(void) { u8 idx = 0; - u8 a = eContestResources8.contestant; + u8 contestant = eContestResources8.contestant; - if (eContestResources8.turnOrder[a] != 0) + if (eContestResources8.turnOrder[contestant] != 0) { int i, j; - for (i = 0, j = 0; i < 4; i++) + for (i = 0, j = 0; i < CONTESTANT_COUNT; i++) { - if (eContestResources8.turnOrder[a] > eContestResources8.turnOrder[i]) + if (eContestResources8.turnOrder[contestant] > eContestResources8.turnOrder[i]) eContestResources8.jamQueue[j++] = i; } @@ -390,11 +390,11 @@ static void ContestEffect_MakeFollowingMonsNervous(void) u8 contestantIds[5]; int i; int numAfter; - s16 oddsMod[4]; - s16 odds[4]; + s16 oddsMod[CONTESTANT_COUNT]; + s16 odds[CONTESTANT_COUNT]; memset(contestantIds, 0xFF, ARRAY_COUNT(contestantIds)); - for (i = 0, numAfter = 0; i < 4; i++) + for (i = 0, numAfter = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] < eContestResources8.turnOrder[i] && !eContestantStatus[i].nervous && !Contest_IsMonsTurnDisabled(i)) @@ -418,10 +418,10 @@ static void ContestEffect_MakeFollowingMonsNervous(void) } else { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) odds[i] = 0; } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestantStatus[i].hasJudgesAttention && sub_80DE1E8(i)) oddsMod[i] = gComboStarterLookupTable[gContestMoves[eContestantStatus[i].prevMove].comboStarterId] * 10; @@ -471,7 +471,7 @@ static void ContestEffect_WorsenConditionOfPrevMons(void) u8 numHit = 0; int i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i] && eContestantStatus[i].condition > 0 && @@ -495,7 +495,7 @@ static void ContestEffect_BadlyStartlesMonsInGoodCondition(void) u8 numHit = 0; int i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i]) { @@ -542,7 +542,7 @@ static void ContestEffect_AppealAsGoodAsPrevOnes(void) int i; int appealSum; - for (i = 0, appealSum = 0; i < 4; i++) + for (i = 0, appealSum = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i]) appealSum += eContestantStatus[i].appeal2; @@ -570,7 +570,7 @@ static void ContestEffect_AppealAsGoodAsPrevOne(void) if (eContestResources8.turnOrder[eContestResources8.contestant] != 0) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] - 1 == eContestResources8.turnOrder[i]) appeal = eContestantStatus[i].appeal2; @@ -647,7 +647,7 @@ static void ContestEffect_BetterIfSameType(void) while (1) { - for (j = 0; j < 4; j++) + for (j = 0; j < CONTESTANT_COUNT; j++) { if (eContestResources8.turnOrder[j] == i) break; @@ -679,7 +679,7 @@ static void ContestEffect_BetterIfDiffType(void) u16 move = eContestantStatus[eContestResources8.contestant].currMove; int i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] - 1 == eContestResources8.turnOrder[i] && gContestMoves[move].contestCategory != gContestMoves[eContestantStatus[i].currMove].contestCategory) @@ -699,7 +699,7 @@ static void ContestEffect_AffectedByPrevAppeal(void) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] - 1 == eContestResources8.turnOrder[i]) { @@ -748,18 +748,18 @@ static void ContestEffect_NextAppealEarlier(void) { s8 i; s8 j; - u8 turnOrder[4]; + u8 turnOrder[CONTESTANT_COUNT]; if (eContest.turnNumber != 4) { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) turnOrder[i] = eContestantStatus[i].nextTurnOrder; turnOrder[eContestResources8.contestant] = 0xFF; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - for (j = 0; j < 4; j++) + for (j = 0; j < CONTESTANT_COUNT; j++) { if (j != eContestResources8.contestant && i == turnOrder[j] && @@ -769,14 +769,14 @@ static void ContestEffect_NextAppealEarlier(void) break; } } - if (j == 4) + if (j == CONTESTANT_COUNT) break; } turnOrder[eContestResources8.contestant] = 0; eContestantStatus[eContestResources8.contestant].turnOrderMod = 1; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { eContestantStatus[i].nextTurnOrder = turnOrder[i]; } @@ -790,18 +790,18 @@ static void ContestEffect_NextAppealLater(void) { s8 i; s8 j; - u8 turnOrder[4]; + u8 turnOrder[CONTESTANT_COUNT]; if (eContest.turnNumber != 4) { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) turnOrder[i] = eContestantStatus[i].nextTurnOrder; turnOrder[eContestResources8.contestant] = 0xFF; - for (i = 3; i > -1; i--) + for (i = CONTESTANT_COUNT - 1; i > -1; i--) { - for (j = 0; j < 4; j++) + for (j = 0; j < CONTESTANT_COUNT; j++) { if (j != eContestResources8.contestant && i == turnOrder[j] && @@ -811,14 +811,14 @@ static void ContestEffect_NextAppealLater(void) break; } } - if (j == 4) + if (j == CONTESTANT_COUNT) break; } - turnOrder[eContestResources8.contestant] = 3; + turnOrder[eContestResources8.contestant] = CONTESTANT_COUNT - 1; eContestantStatus[eContestResources8.contestant].turnOrderMod = 1; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { eContestantStatus[i].nextTurnOrder = turnOrder[i]; } @@ -838,22 +838,22 @@ static void ContestEffect_ScrambleNextTurnOrder(void) { s8 i; s8 j; - u8 turnOrder[4]; - u8 unselectedContestants[4]; + u8 turnOrder[CONTESTANT_COUNT]; + u8 unselectedContestants[CONTESTANT_COUNT]; if (eContest.turnNumber != 4) { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { turnOrder[i] = eContestantStatus[i].nextTurnOrder; unselectedContestants[i] = i; } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { - u8 rval = Random() % (4 - i); + u8 rval = Random() % (CONTESTANT_COUNT - i); - for (j = 0; j < 4; j++) + for (j = 0; j < CONTESTANT_COUNT; j++) { if (unselectedContestants[j] != 0xFF) { @@ -869,7 +869,7 @@ static void ContestEffect_ScrambleNextTurnOrder(void) } } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { eContestantStatus[i].nextTurnOrder = turnOrder[i]; eContestantStatus[i].turnOrderMod = 2; @@ -894,7 +894,7 @@ static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void) int i; u8 numJammed = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i]) { @@ -965,7 +965,7 @@ static void JamByMoveCategory(u8 category) int i; int numJammed = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (eContestResources8.turnOrder[eContestResources8.contestant] > eContestResources8.turnOrder[i]) { @@ -1010,7 +1010,7 @@ static bool8 CanUnnerveContestant(u8 i) static bool8 WasAtLeastOneOpponentJammed(void) { - s16 jamBuffer[4] = {0}; + s16 jamBuffer[CONTESTANT_COUNT] = {0}; int i; for (i = 0; eContestResources8.jamQueue[i] != 0xFF; i++) @@ -1044,7 +1044,7 @@ static bool8 WasAtLeastOneOpponentJammed(void) } } - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) { if (jamBuffer[i] != 0) return TRUE; diff --git a/src/contest_link.c b/src/contest_link.c index eb688f55e..9241102e7 100644 --- a/src/contest_link.c +++ b/src/contest_link.c @@ -12,7 +12,11 @@ static void sub_80FC5C0(u8); static void sub_80FC5DC(u8); -bool32 sub_80FC4F4(void *src, u16 size) +#define tState data[0] +#define tCategory data[9] +#define tTimer data[11] + +bool32 LinkContest_SendBlock(void *src, u16 size) { memcpy(gDecompressionBuffer, src, size); if (SendBlock(bitmask_all_link_players_but_self(), gDecompressionBuffer, size)) @@ -21,21 +25,21 @@ bool32 sub_80FC4F4(void *src, u16 size) return FALSE; } -bool8 sub_80FC530(u8 arg0) +bool8 LinkContest_GetBlockReceived(u8 flag) { - u8 mask = (1 << arg0); + u8 mask = (1 << flag); if (!(GetBlockReceivedStatus() & mask)) { return FALSE; } else { - ResetBlockReceivedFlag(arg0); + ResetBlockReceivedFlag(flag); return TRUE; } } -bool8 sub_80FC55C(void) +bool8 LinkContest_GetBlockReceivedFromAllPlayers(void) { if (GetBlockReceivedStatus() == GetLinkPlayerCountAsBitFlags()) { @@ -52,10 +56,10 @@ void sub_80FC580(u8 taskId) { u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gBlockRecvBuffer[i][0] = 0xFF; - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; gTasks[taskId].func = sub_80FC5C0; } @@ -77,6 +81,7 @@ static void sub_80FC5DC(u8 taskId) if (gWirelessCommType == 1) gLinkContestFlags = LINK_CONTEST_FLAG_IS_LINK | LINK_CONTEST_FLAG_IS_WIRELESS; + // Get number of players using Emerald/FRLG for (i = 0; i < gNumLinkContestPlayers && (u32)(gLinkPlayers[i].version & 0xFF) - 1 > VERSION_RUBY - 1; i++) ; @@ -86,22 +91,22 @@ static void sub_80FC5DC(u8 taskId) SwitchTaskToFollowupFunc(taskId); } -bool32 sub_80FC670(s16 *arg0) +bool32 sub_80FC670(s16 *state) { if (gLinkContestFlags & LINK_CONTEST_FLAG_HAS_RS_PLAYER) return TRUE; - switch (*arg0) + switch (*state) { case 0: if (IsLinkTaskFinished()) { sub_800ADF8(); - (*arg0)++; + (*state)++; } return FALSE; case 1: - (*arg0)++; + (*state)++; return FALSE; default: if (IsLinkTaskFinished() != TRUE) @@ -118,7 +123,7 @@ void sub_80FC6BC(u8 taskId) if (!sub_80FC670(&gTasks[taskId].data[12])) return; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (GetMultiplayerId() == 0) @@ -126,37 +131,37 @@ void sub_80FC6BC(u8 taskId) if (IsLinkTaskFinished()) { memcpy(gBlockSendBuffer, &gContestMons[gContestPlayerMonIndex], sizeof(struct ContestPokemon)); - gTasks[taskId].data[0] = 10; + gTasks[taskId].tState = 10; } } else { memcpy(gBlockSendBuffer, &gContestMons[gContestPlayerMonIndex], sizeof(struct ContestPokemon)); - gTasks[taskId].data[0] = 1; + gTasks[taskId].tState = 1; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { for (i = 0; i < gNumLinkContestPlayers; i++) { memcpy(&gContestMons[i], gBlockRecvBuffer[i], sizeof(struct ContestPokemon)); - sub_80DFA08(&gContestMons[i], gLinkPlayers[i].language); + StripPlayerAndMonNamesForLinkContest(&gContestMons[i], gLinkPlayers[i].language); } - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 10: - if (++gTasks[taskId].data[11] > 300) + if (++gTasks[taskId].tTimer > 300) { sub_800A4D8(2); - gTasks[taskId].data[0] = 1; + gTasks[taskId].tState = 1; } break; default: - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[11] = 0; + gTasks[taskId].tState = 0; + gTasks[taskId].tTimer = 0; gTasks[taskId].data[12] = 0; SwitchTaskToFollowupFunc(taskId); break; @@ -165,29 +170,29 @@ void sub_80FC6BC(u8 taskId) void sub_80FC804(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (GetMultiplayerId() == 0) { - if (IsLinkTaskFinished() && sub_80FC4F4(&gRngValue, sizeof(gRngValue)) == TRUE) - gTasks[taskId].data[0]++; + if (IsLinkTaskFinished() && LinkContest_SendBlock(&gRngValue, sizeof(gRngValue)) == TRUE) + gTasks[taskId].tState++; } else { - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC530(0)) + if (LinkContest_GetBlockReceived(0)) { memcpy(&gRngValue, gBlockRecvBuffer[0], sizeof(gRngValue)); memcpy(&gContestRngValue, gBlockRecvBuffer[0], sizeof(gContestRngValue)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; default: - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; SwitchTaskToFollowupFunc(taskId); break; } @@ -200,91 +205,93 @@ void sub_80FC894(u8 taskId) if (!sub_80FC670(&gTasks[taskId].data[12])) return; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: - gBlockSendBuffer[0] = gTasks[taskId].data[9]; + gBlockSendBuffer[0] = gTasks[taskId].tCategory; if (GetMultiplayerId() == 0) { if (IsLinkTaskFinished()) - gTasks[taskId].data[0] = 10; + gTasks[taskId].tState = 10; } else { - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { for (i = 0; i < gNumLinkContestPlayers; i++) gTasks[taskId].data[i + 1] = gBlockRecvBuffer[i][0]; - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 10: - if (++gTasks[taskId].data[11] > 10) + if (++gTasks[taskId].tTimer > 10) { sub_800A4D8(2); - gTasks[taskId].data[0] = 1; + gTasks[taskId].tState = 1; } break; default: - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[11] = 0; + gTasks[taskId].tState = 0; + gTasks[taskId].tTimer = 0; gTasks[taskId].data[12] = 0; SwitchTaskToFollowupFunc(taskId); break; } } -void sub_80FC998(u8 taskId) +void Task_LinkContest_CommunicateMonIdxs(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(&gContestPlayerMonIndex, sizeof(gContestPlayerMonIndex)) == TRUE) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(&gContestPlayerMonIndex, sizeof(gContestPlayerMonIndex)) == TRUE) + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC55C()) - gTasks[taskId].data[0]++; + if (LinkContest_GetBlockReceivedFromAllPlayers()) + gTasks[taskId].tState++; break; default: - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; SwitchTaskToFollowupFunc(taskId); break; } } -void sub_80FC9F8(u8 taskId) +void Task_LinkContest_CommunicateMoveSelections(u8 taskId) { int i; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(&eContestantStatus[gContestPlayerMonIndex].currMove, sizeof(eContestantStatus[gContestPlayerMonIndex].currMove)) == TRUE) - gTasks[taskId].data[0]++; + // Send player's move selection + if (LinkContest_SendBlock(&eContestantStatus[gContestPlayerMonIndex].currMove, sizeof(eContestantStatus[gContestPlayerMonIndex].currMove)) == TRUE) + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { + // Receive partners' move selections for (i = 0; i < gNumLinkContestPlayers; i++) eContestantStatus[i].currMove = gBlockRecvBuffer[i][0]; - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; default: - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; SwitchTaskToFollowupFunc(taskId); break; } @@ -292,20 +299,20 @@ void sub_80FC9F8(u8 taskId) void sub_80FCACC(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestMonTotalPoints, sizeof(gContestMonTotalPoints)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gContestMonTotalPoints, sizeof(gContestMonTotalPoints)) == 1) + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gContestMonTotalPoints, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestMonTotalPoints)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 2: @@ -315,53 +322,53 @@ void sub_80FCACC(u8 taskId) if (gTasks[taskId].data[1]++ > 10) { gTasks[taskId].data[1] = 0; - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 3: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gUnknown_02039F10, sizeof(gUnknown_02039F10)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gUnknown_02039F10, sizeof(gUnknown_02039F10)) == 1) + gTasks[taskId].tState++; } break; case 4: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gUnknown_02039F10, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gUnknown_02039F10)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 6: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestMonRound2Points, sizeof(gContestMonRound2Points)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gContestMonRound2Points, sizeof(gContestMonRound2Points)) == 1) + gTasks[taskId].tState++; } break; case 7: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gContestMonRound2Points, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestMonRound2Points)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 9: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestFinalStandings, sizeof(gContestFinalStandings)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gContestFinalStandings, sizeof(gContestFinalStandings)) == 1) + gTasks[taskId].tState++; } break; case 10: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gContestFinalStandings, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestFinalStandings)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; default: - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; SwitchTaskToFollowupFunc(taskId); break; } @@ -369,20 +376,20 @@ void sub_80FCACC(u8 taskId) void sub_80FCC88(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(eContestantStatus, 4 * sizeof(struct ContestantStatus)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(eContestantStatus, 4 * sizeof(struct ContestantStatus)) == 1) + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(eContestantStatus, gBlockRecvBuffer[gUnknown_02039F2B], 4 * sizeof(struct ContestantStatus)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 2: @@ -392,53 +399,53 @@ void sub_80FCC88(u8 taskId) if (gTasks[taskId].data[1]++ > 10) { gTasks[taskId].data[1] = 0; - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 3: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestResources->field_8, sizeof(struct UnknownContestStruct7)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gContestResources->field_8, sizeof(struct UnknownContestStruct7)) == 1) + gTasks[taskId].tState++; } break; case 4: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gContestResources->field_8, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(struct UnknownContestStruct7)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 6: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestResources->field_10, sizeof(struct UnknownContestStruct5)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gContestResources->field_10, sizeof(struct UnknownContestStruct5)) == 1) + gTasks[taskId].tState++; } break; case 7: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gContestResources->field_10, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(struct UnknownContestStruct5)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 9: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestantTurnOrder, sizeof(gContestantTurnOrder)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gContestantTurnOrder, sizeof(gContestantTurnOrder)) == 1) + gTasks[taskId].tState++; } break; case 10: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gContestantTurnOrder, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestantTurnOrder)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; default: - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; SwitchTaskToFollowupFunc(taskId); break; } @@ -451,39 +458,39 @@ void sub_80FCE48(u8 taskId) if (!sub_80FC670(&gTasks[taskId].data[12])) return; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: gBlockSendBuffer[0] = 0x6E; if (GetMultiplayerId() == 0) { if (IsLinkTaskFinished()) - gTasks[taskId].data[0] = 10; + gTasks[taskId].tState = 10; } else { - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { - for (i = 0; i < 4; i++) + for (i = 0; i < CONTESTANT_COUNT; i++) gTasks[taskId].data[i + 5] = gBlockRecvBuffer[i][0]; - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; case 10: - if (++gTasks[taskId].data[11] > 10) + if (++gTasks[taskId].tTimer > 10) { sub_800A4D8(2); - gTasks[taskId].data[0] = 1; + gTasks[taskId].tState = 1; } break; default: - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[11] = 0; + gTasks[taskId].tState = 0; + gTasks[taskId].tTimer = 0; gTasks[taskId].data[12] = 0; SwitchTaskToFollowupFunc(taskId); break; @@ -495,24 +502,24 @@ void sub_80FCF40(u8 taskId) if (!sub_80FC670(&gTasks[taskId].data[12])) return; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestMonConditions, sizeof(gContestMonConditions)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gContestMonConditions, sizeof(gContestMonConditions)) == 1) + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gContestMonConditions, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestMonConditions)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; default: - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; gTasks[taskId].data[12] = 0; SwitchTaskToFollowupFunc(taskId); break; @@ -524,24 +531,24 @@ void sub_80FCFD0(u8 taskId) if (!sub_80FC670(&gTasks[taskId].data[12])) return; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(gContestantTurnOrder, sizeof(gContestantTurnOrder)) == 1) - gTasks[taskId].data[0]++; + if (LinkContest_SendBlock(gContestantTurnOrder, sizeof(gContestantTurnOrder)) == 1) + gTasks[taskId].tState++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { memcpy(gContestantTurnOrder, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestantTurnOrder)); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } break; default: - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; gTasks[taskId].data[12] = 0; SwitchTaskToFollowupFunc(taskId); break; diff --git a/src/contest_link_util.c b/src/contest_link_util.c index 8060b6cdc..221374112 100644 --- a/src/contest_link_util.c +++ b/src/contest_link_util.c @@ -1,5 +1,6 @@ #include "global.h" #include "contest.h" +#include "contest_link.h" #include "event_data.h" #include "link.h" #include "random.h" @@ -17,33 +18,35 @@ static void sub_81DA2E8(u8); static void sub_81DA3B8(u8); static void sub_81DA488(u8); +#define tCategory data[9] + void sub_81D9DE4(u8 taskId) { int gameCleared; - switch (gTasks[taskId].data[9]) + switch (gTasks[taskId].tCategory) { - case 0: + case CONTEST_CATEGORY_COOL: gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_COOL_RIBBON); break; - case 1: + case CONTEST_CATEGORY_BEAUTY: gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_BEAUTY_RIBBON); break; - case 2: + case CONTEST_CATEGORY_CUTE: gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_CUTE_RIBBON); break; - case 3: + case CONTEST_CATEGORY_SMART: gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_SMART_RIBBON); break; - case 4: + case CONTEST_CATEGORY_TOUGH: default: gHighestRibbonRank = GetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_TOUGH_RIBBON); break; } - gContestMons[gContestPlayerMonIndex].unk2C[0] = gHighestRibbonRank; + gContestMons[gContestPlayerMonIndex].highestRank = gHighestRibbonRank; gameCleared = FlagGet(FLAG_SYS_GAME_CLEAR) > 0; - gContestMons[gContestPlayerMonIndex].unk2C[1] = gameCleared; + gContestMons[gContestPlayerMonIndex].gameCleared = gameCleared; SetTaskFuncWithFollowupFunc(taskId, sub_81DA160, sub_81D9F14); } @@ -94,13 +97,13 @@ static void sub_81D9F68(u8 taskId) for (i = 0; i < gNumLinkContestPlayers; i++) data2[i] = gTasks[taskId].data[i + 5]; - if (gNumLinkContestPlayers != 4 && GetMultiplayerId() == 0) + if (gNumLinkContestPlayers != CONTESTANT_COUNT && GetMultiplayerId() == 0) { - rank = gContestMons[0].unk2C[0]; + rank = gContestMons[0].highestRank; for (i = 1; i < gNumLinkContestPlayers; i++) { - if (rank < gContestMons[i].unk2C[0]) - rank = gContestMons[i].unk2C[0]; + if (rank < gContestMons[i].highestRank) + rank = gContestMons[i].highestRank; } if (rank) @@ -109,7 +112,7 @@ static void sub_81D9F68(u8 taskId) gameCleared = 1; for (i = 0; i < gNumLinkContestPlayers; i++) { - if (!gContestMons[i].unk2C[1]) + if (!gContestMons[i].gameCleared) { gameCleared = 0; break; @@ -120,7 +123,7 @@ static void sub_81D9F68(u8 taskId) } gUnknown_02039F2B = sub_80F86E0(data2); - if (gNumLinkContestPlayers < 4) + if (gNumLinkContestPlayers < CONTESTANT_COUNT) SetTaskFuncWithFollowupFunc(taskId, sub_81DA488, sub_81DA10C); else gTasks[taskId].func = sub_81DA10C; @@ -155,17 +158,17 @@ static void sub_81DA160(u8 taskId) case 0: if (IsLinkTaskFinished()) { - if (sub_80FC4F4(&gContestMons[gContestPlayerMonIndex], sizeof(struct ContestPokemon)) == 1) + if (LinkContest_SendBlock(&gContestMons[gContestPlayerMonIndex], sizeof(struct ContestPokemon)) == 1) gTasks[taskId].data[0]++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { for (i = 0; i < gNumLinkContestPlayers; i++) { memcpy(&gContestMons[i], gBlockRecvBuffer[i], sizeof(struct ContestPokemon)); - sub_80DFA08(&gContestMons[i], gLinkPlayers[i].language); + StripPlayerAndMonNamesForLinkContest(&gContestMons[i], gLinkPlayers[i].language); } gTasks[taskId].data[0]++; @@ -192,7 +195,7 @@ static void sub_81DA244(u8 taskId) if (!IsLinkTaskFinished()) return; - if (sub_80FC4F4(&gRngValue, sizeof(gRngValue)) == 1) + if (LinkContest_SendBlock(&gRngValue, sizeof(gRngValue)) == 1) gTasks[taskId].data[0]++; } else @@ -201,7 +204,7 @@ static void sub_81DA244(u8 taskId) } break; case 1: - if (sub_80FC530(0)) + if (LinkContest_GetBlockReceived(0)) { memcpy(&gRngValue, gBlockRecvBuffer[0], sizeof(gRngValue)); memcpy(&gContestRngValue, gBlockRecvBuffer[0], sizeof(gContestRngValue)); @@ -231,12 +234,12 @@ static void sub_81DA2E8(u8 taskId) if (IsLinkTaskFinished()) { var0 = 0x6E; - if (sub_80FC4F4(&var0, sizeof(var0)) == 1) + if (LinkContest_SendBlock(&var0, sizeof(var0)) == 1) gTasks[taskId].data[0]++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { for (i = 0; i < gNumLinkContestPlayers; i++) { @@ -253,8 +256,8 @@ static void sub_81DA2E8(u8 taskId) static void sub_81DA3B8(u8 taskId) { int i; - u16 data[4]; - u16 var0; + u16 data[CONTESTANT_COUNT]; + u16 category; if (!sub_80FC670(&gTasks[taskId].data[12])) return; @@ -269,13 +272,13 @@ static void sub_81DA3B8(u8 taskId) case 0: if (IsLinkTaskFinished()) { - var0 = gTasks[taskId].data[9]; - if (sub_80FC4F4(&var0, sizeof(var0)) == 1) + category = gTasks[taskId].tCategory; + if (LinkContest_SendBlock(&category, sizeof(category)) == 1) gTasks[taskId].data[0]++; } break; case 1: - if (sub_80FC55C()) + if (LinkContest_GetBlockReceivedFromAllPlayers()) { for (i = 0; i < gNumLinkContestPlayers; i++) { @@ -309,7 +312,7 @@ static void sub_81DA488(u8 taskId) if (!IsLinkTaskFinished()) return; - if (sub_80FC4F4(&gContestMons[gNumLinkContestPlayers], (4 - gNumLinkContestPlayers) * sizeof(struct ContestPokemon)) == 1) + if (LinkContest_SendBlock(&gContestMons[gNumLinkContestPlayers], (CONTESTANT_COUNT - gNumLinkContestPlayers) * sizeof(struct ContestPokemon)) == 1) gTasks[taskId].data[0]++; } else @@ -318,11 +321,11 @@ static void sub_81DA488(u8 taskId) } break; case 1: - if (sub_80FC530(0)) + if (LinkContest_GetBlockReceived(0)) { - memcpy(&gContestMons[gNumLinkContestPlayers], gBlockRecvBuffer[0], (4 - gNumLinkContestPlayers) * sizeof(struct ContestPokemon)); - for (i = gNumLinkContestPlayers; i < 4; i++) - sub_80DFA08(&gContestMons[i], gLinkPlayers[0].language); + memcpy(&gContestMons[gNumLinkContestPlayers], gBlockRecvBuffer[0], (CONTESTANT_COUNT - gNumLinkContestPlayers) * sizeof(struct ContestPokemon)); + for (i = gNumLinkContestPlayers; i < CONTESTANT_COUNT; i++) + StripPlayerAndMonNamesForLinkContest(&gContestMons[i], gLinkPlayers[0].language); gTasks[taskId].data[0]++; } diff --git a/src/contest_util.c b/src/contest_util.c index 22074e1a1..6ad67ee50 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -653,7 +653,7 @@ static void Task_WaitForLinkPartnersBeforeResults(u8 taskId) static void sub_80F5F14(u8 taskId) { - SetTaskFuncWithFollowupFunc(taskId, sub_80FC998, sub_80F5F30); + SetTaskFuncWithFollowupFunc(taskId, Task_LinkContest_CommunicateMonIdxs, sub_80F5F30); } static void sub_80F5F30(u8 taskId) @@ -2405,25 +2405,25 @@ void GetContestPlayerId(void) gSpecialVar_0x8004 = gContestPlayerMonIndex; } -void ContestLinkTransfer(u8 taskId) +void ContestLinkTransfer(u8 category) { u8 newTaskId; ScriptContext2_Enable(); newTaskId = CreateTask(sub_80FC580, 0); SetTaskFuncWithFollowupFunc(newTaskId, sub_80FC580, sub_80F8508); - gTasks[newTaskId].data[9] = taskId; + gTasks[newTaskId].data[9] = category; } static void sub_80F8508(u8 taskId) { if (gLinkContestFlags & LINK_CONTEST_FLAG_HAS_RS_PLAYER) { - sub_80DA8C8(gContestMonPartyIndex); + CreateContestMonFromParty(gContestMonPartyIndex); SetTaskFuncWithFollowupFunc(taskId, sub_80FC6BC, sub_80F8568); } else { - sub_80DA8C8(gContestMonPartyIndex); + CreateContestMonFromParty(gContestMonPartyIndex); gTasks[taskId].func = sub_81D9DE4; } } diff --git a/src/data/contest_opponents.h b/src/data/contest_opponents.h index 8fa746725..53868fc84 100644 --- a/src/data/contest_opponents.h +++ b/src/data/contest_opponents.h @@ -203,7 +203,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 3, .tough = 4, .sheen = 50, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -232,7 +231,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 1, .tough = 2, .sheen = 60, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -261,7 +259,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 12, .tough = 4, .sheen = 70, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -290,7 +287,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 2, .tough = 7, .sheen = 80, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -319,7 +315,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 5, .tough = 4, .sheen = 90, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -348,7 +343,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 7, .tough = 8, .sheen = 100, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -377,7 +371,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 2, .tough = 2, .sheen = 50, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -406,7 +399,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 10, .sheen = 60, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -435,7 +427,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 5, .tough = 18, .sheen = 70, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -464,7 +455,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 2, .tough = 7, .sheen = 80, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -493,7 +483,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 8, .tough = 1, .sheen = 90, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -522,7 +511,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 2, .sheen = 100, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -551,7 +539,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 2, .tough = 10, .sheen = 50, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -580,7 +567,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 5, .sheen = 60, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -609,7 +595,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 1, .tough = 1, .sheen = 70, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -638,7 +623,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 4, .sheen = 50, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -667,7 +651,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 4, .sheen = 60, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -696,7 +679,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 2, .tough = 3, .sheen = 70, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -725,7 +707,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 5, .tough = 10, .sheen = 80, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -754,7 +735,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 3, .tough = 10, .sheen = 90, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -783,7 +763,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 1, .tough = 5, .sheen = 100, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -812,7 +791,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 6, .tough = 2, .sheen = 90, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -841,7 +819,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 5, .tough = 3, .sheen = 80, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -870,7 +847,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 8, .tough = 10, .sheen = 70, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -899,7 +875,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 20, .sheen = 100, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -928,7 +903,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 85, .tough = 35, .sheen = 110, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -957,7 +931,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 25, .sheen = 120, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -986,7 +959,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 65, .tough = 25, .sheen = 130, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1015,7 +987,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 100, .sheen = 140, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1044,7 +1015,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 35, .tough = 35, .sheen = 150, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1073,7 +1043,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 40, .tough = 40, .sheen = 100, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1102,7 +1071,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 10, .tough = 25, .sheen = 110, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1131,7 +1099,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 30, .tough = 25, .sheen = 120, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1160,7 +1127,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 40, .tough = 30, .sheen = 130, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1189,7 +1155,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 75, .tough = 35, .sheen = 140, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1218,7 +1183,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 30, .tough = 25, .sheen = 150, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1247,7 +1211,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 25, .tough = 15, .sheen = 100, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1276,7 +1239,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 60, .tough = 20, .sheen = 110, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1305,7 +1267,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 15, .tough = 75, .sheen = 120, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1334,7 +1295,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 30, .tough = 20, .sheen = 100, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1363,7 +1323,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 20, .tough = 20, .sheen = 110, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1392,7 +1351,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 20, .tough = 20, .sheen = 120, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1421,7 +1379,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 30, .tough = 45, .sheen = 130, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1450,7 +1407,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 20, .tough = 45, .sheen = 140, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1479,7 +1435,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 20, .tough = 20, .sheen = 150, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1508,7 +1463,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 25, .tough = 25, .sheen = 140, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1537,7 +1491,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 20, .tough = 20, .sheen = 130, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1566,7 +1519,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 45, .tough = 20, .sheen = 120, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1595,7 +1547,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 100, .tough = 90, .sheen = 200, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1624,7 +1575,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 35, .tough = 70, .sheen = 210, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1653,7 +1603,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 70, .tough = 70, .sheen = 220, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1682,7 +1631,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 75, .tough = 40, .sheen = 230, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1711,7 +1659,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 70, .tough = 70, .sheen = 240, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1740,7 +1687,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 80, .tough = 100, .sheen = 250, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1769,7 +1715,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 70, .tough = 90, .sheen = 200, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1798,7 +1743,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 50, .tough = 65, .sheen = 210, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1827,7 +1771,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 60, .tough = 50, .sheen = 220, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1856,7 +1799,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 45, .tough = 70, .sheen = 230, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1885,7 +1827,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 40, .tough = 100, .sheen = 240, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1914,7 +1855,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 50, .tough = 30, .sheen = 250, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1943,7 +1883,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 50, .tough = 160, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -1972,7 +1911,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 70, .tough = 50, .sheen = 210, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2001,7 +1939,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 35, .tough = 35, .sheen = 220, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2030,7 +1967,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 100, .tough = 80, .sheen = 200, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2059,7 +1995,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 35, .tough = 100, .sheen = 210, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2088,7 +2023,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 50, .tough = 100, .sheen = 220, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2117,7 +2051,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 40, .tough = 95, .sheen = 230, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2146,7 +2079,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 50, .tough = 100, .sheen = 240, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2175,7 +2107,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 80, .tough = 80, .sheen = 250, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2204,7 +2135,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 40, .tough = 110, .sheen = 240, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2233,7 +2163,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 25, .tough = 80, .sheen = 230, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2262,7 +2191,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 35, .tough = 40, .sheen = 220, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2291,7 +2219,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 40, .tough = 160, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2320,7 +2247,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 150, .tough = 160, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2349,7 +2275,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 185, .tough = 60, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2378,7 +2303,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 110, .tough = 150, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2407,7 +2331,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 30, .tough = 90, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2436,7 +2359,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 230, .tough = 80, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2465,7 +2387,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 130, .tough = 40, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2494,7 +2415,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 150, .tough = 160, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2523,7 +2443,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 130, .tough = 170, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2552,7 +2471,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 75, .tough = 100, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2581,7 +2499,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 40, .tough = 190, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2610,7 +2527,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 240, .tough = 140, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2639,7 +2555,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 35, .tough = 50, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2668,7 +2583,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 115, .tough = 120, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2697,7 +2611,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 220, .tough = 210, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2726,7 +2639,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 80, .tough = 180, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2755,7 +2667,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 130, .tough = 130, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2784,7 +2695,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 120, .tough = 150, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2813,7 +2723,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 170, .tough = 80, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2842,7 +2751,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 150, .tough = 120, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2871,7 +2779,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 120, .tough = 80, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2900,7 +2807,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 80, .tough = 150, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2929,7 +2835,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 110, .tough = 170, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF }, @@ -2958,7 +2863,6 @@ const struct ContestPokemon gContestOpponents[] = .smart = 80, .tough = 190, .sheen = 255, - .unk2C = {0}, .personality = 0, .otId = 0xFFFF } diff --git a/src/graphics.c b/src/graphics.c index b774c5ad2..055a6c4cd 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -461,12 +461,12 @@ const u32 gContestMiscGfx[] = INCBIN_U32("graphics/contest/misc.4bpp.lz"); const u32 gContestAudienceGfx[] = INCBIN_U32("graphics/contest/audience.4bpp.lz"); -const u32 gUnknown_08C19168[] = INCBIN_U32("graphics/contest/faces.4bpp.lz"); +const u32 gContestFaces_Gfx[] = INCBIN_U32("graphics/contest/faces.4bpp.lz"); const u32 gContestJudgeSymbolsGfx[] = INCBIN_U32("graphics/contest/judge_symbols.4bpp.lz"); const u32 gContest3Pal[] = INCBIN_U32("graphics/contest/judge_symbols.gbapal.lz"); -const u8 gTiles_8C19450[] = INCBIN_U8("graphics/contest/heart.4bpp"); +const u8 gContestSliderHeart_Gfx[] = INCBIN_U8("graphics/contest/slider_heart.4bpp"); const u32 gUnknownGfx_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.4bpp.lz"); const u32 gUnknownPal_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.gbapal.lz"); diff --git a/src/pokemon.c b/src/pokemon.c index 329240f99..9687a5abf 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4499,8 +4499,8 @@ void CreateSecretBaseEnemyParty(struct SecretBase *secretBaseRecord) for (j = 0; j < MAX_MON_MOVES; j++) { - SetMonData(&gEnemyParty[i], MON_DATA_MOVE1 + j, &gBattleResources->secretBase->party.moves[i * 4 + j]); - SetMonData(&gEnemyParty[i], MON_DATA_PP1 + j, &gBattleMoves[gBattleResources->secretBase->party.moves[i * 4 + j]].pp); + SetMonData(&gEnemyParty[i], MON_DATA_MOVE1 + j, &gBattleResources->secretBase->party.moves[i * MAX_MON_MOVES + j]); + SetMonData(&gEnemyParty[i], MON_DATA_PP1 + j, &gBattleMoves[gBattleResources->secretBase->party.moves[i * MAX_MON_MOVES + j]].pp); } } }