From 55f4bdf8ae1f5fbe8c3e7bdcd2bc88b1283b13a9 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 20 Aug 2024 08:50:45 -0400 Subject: [PATCH 1/6] DoBattleIntro state documentation --- src/battle_main.c | 67 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index e0ab912e4f9c..402bde1691d4 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3421,6 +3421,31 @@ const u8* FaintClearSetData(u32 battler) return result; } +enum +{ + STATE_GET_MON_DATA, + STATE_LOOP_BATTLER_DATA, + STATE_PREPARE_BG_SLIDE, + STATE_WAIT_FOR_BG_SLIDE, + STATE_DRAW_SPRITES, + STATE_DRAW_PARTY_SUMMARY, + STATE_WAIT_FOR_PARTY_SUMMARY, + STATE_INTRO_TEXT, + STATE_WAIT_FOR_INTRO_TEXT, + STATE_TRAINER_SEND_OUT_TEXT, + STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT, + STATE_TRAINER_1_SEND_OUT_ANIM, + STATE_NOTHING, + STATE_TRAINER_2_SEND_OUT_ANIM, + STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM, + STATE_WAIT_FOR_WILD_BATTLE_TEXT, + STATE_PRINT_PLAYER_SEND_OUT_TEXT, + STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT, + STATE_PRINT_PLAYER_1_SEND_OUT_TEXT, + STATE_PRINT_PLAYER_2_SEND_OUT_TEXT, + STATE_SET_DEX_AND_BATTLE_VARS +}; + static void DoBattleIntro(void) { s32 i; @@ -3429,13 +3454,13 @@ static void DoBattleIntro(void) switch (*state) { - case 0: // Get Data of all battlers. + case STATE_GET_MON_DATA: battler = gBattleCommunication[1]; BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, 0); MarkBattlerForControllerExec(battler); (*state)++; break; - case 1: // Loop through all battlers. + case STATE_LOOP_BATTLER_DATA: if (!gBattleControllerExecFlags) { if (++gBattleCommunication[1] == gBattlersCount) @@ -3444,7 +3469,7 @@ static void DoBattleIntro(void) *state = 0; } break; - case 2: // Start graphical intro slide. + case STATE_PREPARE_BG_SLIDE: if (!gBattleControllerExecFlags) { battler = GetBattlerAtPosition(0); @@ -3455,11 +3480,11 @@ static void DoBattleIntro(void) (*state)++; } break; - case 3: // Wait for intro slide. + case STATE_WAIT_FOR_BG_SLIDE: if (!gBattleControllerExecFlags) (*state)++; break; - case 4: // Copy battler data gotten in cases 0 and 1. Draw trainer/mon sprite. + case STATE_DRAW_SPRITES: for (battler = 0; battler < gBattlersCount; battler++) { if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && GetBattlerSide(battler) == B_SIDE_PLAYER) @@ -3549,7 +3574,7 @@ static void DoBattleIntro(void) *state = 6; // Wait for sprite to load. } break; - case 5: // draw party summary in trainer battles + case STATE_DRAW_PARTY_SUMMARY: if (!gBattleControllerExecFlags) { struct HpAndStatus hpStatus[PARTY_SIZE]; @@ -3595,18 +3620,18 @@ static void DoBattleIntro(void) (*state)++; } break; - case 6: // wait for previous action to complete + case STATE_WAIT_FOR_PARTY_SUMMARY: if (!gBattleControllerExecFlags) (*state)++; break; - case 7: // print battle intro message + case STATE_INTRO_TEXT: if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) { PrepareStringBattle(STRINGID_INTROMSG, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); (*state)++; } break; - case 8: // wait for intro message to be printed + case STATE_WAIT_FOR_INTRO_TEXT: if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) { if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) @@ -3622,18 +3647,18 @@ static void DoBattleIntro(void) } } break; - case 9: // print opponent sends out + case STATE_TRAINER_SEND_OUT_TEXT: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); else PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)); (*state)++; break; - case 10: // wait for opponent sends out text + case STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT: if (!gBattleControllerExecFlags) (*state)++; break; - case 11: // first opponent's mon send out animation + case STATE_TRAINER_1_SEND_OUT_ANIM: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); else @@ -3643,9 +3668,9 @@ static void DoBattleIntro(void) MarkBattlerForControllerExec(battler); (*state)++; break; - case 12: // nothing + case STATE_NOTHING: (*state)++; - case 13: // second opponent's mon send out + case STATE_TRAINER_2_SEND_OUT_ANIM: if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3662,15 +3687,15 @@ static void DoBattleIntro(void) else (*state)++; break; - case 14: // wait for opponent 2 send out + case STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM: if (!gBattleControllerExecFlags) (*state)++; break; - case 15: // wait for wild battle message + case STATE_WAIT_FOR_WILD_BATTLE_TEXT: if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) (*state)++; break; - case 16: // print player sends out + case STATE_PRINT_PLAYER_SEND_OUT_TEXT: if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3691,7 +3716,7 @@ static void DoBattleIntro(void) } (*state)++; break; - case 17: // wait for player send out message + case STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT: if (!(gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleControllerExecFlags)) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3703,7 +3728,7 @@ static void DoBattleIntro(void) (*state)++; } break; - case 18: // player 1 send out + case STATE_PRINT_PLAYER_1_SEND_OUT_TEXT: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else @@ -3713,7 +3738,7 @@ static void DoBattleIntro(void) MarkBattlerForControllerExec(battler); (*state)++; break; - case 19: // player 2 send out + case STATE_PRINT_PLAYER_2_SEND_OUT_TEXT: if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3726,7 +3751,7 @@ static void DoBattleIntro(void) } (*state)++; break; - case 20: // set dex and battle vars + case STATE_SET_DEX_AND_BATTLE_VARS: if (!gBattleControllerExecFlags) { for (battler = 0; battler < gBattlersCount; battler++) From 1b6e07b84e3ceb80142c795ad9afc105ae2f0e76 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 20 Aug 2024 08:51:52 -0400 Subject: [PATCH 2/6] Removed unused state --- src/battle_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 402bde1691d4..d22998518537 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3435,7 +3435,6 @@ enum STATE_TRAINER_SEND_OUT_TEXT, STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT, STATE_TRAINER_1_SEND_OUT_ANIM, - STATE_NOTHING, STATE_TRAINER_2_SEND_OUT_ANIM, STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM, STATE_WAIT_FOR_WILD_BATTLE_TEXT, @@ -3668,8 +3667,6 @@ static void DoBattleIntro(void) MarkBattlerForControllerExec(battler); (*state)++; break; - case STATE_NOTHING: - (*state)++; case STATE_TRAINER_2_SEND_OUT_ANIM: if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT) { From 2b927d445f3670ca9d647f3057d14440cfc9745e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 20 Aug 2024 09:44:12 -0400 Subject: [PATCH 3/6] Update src/battle_main.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> --- src/battle_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_main.c b/src/battle_main.c index d22998518537..4a0bcf4ba9c9 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3421,7 +3421,7 @@ const u8* FaintClearSetData(u32 battler) return result; } -enum +enum BattleIntroStates { STATE_GET_MON_DATA, STATE_LOOP_BATTLER_DATA, From c28e33331e44c567825a361e34a2f090daf147b3 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 20 Aug 2024 17:47:50 -0400 Subject: [PATCH 4/6] Fixed state jumps --- src/battle_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 4a0bcf4ba9c9..085ad9d36583 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3465,7 +3465,7 @@ static void DoBattleIntro(void) if (++gBattleCommunication[1] == gBattlersCount) (*state)++; else - *state = 0; + *state = STATE_GET_MON_DATA; } break; case STATE_PREPARE_BG_SLIDE: @@ -3568,9 +3568,9 @@ static void DoBattleIntro(void) else // Skip party summary since it is a wild battle. { if (B_FAST_INTRO == TRUE) - *state = 7; // Don't wait for sprite, print message at the same time. + *state = STATE_INTRO_TEXT; // Don't wait for sprite, print message at the same time. else - *state = 6; // Wait for sprite to load. + *state = STATE_WAIT_FOR_PARTY_SUMMARY; // Wait for sprite to load. } break; case STATE_DRAW_PARTY_SUMMARY: @@ -3640,9 +3640,9 @@ static void DoBattleIntro(void) else { if (B_FAST_INTRO == TRUE) - *state = 15; // Wait for text to be printed. + *state = STATE_WAIT_FOR_WILD_BATTLE_TEXT; else - *state = 14; // Wait for text and sprite. + *state = STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM; } } break; @@ -3680,7 +3680,7 @@ static void DoBattleIntro(void) } if (B_FAST_INTRO == TRUE && !(gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_RECORDED_IS_MASTER | BATTLE_TYPE_LINK))) - *state = 15; // Print at the same time as trainer sends out second mon. + *state = STATE_WAIT_FOR_WILD_BATTLE_TEXT; // Print at the same time as trainer sends out second mon. else (*state)++; break; From 7625f0b417e728c74318fa49a39d4250618c3915 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 21 Aug 2024 08:56:13 -0400 Subject: [PATCH 5/6] BattleStruct state uses enum --- include/battle.h | 26 +++++++++++++++- src/battle_main.c | 77 ++++++++++++++++------------------------------- 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/include/battle.h b/include/battle.h index 6d81bc146e93..adc878858254 100644 --- a/include/battle.h +++ b/include/battle.h @@ -607,6 +607,30 @@ struct BattleVideo { }; #endif +enum BattleIntroStates +{ + STATE_GET_MON_DATA, + STATE_LOOP_BATTLER_DATA, + STATE_PREPARE_BG_SLIDE, + STATE_WAIT_FOR_BG_SLIDE, + STATE_DRAW_SPRITES, + STATE_DRAW_PARTY_SUMMARY, + STATE_WAIT_FOR_PARTY_SUMMARY, + STATE_INTRO_TEXT, + STATE_WAIT_FOR_INTRO_TEXT, + STATE_TRAINER_SEND_OUT_TEXT, + STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT, + STATE_TRAINER_1_SEND_OUT_ANIM, + STATE_TRAINER_2_SEND_OUT_ANIM, + STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM, + STATE_WAIT_FOR_WILD_BATTLE_TEXT, + STATE_PRINT_PLAYER_SEND_OUT_TEXT, + STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT, + STATE_PRINT_PLAYER_1_SEND_OUT_TEXT, + STATE_PRINT_PLAYER_2_SEND_OUT_TEXT, + STATE_SET_DEX_AND_BATTLE_VARS +}; + struct BattleStruct { u8 turnEffectsTracker; @@ -726,7 +750,7 @@ struct BattleStruct struct BattleGimmickData gimmick; const u8 *trainerSlideMsg; bool8 trainerSlideLowHpMsgDone; - u8 introState; + enum BattleIntroStates introState:8; u8 ateBerry[2]; // array id determined by side, each party pokemon as bit u8 stolenStats[NUM_BATTLE_STATS]; // hp byte is used for which stats to raise, other inform about by how many stages u8 lastMoveFailed; // as bits for each battler, for the sake of Stomping Tantrum diff --git a/src/battle_main.c b/src/battle_main.c index 085ad9d36583..d9f253aef772 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3421,51 +3421,26 @@ const u8* FaintClearSetData(u32 battler) return result; } -enum BattleIntroStates -{ - STATE_GET_MON_DATA, - STATE_LOOP_BATTLER_DATA, - STATE_PREPARE_BG_SLIDE, - STATE_WAIT_FOR_BG_SLIDE, - STATE_DRAW_SPRITES, - STATE_DRAW_PARTY_SUMMARY, - STATE_WAIT_FOR_PARTY_SUMMARY, - STATE_INTRO_TEXT, - STATE_WAIT_FOR_INTRO_TEXT, - STATE_TRAINER_SEND_OUT_TEXT, - STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT, - STATE_TRAINER_1_SEND_OUT_ANIM, - STATE_TRAINER_2_SEND_OUT_ANIM, - STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM, - STATE_WAIT_FOR_WILD_BATTLE_TEXT, - STATE_PRINT_PLAYER_SEND_OUT_TEXT, - STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT, - STATE_PRINT_PLAYER_1_SEND_OUT_TEXT, - STATE_PRINT_PLAYER_2_SEND_OUT_TEXT, - STATE_SET_DEX_AND_BATTLE_VARS -}; - static void DoBattleIntro(void) { s32 i; u32 battler; - u8 *state = &gBattleStruct->introState; - switch (*state) + switch (gBattleStruct->introState) { case STATE_GET_MON_DATA: battler = gBattleCommunication[1]; BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, 0); MarkBattlerForControllerExec(battler); - (*state)++; + gBattleStruct->introState++; break; case STATE_LOOP_BATTLER_DATA: if (!gBattleControllerExecFlags) { if (++gBattleCommunication[1] == gBattlersCount) - (*state)++; + gBattleStruct->introState++; else - *state = STATE_GET_MON_DATA; + gBattleStruct->introState = STATE_GET_MON_DATA; } break; case STATE_PREPARE_BG_SLIDE: @@ -3476,12 +3451,12 @@ static void DoBattleIntro(void) MarkBattlerForControllerExec(battler); gBattleCommunication[0] = 0; gBattleCommunication[1] = 0; - (*state)++; + gBattleStruct->introState++; } break; case STATE_WAIT_FOR_BG_SLIDE: if (!gBattleControllerExecFlags) - (*state)++; + gBattleStruct->introState++; break; case STATE_DRAW_SPRITES: for (battler = 0; battler < gBattlersCount; battler++) @@ -3563,14 +3538,14 @@ static void DoBattleIntro(void) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { - (*state)++; + gBattleStruct->introState++; } else // Skip party summary since it is a wild battle. { if (B_FAST_INTRO == TRUE) - *state = STATE_INTRO_TEXT; // Don't wait for sprite, print message at the same time. + gBattleStruct->introState = STATE_INTRO_TEXT; // Don't wait for sprite, print message at the same time. else - *state = STATE_WAIT_FOR_PARTY_SUMMARY; // Wait for sprite to load. + gBattleStruct->introState = STATE_WAIT_FOR_PARTY_SUMMARY; // Wait for sprite to load. } break; case STATE_DRAW_PARTY_SUMMARY: @@ -3616,18 +3591,18 @@ static void DoBattleIntro(void) BtlController_EmitDrawPartyStatusSummary(battler, BUFFER_A, hpStatus, PARTY_SUMM_SKIP_DRAW_DELAY); MarkBattlerForControllerExec(battler); - (*state)++; + gBattleStruct->introState++; } break; case STATE_WAIT_FOR_PARTY_SUMMARY: if (!gBattleControllerExecFlags) - (*state)++; + gBattleStruct->introState++; break; case STATE_INTRO_TEXT: if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) { PrepareStringBattle(STRINGID_INTROMSG, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); - (*state)++; + gBattleStruct->introState++; } break; case STATE_WAIT_FOR_INTRO_TEXT: @@ -3635,14 +3610,14 @@ static void DoBattleIntro(void) { if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { - (*state)++; + gBattleStruct->introState++; } else { if (B_FAST_INTRO == TRUE) - *state = STATE_WAIT_FOR_WILD_BATTLE_TEXT; + gBattleStruct->introState = STATE_WAIT_FOR_WILD_BATTLE_TEXT; else - *state = STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM; + gBattleStruct->introState = STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM; } } break; @@ -3651,11 +3626,11 @@ static void DoBattleIntro(void) PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); else PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)); - (*state)++; + gBattleStruct->introState++; break; case STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT: if (!gBattleControllerExecFlags) - (*state)++; + gBattleStruct->introState++; break; case STATE_TRAINER_1_SEND_OUT_ANIM: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3665,7 +3640,7 @@ static void DoBattleIntro(void) BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A); MarkBattlerForControllerExec(battler); - (*state)++; + gBattleStruct->introState++; break; case STATE_TRAINER_2_SEND_OUT_ANIM: if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT) @@ -3680,17 +3655,17 @@ static void DoBattleIntro(void) } if (B_FAST_INTRO == TRUE && !(gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_RECORDED_IS_MASTER | BATTLE_TYPE_LINK))) - *state = STATE_WAIT_FOR_WILD_BATTLE_TEXT; // Print at the same time as trainer sends out second mon. + gBattleStruct->introState = STATE_WAIT_FOR_WILD_BATTLE_TEXT; // Print at the same time as trainer sends out second mon. else - (*state)++; + gBattleStruct->introState++; break; case STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM: if (!gBattleControllerExecFlags) - (*state)++; + gBattleStruct->introState++; break; case STATE_WAIT_FOR_WILD_BATTLE_TEXT: if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) - (*state)++; + gBattleStruct->introState++; break; case STATE_PRINT_PLAYER_SEND_OUT_TEXT: if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) @@ -3711,7 +3686,7 @@ static void DoBattleIntro(void) PrepareStringBattle(STRINGID_INTROSENDOUT, battler); } - (*state)++; + gBattleStruct->introState++; break; case STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT: if (!(gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleControllerExecFlags)) @@ -3722,7 +3697,7 @@ static void DoBattleIntro(void) battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); if (!IsBattlerMarkedForControllerExec(battler)) - (*state)++; + gBattleStruct->introState++; } break; case STATE_PRINT_PLAYER_1_SEND_OUT_TEXT: @@ -3733,7 +3708,7 @@ static void DoBattleIntro(void) BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A); MarkBattlerForControllerExec(battler); - (*state)++; + gBattleStruct->introState++; break; case STATE_PRINT_PLAYER_2_SEND_OUT_TEXT: if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)) @@ -3746,7 +3721,7 @@ static void DoBattleIntro(void) BtlController_EmitIntroTrainerBallThrow(battler, BUFFER_A); MarkBattlerForControllerExec(battler); } - (*state)++; + gBattleStruct->introState++; break; case STATE_SET_DEX_AND_BATTLE_VARS: if (!gBattleControllerExecFlags) From 275c483b12b1da77fe716b54fde4a9d041621d11 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 21 Aug 2024 09:34:08 -0400 Subject: [PATCH 6/6] Renamed state enums --- include/battle.h | 40 ++++++++++++++++++------------------ src/battle_main.c | 52 +++++++++++++++++++++++------------------------ 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/include/battle.h b/include/battle.h index adc878858254..084c09f78988 100644 --- a/include/battle.h +++ b/include/battle.h @@ -609,26 +609,26 @@ struct BattleVideo { enum BattleIntroStates { - STATE_GET_MON_DATA, - STATE_LOOP_BATTLER_DATA, - STATE_PREPARE_BG_SLIDE, - STATE_WAIT_FOR_BG_SLIDE, - STATE_DRAW_SPRITES, - STATE_DRAW_PARTY_SUMMARY, - STATE_WAIT_FOR_PARTY_SUMMARY, - STATE_INTRO_TEXT, - STATE_WAIT_FOR_INTRO_TEXT, - STATE_TRAINER_SEND_OUT_TEXT, - STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT, - STATE_TRAINER_1_SEND_OUT_ANIM, - STATE_TRAINER_2_SEND_OUT_ANIM, - STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM, - STATE_WAIT_FOR_WILD_BATTLE_TEXT, - STATE_PRINT_PLAYER_SEND_OUT_TEXT, - STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT, - STATE_PRINT_PLAYER_1_SEND_OUT_TEXT, - STATE_PRINT_PLAYER_2_SEND_OUT_TEXT, - STATE_SET_DEX_AND_BATTLE_VARS + BATTLE_INTRO_STATE_GET_MON_DATA, + BATTLE_INTRO_STATE_LOOP_BATTLER_DATA, + BATTLE_INTRO_STATE_PREPARE_BG_SLIDE, + BATTLE_INTRO_STATE_WAIT_FOR_BG_SLIDE, + BATTLE_INTRO_STATE_DRAW_SPRITES, + BATTLE_INTRO_STATE_DRAW_PARTY_SUMMARY, + BATTLE_INTRO_STATE_WAIT_FOR_PARTY_SUMMARY, + BATTLE_INTRO_STATE_INTRO_TEXT, + BATTLE_INTRO_STATE_WAIT_FOR_INTRO_TEXT, + BATTLE_INTRO_STATE_TRAINER_SEND_OUT_TEXT, + BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT, + BATTLE_INTRO_STATE_TRAINER_1_SEND_OUT_ANIM, + BATTLE_INTRO_STATE_TRAINER_2_SEND_OUT_ANIM, + BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM, + BATTLE_INTRO_STATE_WAIT_FOR_WILD_BATTLE_TEXT, + BATTLE_INTRO_STATE_PRINT_PLAYER_SEND_OUT_TEXT, + BATTLE_INTRO_STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT, + BATTLE_INTRO_STATE_PRINT_PLAYER_1_SEND_OUT_TEXT, + BATTLE_INTRO_STATE_PRINT_PLAYER_2_SEND_OUT_TEXT, + BATTLE_INTRO_STATE_SET_DEX_AND_BATTLE_VARS }; struct BattleStruct diff --git a/src/battle_main.c b/src/battle_main.c index d9f253aef772..72b2f0838aad 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3428,22 +3428,22 @@ static void DoBattleIntro(void) switch (gBattleStruct->introState) { - case STATE_GET_MON_DATA: + case BATTLE_INTRO_STATE_GET_MON_DATA: battler = gBattleCommunication[1]; BtlController_EmitGetMonData(battler, BUFFER_A, REQUEST_ALL_BATTLE, 0); MarkBattlerForControllerExec(battler); gBattleStruct->introState++; break; - case STATE_LOOP_BATTLER_DATA: + case BATTLE_INTRO_STATE_LOOP_BATTLER_DATA: if (!gBattleControllerExecFlags) { if (++gBattleCommunication[1] == gBattlersCount) gBattleStruct->introState++; else - gBattleStruct->introState = STATE_GET_MON_DATA; + gBattleStruct->introState = BATTLE_INTRO_STATE_GET_MON_DATA; } break; - case STATE_PREPARE_BG_SLIDE: + case BATTLE_INTRO_STATE_PREPARE_BG_SLIDE: if (!gBattleControllerExecFlags) { battler = GetBattlerAtPosition(0); @@ -3454,11 +3454,11 @@ static void DoBattleIntro(void) gBattleStruct->introState++; } break; - case STATE_WAIT_FOR_BG_SLIDE: + case BATTLE_INTRO_STATE_WAIT_FOR_BG_SLIDE: if (!gBattleControllerExecFlags) gBattleStruct->introState++; break; - case STATE_DRAW_SPRITES: + case BATTLE_INTRO_STATE_DRAW_SPRITES: for (battler = 0; battler < gBattlersCount; battler++) { if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && GetBattlerSide(battler) == B_SIDE_PLAYER) @@ -3543,12 +3543,12 @@ static void DoBattleIntro(void) else // Skip party summary since it is a wild battle. { if (B_FAST_INTRO == TRUE) - gBattleStruct->introState = STATE_INTRO_TEXT; // Don't wait for sprite, print message at the same time. + gBattleStruct->introState = BATTLE_INTRO_STATE_INTRO_TEXT; // Don't wait for sprite, print message at the same time. else - gBattleStruct->introState = STATE_WAIT_FOR_PARTY_SUMMARY; // Wait for sprite to load. + gBattleStruct->introState++; // Wait for sprite to load. } break; - case STATE_DRAW_PARTY_SUMMARY: + case BATTLE_INTRO_STATE_DRAW_PARTY_SUMMARY: if (!gBattleControllerExecFlags) { struct HpAndStatus hpStatus[PARTY_SIZE]; @@ -3594,18 +3594,18 @@ static void DoBattleIntro(void) gBattleStruct->introState++; } break; - case STATE_WAIT_FOR_PARTY_SUMMARY: + case BATTLE_INTRO_STATE_WAIT_FOR_PARTY_SUMMARY: if (!gBattleControllerExecFlags) gBattleStruct->introState++; break; - case STATE_INTRO_TEXT: + case BATTLE_INTRO_STATE_INTRO_TEXT: if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) { PrepareStringBattle(STRINGID_INTROMSG, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); gBattleStruct->introState++; } break; - case STATE_WAIT_FOR_INTRO_TEXT: + case BATTLE_INTRO_STATE_WAIT_FOR_INTRO_TEXT: if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) { if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) @@ -3615,24 +3615,24 @@ static void DoBattleIntro(void) else { if (B_FAST_INTRO == TRUE) - gBattleStruct->introState = STATE_WAIT_FOR_WILD_BATTLE_TEXT; + gBattleStruct->introState = BATTLE_INTRO_STATE_WAIT_FOR_WILD_BATTLE_TEXT; else - gBattleStruct->introState = STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM; + gBattleStruct->introState = BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM; } } break; - case STATE_TRAINER_SEND_OUT_TEXT: + case BATTLE_INTRO_STATE_TRAINER_SEND_OUT_TEXT: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)); else PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)); gBattleStruct->introState++; break; - case STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT: + case BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_SEND_OUT_TEXT: if (!gBattleControllerExecFlags) gBattleStruct->introState++; break; - case STATE_TRAINER_1_SEND_OUT_ANIM: + case BATTLE_INTRO_STATE_TRAINER_1_SEND_OUT_ANIM: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) battler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); else @@ -3642,7 +3642,7 @@ static void DoBattleIntro(void) MarkBattlerForControllerExec(battler); gBattleStruct->introState++; break; - case STATE_TRAINER_2_SEND_OUT_ANIM: + case BATTLE_INTRO_STATE_TRAINER_2_SEND_OUT_ANIM: if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3655,19 +3655,19 @@ static void DoBattleIntro(void) } if (B_FAST_INTRO == TRUE && !(gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_RECORDED_LINK | BATTLE_TYPE_RECORDED_IS_MASTER | BATTLE_TYPE_LINK))) - gBattleStruct->introState = STATE_WAIT_FOR_WILD_BATTLE_TEXT; // Print at the same time as trainer sends out second mon. + gBattleStruct->introState = BATTLE_INTRO_STATE_WAIT_FOR_WILD_BATTLE_TEXT; // Print at the same time as trainer sends out second mon. else gBattleStruct->introState++; break; - case STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM: + case BATTLE_INTRO_STATE_WAIT_FOR_TRAINER_2_SEND_OUT_ANIM: if (!gBattleControllerExecFlags) gBattleStruct->introState++; break; - case STATE_WAIT_FOR_WILD_BATTLE_TEXT: + case BATTLE_INTRO_STATE_WAIT_FOR_WILD_BATTLE_TEXT: if (!IsBattlerMarkedForControllerExec(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) gBattleStruct->introState++; break; - case STATE_PRINT_PLAYER_SEND_OUT_TEXT: + case BATTLE_INTRO_STATE_PRINT_PLAYER_SEND_OUT_TEXT: if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3688,7 +3688,7 @@ static void DoBattleIntro(void) } gBattleStruct->introState++; break; - case STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT: + case BATTLE_INTRO_STATE_WAIT_FOR_PLAYER_SEND_OUT_TEXT: if (!(gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleControllerExecFlags)) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3700,7 +3700,7 @@ static void DoBattleIntro(void) gBattleStruct->introState++; } break; - case STATE_PRINT_PLAYER_1_SEND_OUT_TEXT: + case BATTLE_INTRO_STATE_PRINT_PLAYER_1_SEND_OUT_TEXT: if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else @@ -3710,7 +3710,7 @@ static void DoBattleIntro(void) MarkBattlerForControllerExec(battler); gBattleStruct->introState++; break; - case STATE_PRINT_PLAYER_2_SEND_OUT_TEXT: + case BATTLE_INTRO_STATE_PRINT_PLAYER_2_SEND_OUT_TEXT: if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)) { if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK && !(gBattleTypeFlags & BATTLE_TYPE_RECORDED_IS_MASTER)) @@ -3723,7 +3723,7 @@ static void DoBattleIntro(void) } gBattleStruct->introState++; break; - case STATE_SET_DEX_AND_BATTLE_VARS: + case BATTLE_INTRO_STATE_SET_DEX_AND_BATTLE_VARS: if (!gBattleControllerExecFlags) { for (battler = 0; battler < gBattlersCount; battler++)