diff --git a/battle/anim_commands.asm b/battle/anim_commands.asm index 96bd1c45b..839449d19 100644 --- a/battle/anim_commands.asm +++ b/battle/anim_commands.asm @@ -40,7 +40,7 @@ _PlayBattleAnim: ; cc0e4 push af ld [hl], c - call Functioncc11c + call BattleAnimRunScript pop af ld [hVBlank], a @@ -55,17 +55,17 @@ _PlayBattleAnim: ; cc0e4 ret ; cc11c -Functioncc11c: ; cc11c +BattleAnimRunScript: ; cc11c ld a, [FXAnimIDHi] and a - jr nz, .asm_cc156 + jr nz, .hi_byte callba CheckBattleScene - jr c, .asm_cc141 + jr c, .disabled call BattleAnimClearHud - call Functioncc163 + call RunBattleAnimScript call BattleAnimAssignPals call BattleAnimRequestPals @@ -76,31 +76,31 @@ Functioncc11c: ; cc11c call BattleAnimDelayFrame call BattleAnimRestoreHuds -.asm_cc141 +.disabled ld a, [wcfca] and a - jr z, .asm_cc15f + jr z, .done ld l, a ld h, 0 - ld de, $10e + ld de, ANIM_MISS add hl, de ld a, l ld [FXAnimIDLo], a ld a, h ld [FXAnimIDHi], a -.asm_cc156 +.hi_byte call WaitSFX call Functioncc881 - call Functioncc163 + call RunBattleAnimScript -.asm_cc15f +.done call Functioncc8f6 ret ; cc163 -Functioncc163: ; cc163 +RunBattleAnimScript: ; cc163 call Functioncc8d3 @@ -257,11 +257,11 @@ Functioncc23d: ; cc23d ld a, [BattleAnimFlags] bit 3, a - jr z, .asm_cc254 + jr z, .skip ld hl, Sprites + 3 ld c, (SpritesEnd - Sprites) / 4 -.asm_cc249 +.loop ld a, [hl] and $f0 ld [hli], a @@ -269,71 +269,71 @@ rept 3 inc hl endr dec c - jr nz, .asm_cc249 + jr nz, .loop ret -.asm_cc254 +.skip ld hl, Sprites ld c, SpritesEnd - Sprites xor a -.asm_cc25a +.loop2 ld [hli], a dec c - jr nz, .asm_cc25a + jr nz, .loop2 ret ; cc25f Functioncc25f: ; cc25f - call Functioncc267 + call .CheckTimer ret nc - call Functioncc275 + call .RunScript ret ; cc267 -Functioncc267: ; cc267 +.CheckTimer: ; cc267 ld a, [BattleAnimDuration] and a - jr z, .asm_cc273 + jr z, .done dec a ld [BattleAnimDuration], a and a ret -.asm_cc273 +.done scf ret ; cc275 -Functioncc275: ; cc275 - +.RunScript: ; cc275 +.loop call GetBattleAnimByte cp $ff - jr nz, .asm_cc286 + jr nz, .not_done_with_anim ; Return from a subroutine. ld hl, BattleAnimFlags bit 1, [hl] - jr nz, .asm_cc28e + jr nz, .do_anim set 0, [hl] ret -.asm_cc286 +.not_done_with_anim cp $d0 - jr nc, .asm_cc28e + jr nc, .do_anim ld [BattleAnimDuration], a ret -.asm_cc28e - call Functioncc293 +.do_anim + call .DoCommand - jr Functioncc275 + jr .loop ; cc293 -Functioncc293: ; cc293 +.DoCommand: ; cc293 ; Execute battle animation command in [BattleAnimByte]. ld a, [BattleAnimByte] sub $d0 @@ -1332,11 +1332,11 @@ Datacc871: ; cc871 Functioncc881: ; cc881 ld a, [wcfca] cp $1 - jr z, .asm_cc88b + jr z, .okay cp $4 ret nz -.asm_cc88b +.okay ld a, [TypeModifier] and $7f ret z @@ -1358,41 +1358,43 @@ Functioncc881: ; cc881 BattleAnimAssignPals: ; cc8a4 ld a, [hCGB] and a - jr nz, .asm_cc8be + jr nz, .cgb ld a, [hSGB] and a - ld a, $e0 - jr z, .asm_cc8b2 - ld a, $f0 + ld a, %11100000 + jr z, .sgb + ld a, %11110000 -.asm_cc8b2 +.sgb ld [wcfc8], a - ld a, $e4 + ld a, %11100100 ld [wcfc7], a ld [wcfc9], a ret -.asm_cc8be - ld a, $e4 +.cgb + ld a, %11100100 ld [wcfc7], a ld [wcfc8], a ld [wcfc9], a call DmgToCgbBGPals - ld de, $e4e4 + lb de, %11100100, %11100100 call DmgToCgbObjPals ret ; cc8d3 Functioncc8d3: ; cc8d3 +; Clear animation block ld hl, LYOverrides - ld bc, $0354 -.asm_cc8d9 + ld bc, wBattleAnimEnd - LYOverrides +.loop ld [hl], $0 inc hl dec bc ld a, c or b - jr nz, .asm_cc8d9 + jr nz, .loop + ld hl, FXAnimIDLo ld e, [hl] inc hl @@ -1401,7 +1403,7 @@ Functioncc8d3: ; cc8d3 rept 2 add hl, de endr - call Function3ae1 + call GetBattleAnimPointer call BattleAnimAssignPals call BattleAnimDelayFrame ret @@ -1409,12 +1411,12 @@ endr Functioncc8f6: ; cc8f6 call WaitTop - ld a, $e4 + ld a, %11100100 ld [wcfc7], a ld [wcfc8], a ld [wcfc9], a call DmgToCgbBGPals - ld de, $e4e4 + lb de, %11100100, %11100100 call DmgToCgbObjPals xor a ld [hSCX], a diff --git a/battle/anims.asm b/battle/anims.asm index 0f3ba748b..51b3448b2 100644 --- a/battle/anims.asm +++ b/battle/anims.asm @@ -255,6 +255,7 @@ BattleAnimations:: ; c906f dw BattleAnim_253 dw BattleAnim_254 dw BattleAnim_SweetScent2 +; $100 dw BattleAnim_ThrowPokeBall dw BattleAnim_SendOutMon dw BattleAnim_ReturnMon diff --git a/battle/core.asm b/battle/core.asm index 0cfb585bf..c44400baa 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -2022,7 +2022,7 @@ Function3ccc2: ; 3ccc2 ret ; 3ccde -Function3ccde: ; 3ccde +CheckUserHasEnoughHP: ; 3ccde ld hl, BattleMonHP + 1 ld a, [hBattleTurn] and a @@ -3740,7 +3740,7 @@ Function3d7a0: ; 3d7a0 lb bc, 4, 10 call ClearBox call WaitBGMap - jp Function3ee27 + jp FinishBattleAnim ; 3d7b8 Function_BattleTextEnemySentOut: ; 3d7b8 @@ -4253,7 +4253,7 @@ SendOutPlayerMon: ; 3db5f ld [hBGMapMode], a call GetMonBackpic xor a - ld [$ffad], a + ld [hFillBox], a ld [wd0d2], a ld [CurMoveNum], a ld [TypeModifier], a @@ -4262,7 +4262,7 @@ SendOutPlayerMon: ; 3db5f ld [LastPlayerCounterMove], a ld [LastPlayerMove], a call CheckAmuletCoin - call Function3ee27 + call FinishBattleAnim xor a ld [wEnemyWrapCount], a call SetPlayerTurn @@ -5132,7 +5132,7 @@ Function3e12e: ; 3e12e ld a, [hl] cp b ret z - jp Function3ee27 + jp FinishBattleAnim ; 3e138 Function3e138: ; 3e138 @@ -5269,7 +5269,7 @@ BattleMenu_Pack: ; 3e1c7 call GetMonFrontpic call ExitMenu call WaitBGMap - call Function3ee27 + call FinishBattleAnim call LoadTileMapToTempTileMap jp BattleMenu ; 3e22b @@ -5309,7 +5309,7 @@ Function3e234: ; 3e234 call WaitBGMap call LoadTileMapToTempTileMap call ResetTextRelatedRAM - call Function3ee27 + call FinishBattleAnim and a ret @@ -6873,7 +6873,7 @@ Function3ebc7: ; 3ebc7 Function3ebd8: ; 3ebd8 xor a ld [TempEnemyMonSpecies], a - call Function3ee27 + call FinishBattleAnim ld a, [OtherTrainerClass] ld [TrainerClass], a ld de, VTiles2 @@ -7368,7 +7368,7 @@ Call_PlayBattleAnim: ; 3ee17 predef_jump PlayBattleAnim ; 3ee27 -Function3ee27: ; 3ee27 +FinishBattleAnim: ; 3ee27 push af push bc push de @@ -8377,7 +8377,7 @@ GetMonBackpic: ; 3f43d ld a, [PlayerSubStatus4] bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_DD - jr nz, Function3f46f + jr nz, Function3f46f ; substitute Function3f447: ; 3f447 ld a, [wc6fe] @@ -8576,7 +8576,7 @@ InitEnemyTrainer: ; 3f594 ld de, VTiles2 callab GetTrainerPic xor a - ld [$ffad], a + ld [hFillBox], a dec a ld [wc6e6], a hlcoord 12, 0 @@ -8641,7 +8641,7 @@ InitEnemyWildmon: ; 3f607 predef Function5108b xor a ld [TrainerClass], a - ld [$ffad], a + ld [hFillBox], a hlcoord 12, 0 lb bc, 7, 7 predef FillBox @@ -9400,7 +9400,7 @@ Function3fb6c: ; 3fb6c ld a, $1 ld [hBGMapMode], a ld a, $31 - ld [$ffad], a + ld [hFillBox], a hlcoord 2, 6 lb bc, 6, 6 predef FillBox @@ -9494,7 +9494,7 @@ CopyBackpic: ; 3fc30 ld [rSVBK], a call Function3fc5b ld a, $31 - ld [$ffad], a + ld [hFillBox], a hlcoord 2, 6 lb bc, 6, 6 predef FillBox diff --git a/battle/effect_command_pointers.asm b/battle/effect_command_pointers.asm index e0735b2ea..1113f968f 100644 --- a/battle/effect_command_pointers.asm +++ b/battle/effect_command_pointers.asm @@ -13,7 +13,7 @@ BattleCommandPointers: ; 3fd28 dw BattleCommand_LowerSub ; 34eee dw BattleCommand_HitTargetNoSub ; 34f60 dw BattleCommand_RaiseSub ; 35004 - dw BattleCommand_ResultText ; 35023 + dw BattleCommand_FailureText ; 35023 dw BattleCommand_CheckFaint ; 3505e dw BattleCommand_CriticalText ; 35175 dw BattleCommand_SuperEffectiveText ; 351ad diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 37e13d0bc..d31e635b3 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -30,12 +30,12 @@ DoTurn: ; 3401d ; Read in and execute the user's move effects for this turn. xor a - ld [wc6b4], a + ld [wTurnEnded], a ; Effect command checkturn is called for every move. call CheckTurn - ld a, [wc6b4] + ld a, [wTurnEnded] and a ret nz @@ -128,7 +128,7 @@ BattleCommand_CheckTurn: ; 34084 ld a, BATTLE_VARS_MOVE call GetBattleVar inc a - jp z, Function34385 + jp z, EndTurn xor a ld [AttackMissed], a @@ -156,7 +156,7 @@ CheckPlayerTurn: ld hl, MustRechargeText call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn .no_recharge @@ -185,7 +185,7 @@ CheckPlayerTurn: ld hl, UpdatePlayerHUD call CallBattleCore ld a, $1 - ld [$ffd4], a + ld [hBGMapMode], a ld hl, PlayerSubStatus1 res SUBSTATUS_NIGHTMARE, [hl] jr .not_asleep @@ -202,7 +202,7 @@ CheckPlayerTurn: jr z, .not_asleep call CantMove - jp Function34385 + jp EndTurn .not_asleep @@ -222,7 +222,7 @@ CheckPlayerTurn: call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn .not_frozen @@ -236,7 +236,7 @@ CheckPlayerTurn: call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn .not_flinched @@ -293,7 +293,7 @@ CheckPlayerTurn: call HitConfusion call CantMove - jp Function34385 + jp EndTurn .not_confused @@ -317,7 +317,7 @@ CheckPlayerTurn: ld hl, InfatuationText call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn .not_infatuated @@ -334,7 +334,7 @@ CheckPlayerTurn: call MoveDisabled call CantMove - jp Function34385 + jp EndTurn .no_disabled_move @@ -351,7 +351,7 @@ CheckPlayerTurn: ld hl, FullyParalyzedText call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn ; 341f0 @@ -379,7 +379,7 @@ CantMove: ; 341f0 .fly_dig res SUBSTATUS_UNDERGROUND, [hl] res SUBSTATUS_FLYING, [hl] - jp Function37ece + jp AppearUserRaiseSub ; 34216 @@ -402,7 +402,7 @@ CheckEnemyTurn: ; 3421f ld hl, MustRechargeText call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn .no_recharge @@ -433,7 +433,7 @@ CheckEnemyTurn: ; 3421f ld hl, UpdateEnemyHUD call CallBattleCore ld a, $1 - ld [$ffd4], a + ld [hBGMapMode], a ld hl, EnemySubStatus1 res SUBSTATUS_NIGHTMARE, [hl] jr .not_asleep @@ -446,7 +446,7 @@ CheckEnemyTurn: ; 3421f cp SLEEP_TALK jr z, .not_asleep call CantMove - jp Function34385 + jp EndTurn .not_asleep @@ -463,7 +463,7 @@ CheckEnemyTurn: ; 3421f ld hl, FrozenSolidText call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn .not_frozen @@ -477,7 +477,7 @@ CheckEnemyTurn: ; 3421f call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn .not_flinched @@ -527,7 +527,7 @@ CheckEnemyTurn: ; 3421f ; 50% chance of hitting itself call BattleRandom - cp $80 + cp 1 + 50 percent jr nc, .not_confused ; clear confusion-dependent substatus @@ -538,7 +538,7 @@ CheckEnemyTurn: ; 3421f ld hl, HurtItselfText call StdBattleTextBox - call Function355dd + call HitSelfInConfusion call BattleCommand_DamageCalc call BattleCommand_LowerSub xor a @@ -552,10 +552,10 @@ CheckEnemyTurn: ; 3421f call z, PlayFXAnimID ld c, $1 - call Function35d1c + call EnemyHurtItself call BattleCommand_RaiseSub call CantMove - jp Function34385 + jp EndTurn .not_confused @@ -573,13 +573,13 @@ CheckEnemyTurn: ; 3421f ; 50% chance of infatuation call BattleRandom - cp $80 + cp 1 + 50 percent jr c, .not_infatuated ld hl, InfatuationText call StdBattleTextBox call CantMove - jp Function34385 + jp EndTurn .not_infatuated @@ -597,7 +597,7 @@ CheckEnemyTurn: ; 3421f call MoveDisabled call CantMove - jp Function34385 + jp EndTurn .no_disabled_move @@ -619,9 +619,9 @@ CheckEnemyTurn: ; 3421f ; 34385 -Function34385: ; 34385 +EndTurn: ; 34385 ld a, $1 - ld [wc6b4], a + ld [wTurnEnded], a jp ResetDamage ; 3438d @@ -651,7 +651,7 @@ HitConfusion: ; 343a5 xor a ld [CriticalHit], a - call Function355dd + call HitSelfInConfusion call BattleCommand_DamageCalc call BattleCommand_LowerSub @@ -668,9 +668,9 @@ HitConfusion: ; 343a5 ld hl, UpdatePlayerHUD call CallBattleCore ld a, $1 - ld [$ffd4], a + ld [hBGMapMode], a ld c, $1 - call Function35d7e + call PlayerHurtItself jp BattleCommand_RaiseSub ; 343db @@ -683,7 +683,7 @@ BattleCommand_CheckObedience: ; 343db and a ret nz - call Function34548 + call CheckUserIsCharging ret nz ; If we've already checked this turn @@ -1013,7 +1013,7 @@ BattleCommand_UsedMoveText: ; 34541 ; 34548 -Function34548: ; 34548 +CheckUserIsCharging: ; 34548 ld a, [hBattleTurn] and a @@ -1027,7 +1027,7 @@ Function34548: ; 34548 BattleCommand_DoTurn: ; 34555 - call Function34548 + call CheckUserIsCharging ret nz ld hl, BattleMonPP @@ -1079,7 +1079,7 @@ endr ld a, [CurBattleMon] jr z, .player -; skip this part entirely if wildbattle +; mimic this part entirely if wildbattle ld a, [wBattleMode] dec a jr z, .wild @@ -1090,7 +1090,7 @@ endr .player call GetPartyLocation push hl - call Function3460b + call CheckMimicUsed pop hl ret c @@ -1107,7 +1107,7 @@ endr add hl, bc ld a, [hl] and $3f - jr z, .asm_345e3 + jr z, .out_of_pp dec [hl] ld b, 0 ret @@ -1121,18 +1121,18 @@ endr ld a, [hl] cp MIMIC jr z, .mimic - ld hl, wCaughtMonMoves + ld hl, wWildMonMoves add hl, bc ld a, [hl] cp MIMIC ret z .mimic - ld hl, wCaughtMonPP + ld hl, wWildMonPP call .consume_pp ret -.asm_345e3 +.out_of_pp call BattleCommand_MoveDelay ; get move effect ld a, BATTLE_VARS_MOVE_EFFECT @@ -1165,7 +1165,7 @@ endr db $ff ; 3460b -Function3460b: ; 3460b +CheckMimicUsed: ; 3460b ld a, [hBattleTurn] and a ld a, [CurMoveNum] @@ -1174,24 +1174,24 @@ Function3460b: ; 3460b .player ld c, a - ld a, 2 + ld a, MON_MOVES call UserPartyAttr ld a, BATTLE_VARS_MOVE call GetBattleVar cp MIMIC - jr z, .asm_3462f - + jr z, .mimic +; ld b, 0 add hl, bc ld a, [hl] cp MIMIC - jr nz, .asm_3462f + jr nz, .mimic scf ret -.asm_3462f +.mimic and a ret ; 34631 @@ -2063,12 +2063,12 @@ BattleCommand_LowerSub: ; 34eee call .Rampage jr z, .charge_turn - call Function34548 + call CheckUserIsCharging ret nz .charge_turn call _CheckBattleScene - jr c, .skip_anims + jr c, .mimic_anims xor a ld [wcfca], a @@ -2076,9 +2076,9 @@ BattleCommand_LowerSub: ; 34eee inc a ld [wKickCounter], a ld a, SUBSTITUTE - jp PlayMoveAnim_KeepHiID + jp LoadAnim -.skip_anims +.mimic_anims call BattleCommand_LowerSubNoAnim jp BattleCommand_MoveDelay @@ -2119,10 +2119,10 @@ BattleCommand_HitTargetNoSub: ; 34f60 ld a, [hBattleTurn] and a ld de, PlayerRolloutCount - ld a, 1 + ld a, BATTLEANIM_ENEMY_DAMAGE jr z, .got_rollout_count ld de, EnemyRolloutCount - ld a, 4 + ld a, BATTLEANIM_PLAYER_DAMAGE .got_rollout_count ld [wcfca], a @@ -2158,7 +2158,7 @@ BattleCommand_HitTargetNoSub: ; 34f60 .fly_dig ; clear sprite - jp Function37ec7 + jp AppearUserLowerSub .multihit .conversion .doublehit @@ -2199,9 +2199,9 @@ BattleCommand_StatDownAnim: ; 34fdb ld a, [hBattleTurn] and a - ld a, 2 + ld a, BATTLEANIM_ENEMY_STAT_DOWN jr z, BattleCommand_StatUpDownAnim - ld a, 5 + ld a, BATTLEANIM_WOBBLE ; fallthrough ; 34feb @@ -2246,47 +2246,50 @@ BattleCommand_RaiseSub: ; 35004 ld a, $2 ld [wKickCounter], a ld a, SUBSTITUTE - jp PlayMoveAnim_KeepHiID + jp LoadAnim ; 35023 -BattleCommand_ResultText: ; 35023 -; resulttext +BattleCommand_FailureText: ; 35023 +; failuretext +; If the move missed or failed, load the appropriate +; text, and end the effects of multi-turn or multi- +; hit moves. ld a, [AttackMissed] and a ret z - call Function350e4 + call GetFailureResultText ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVarAddr cp FLY - jr z, .asm_3504f + jr z, .fly_dig cp DIG - jr z, .asm_3504f + jr z, .fly_dig ; Move effect: inc hl ld a, [hl] cp EFFECT_MULTI_HIT - jr z, .asm_35049 + jr z, .multihit cp EFFECT_DOUBLE_HIT - jr z, .asm_35049 + jr z, .multihit cp EFFECT_TWINEEDLE - jr z, .asm_35049 + jr z, .multihit jp EndMoveEffect -.asm_35049 +.multihit call BattleCommand_RaiseSub jp EndMoveEffect -.asm_3504f +.fly_dig ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr res SUBSTATUS_UNDERGROUND, [hl] res SUBSTATUS_FLYING, [hl] - call Function37ece + call AppearUserRaiseSub jp EndMoveEffect ; 3505e @@ -2297,50 +2300,50 @@ BattleCommand_CheckFaint: ; 3505e ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVar bit SUBSTATUS_ENDURE, a - jr z, .asm_35072 + jr z, .not_enduring call BattleCommand_FalseSwipe ld b, $0 - jr nc, .asm_3508b + jr nc, .okay ld b, $1 - jr .asm_3508b + jr .okay -.asm_35072 +.not_enduring call GetOpponentItem ld a, b cp HELD_FOCUS_BAND ld b, $0 - jr nz, .asm_3508b + jr nz, .okay call BattleRandom cp c - jr nc, .asm_3508b + jr nc, .okay call BattleCommand_FalseSwipe ld b, $0 - jr nc, .asm_3508b + jr nc, .okay ld b, $2 -.asm_3508b +.okay push bc - call .asm_50bb + call .check_sub ld c, $0 ld a, [hBattleTurn] and a - jr nz, .asm_3509b - call Function35d1c - jr .asm_3509e + jr nz, .damage_player + call EnemyHurtItself + jr .done_damage -.asm_3509b - call Function35d7e +.damage_player + call PlayerHurtItself -.asm_3509e +.done_damage pop bc ld a, b and a ret z dec a - jr nz, .asm_350ab + jr nz, .not_enduring2 ld hl, EnduredText jp StdBattleTextBox -.asm_350ab +.not_enduring2 call GetOpponentItem ld a, [hl] ld [wNamedObjectIndexBuffer], a @@ -2349,7 +2352,7 @@ BattleCommand_CheckFaint: ; 3505e ld hl, HungOnText jp StdBattleTextBox -.asm_50bb +.check_sub ld a, BATTLE_VARS_SUBSTATUS4_OPP call GetBattleVar bit SUBSTATUS_SUBSTITUTE, a @@ -2358,10 +2361,10 @@ BattleCommand_CheckFaint: ; 3505e ld de, PlayerDamageTaken + 1 ld a, [hBattleTurn] and a - jr nz, .asm_350ce + jr nz, .damage_taken ld de, EnemyDamageTaken + 1 -.asm_350ce +.damage_taken ld a, [CurDamage + 1] ld b, a ld a, [de] @@ -2382,26 +2385,26 @@ BattleCommand_CheckFaint: ; 3505e ; 350e4 -Function350e4: ; 350e4 +GetFailureResultText: ; 350e4 ld hl, DoesntAffectText ld de, DoesntAffectText ld a, [TypeModifier] and $7f - jr z, .asm_35110 + jr z, .got_text ld a, BATTLE_VARS_MOVE_EFFECT call GetBattleVar cp EFFECT_FUTURE_SIGHT ld hl, ButItFailedText ld de, ItFailedText - jr z, .asm_35110 + jr z, .got_text ld hl, AttackMissedText ld de, AttackMissed2Text ld a, [CriticalHit] cp $ff - jr nz, .asm_35110 + jr nz, .got_text ld hl, UnaffectedText -.asm_35110 - call Function35157 +.got_text + call FailText_CheckOpponentProtect xor a ld [CriticalHit], a @@ -2409,9 +2412,11 @@ Function350e4: ; 350e4 call GetBattleVar cp EFFECT_JUMP_KICK ret nz + ld a, [TypeModifier] and $7f ret z + ld hl, CurDamage ld a, [hli] ld b, [hl] @@ -2423,29 +2428,29 @@ Function350e4: ; 350e4 dec hl ld [hli], a or b - jr nz, .asm_3513e + jr nz, .do_at_least_1_damage inc a ld [hl], a -.asm_3513e +.do_at_least_1_damage ld hl, CrashedText call StdBattleTextBox ld a, $1 ld [wKickCounter], a - call PlayPlayerMoveAnim_ClearHiID + call LoadMoveAnim ld c, $1 ld a, [hBattleTurn] and a - jp nz, Function35d1c - jp Function35d7e + jp nz, EnemyHurtItself + jp PlayerHurtItself -Function35157: ; 35157 +FailText_CheckOpponentProtect: ; 35157 ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVar bit SUBSTATUS_PROTECT, a - jr z, .asm_35162 + jr z, .not_protected ld h, d ld l, e -.asm_35162 +.not_protected jp StdBattleTextBox ; 35165 @@ -2599,7 +2604,7 @@ BattleCommand_CheckDestinyBond: ; 351c0 inc a ld [wKickCounter], a ld a, DESTINY_BOND - call PlayMoveAnim_KeepHiID + call LoadAnim call BattleCommand_SwitchTurn jr .asm_3524d ; 3522f $1c @@ -2823,7 +2828,7 @@ PlayerAttackDamage: ; 352e2 call ThickClubBoost .done - call Function3534d + call TruncateHL_BC ld a, [BattleMonLevel] ld e, a @@ -2835,13 +2840,14 @@ PlayerAttackDamage: ; 352e2 ; 3534d -Function3534d: ; 3534d +TruncateHL_BC: ; 3534d +.loop ; Truncate 16-bit values hl and bc to 8-bit values b and c respectively. ; b = hl, c = bc ld a, h or b - jr z, .asm_3536b + jr z, .finish srl b rr c @@ -2850,10 +2856,10 @@ Function3534d: ; 3534d ld a, c or b - jr nz, .asm_3535e + jr nz, .done_bc inc c -.asm_3535e +.done_bc srl h rr l srl h @@ -2861,17 +2867,17 @@ Function3534d: ; 3534d ld a, l or h - jr nz, .asm_3536b + jr nz, .finish inc l -.asm_3536b +.finish ld a, [wLinkMode] cp 3 jr z, .done ld a, h or b - jr nz, Function3534d + jr nz, .loop .done ld b, l @@ -3077,7 +3083,7 @@ EnemyAttackDamage: ; 353f6 call ThickClubBoost .done - call Function3534d + call TruncateHL_BC ld a, [EnemyMonLevel] ld e, a @@ -3315,37 +3321,37 @@ BattleCommand_ClearMissDamage: ; 355d5 ; 355dd -Function355dd: ; 355dd +HitSelfInConfusion: ; 355dd call ResetDamage ld a, [hBattleTurn] and a ld hl, BattleMonDefense ld de, PlayerScreens ld a, [BattleMonLevel] - jr z, .asm_355f7 + jr z, .got_it ld hl, EnemyMonDefense ld de, EnemyScreens ld a, [EnemyMonLevel] -.asm_355f7 +.got_it push af ld a, [hli] ld b, a ld c, [hl] ld a, [de] bit SCREENS_REFLECT, a - jr z, .asm_35604 + jr z, .mimic_screen sla c rl b -.asm_35604 +.mimic_screen rept 3 dec hl endr ld a, [hli] ld l, [hl] ld h, a - call Function3534d + call TruncateHL_BC ld d, $28 pop af ld e, a @@ -3798,7 +3804,7 @@ BattleCommand_Counter: ; 35813 and a ret z - call Function36abf + call CheckOpponentWentFirst ret z ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP @@ -3885,7 +3891,7 @@ rept 3 inc a endr ld [de], a - call Function36abf + call CheckOpponentWentFirst jr nz, .asm_3591a ld a, [hBattleTurn] and a @@ -3967,13 +3973,13 @@ BattleCommand_PainSplit: ; 35926 ld a, [AttackMissed] and a - jp nz, Function359cd + jp nz, PainSplit_PrintButItFailed call CheckSubstituteOpp - jp nz, Function359cd + jp nz, PainSplit_PrintButItFailed call AnimateCurrentMove ld hl, BattleMonMaxHP + 1 ld de, EnemyMonMaxHP + 1 - call .asm_3597d + call .PlayerShareHP ld a, $1 ld [wd10a], a hlcoord 10, 9 @@ -3987,18 +3993,18 @@ BattleCommand_PainSplit: ; 35926 ld [Buffer2], a ld a, [hl] ld [Buffer1], a - call Function359ac + call .EnemyShareHP xor a ld [wd10a], a call ResetDamage hlcoord 2, 2 predef AnimateHPBar - callba Function178000 + callba _UpdateBattleHUDs ld hl, SharedPainText jp StdBattleTextBox -.asm_3597d +.PlayerShareHP ld a, [hld] ld [Buffer1], a ld a, [hld] @@ -4030,11 +4036,7 @@ rept 3 inc de endr - ; fallthrough -; 359ac - - -Function359ac: ; 359ac +.EnemyShareHP: ; 359ac ld c, [hl] dec hl ld a, [CurDamage + 1] @@ -4043,13 +4045,13 @@ Function359ac: ; 359ac dec hl ld a, [CurDamage] sbc b - jr nc, .asm_359c2 + jr nc, .skip ld a, [CurDamage] ld b, a ld a, [CurDamage + 1] ld c, a -.asm_359c2 +.skip ld a, c ld [hld], a ld [Buffer5], a @@ -4059,7 +4061,7 @@ Function359ac: ; 359ac ret ; 359cd -Function359cd: ; 359cd +PainSplit_PrintButItFailed: ; 359cd jp PrintDidntAffect2 ; 359d0 @@ -4073,7 +4075,7 @@ BattleCommand_Snore: ; 359d0 call ResetDamage ld a, $1 ld [AttackMissed], a - call Function37354 + call FailSnore jp EndMoveEffect ; 359e6 @@ -4141,7 +4143,7 @@ BattleCommand_Conversion2: ; 359e6 jp StdBattleTextBox .asm_35a50 - jp Function37354 + jp FailConversion2 ; 35a53 @@ -4149,11 +4151,11 @@ BattleCommand_LockOn: ; 35a53 ; lockon call CheckSubstituteOpp - jr nz, .asm_35a6e + jr nz, .fail ld a, [AttackMissed] and a - jr nz, .asm_35a6e + jr nz, .fail ld a, BATTLE_VARS_SUBSTATUS5_OPP call GetBattleVarAddr @@ -4163,7 +4165,7 @@ BattleCommand_LockOn: ; 35a53 ld hl, TookAimText jp StdBattleTextBox -.asm_35a6e +.fail call AnimateFailedMove jp PrintDidntAffect ; 35a74 @@ -4172,58 +4174,68 @@ BattleCommand_LockOn: ; 35a53 BattleCommand_Sketch: ; 35a74 ; sketch - call Function372d8 - + call ClearLastMove +; Don't sketch during a link battle ld a, [wLinkMode] and a - jr z, .asm_35a83 + jr z, .not_linked call AnimateFailedMove jp PrintNothingHappened -.asm_35a83 +.not_linked +; If the opponent has a substitute up, fail. call CheckSubstituteOpp - jp nz, .asm_35b10 - + jp nz, .fail +; If the opponent is transformed, fail. ld a, BATTLE_VARS_SUBSTATUS5_OPP call GetBattleVarAddr bit SUBSTATUS_TRANSFORMED, [hl] - jp nz, .asm_35b10 - + jp nz, .fail +; Get the user's moveset in its party struct. +; This move replacement shall be permanent. +; Pointer will be in de. ld a, MON_MOVES call UserPartyAttr ld d, h ld e, l +; Get the battle move structs. ld hl, BattleMonMoves ld a, [hBattleTurn] and a - jr z, .asm_35aa5 + jr z, .get_last_move ld hl, EnemyMonMoves -.asm_35aa5 +.get_last_move ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar ld [wTypeMatchup], a ld b, a +; Fail if move is invalid or is Struggle. and a - jr z, .asm_35b10 + jr z, .fail cp STRUGGLE - jr z, .asm_35b10 + jr z, .fail +; Fail if user already knows that move ld c, NUM_MOVES -.asm_35ab7 +.does_user_already_know_move ld a, [hli] cp b - jr z, .asm_35b10 + jr z, .fail dec c - jr nz, .asm_35ab7 + jr nz, .does_user_already_know_move +; Find Sketch in the user's moveset. +; Pointer in hl, and index in c. dec hl ld c, NUM_MOVES -.asm_35ac1 +.find_sketch dec c ld a, [hld] cp SKETCH - jr nz, .asm_35ac1 + jr nz, .find_sketch inc hl +; The Sketched move is loaded to that slot. ld a, b ld [hl], a +; Copy the base PP from that move. push bc push hl dec a @@ -4234,24 +4246,27 @@ BattleCommand_Sketch: ; 35a74 add hl, bc ld [hl], a pop bc + ld a, [hBattleTurn] and a - jr z, .asm_35af6 + jr z, .user_trainer ld a, [wBattleMode] dec a - jr nz, .asm_35af6 + jr nz, .user_trainer +; wildmon ld a, [hl] push bc - ld hl, wc739 + ld hl, wWildMonPP ld b, 0 add hl, bc ld [hl], a - ld hl, wc735 + ld hl, wWildMonMoves add hl, bc pop bc ld [hl], b - jr .asm_35b04 -.asm_35af6 + jr .done_copy + +.user_trainer ld a, [hl] push af ld l, c @@ -4260,17 +4275,17 @@ BattleCommand_Sketch: ; 35a74 ld a, b ld [hl], a pop af - ld de, $0015 + ld de, MON_PP - MON_MOVES add hl, de ld [hl], a -.asm_35b04 +.done_copy call GetMoveName call AnimateCurrentMove ld hl, SketchedText jp StdBattleTextBox -.asm_35b10 +.fail call AnimateFailedMove jp PrintDidntAffect ; 35b16 @@ -4307,10 +4322,10 @@ BattleCommand_DefrostOpponent: ; 35b16 BattleCommand_SleepTalk: ; 35b33 ; sleeptalk - call Function372d8 + call ClearLastMove ld a, [AttackMissed] and a - jr nz, .asm_35ba3 + jr nz, .fail ld a, [hBattleTurn] and a ld hl, BattleMonMoves + 1 @@ -4324,12 +4339,12 @@ BattleCommand_SleepTalk: ; 35b33 ld a, BATTLE_VARS_STATUS call GetBattleVar and SLP - jr z, .asm_35ba3 + jr z, .fail ld a, [hl] and a - jr z, .asm_35ba3 + jr z, .fail call .asm_35ba9 - jr c, .asm_35ba3 + jr c, .fail dec hl .asm_35b62 push hl @@ -4356,18 +4371,19 @@ BattleCommand_SleepTalk: ; 35b33 call GetBattleVarAddr ld a, e ld [hl], a - call Function34548 - jr nz, .asm_35b9a + call CheckUserIsCharging + jr nz, .charging ld a, [wKickCounter] push af call BattleCommand_LowerSub pop af ld [wKickCounter], a -.asm_35b9a - call PlayPlayerMoveAnim_ClearHiID +.charging + call LoadMoveAnim call UpdateMoveData jp ResetTurn -.asm_35ba3 + +.fail call AnimateFailedMove jp TryPrintButItFailed @@ -4656,22 +4672,23 @@ PlayFXAnimID: ; 35d08 ; 35d1c -Function35d1c: ; 35d1c +EnemyHurtItself: ; 35d1c ld hl, CurDamage ld a, [hli] ld b, a ld a, [hl] or b - jr z, .asm_35d7b + jr z, .did_no_damage ld a, c and a - jr nz, .asm_35d31 + jr nz, .mimic_sub_check ld a, [EnemySubStatus4] bit SUBSTATUS_SUBSTITUTE, a - jp nz, Function35de0 -.asm_35d31 + jp nz, SelfInflictDamageToSubstitute + +.mimic_sub_check ld a, [hld] ld b, a ld a, [EnemyMonHP + 1] @@ -4684,7 +4701,7 @@ Function35d1c: ; 35d1c ld [Buffer4], a sbc b ld [EnemyMonHP], a - jr nc, .asm_35d59 + jr nc, .mimic_faint ld a, [Buffer4] ld [hli], a @@ -4696,7 +4713,7 @@ Function35d1c: ; 35d1c ld [hli], a ld [hl], a -.asm_35d59 +.mimic_faint ld hl, EnemyMonMaxHP ld a, [hli] ld [Buffer2], a @@ -4711,27 +4728,27 @@ Function35d1c: ; 35d1c xor a ld [wd10a], a predef AnimateHPBar -.asm_35d7b +.did_no_damage jp RefreshBattleHuds ; 35d7e -Function35d7e: ; 35d7e +PlayerHurtItself: ; 35d7e ld hl, CurDamage ld a, [hli] ld b, a ld a, [hl] or b - jr z, .asm_35ddd + jr z, .did_no_damage ld a, c and a - jr nz, .asm_35d93 + jr nz, .mimic_sub_check ld a, [PlayerSubStatus4] bit SUBSTATUS_SUBSTITUTE, a - jp nz, Function35de0 -.asm_35d93 + jp nz, SelfInflictDamageToSubstitute +.mimic_sub_check ld a, [hld] ld b, a ld a, [BattleMonHP + 1] @@ -4745,7 +4762,7 @@ Function35d7e: ; 35d7e sbc b ld [BattleMonHP], a ld [Buffer6], a - jr nc, .asm_35dc5 + jr nc, .mimic_faint ld a, [Buffer4] ld [hli], a @@ -4760,7 +4777,7 @@ Function35d7e: ; 35d7e ld [hli], a ld [hl], a -.asm_35dc5 +.mimic_faint ld hl, BattleMonMaxHP ld a, [hli] ld [Buffer2], a @@ -4770,12 +4787,12 @@ Function35d7e: ; 35d7e ld a, $1 ld [wd10a], a predef AnimateHPBar -.asm_35ddd +.did_no_damage jp RefreshBattleHuds ; 35de0 -Function35de0: ; 35de0 +SelfInflictDamageToSubstitute: ; 35de0 ld hl, SubTookDamageText call StdBattleTextBox @@ -4811,7 +4828,7 @@ Function35de0: ; 35de0 ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND - call z, Function37ec7 + call z, AppearUserLowerSub call BattleCommand_SwitchTurn ld a, BATTLE_VARS_MOVE_EFFECT @@ -5031,25 +5048,25 @@ BattleCommand_Poison: ; 35f2c ld a, [hBattleTurn] and a - jr z, .skip_random + jr z, .mimic_random ld a, [wLinkMode] and a - jr nz, .skip_random + jr nz, .mimic_random ld a, [InBattleTowerBattle] and a - jr nz, .skip_random + jr nz, .mimic_random ld a, [PlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a - jr nz, .skip_random + jr nz, .mimic_random call BattleRandom cp $40 ; 25% chance AI fails jr c, .failed -.skip_random +.mimic_random call CheckSubstituteOpp jr nz, .failed ld a, [AttackMissed] @@ -5244,7 +5261,7 @@ BattleCommand_BurnTarget: ; 3608c ld a, [TypeModifier] and $7f ret z - call Function36e5b + call CheckMoveTypeMatchesTarget ; Don't burn a Fire-type ret z call GetOpponentItem ld a, b @@ -5317,7 +5334,7 @@ BattleCommand_FreezeTarget: ; 36102 ld a, [Weather] cp WEATHER_SUN ret z - call Function36e5b + call CheckMoveTypeMatchesTarget ; Don't freeze an Ice-type ret z call GetOpponentItem ld a, b @@ -5454,7 +5471,7 @@ BattleCommand_StatUp: ; 361e4 ld a, [FailedMessage] and a ret nz - jp Function36281 + jp StatUpAnimation ; 361ef @@ -5561,7 +5578,7 @@ CheckIfStatCanBeRaised: ; 361ef ; 36281 -Function36281: ; 36281 +StatUpAnimation: ; 36281 ld bc, wc6fe ld hl, Function3f447 ld a, [hBattleTurn] @@ -5581,7 +5598,7 @@ Function36281: ; 36281 ret nc xor a - ld [$ffd4], a + ld [hBGMapMode], a call CallBattleCore call WaitBGMap jp BattleCommand_MoveDelay @@ -6146,7 +6163,7 @@ BattleCommand_RaiseSubNoAnim: ; 365af ld hl, GetMonFrontpic .PlayerTurn xor a - ld [$ffd4], a + ld [hBGMapMode], a call CallBattleCore jp WaitBGMap ; 365c3 @@ -6160,7 +6177,7 @@ BattleCommand_LowerSubNoAnim: ; 365c3 ld hl, Function3f486 .PlayerTurn xor a - ld [$ffd4], a + ld [hBGMapMode], a call CallBattleCore jp WaitBGMap ; 365d7 @@ -6534,7 +6551,7 @@ BattleCommand_Teleport: ; 36778 ld [wKickCounter], a call SetBattleDraw call BattleCommand_LowerSub - call PlayPlayerMoveAnim_ClearHiID + call LoadMoveAnim ld c, 20 call DelayFrames call SetBattleDraw @@ -6944,17 +6961,17 @@ BattleCommand_FakeOut: ; 36a82 ret nz call CheckSubstituteOpp - jr nz, .asm_36a9a + jr nz, .fail ld a, BATTLE_VARS_STATUS_OPP call GetBattleVar and 1 << FRZ | SLP - jr nz, .asm_36a9a + jr nz, .fail - call Function36abf - jr z, Function36ab5 + call CheckOpponentWentFirst + jr z, FlinchTarget -.asm_36a9a +.fail ld a, 1 ld [AttackMissed], a ret @@ -6970,7 +6987,7 @@ BattleCommand_FlinchTarget: ; 36aa0 and 1 << FRZ | SLP ret nz - call Function36abf + call CheckOpponentWentFirst ret nz ld a, [EffectFailed] @@ -6981,7 +6998,7 @@ BattleCommand_FlinchTarget: ; 36aa0 ; 36ab5 -Function36ab5: ; 36ab5 +FlinchTarget: ; 36ab5 ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVarAddr set SUBSTATUS_FLINCHED, [hl] @@ -6989,12 +7006,14 @@ Function36ab5: ; 36ab5 ; 36abf -Function36abf: ; 36abf +CheckOpponentWentFirst: ; 36abf +; Returns a=0, z if user went first +; Returns a=1, nz if opponent went first push bc - ld a, [wEnemyGoesFirst] + ld a, [wEnemyGoesFirst] ; 0 if player went first ld b, a - ld a, [hBattleTurn] - xor b + ld a, [hBattleTurn] ; 0 if it's the player's turn + xor b ; 1 if opponent went first pop bc ret ; 36ac9 @@ -7099,14 +7118,14 @@ BattleCommand_Charge: ; 36b4d ld a, BATTLE_VARS_STATUS call GetBattleVar and SLP - jr z, .asm_36b65 + jr z, .awake call BattleCommand_MoveDelay call BattleCommand_RaiseSub call PrintButItFailed jp EndMoveEffect -.asm_36b65 +.awake ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr set SUBSTATUS_CHARGED, [hl] @@ -7121,36 +7140,36 @@ BattleCommand_Charge: ; 36b4d ld [wcfca], a inc a ld [wKickCounter], a - call PlayPlayerMoveAnim_ClearHiID + call LoadMoveAnim ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar cp FLY - jr z, .asm_36b96 + jr z, .flying cp DIG - jr z, .asm_36b96 + jr z, .flying call BattleCommand_RaiseSub - jr .asm_36b99 -.asm_36b96 - call Function37ec0 -.asm_36b99 + jr .not_flying +.flying + call DisappearUser +.not_flying ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar ld b, a cp FLY - jr z, .asm_36bb0 + jr z, .set_flying cp DIG - jr nz, .asm_36bb2 + jr nz, .dont_set_digging set SUBSTATUS_UNDERGROUND, [hl] - jr .asm_36bb2 + jr .dont_set_digging -.asm_36bb0 +.set_flying set SUBSTATUS_FLYING, [hl] -.asm_36bb2 - call Function34548 - jr nz, .asm_36bc3 +.dont_set_digging + call CheckUserIsCharging + jr nz, .mimic ld a, BATTLE_VARS_LAST_COUNTER_MOVE call GetBattleVarAddr ld [hl], b @@ -7158,7 +7177,7 @@ BattleCommand_Charge: ; 36b4d call GetBattleVarAddr ld [hl], b -.asm_36bc3 +.mimic call ResetDamage ld hl, .UsedText @@ -7567,7 +7586,7 @@ BattleCommand_Paralyze: ; 36dc7 call DelayFrames call AnimateCurrentMove ld a, $1 - ld [$ffd4], a + ld [hBGMapMode], a ld a, BATTLE_VARS_STATUS_OPP call GetBattleVarAddr set PAR, [hl] @@ -7590,7 +7609,7 @@ BattleCommand_Paralyze: ; 36dc7 ; 36e5b -Function36e5b: ; 36e5b +CheckMoveTypeMatchesTarget: ; 36e5b ; Compare move type to opponent type. ; Return z if matching the opponent type, ; unless the move is Normal (Tri Attack). @@ -7694,7 +7713,7 @@ endr ld [FXAnimIDHi], a ld [wKickCounter], a ld a, SUBSTITUTE - call PlayMoveAnim_KeepHiID + call LoadAnim jr .finish .mobile @@ -7705,13 +7724,13 @@ endr jp RefreshBattleHuds .already_has_sub - call Function34548 + call CheckUserIsCharging call nz, BattleCommand_RaiseSub ld hl, HasSubstituteText jr .jp_stdbattletextbox .too_weak_to_sub - call Function34548 + call CheckUserIsCharging call nz, BattleCommand_RaiseSub ld hl, TooWeakSubText .jp_stdbattletextbox @@ -7785,38 +7804,38 @@ DoubleDamage: ; 36f37 BattleCommand_Mimic: ; 36f46 ; mimic - call Function372d8 + call ClearLastMove call BattleCommand_MoveDelay ld a, [AttackMissed] and a - jr nz, .asm_36f9a + jr nz, .fail ld hl, BattleMonMoves ld a, [hBattleTurn] and a - jr z, .asm_36f5d + jr z, .player_turn ld hl, EnemyMonMoves -.asm_36f5d +.player_turn call CheckHiddenOpponent - jr nz, .asm_36f9a + jr nz, .fail ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar and a - jr z, .asm_36f9a + jr z, .fail cp STRUGGLE - jr z, .asm_36f9a + jr z, .fail ld b, a ld c, NUM_MOVES -.asm_36f71 +.check_already_knows_move ld a, [hli] cp b - jr z, .asm_36f9a + jr z, .fail dec c - jr nz, .asm_36f71 + jr nz, .check_already_knows_move dec hl -.asm_36f79 +.find_mimic ld a, [hld] cp MIMIC - jr nz, .asm_36f79 + jr nz, .find_mimic inc hl ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar @@ -7829,8 +7848,9 @@ BattleCommand_Mimic: ; 36f46 call AnimateCurrentMove ld hl, LearnedMoveText jp StdBattleTextBox -.asm_36f9a - jp Function37357 + +.fail + jp FailMimic ; 36f9d @@ -7954,7 +7974,7 @@ BattleCommand_Disable: ; 36fed ld hl, WasDisabledText jp StdBattleTextBox .asm_37059 - jp Function37354 + jp FailDisable ; 3705c @@ -8202,7 +8222,7 @@ BattleCommand_Heal: ; 3713e BattleCommand_Transform: ; 371cd ; transform - call Function372d8 + call ClearLastMove ld a, BATTLE_VARS_SUBSTATUS5_OPP call GetBattleVarAddr bit SUBSTATUS_TRANSFORMED, [hl] @@ -8218,12 +8238,12 @@ BattleCommand_Transform: ; 371cd call GetBattleVarAddr bit SUBSTATUS_SUBSTITUTE, [hl] push af - jr z, .skip_substitute - call Function34548 - jr nz, .skip_substitute + jr z, .mimic_substitute + call CheckUserIsCharging + jr nz, .mimic_substitute ld a, SUBSTITUTE - call PlayMoveAnim_KeepHiID -.skip_substitute + call LoadAnim +.mimic_substitute ld a, BATTLE_VARS_SUBSTATUS5 call GetBattleVarAddr set SUBSTATUS_TRANSFORMED, [hl] @@ -8249,14 +8269,14 @@ endr call CopyBytes ld a, [hBattleTurn] and a - jr z, .skip_enemy_backup + jr z, .mimic_enemy_backup ld a, [de] ld [wEnemyBackupDVs], a inc de ld a, [de] ld [wEnemyBackupDVs + 1], a dec de -.skip_enemy_backup +.mimic_enemy_backup ; copy DVs ld a, [hli] ld [de], a @@ -8312,7 +8332,7 @@ endr ld bc, 8 call BattleSideCopy call _CheckBattleScene - jr c, .skip_anims + jr c, .mimic_anims ld a, [hBattleTurn] and a ld a, [wc6fe] @@ -8320,10 +8340,10 @@ endr ld a, [wc6fa] .got_byte and a - jr nz, .skip_anims - call PlayPlayerMoveAnim_ClearHiID + jr nz, .mimic_anims + call LoadMoveAnim jr .after_anim -.skip_anims +.mimic_anims call BattleCommand_MoveDelay call BattleCommand_RaiseSubNoAnim .after_anim @@ -8334,7 +8354,7 @@ endr ld [wKickCounter], a pop af ld a, SUBSTITUTE - call nz, PlayMoveAnim_KeepHiID + call nz, LoadAnim ld hl, TransformedText jp StdBattleTextBox ; 372c6 @@ -8363,7 +8383,7 @@ Function372d2: ; 372d2 ; 372d8 -Function372d8: ; 372d8 +ClearLastMove: ; 372d8 ld a, BATTLE_VARS_LAST_COUNTER_MOVE call GetBattleVarAddr xor a @@ -8472,15 +8492,20 @@ PrintButItFailed: ; 3734e ; 37354 -Function37354: ; 37354 +FailSnore: +FailDisable: +FailConversion2: +FailAttract: +FailForesight: +FailSpikes: call AnimateFailedMove ; fallthrough ; 37357 -Function37357: ; 37357 +FailMimic: ; 37357 ld hl, ButItFailedText ; 'but it failed!' ld de, ItFailedText ; 'it failed!' - jp Function35157 + jp FailText_CheckOpponentProtect ; 37360 @@ -8495,7 +8520,7 @@ PrintDidntAffect2: ; 37366 call AnimateFailedMove ld hl, DidntAffect1Text ; 'it didn't affect' ld de, DidntAffect2Text ; 'it didn't affect' - jp Function35157 + jp FailText_CheckOpponentProtect ; 37372 @@ -8516,9 +8541,9 @@ CheckSubstituteOpp: ; 37378 BattleCommand_SelfDestruct: ; 37380 callba MobileFn_10610d - ld a, $4 + ld a, BATTLEANIM_PLAYER_DAMAGE ld [wcfca], a - ld c, $3 + ld c, 3 call DelayFrames ld a, BATTLE_VARS_STATUS call GetBattleVarAddr @@ -8530,7 +8555,7 @@ BattleCommand_SelfDestruct: ; 37380 ld a, $1 ld [wKickCounter], a call BattleCommand_LowerSub - call PlayPlayerMoveAnim_ClearHiID + call LoadMoveAnim ld a, BATTLE_VARS_SUBSTATUS4 call GetBattleVarAddr res SUBSTATUS_LEECH_SEED, [hl] @@ -9348,15 +9373,17 @@ BattleCommand_StartSun: ; 37c07 BattleCommand_BellyDrum: ; 37c1a ; bellydrum +; This command is buggy because it raises the user's attack +; before checking that it has enough HP to use the move. +; Swap the order of these two blocks to fix. call BattleCommand_AttackUp2 ld a, [AttackMissed] and a - jr nz, .asm_37c4f + jr nz, .failed callab GetHalfMaxHP - - callab Function3ccde - jr nc, .asm_37c4f + callab CheckUserHasEnoughHP + jr nc, .failed push bc call AnimateCurrentMove @@ -9365,16 +9392,17 @@ BattleCommand_BellyDrum: ; 37c1a call UpdateUserInParty ld a, 5 -.asm_37c41 +.max_attack_loop push af call BattleCommand_AttackUp2 pop af dec a - jr nz, .asm_37c41 + jr nz, .max_attack_loop ld hl, BellyDrumText jp StdBattleTextBox -.asm_37c4f + +.failed call AnimateFailedMove jp PrintButItFailed ; 37c55 @@ -9387,40 +9415,45 @@ BattleCommand_PsychUp: ; 37c55 ld de, PlayerStatLevels ld a, [hBattleTurn] and a - jr z, .asm_37c64 ; 37c5e $4 + jr z, .pointers_correct ; 37c5e $4 +; It's the enemy's turn, so swap the pointers. push hl ld h, d ld l, e pop de -.asm_37c64 +.pointers_correct push hl - ld b, $8 -.asm_37c67 + ld b, NUM_LEVEL_STATS +; If any of the enemy's stats is modified from its base level, +; the move succeeds. Otherwise, it fails. +.loop ld a, [hli] - cp $7 - jr nz, .asm_37c76 ; 37c6a $a + cp BASE_STAT_LEVEL + jr nz, .break ; 37c6a $a dec b - jr nz, .asm_37c67 ; 37c6d $f8 + jr nz, .loop ; 37c6d $f8 pop hl call AnimateFailedMove jp PrintButItFailed -.asm_37c76 + +.break pop hl - ld b, $8 -.asm_37c79 + ld b, NUM_LEVEL_STATS +.loop2 ld a, [hli] ld [de], a inc de dec b - jr nz, .asm_37c79 ; 37c7d $fa + jr nz, .loop2 ; 37c7d $fa ld a, [hBattleTurn] and a - jr nz, .asm_37c89 ; 37c82 $5 + jr nz, .calc_enemy_stats ; 37c82 $5 call CalcPlayerStats - jr .asm_37c8c ; 37c87 $3 -.asm_37c89 + jr .merge ; 37c87 $3 + +.calc_enemy_stats call CalcEnemyStats -.asm_37c8c +.merge call AnimateCurrentMove ld hl, CopiedStatsText jp StdBattleTextBox @@ -9449,7 +9482,7 @@ BattleCommand_MirrorCoat: ; 37c95 and a ret z - call Function36abf + call CheckOpponentWentFirst ret z ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP @@ -9514,7 +9547,7 @@ BattleCommand_DoubleMinimizeDamage: ; 37ce6 BattleCommand_SkipSunCharge: ; 37d02 -; skipsuncharge +; mimicsuncharge ld a, [Weather] cp WEATHER_SUN ret nz @@ -9554,7 +9587,7 @@ BattleCommand_CheckFutureSight: ; 37d0d BattleCommand_FutureSight: ; 37d34 ; futuresight - call Function34548 + call CheckUserIsCharging jr nz, .asm_37d4b ; 37d37 $12 ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar @@ -9691,7 +9724,7 @@ AnimateCurrentMoveEitherSide: ; 37de9 call BattleCommand_LowerSub pop af ld [wKickCounter], a - call PlayMoveAnim_ClearHiID + call PlayDamageAnim call BattleCommand_RaiseSub pop bc pop de @@ -9709,7 +9742,7 @@ AnimateCurrentMove: ; 37e01 call BattleCommand_LowerSub pop af ld [wKickCounter], a - call PlayPlayerMoveAnim_ClearHiID + call LoadMoveAnim call BattleCommand_RaiseSub pop bc pop de @@ -9718,7 +9751,7 @@ AnimateCurrentMove: ; 37e01 ; 37e19 -PlayMoveAnim_ClearHiID: ; 37e19 +PlayDamageAnim: ; 37e19 xor a ld [FXAnimIDHi], a @@ -9731,9 +9764,9 @@ PlayMoveAnim_ClearHiID: ; 37e19 ld a, [hBattleTurn] and a - ld a, 1 + ld a, BATTLEANIM_ENEMY_DAMAGE jr z, .player - ld a, 4 + ld a, BATTLEANIM_PLAYER_DAMAGE .player ld [wcfca], a @@ -9742,7 +9775,7 @@ PlayMoveAnim_ClearHiID: ; 37e19 ; 37e36 -PlayPlayerMoveAnim_ClearHiID: ; 37e36 +LoadMoveAnim: ; 37e36 xor a ld [wcfca], a ld [FXAnimIDHi], a @@ -9756,7 +9789,7 @@ PlayPlayerMoveAnim_ClearHiID: ; 37e36 ; 37e44 -PlayMoveAnim_KeepHiID: ; 37e44 +LoadAnim: ; 37e44 ld [FXAnimIDLo], a @@ -9838,10 +9871,10 @@ SkipToBattleCommand: ; 37e8c ld h, a ld a, [BattleScriptBufferLoc] ld l, a -.asm_37e94 +.loop ld a, [hli] cp b - jr nz, .asm_37e94 + jr nz, .loop ld a, h ld [BattleScriptBufferLoc + 1], a @@ -9878,20 +9911,20 @@ GetMoveByte: ; 37ebb ; 37ec0 -Function37ec0: ; 37ec0 - callba Functionfbd54 +DisappearUser: ; 37ec0 + callba _DisappearUser ret ; 37ec7 -Function37ec7: ; 37ec7 - callba Functionfbd71 +AppearUserLowerSub: ; 37ec7 + callba _AppearUserLowerSub ret ; 37ece -Function37ece: ; 37ece - callba Functionfbd69 +AppearUserRaiseSub: ; 37ece + callba _AppearUserRaiseSub ret ; 37ed5 diff --git a/battle/effects/attract.asm b/battle/effects/attract.asm index 5e9561206..f1bc590eb 100755 --- a/battle/effects/attract.asm +++ b/battle/effects/attract.asm @@ -20,7 +20,7 @@ BattleCommand_Attract: ; 377ce jp StdBattleTextBox .failed - jp Function37354 + jp FailAttract ; 377f5 diff --git a/battle/effects/foresight.asm b/battle/effects/foresight.asm index a8834fd9c..6f4f97cd2 100644 --- a/battle/effects/foresight.asm +++ b/battle/effects/foresight.asm @@ -19,5 +19,5 @@ BattleCommand_Foresight: ; 376a0 jp StdBattleTextBox .failed - jp Function37354 + jp FailForesight ; 376c2 diff --git a/battle/effects/metronome.asm b/battle/effects/metronome.asm index af574061d..ddc1bf62e 100644 --- a/battle/effects/metronome.asm +++ b/battle/effects/metronome.asm @@ -1,8 +1,8 @@ BattleCommand_Metronome: ; 37418 ; metronome - call Function372d8 - call Function34548 + call ClearLastMove + call CheckUserIsCharging jr nz, .asm_3742b ld a, [wKickCounter] @@ -12,7 +12,7 @@ BattleCommand_Metronome: ; 37418 ld [wKickCounter], a .asm_3742b - call PlayPlayerMoveAnim_ClearHiID + call LoadMoveAnim .GetMove call BattleRandom diff --git a/battle/effects/mirror_move.asm b/battle/effects/mirror_move.asm index e6196466b..c4f208d77 100644 --- a/battle/effects/mirror_move.asm +++ b/battle/effects/mirror_move.asm @@ -1,7 +1,7 @@ BattleCommand_MirrorMove: ; 373c9 ; mirrormove - call Function372d8 + call ClearLastMove ld a, BATTLE_VARS_MOVE call GetBattleVarAddr @@ -37,7 +37,7 @@ BattleCommand_MirrorMove: ; 373c9 call GetMoveData call GetMoveName call CopyName1 - call Function34548 + call CheckUserIsCharging jr nz, .done ld a, [wKickCounter] diff --git a/battle/effects/protect.asm b/battle/effects/protect.asm index ada796001..568ac00f8 100644 --- a/battle/effects/protect.asm +++ b/battle/effects/protect.asm @@ -23,7 +23,7 @@ ProtectChance: ; 3762c ld de, EnemyProtectCount .asm_37637 - call Function36abf + call CheckOpponentWentFirst jr nz, .failed ; Can't have a substitute. diff --git a/battle/effects/spikes.asm b/battle/effects/spikes.asm index 16a2c035d..3d15e4cfd 100644 --- a/battle/effects/spikes.asm +++ b/battle/effects/spikes.asm @@ -23,5 +23,5 @@ BattleCommand_Spikes: ; 37683 jp StdBattleTextBox .failed - jp Function37354 + jp FailSpikes ; 376a0 diff --git a/battle/misc.asm b/battle/misc.asm index f6b20e739..429e4aae6 100644 --- a/battle/misc.asm +++ b/battle/misc.asm @@ -1,50 +1,50 @@ -Functionfbd54: ; fbd54 +_DisappearUser: ; fbd54 xor a ld [hBGMapMode], a ; $ff00+$d4 ld a, [hBattleTurn] ; $ff00+$e4 and a - jr z, .asm_fbd61 - call Functionfbd96 - jr .asm_fbd64 -.asm_fbd61 - call Functionfbd9d -.asm_fbd64 + jr z, .player + call GetEnemyFrontpicCoords + jr .okay +.player + call GetPlayerBackpicCoords +.okay call ClearBox - jr Functionfbd91 + jr FinishAppearDisappearUser -Functionfbd69: ; fbd69 (3e:7d69) +_AppearUserRaiseSub: ; fbd69 (3e:7d69) callba BattleCommand_RaiseSubNoAnim - jr Functionfbd77 + jr AppearUser -Functionfbd71: ; fbd71 (3e:7d71) +_AppearUserLowerSub: ; fbd71 (3e:7d71) callba BattleCommand_LowerSubNoAnim -Functionfbd77: ; fbd77 (3e:7d77) +AppearUser: ; fbd77 (3e:7d77) xor a ld [hBGMapMode], a ; $ff00+$d4 ld a, [hBattleTurn] ; $ff00+$e4 and a - jr z, .asm_fbd85 - call Functionfbd96 + jr z, .player + call GetEnemyFrontpicCoords xor a - jr .asm_fbd8a -.asm_fbd85 - call Functionfbd9d + jr .okay +.player + call GetPlayerBackpicCoords ld a, $31 -.asm_fbd8a - ld [$ffad], a +.okay + ld [hFillBox], a predef FillBox -Functionfbd91: ; fbd91 (3e:7d91) +FinishAppearDisappearUser: ; fbd91 (3e:7d91) ld a, $1 ld [hBGMapMode], a ; $ff00+$d4 ret -Functionfbd96: ; fbd96 (3e:7d96) +GetEnemyFrontpicCoords: ; fbd96 (3e:7d96) hlcoord 12, 0 lb bc, 7, 7 ret -Functionfbd9d: ; fbd9d (3e:7d9d) +GetPlayerBackpicCoords: ; fbd9d (3e:7d9d) hlcoord 2, 6 lb bc, 6, 6 ret @@ -62,7 +62,7 @@ DoWeatherModifiers: ; fbda4 ld a, [de] inc de cp $ff - jr z, .asm_fbdc0 + jr z, .done_weather_types cp b jr nz, .NextWeatherType @@ -78,7 +78,7 @@ endr jr .CheckWeatherType -.asm_fbdc0 +.done_weather_types ld de, .WeatherMoveModifiers ld a, BATTLE_VARS_MOVE_EFFECT @@ -217,10 +217,10 @@ DoBadgeTypeBoosts: ; fbe24 ld a, e or d - jr nz, .asm_fbe6f + jr nz, .done_min ld e, 1 -.asm_fbe6f +.done_min add hl, de jr nc, .Update diff --git a/battle/moves/move_effects.asm b/battle/moves/move_effects.asm index 7f69ea6fd..454a1ac9b 100644 --- a/battle/moves/move_effects.asm +++ b/battle/moves/move_effects.asm @@ -44,7 +44,7 @@ NormalHit: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -83,7 +83,7 @@ PoisonHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -107,7 +107,7 @@ LeechHit: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -133,7 +133,7 @@ BurnHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -158,7 +158,7 @@ FreezeHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -187,7 +187,7 @@ ParalyzeHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -209,7 +209,7 @@ Explosion: checkhit selfdestruct hittargetnosub - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -229,7 +229,7 @@ DreamEater: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -634,7 +634,7 @@ AttackDownHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -659,7 +659,7 @@ DefenseDownHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -686,7 +686,7 @@ SpeedDownHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -708,7 +708,7 @@ SpecialAttackDownHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -733,7 +733,7 @@ SpecialDefenseDownHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -757,7 +757,7 @@ AccuracyDownHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -779,7 +779,7 @@ EvasionDownHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -802,7 +802,7 @@ DefenseUpHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -825,7 +825,7 @@ AttackUpHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -848,7 +848,7 @@ AllUpHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -868,7 +868,7 @@ PayDay: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -925,7 +925,7 @@ Rampage: damagevariation clearmissdamage hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -967,7 +967,7 @@ MultiHit: damagevariation clearmissdamage hittargetnosub - resulttext + failuretext checkfaint criticaltext cleartext @@ -995,7 +995,7 @@ PoisonMultiHit: damagevariation clearmissdamage hittargetnosub - resulttext + failuretext checkfaint criticaltext cleartext @@ -1027,7 +1027,7 @@ FlinchHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1046,7 +1046,7 @@ OHKOHit: stab ohko hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1069,7 +1069,7 @@ RecoilHit: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1122,7 +1122,7 @@ ConfuseHit: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1169,7 +1169,7 @@ TriAttack: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1218,7 +1218,7 @@ SkyAttack: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1246,7 +1246,7 @@ HyperBeam: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1267,7 +1267,7 @@ Rage: ragedamage damagevariation hittarget - resulttext + failuretext rage checkfaint criticaltext @@ -1328,7 +1328,7 @@ RazorWind: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1352,7 +1352,7 @@ Dig: checkhit hittargetnosub raisesub - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1377,7 +1377,7 @@ Whirlpool: damagevariation clearmissdamage hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1400,7 +1400,7 @@ StaticDamage: checkhit resettypematchup hittarget - resulttext + failuretext checkfaint checkdestinybond buildopponentrage @@ -1416,7 +1416,7 @@ Reversal: stab checkhit hittarget - resulttext + failuretext checkfaint supereffectivetext checkdestinybond @@ -1430,7 +1430,7 @@ Counter: doturn counter hittarget - resulttext + failuretext checkfaint checkdestinybond buildopponentrage @@ -1466,7 +1466,7 @@ Snore: effectchance snore hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1541,7 +1541,7 @@ FalseSwipe: falseswipe checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1572,7 +1572,7 @@ TripleKick: damagevariation clearmissdamage hittargetnosub - resulttext + failuretext checkfaint criticaltext cleartext @@ -1597,7 +1597,7 @@ Thief: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1634,7 +1634,7 @@ FlameWheel: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1708,7 +1708,7 @@ Rollout: rolloutpower damagevariation hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1728,7 +1728,7 @@ Swagger: lowersub statupanim raisesub - resulttext + failuretext switchturn statupmessage switchturn @@ -1747,7 +1747,7 @@ FuryCutter: furycutter damagevariation hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1776,7 +1776,7 @@ Return: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1797,7 +1797,7 @@ Present: stab damagevariation clearmissdamage - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1818,7 +1818,7 @@ Frustration: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1846,7 +1846,7 @@ SacredFire: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1869,7 +1869,7 @@ Magnitude: checkhit doubleundergrounddamage hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1897,7 +1897,7 @@ Pursuit: pursuit checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1917,7 +1917,7 @@ RapidSpin: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1959,7 +1959,7 @@ HiddenPower: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -1989,7 +1989,7 @@ FakeOut: checkhit fakeout hittarget - resulttext + failuretext endmove BellyDrum: @@ -2012,7 +2012,7 @@ MirrorCoat: doturn mirrorcoat hittarget - resulttext + failuretext checkfaint checkdestinybond buildopponentrage @@ -2032,7 +2032,7 @@ SkullBash: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -2057,7 +2057,7 @@ Twister: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -2079,7 +2079,7 @@ Earthquake: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -2098,7 +2098,7 @@ FutureSight: damagevariation checkhit hittargetnosub - resulttext + failuretext checkfaint checkdestinybond buildopponentrage @@ -2116,7 +2116,7 @@ Gust: doubleflyingdamage checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -2137,7 +2137,7 @@ Stomp: checkhit effectchance hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -2160,7 +2160,7 @@ Solarbeam: damagevariation checkhit hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -2182,7 +2182,7 @@ Thunder: stab damagevariation hittarget - resulttext + failuretext checkfaint criticaltext supereffectivetext @@ -2212,7 +2212,7 @@ BeatUp: damagevariation clearmissdamage hittargetnosub - resulttext + failuretext checkfaint criticaltext cleartext diff --git a/constants/animation_constants.asm b/constants/animation_constants.asm index 6ca0ff2e1..5bc9b7b06 100644 --- a/constants/animation_constants.asm +++ b/constants/animation_constants.asm @@ -1,26 +1,3 @@ -ANIM_SWEET_SCENT_2 EQU 255 ; unused? -ANIM_THROW_POKE_BALL EQU 256 -ANIM_SEND_OUT_MON EQU 257 ; seems to also cover shiny -ANIM_RETURN_MON EQU 258 -ANIM_CONFUSED EQU 259 -ANIM_SLP EQU 260 -ANIM_BRN EQU 261 -ANIM_PSN EQU 262 -ANIM_SAP EQU 263 -ANIM_FRZ EQU 264 -ANIM_PAR EQU 265 -ANIM_IN_LOVE EQU 266 -ANIM_IN_SANDSTORM EQU 267 -ANIM_IN_NIGHTMARE EQU 268 -ANIM_IN_WHIRLPOOL EQU 269 -ANIM_MISS EQU 270 -ANIM_ENEMY_DAMAGE EQU 271 -ANIM_ENEMY_STAT_DOWN EQU 272 ; vibrate horizontally -ANIM_PLAYER_STAT_DOWN EQU 273 ; wobble horizontally -ANIM_PLAYER_DAMAGE EQU 274 -ANIM_WOBBLE EQU 275 -ANIM_SHAKE EQU 276 -ANIM_HIT_CONFUSION EQU 277 ANIM_OBJ_BURNED EQU $10 ANIM_OBJ_FROZEN EQU $2a @@ -71,3 +48,53 @@ ANIM_BG_WOBBLE_MON EQU $34 const ANIM_MON_UNUSED ; 6 const ANIM_MON_EGG1 ; 7 const ANIM_MON_EGG2 ; 8 + +const_value SET $d0 + const BATTLEANIM_D0 + const BATTLEANIM_D1 + const BATTLEANIM_D2 + const BATTLEANIM_D3 + const BATTLEANIM_D4 + const BATTLEANIM_D5 + const BATTLEANIM_D6 + const BATTLEANIM_D7 + const BATTLEANIM_D8 + const BATTLEANIM_D9 + const BATTLEANIM_DA + const BATTLEANIM_DB + const BATTLEANIM_DC + const BATTLEANIM_DD + const BATTLEANIM_DE + const BATTLEANIM_DF + const BATTLEANIM_E0 + const BATTLEANIM_E1 + const BATTLEANIM_E2 + const BATTLEANIM_E3 + const BATTLEANIM_E4 + const BATTLEANIM_E5 + const BATTLEANIM_E6 + const BATTLEANIM_E7 + const BATTLEANIM_E8 + const BATTLEANIM_E9 + const BATTLEANIM_EA + const BATTLEANIM_EB + const BATTLEANIM_EC + const BATTLEANIM_ED + const BATTLEANIM_EE + const BATTLEANIM_EF + const BATTLEANIM_F0 + const BATTLEANIM_F1 + const BATTLEANIM_F2 + const BATTLEANIM_F3 + const BATTLEANIM_F4 + const BATTLEANIM_F5 + const BATTLEANIM_F6 + const BATTLEANIM_F7 + const BATTLEANIM_F8 + const BATTLEANIM_F9 + const BATTLEANIM_FA + const BATTLEANIM_FB + const BATTLEANIM_FC + const BATTLEANIM_FD + const BATTLEANIM_FE + const BATTLEANIM_FF diff --git a/constants/move_constants.asm b/constants/move_constants.asm index d88b0b560..e8392b45a 100644 --- a/constants/move_constants.asm +++ b/constants/move_constants.asm @@ -256,3 +256,44 @@ const_value SET const_value + -1 const NUM_ATTACKS ; $fb + +; Battle animations use the same constants +; as the moves up to this point. + const ANIM_FC ; $fc + const ANIM_FD ; $fd + const ANIM_FE ; $fe + const ANIM_SWEET_SCENT_2 ; $ff + const ANIM_THROW_POKE_BALL ; $100 + const ANIM_SEND_OUT_MON ; $101 + const ANIM_RETURN_MON ; $102 + const ANIM_CONFUSED ; $103 + const ANIM_SLP ; $104 + const ANIM_BRN ; $105 + const ANIM_PSN ; $106 + const ANIM_SAP ; $107 + const ANIM_FRZ ; $108 + const ANIM_PAR ; $109 + const ANIM_IN_LOVE ; $10a + const ANIM_IN_SANDSTORM ; $10b + const ANIM_IN_NIGHTMARE ; $10c + const ANIM_IN_WHIRLPOOL ; $10d +; battle anims + const ANIM_MISS ; $10e + const ANIM_ENEMY_DAMAGE ; $10f + const ANIM_ENEMY_STAT_DOWN ; $110 + const ANIM_PLAYER_STAT_DOWN ; $111 + const ANIM_PLAYER_DAMAGE ; $112 + const ANIM_WOBBLE ; $113 + const ANIM_SHAKE ; $114 + const ANIM_HIT_CONFUSION ; $115 + +; wcfca 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 \ No newline at end of file diff --git a/engine/credits.asm b/engine/credits.asm index 793891dd2..473a851be 100644 --- a/engine/credits.asm +++ b/engine/credits.asm @@ -366,7 +366,7 @@ ParseCredits: ; 1099aa ; First, let's clear the current text display, ; starting from line 5. xor a - ld [$ffd4], a + ld [hBGMapMode], a hlcoord 0, 5 ld bc, 20 * 12 ld a, " " @@ -479,9 +479,9 @@ endr ld [CreditsTimer], a xor a - ld [$ffd5], a + ld [hBGMapThird], a ld a, 1 - ld [$ffd4], a + ld [hBGMapMode], a .done jp Function109951 diff --git a/engine/scripting.asm b/engine/scripting.asm index 296f69ecd..703f67e07 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -440,14 +440,14 @@ Script_closetext: ; 0x96ed9 Script_keeptextopen: ; 0x96edc ; script command 0x55 - ld a, [$ffd8] + ld a, [hOAMUpdate] push af ld a, $1 - ld [$ffd8], a + ld [hOAMUpdate], a call WaitBGMap call KeepTextOpen pop af - ld [$ffd8], a + ld [hOAMUpdate], a ret ; 0x96eed diff --git a/home.asm b/home.asm index 1f32edbe8..2f1b231a0 100644 --- a/home.asm +++ b/home.asm @@ -1724,7 +1724,7 @@ Function378b:: ; 378b predef GetFrontpic pop hl xor a - ld [$ffad], a + ld [hFillBox], a lb bc, 7, 7 predef FillBox xor a @@ -1991,57 +1991,6 @@ Function392d:: ; 392d INCLUDE "home/battle.asm" - -Function3ae1:: ; 3ae1 - -GLOBAL BattleAnimations -GLOBAL BattleAnimCommands - - ld a, BANK(BattleAnimations) - rst Bankswitch - - ld a, [hli] - ld [BattleAnimAddress], a - ld a, [hl] - ld [BattleAnimAddress + 1], a - - ld a, BANK(BattleAnimCommands) - rst Bankswitch - - ret -; 3af0 - -GetBattleAnimByte:: ; 3af0 - - push hl - push de - - ld hl, BattleAnimAddress - ld e, [hl] - inc hl - ld d, [hl] - - ld a, BANK(BattleAnimations) - rst Bankswitch - - ld a, [de] - ld [BattleAnimByte], a - inc de - - ld a, BANK(BattleAnimCommands) - rst Bankswitch - - ld [hl], d - dec hl - ld [hl], e - - pop de - pop hl - - ld a, [BattleAnimByte] - ret -; 3b0c - Function3b0c:: ; 3b0c ld a, [hLCDStatCustom] diff --git a/home/battle.asm b/home/battle.asm index 37f39572a..94a065d4d 100644 --- a/home/battle.asm +++ b/home/battle.asm @@ -309,3 +309,53 @@ GLOBAL BattleText rst Bankswitch ret ; 3ae1 + +GetBattleAnimPointer:: ; 3ae1 + +GLOBAL BattleAnimations +GLOBAL BattleAnimCommands + + ld a, BANK(BattleAnimations) + rst Bankswitch + + ld a, [hli] + ld [BattleAnimAddress], a + ld a, [hl] + ld [BattleAnimAddress + 1], a + + ld a, BANK(BattleAnimCommands) + rst Bankswitch + + ret +; 3af0 + +GetBattleAnimByte:: ; 3af0 + + push hl + push de + + ld hl, BattleAnimAddress + ld e, [hl] + inc hl + ld d, [hl] + + ld a, BANK(BattleAnimations) + rst Bankswitch + + ld a, [de] + ld [BattleAnimByte], a + inc de + + ld a, BANK(BattleAnimCommands) + rst Bankswitch + + ld [hl], d + dec hl + ld [hl], e + + pop de + pop hl + + ld a, [BattleAnimByte] + ret +; 3b0c diff --git a/home/map.asm b/home/map.asm index 6b871617e..df7f943b2 100644 --- a/home/map.asm +++ b/home/map.asm @@ -124,9 +124,10 @@ LoadMapPart:: ; 217a ; 2198 LoadMetatiles:: ; 2198 +; de <- wd194 ld a, [wd194] ld e, a - ld a, [wd195] + ld a, [wd194 + 1] ld d, a ld hl, wMisc ld b, 5 ; SCREEN_WIDTH / 4 @@ -163,20 +164,21 @@ endr ld h, a rept 3 +; copy 4 bytes from hl to de rept 4 ld a, [hli] ld [de], a inc de endr - +; next row ld a, e - add 5 * 4 + add SCREEN_WIDTH ld e, a jr nc, .next\@ inc d .next\@ endr - +; copy 4 more bytes from hl to de rept 4 ld a, [hli] ld [de], a diff --git a/home/palettes.asm b/home/palettes.asm index 93498aedd..30e14c8b3 100644 --- a/home/palettes.asm +++ b/home/palettes.asm @@ -79,7 +79,7 @@ DmgToCgbBGPals:: ; c9f ld [rBGP], a push af -; Don't need to be here if CGB +; Don't need to be here if DMG ld a, [hCGB] and a jr z, .end diff --git a/hram.asm b/hram.asm index 452071c70..d5ca2737b 100644 --- a/hram.asm +++ b/hram.asm @@ -32,6 +32,8 @@ hJoyDown EQU $ffa8 hJoyLast EQU $ffa9 hInMenu EQU $ffaa +hFillBox EQU $ffad + hMapObjectIndexBuffer EQU $ffaf hObjectStructIndexBuffer EQU $ffb0 diff --git a/items/item_effects.asm b/items/item_effects.asm index b2258b6d5..22877e26e 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -225,7 +225,7 @@ ParkBall: ; e8a2 .room_in_party xor a - ld [wCaughtMon], a + ld [wWildMon], a ld a, [CurItem] cp PARK_BALL call nz, Functionedfa @@ -394,7 +394,7 @@ endr ld a, [EnemyMonSpecies] .fail_to_catch - ld [wCaughtMon], a + ld [wWildMon], a ld c, 20 call DelayFrames @@ -416,7 +416,7 @@ endr ld [wcfca], a predef PlayBattleAnim - ld a, [wCaughtMon] + ld a, [wWildMon] and a jr nz, .caught ld a, [Buffer2] @@ -493,19 +493,19 @@ endr ld hl, EnemySubStatus5 bit SUBSTATUS_TRANSFORMED, [hl] jr nz, .Transformed - ld hl, wCaughtMonMoves + ld hl, wWildMonMoves ld de, EnemyMonMoves ld bc, NUM_MOVES call CopyBytes - ld hl, wCaughtMonPP + ld hl, wWildMonPP ld de, EnemyMonPP ld bc, NUM_MOVES call CopyBytes .Transformed ld a, [EnemyMonSpecies] - ld [wCaughtMon], a + ld [wWildMon], a ld [CurPartySpecies], a ld [wd265], a ld a, [BattleType] @@ -710,7 +710,7 @@ endr cp BATTLETYPE_CONTEST jr z, .used_park_ball - ld a, [wCaughtMon] + ld a, [wWildMon] and a jr z, .toss diff --git a/macros/move_effect.asm b/macros/move_effect.asm index 8842fdcd7..d25db45bd 100644 --- a/macros/move_effect.asm +++ b/macros/move_effect.asm @@ -17,7 +17,7 @@ endm command lowersub command hittargetnosub command raisesub - command resulttext + command failuretext command checkfaint command criticaltext command supereffectivetext diff --git a/main.asm b/main.asm index 7a77b77f6..924012f37 100644 --- a/main.asm +++ b/main.asm @@ -1001,7 +1001,7 @@ Function619c: ; 619c ld de, VTiles2 callba GetTrainerPic xor a - ld [$ffad], a + ld [hFillBox], a hlcoord 6, 4 lb bc, 7, 7 predef FillBox @@ -1013,7 +1013,7 @@ ShrinkFrame: ; 61b4 ld c, $31 predef DecompressPredef xor a - ld [$ffad], a + ld [hFillBox], a hlcoord 6, 4 lb bc, 7, 7 predef FillBox @@ -7487,11 +7487,11 @@ Functiond5fe: ; d5fe (3:55fe) cp $2 jr nz, .asm_d61c ld [hl], $0 - call Functiond61d + call .Incrementwd194 .asm_d61c ret -Functiond61d: ; d61d (3:561d) +.Incrementwd194: ; d61d (3:561d) ld hl, wd194 ld a, [hl] add $1 @@ -7757,14 +7757,14 @@ Functiond784: ; d784 and a ret z cp $1 - jr z, .asm_d792 + jr z, .load_15 ld de, $16 - jr .asm_d795 + jr .loaded_de -.asm_d792 +.load_15 ld de, $15 -.asm_d795 +.loaded_de push hl add hl, de ld a, " " @@ -7799,39 +7799,39 @@ Functiond7b4: ; d7b4 Functiond7c9: ; d7c9 ld a, [hCGB] and a - jr nz, .asm_d7d5 + jr nz, .cgb call DelayFrame call DelayFrame ret -.asm_d7d5 +.cgb ld a, [wd10a] and a - jr z, .asm_d829 + jr z, .load_0 cp $1 - jr z, .asm_d82d + jr z, .load_1 ld a, [CurPartyMon] cp $3 - jr nc, .asm_d7ea + jr nc, .c_is_1 ld c, $0 - jr .asm_d7ec + jr .c_is_0 -.asm_d7ea +.c_is_1 ld c, $1 -.asm_d7ec +.c_is_0 push af cp $2 - jr z, .asm_d7ff + jr z, .skip_delay cp $5 - jr z, .asm_d7ff + jr z, .skip_delay ld a, $2 ld [hBGMapMode], a ld a, c ld [hBGMapThird], a call DelayFrame -.asm_d7ff +.skip_delay ld a, $1 ld [hBGMapMode], a ld a, c @@ -7839,12 +7839,12 @@ Functiond7c9: ; d7c9 call DelayFrame pop af cp $2 - jr z, .asm_d813 + jr z, .two_frames cp $5 - jr z, .asm_d813 + jr z, .two_frames ret -.asm_d813 +.two_frames inc c ld a, $2 ld [hBGMapMode], a @@ -7858,14 +7858,14 @@ Functiond7c9: ; d7c9 call DelayFrame ret -.asm_d829 +.load_0 ld c, $0 - jr .asm_d82f + jr .finish -.asm_d82d +.load_1 ld c, $1 -.asm_d82f +.finish call DelayFrame ld a, c ld [hBGMapThird], a @@ -7880,23 +7880,23 @@ Functiond839: ; d839 ld hl, 0 ld a, [wd1f1] cp $30 - jr nc, .asm_d885 + jr nc, .coppy_buffer and a - jr z, .asm_d880 + jr z, .return_zero call AddNTimes ld b, $0 -.asm_d851 +.loop ld a, l sub $30 ld l, a ld a, h sbc $0 ld h, a - jr c, .asm_d85e + jr c, .done inc b - jr .asm_d851 + jr .loop -.asm_d85e +.done push bc ld bc, $80 add hl, bc @@ -7907,28 +7907,28 @@ Functiond839: ; d839 ld a, h sbc $0 ld h, a - jr c, .asm_d86f + jr c, .no_carry inc b -.asm_d86f +.no_carry ld a, [wd1f5] cp b - jr nc, .asm_d87c + jr nc, .finish ld a, [wd1f6] cp b - jr c, .asm_d87c + jr c, .finish ld a, b -.asm_d87c +.finish ld [wd1ec], a ret -.asm_d880 +.return_zero xor a ld [wd1ec], a ret -.asm_d885 +.coppy_buffer ld a, [Buffer1] ld [wd1ec], a ret @@ -8262,10 +8262,10 @@ endr FillPP: ; da6d push bc ld b, NUM_MOVES -.asm_da70 +.loop ld a, [hli] and a - jr z, .asm_da8f + jr z, .next dec a push hl push de @@ -8281,11 +8281,11 @@ FillPP: ; da6d pop hl ld a, [StringBuffer1 + MOVE_PP] -.asm_da8f +.next ld [de], a inc de dec b - jr nz, .asm_da70 + jr nz, .loop pop bc ret ; da96 @@ -8396,13 +8396,13 @@ SentGetPkmnIntoFromBox: ; db3f ld a, [hl] cp MONS_PER_BOX jr nz, .there_is_room - jp CloseSRAM_And_SetCFlag + jp CloseSRAM_And_SetCarryFlag .check_IfPartyIsFull ld hl, PartyCount ld a, [hl] cp PARTY_LENGTH - jp z, CloseSRAM_And_SetCFlag + jp z, CloseSRAM_And_SetCarryFlag .there_is_room inc a @@ -8529,7 +8529,7 @@ SentGetPkmnIntoFromBox: ; db3f cp PC_DEPOSIT jr z, .took_out_of_box cp DAYCARE_DEPOSIT - jp z, .CloseSRAM_And_ClearCFlag + jp z, .CloseSRAM_And_ClearCarryFlag push hl srl a @@ -8560,7 +8560,7 @@ SentGetPkmnIntoFromBox: ; db3f ld a, [wPokemonWithdrawDepositParameter] and a - jr nz, .CloseSRAM_And_ClearCFlag + jr nz, .CloseSRAM_And_ClearCarryFlag ld hl, MON_STATUS add hl, bc xor a @@ -8580,14 +8580,14 @@ endr ld a, [hl] inc de ld [de], a - jr .CloseSRAM_And_ClearCFlag + jr .CloseSRAM_And_ClearCarryFlag .egg xor a ld [de], a inc de ld [de], a - jr .CloseSRAM_And_ClearCFlag + jr .CloseSRAM_And_ClearCarryFlag .took_out_of_box ld a, [sBoxCount] @@ -8595,13 +8595,13 @@ endr ld b, a call Functiondcb6 -.CloseSRAM_And_ClearCFlag +.CloseSRAM_And_ClearCarryFlag call CloseSRAM and a ret ; dcb1 -CloseSRAM_And_SetCFlag: ; dcb1 +CloseSRAM_And_SetCarryFlag: ; dcb1 call CloseSRAM scf ret @@ -19131,7 +19131,7 @@ Function16cc8: ; 16cc8 call Function16cff hlcoord 1, 6 xor a - ld [$ffad], a + ld [hFillBox], a lb bc, 7, 7 predef FillBox ld de, VTiles2 tile $31 @@ -19213,7 +19213,7 @@ Function16dac: ; 16dac call ByteFill hlcoord 7, 11 ld a, $31 - ld [$ffad], a + ld [hFillBox], a lb bc, 7, 7 predef FillBox ret @@ -19950,7 +19950,7 @@ Function17254: ; 17254 (5:7254) ld a, b ld [hBGMapAddress + 1], a ld a, c - ld [$ffad], a + ld [hFillBox], a lb bc, 7, 7 predef FillBox pop af @@ -20832,7 +20832,7 @@ Pokepic:: ; 244e3 ld c, a call GetTileCoord ld a, $80 - ld [$ffad], a + ld [hFillBox], a lb bc, 7, 7 predef FillBox call WaitBGMap @@ -22991,7 +22991,7 @@ Function25299: ; 25299 (9:5299) hlcoord 14, 1 lb bc, 5, 7 xor a - ld [$ffad], a + ld [hFillBox], a predef FillBox ret ; 252ec (9:52ec) @@ -28076,7 +28076,7 @@ Function294c3: ; 294c3 call Function297cf hlcoord 7, 2 xor a - ld [$ffad], a + ld [hFillBox], a lb bc, 7, 7 predef FillBox call WaitBGMap @@ -32294,7 +32294,7 @@ endr FillBox: ; 2ef6e ; Fill wc2c6-aligned box width b height c -; with iterating tile starting from $ffad at hl. +; with iterating tile starting from hFillBox at hl. ; Predef $13 ld de, 20 @@ -32303,7 +32303,7 @@ FillBox: ; 2ef6e and a jr nz, .left - ld a, [$ffad] + ld a, [hFillBox] .x1 push bc push hl @@ -32330,7 +32330,7 @@ FillBox: ; 2ef6e add hl, bc pop bc - ld a, [$ffad] + ld a, [hFillBox] .x2 push bc push hl @@ -48128,7 +48128,7 @@ Function81adb: ; 81adb ld de, VTiles2 tile $31 predef GetBackpic ld a, $31 - ld [$ffad], a + ld [hFillBox], a hlcoord 2, 4 lb bc, 6, 6 predef FillBox @@ -48160,7 +48160,7 @@ Function81adb: ; 81adb callab GetTrainerPic xor a ld [TempEnemyMonSpecies], a - ld [$ffad], a + ld [hFillBox], a hlcoord 2, 3 lb bc, 7, 7 predef FillBox @@ -50997,7 +50997,7 @@ endr ld de, VTiles2 tile $31 predef GetBackpic ld a, $31 - ld [$ffad], a + ld [hFillBox], a hlcoord 6, 6 lb bc, 6, 6 predef FillBox @@ -51295,7 +51295,7 @@ Function86810: ; 86810 call ByteFill callba GetPlayerBackpic ld a, $31 - ld [$ffad], a + ld [hFillBox], a hlcoord 6, 6 lb bc, 6, 6 predef FillBox @@ -51319,7 +51319,7 @@ Function86810: ; 86810 call ByteFill callba Function88840 xor a - ld [$ffad], a + ld [hFillBox], a hlcoord 12, 5 lb bc, 7, 7 predef FillBox @@ -51635,7 +51635,7 @@ DrawIntroPlayerPic: ; 88874 ; Draw xor a - ld [$ffad], a + ld [hFillBox], a hlcoord 6, 4 lb bc, 7, 7 predef FillBox @@ -52482,7 +52482,7 @@ Function8ce14: ; 8ce14 Function8ce19: ; 8ce19 ld d, $55 - ld a, [wd195] + ld a, [wd194 + 1] ld e, a ld b, $15 ld a, [rSVBK] @@ -75652,22 +75652,22 @@ EnterWestConnection: ; 1045ed ld h, [hl] ld l, a srl c - jr z, .asm_10461e + jr z, .skip_to_load ld a, [WestConnectedMapWidth] add 6 ld e, a ld d, 0 -.asm_10461a +.loop add hl, de dec c - jr nz, .asm_10461a + jr nz, .loop -.asm_10461e +.skip_to_load ld a, l ld [wd194], a ld a, h - ld [wd195], a + ld [wd194 + 1], a jp EnteredConnection ; 104629 @@ -75689,22 +75689,22 @@ EnterEastConnection: ; 104629 ld h, [hl] ld l, a srl c - jr z, .asm_10465a + jr z, .skip_to_load ld a, [EastConnectedMapWidth] add 6 ld e, a ld d, 0 -.asm_104656 +.loop add hl, de dec c - jr nz, .asm_104656 + jr nz, .loop -.asm_10465a +.skip_to_load ld a, l ld [wd194], a ld a, h - ld [wd195], a + ld [wd194 + 1], a jp EnteredConnection ; 104665 @@ -75731,7 +75731,7 @@ EnterNorthConnection: ; 104665 ld a, l ld [wd194], a ld a, h - ld [wd195], a + ld [wd194 + 1], a jp EnteredConnection ; 104696 @@ -75758,7 +75758,7 @@ EnterSouthConnection: ; 104696 ld a, l ld [wd194], a ld a, h - ld [wd195], a + ld [wd194 + 1], a ; fallthrough ; 1046c4 @@ -75994,16 +75994,16 @@ GetCoordOfUpperLeftCorner:: ; 10486d ld hl, OverworldMap ld a, [XCoord] bit 0, a - jr nz, .asm_10487d + jr nz, .increment_then_halve1 srl a add $1 - jr .asm_104881 + jr .resume -.asm_10487d +.increment_then_halve1 add $1 srl a -.asm_104881 +.resume ld c, a ld b, $0 add hl, bc @@ -76013,21 +76013,21 @@ GetCoordOfUpperLeftCorner:: ; 10486d ld b, $0 ld a, [YCoord] bit 0, a - jr nz, .asm_10489a + jr nz, .increment_then_halve2 srl a add $1 - jr .asm_10489e + jr .resume2 -.asm_10489a +.increment_then_halve2 add $1 srl a -.asm_10489e +.resume2 call AddNTimes ld a, l ld [wd194], a ld a, h - ld [wd195], a + ld [wd194 + 1], a ld a, [YCoord] and $1 ld [wd196], a @@ -77777,7 +77777,7 @@ UsedMoveText: ; 105db9 ld [wd265], a push hl - callba Function34548 + callba CheckUserIsCharging pop hl jr nz, .grammar @@ -79228,14 +79228,14 @@ INCLUDE "text/phone/extra3.asm" SECTION "bank5E", ROMX, BANK[$5E] -Function178000: +_UpdateBattleHUDs: callba DrawPlayerHUD ld hl, PlayerHPPal call SetHPPal callba DrawEnemyHUD ld hl, EnemyHPPal call SetHPPal - callba Function3ee27 + callba FinishBattleAnim ret ; 17801f (5e:401f) diff --git a/misc/mobile_22.asm b/misc/mobile_22.asm index 78fef3f56..c11ca8a14 100644 --- a/misc/mobile_22.asm +++ b/misc/mobile_22.asm @@ -1253,7 +1253,7 @@ Function897d5: ; 897d5 .asm_897f3 ld a, $37 - ld [$ffad], a + ld [hFillBox], a hlcoord 12, 3 lb bc, 7, 7 predef FillBox diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index e7b73aa36..70091db27 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -1618,7 +1618,7 @@ Function100a09: ; 100a09 call Function100a87 call Function100da5 - callba Function3ee27 + callba FinishBattleAnim jr .asm_100a2d .asm_100a2a diff --git a/misc/mobile_42.asm b/misc/mobile_42.asm index 72a8f9e8c..591a26e1f 100644 --- a/misc/mobile_42.asm +++ b/misc/mobile_42.asm @@ -1210,7 +1210,7 @@ asm_108966 call Function108ac8 hlcoord 7, 2 xor a - ld [$ffad], a + ld [hFillBox], a ld bc, $0707 predef FillBox call WaitBGMap @@ -1224,7 +1224,7 @@ Function10898a: ; 10898a call Function108ac8 hlcoord 7, 2 xor a - ld [$ffad], a + ld [hFillBox], a ld bc, $0707 predef FillBox call WaitBGMap diff --git a/wram.asm b/wram.asm index d7882fa17..2436884be 100644 --- a/wram.asm +++ b/wram.asm @@ -473,7 +473,7 @@ wc64c:: ds 1 wc64d:: ds 1 -wCaughtMon:: +wWildMon:: wc64e:: ds 1 ds 1 wEnemyTrainerItem1:: ds 1 @@ -635,7 +635,8 @@ BattleScriptBuffer:: ; c68a BattleScriptBufferLoc:: ; c6b2 ds 2 -wc6b4:: ds 2 +wTurnEnded:: ds 1 + ds 1 PlayerStats:: ; c6b6 ds 10 @@ -862,10 +863,10 @@ wc734:: BattleEnded:: ; c734 ds 1 -wCaughtMonMoves:: +wWildMonMoves:: wc735:: ds 1 wc736:: ds 3 -wCaughtMonPP:: +wWildMonPP:: wc739:: ds 4 wc73d:: ds 1 wc73e:: ds 1 @@ -1627,7 +1628,11 @@ wd151:: ds 1 wd152:: ds 1 wd153:: ds 1 -UsedSprites:: ; d154 +UsedSprites:: ds 64 +UsedSpritesEnd:: + ds UsedSprites - @ + +wd154:: ; d154 ds 31 ; 64 wd173:: ds 1 @@ -1639,9 +1644,7 @@ wd182:: ds 1 wd191:: ds 1 wd192:: ds 1 wd193:: ds 1 -UsedSpritesEnd:: -wd194:: ds 1 -wd195:: ds 1 +wd194:: dw wd196:: ds 1 wd197:: ds 2 wd199:: ds 1 @@ -2731,7 +2734,7 @@ OBPals:: ds 8 * 8 ; d0c0 LYOverrides:: ; d100 ds SCREEN_HEIGHT_PX -LYOverridesEnd:: +LYOverridesEnd:: ; d190 ds 1 w5_d191:: ds 1 @@ -2781,7 +2784,9 @@ w5_d418:: ds 1 BattleAnimTemps:: ; d419 ds 8 ds 1 -w5_d422:: ds $40 +w5_d422:: ds $32 +wBattleAnimEnd:: + ds $e SECTION "WRAM 6", WRAMX, BANK [6]