From 9a798b01379d601db2586e74b71a8d4bed05079e Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Sat, 31 May 2025 15:22:54 -0400 Subject: [PATCH] Use offsets from `ANIM_*` constants for `wBattleAfterAnim` (formerly `wNumHits`) --- constants/move_constants.asm | 14 +---- engine/battle/core.asm | 24 ++++----- engine/battle/effect_commands.asm | 58 ++++++++++----------- engine/battle/move_effects/selfdestruct.asm | 4 +- engine/battle/move_effects/substitute.asm | 2 +- engine/battle/move_effects/teleport.asm | 2 +- engine/battle/move_effects/transform.asm | 4 +- engine/battle_anims/anim_commands.asm | 14 ++--- engine/items/item_effects.asm | 4 +- ram/wram.asm | 2 +- 10 files changed, 59 insertions(+), 69 deletions(-) diff --git a/constants/move_constants.asm b/constants/move_constants.asm index 6e79b2e4..2d4b4313 100644 --- a/constants/move_constants.asm +++ b/constants/move_constants.asm @@ -278,7 +278,8 @@ DEF CANNOT_MOVE EQU $ff const ANIM_IN_SANDSTORM ; 10b const ANIM_IN_NIGHTMARE ; 10c const ANIM_IN_WHIRLPOOL ; 10d -; battle anims +; wBattleAfterAnim uses offsets from BATTLE_AFTERANIMS +DEF BATTLE_AFTERANIMS EQU const_value const ANIM_MISS ; 10e const ANIM_ENEMY_DAMAGE ; 10f const ANIM_ENEMY_STAT_DOWN ; 110 @@ -288,14 +289,3 @@ DEF CANNOT_MOVE EQU $ff const ANIM_SHAKE ; 114 const ANIM_HIT_CONFUSION ; 115 DEF NUM_BATTLE_ANIMS EQU const_value - 1 - -; wNumHits uses offsets from ANIM_MISS - const_def - const BATTLEANIM_NONE - const BATTLEANIM_ENEMY_DAMAGE - const BATTLEANIM_ENEMY_STAT_DOWN - const BATTLEANIM_PLAYER_STAT_DOWN - const BATTLEANIM_PLAYER_DAMAGE - const BATTLEANIM_WOBBLE - const BATTLEANIM_SHAKE - const BATTLEANIM_HIT_CONFUSION diff --git a/engine/battle/core.asm b/engine/battle/core.asm index e880e995..ae0d8f10 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -367,7 +367,7 @@ HandleBerserkGene: bit SUBSTATUS_CONFUSED, a ret nz xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_CONFUSED call Call_PlayBattleAnim_OnlyIfVisible call SwitchTurnCore @@ -972,7 +972,7 @@ ResidualDamage: pop de xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a call Call_PlayBattleAnim_OnlyIfVisible call GetEighthMaxHP ld de, wPlayerToxicCount @@ -1012,7 +1012,7 @@ ResidualDamage: call SwitchTurnCore xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_SAP ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar @@ -1037,7 +1037,7 @@ ResidualDamage: bit SUBSTATUS_NIGHTMARE, [hl] jr z, .not_nightmare xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_IN_NIGHTMARE call Call_PlayBattleAnim_OnlyIfVisible call GetQuarterMaxHP @@ -1055,7 +1055,7 @@ ResidualDamage: jr z, .not_cursed xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_IN_NIGHTMARE call Call_PlayBattleAnim_OnlyIfVisible call GetQuarterMaxHP @@ -1197,7 +1197,7 @@ HandleWrap: call SwitchTurnCore xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a predef PlayBattleAnim call SwitchTurnCore @@ -1687,7 +1687,7 @@ HandleWeather: call SwitchTurnCore xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_IN_SANDSTORM call Call_PlayBattleAnim call SwitchTurnCore @@ -3358,7 +3358,7 @@ ShowSetEnemyMonAndSendOutAnimation: call GetEnemyMonFrontpic xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wBattleAnimParam], a call SetEnemyTurn ld de, ANIM_SEND_OUT_MON @@ -3815,7 +3815,7 @@ SendOutPlayerMon: ld [wEnemyWrapCount], a call SetPlayerTurn xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wBattleAnimParam], a ld de, ANIM_SEND_OUT_MON call Call_PlayBattleAnim @@ -3995,7 +3995,7 @@ RecallPlayerMon: push af xor a ldh [hBattleTurn], a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_RETURN_MON call Call_PlayBattleAnim pop af @@ -4127,7 +4127,7 @@ ItemRecoveryAnim: ld [wFXAnimID], a call SwitchTurnCore xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a predef PlayBattleAnim call SwitchTurnCore @@ -8700,7 +8700,7 @@ BattleStartMessage: jr nc, .not_shiny xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld a, 1 ldh [hBattleTurn], a ld a, 1 diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index ecac2ea5..77e826b8 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -167,7 +167,7 @@ BattleCommand_CheckTurn: jr z, .woke_up xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_SLP call FarPlayBattleAnimation jr .fast_asleep @@ -267,7 +267,7 @@ BattleCommand_CheckTurn: ld hl, IsConfusedText call StdBattleTextbox xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_CONFUSED call FarPlayBattleAnimation @@ -295,7 +295,7 @@ BattleCommand_CheckTurn: ld hl, InLoveWithText call StdBattleTextbox xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_IN_LOVE call FarPlayBattleAnimation @@ -398,7 +398,7 @@ CheckEnemyTurn: ld hl, FastAsleepText call StdBattleTextbox xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_SLP call FarPlayBattleAnimation jr .fast_asleep @@ -496,7 +496,7 @@ CheckEnemyTurn: call StdBattleTextbox xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_CONFUSED call FarPlayBattleAnimation @@ -519,7 +519,7 @@ CheckEnemyTurn: call BattleCommand_LowerSub xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ; Flicker the monster pic unless flying or underground. ld de, ANIM_HIT_CONFUSION @@ -543,7 +543,7 @@ CheckEnemyTurn: ld hl, InLoveWithText call StdBattleTextbox xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld de, ANIM_IN_LOVE call FarPlayBattleAnimation @@ -622,7 +622,7 @@ HitConfusion: call BattleCommand_LowerSub xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ; Flicker the monster pic unless flying or underground. ld de, ANIM_HIT_CONFUSION @@ -1920,7 +1920,7 @@ BattleCommand_LowerSub: jr c, .mimic_anims xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a inc a ld [wBattleAnimParam], a @@ -1963,13 +1963,13 @@ BattleCommand_MoveAnimNoSub: ldh a, [hBattleTurn] and a ld de, wPlayerRolloutCount - ld a, BATTLEANIM_ENEMY_DAMAGE + ld a, ANIM_ENEMY_DAMAGE - BATTLE_AFTERANIMS jr z, .got_rollout_count ld de, wEnemyRolloutCount - ld a, BATTLEANIM_PLAYER_DAMAGE + ld a, ANIM_PLAYER_DAMAGE - BATTLE_AFTERANIMS .got_rollout_count - ld [wNumHits], a + ld [wBattleAfterAnim], a ld a, BATTLE_VARS_MOVE_EFFECT call GetBattleVar cp EFFECT_MULTI_HIT @@ -2016,7 +2016,7 @@ BattleCommand_MoveAnimNoSub: pop af jp z, PlayFXAnimID xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a jp PlayFXAnimID BattleCommand_StatUpAnim: @@ -2034,14 +2034,14 @@ BattleCommand_StatDownAnim: ldh a, [hBattleTurn] and a - ld a, BATTLEANIM_ENEMY_STAT_DOWN + ld a, ANIM_ENEMY_STAT_DOWN - BATTLE_AFTERANIMS jr z, BattleCommand_StatUpDownAnim - ld a, BATTLEANIM_WOBBLE + ld a, ANIM_WOBBLE - BATTLE_AFTERANIMS ; fallthrough BattleCommand_StatUpDownAnim: - ld [wNumHits], a + ld [wBattleAfterAnim], a xor a ld [wBattleAnimParam], a ld a, BATTLE_VARS_MOVE_ANIM @@ -2068,7 +2068,7 @@ BattleCommand_RaiseSub: jp c, BattleCommand_RaiseSubNoAnim xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a ld a, $2 ld [wBattleAnimParam], a @@ -2401,7 +2401,7 @@ BattleCommand_CheckFaint: call BattleCommand_SwitchTurn xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a inc a ld [wBattleAnimParam], a @@ -3894,7 +3894,7 @@ SapHealth: BattleCommand_BurnTarget: xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a call CheckSubstituteOpp ret nz ld a, BATTLE_VARS_STATUS_OPP @@ -3958,7 +3958,7 @@ Defrost: BattleCommand_FreezeTarget: xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a call CheckSubstituteOpp ret nz ld a, BATTLE_VARS_STATUS_OPP @@ -4009,7 +4009,7 @@ BattleCommand_FreezeTarget: BattleCommand_ParalyzeTarget: xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a call CheckSubstituteOpp ret nz ld a, BATTLE_VARS_STATUS_OPP @@ -4947,7 +4947,7 @@ BattleCommand_ForceSwitch: .wild_force_flee call UpdateBattleMonInParty xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a inc a ; TRUE ld [wForcedSwitch], a inc a ; DRAW @@ -5041,7 +5041,7 @@ BattleCommand_ForceSwitch: .wild_succeed_playeristarget call UpdateBattleMonInParty xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a inc a ; TRUE ld [wForcedSwitch], a inc a ; DRAW @@ -5453,7 +5453,7 @@ BattleCommand_Charge: call BattleCommand_LowerSub xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a inc a ld [wBattleAnimParam], a call LoadMoveAnim @@ -6591,18 +6591,18 @@ PlayDamageAnim: ldh a, [hBattleTurn] and a - ld a, BATTLEANIM_ENEMY_DAMAGE + ld a, ANIM_ENEMY_DAMAGE - BATTLE_AFTERANIMS jr z, .player - ld a, BATTLEANIM_PLAYER_DAMAGE + ld a, ANIM_PLAYER_DAMAGE - BATTLE_AFTERANIMS .player - ld [wNumHits], a + ld [wBattleAfterAnim], a jp PlayUserBattleAnim LoadMoveAnim: xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a ld a, BATTLE_VARS_MOVE_ANIM @@ -6633,7 +6633,7 @@ PlayOpponentBattleAnim: ld a, d ld [wFXAnimID + 1], a xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a push hl push de diff --git a/engine/battle/move_effects/selfdestruct.asm b/engine/battle/move_effects/selfdestruct.asm index 61bf9665..657462a0 100644 --- a/engine/battle/move_effects/selfdestruct.asm +++ b/engine/battle/move_effects/selfdestruct.asm @@ -1,6 +1,6 @@ BattleCommand_Selfdestruct: - ld a, BATTLEANIM_PLAYER_DAMAGE - ld [wNumHits], a + ld a, ANIM_PLAYER_DAMAGE - BATTLE_AFTERANIMS + ld [wBattleAfterAnim], a ld c, 3 call DelayFrames ld a, BATTLE_VARS_STATUS diff --git a/engine/battle/move_effects/substitute.asm b/engine/battle/move_effects/substitute.asm index d8319c1e..0a2ef832 100644 --- a/engine/battle/move_effects/substitute.asm +++ b/engine/battle/move_effects/substitute.asm @@ -60,7 +60,7 @@ BattleCommand_Substitute: jr c, .no_anim xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a ld [wBattleAnimParam], a ld a, SUBSTITUTE diff --git a/engine/battle/move_effects/teleport.asm b/engine/battle/move_effects/teleport.asm index ddd93042..7dec5c81 100644 --- a/engine/battle/move_effects/teleport.asm +++ b/engine/battle/move_effects/teleport.asm @@ -75,7 +75,7 @@ BattleCommand_Teleport: .run_away call UpdateBattleMonInParty xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a inc a ld [wForcedSwitch], a ; set battle draw diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index b481bc5d..65969a9a 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -7,7 +7,7 @@ BattleCommand_Transform: call CheckHiddenOpponent jp nz, BattleEffect_ButItFailed xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a ld a, $1 ld [wBattleAnimParam], a @@ -127,7 +127,7 @@ BattleCommand_Transform: call BattleCommand_RaiseSubNoAnim .after_anim xor a - ld [wNumHits], a + ld [wBattleAfterAnim], a ld [wFXAnimID + 1], a ld a, $2 ld [wBattleAnimParam], a diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm index 35fc3d1a..1ef549fe 100644 --- a/engine/battle_anims/anim_commands.asm +++ b/engine/battle_anims/anim_commands.asm @@ -33,7 +33,7 @@ PlayBattleAnim: BattleAnimRunScript: ld a, [wFXAnimID + 1] and a - jr nz, .hi_byte + jr nz, .not_move ld a, [wOptions] bit BATTLE_SCENE, a @@ -53,20 +53,20 @@ BattleAnimRunScript: call BattleAnimRestoreHuds .disabled - ld a, [wNumHits] + ld a, [wBattleAfterAnim] and a jr z, .done ld l, a ld h, 0 - ld de, ANIM_MISS + ld de, BATTLE_AFTERANIMS add hl, de ld a, l ld [wFXAnimID], a ld a, h ld [wFXAnimID + 1], a -.hi_byte +.not_move call WaitSFX call PlayHitSound call RunBattleAnimScript @@ -1198,10 +1198,10 @@ endr dw $0000, $0000 PlayHitSound: - ld a, [wNumHits] - cp BATTLEANIM_ENEMY_DAMAGE + ld a, [wBattleAfterAnim] + cp ANIM_ENEMY_DAMAGE - BATTLE_AFTERANIMS jr z, .okay - cp BATTLEANIM_PLAYER_DAMAGE + cp ANIM_PLAYER_DAMAGE - BATTLE_AFTERANIMS ret nz .okay diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index b61949b6..05453d4d 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -407,7 +407,7 @@ PokeBallEffect: xor a ldh [hBattleTurn], a ld [wThrownBallWobbleCount], a - ld [wNumHits], a + ld [wBattleAfterAnim], a predef PlayBattleAnim ld a, [wWildMon] @@ -2585,7 +2585,7 @@ UseBallInTrainerBattle: xor a ld [wBattleAnimParam], a ldh [hBattleTurn], a - ld [wNumHits], a + ld [wBattleAfterAnim], a predef PlayBattleAnim ld hl, BallBlockedText call PrintText diff --git a/ram/wram.asm b/ram/wram.asm index 22236d73..5ff61908 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -1711,7 +1711,7 @@ wBGP:: db wOBP0:: db wOBP1:: db -wNumHits:: db +wBattleAfterAnim:: db ds 1