summaryrefslogtreecommitdiff
path: root/battle
diff options
context:
space:
mode:
Diffstat (limited to 'battle')
-rw-r--r--battle/ai/items.asm47
-rwxr-xr-xbattle/ai/move.asm7
-rw-r--r--battle/ai/scoring.asm178
-rwxr-xr-xbattle/ai/switch.asm94
-rw-r--r--battle/anim_commands.asm19
-rw-r--r--battle/anims.asm236
-rw-r--r--battle/bg_effects.asm265
-rw-r--r--battle/core.asm191
-rw-r--r--battle/effect_commands.asm50
-rw-r--r--battle/hidden_power.asm6
-rwxr-xr-xbattle/link_result.asm162
-rw-r--r--battle/magikarp_length.asm3
-rw-r--r--battle/misc.asm6
-rwxr-xr-xbattle/objects/data.asm52
-rwxr-xr-xbattle/objects/functions.asm212
-rwxr-xr-xbattle/sliding_intro.asm13
-rwxr-xr-xbattle/trainer_huds.asm10
17 files changed, 798 insertions, 753 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm
index 16511de79..4405ae756 100644
--- a/battle/ai/items.asm
+++ b/battle/ai/items.asm
@@ -196,9 +196,9 @@ AI_TryItem: ; 38105
jr z, .has_item
dec de
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
jr .loop
.has_item
@@ -216,9 +216,8 @@ endr
pop de
pop hl
-rept 2
inc hl
-endr
+ inc hl
jr c, .loop
.used_item
@@ -572,20 +571,20 @@ EnemyUsedFullHeal: ; 383a3 (e:43a3)
EnemyUsedMaxPotion: ; 383ae (e:43ae)
ld a, MAX_POTION
- ld [wd1f1], a
+ ld [CurEnemyItem], a
jr FullRestoreContinue
EnemyUsedFullRestore: ; 383b5 (e:43b5)
call AI_HealStatus
ld a, FULL_RESTORE
- ld [wd1f1], a
+ ld [CurEnemyItem], a
ld hl, EnemySubStatus3
res SUBSTATUS_CONFUSED, [hl]
xor a
ld [EnemyConfuseCount], a
FullRestoreContinue: ; 383c6
- ld de, wd1ec
+ ld de, wCurHPAnimOldHP
ld hl, EnemyMonHP + 1
ld a, [hld]
ld [de], a
@@ -597,11 +596,11 @@ FullRestoreContinue: ; 383c6
ld a, [hld]
ld [de], a
inc de
- ld [Buffer1], a
+ ld [wCurHPAnimMaxHP], a
ld [EnemyMonHP + 1], a
ld a, [hl]
ld [de], a
- ld [Buffer2], a
+ ld [wCurHPAnimMaxHP + 1], a
ld [EnemyMonHP], a
jr EnemyPotionFinish
; 383e8 (e:43e8)
@@ -621,20 +620,20 @@ EnemyUsedHyperPotion: ; 383f4 (e:43f4)
ld b, 200
EnemyPotionContinue: ; 383f8
- ld [wd1f1], a
+ ld [CurEnemyItem], a
ld hl, EnemyMonHP + 1
ld a, [hl]
- ld [wd1ec], a
+ ld [wCurHPAnimOldHP], a
add b
ld [hld], a
- ld [wd1ee], a
+ ld [wCurHPAnimNewHP], a
ld a, [hl]
- ld [wd1ec + 1], a
- ld [wd1ee + 1], a
+ ld [wCurHPAnimOldHP + 1], a
+ ld [wCurHPAnimNewHP + 1], a
jr nc, .ok
inc a
ld [hl], a
- ld [wd1ee + 1], a
+ ld [wCurHPAnimNewHP + 1], a
.ok
inc hl
ld a, [hld]
@@ -642,22 +641,22 @@ EnemyPotionContinue: ; 383f8
ld de, EnemyMonMaxHP + 1
ld a, [de]
dec de
- ld [Buffer1], a
+ ld [wCurHPAnimMaxHP], a
sub b
ld a, [hli]
ld b, a
ld a, [de]
- ld [Buffer2], a
+ ld [wCurHPAnimMaxHP + 1], a
sbc b
jr nc, EnemyPotionFinish
inc de
ld a, [de]
dec de
ld [hld], a
- ld [wd1ee], a
+ ld [wCurHPAnimNewHP], a
ld a, [de]
ld [hl], a
- ld [wd1ef], a
+ ld [wCurHPAnimNewHP + 1], a
EnemyPotionFinish: ; 38436
call PrintText_UsedItemOn
@@ -726,7 +725,7 @@ AI_Switch: ; 3846c
.skiptext
ld a, 1
- ld [wAISwitch], a
+ ld [wBattleHasJustStarted], a
callab NewEnemyMonStatus
callab ResetEnemyStatLevels
ld hl, PlayerSubStatus1
@@ -734,7 +733,7 @@ AI_Switch: ; 3846c
callba EnemySwitch
callba ResetBattleParticipants
xor a
- ld [wAISwitch], a
+ ld [wBattleHasJustStarted], a
ld a, [wLinkMode]
and a
ret nz
@@ -844,7 +843,7 @@ EnemyUsedXSpecial: ; 38553
; a = ITEM_CONSTANT
; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION)
EnemyUsedXItem:
- ld [wd1f1], a
+ ld [CurEnemyItem], a
push bc
call PrintText_UsedItemOn
pop bc
@@ -856,13 +855,13 @@ EnemyUsedXItem:
; Parameter
; a = ITEM_CONSTANT
PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568
- ld [wd1f1], a
+ ld [CurEnemyItem], a
call PrintText_UsedItemOn
jp AIUpdateHUD
; 38571
PrintText_UsedItemOn: ; 38571
- ld a, [wd1f1]
+ ld a, [CurEnemyItem]
ld [wd265], a
call GetItemName
ld hl, StringBuffer1
diff --git a/battle/ai/move.asm b/battle/ai/move.asm
index 0d1c6c968..6e5aca358 100755
--- a/battle/ai/move.asm
+++ b/battle/ai/move.asm
@@ -19,9 +19,9 @@ AIChooseMove: ; 440ce
; The default score is 20. Unusable moves are given a score of 80.
ld a, 20
ld hl, Buffer1
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
; Don't pick disabled moves.
@@ -107,9 +107,8 @@ endr
ld hl, AIScoringPointers
dec c
ld b, 0
-rept 2
add hl, bc
-endr
+ add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm
index 9b8dd6e42..3091697e5 100644
--- a/battle/ai/scoring.asm
+++ b/battle/ai/scoring.asm
@@ -133,18 +133,16 @@ AI_Setup: ; 385e0
call AI_50_50
jr c, .checkmove
-rept 2
dec [hl]
-endr
+ dec [hl]
jr .checkmove
.discourage
call Random
cp 30
jr c, .checkmove
-rept 2
inc [hl]
-endr
+ inc [hl]
jr .checkmove
; 38635
@@ -264,9 +262,8 @@ AI_Offensive: ; 386a2
and a
jr nz, .checkmove
-rept 2
inc [hl]
-endr
+ inc [hl]
jr .checkmove
; 386be
@@ -420,9 +417,8 @@ AI_Smart_Sleep: ; 387e3
.asm_387f0
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 387f7
@@ -533,9 +529,8 @@ AI_Smart_LockOn: ; 3881d
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38882
@@ -560,9 +555,8 @@ endr
cp 180
jr nc, .asm_3888b
-rept 2
dec [hl]
-endr
+ dec [hl]
jr .asm_3888b
.asm_388a2
@@ -602,9 +596,9 @@ AI_Smart_Explosion: ; 388a6
ret c
.asm_388c6
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 388ca
@@ -616,9 +610,9 @@ AI_Smart_DreamEater: ; 388ca
call Random
cp 25
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 388d4
@@ -645,9 +639,8 @@ AI_Smart_EvasionUp: ; 388d4
jr nc, .asm_38911
.asm_388ef
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_388f2
@@ -676,9 +669,8 @@ endr
jr c, .asm_38911
.asm_3890f
-rept 2
inc [hl]
-endr
+ inc [hl]
; 30% chance to end up here if enemy's HP is full and player is not badly poisoned.
; 77% chance to end up here if enemy's HP is above 50% but not full.
@@ -722,9 +714,8 @@ endr
call Random
cp $50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; Player is seeded.
@@ -756,9 +747,8 @@ AI_Smart_AlwaysHit: ; 38947
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 3895b
@@ -828,9 +818,8 @@ AI_Smart_AccuracyDown: ; 38985
jr nc, .asm_389bf
.asm_3899d
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_389a0
@@ -859,9 +848,8 @@ endr
jr c, .asm_389bf
.asm_389bd
-rept 2
inc [hl]
-endr
+ inc [hl]
; We only end up here if the move has not been already encouraged.
.asm_389bf
@@ -900,9 +888,8 @@ endr
call Random
cp $50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; Player is seeded.
@@ -1010,9 +997,8 @@ AI_Smart_Moonlight: ; 38a3a
call Random
cp $19
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38a4e
@@ -1093,9 +1079,8 @@ AI_Smart_Bind: ; 38a71
ret nc
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38a9c
@@ -1200,9 +1185,8 @@ AI_Smart_SpDefenseUp2: ; 38aed
.asm_38b09
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38b10
@@ -1224,9 +1208,9 @@ AI_Smart_Fly: ; 38b12
call AICompareSpeed
ret nc
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38b20
@@ -1255,9 +1239,8 @@ AI_Smart_Paralyze: ; 38b26
ret nc
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38b3a
@@ -1289,9 +1272,8 @@ AI_Smart_SpeedDownHit: ; 38b40
call Random
cp 30
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38b5c
@@ -1528,15 +1510,14 @@ AI_Smart_Encore: ; 38c3b
call Random
cp $46
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38c81
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
.EncoreMoves:
@@ -1606,15 +1587,15 @@ AI_Smart_SleepTalk: ; 38cba
cp $1
jr z, .asm_38cc7
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
.asm_38cc7
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 38ccb
@@ -1626,9 +1607,9 @@ AI_Smart_DefrostOpponent: ; 38ccb
ld a, [EnemyMonStatus]
and $20
ret z
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38cd5
@@ -1685,9 +1666,8 @@ AI_Smart_Spite: ; 38cd5
call Random
cp $64
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38d16
@@ -1728,9 +1708,9 @@ AI_Smart_HealBell: ; 38d1f
jr z, .next
; status
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld a, [hl]
or c
ld c, a
@@ -1755,9 +1735,8 @@ endr
ret z
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.no_status
@@ -1795,9 +1774,9 @@ AI_Smart_PriorityHit: ; 38d5a
ld a, [BattleMonHP]
sbc b
ret nc
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38d93
@@ -1921,9 +1900,9 @@ AI_Smart_MeanLook: ; 38dfb
.asm_38e26
call AI_80_20
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38e2e
@@ -2007,15 +1986,13 @@ AI_Smart_Curse: ; 38e5c
ret nc
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38e90
-rept 2
inc [hl]
-endr
+ inc [hl]
.asm_38e92
inc [hl]
.asm_38e93
@@ -2065,9 +2042,8 @@ endr
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38ed2
@@ -2119,9 +2095,8 @@ AI_Smart_Protect: ; 38ed2
call Random
cp 20
ret c
-rept 2
inc [hl]
-endr
+ inc [hl]
ret
; 38f1d
@@ -2151,9 +2126,8 @@ AI_Smart_Foresight: ; 38f1d
call Random
cp 100
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38f4a
@@ -2259,9 +2233,9 @@ AI_Smart_Endure: ; 38fac
call AI_80_20
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
.asm_38fcb
@@ -2272,9 +2246,8 @@ endr
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38fd8
@@ -2296,15 +2269,14 @@ AI_Smart_FuryCutter: ; 38fdb
cp 2
jr c, .end
-rept 2
dec [hl]
-endr
+ dec [hl]
cp 3
jr c, .end
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
.end
@@ -2344,9 +2316,8 @@ AI_Smart_Rollout: ; 38fef
call Random
cp 200
ret nc
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_39020
@@ -2406,9 +2377,8 @@ AI_Smart_Earthquake: ; 39044
call AICompareSpeed
ret nc
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.could_dig
@@ -2455,9 +2425,8 @@ AI_Smart_Pursuit: ; 39072
.asm_3907d
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 39084
@@ -2482,9 +2451,8 @@ AI_Smart_RapidSpin: ; 39084
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 3909e
@@ -2611,9 +2579,9 @@ AI_Smart_WeatherMove: ; 3910d
; 3911e
AIBadWeatherType: ; 3911e
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 39122
@@ -2636,9 +2604,8 @@ AIGoodWeatherType: ; 39122
ret nz
.good
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 39134
@@ -2733,9 +2700,8 @@ AI_Smart_PsychUp: ; 39152
ret
.asm_39188
-rept 2
inc [hl]
-endr
+ inc [hl]
ret
; 3918b
@@ -2820,9 +2786,8 @@ AI_Smart_Gust: ; 391d5
call AICompareSpeed
ret nc
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; Try to predict if the player will use Fly this turn.
@@ -2849,9 +2814,8 @@ AI_Smart_FutureSight: ; 391f3
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
ret z
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 39200
@@ -2886,18 +2850,16 @@ AI_Smart_Solarbeam: ; 3920b
cp 25 ; 1/10
ret c
-rept 2
inc [hl]
-endr
+ inc [hl]
ret
.asm_3921e
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 39225
@@ -2991,9 +2953,8 @@ AICheckPlayerHalfHP: ; 3926e
ld c, [hl]
sla c
rl b
-rept 2
inc hl
-endr
+ inc hl
ld a, [hld]
cp c
ld a, [hl]
@@ -3013,9 +2974,8 @@ AICheckEnemyHalfHP: ; 39281
ld c, [hl]
sla c
rl b
-rept 2
inc hl
-endr
+ inc hl
ld a, [hld]
cp c
ld a, [hl]
@@ -3039,9 +2999,8 @@ AICheckEnemyQuarterHP: ; 39298
rl b
sla c
rl b
-rept 2
inc hl
-endr
+ inc hl
ld a, [hld]
cp c
ld a, [hl]
@@ -3063,9 +3022,8 @@ AICheckPlayerQuarterHP: ; 392b3
rl b
sla c
rl b
-rept 2
inc hl
-endr
+ inc hl
ld a, [hld]
cp c
ld a, [hl]
diff --git a/battle/ai/switch.asm b/battle/ai/switch.asm
index 8f5db7a54..cb1fe3660 100755
--- a/battle/ai/switch.asm
+++ b/battle/ai/switch.asm
@@ -136,9 +136,11 @@ CheckPlayerMoveTypeMatchups: ; 3484e
jr c, .loop2
; neutral
-rept 5
inc c
-endr
+ inc c
+ inc c
+ inc c
+ inc c
cp 10
jr z, .loop2
@@ -161,11 +163,6 @@ endr
.doubledown
call .DecreaseScore
-
- ; fallthrough
-; 34931
-
-
.DecreaseScore: ; 34931
ld a, [wEnemyAISwitchScore]
dec a
@@ -173,7 +170,6 @@ endr
ret
; 34939
-
.IncreaseScore: ; 34939
ld a, [wEnemyAISwitchScore]
inc a
@@ -198,16 +194,16 @@ CheckAbleToSwitch: ; 34941
; Perish count is 1
call FindAliveEnemyMons
- call FindEnemyMonsWithEnoughHP
+ call FindEnemyMonsWithAtLeastQuarterMaxHP
call FindEnemyMonsThatResistPlayer
- call Function34a85
+ call FindAliveEnemyMonsWithASuperEffectiveMove
ld a, e
cp 2
jr nz, .not_2
ld a, [wEnemyAISwitchScore]
- add $30
+ add $30 ; maximum chance
ld [wEnemySwitchMonParam], a
ret
@@ -223,12 +219,11 @@ CheckAbleToSwitch: ; 34941
jr nc, .loop1
ld a, b
- add $30
+ add $30 ; maximum chance
ld [wEnemySwitchMonParam], a
ret
.no_perish
-
call CheckPlayerMoveTypeMatchups
ld a, [wEnemyAISwitchScore]
cp 11
@@ -238,13 +233,13 @@ CheckAbleToSwitch: ; 34941
and a
jr z, .no_last_counter_move
- call Function34a2a
+ call FindEnemyMonsImmuneToLastCounterMove
ld a, [wEnemyAISwitchScore]
and a
jr z, .no_last_counter_move
ld c, a
- call Function34aa7
+ call FindEnemyMonsWithASuperEffectiveMove
ld a, [wEnemyAISwitchScore]
cp $ff
ret z
@@ -285,9 +280,9 @@ CheckAbleToSwitch: ; 34941
ret nc
call FindAliveEnemyMons
- call FindEnemyMonsWithEnoughHP
+ call FindEnemyMonsWithAtLeastQuarterMaxHP
call FindEnemyMonsThatResistPlayer
- call Function34a85
+ call FindAliveEnemyMonsWithASuperEffectiveMove
ld a, e
cp $2
@@ -352,7 +347,7 @@ FindAliveEnemyMons: ; 349f4
; 34a2a
-Function34a2a: ; 34a2a
+FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
ld hl, OTPartyMon1
ld a, [OTPartyCount]
ld b, a
@@ -361,44 +356,50 @@ Function34a2a: ; 34a2a
xor a
ld [wEnemyAISwitchScore], a
-.asm_34a39
+.loop
ld a, [CurOTMon]
cp d
push hl
- jr z, .asm_34a77
+ jr z, .next
push hl
push bc
+
+ ; If the Pokemon has at least 1 HP...
ld bc, MON_HP
add hl, bc
pop bc
ld a, [hli]
or [hl]
pop hl
- jr z, .asm_34a77
+ jr z, .next
ld a, [hl]
ld [CurSpecies], a
call GetBaseData
+
+ ; the enemy's last move is damaging...
ld a, [LastEnemyCounterMove]
dec a
ld hl, Moves + MOVE_POWER
call GetMoveAttr
and a
- jr z, .asm_34a77
+ jr z, .next
+ ; and the Pokemon is immune to it...
inc hl
call GetMoveByte
ld hl, BaseType
call CheckTypeMatchup
ld a, [wTypeMatchup]
and a
- jr nz, .asm_34a77
+ jr nz, .next
+ ; ... encourage that Pokemon.
ld a, [wEnemyAISwitchScore]
or c
ld [wEnemyAISwitchScore], a
-.asm_34a77
+.next
pop hl
dec b
ret z
@@ -410,11 +411,11 @@ Function34a2a: ; 34a2a
inc d
srl c
- jr .asm_34a39
+ jr .loop
; 34a85
-Function34a85: ; 34a85
+FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85
push bc
ld a, [OTPartyCount]
ld e, a
@@ -444,13 +445,9 @@ Function34a85: ; 34a85
and c
ld c, a
+FindEnemyMonsWithASuperEffectiveMove: ; 34aa7
- ; fallthrough
-; 34aa7
-
-Function34aa7: ; 34aa7
-
- ld a, $ff
+ ld a, -1
ld [wEnemyAISwitchScore], a
ld hl, OTPartyMon1Moves
ld b, 1 << (PARTY_LENGTH - 1)
@@ -463,32 +460,40 @@ Function34aa7: ; 34aa7
push hl
push bc
+ ; for move on mon:
ld b, NUM_MOVES
ld c, 0
.loop3
+ ; if move is None: break
ld a, [hli]
and a
push hl
jr z, .break3
+ ; if move has no power: continue
dec a
ld hl, Moves + MOVE_POWER
call GetMoveAttr
and a
jr z, .nope
+ ; check type matchups
inc hl
call GetMoveByte
ld hl, BattleMonType1
call CheckTypeMatchup
+
+ ; if immune or not very effective: continue
ld a, [wTypeMatchup]
cp 10
jr c, .nope
+ ; if neutral: load 1 and continue
ld e, 1
cp 10 + 1
jr c, .nope
+ ; if super-effective: load 2 and break
ld e, 2
jr .break3
@@ -505,18 +510,19 @@ Function34aa7: ; 34aa7
ld a, e
pop bc
pop hl
- cp $2
- jr z, .done2
-
- cp $1
- jr nz, .next
+ cp 2
+ jr z, .done2 ; at least one move is super-effective
+ cp 1
+ jr nz, .next ; no move does more than half damage
+ ; encourage this pokemon
ld a, d
or b
ld d, a
- jr .next
+ jr .next ; such a long jump
.next
+ ; next pokemon?
push bc
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
@@ -524,12 +530,14 @@ Function34aa7: ; 34aa7
srl b
jr nc, .loop
+ ; if no pokemon has a super-effective move: return
ld a, d
ld b, a
and a
ret z
.done2
+ ; convert the bit flag to an int and return
push bc
sla b
sla b
@@ -608,7 +616,7 @@ FindEnemyMonsThatResistPlayer: ; 34b20
; 34b77
-FindEnemyMonsWithEnoughHP: ; 34b77
+FindEnemyMonsWithAtLeastQuarterMaxHP: ; 34b77
push bc
ld de, OTPartySpecies
ld b, 1 << (PARTY_LENGTH - 1)
@@ -626,17 +634,15 @@ FindEnemyMonsWithEnoughHP: ; 34b77
ld b, [hl]
inc hl
ld c, [hl]
-rept 2
inc hl
-endr
+ inc hl
; hl = MaxHP + 1
-; b = (4 * b) % $100 + (c & 3)
-; c = c / 4
+; bc = [CurHP] * 4
srl c
rl b
srl c
rl b
-; a = (MaxHP / $100) - b - (1 if c > (MaxHP % $100) else 0)
+; if bc >= [hl], encourage
ld a, [hld]
cp c
ld a, [hl]
diff --git a/battle/anim_commands.asm b/battle/anim_commands.asm
index 48dc9c433..957b2a066 100644
--- a/battle/anim_commands.asm
+++ b/battle/anim_commands.asm
@@ -108,7 +108,7 @@ RunBattleAnimScript: ; cc163
call RunBattleAnimCommand
call _ExecuteBGEffects
call BattleAnim_UpdateOAM_All
- call Function3b0c
+ call PushLYOverrides
call BattleAnimRequestPals
; Speed up Rollout's animation.
@@ -265,9 +265,9 @@ BattleAnim_ClearCGB_OAMFlags: ; cc23d
ld a, [hl]
and $f0
ld [hli], a
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
dec c
jr nz, .loop
ret
@@ -382,7 +382,7 @@ BattleAnimCommands:: ; cc2a4 (33:42a4)
dw BattleAnimCmd_EB ; dummy
dw BattleAnimCmd_EC ; dummy
dw BattleAnimCmd_ED ; dummy
- dw BattleAnimCmd_JumpAnd
+ dw BattleAnimCmd_IfParamAnd
dw BattleAnimCmd_JumpUntil
dw BattleAnimCmd_BGEffect
dw BattleAnimCmd_BGP
@@ -392,10 +392,10 @@ BattleAnimCommands:: ; cc2a4 (33:42a4)
dw BattleAnimCmd_F5
dw BattleAnimCmd_F6
dw BattleAnimCmd_F7
- dw BattleAnimCmd_JumpIf
+ dw BattleAnimCmd_IfParamEqual
dw BattleAnimCmd_SetVar
dw BattleAnimCmd_IncVar
- dw BattleAnimCmd_JumpVar
+ dw BattleAnimCmd_IfVarEqual
dw BattleAnimCmd_Jump
dw BattleAnimCmd_Loop
dw BattleAnimCmd_Call
@@ -535,7 +535,7 @@ BattleAnimCmd_IncVar: ; cc3ad (33:43ad)
inc [hl]
ret
-BattleAnimCmd_JumpVar: ; cc3b2 (33:43b2)
+BattleAnimCmd_IfVarEqual: ; cc3b2 (33:43b2)
call GetBattleAnimByte
ld hl, BattleAnimVar
cp [hl]
@@ -563,7 +563,7 @@ BattleAnimCmd_JumpVar: ; cc3b2 (33:43b2)
ld [hl], d
ret
-BattleAnimCmd_JumpIf: ; cc3d6 (33:43d6)
+BattleAnimCmd_IfParamEqual: ; cc3d6 (33:43d6)
call GetBattleAnimByte
ld hl, wBattleAnimParam
cp [hl]
@@ -591,7 +591,7 @@ BattleAnimCmd_JumpIf: ; cc3d6 (33:43d6)
ld [hl], d
ret
-BattleAnimCmd_JumpAnd: ; cc3fa (33:43fa)
+BattleAnimCmd_IfParamAnd: ; cc3fa (33:43fa)
call GetBattleAnimByte
ld e, a
ld a, [wBattleAnimParam]
@@ -608,6 +608,7 @@ BattleAnimCmd_JumpAnd: ; cc3fa (33:43fa)
dec hl
ld [hl], e
ret
+
.jump
call GetBattleAnimByte
ld e, a
diff --git a/battle/anims.asm b/battle/anims.asm
index 7a4e8459c..e0b7f0014 100644
--- a/battle/anims.asm
+++ b/battle/anims.asm
@@ -303,10 +303,10 @@ BattleAnim_SweetScent2: ; c929c
; c92c1
BattleAnim_ThrowPokeBall
- anim_jumpif NO_ITEM, .TheTrainerBlockedTheBall
- anim_jumpif MASTER_BALL, .MasterBall
- anim_jumpif ULTRA_BALL, .UltraBall
- anim_jumpif GREAT_BALL, .GreatBall
+ anim_if_param_equal NO_ITEM, .TheTrainerBlockedTheBall
+ anim_if_param_equal MASTER_BALL, .MasterBall
+ anim_if_param_equal ULTRA_BALL, .UltraBall
+ anim_if_param_equal GREAT_BALL, .GreatBall
; any other ball
anim_2gfx ANIM_GFX_POKE_BALL, ANIM_GFX_SMOKE
anim_sound 6, 2, SFX_THROW_BALL
@@ -316,7 +316,7 @@ BattleAnim_ThrowPokeBall
anim_setobj $2, $7
anim_wait 16
anim_sound 0, 1, SFX_BALL_POOF
- anim_obj ANIM_OBJ_1C, -15, 0, 8, 0, $10
+ anim_obj ANIM_OBJ_BALL_POOF, -15, 0, 8, 0, $10
anim_wait 16
anim_jump .Shake
; c92f2
@@ -324,7 +324,7 @@ BattleAnim_ThrowPokeBall
.TheTrainerBlockedTheBall:
anim_2gfx ANIM_GFX_POKE_BALL, ANIM_GFX_HIT
anim_sound 6, 2, SFX_THROW_BALL
- anim_obj ANIM_OBJ_16, 8, 0, 11, 4, $20
+ anim_obj ANIM_OBJ_POKE_BALL_BLOCKED, 8, 0, 11, 4, $20
anim_wait 20
anim_obj ANIM_OBJ_01, 14, 0, 5, 0, $0
anim_wait 32
@@ -340,7 +340,7 @@ BattleAnim_ThrowPokeBall
anim_setobj $2, $7
anim_wait 16
anim_sound 0, 1, SFX_BALL_POOF
- anim_obj ANIM_OBJ_1C, -15, 0, 8, 0, $10
+ anim_obj ANIM_OBJ_BALL_POOF, -15, 0, 8, 0, $10
anim_wait 16
anim_jump .Shake
; c9326
@@ -354,7 +354,7 @@ BattleAnim_ThrowPokeBall
anim_setobj $2, $7
anim_wait 16
anim_sound 0, 1, SFX_BALL_POOF
- anim_obj ANIM_OBJ_1C, -15, 0, 8, 0, $10
+ anim_obj ANIM_OBJ_BALL_POOF, -15, 0, 8, 0, $10
anim_wait 16
anim_jump .Shake
; c9347
@@ -368,17 +368,17 @@ BattleAnim_ThrowPokeBall
anim_setobj $2, $7
anim_wait 16
anim_sound 0, 1, SFX_BALL_POOF
- anim_obj ANIM_OBJ_1C, -15, 0, 8, 0, $10
+ anim_obj ANIM_OBJ_BALL_POOF, -15, 0, 8, 0, $10
anim_wait 24
anim_sound 0, 1, SFX_MASTER_BALL
- anim_obj ANIM_OBJ_2B, -15, 0, 7, 0, $30
- anim_obj ANIM_OBJ_2B, -15, 0, 7, 0, $31
- anim_obj ANIM_OBJ_2B, -15, 0, 7, 0, $32
- anim_obj ANIM_OBJ_2B, -15, 0, 7, 0, $33
- anim_obj ANIM_OBJ_2B, -15, 0, 7, 0, $34
- anim_obj ANIM_OBJ_2B, -15, 0, 7, 0, $35
- anim_obj ANIM_OBJ_2B, -15, 0, 7, 0, $36
- anim_obj ANIM_OBJ_2B, -15, 0, 7, 0, $37
+ anim_obj ANIM_OBJ_MASTER_BALL_SPARKLE, -15, 0, 7, 0, $30
+ anim_obj ANIM_OBJ_MASTER_BALL_SPARKLE, -15, 0, 7, 0, $31
+ anim_obj ANIM_OBJ_MASTER_BALL_SPARKLE, -15, 0, 7, 0, $32
+ anim_obj ANIM_OBJ_MASTER_BALL_SPARKLE, -15, 0, 7, 0, $33
+ anim_obj ANIM_OBJ_MASTER_BALL_SPARKLE, -15, 0, 7, 0, $34
+ anim_obj ANIM_OBJ_MASTER_BALL_SPARKLE, -15, 0, 7, 0, $35
+ anim_obj ANIM_OBJ_MASTER_BALL_SPARKLE, -15, 0, 7, 0, $36
+ anim_obj ANIM_OBJ_MASTER_BALL_SPARKLE, -15, 0, 7, 0, $37
anim_wait 64
.Shake:
anim_bgeffect ANIM_BG_RETURN_MON, $0, $0, $0
@@ -397,8 +397,8 @@ BattleAnim_ThrowPokeBall
.Loop:
anim_wait 48
anim_checkpokeball
- anim_jumpvar $1, .Click
- anim_jumpvar $2, .BreakFree
+ anim_if_var_equal $1, .Click
+ anim_if_var_equal $2, .BreakFree
anim_incobj 1
anim_sound 0, 1, SFX_BALL_WIGGLE
anim_jump .Loop
@@ -412,7 +412,7 @@ BattleAnim_ThrowPokeBall
.BreakFree:
anim_setobj $1, $b
anim_sound 0, 1, SFX_BALL_POOF
- anim_obj ANIM_OBJ_1C, -15, 0, 8, 0, $10
+ anim_obj ANIM_OBJ_BALL_POOF, -15, 0, 8, 0, $10
anim_wait 2
anim_bgeffect ANIM_BG_ENTER_MON, $0, $0, $0
anim_wait 32
@@ -420,9 +420,9 @@ BattleAnim_ThrowPokeBall
; c93d1
BattleAnim_SendOutMon: ; c93d1
- anim_jumpif $0, .Normal
- anim_jumpif $1, .Shiny
- anim_jumpif $2, .Unknown
+ anim_if_param_equal $0, .Normal
+ anim_if_param_equal $1, .Shiny
+ anim_if_param_equal $2, .Unknown
anim_1gfx ANIM_GFX_SMOKE
anim_call BattleAnim_FollowEnemyFeet_0
anim_bgeffect ANIM_BG_2B, $0, $1, $0
@@ -482,7 +482,7 @@ BattleAnim_SendOutMon: ; c93d1
.Normal:
anim_1gfx ANIM_GFX_SMOKE
anim_sound 0, 0, SFX_BALL_POOF
- anim_obj ANIM_OBJ_1C, 5, 4, 12, 0, $0
+ anim_obj ANIM_OBJ_BALL_POOF, 5, 4, 12, 0, $0
anim_wait 4
anim_bgeffect ANIM_BG_ENTER_MON, $0, $1, $0
anim_wait 32
@@ -543,13 +543,13 @@ BattleAnim_Psn: ; c94c5
BattleAnim_Sap: ; c94da
anim_1gfx ANIM_GFX_CHARGE
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, 16, 0, 6, 0, $2
+ anim_obj ANIM_OBJ_ABSORB, 16, 0, 6, 0, $2
anim_wait 6
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, -15, 0, 8, 0, $3
+ anim_obj ANIM_OBJ_ABSORB, -15, 0, 8, 0, $3
anim_wait 6
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, -15, 0, 4, 0, $4
+ anim_obj ANIM_OBJ_ABSORB, -15, 0, 4, 0, $4
anim_wait 16
anim_ret
; c94f8
@@ -711,7 +711,7 @@ BattleAnim_KarateChop: ; c95d5
BattleAnim_Doubleslap: ; c9605
anim_1gfx ANIM_GFX_HIT
- anim_jumpif $1, BattleAnim_Doubleslap_branch_c961b
+ anim_if_param_equal $1, BattleAnim_Doubleslap_branch_c961b
anim_sound 0, 1, SFX_DOUBLESLAP
anim_obj ANIM_OBJ_08, -14, 0, 6, 0, $0
anim_wait 6
@@ -731,7 +731,7 @@ BattleAnim_Doubleslap_branch_c961b: ; c961b
BattleAnim_CometPunch: ; c962b
anim_1gfx ANIM_GFX_HIT
- anim_jumpif $1, BattleAnim_CometPunch_branch_c9641
+ anim_if_param_equal $1, BattleAnim_CometPunch_branch_c9641
anim_sound 0, 1, SFX_COMET_PUNCH
anim_obj ANIM_OBJ_06, -14, 0, 6, 0, $0
anim_wait 6
@@ -788,7 +788,7 @@ BattleAnim_Stomp: ; c9677
BattleAnim_DoubleKick: ; c96a7
anim_1gfx ANIM_GFX_HIT
- anim_jumpif $1, BattleAnim_DoubleKick_branch_c96bd
+ anim_if_param_equal $1, BattleAnim_DoubleKick_branch_c96bd
anim_sound 0, 1, SFX_DOUBLE_KICK
anim_obj ANIM_OBJ_07, -14, 0, 6, 0, $0
anim_wait 6
@@ -808,7 +808,7 @@ BattleAnim_DoubleKick_branch_c96bd: ; c96bd
BattleAnim_JumpKick: ; c96cd
anim_1gfx ANIM_GFX_HIT
- anim_jumpif $1, BattleAnim_JumpKick_branch_c96f1
+ anim_if_param_equal $1, BattleAnim_JumpKick_branch_c96f1
anim_sound 0, 1, SFX_JUMP_KICK
anim_obj ANIM_OBJ_07, 14, 0, 9, 0, $0
anim_obj ANIM_OBJ_07, 12, 4, 7, 4, $0
@@ -832,7 +832,7 @@ BattleAnim_JumpKick_branch_c96f1: ; c96f1
BattleAnim_HiJumpKick: ; c96fc
anim_1gfx ANIM_GFX_HIT
anim_bgeffect ANIM_BG_1F, $40, $2, $0
- anim_jumpif $1, BattleAnim_HiJumpKick_branch_c971e
+ anim_if_param_equal $1, BattleAnim_HiJumpKick_branch_c971e
anim_wait 32
anim_sound 0, 1, SFX_JUMP_KICK
anim_obj ANIM_OBJ_07, 14, 0, 9, 0, $0
@@ -1041,13 +1041,13 @@ BattleAnim_IceBeam: ; c98bd
anim_1gfx ANIM_GFX_ICE
.loop
anim_sound 6, 2, SFX_SHINE
- anim_obj ANIM_OBJ_13, 8, 0, 11, 4, $4
+ anim_obj ANIM_OBJ_ICE_BEAM, 8, 0, 11, 4, $4
anim_wait 4
anim_loop 5, .loop
- anim_obj ANIM_OBJ_29, -15, 0, 9, 2, $10
+ anim_obj ANIM_OBJ_ICE_BUILDUP, -15, 0, 9, 2, $10
.loop2
anim_sound 6, 2, SFX_SHINE
- anim_obj ANIM_OBJ_13, 8, 0, 11, 4, $4
+ anim_obj ANIM_OBJ_ICE_BEAM, 8, 0, 11, 4, $4
anim_wait 4
anim_loop 15, .loop2
anim_wait 48
@@ -1062,18 +1062,18 @@ BattleAnim_Blizzard: ; c98e8
anim_1gfx ANIM_GFX_ICE
.loop
anim_sound 6, 2, SFX_SHINE
- anim_obj ANIM_OBJ_11, 8, 0, 11, 0, $63
+ anim_obj ANIM_OBJ_BLIZZARD, 8, 0, 11, 0, $63
anim_wait 2
anim_sound 6, 2, SFX_SHINE
- anim_obj ANIM_OBJ_11, 8, 0, 10, 0, $64
+ anim_obj ANIM_OBJ_BLIZZARD, 8, 0, 10, 0, $64
anim_wait 2
anim_sound 6, 2, SFX_SHINE
- anim_obj ANIM_OBJ_11, 8, 0, 12, 0, $63
+ anim_obj ANIM_OBJ_BLIZZARD, 8, 0, 12, 0, $63
anim_wait 2
anim_loop 3, .loop
anim_bgeffect ANIM_BG_WHITE_HUES, $0, $8, $0
anim_wait 32
- anim_obj ANIM_OBJ_29, -15, 0, 9, 2, $10
+ anim_obj ANIM_OBJ_ICE_BUILDUP, -15, 0, 9, 2, $10
anim_wait 128
anim_sound 0, 1, SFX_SHINE
anim_wait 8
@@ -1085,13 +1085,13 @@ BattleAnim_Blizzard: ; c98e8
BattleAnim_Bubble: ; c991e
anim_1gfx ANIM_GFX_BUBBLE
anim_sound 32, 2, SFX_WATER_GUN
- anim_obj ANIM_OBJ_21, 8, 0, 11, 4, $c1
+ anim_obj ANIM_OBJ_BUBBLE, 8, 0, 11, 4, $c1
anim_wait 6
anim_sound 32, 2, SFX_WATER_GUN
- anim_obj ANIM_OBJ_21, 8, 0, 11, 4, $e1
+ anim_obj ANIM_OBJ_BUBBLE, 8, 0, 11, 4, $e1
anim_wait 6
anim_sound 32, 2, SFX_WATER_GUN
- anim_obj ANIM_OBJ_21, 8, 0, 11, 4, $d1
+ anim_obj ANIM_OBJ_BUBBLE, 8, 0, 11, 4, $d1
anim_wait 128
anim_wait 32
anim_ret
@@ -1101,13 +1101,13 @@ BattleAnim_Bubblebeam: ; c993d
anim_1gfx ANIM_GFX_BUBBLE
.loop
anim_sound 16, 2, SFX_BUBBLEBEAM
- anim_obj ANIM_OBJ_21, 8, 0, 11, 4, $92
+ anim_obj ANIM_OBJ_BUBBLE, 8, 0, 11, 4, $92
anim_wait 6
anim_sound 16, 2, SFX_BUBBLEBEAM
- anim_obj ANIM_OBJ_21, 8, 0, 11, 4, $b3
+ anim_obj ANIM_OBJ_BUBBLE, 8, 0, 11, 4, $b3
anim_wait 6
anim_sound 16, 2, SFX_BUBBLEBEAM
- anim_obj ANIM_OBJ_21, 8, 0, 11, 4, $f4
+ anim_obj ANIM_OBJ_BUBBLE, 8, 0, 11, 4, $f4
anim_wait 8
anim_loop 3, .loop
anim_wait 64
@@ -1213,13 +1213,13 @@ BattleAnim_VineWhip: ; c9a42
BattleAnim_LeechSeed: ; c9a5a
anim_1gfx ANIM_GFX_PLANT
anim_sound 16, 2, SFX_VINE_WHIP
- anim_obj ANIM_OBJ_4A, 6, 0, 10, 0, $20
+ anim_obj ANIM_OBJ_LEECH_SEED, 6, 0, 10, 0, $20
anim_wait 8
anim_sound 16, 2, SFX_VINE_WHIP
- anim_obj ANIM_OBJ_4A, 6, 0, 10, 0, $30
+ anim_obj ANIM_OBJ_LEECH_SEED, 6, 0, 10, 0, $30
anim_wait 8
anim_sound 16, 2, SFX_VINE_WHIP
- anim_obj ANIM_OBJ_4A, 6, 0, 10, 0, $28
+ anim_obj ANIM_OBJ_LEECH_SEED, 6, 0, 10, 0, $28
anim_wait 32
anim_sound 0, 1, SFX_CHARGE
anim_wait 128
@@ -1229,17 +1229,17 @@ BattleAnim_LeechSeed: ; c9a5a
BattleAnim_RazorLeaf: ; c9a7c
anim_1gfx ANIM_GFX_PLANT
anim_sound 0, 0, SFX_VINE_WHIP
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $28
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $5c
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $10
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $e8
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $9c
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $d0
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $28
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $5c
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $10
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $e8
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $9c
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $d0
anim_wait 6
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $1c
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $50
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $dc
- anim_obj ANIM_OBJ_14, 6, 0, 10, 0, $90
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $1c
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $50
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $dc
+ anim_obj ANIM_OBJ_RAZOR_LEAF, 6, 0, 10, 0, $90
anim_wait 80
anim_sound 16, 2, SFX_VINE_WHIP
anim_incobj 3
@@ -1275,7 +1275,8 @@ BattleAnim_RazorLeaf: ; c9a7c
; c9af2
BattleAnim_Solarbeam: ; c9af2
- anim_jumpif $0, BattleAnim_Solarbeam_branch_c9b30
+ anim_if_param_equal $0, .FireSolarBeam
+ ; charge turn
anim_1gfx ANIM_GFX_CHARGE
anim_sound 0, 0, SFX_CHARGE
anim_obj ANIM_OBJ_3D, 6, 0, 10, 4, $0
@@ -1293,7 +1294,7 @@ BattleAnim_Solarbeam: ; c9af2
anim_ret
; c9b30
-BattleAnim_Solarbeam_branch_c9b30: ; c9b30
+.FireSolarBeam
anim_1gfx ANIM_GFX_BEAM
anim_bgeffect ANIM_BG_06, $0, $2, $0
anim_call BattleAnim_Solarbeam_branch_cbb39
@@ -1362,7 +1363,7 @@ BattleAnim_Thunder: ; c9b9a
; c9bbd
BattleAnim_RazorWind: ; c9bbd
- anim_jumpif $1, BattleAnim_RazorWind_branch_c9fb5
+ anim_if_param_equal $1, BattleAnim_RazorWind_branch_c9fb5
anim_1gfx ANIM_GFX_WHIP
anim_bgeffect ANIM_BG_06, $0, $1, $0
.loop
@@ -1430,7 +1431,7 @@ BattleAnim_Sonicboom: ; c9c36
BattleAnim_Selfdestruct: ; c9c53
anim_1gfx ANIM_GFX_EXPLOSION
anim_bgeffect ANIM_BG_FLASH_INVERTED, $0, $8, $24
- anim_jumpif $1, .loop
+ anim_if_param_equal $1, .loop
anim_call BattleAnim_Selfdestruct_branch_cbb8f
anim_wait 16
anim_ret
@@ -1449,7 +1450,7 @@ BattleAnim_Explosion: ; c9c72
anim_1gfx ANIM_GFX_EXPLOSION
anim_bgeffect ANIM_BG_1F, $60, $4, $10
anim_bgeffect ANIM_BG_FLASH_INVERTED, $0, $8, $24
- anim_jumpif $1, .loop
+ anim_if_param_equal $1, .loop
anim_call BattleAnim_Explosion_branch_cbb8f
anim_wait 16
anim_ret
@@ -1604,7 +1605,7 @@ BattleAnim_Scratch: ; c9da6
BattleAnim_FurySwipes: ; c9dbc
anim_1gfx ANIM_GFX_CUT
- anim_jumpif $1, BattleAnim_FurySwipes_branch_c9dd9
+ anim_if_param_equal $1, BattleAnim_FurySwipes_branch_c9dd9
anim_sound 0, 1, SFX_SCRATCH
anim_obj ANIM_OBJ_37, -14, 0, 6, 0, $0
anim_obj ANIM_OBJ_37, -15, 4, 5, 4, $0
@@ -1685,8 +1686,8 @@ BattleAnim_Teleport: ; c9e4f
; c9e6f
BattleAnim_Fly: ; c9e6f
- anim_jumpif $1, BattleAnim_Fly_branch_c9e89
- anim_jumpif $2, BattleAnim_Fly_branch_c9e82
+ anim_if_param_equal $1, BattleAnim_Fly_branch_c9e89
+ anim_if_param_equal $2, BattleAnim_Fly_branch_c9e82
anim_1gfx ANIM_GFX_HIT
anim_sound 0, 1, SFX_WING_ATTACK
anim_obj ANIM_OBJ_01, -15, 0, 7, 0, $0
@@ -1742,13 +1743,13 @@ BattleAnim_Absorb: ; c9eeb
anim_obj ANIM_OBJ_3D, 5, 4, 11, 0, $0
.loop
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, 16, 0, 6, 0, $2
+ anim_obj ANIM_OBJ_ABSORB, 16, 0, 6, 0, $2
anim_wait 6
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, -15, 0, 8, 0, $3
+ anim_obj ANIM_OBJ_ABSORB, -15, 0, 8, 0, $3
anim_wait 6
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, -15, 0, 4, 0, $4
+ anim_obj ANIM_OBJ_ABSORB, -15, 0, 4, 0, $4
anim_wait 6
anim_loop 5, .loop
anim_wait 32
@@ -1762,17 +1763,17 @@ BattleAnim_MegaDrain: ; c9f13
anim_setvar $0
.loop
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, 16, 0, 6, 0, $2
+ anim_obj ANIM_OBJ_ABSORB, 16, 0, 6, 0, $2
anim_wait 6
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, -15, 0, 8, 0, $3
+ anim_obj ANIM_OBJ_ABSORB, -15, 0, 8, 0, $3
anim_wait 6
anim_sound 6, 3, SFX_WATER_GUN
- anim_obj ANIM_OBJ_45, -15, 0, 4, 0, $4
+ anim_obj ANIM_OBJ_ABSORB, -15, 0, 4, 0, $4
anim_wait 6
anim_incvar
- anim_jumpvar $7, .done
- anim_jumpvar $2, .spawn
+ anim_if_var_equal $7, .done
+ anim_if_var_equal $2, .spawn
anim_jump .loop
; c9f46
@@ -1861,7 +1862,7 @@ BattleAnim_SkyAttack_branch_c9fb5: ; c9fb5
; c9ffc
BattleAnim_Bide: ; c9ffc
- anim_jumpif $0, BattleAnim_Bide_branch_c9651
+ anim_if_param_equal $0, BattleAnim_Bide_branch_c9651
anim_1gfx ANIM_GFX_HIT
anim_call BattleAnim_FollowEnemyFeet_0
anim_sound 0, 0, SFX_ESCAPE_ROPE
@@ -1982,7 +1983,7 @@ BattleAnim_Roar: ; ca0d7
anim_wait 16
anim_loop 3, .loop
anim_wait 16
- anim_jumpif $0, .done
+ anim_if_param_equal $0, .done
anim_bgeffect ANIM_BG_27, $0, $0, $0
anim_wait 64
.done
@@ -2142,8 +2143,8 @@ BattleAnim_Splash: ; ca237
BattleAnim_Dig: ; ca24b
anim_2gfx ANIM_GFX_SAND, ANIM_GFX_HIT
- anim_jumpif $0, .hit
- anim_jumpif $2, .fail
+ anim_if_param_equal $0, .hit
+ anim_if_param_equal $2, .fail
anim_call BattleAnim_FollowPlayerHead_0
anim_bgeffect ANIM_BG_DIG, $0, $1, $1
anim_obj ANIM_OBJ_57, 9, 0, 13, 0, $0
@@ -2312,7 +2313,7 @@ BattleAnim_Whirlwind: ; ca3a8
anim_incobj 9
anim_sound 16, 2, SFX_WHIRLWIND
anim_wait 128
- anim_jumpif $0, .done
+ anim_if_param_equal $0, .done
anim_bgeffect ANIM_BG_27, $0, $0, $0
anim_wait 64
.done
@@ -2335,8 +2336,8 @@ BattleAnim_Haze: ; ca3ee
anim_1gfx ANIM_GFX_HAZE
anim_sound 0, 1, SFX_SURF
.loop
- anim_obj ANIM_OBJ_5B, 6, 0, 7, 0, $0
- anim_obj ANIM_OBJ_5B, -16, 4, 2, 0, $0
+ anim_obj ANIM_OBJ_HAZE, 6, 0, 7, 0, $0
+ anim_obj ANIM_OBJ_HAZE, -16, 4, 2, 0, $0
anim_wait 12
anim_loop 5, .loop
anim_wait 96
@@ -2348,7 +2349,7 @@ BattleAnim_Mist: ; ca404
anim_1gfx ANIM_GFX_HAZE
anim_sound 0, 0, SFX_SURF
.loop
- anim_obj ANIM_OBJ_5C, 6, 0, 7, 0, $0
+ anim_obj ANIM_OBJ_MIST, 6, 0, 7, 0, $0
anim_wait 8
anim_loop 10, .loop
anim_wait 96
@@ -2359,7 +2360,7 @@ BattleAnim_Smog: ; ca417
anim_1gfx ANIM_GFX_HAZE
anim_sound 0, 1, SFX_BUBBLEBEAM
.loop
- anim_obj ANIM_OBJ_5D, -16, 4, 2, 0, $0
+ anim_obj ANIM_OBJ_SMOG, -16, 4, 2, 0, $0
anim_wait 8
anim_loop 10, .loop
anim_wait 96
@@ -2370,7 +2371,7 @@ BattleAnim_PoisonGas: ; ca428
anim_1gfx ANIM_GFX_HAZE
anim_sound 16, 2, SFX_BUBBLEBEAM
.loop
- anim_obj ANIM_OBJ_5E, 5, 4, 10, 0, $2
+ anim_obj ANIM_OBJ_POISON_GAS, 5, 4, 10, 0, $2
anim_wait 8
anim_loop 10, .loop
anim_wait 128
@@ -2379,7 +2380,7 @@ BattleAnim_PoisonGas: ; ca428
BattleAnim_HornAttack: ; ca439
anim_2gfx ANIM_GFX_HORN, ANIM_GFX_HIT
- anim_obj ANIM_OBJ_5F, 9, 0, 10, 0, $1
+ anim_obj ANIM_OBJ_HORN, 9, 0, 10, 0, $1
anim_wait 16
anim_sound 0, 1, SFX_HORN_ATTACK
anim_obj ANIM_OBJ_01, -15, 0, 7, 0, $0
@@ -2389,17 +2390,17 @@ BattleAnim_HornAttack: ; ca439
BattleAnim_FuryAttack: ; ca44c
anim_2gfx ANIM_GFX_HORN, ANIM_GFX_HIT
- anim_obj ANIM_OBJ_5F, 9, 0, 9, 0, $2
+ anim_obj ANIM_OBJ_HORN, 9, 0, 9, 0, $2
anim_wait 8
anim_sound 0, 1, SFX_HORN_ATTACK
anim_obj ANIM_OBJ_04, 16, 0, 5, 0, $0
anim_wait 8
- anim_obj ANIM_OBJ_5F, 10, 0, 11, 0, $2
+ anim_obj ANIM_OBJ_HORN, 10, 0, 11, 0, $2
anim_wait 8
anim_sound 0, 1, SFX_HORN_ATTACK
anim_obj ANIM_OBJ_04, -15, 0, 7, 0, $0
anim_wait 8
- anim_obj ANIM_OBJ_5F, 9, 4, 10, 0, $2
+ anim_obj ANIM_OBJ_HORN, 9, 4, 10, 0, $2
anim_wait 8
anim_sound 0, 1, SFX_HORN_ATTACK
anim_obj ANIM_OBJ_04, -16, 4, 6, 0, $0
@@ -2410,7 +2411,7 @@ BattleAnim_FuryAttack: ; ca44c
BattleAnim_HornDrill: ; ca47d
anim_2gfx ANIM_GFX_HORN, ANIM_GFX_HIT
anim_bgeffect ANIM_BG_FLASH_INVERTED, $0, $8, $40
- anim_obj ANIM_OBJ_5F, 9, 0, 10, 0, $3
+ anim_obj ANIM_OBJ_HORN, 9, 0, 10, 0, $3
anim_wait 8
.loop
anim_sound 0, 1, SFX_HORN_ATTACK
@@ -2608,7 +2609,7 @@ BattleAnim_Crabhammer: ; ca624
; ca63f
BattleAnim_SkullBash: ; ca63f
- anim_jumpif $1, BattleAnim_SkullBash_branch_c9fb5
+ anim_if_param_equal $1, BattleAnim_SkullBash_branch_c9fb5
anim_1gfx ANIM_GFX_HIT
anim_bgeffect ANIM_BG_1F, $14, $2, $0
anim_wait 32
@@ -2714,14 +2715,14 @@ BattleAnim_Flash: ; ca700
BattleAnim_Substitute: ; ca73c
anim_sound 0, 0, SFX_SURF
- anim_jumpif $3, BattleAnim_Substitute_branch_ca77c
- anim_jumpif $2, BattleAnim_Substitute_branch_ca76e
- anim_jumpif $1, BattleAnim_Substitute_branch_ca760
+ anim_if_param_equal $3, BattleAnim_Substitute_branch_ca77c
+ anim_if_param_equal $2, BattleAnim_Substitute_branch_ca76e
+ anim_if_param_equal $1, BattleAnim_Substitute_branch_ca760
anim_1gfx ANIM_GFX_SMOKE
anim_bgeffect ANIM_BG_27, $0, $1, $0
anim_wait 48
anim_raisesub
- anim_obj ANIM_OBJ_1C, 6, 0, 12, 0, $0
+ anim_obj ANIM_OBJ_BALL_POOF, 6, 0, 12, 0, $0
anim_bgeffect ANIM_BG_ENTER_MON, $0, $1, $0
anim_wait 32
anim_ret
@@ -2769,7 +2770,7 @@ BattleAnim_Minimize: ; ca78a
; ca7a1
BattleAnim_SkyAttack: ; ca7a1
- anim_jumpif $1, BattleAnim_SkyAttack_branch_c9fb5
+ anim_if_param_equal $1, BattleAnim_SkyAttack_branch_c9fb5
anim_1gfx ANIM_GFX_SKY_ATTACK
anim_bgeffect ANIM_BG_27, $0, $1, $0
anim_wait 32
@@ -2826,14 +2827,14 @@ BattleAnim_TriAttack: ; ca7f1
BattleAnim_Withdraw: ; ca80c
anim_1gfx ANIM_GFX_REFLECT
anim_call BattleAnim_FollowPlayerHead_0
- anim_bgeffect ANIM_BG_21, $0, $1, $50
+ anim_bgeffect ANIM_BG_WITHDRAW, $0, $1, $50
anim_wait 48
anim_sound 0, 0, SFX_SHINE
- anim_obj ANIM_OBJ_70, 6, 0, 11, 0, $0
+ anim_obj ANIM_OBJ_WITHDRAW, 6, 0, 11, 0, $0
anim_wait 64
anim_incobj 2
anim_wait 1
- anim_incbgeffect ANIM_BG_21
+ anim_incbgeffect ANIM_BG_WITHDRAW
anim_call BattleAnim_ShowMon_0
anim_ret
; ca829
@@ -2965,7 +2966,7 @@ BattleAnim_Smokescreen: ; ca939
anim_wait 24
anim_incobj 1
anim_sound 0, 1, SFX_BALL_POOF
- anim_obj ANIM_OBJ_1C, 13, 4, 8, 6, $10
+ anim_obj ANIM_OBJ_BALL_POOF, 13, 4, 8, 6, $10
anim_wait 8
.loop
anim_sound 0, 1, SFX_MENU
@@ -3324,8 +3325,8 @@ BattleAnim_Sketch: ; cac61
BattleAnim_TripleKick: ; cac7b
anim_1gfx ANIM_GFX_HIT
- anim_jumpif $1, BattleAnim_TripleKick_branch_cac95
- anim_jumpif $2, BattleAnim_TripleKick_branch_caca5
+ anim_if_param_equal $1, BattleAnim_TripleKick_branch_cac95
+ anim_if_param_equal $2, BattleAnim_TripleKick_branch_caca5
anim_sound 0, 1, SFX_MEGA_KICK
anim_obj ANIM_OBJ_07, -14, 0, 6, 0, $0
anim_wait 6
@@ -3447,7 +3448,7 @@ BattleAnim_Snore: ; cad6b
; cad86
BattleAnim_Curse: ; cad86
- anim_jumpif $1, .NotGhost
+ anim_if_param_equal $1, .NotGhost
anim_2gfx ANIM_GFX_HIT, ANIM_GFX_OBJECTS
anim_obj ANIM_OBJ_A5, 8, 4, 9, 0, $0
anim_sound 0, 0, SFX_CURSE
@@ -3551,7 +3552,7 @@ BattleAnim_CottonSpore: ; cae84
anim_1gfx ANIM_GFX_MISC
anim_sound 0, 1, SFX_POWDER
.loop ; cae8b
- anim_obj ANIM_OBJ_81, -16, 4, 4, 0, $0
+ anim_obj ANIM_OBJ_COTTON_SPORE, -16, 4, 4, 0, $0
anim_wait 8
anim_loop 5, .loop
anim_wait 96
@@ -3750,9 +3751,9 @@ BattleAnim_Octazooka: ; cb06f
anim_sound 6, 2, SFX_SLUDGE_BOMB
anim_obj ANIM_OBJ_8C, 8, 0, 11, 4, $4
anim_wait 16
- anim_obj ANIM_OBJ_1C, -16, 4, 7, 0, $10
+ anim_obj ANIM_OBJ_BALL_POOF, -16, 4, 7, 0, $10
anim_wait 8
- anim_jumpif $0, .done
+ anim_if_param_equal $0, .done
.loop
anim_obj ANIM_OBJ_74, -16, 4, 7, 4, $20
anim_wait 8
@@ -3810,7 +3811,7 @@ BattleAnim_DestinyBond: ; cb0f0
anim_1gfx ANIM_GFX_ANGELS
anim_bgp $1b
anim_obp0 $0
- anim_jumpif $1, BattleAnim_DestinyBond_branch_cb104
+ anim_if_param_equal $1, BattleAnim_DestinyBond_branch_cb104
anim_sound 6, 2, SFX_WHIRLWIND
anim_obj ANIM_OBJ_9B, 5, 4, 15, 0, $2
anim_wait 128
@@ -4097,7 +4098,7 @@ BattleAnim_FuryCutter: ; cb386
anim_1gfx ANIM_GFX_CUT
.loop
anim_sound 0, 1, SFX_CUT
- anim_jumpand $1, .obj1
+ anim_if_param_and %00000001, .obj1
anim_obj ANIM_OBJ_3A, -13, 0, 5, 0, $0
anim_jump .okay
@@ -4223,7 +4224,7 @@ BattleAnim_Present: ; cb488
anim_obj ANIM_OBJ_53, 13, 0, 6, 0, $0
anim_wait 48
anim_incobj 2
- anim_jumpif $3, .heal
+ anim_if_param_equal $3, .heal
anim_incobj 1
anim_wait 1
anim_1gfx ANIM_GFX_EXPLOSION
@@ -4356,7 +4357,7 @@ BattleAnim_Megahorn: ; cb5c0
anim_bgeffect ANIM_BG_1F, $40, $2, $0
anim_wait 48
anim_bgeffect ANIM_BG_FLASH_INVERTED, $0, $8, $3
- anim_obj ANIM_OBJ_5F, 9, 0, 10, 0, $1
+ anim_obj ANIM_OBJ_HORN, 9, 0, 10, 0, $1
anim_sound 0, 1, SFX_HORN_ATTACK
anim_wait 16
anim_obj ANIM_OBJ_00, -15, 0, 7, 0, $0
@@ -4399,7 +4400,7 @@ BattleAnim_Encore: ; cb5fe
BattleAnim_Pursuit: ; cb61b
anim_1gfx ANIM_GFX_HIT
- anim_jumpif $1, BattleAnim_Pursuit_branch_cb62b
+ anim_if_param_equal $1, BattleAnim_Pursuit_branch_cb62b
anim_sound 0, 1, SFX_COMET_PUNCH
anim_obj ANIM_OBJ_01, -15, 0, 7, 0, $0
anim_wait 16
@@ -4534,7 +4535,7 @@ BattleAnim_MorningSun: ; cb739
anim_wait 6
anim_loop 5, .loop
anim_wait 32
- anim_jumpif $0, .zero
+ anim_if_param_equal 0, .zero
anim_call BattleAnim_MorningSun_branch_cbc6a
anim_ret
; cb756
@@ -4553,12 +4554,12 @@ BattleAnim_Synthesis: ; cb75a
anim_wait 72
anim_incbgeffect ANIM_BG_18
anim_call BattleAnim_ShowMon_0
- anim_jumpif $1, BattleAnim_Synthesis_branch_cb77a
+ anim_if_param_equal $1, .one
anim_call BattleAnim_Synthesis_branch_cbc6a
anim_ret
; cb77a
-BattleAnim_Synthesis_branch_cb77a: ; cb77a
+.one
anim_call BattleAnim_Synthesis_branch_cbc80
anim_ret
; cb77e
@@ -4592,12 +4593,11 @@ BattleAnim_Moonlight: ; cb7a8
anim_wait 1
anim_sound 0, 0, SFX_MOONLIGHT
anim_wait 63
- anim_jumpif $3, BattleAnim_Moonlight_branch_cb7d7
+ anim_if_param_equal $3, .three
anim_call BattleAnim_Moonlight_branch_cbc6a
anim_ret
-; cb7d7
-BattleAnim_Moonlight_branch_cb7d7: ; cb7d7
+.three
anim_call BattleAnim_Moonlight_branch_cbc80
anim_ret
; cb7db
@@ -4811,7 +4811,7 @@ BattleAnim_ShadowBall: ; cb9c6
anim_sound 6, 2, SFX_SLUDGE_BOMB
anim_obj ANIM_OBJ_B4, 8, 0, 11, 4, $2
anim_wait 32
- anim_obj ANIM_OBJ_1C, -16, 4, 7, 0, $10
+ anim_obj ANIM_OBJ_BALL_POOF, -16, 4, 7, 0, $10
anim_wait 24
anim_ret
; cb9db
@@ -4877,7 +4877,7 @@ BattleAnim_Whirlpool: ; cba6a
; cba84
BattleAnim_BeatUp: ; cba84
- anim_jumpif $0, .current_mon
+ anim_if_param_equal $0, .current_mon
anim_sound 0, 0, SFX_BALL_POOF
anim_bgeffect ANIM_BG_RETURN_MON, $0, $1, $0
anim_wait 16
diff --git a/battle/bg_effects.asm b/battle/bg_effects.asm
index 52917b61f..b7f415770 100644
--- a/battle/bg_effects.asm
+++ b/battle/bg_effects.asm
@@ -111,7 +111,7 @@ BattleBGEffects: ; c805a (32:405a)
dw BattleBGEffect_1e
dw BattleBGEffect_1f
dw BattleBGEffect_20
- dw BattleBGEffect_21
+ dw BattleBGEffect_Withdraw
dw BattleBGEffect_BounceDown
dw BattleBGEffect_Dig
dw BattleBGEffect_Tackle
@@ -738,9 +738,9 @@ BattleBGEffect_RunPicResizeScript: ; c83ed (32:43ed)
ld l, a
ld a, [wBattleAnimTemp2]
ld h, a
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld a, [hl]
cp -1
jr z, .end
@@ -805,9 +805,9 @@ endr
ld e, [hl]
ld d, 0
ld hl, .BGSquares
-rept 3
add hl, de
-endr
+ add hl, de
+ add hl, de
ld a, [hli]
ld b, a
and $f
@@ -933,7 +933,7 @@ BattleBGEffect_Surf: ; c8545 (32:4545)
call InitSurfWaves
.one
- ld a, [hFFC6]
+ ld a, [hLCDCPointer]
and a
ret z
push bc
@@ -963,7 +963,7 @@ BattleBGEffect_Surf: ; c8545 (32:4545)
ld hl, wSurfWaveBGEffect
ld bc, $0
.loop2
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
cp e
jr nc, .load_zero
push hl
@@ -997,12 +997,12 @@ BattleBGEffect_Whirlpool: ; c8599 (32:4599)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $42
- ld [hFFC6], a
+ ld a, rSCY - $ff00
+ ld [hLCDCPointer], a
xor a
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ld a, $5e
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
lb de, 2, 2
call Functionc8f2e
ret
@@ -1017,7 +1017,7 @@ BattleBGEffect_Whirlpool: ; c8599 (32:4599)
BattleBGEffect_30: ; c85c2 (32:45c2)
call BattleBGEffects_ClearLYOverrides
- ld a, $42
+ ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms1
call EndBattleBGEffect
ret
@@ -1071,12 +1071,12 @@ BattleBGEffect_Psychic: ; c8607 (32:4607)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
- ld [hFFC6], a
+ ld a, rSCX - $ff00
+ ld [hLCDCPointer], a
xor a
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ld a, $5f
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
lb de, 6, 5
call Functionc8f2e
ld hl, BG_EFFECT_STRUCT_03
@@ -1109,7 +1109,7 @@ BattleBGEffect_Teleport: ; c863f (32:463f)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
lb de, 6, 5
call Functionc8f2e
@@ -1134,7 +1134,7 @@ BattleBGEffect_NightShade: ; c8662 (32:4662)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $42
+ ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms1
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
@@ -1165,11 +1165,11 @@ BattleBGEffect_DoubleTeam: ; c8689 (32:4689)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
ld [hl], $0
@@ -1224,9 +1224,9 @@ BattleBGEffect_DoubleTeam: ; c8689 (32:4689)
inc a
ld d, a
ld h, LYOverridesBackup / $100
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
ld l, a
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
sub l
srl a
push af
@@ -1257,15 +1257,15 @@ BattleBGEffect_AcidArmor: ; c8709 (32:4709)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $42
+ ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms1
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld e, [hl]
ld d, 2
call Functionc8f2e
- ld h, $d2
- ld a, [hFFC8]
+ ld h, LYOverridesBackup / $100
+ ld a, [hLYOverrideEnd]
ld l, a
ld [hl], $0
dec l
@@ -1273,9 +1273,9 @@ BattleBGEffect_AcidArmor: ; c8709 (32:4709)
ret
.one
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
ld l, a
- ld h, $d2
+ ld h, LYOverridesBackup / $100
ld e, l
ld d, h
dec de
@@ -1283,11 +1283,11 @@ BattleBGEffect_AcidArmor: ; c8709 (32:4709)
ld a, [de]
dec de
ld [hld], a
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
cp l
jr nz, .loop
ld [hl], $90
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
ld l, a
ld a, [hl]
cp $1
@@ -1309,7 +1309,7 @@ BattleBGEffect_AcidArmor: ; c8709 (32:4709)
call BattleAnim_ResetLCDStatCustom
ret
-BattleBGEffect_21: ; c8761 (32:4761)
+BattleBGEffect_Withdraw: ; c8761 (32:4761)
call BattleBGEffects_AnonJumptable
.anon_dw
dw .zero
@@ -1320,11 +1320,11 @@ BattleBGEffect_21: ; c8761 (32:4761)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $42
+ ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
ld [hl], $1
@@ -1341,7 +1341,7 @@ BattleBGEffect_21: ; c8761 (32:4761)
ld a, [hl]
cp d
ret nc
- call Functionc901b
+ call BGEffect_DisplaceLYOverridesBackup
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld a, [hl]
@@ -1370,11 +1370,11 @@ BattleBGEffect_Dig: ; c87a7 (32:47a7)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $42
+ ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
ld [hl], $2
@@ -1396,9 +1396,9 @@ BattleBGEffect_Dig: ; c87a7 (32:47a7)
ld [hl], $10
call BattleBGEffects_IncrementJumptable
.two
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
ld l, a
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
sub l
dec a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
@@ -1414,7 +1414,7 @@ BattleBGEffect_Dig: ; c87a7 (32:47a7)
dec [hl]
.skip
pop af
- call Functionc901b
+ call BGEffect_DisplaceLYOverridesBackup
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
inc [hl]
@@ -1437,11 +1437,11 @@ BattleBGEffect_Tackle: ; c8805 (32:4805)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld [hl], $0
@@ -1472,11 +1472,11 @@ BattleBGEffect_25: ; c8837 (32:4837)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms2
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld [hl], $0
@@ -1546,19 +1546,19 @@ Functionc88a5: ; c88a5 (32:48a5)
jr z, .rollout
.not_rollout
pop af
- jp Functionc900b
+ jp BGEffect_FillLYOverridesBackup
.rollout
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
ld d, a
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
sub d
ld d, a
ld h, LYOverridesBackup / $100
ld a, [hSCY]
or a
jr nz, .skip1
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
or a
jr z, .skip2
dec a
@@ -1567,14 +1567,14 @@ Functionc88a5: ; c88a5 (32:48a5)
jr .skip2
.skip1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
dec a
ld l, a
ld [hl], $0
.skip2
ld a, [hSCY]
ld l, a
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
sub l
jr nc, .skip3
xor a
@@ -1604,11 +1604,11 @@ BattleBGEffect_2d: ; c88e7 (32:48e7)
BGEffect2d_2f_zero:
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld [hl], $0
@@ -1648,11 +1648,11 @@ BattleBGEffect_26: ; c892a (32:492a)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld [hl], $0
@@ -1664,7 +1664,7 @@ BattleBGEffect_26: ; c892a (32:492a)
ld a, [hl]
ld d, $8
call BattleBGEffects_Sine
- call Functionc900b
+ call BGEffect_FillLYOverridesBackup
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld a, [hl]
@@ -1687,11 +1687,11 @@ BattleBGEffect_2c: ; c8964 (32:4964)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
xor a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
@@ -1714,7 +1714,7 @@ BattleBGEffect_2c: ; c8964 (32:4964)
ld e, a
pop af
add e
- call Functionc900b
+ call BGEffect_FillLYOverridesBackup
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
ld a, [hl]
@@ -1742,7 +1742,7 @@ BattleBGEffect_28: ; c89b5 (32:49b5)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
ret
@@ -1785,11 +1785,11 @@ BattleBGEffect_BounceDown: ; c89ee (32:49ee)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $42
+ ld a, rSCY - $ff00
call BattleBGEffect_SetLCDStatCustoms2
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
ld [hl], $1
@@ -1814,7 +1814,7 @@ BattleBGEffect_BounceDown: ; c89ee (32:49ee)
ld d, a
pop af
add d
- call Functionc901b
+ call BGEffect_DisplaceLYOverridesBackup
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
inc [hl]
@@ -1841,14 +1841,14 @@ BattleBGEffect_2a: ; c8a3a (32:4a3a)
call BattleBGEffects_SetLYOverrides
ld a, $47
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
- ld a, [hFFC7]
+ ld [hLYOverrideEnd], a
+ ld a, [hLYOverrideStart]
ld l, a
- ld h, $d2
+ ld h, LYOverridesBackup / $100
.loop
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
cp l
jr z, .done
xor a
@@ -1873,9 +1873,9 @@ BattleBGEffect_2a: ; c8a3a (32:4a3a)
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld [hl], $0
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
inc a
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
call BattleBGEffects_IncrementJumptable
ret
@@ -1883,7 +1883,7 @@ BattleBGEffect_2a: ; c8a3a (32:4a3a)
call .GetLYOverride
jr nc, .finish
call .SetLYOverridesBackup
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
dec a
ld l, a
ld [hl], e
@@ -1895,9 +1895,9 @@ BattleBGEffect_2a: ; c8a3a (32:4a3a)
.SetLYOverridesBackup:
ld e, a
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
ld l, a
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
sub l
srl a
ld h, LYOverridesBackup / $100
@@ -1944,7 +1944,7 @@ BattleBGEffect_2b: ; c8acc (32:4acc)
.zero
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
@@ -1986,12 +1986,12 @@ BattleBGEffect_1c: ; c8b00 (32:4b00)
call BattleBGEffects_IncrementJumptable
ld a, $e4
call BattleBGEffects_SetLYOverrides
- ld a, $47
- ld [hFFC6], a
+ ld a, rBGP - $ff00
+ ld [hLCDCPointer], a
xor a
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ld a, $60
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ret
.one
@@ -2221,11 +2221,11 @@ BattleBGEffect_VibrateMon: ; c8c61 (32:4c61)
.zero ; c8c68 (32:4c68)
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
+ ld a, rSCX - $ff00
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
add hl, bc
ld [hl], $1
@@ -2249,7 +2249,7 @@ BattleBGEffect_VibrateMon: ; c8c61 (32:4c61)
xor $ff
inc a
ld [hl], a
- call Functionc900b
+ call BGEffect_FillLYOverridesBackup
ret
.finish
@@ -2267,12 +2267,12 @@ BattleBGEffect_WobbleMon: ; c8ca2 (32:4ca2)
.zero ; c8cab (32:4cab)
call BattleBGEffects_IncrementJumptable
call BattleBGEffects_ClearLYOverrides
- ld a, $43
- ld [hFFC6], a
+ ld a, rSCX - $ff00
+ ld [hLCDCPointer], a
xor a
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ld a, $37
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld [hl], $0
@@ -2286,7 +2286,7 @@ BattleBGEffect_WobbleMon: ; c8ca2 (32:4ca2)
jr nc, .two
ld d, $6
call BattleBGEffects_Sine
- call Functionc900b
+ call BGEffect_FillLYOverridesBackup
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld a, [hl]
@@ -2435,9 +2435,9 @@ BGEffect_RapidCyclePals: ; c8d77 (32:4d77)
call BattleBGEffects_SetLYOverrides
ld a, $47
call BattleBGEffect_SetLCDStatCustoms1
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
inc a
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ld hl, BG_EFFECT_STRUCT_03
add hl, bc
ld a, [hl]
@@ -2463,7 +2463,7 @@ BGEffect_RapidCyclePals: ; c8d77 (32:4d77)
ld [hl], a
call BattleBGEffect_GetFirstDMGPal
jr c, .okay_2_dmg
- call Functionc900b
+ call BGEffect_FillLYOverridesBackup
ret
.okay_2_dmg
@@ -2655,7 +2655,7 @@ BattleBGEffect_GetNextDMGPal: ; c8eb2 (32:4eb2)
BattleBGEffects_ClearLYOverrides: ; c8eca (32:4eca)
xor a
BattleBGEffects_SetLYOverrides: ; c8ecb (32:4ecb)
- ld hl, LYOverrides ; wd100
+ ld hl, LYOverrides ; wListPointer
ld e, $99
.loop1
ld [hli], a
@@ -2670,7 +2670,7 @@ BattleBGEffects_SetLYOverrides: ; c8ecb (32:4ecb)
ret
BattleBGEffect_SetLCDStatCustoms1: ; c8ede (32:4ede)
- ld [hFFC6], a
+ ld [hLCDCPointer], a
call BGEffect_CheckBattleTurn
jr nz, .player_turn
lb de, $00, $36
@@ -2680,13 +2680,13 @@ BattleBGEffect_SetLCDStatCustoms1: ; c8ede (32:4ede)
lb de, $2f, $5e
.okay
ld a, d
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ld a, e
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ret
BattleBGEffect_SetLCDStatCustoms2: ; c8ef4 (32:4ef4)
- ld [hFFC6], a
+ ld [hLCDCPointer], a
call BGEffect_CheckBattleTurn
jr nz, .player_turn
lb de, $00, $36
@@ -2696,30 +2696,30 @@ BattleBGEffect_SetLCDStatCustoms2: ; c8ef4 (32:4ef4)
lb de, $2d, $5e
.okay
ld a, d
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ld a, e
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ret
BattleAnim_ResetLCDStatCustom: ; c8f0a (32:4f0a)
xor a
- ld [hFFC7], a
- ld [hFFC8], a
+ ld [hLYOverrideStart], a
+ ld [hLYOverrideEnd], a
call BattleBGEffects_ClearLYOverrides
xor a
- ld [hFFC6], a
+ ld [hLCDCPointer], a
call EndBattleBGEffect
ret
BattleBGEffects_ResetVideoHRAM: ; c8f19 (32:4f19)
xor a
- ld [hFFC6], a
+ ld [hLCDCPointer], a
ld a, %11100100
ld [rBGP], a
ld [wBGP], a
ld [wOBP1], a
- ld [hFFC7], a
- ld [hFFC8], a
+ ld [hLYOverrideStart], a
+ ld [hLYOverrideEnd], a
call BattleBGEffects_ClearLYOverrides
ret
@@ -2735,10 +2735,10 @@ Functionc8f2e: ; c8f2e (32:4f2e)
ld [wBattleAnimTemp3], a
ld bc, LYOverridesBackup
.loop
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
cp c
jr nc, .next
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
cp c
jr c, .next
ld a, [wBattleAnimTemp2]
@@ -2812,14 +2812,14 @@ Functionc8f9a: ; c8f9a (32:4f9a)
call BattleBGEffects_Sine
ld e, a
pop hl
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
cp c
jr c, .skip1
ld a, e
ld [bc], a
inc bc
.skip1
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
cp l
jr nc, .skip2
ld [hl], e
@@ -2837,7 +2837,7 @@ Functionc8f9a: ; c8f9a (32:4f9a)
ret
.GetLYOverrideBackupAddrOffset:
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
ld e, a
ld a, [wBattleAnimTemp0]
add e
@@ -2847,13 +2847,13 @@ Functionc8f9a: ; c8f9a (32:4f9a)
BattleBGEffect_WavyScreenFX: ; c8fef (32:4fef)
push bc
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
ld l, a
inc a
ld e, a
- ld h, $d2
+ ld h, LYOverridesBackup / $100
ld d, h
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
sub l
and a
jr z, .done
@@ -2872,44 +2872,45 @@ BattleBGEffect_WavyScreenFX: ; c8fef (32:4fef)
pop bc
ret
-Functionc900b: ; c900b (32:500b)
+BGEffect_FillLYOverridesBackup: ; c900b (32:500b)
push af
- ld h, $d2
- ld a, [hFFC7]
+ ld h, LYOverridesBackup / $100
+ ld a, [hLYOverrideStart]
ld l, a
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
sub l
ld d, a
pop af
-.asm_c9016
+.loop
ld [hli], a
dec d
- jr nz, .asm_c9016
+ jr nz, .loop
ret
-Functionc901b: ; c901b (32:501b)
+BGEffect_DisplaceLYOverridesBackup: ; c901b (32:501b)
+ ; e = a; d = [hLYOverrideEnd] - [hLYOverrideStart] - a
push af
ld e, a
- ld a, [hFFC7]
+ ld a, [hLYOverrideStart]
ld l, a
- ld a, [hFFC8]
+ ld a, [hLYOverrideEnd]
sub l
sub e
ld d, a
- ld h, $d2
- ld a, [hFFC7]
+ ld h, LYOverridesBackup / $100
+ ld a, [hLYOverrideStart]
ld l, a
ld a, $90
-.asm_c902c
+.loop
ld [hli], a
dec e
- jr nz, .asm_c902c
+ jr nz, .loop
pop af
xor $ff
-.asm_c9033
+.loop2
ld [hli], a
dec d
- jr nz, .asm_c9033
+ jr nz, .loop2
ret
BGEffect_CheckBattleTurn: ; c9038 (32:5038)
diff --git a/battle/core.asm b/battle/core.asm
index eb73f77a2..dec315ab8 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -7,7 +7,7 @@ DoBattle: ; 3c000
ld [wPlayerAction], a
ld [BattleEnded], a
inc a
- ld [wAISwitch], a
+ ld [wBattleHasJustStarted], a
ld hl, OTPartyMon1HP
ld bc, PARTYMON_STRUCT_LENGTH - 1
ld d, BATTLEACTION_SWITCH1 - 1
@@ -116,8 +116,6 @@ DoBattle: ; 3c000
jp BattleMenu
; 3c0e5
-
-
WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
call Call_LoadTempTileMapToTileMap
ld a, [wBattleResult]
@@ -160,7 +158,6 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
ret
; 3c12f
-
BattleTurn: ; 3c12f
.loop
call MobileFn_3c1bf
@@ -170,7 +167,7 @@ BattleTurn: ; 3c12f
xor a
ld [wPlayerIsSwitching], a
ld [wEnemyIsSwitching], a
- ld [wAISwitch], a
+ ld [wBattleHasJustStarted], a
ld [wPlayerJustGotFrozen], a
ld [wEnemyJustGotFrozen], a
ld [CurDamage], a
@@ -183,7 +180,7 @@ BattleTurn: ; 3c12f
call IsMobileBattle
jr nz, .not_disconnected
callba Function100da5
- callba Function100641
+ callba StartMobileInactivityTimer
callba Function100dd8
jp c, .quit
.not_disconnected
@@ -252,7 +249,6 @@ MobileFn_3c1bf: mobile
ret
; 3c1d6
-
HandleBetweenTurnEffects: ; 3c1d6
ld a, [hLinkPlayerNumber]
cp $1
@@ -769,7 +765,6 @@ HandleEncore: ; 3c4df
jp StdBattleTextBox
; 3c543
-
TryEnemyFlee: ; 3c543
ld a, [wBattleMode]
dec a
@@ -861,7 +856,6 @@ AlwaysFleeMons: ; 3c5b1
db -1
; 3c5b4
-
CompareMovePriority: ; 3c5b4
; Compare the priority of the player and enemy's moves.
; Return carry if the player goes first, or z if they match.
@@ -915,7 +909,6 @@ MoveEffectPriorities: ; 3c5df
db -1
; 3c5ec
-
GetMoveEffect: ; 3c5ec
ld a, b
dec a
@@ -928,7 +921,6 @@ GetMoveEffect: ; 3c5ec
ret
; 3c5fe
-
Battle_EnemyFirst: ; 3c5fe
call LoadTileMapToTempTileMap
call TryEnemyFlee
@@ -1695,7 +1687,6 @@ HandleSafeguard: ; 3cafb
ld hl, BattleText_SafeguardFaded
jp StdBattleTextBox
-
HandleScreens: ; 3cb36
ld a, [hLinkPlayerNumber]
cp 1
@@ -1739,7 +1730,6 @@ HandleScreens: ; 3cb36
db "Enemy@"
; 3cb80
-
.LightScreenTick: ; 3cb80
ld a, [de]
dec a
@@ -1878,7 +1868,6 @@ SubtractHPFromUser: ; 3cc3f
jp UpdateHPBarBattleHuds
; 3cc45
-
SubtractHP: ; 3cc45
ld hl, BattleMonHP
ld a, [hBattleTurn]
@@ -1925,7 +1914,6 @@ GetSixteenthMaxHP: ; 3cc76
ret
; 3cc83
-
GetEighthMaxHP: ; 3cc83
; output: bc
call GetQuarterMaxHP
@@ -1941,7 +1929,6 @@ GetEighthMaxHP: ; 3cc83
ret
; 3cc8e
-
GetQuarterMaxHP: ; 3cc8e
; output: bc
call GetMaxHP
@@ -1962,7 +1949,6 @@ GetQuarterMaxHP: ; 3cc8e
ret
; 3cc9f
-
GetHalfMaxHP: ; 3cc9f
; output: bc
call GetMaxHP
@@ -1980,7 +1966,6 @@ GetHalfMaxHP: ; 3cc9f
ret
; 3ccac
-
GetMaxHP: ; 3ccac
; output: bc, Buffer1-2
@@ -2036,7 +2021,6 @@ CheckUserHasEnoughHP: ; 3ccde
ret
; 3ccef
-
RestoreHP ; 3ccef
ld hl, EnemyMonMaxHP
ld a, [hBattleTurn]
@@ -2349,8 +2333,6 @@ IsAnyMonHoldingExpShare: ; 3ceaa
ret
; 3ceec
-
-
StopDangerSound: ; 3ceec
xor a
ld [Danger], a
@@ -2503,8 +2485,8 @@ WinTrainerBattle: ; 3cfa4
call BattleWinSlideInEnemyTrainerFrontpic
ld c, 40
call DelayFrames
- ld c, $4
- callba Function4ea0a
+ ld c, $4 ; win
+ callba Mobile_PrintOpponentBattleMessage
ret
.battle_tower
@@ -2622,7 +2604,6 @@ WinTrainerBattle: ; 3cfa4
dw SentAllToMomText
; 3d0b1
-
.CheckMaxedOutMomMoney: ; 3d0b1
ld hl, wMomsMoney + 2
ld a, [hld]
@@ -2642,7 +2623,7 @@ AddBattleMoneyToAccount: ; 3d0be
push bc
ld b, h
ld c, l
- callba MobileFn_106008
+ callba TrainerRankings_AddToBattlePayouts
pop bc
pop hl
.loop
@@ -2705,8 +2686,6 @@ PlayVictoryMusic: ; 3d0ea
ret
; 3d123
-
-
; These functions check if the current opponent is a gym leader or one of a
; few other special trainers.
@@ -2760,7 +2739,6 @@ KantoGymLeaders:
db BLUE
db -1
-
HandlePlayerMonFaint: ; 3d14e
call FaintYourPokemon
ld hl, EnemyMonHP
@@ -2961,7 +2939,6 @@ PlayerPartyMonEntrance: ; 3d2b3
jp SpikesDamage
; 3d2e0
-
CheckMobileBattleError: ; 3d2e0
ld a, [wLinkMode]
cp LINK_MOBILE
@@ -3060,7 +3037,6 @@ ForcePickPartyMonInBattle: ; 3d362
jr .pick
; 3d375
-
PickSwitchMonInBattle: ; 3d375
.pick
call PickPartyMonInBattle
@@ -3085,7 +3061,6 @@ ForcePickSwitchMonInBattle: ; 3d380
ret
; 3d38e
-
LostBattle: ; 3d38e
ld a, 1
ld [BattleEnded], a
@@ -3176,13 +3151,12 @@ LostBattle: ; 3d38e
ld c, 40
call DelayFrames
- ld c, $3
- callba Function4ea0a
+ ld c, $3 ; lost
+ callba Mobile_PrintOpponentBattleMessage
scf
ret
; 3d432
-
EnemyMonFaintedAnimation: ; 3d432
hlcoord 12, 5
decoord 12, 6
@@ -3250,7 +3224,6 @@ MonFaintedAnimation: ; 3d444
db " @"
; 3d490
-
SlideBattlePicOut: ; 3d490
ld [hMapObjectIndexBuffer], a
ld c, a
@@ -3297,7 +3270,6 @@ SlideBattlePicOut: ; 3d490
ret
; 3d4c3
-
ForceEnemySwitch: ; 3d4c3
call ResetEnemyBattleVars
ld a, [wEnemySwitchMonIndex]
@@ -3313,7 +3285,6 @@ ForceEnemySwitch: ; 3d4c3
ret
; 3d4e1
-
EnemySwitch: ; 3d4e1
call CheckWhetherToAskSwitch
jr nc, EnemySwitch_SetMode
@@ -3372,14 +3343,14 @@ CheckWhetherSwitchmonIsPredetermined: ; 3d533
.not_linked
ld a, [wEnemySwitchMonIndex]
and a
- jr z, .check_wAISwitch
+ jr z, .check_wBattleHasJustStarted
dec a
ld b, a
jr .return_carry
-.check_wAISwitch
- ld a, [wAISwitch]
+.check_wBattleHasJustStarted
+ ld a, [wBattleHasJustStarted]
and a
ld b, $0
jr nz, .return_carry
@@ -3655,7 +3626,7 @@ LoadEnemyPkmnToSwitchTo: ; 3d6ca
; 3d714
CheckWhetherToAskSwitch: ; 3d714
- ld a, [wAISwitch]
+ ld a, [wBattleHasJustStarted]
dec a
jp z, .return_nc
ld a, [PartyCount]
@@ -3846,7 +3817,6 @@ CheckPlayerPartyForFitPkmn: ; 3d873
ret
; 3d887
-
CheckIfCurPartyMonIsFitToFight: ; 3d887
ld a, [CurPartyMon]
ld hl, PartyMon1HP
@@ -3855,7 +3825,7 @@ CheckIfCurPartyMonIsFitToFight: ; 3d887
or [hl]
ret nz
- ld a, [wAISwitch]
+ ld a, [wBattleHasJustStarted]
and a
jr nz, .finish_fail
ld hl, PartySpecies
@@ -3878,7 +3848,6 @@ CheckIfCurPartyMonIsFitToFight: ; 3d887
ret
; 3d8b3
-
TryToRunAwayFromBattle: ; 3d8b3
; Run away from battle, with or without item
ld a, [BattleType]
@@ -4068,7 +4037,6 @@ TryToRunAwayFromBattle: ; 3d8b3
ret
; 3da0d
-
InitBattleMon: ; 3da0d
ld a, MON_SPECIES
call GetPartyParamLocation
@@ -4080,9 +4048,9 @@ InitBattleMon: ; 3da0d
ld de, BattleMonDVs
ld bc, MON_PKRUS - MON_DVS
call CopyBytes
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld de, BattleMonLevel
ld bc, PARTYMON_STRUCT_LENGTH - MON_LEVEL
call CopyBytes
@@ -4159,7 +4127,6 @@ ResetPlayerStatLevels: ; 3dab1
ret
; 3dabd
-
InitEnemyMon: ; 3dabd
ld a, [CurPartyMon]
ld hl, OTPartyMon1Species
@@ -4172,9 +4139,9 @@ InitEnemyMon: ; 3dabd
ld de, EnemyMonDVs
ld bc, MON_PKRUS - MON_DVS
call CopyBytes
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
ld de, EnemyMonLevel
ld bc, PARTYMON_STRUCT_LENGTH - MON_LEVEL
call CopyBytes
@@ -4213,7 +4180,6 @@ endr
ret
; 3db32
-
SwitchPlayerMon: ; 3db32
call ClearSprites
ld a, [CurBattleMon]
@@ -4234,7 +4200,6 @@ SwitchPlayerMon: ; 3db32
ret
; 3db5f
-
SendOutPlayerMon: ; 3db5f
ld hl, BattleMonDVs
predef GetUnownLetter
@@ -4302,9 +4267,9 @@ rept 4
endr
ld [hl], a
ld hl, PlayerUsedMoves
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
ld [PlayerDisableCount], a
ld [PlayerFuryCutterCount], a
@@ -4580,7 +4545,6 @@ UseOpponentItem:
jp StdBattleTextBox
; 3ddc8
-
ItemRecoveryAnim: ; 3ddc8
push hl
push de
@@ -4665,7 +4629,6 @@ UseHeldStatusHealingItem: ; 3dde9
db $ff
; 3de51
-
UseConfusionHealingItem: ; 3de51
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call GetBattleVar
@@ -4713,21 +4676,21 @@ HandleStatBoostingHeldItems: ; 3de97
ld a, [hLinkPlayerNumber]
cp $1
jr z, .player_1
- call .DoEnemy
- jp .DoPlayer
-
-.player_1
call .DoPlayer
jp .DoEnemy
+
+.player_1
+ call .DoEnemy
+ jp .DoPlayer
; 3dea9
-.DoEnemy: ; 3dea9
+.DoPlayer: ; 3dea9
call GetPartymonItem
ld a, $0
jp .HandleItem
; 3deb1
-.DoPlayer: ; 3deb1
+.DoEnemy: ; 3deb1
call GetOTPartymonItem
ld a, $1
.HandleItem: ; 3deb6
@@ -4790,7 +4753,6 @@ HandleStatBoostingHeldItems: ; 3de97
db $ff
; 3df12
-
GetPartymonItem: ; 3df12
ld hl, PartyMon1Item
ld a, [CurBattleMon]
@@ -4824,8 +4786,6 @@ UpdateBattleHUDs: ; 3df2c
ret
; 3df48
-
-
UpdatePlayerHUD:: ; 3df48
push hl
push de
@@ -4939,7 +4899,7 @@ PrintPlayerHUD: ; 3dfbf
pop hl
dec hl
- ld a, BREEDMON
+ ld a, TEMPMON
ld [MonType], a
callab GetGender
ld a, " "
@@ -5017,7 +4977,7 @@ DrawEnemyHUD: ; 3e043
ld a, [hl]
ld [de], a
- ld a, BREEDMON
+ ld a, TEMPMON
ld [MonType], a
callab GetGender
ld a, " "
@@ -5164,7 +5124,6 @@ BattleMenu: ; 3e139
jr z, .skip_dude_pack_select
callba _DudeAutoInput_DownA
.skip_dude_pack_select
-
call LoadBattleMenu2
ret c
@@ -5383,35 +5342,42 @@ BattleMenuPKMN_Loop:
Battle_StatsScreen: ; 3e308
call DisableLCD
+
ld hl, VTiles2 tile $31
ld de, VTiles0
- ld bc, $0110
+ ld bc, $11 tiles
call CopyBytes
+
ld hl, VTiles2
ld de, VTiles0 tile $11
ld bc, $31 tiles
call CopyBytes
+
call EnableLCD
+
call ClearSprites
call LowVolume
xor a ; PARTYMON
ld [MonType], a
callba BattleStatsScreenInit
call MaxVolume
+
call DisableLCD
+
ld hl, VTiles0
ld de, VTiles2 tile $31
ld bc, $11 tiles
call CopyBytes
+
ld hl, VTiles0 tile $11
ld de, VTiles2
ld bc, $31 tiles
call CopyBytes
+
call EnableLCD
ret
; 3e358
-
TryPlayerSwitch: ; 3e358
ld a, [CurBattleMon]
ld d, a
@@ -5566,7 +5532,6 @@ PassedBattleMonEntrance: ; 3e459
jp SpikesDamage
; 3e489
-
BattleMenu_Run: ; 3e489
call Call_LoadTempTileMapToTileMap
ld a, $3
@@ -5583,7 +5548,6 @@ BattleMenu_Run: ; 3e489
jp BattleMenu
; 3e4a8
-
CheckAmuletCoin: ; 3e4a8
ld a, [BattleMonItem]
ld b, a
@@ -5990,7 +5954,6 @@ MoveInfoBox: ; 3e6c8
db "TYPE/@"
; 3e75f
-
.PrintPP: ; 3e75f
hlcoord 5, 11
ld a, [wLinkMode] ; What's the point of this check?
@@ -6048,7 +6011,7 @@ CheckPlayerHasUsableMoves: ; 3e786
jr .loop
.done
- and a
+ and a ; This is probably a bug, and will result in a move with PP Up confusing the game.
ret nz
.force_struggle
@@ -6060,8 +6023,6 @@ CheckPlayerHasUsableMoves: ; 3e786
ret
; 3e7c1
-
-
ParseEnemyAction: ; 3e7c1
ld a, [wEnemyIsSwitching]
and a
@@ -6242,7 +6203,6 @@ LinkBattleSendReceiveAction: ; 3e8e4
ret
; 3e8eb
-
LoadEnemyMon: ; 3e8eb
; Initialize enemy monster parameters
; To do this we pull the species from TempEnemyMonSpecies
@@ -6275,7 +6235,6 @@ LoadEnemyMon: ; 3e8eb
; Grab the BaseData for this species
call GetBaseData
-
; Let's get the item:
; Is the item predetermined?
@@ -6290,7 +6249,6 @@ LoadEnemyMon: ; 3e8eb
ld a, [hl]
jr .UpdateItem
-
.WildItem:
; In a wild battle, we pull from the item slots in BaseData
@@ -6320,11 +6278,9 @@ LoadEnemyMon: ; 3e8eb
jr nc, .UpdateItem
ld a, [BaseItems+1]
-
.UpdateItem:
ld [EnemyMonItem], a
-
; Initialize DVs
; If we're in a trainer battle, DVs are predetermined
@@ -6346,7 +6302,6 @@ LoadEnemyMon: ; 3e8eb
ld [de], a
jp .Happiness
-
.InitDVs:
; Trainer DVs
@@ -6359,7 +6314,6 @@ LoadEnemyMon: ; 3e8eb
dec a
jr nz, .UpdateDVs
-
; Wild DVs
; Here's where the fun starts
@@ -6402,7 +6356,6 @@ LoadEnemyMon: ; 3e8eb
; We're done with DVs
jr .UpdateDVs
-
.NotRoaming:
; Register a contains BattleType
@@ -6429,16 +6382,13 @@ LoadEnemyMon: ; 3e8eb
ld [hli], a
ld [hl], c
-
; We've still got more to do if we're dealing with a wild monster
ld a, [wBattleMode]
dec a
jr nz, .Happiness
-
; Species-specfic:
-
; Unown
ld a, [TempEnemyMonSpecies]
cp a, UNOWN
@@ -6452,7 +6402,6 @@ LoadEnemyMon: ; 3e8eb
call CheckUnownLetter
jr c, .GenerateDVs ; try again
-
.Magikarp:
; Skimming this part recommended
@@ -6513,7 +6462,6 @@ LoadEnemyMon: ; 3e8eb
cp a, 1024 >> 8
jr c, .GenerateDVs ; try again
-
; Finally done with DVs
.Happiness:
@@ -6526,7 +6474,7 @@ LoadEnemyMon: ; 3e8eb
; Fill stats
ld de, EnemyMonMaxHP
ld b, FALSE
- ld hl, LinkBattleRNs + 7 ; ?
+ ld hl, EnemyMonDVs - (MON_DVS - MON_STAT_EXP + 1) ; LinkBattleRNs + 7 ; ?
predef CalcPkmnStats
; If we're in a trainer battle,
@@ -6588,7 +6536,6 @@ LoadEnemyMon: ; 3e8eb
ld [hl], a
jr .Moves
-
.OpponentParty:
; Get HP from the party struct
ld hl, (OTPartyMon1HP + 1)
@@ -6608,7 +6555,6 @@ LoadEnemyMon: ; 3e8eb
ld a, [hl] ; OTPartyMonStatus
ld [EnemyMonStatus], a
-
.Moves:
ld hl, BaseType1
ld de, EnemyMonType1
@@ -6637,9 +6583,9 @@ LoadEnemyMon: ; 3e8eb
xor a
ld h, d
ld l, e
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
; Make sure the predef knows this isn't a partymon
ld [MagikarpLength], a
@@ -6718,7 +6664,6 @@ endr
ret
; 3eb38
-
CheckSleepingTreeMon: ; 3eb38
; Return carry if species is in the list
; for the current time of day
@@ -6779,7 +6724,6 @@ CheckSleepingTreeMon: ; 3eb38
db -1 ; end
; 3eb75
-
CheckUnownLetter: ; 3eb75
; Return carry if the Unown letter hasn't been unlocked yet
@@ -6848,7 +6792,6 @@ CheckUnownLetter: ; 3eb75
; 3ebc7
-
SwapBattlerLevels: ; 3ebc7
; unreferenced
push bc
@@ -6924,7 +6867,6 @@ BattleWinSlideInEnemyTrainerFrontpic: ; 3ebd8
ret
; 3ec2c
-
ApplyStatusEffectOnPlayerStats: ; 3ec2c
ld a, 1
jr ApplyStatusEffectOnStats
@@ -7143,7 +7085,6 @@ ApplyStatLevelMultiplier: ; 3ecb7
db 4, 1 ; 400%
; 3ed45
-
BadgeStatBoosts: ; 3ed45
; Raise BattleMon stats depending on which badges have been obtained.
@@ -7202,7 +7143,6 @@ BadgeStatBoosts: ; 3ed45
ret
; 3ed7c
-
BoostStat: ; 3ed7c
; Raise stat at hl by 1/8.
@@ -7235,7 +7175,6 @@ BoostStat: ; 3ed7c
ret
; 3ed9f
-
_LoadBattleFontsHPBar: ; 3ed9f
callab LoadBattleFontsHPBar
ret
@@ -7246,7 +7185,6 @@ _LoadHPBar: ; 3eda6
ret
; 3edad
-
LoadHPExpBarGFX: ; unreferenced
ld de, EnemyHPBarBorderGFX
ld hl, VTiles2 tile $6c
@@ -7262,7 +7200,6 @@ LoadHPExpBarGFX: ; unreferenced
jp Get2bpp
; 3edd1
-
EmptyBattleTextBox: ; 3edd1
ld hl, .empty
jp BattleTextBox
@@ -7270,7 +7207,6 @@ EmptyBattleTextBox: ; 3edd1
db "@"
; 3edd8
-
_BattleRandom:: ; 3edd8
; If the normal RNG is used in a link battle it'll desync.
; To circumvent this a shared PRNG is used instead.
@@ -7340,7 +7276,6 @@ _BattleRandom:: ; 3edd8
ret
; 3ee0f
-
Call_PlayBattleAnim_OnlyIfVisible: ; 3ee0f
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVar
@@ -7373,7 +7308,6 @@ FinishBattleAnim: ; 3ee27
ret
; 3ee3b
-
GiveExperiencePoints: ; 3ee3b
; Give experience.
; Don't give experience if linked or in the Battle Tower.
@@ -7832,7 +7766,6 @@ TextJump_StringBuffer2ExpPoints: ; 3f131
db "@"
; 3f136
-
AnimateExpBar: ; 3f136
push bc
@@ -8019,8 +7952,6 @@ AnimateExpBar: ; 3f136
ld [hBGMapMode], a
ret
-
-
SendOutPkmnText: ; 3f26d
ld a, [wLinkMode]
and a
@@ -8028,7 +7959,7 @@ SendOutPkmnText: ; 3f26d
ld hl, JumpText_GoPkmn ; If we're in a LinkBattle print just "Go <PlayerMon>"
- ld a, [wAISwitch] ; unless this (unidentified) variable is set
+ ld a, [wBattleHasJustStarted] ; unless this (unidentified) variable is set
and a
jr nz, .skip_to_textbox
@@ -8083,7 +8014,6 @@ SendOutPkmnText: ; 3f26d
jp BattleTextBox
; 3f2d1
-
JumpText_GoPkmn: ; 3f2d1
text_jump Text_GoPkmn
start_asm
@@ -8197,7 +8127,6 @@ TextJump_ComeBack: ; 3f35b
db "@"
; 3f360
-
HandleSafariAngerEatingStatus: ; unreferenced
ld hl, wSafariMonEating
ld a, [hl]
@@ -8230,7 +8159,6 @@ HandleSafariAngerEatingStatus: ; unreferenced
jp StdBattleTextBox
; 3f390
-
FillInExpBar: ; 3f390
push hl
call CalcExpBar
@@ -8447,7 +8375,6 @@ GetFrontpic_DoAnim: ; 3f4b4
ret
; 3f4c1
-
StartBattle: ; 3f4c1
; This check prevents you from entering a battle without any Pokemon.
; Those using walk-through-walls to bypass getting a Pokemon experience
@@ -8467,16 +8394,14 @@ StartBattle: ; 3f4c1
ret
; 3f4d9
-
_DoBattle: ; 3f4d9
; unreferenced
call DoBattle
ret
; 3f4dd
-
BattleIntro: ; 3f4dd
- callba MobileFn_106050 ; mobile
+ callba TrainerRankings_Battles ; mobile
call LoadTrainerOrWildMonPic
xor a
ld [TempBattleMonSpecies], a
@@ -8561,7 +8486,7 @@ BackUpVBGMap2: ; 3f568
InitEnemyTrainer: ; 3f594
ld [TrainerClass], a
- callba MobileFn_10606a
+ callba TrainerRankings_TrainerBattles
xor a
ld [TempEnemyMonSpecies], a
callab GetTrainerAttributes
@@ -8617,7 +8542,7 @@ InitEnemyTrainer: ; 3f594
InitEnemyWildmon: ; 3f607
ld a, WILD_BATTLE
ld [wBattleMode], a
- callba MobileFn_10605d
+ callba TrainerRankings_WildBattles
call LoadEnemyMon
ld hl, EnemyMonMoves
ld de, wWildMonMoves
@@ -8702,7 +8627,6 @@ Function3f662: ; 3f662
ret
; 3f69e
-
ExitBattle: ; 3f69e
call .HandleEndOfBattle
call CleanUpBattleRAM
@@ -8801,7 +8725,7 @@ CheckPayDay: ; 3f71d
; 3f759
ShowLinkBattleParticipantsAfterEnd: ; 3f759
- callba MobileFn_1060df
+ callba TrainerRankings_LinkBattles
callba BackupMobileEventIndex
ld a, [CurOTMon]
ld hl, OTPartyMon1Status
@@ -8831,17 +8755,17 @@ DetermineMobileBattleResult: ; 3f77c
cp $1
jr c, .victory
jr z, .loss
- callba MobileFn_SaveBattleResult_Draw
+ callba TrainerRankings_ColosseumDraws
ld de, .Draw
jr .store_result
.victory
- callba MobileFn_SaveBattleResult_Win
+ callba TrainerRankings_ColosseumWins
ld de, .Win
jr .store_result
.loss
- callba MobileFn_SaveBattleResult_Lose
+ callba TrainerRankings_ColosseumLosses
ld de, .Lose
jr .store_result
@@ -8881,7 +8805,6 @@ DetermineMobileBattleResult: ; 3f77c
db " DRAW@"
; 3f80f
-
.Mobile_InvalidBattle: ; 3f80f
hlcoord 6, 8
ld de, .Invalid
@@ -8896,14 +8819,12 @@ DetermineMobileBattleResult: ; 3f77c
db "INVALID BATTLE@"
; 3f830
-
IsMobileBattle2: ; 3f830
ld a, [wLinkMode]
cp LINK_MOBILE
ret
; 3f836
-
DisplayLinkRecord: ; 3f836
ld a, BANK(sLinkBattleStats)
call GetSRAMBank
@@ -8916,7 +8837,7 @@ DisplayLinkRecord: ; 3f836
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call ByteFill
call WaitBGMap2
- ld b, SCGB_08
+ ld b, SCGB_DIPLOMA
call GetSGBLayout
call SetPalettes
ld c, 8
@@ -8925,7 +8846,6 @@ DisplayLinkRecord: ; 3f836
ret
; 3f85f
-
ReadAndPrintLinkBattleRecord: ; 3f85f
call ClearTileMap
call ClearSprites
@@ -9060,7 +8980,6 @@ ReadAndPrintLinkBattleRecord: ; 3f85f
db "TOTAL WIN LOSE DRAW@"
; 3f998
-
BattleEnd_HandleRoamMons: ; 3f998
ld a, [BattleType]
cp BATTLETYPE_ROAMING
@@ -9168,7 +9087,6 @@ GetRoamMonSpecies: ; 3fa31
ret
; 3fa42
-
AddLastMobileBattleToLinkRecord: ; 3fa42
ld hl, OTPlayerID
ld de, StringBuffer1
@@ -9429,7 +9347,7 @@ InitBattleDisplay: ; 3fb6c
ld [rSVBK], a
ld hl, wDecompressScratch
- ld bc, wBackupAttrMap - wDecompressScratch
+ ld bc, wScratchAttrMap - wDecompressScratch
ld a, " "
call ByteFill
@@ -9449,7 +9367,6 @@ InitBattleDisplay: ; 3fb6c
ret
; 3fbff
-
GetTrainerBackpic: ; 3fbff
; Load the player character's backpic (6x6) into VRAM starting from VTiles2 tile $31.
@@ -9484,7 +9401,6 @@ GetTrainerBackpic: ; 3fbff
ret
; 3fc30
-
CopyBackpic: ; 3fc30
ld a, [rSVBK]
push af
@@ -9543,7 +9459,6 @@ CopyBackpic: ; 3fc30
ret
; 3fc8b
-
BattleStartMessage: ; 3fc8b
ld a, [wBattleMode]
dec a
@@ -9598,7 +9513,7 @@ BattleStartMessage: ; 3fc8b
cp BATTLETYPE_FISH
jr nz, .NotFishing
- callba MobileFn_106086 ; update fishing records?
+ callba TrainerRankings_HookedEncounters
ld hl, HookedPokemonAttackedText
jr .PlaceBattleStartText
@@ -9621,8 +9536,8 @@ BattleStartMessage: ; 3fc8b
call IsMobileBattle2
ret nz
- ld c, $2
- callba Function4ea0a
+ ld c, $2 ; start
+ callba Mobile_PrintOpponentBattleMessage
ret
; 3fd26
diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm
index 5c1214cb7..a74dea632 100644
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -1541,11 +1541,6 @@ BattleCheckTypeMatchup: ; 347c8
and a
jr z, CheckTypeMatchup
ld hl, BattleMonType1
-
- ; fallthrough
-; 347d3
-
-
CheckTypeMatchup: ; 347d3
push hl
push de
@@ -2837,11 +2832,11 @@ PlayerAttackDamage: ; 352e2
call GetDamageStatsCritical
jr c, .thickclub
- ld hl, EnemyStats + 2
+ ld hl, EnemyDefense
ld a, [hli]
ld b, a
ld c, [hl]
- ld hl, PlayerStats
+ ld hl, PlayerAttack
jr .thickclub
.special
@@ -2861,11 +2856,11 @@ PlayerAttackDamage: ; 352e2
call GetDamageStatsCritical
jr c, .lightball
- ld hl, EnemyStats + SP_DEFENSE * 2
+ ld hl, EnemySpDef
ld a, [hli]
ld b, a
ld c, [hl]
- ld hl, PlayerStats + SP_ATTACK * 2
+ ld hl, PlayerSpAtk
.lightball
; Note: Returns player special attack at hl in hl.
@@ -3103,11 +3098,11 @@ EnemyAttackDamage: ; 353f6
call GetDamageStatsCritical
jr c, .thickclub
- ld hl, PlayerStats + 2
+ ld hl, PlayerDefense
ld a, [hli]
ld b, a
ld c, [hl]
- ld hl, EnemyStats
+ ld hl, EnemyAttack
jr .thickclub
.Special:
@@ -3126,11 +3121,11 @@ EnemyAttackDamage: ; 353f6
ld hl, EnemyMonSpclAtk
call GetDamageStatsCritical
jr c, .lightball
- ld hl, PlayerStats + 8
+ ld hl, PlayerSpDef
ld a, [hli]
ld b, a
ld c, [hl]
- ld hl, EnemyStats + 6
+ ld hl, EnemySpAtk
.lightball
call LightBallBoost
@@ -3407,9 +3402,9 @@ HitSelfInConfusion: ; 355dd
sla c
rl b
.mimic_screen
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld a, [hli]
ld l, [hl]
ld h, a
@@ -3953,9 +3948,9 @@ BattleCommand_Encore: ; 35864
set SUBSTATUS_ENCORED, [hl]
call BattleRandom
and $3
-rept 3
inc a
-endr
+ inc a
+ inc a
ld [de], a
call CheckOpponentWentFirst
jr nz, .finish_move
@@ -4094,12 +4089,12 @@ BattleCommand_PainSplit: ; 35926
ld a, [CurDamage + 1]
rr a
ld [CurDamage + 1], a
-rept 3
inc hl
-endr
-rept 3
+ inc hl
+ inc hl
+ inc de
+ inc de
inc de
-endr
.EnemyShareHP: ; 359ac
ld c, [hl]
@@ -6687,6 +6682,10 @@ BattleCommand_Teleport: ; 36778
srl b
srl b
cp b
+ ; This does the wrong thing. What was
+ ; probably intended was jr c, .failed
+ ; The way this is made makes enemy use
+ ; of Teleport always succeed if able
jr nc, .run_away
.run_away
call UpdateBattleMonInParty
@@ -7447,9 +7446,9 @@ BattleCommand_TrapTarget: ; 36c2d
ret nz
call BattleRandom
and 3
-rept 3
inc a
-endr
+ inc a
+ inc a
ld [hl], a
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
@@ -8074,7 +8073,7 @@ BattleCommand_LeechSeed: ; 36f9d
BattleCommand_Splash: ; 36fe1
call AnimateCurrentMove
- callba MobileFn_1060e5
+ callba TrainerRankings_Splash
jp PrintNothingHappened
; 36fed
@@ -8601,7 +8600,7 @@ CheckSubstituteOpp: ; 37378
BattleCommand_SelfDestruct: ; 37380
- callba MobileFn_10610d
+ callba TrainerRankings_SelfDestruct
ld a, BATTLEANIM_PLAYER_DAMAGE
ld [wNumHits], a
ld c, 3
@@ -9750,6 +9749,7 @@ BattleCommand_ThunderAccuracy: ; 37d94
ret
.rain
+ ; Redundant with CheckHit guranteeing hit
ld [hl], 100 percent
ret
diff --git a/battle/hidden_power.asm b/battle/hidden_power.asm
index 68b0e80f8..184c597d0 100644
--- a/battle/hidden_power.asm
+++ b/battle/hidden_power.asm
@@ -45,9 +45,8 @@ HiddenPowerDamage: ; fbced
; Multiply by 5
ld b, a
-rept 2
add a
-endr
+ add a
add b
; Add Special & 3
@@ -75,9 +74,8 @@ endr
ld a, [hl]
and 3 << 4
swap a
-rept 2
add a
-endr
+ add a
or b
; Skip Normal
diff --git a/battle/link_result.asm b/battle/link_result.asm
new file mode 100755
index 000000000..5739bbdc0
--- /dev/null
+++ b/battle/link_result.asm
@@ -0,0 +1,162 @@
+DetermineLinkBattleResult: ; 2b930
+ callba UpdateEnemyMonInParty
+ ld hl, PartyMon1HP
+ call .CountMonsRemaining
+ push bc
+ ld hl, OTPartyMon1HP
+ call .CountMonsRemaining
+ ld a, c
+ pop bc
+ cp c
+ jr z, .even_number_of_mons_remaining
+ jr c, .defeat
+ jr .victory
+
+.even_number_of_mons_remaining
+ call .BothSides_CheckNumberMonsAtFullHealth
+ jr z, .drawn
+ ld a, e
+ cp $1
+ jr z, .victory
+ cp $2
+ jr z, .defeat
+ ld hl, PartyMon1HP
+ call .CalcPercentHPRemaining
+ push de
+ ld hl, OTPartyMon1HP
+ call .CalcPercentHPRemaining
+ pop hl
+ ld a, d
+ cp h
+ jr c, .victory
+ jr z, .compare_lo
+ jr .defeat
+
+.compare_lo
+ ld a, e
+ cp l
+ jr z, .drawn
+ jr nc, .defeat
+
+.victory
+ ld a, [wBattleResult]
+ and $f0
+ ld [wBattleResult], a
+ ret
+
+.defeat
+ ld a, [wBattleResult]
+ and $f0
+ add $1
+ ld [wBattleResult], a
+ ret
+
+.drawn
+ ld a, [wBattleResult]
+ and $f0
+ add $2
+ ld [wBattleResult], a
+ ret
+
+.CountMonsRemaining: ; 2b995
+ ld c, 0
+ ld b, 3
+ ld de, PARTYMON_STRUCT_LENGTH - 1
+.loop
+ ld a, [hli]
+ or [hl]
+ jr nz, .not_fainted
+ inc c
+
+.not_fainted
+ add hl, de
+ dec b
+ jr nz, .loop
+ ret
+
+.CalcPercentHPRemaining: ; 2b9a6
+ ld de, 0
+ ld c, $3
+.loop2
+ ld a, [hli]
+ or [hl]
+ jr z, .next
+ dec hl
+ xor a
+ ld [hDividend + 0], a
+ ld a, [hli]
+ ld [hDividend + 1], a
+ ld a, [hli]
+ ld [hDividend + 2], a
+ xor a
+ ld [hDividend + 3], a
+ ld a, [hli]
+ ld b, a
+ ld a, [hld]
+ srl b
+ rr a
+ srl b
+ rr a
+ ld [hDivisor], a
+ ld b, $4
+ call Divide
+ ld a, [hQuotient + 2]
+ add e
+ ld e, a
+ ld a, [hQuotient + 1]
+ adc d
+ ld d, a
+ dec hl
+
+.next
+ push de
+ ld de, $2f
+ add hl, de
+ pop de
+ dec c
+ jr nz, .loop2
+ ret
+
+.BothSides_CheckNumberMonsAtFullHealth: ; 2b9e1
+ ld hl, PartyMon1HP
+ call .CheckFaintedOrFullHealth
+ jr nz, .finish ; we have a pokemon that's neither fainted nor at full health
+ ld hl, OTPartyMon1HP
+ call .CheckFaintedOrFullHealth
+ ld e, $1
+ ret
+
+.finish
+ ld hl, OTPartyMon1HP
+ call .CheckFaintedOrFullHealth
+ ld e, $0
+ ret nz ; we both have pokemon that are neither fainted nor at full health
+ ld e, $2
+ ld a, $1
+ and a
+ ret
+
+.CheckFaintedOrFullHealth: ; 2ba01
+ ld d, 3
+.loop3
+ ld a, [hli]
+ ld b, a
+ ld a, [hli]
+ ld c, a
+ or b
+ jr z, .fainted_or_full_health
+ ld a, [hli]
+ cp b
+ ret nz
+ ld a, [hld]
+ cp c
+ ret nz
+
+.fainted_or_full_health
+ push de
+ ld de, PARTYMON_STRUCT_LENGTH - 2
+ add hl, de
+ pop de
+ dec d
+ jr nz, .loop3
+ ret
diff --git a/battle/magikarp_length.asm b/battle/magikarp_length.asm
index 237450928..160912c53 100644
--- a/battle/magikarp_length.asm
+++ b/battle/magikarp_length.asm
@@ -141,9 +141,8 @@ CalcMagikarpLength: ; fbbfc
; hl = de * 10
ld h, d
ld l, e
-rept 2
add hl, hl
-endr
+ add hl, hl
add hl, de
add hl, hl
diff --git a/battle/misc.asm b/battle/misc.asm
index 97a11898e..0fed74e38 100644
--- a/battle/misc.asm
+++ b/battle/misc.asm
@@ -72,9 +72,8 @@ DoWeatherModifiers: ; fbda4
jr z, .ApplyModifier
.NextWeatherType:
-rept 2
inc de
-endr
+ inc de
jr .CheckWeatherType
@@ -99,9 +98,8 @@ endr
jr z, .ApplyModifier
.NextWeatherMove:
-rept 2
inc de
-endr
+ inc de
jr .CheckWeatherMove
.ApplyModifier:
diff --git a/battle/objects/data.asm b/battle/objects/data.asm
index 8a3f42f85..fa5dff269 100755
--- a/battle/objects/data.asm
+++ b/battle/objects/data.asm
@@ -57,22 +57,22 @@ endm
; ANIM_OBJ_BURNED
battleanimobj $01, $90, BATTLEANIMFRAMESET_11, BATTLEANIMFUNC_03, $04, $03
-; ANIM_OBJ_11
+; ANIM_OBJ_BLIZZARD
battleanimobj $01, $90, BATTLEANIMFRAMESET_12, BATTLEANIMFUNC_08, $06, $0a
; ANIM_OBJ_12
battleanimobj $01, $90, BATTLEANIMFRAMESET_13, BATTLEANIMFUNC_00, $06, $0a
-; ANIM_OBJ_13
+; ANIM_OBJ_ICE_BEAM
battleanimobj $01, $90, BATTLEANIMFRAMESET_14, BATTLEANIMFUNC_01, $06, $0a
-; ANIM_OBJ_14
- battleanimobj $21, $78, BATTLEANIMFRAMESET_16, BATTLEANIMFUNC_0B, $05, $06
+; ANIM_OBJ_RAZOR_LEAF
+ battleanimobj $21, $78, BATTLEANIMFRAMESET_16, BATTLEANIMFUNC_RAZOR_LEAF, $05, $06
; ANIM_OBJ_POKE_BALL
battleanimobj $00, $00, BATTLEANIMFRAMESET_09, BATTLEANIMFUNC_12, $04, $0b
-; ANIM_OBJ_16
+; ANIM_OBJ_POKE_BALL_BLOCKED
battleanimobj $00, $00, BATTLEANIMFRAMESET_09, BATTLEANIMFUNC_13, $04, $0b
; ANIM_OBJ_17
@@ -90,7 +90,7 @@ endm
; ANIM_OBJ_1B
battleanimobj $01, $90, BATTLEANIMFRAMESET_08, BATTLEANIMFUNC_00, $02, $07
-; ANIM_OBJ_1C
+; ANIM_OBJ_BALL_POOF
battleanimobj $01, $a0, BATTLEANIMFRAMESET_08, BATTLEANIMFUNC_00, $02, $07
; ANIM_OBJ_1D
@@ -105,7 +105,7 @@ endm
; ANIM_OBJ_20
battleanimobj $01, $b0, BATTLEANIMFRAMESET_84, BATTLEANIMFUNC_36, $06, $21
-; ANIM_OBJ_21
+; ANIM_OBJ_BUBBLE
battleanimobj $01, $90, BATTLEANIMFRAMESET_21, BATTLEANIMFUNC_0C, $06, $0d
; ANIM_OBJ_22
@@ -129,13 +129,13 @@ endm
; ANIM_OBJ_28
battleanimobj $61, $98, BATTLEANIMFRAMESET_2D, BATTLEANIMFUNC_09, $03, $10
-; ANIM_OBJ_29
+; ANIM_OBJ_ICE_BUILDUP
battleanimobj $01, $b8, BATTLEANIMFRAMESET_2E, BATTLEANIMFUNC_00, $06, $0a
; ANIM_OBJ_FROZEN
battleanimobj $01, $b8, BATTLEANIMFRAMESET_2F, BATTLEANIMFUNC_00, $06, $0a
-; ANIM_OBJ_2B
+; ANIM_OBJ_MASTER_BALL_SPARKLE
battleanimobj $01, $b8, BATTLEANIMFRAMESET_30, BATTLEANIMFUNC_14, $07, $11
; ANIM_OBJ_2C
@@ -213,7 +213,7 @@ endm
; ANIM_OBJ_44
battleanimobj $21, $80, BATTLEANIMFRAMESET_4B, BATTLEANIMFUNC_00, $03, $11
-; ANIM_OBJ_45
+; ANIM_OBJ_ABSORB
battleanimobj $01, $88, BATTLEANIMFRAMESET_4C, BATTLEANIMFUNC_1C, $05, $12
; ANIM_OBJ_46
@@ -228,8 +228,8 @@ endm
; ANIM_OBJ_49
battleanimobj $21, $ff, BATTLEANIMFRAMESET_54, BATTLEANIMFUNC_1F, $05, $16
-; ANIM_OBJ_4A
- battleanimobj $21, $68, BATTLEANIMFRAMESET_56, BATTLEANIMFUNC_20, $05, $06
+; ANIM_OBJ_LEECH_SEED
+ battleanimobj $21, $68, BATTLEANIMFRAMESET_56, BATTLEANIMFUNC_LEECH_SEED, $05, $06
; ANIM_OBJ_4B
battleanimobj $21, $90, BATTLEANIMFRAMESET_59, BATTLEANIMFUNC_21, $02, $0e
@@ -279,20 +279,20 @@ endm
; ANIM_OBJ_5A
battleanimobj $21, $90, BATTLEANIMFRAMESET_6A, BATTLEANIMFUNC_27, $02, $1b
-; ANIM_OBJ_5B
- battleanimobj $00, $00, BATTLEANIMFRAMESET_6F, BATTLEANIMFUNC_29, $02, $1c
+; ANIM_OBJ_HAZE
+ battleanimobj $00, $00, BATTLEANIMFRAMESET_6F, BATTLEANIMFUNC_SPRIAL_DESCENT, $02, $1c
-; ANIM_OBJ_5C
- battleanimobj $21, $48, BATTLEANIMFRAMESET_70, BATTLEANIMFUNC_29, $02, $1c
+; ANIM_OBJ_MIST
+ battleanimobj $21, $48, BATTLEANIMFRAMESET_70, BATTLEANIMFUNC_SPRIAL_DESCENT, $02, $1c
-; ANIM_OBJ_5D
- battleanimobj $21, $48, BATTLEANIMFRAMESET_6F, BATTLEANIMFUNC_29, $02, $1c
+; ANIM_OBJ_SMOG
+ battleanimobj $21, $48, BATTLEANIMFRAMESET_6F, BATTLEANIMFUNC_SPRIAL_DESCENT, $02, $1c
-; ANIM_OBJ_5E
- battleanimobj $21, $78, BATTLEANIMFRAMESET_6F, BATTLEANIMFUNC_2A, $02, $1c
+; ANIM_OBJ_POISON_GAS
+ battleanimobj $21, $78, BATTLEANIMFRAMESET_6F, BATTLEANIMFUNC_POISON_GAS, $02, $1c
-; ANIM_OBJ_5F
- battleanimobj $61, $90, BATTLEANIMFRAMESET_71, BATTLEANIMFUNC_2B, $02, $1d
+; ANIM_OBJ_HORN
+ battleanimobj $61, $90, BATTLEANIMFRAMESET_71, BATTLEANIMFUNC_HORN, $02, $1d
; ANIM_OBJ_60
battleanimobj $61, $90, BATTLEANIMFRAMESET_72, BATTLEANIMFUNC_2C, $02, $1d
@@ -313,7 +313,7 @@ endm
battleanimobj $01, $80, BATTLEANIMFRAMESET_30, BATTLEANIMFUNC_2F, $02, $11
; ANIM_OBJ_66
- battleanimobj $01, $78, BATTLEANIMFRAMESET_76, BATTLEANIMFUNC_2A, $04, $23
+ battleanimobj $01, $78, BATTLEANIMFRAMESET_76, BATTLEANIMFUNC_POISON_GAS, $04, $23
; ANIM_OBJ_67
battleanimobj $01, $80, BATTLEANIMFRAMESET_77, BATTLEANIMFUNC_30, $02, $1f
@@ -342,7 +342,7 @@ endm
; ANIM_OBJ_LICK
battleanimobj $21, $98, BATTLEANIMFRAMESET_7C, BATTLEANIMFUNC_00, $02, $04
-; ANIM_OBJ_70
+; ANIM_OBJ_WITHDRAW
battleanimobj $21, $80, BATTLEANIMFRAMESET_7D, BATTLEANIMFUNC_00, $02, $18
; ANIM_OBJ_71
@@ -393,8 +393,8 @@ endm
; ANIM_OBJ_80
battleanimobj $01, $a8, BATTLEANIMFRAMESET_0F, BATTLEANIMFUNC_3C, $04, $03
-; ANIM_OBJ_81
- battleanimobj $21, $68, BATTLEANIMFRAMESET_89, BATTLEANIMFUNC_29, $02, $1f
+; ANIM_OBJ_COTTON_SPORE
+ battleanimobj $21, $68, BATTLEANIMFRAMESET_89, BATTLEANIMFUNC_SPRIAL_DESCENT, $02, $1f
; ANIM_OBJ_82
battleanimobj $21, $b0, BATTLEANIMFRAMESET_8A, BATTLEANIMFUNC_00, $02, $1f
diff --git a/battle/objects/functions.asm b/battle/objects/functions.asm
index fbe48e558..4ed9b67b7 100755
--- a/battle/objects/functions.asm
+++ b/battle/objects/functions.asm
@@ -13,26 +13,26 @@ DoBattleAnimFrame: ; ccfbe
; ccfce
.Jumptable:
- dw BattleAnimFunction_00 ; 00
+ dw BattleAnimFunction_Null ; 00
dw BattleAnimFunction_01 ; 01
dw BattleAnimFunction_02 ; 02
dw BattleAnimFunction_03 ; 03
dw BattleAnimFunction_04 ; 04
- dw BattleAnimFunction_05 ; 05
- dw BattleAnimFunction_06 ; 06
+ dw BattleAnimFunction_ThrowFromPlayerToEnemy ; 05
+ dw BattleAnimFunction_ThrowFromPlayerToEnemyAndDisappear ; 06
dw BattleAnimFunction_07 ; 07
dw BattleAnimFunction_08 ; 08
dw BattleAnimFunction_09 ; 09
dw BattleAnimFunction_0A ; 0a
- dw BattleAnimFunction_0B ; 0b
+ dw BattleAnimFunction_RazorLeaf ; 0b
dw BattleAnimFunction_0C ; 0c
dw BattleAnimFunction_0D ; 0d
dw BattleAnimFunction_0E ; 0e
dw BattleAnimFunction_0F ; 0f
dw BattleAnimFunction_10 ; 10
dw BattleAnimFunction_11 ; 11
- dw BattleAnimFunction_12 ; 12
- dw BattleAnimFunction_13 ; 13
+ dw BattleAnimFunction_PokeBall ; 12
+ dw BattleAnimFunction_PokeBallBlocked ; 13
dw BattleAnimFunction_14 ; 14
dw BattleAnimFunction_15 ; 15
dw BattleAnimFunction_16 ; 16
@@ -45,7 +45,7 @@ DoBattleAnimFrame: ; ccfbe
dw BattleAnimFunction_1D ; 1d
dw BattleAnimFunction_1E ; 1e
dw BattleAnimFunction_1F ; 1f
- dw BattleAnimFunction_20 ; 20
+ dw BattleAnimFunction_LeechSeed ; 20
dw BattleAnimFunction_21 ; 21
dw BattleAnimFunction_22 ; 22
dw BattleAnimFunction_23 ; 23
@@ -54,9 +54,9 @@ DoBattleAnimFrame: ; ccfbe
dw BattleAnimFunction_26 ; 26
dw BattleAnimFunction_27 ; 27
dw BattleAnimFunction_28 ; 28
- dw BattleAnimFunction_29 ; 29
- dw BattleAnimFunction_2A ; 2a
- dw BattleAnimFunction_2B ; 2b
+ dw BattleAnimFunction_SpiralDescent ; 29
+ dw BattleAnimFunction_PoisonGas ; 2a
+ dw BattleAnimFunction_Horn ; 2b
dw BattleAnimFunction_2C ; 2c
dw BattleAnimFunction_2D ; 2d
dw BattleAnimFunction_2E ; 2e
@@ -94,7 +94,7 @@ DoBattleAnimFrame: ; ccfbe
dw BattleAnimFunction_4E ; 4e
dw BattleAnimFunction_4F ; 4f
-BattleAnimFunction_00: ; cd06e (33:506e)
+BattleAnimFunction_Null: ; cd06e (33:506e)
call BattleAnim_AnonJumptable
.anon_dw
dw .zero
@@ -104,34 +104,41 @@ BattleAnimFunction_00: ; cd06e (33:506e)
.zero
ret
-BattleAnimFunction_06: ; cd079 (33:5079)
- call BattleAnimFunction_05
+BattleAnimFunction_ThrowFromPlayerToEnemyAndDisappear: ; cd079 (33:5079)
+ call BattleAnimFunction_ThrowFromPlayerToEnemy
ret c
call DeinitBattleAnimation
ret
-BattleAnimFunction_05: ; cd081 (33:5081)
+BattleAnimFunction_ThrowFromPlayerToEnemy: ; cd081 (33:5081)
+ ; If x coord at $88 or beyond, abort.
ld hl, BATTLEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hl]
cp $88
ret nc
+ ; Move right 2 pixels
add $2
ld [hl], a
+ ; Move down 1 pixel
ld hl, BATTLEANIMSTRUCT_YCOORD
add hl, bc
dec [hl]
+ ; Decrease ??? and hold onto its previous value (argument of the sine function)
ld hl, BATTLEANIMSTRUCT_0F
add hl, bc
ld a, [hl]
dec [hl]
+ ; Get ???, which is the amplitude of the sine function
ld hl, BATTLEANIMSTRUCT_0B
add hl, bc
ld d, [hl]
call BattleAnim_Sine
+ ; Store the result in the Y offset
ld hl, BATTLEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
+ ; Carry flag denotes success
scf
ret
@@ -153,9 +160,10 @@ BattleAnimFunction_04: ; cd0a6 (33:50a6)
ld hl, BATTLEANIMSTRUCT_0F
add hl, bc
ld a, [hl]
-rept 4
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
+ inc [hl]
ld d, $10
push af
push de
@@ -258,7 +266,7 @@ BattleAnimFunction_02: ; cd146 (33:5146)
call DeinitBattleAnimation
ret
-BattleAnimFunction_12: ; cd15c (33:515c)
+BattleAnimFunction_PokeBall: ; cd15c (33:515c)
call BattleAnim_AnonJumptable
.anon_dw
dw .zero
@@ -273,13 +281,13 @@ BattleAnimFunction_12: ; cd15c (33:515c)
dw .nine
dw .ten
dw .eleven
-.zero
+.zero ; init
call GetBallAnimPal
call BattleAnim_IncAnonJumptableIndex
ret
.one
- call BattleAnimFunction_05
+ call BattleAnimFunction_ThrowFromPlayerToEnemy
ret c
ld hl, BATTLEANIMSTRUCT_YOFFSET
add hl, bc
@@ -288,14 +296,14 @@ BattleAnimFunction_12: ; cd15c (33:515c)
add hl, bc
add [hl]
ld [hl], a
- ld a, $b
+ ld a, BATTLEANIMFRAMESET_0B
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
.three
call BattleAnim_IncAnonJumptableIndex
- ld a, $9
+ ld a, BATTLEANIMFRAMESET_09
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_0F
add hl, bc
@@ -325,13 +333,13 @@ BattleAnimFunction_12: ; cd15c (33:515c)
sub $4
ld [hl], a
ret nz
- ld a, $c
+ ld a, BATTLEANIMFRAMESET_0C
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
.six
- ld a, $d
+ ld a, BATTLEANIMFRAMESET_0D
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_ANON_JT_INDEX
add hl, bc
@@ -343,7 +351,7 @@ BattleAnimFunction_12: ; cd15c (33:515c)
.seven
call GetBallAnimPal
- ld a, $a
+ ld a, BATTLEANIMFRAMESET_0A
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_10
@@ -375,7 +383,7 @@ BattleAnimFunction_12: ; cd15c (33:515c)
call DeinitBattleAnimation
ret
-BattleAnimFunction_13: ; cd212 (33:5212)
+BattleAnimFunction_PokeBallBlocked: ; cd212 (33:5212)
call BattleAnim_AnonJumptable
.anon_dw
dw .zero
@@ -392,7 +400,7 @@ BattleAnimFunction_13: ; cd212 (33:5212)
ld a, [hl]
cp $70
jr nc, .next
- call BattleAnimFunction_05
+ call BattleAnimFunction_ThrowFromPlayerToEnemy
ret
.next
@@ -493,7 +501,7 @@ BattleAnimFunction_10: ; cd284 (33:5284)
.three
call BattleAnim_IncAnonJumptableIndex
- ld a, $f
+ ld a, BATTLEANIMFRAMESET_0F
call ReinitBattleAnimFrameset
.four
ret
@@ -727,7 +735,7 @@ BattleAnimFunction_0A: ; cd3f2 (33:53f2)
ld [hl], a
cp $7
jr z, .seven
- ld a, $11
+ ld a, BATTLEANIMFRAMESET_11
call ReinitBattleAnimFrameset
ret
@@ -746,7 +754,7 @@ BattleAnimFunction_0A: ; cd3f2 (33:53f2)
.set_up_eight
call BattleAnim_IncAnonJumptableIndex
- ld a, $10
+ ld a, BATTLEANIMFRAMESET_10
call ReinitBattleAnimFrameset
.eight
ld hl, BATTLEANIMSTRUCT_0F
@@ -801,7 +809,7 @@ BattleAnimFunction_0A: ; cd3f2 (33:53f2)
.six
ret
-BattleAnimFunction_0B: ; cd478 (33:5478)
+BattleAnimFunction_RazorLeaf: ; cd478 (33:5478)
call BattleAnim_AnonJumptable
.anon_dw
dw .zero
@@ -830,7 +838,7 @@ BattleAnimFunction_0B: ; cd478 (33:5478)
add hl, bc
ld [hli], a
ld [hl], a
- ld a, $17
+ ld a, BATTLEANIMFRAMESET_17
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_0B
add hl, bc
@@ -926,7 +934,7 @@ BattleAnimFunction_0B: ; cd478 (33:5478)
ret
.three
- ld a, $16
+ ld a, BATTLEANIMFRAMESET_16
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_01
add hl, bc
@@ -1077,7 +1085,7 @@ BattleAnimFunction_0C: ; cd5e9 (33:55e9)
ld hl, BATTLEANIMSTRUCT_0F
add hl, bc
ld [hl], $0
- ld a, $22
+ ld a, BATTLEANIMFRAMESET_22
call ReinitBattleAnimFrameset
.two
ld hl, BATTLEANIMSTRUCT_XCOORD
@@ -1142,12 +1150,12 @@ BattleAnimFunction_0D: ; cd66a (33:566a)
dw .four
.zero
call BattleAnim_IncAnonJumptableIndex
- ld a, $42
- ld [hFFC6], a
+ ld a, rSCY - $ff00
+ ld [hLCDCPointer], a
ld a, $58
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ld a, $5e
- ld [hFFC8], a
+ ld [hLYOverrideEnd], a
ret
.one
@@ -1161,7 +1169,7 @@ BattleAnimFunction_0D: ; cd66a (33:566a)
jr nc, .asm_cd69b
call BattleAnim_IncAnonJumptableIndex
xor a
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ret
.asm_cd69b
@@ -1180,7 +1188,7 @@ BattleAnimFunction_0D: ; cd66a (33:566a)
add [hl]
sub $10
ret c
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ld hl, BATTLEANIMSTRUCT_XOFFSET
add hl, bc
ld a, [hl]
@@ -1201,9 +1209,9 @@ BattleAnimFunction_0D: ; cd66a (33:566a)
cp $70
jr c, asm_cd6da
xor a
- ld [hFFC6], a
- ld [hFFC7], a
- ld [hFFC8], a
+ ld [hLCDCPointer], a
+ ld [hLYOverrideStart], a
+ ld [hLYOverrideEnd], a
.four
call DeinitBattleAnimation
ret
@@ -1214,7 +1222,7 @@ asm_cd6da: ; cd6da (33:56da)
ld [hl], a
sub $10
ret c
- ld [hFFC7], a
+ ld [hLYOverrideStart], a
ret
BattleAnimFunction_0E: ; cd6e3 (33:56e3)
@@ -1226,8 +1234,8 @@ Functioncd6ea: ; cd6ea (33:56ea)
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_0B
add hl, bc
- ld a, $24
- add [hl]
+ ld a, BATTLEANIMFRAMESET_24
+ add [hl] ; offset
call ReinitBattleAnimFrameset
Functioncd6f7: ; cd6f7 (33:56f7)
ld hl, BATTLEANIMSTRUCT_XCOORD
@@ -1282,7 +1290,7 @@ Functioncd728: ; cd728 (33:5728)
.asm_cd747
call BattleAnim_IncAnonJumptableIndex
- ld a, $28
+ ld a, BATTLEANIMFRAMESET_28
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_YOFFSET
add hl, bc
@@ -1306,7 +1314,7 @@ Functioncd763: ; cd763 (33:5763)
.asm_cd76e
call BattleAnim_IncAnonJumptableIndex
- ld a, $29
+ ld a, BATTLEANIMFRAMESET_29
call ReinitBattleAnimFrameset
Functioncd776: ; cd776 (33:5776)
ret
@@ -1419,7 +1427,7 @@ BattleAnimFunction_15: ; cd80c (33:580c)
dw Functioncd820
Functioncd817: ; cd817 (33:5817)
call BattleAnim_IncAnonJumptableIndex
- ld a, $35
+ ld a, BATTLEANIMFRAMESET_35
call ReinitBattleAnimFrameset
Functioncd81f: ; cd81f (33:581f)
ret
@@ -1477,18 +1485,18 @@ Functioncd860: ; cd860 (33:5860)
add hl, bc
ld [hl], a
bit 7, a
- jr nz, .asm_cd87e
+ jr nz, .load_no_inc
ld hl, BATTLEANIMSTRUCT_10
add hl, bc
ld a, [hl]
inc a
- jr .asm_cd883
+ jr .reinit
-.asm_cd87e
+.load_no_inc
ld hl, BATTLEANIMSTRUCT_10
add hl, bc
ld a, [hl]
-.asm_cd883
+.reinit
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_0F
add hl, bc
@@ -1800,50 +1808,50 @@ Functioncda3a: ; cda3a (33:5a3a)
Functioncda4c: ; cda4c (33:5a4c)
ret
-BattleAnimFunction_20: ; cda4d (33:5a4d)
+BattleAnimFunction_LeechSeed: ; cda4d (33:5a4d)
call BattleAnim_AnonJumptable
.anon_dw
- dw Functioncda58
- dw Functioncda62
- dw Functioncda7a
- dw Functioncda8c
-Functioncda58: ; cda58 (33:5a58)
+ dw .zero
+ dw .one
+ dw .two
+ dw .three
+.zero: ; cda58 (33:5a58)
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_10
add hl, bc
ld [hl], $40
ret
-Functioncda62: ; cda62 (33:5a62)
+.one: ; cda62 (33:5a62)
ld hl, BATTLEANIMSTRUCT_10
add hl, bc
ld a, [hl]
cp $20
- jr c, .asm_cda6f
+ jr c, .sprout
call Functioncda8d
ret
-.asm_cda6f
+.sprout
ld [hl], $40
- ld a, $57
+ ld a, BATTLEANIMFRAMESET_57
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
-Functioncda7a: ; cda7a (33:5a7a)
+.two: ; cda7a (33:5a7a)
ld hl, BATTLEANIMSTRUCT_10
add hl, bc
ld a, [hl]
and a
- jr z, .asm_cda84
+ jr z, .flutter
dec [hl]
ret
-.asm_cda84
+.flutter
call BattleAnim_IncAnonJumptableIndex
- ld a, $58
+ ld a, BATTLEANIMFRAMESET_58
call ReinitBattleAnimFrameset
-Functioncda8c: ; cda8c (33:5a8c)
+.three: ; cda8c (33:5a8c)
ret
Functioncda8d: ; cda8d (33:5a8d)
@@ -2124,7 +2132,7 @@ Functioncdc1a: ; cdc1a (33:5c1a)
ret
Functioncdc1e: ; cdc1e (33:5c1e)
- ld a, $4e
+ ld a, BATTLEANIMFRAMESET_4E
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ret
@@ -2143,7 +2151,7 @@ Functioncdc27: ; cdc27 (33:5c27)
ret
Functioncdc39: ; cdc39 (33:5c39)
- ld a, $50
+ ld a, BATTLEANIMFRAMESET_50
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_YOFFSET
add hl, bc
@@ -2152,7 +2160,7 @@ Functioncdc39: ; cdc39 (33:5c39)
ret
Functioncdc48: ; cdc48 (33:5c48)
- ld a, $4f
+ ld a, BATTLEANIMFRAMESET_4F
call ReinitBattleAnimFrameset
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_0F
@@ -2258,7 +2266,7 @@ Functioncdcca: ; cdcca (33:5cca)
ld [hl], $8
ld hl, BATTLEANIMSTRUCT_0B
add hl, bc
- ld a, $59
+ ld a, BATTLEANIMFRAMESET_59
add [hl]
call ReinitBattleAnimFrameset
ret
@@ -2330,7 +2338,7 @@ Functioncdd31: ; cdd31 (33:5d31)
and $80
rlca
ld [hl], a
- add $5d
+ add BATTLEANIMFRAMESET_5D
call ReinitBattleAnimFrameset
ret
@@ -2456,7 +2464,7 @@ Functioncde02: ; cde02 (33:5e02)
ld hl, BATTLEANIMSTRUCT_0B
add hl, bc
ld a, [hl]
- add $63
+ add BATTLEANIMFRAMESET_63
call ReinitBattleAnimFrameset
ld hl, BATTLEANIMSTRUCT_0B
add hl, bc
@@ -2540,7 +2548,7 @@ Functioncde72: ; cde72 (33:5e72)
add hl, bc
set 6, [hl]
.asm_cde83
- add $6a
+ add BATTLEANIMFRAMESET_6A
call ReinitBattleAnimFrameset
Functioncde88: ; cde88 (33:5e88)
ret
@@ -2578,7 +2586,7 @@ Functioncde90: ; cde90 (33:5e90)
xor $ff
inc a
ld [hl], a
- ld a, $6e
+ ld a, BATTLEANIMFRAMESET_6E
call ReinitBattleAnimFrameset
ret
@@ -2606,7 +2614,7 @@ Functioncdebf: ; cdebf (33:5ebf)
ld [hl], a
ret
-BattleAnimFunction_29: ; cdedd (33:5edd)
+BattleAnimFunction_SpiralDescent: ; cdedd (33:5edd)
ld hl, BATTLEANIMSTRUCT_0F
add hl, bc
ld a, [hl]
@@ -2639,11 +2647,11 @@ BattleAnimFunction_29: ; cdedd (33:5edd)
add hl, bc
ld a, [hl]
cp $28
- jr nc, .asm_cdf17
+ jr nc, .delete
inc [hl]
ret
-.asm_cdf17
+.delete
call DeinitBattleAnimation
ret
@@ -2688,17 +2696,17 @@ BattleAnimFunction_2D: ; cdf1b (33:5f1b)
call DeinitBattleAnimation
ret
-BattleAnimFunction_2A: ; cdf59 (33:5f59)
+BattleAnimFunction_PoisonGas: ; cdf59 (33:5f59)
call BattleAnim_AnonJumptable
.anon_dw
dw Functioncdf60
- dw BattleAnimFunction_29
+ dw BattleAnimFunction_SpiralDescent
Functioncdf60: ; cdf60 (33:5f60)
ld hl, BATTLEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hl]
cp $84
- jr nc, .asm_cdf88
+ jr nc, .next
inc [hl]
ld hl, BATTLEANIMSTRUCT_0F
add hl, bc
@@ -2719,7 +2727,7 @@ Functioncdf60: ; cdf60 (33:5f60)
dec [hl]
ret
-.asm_cdf88
+.next
call BattleAnim_IncAnonJumptableIndex
ret
@@ -2865,14 +2873,14 @@ Functionce05f: ; ce05f (33:605f)
call DeinitBattleAnimation
ret
-BattleAnimFunction_2B: ; ce063 (33:6063)
+BattleAnimFunction_Horn: ; ce063 (33:6063)
call BattleAnim_AnonJumptable
.anon_dw
- dw Functionce06e
- dw Functionce083
- dw Functionce091
+ dw .zero
+ dw .one
+ dw .two
dw Functionce09e
-Functionce06e: ; ce06e (33:606e)
+.zero: ; ce06e (33:606e)
ld hl, BATTLEANIMSTRUCT_0B
add hl, bc
ld a, [hl]
@@ -2887,7 +2895,7 @@ Functionce06e: ; ce06e (33:606e)
ld [hl], a
ret
-Functionce083: ; ce083 (33:6083)
+.one: ; ce083 (33:6083)
ld hl, BATTLEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hl]
@@ -2897,7 +2905,7 @@ Functionce083: ; ce083 (33:6083)
call Functionce70a
ret
-Functionce091: ; ce091 (33:6091)
+.two: ; ce091 (33:6091)
ld hl, BATTLEANIMSTRUCT_10
add hl, bc
ld a, [hl]
@@ -3395,7 +3403,7 @@ Functionce366: ; ce366 (33:6366)
add hl, bc
ld a, [hl]
and $7f
- add $81
+ add BATTLEANIMFRAMESET_81
call ReinitBattleAnimFrameset
Functionce375: ; ce375 (33:6375)
ld hl, BATTLEANIMSTRUCT_0B
@@ -3437,7 +3445,7 @@ Functionce39c: ; ce39c (33:639c)
.asm_ce3a6
call BattleAnim_IncAnonJumptableIndex
- ld a, $20
+ ld a, BATTLEANIMFRAMESET_20
call ReinitBattleAnimFrameset
Functionce3ae: ; ce3ae (33:63ae)
ld hl, BATTLEANIMSTRUCT_YOFFSET
@@ -3611,7 +3619,7 @@ Functionce4a3: ; ce4a3 (33:64a3)
call BattleAnim_IncAnonJumptableIndex
ld hl, BATTLEANIMSTRUCT_0B
add hl, bc
- ld a, $24
+ ld a, BATTLEANIMFRAMESET_24
add [hl]
call ReinitBattleAnimFrameset
Functionce4b0: ; ce4b0 (33:64b0)
@@ -3832,13 +3840,14 @@ BattleAnimFunction_48: ; ce5dc (33:65dc)
add hl, bc
ld a, [hl]
cp $d0
- jr z, .asm_ce5ea
-rept 4
+ jr z, .disappear
+ dec [hl]
+ dec [hl]
+ dec [hl]
dec [hl]
-endr
ret
-.asm_ce5ea
+.disappear
call DeinitBattleAnimation
ret
@@ -3865,9 +3874,10 @@ Functionce60a: ; ce60a (33:660a)
ld a, [hl]
cp $4
jr z, Functionce618
-rept 4
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
+ inc [hl]
ret
Functionce618: ; ce618 (33:6618)
@@ -3883,9 +3893,10 @@ Functionce622: ; ce622 (33:6622)
ld a, [hl]
cp $d8
ret z
-rept 4
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
+ dec [hl]
ret
BattleAnimFunction_4A: ; ce62f (33:662f)
@@ -4085,6 +4096,7 @@ BattleAnim_IncAnonJumptableIndex: ; ce72c (33:672c)
BattleAnim_Cosine: ; ce732 (33:6732)
add $10
BattleAnim_Sine: ; ce734 (33:6734)
+; a = d sin a
and $3f
cp $20
jr nc, .negative
diff --git a/battle/sliding_intro.asm b/battle/sliding_intro.asm
index 194a4cd1b..ed78add8e 100755
--- a/battle/sliding_intro.asm
+++ b/battle/sliding_intro.asm
@@ -5,10 +5,10 @@ BattleIntroSlidingPics: ; 4e980
ld [rSVBK], a
call .subfunction1
ld a, rSCX - $ff00
- ld [hFFC6], a
+ ld [hLCDCPointer], a
call .subfunction2
xor a
- ld [hFFC6], a
+ ld [hLCDCPointer], a
pop af
ld [rSVBK], a
ret
@@ -39,12 +39,10 @@ BattleIntroSlidingPics: ; 4e980
ld a, d
ld [hSCX], a
call .subfunction5
-rept 2
inc e
-endr
-rept 2
+ inc e
+ dec d
dec d
-endr
pop af
push af
cp $1
@@ -66,9 +64,8 @@ endr
ld c, $12 ; 18
ld de, $4
.loop3
-rept 2
dec [hl]
-endr
+ dec [hl]
add hl, de
dec c
jr nz, .loop3
diff --git a/battle/trainer_huds.asm b/battle/trainer_huds.asm
index ad32df1cd..03a85b9f4 100755
--- a/battle/trainer_huds.asm
+++ b/battle/trainer_huds.asm
@@ -81,9 +81,9 @@ StageBallTilesData: ; 2c059
jr z, .fainted
.got_hp
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld a, [hl]
and a
ld b, $32 ; statused
@@ -92,9 +92,9 @@ endr
jr .load
.fainted
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
.load
ld a, b
@@ -260,7 +260,7 @@ _ShowLinkBattleParticipants: ; 2c1b2
ld [hli], a
ld [hl], $6a ; "S"
callba LinkBattle_TrainerHuds ; no need to callba
- ld b, SCGB_08
+ ld b, SCGB_DIPLOMA
call GetSGBLayout
call SetPalettes
ld a, $e4