ref: eb9fc6676cfed0460d19ce441134dbcdfce49b0d
parent: 560b892b2d24dc7d8766d59eb65337a07e7b3235
author: yenatch <[email protected]>
date: Fri Jun 13 17:18:14 EDT 2014
More battle code cleanup. - Use more substatus constants. - Reformat some code to be more atomic. - Add constants for unused status prevention held item effects. - Remove pointless or redundant comments.
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -24,7 +24,7 @@
.asm_3c021
ld a, d
- ld [$d430], a
+ ld [wBattleAction], a
ld a, [InLinkBattle]
and a
jr z, .asm_3c031
@@ -421,9 +421,9 @@
ret nz
xor a
ld [$cfca], a
- ld de, $0103
+ ld de, ANIM_CONFUSED
call Function3ee0f
- call Function3c8e4
+ call SwitchTurnCore
ld hl, BecameConfusedText
jp StdBattleTextBox
; 3c300
@@ -432,7 +432,7 @@
ld a, [InLinkBattle]
and a
jr z, .asm_3c30d
- ld a, [$d430]
+ ld a, [wBattleAction]
cp $f
jr z, .asm_3c30f
@@ -450,7 +450,7 @@
ld a, [InLinkBattle]
and a
jr z, .asm_3c35b
- ld a, [$d430]
+ ld a, [wBattleAction]
cp $e
jr z, .asm_3c35b
cp $d
@@ -496,10 +496,10 @@
callab GetOpponentItem
pop de
ld a, d
- cp $4a
+ cp HELD_QUICK_CLAW
jr nz, .asm_3c391
ld a, b
- cp $4a
+ cp HELD_QUICK_CLAW
jr z, .asm_3c39f
call BattleRandom
cp e
@@ -508,7 +508,7 @@
.asm_3c391
ld a, b
- cp $4a
+ cp HELD_QUICK_CLAW
jr nz, .asm_3c3c5
call BattleRandom
cp c
@@ -589,23 +589,22 @@
Function3c410: ; 3c410
ld a, [PlayerSubStatus4]
- and $20
- jp nz, Function3c432
+ and 1 << SUBSTATUS_RECHARGE
+ jp nz, .quit
ld hl, EnemySubStatus3
- res 3, [hl]
+ res SUBSTATUS_FLINCHED, [hl]
ld hl, PlayerSubStatus3
- res 3, [hl]
+ res SUBSTATUS_FLINCHED, [hl]
ld a, [hl]
- and $12
- jp nz, Function3c432
+ and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_ROLLOUT
+ jp nz, .quit
ld hl, PlayerSubStatus1
- bit 6, [hl]
- jp nz, Function3c432
+ bit SUBSTATUS_ENCORED, [hl]
+ jp nz, .quit
and a
ret
-; 3c432
-Function3c432: ; 3c432
+.quit
scf
ret
; 3c434
@@ -627,11 +626,11 @@
and a
jr nz, .asm_3c4b5
ld a, [PlayerSubStatus3]
- and $1
+ and 1 << SUBSTATUS_BIDE
jr nz, .asm_3c4ba
xor a
ld [$d235], a
- inc a
+ inc a ; POUND
ld [FXAnimIDLo], a
call Function3e4bc
push af
@@ -638,7 +637,7 @@
call Function30b4
call UpdateBattleHuds
ld a, [CurPlayerMove]
- cp $a5
+ cp STRUGGLE
jr z, .asm_3c476
call PlayClickSFX
@@ -680,7 +679,7 @@
.asm_3c4b5
ld hl, PlayerSubStatus3
- res 0, [hl]
+ res SUBSTATUS_BIDE, [hl]
.asm_3c4ba
xor a
@@ -688,7 +687,7 @@
ld [PlayerProtectCount], a
ld [$c72b], a
ld hl, PlayerSubStatus4
- res 6, [hl]
+ res SUBSTATUS_RAGE, [hl]
.asm_3c4c9
call Function3e7c1
@@ -701,7 +700,7 @@
ld [PlayerProtectCount], a
ld [$c72b], a
ld hl, PlayerSubStatus4
- res 6, [hl]
+ res SUBSTATUS_RAGE, [hl]
xor a
ret
; 3c4df
@@ -726,7 +725,7 @@
ld hl, BattleMonPP
ld a, [CurMoveNum]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
and $3f
@@ -750,7 +749,7 @@
ld hl, EnemyMonPP
ld a, [CurEnemyMoveNum]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
and $3f
@@ -771,7 +770,7 @@
jr nz, .Stay
ld a, [PlayerSubStatus5]
- bit 7, a
+ bit SUBSTATUS_CANT_RUN, a
jr nz, .Stay
ld a, [$c731]
@@ -1033,20 +1032,20 @@
; 3c6ed
Function3c6ed: ; 3c6ed
- ld a, $5
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
call _GetBattleVar
- res 2, [hl]
- res 5, [hl]
- ld a, $9
+ res SUBSTATUS_PROTECT, [hl]
+ res SUBSTATUS_ENDURE, [hl]
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
call _GetBattleVar
- res 6, [hl]
+ res SUBSTATUS_DESTINY_BOND, [hl]
ret
; 3c6fe
Function3c6fe: ; 3c6fe
- ld a, $4
+ ld a, BATTLE_VARS_SUBSTATUS5
call _GetBattleVar
- res 6, [hl]
+ res SUBSTATUS_DESTINY_BOND, [hl]
ret
; 3c706
@@ -1070,18 +1069,20 @@
Function3c716: ; 3c716
call Function3c706
ret z
- ld a, $a
+
+ ld a, BATTLE_VARS_STATUS
call GetBattleVar
- and $18
+ and 1 << PSN | 1 << BRN
jr z, .asm_3c768
+
ld hl, BattleText_0x807e2
- ld de, $0106
- and $10
+ ld de, ANIM_PSN
+ and 1 << BRN
jr z, .asm_3c733
ld hl, BattleText_0x807f8
- ld de, $0105
-
+ ld de, ANIM_BRN
.asm_3c733
+
push de
call StdBattleTextBox
pop de
@@ -1096,11 +1097,11 @@
ld de, $c67c
.asm_3c74d
- ld a, $4
+ ld a, BATTLE_VARS_SUBSTATUS5
call GetBattleVar
- bit 0, a
+ bit SUBSTATUS_TOXIC, a
jr z, .asm_3c765
- call Function3cc76
+ call GetSixteenthMaxHP
ld a, [de]
inc a
ld [de], a
@@ -1118,19 +1119,22 @@
.asm_3c768
call Function3c706
jp z, .asm_3c7f7
- ld a, $3
+
+ ld a, BATTLE_VARS_SUBSTATUS4
call _GetBattleVar
- bit 7, [hl]
+ bit SUBSTATUS_LEECH_SEED, [hl]
jr z, .asm_3c7a1
- call Function3c8e4
+
+ call SwitchTurnCore
xor a
ld [$cfca], a
- ld de, $0107
- ld a, $7
+ ld de, ANIM_SAP
+ ld a, BATTLE_VARS_SUBSTATUS3_OPP
call GetBattleVar
- and $60
+ and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
call z, Function3ee0f
- call Function3c8e4
+ call SwitchTurnCore
+
call GetEighthMaxHP
call Function3cc3f
ld a, $1
@@ -1142,13 +1146,15 @@
.asm_3c7a1
call Function3c706
jr z, .asm_3c7f7
- ld a, $0
+
+ ld a, BATTLE_VARS_SUBSTATUS1
call _GetBattleVar
- bit 0, [hl]
+ bit SUBSTATUS_NIGHTMARE, [hl]
jr z, .asm_3c7c5
+
xor a
ld [$cfca], a
- ld de, $010c
+ ld de, ANIM_IN_NIGHTMARE
call Function3ee0f
call GetQuarterMaxHP
call Function3cc3f
@@ -1158,13 +1164,15 @@
.asm_3c7c5
call Function3c706
jr z, .asm_3c7f7
- ld a, $0
+
+ ld a, BATTLE_VARS_SUBSTATUS1
call _GetBattleVar
- bit 1, [hl]
+ bit SUBSTATUS_CURSE, [hl]
jr z, .asm_3c7e9
+
xor a
ld [$cfca], a
- ld de, $010c
+ ld de, ANIM_IN_NIGHTMARE
call Function3ee0f
call GetQuarterMaxHP
call Function3cc3f
@@ -1185,7 +1193,7 @@
.asm_3c7f7
call RefreshBattleHuds
- ld c, $14
+ ld c, 20
call DelayFrames
xor a
ret
@@ -1212,9 +1220,9 @@
ld hl, EnemyPerishCount
.asm_3c827
- ld a, $0
+ ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVar
- bit 4, a
+ bit SUBSTATUS_PERISH, a
ret z
dec [hl]
ld a, [hl]
@@ -1224,9 +1232,9 @@
call StdBattleTextBox
pop af
ret nz
- ld a, $0
+ ld a, BATTLE_VARS_SUBSTATUS1
call _GetBattleVar
- res 4, [hl]
+ res SUBSTATUS_PERISH, [hl]
ld a, [hBattleTurn]
and a
jr nz, .asm_3c85c
@@ -1285,9 +1293,9 @@
ld a, [hl]
and a
ret z
- ld a, $3
+ ld a, BATTLE_VARS_SUBSTATUS4
call GetBattleVar
- bit 4, a
+ bit SUBSTATUS_SUBSTITUTE, a
ret nz
ld a, [de]
ld [$d265], a
@@ -1295,20 +1303,20 @@
call GetMoveName
dec [hl]
jr z, .asm_3c8de
- ld a, $2
+ ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVar
- and $60
+ and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
jr nz, .asm_3c8d3
- call Function3c8e4
+ call SwitchTurnCore
xor a
ld [$cfca], a
ld [FXAnimIDHi], a
ld a, $37
call Predef
- call Function3c8e4
+ call SwitchTurnCore
.asm_3c8d3
- call Function3cc76
+ call GetSixteenthMaxHP
call Function3cc3f
ld hl, BattleText_0x80de2
jr .asm_3c8e1
@@ -1320,9 +1328,9 @@
jp StdBattleTextBox
; 3c8e4
-Function3c8e4: ; 3c8e4
+SwitchTurnCore: ; 3c8e4
ld a, [hBattleTurn]
- xor $1
+ xor 1
ld [hBattleTurn], a
ret
; 3c8eb
@@ -1367,8 +1375,8 @@
ret z
.asm_3c92d
- call Function3cc76
- call Function3c8e4
+ call GetSixteenthMaxHP
+ call SwitchTurnCore
call Function3ccef
ld hl, BattleText_0x80880
jp StdBattleTextBox
@@ -1481,7 +1489,7 @@
ld a, [EnemySubStatus5]
.asm_3c9ee
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
jr nz, .asm_3c9f5
ld a, [de]
add b
@@ -1508,9 +1516,9 @@
.asm_3ca14
call GetItemName
- call Function3c8e4
+ call SwitchTurnCore
call Function3ddc8
- call Function3c8e4
+ call SwitchTurnCore
ld hl, BattleText_0x80899
jp StdBattleTextBox
; 3ca26
@@ -1740,37 +1748,37 @@
; 3cb9e
HandleWeather: ; 3cb9e
-
ld a, [Weather]
- cp 0
+ cp WEATHER_NONE
ret z
ld hl, WeatherCount
dec [hl]
- jr z, .asm_3cc13
+ jr z, .ended
ld hl, .WeatherMessages
- call .asm_3cc1e
+ call .PrintWeatherMessage
+
ld a, [Weather]
cp WEATHER_SANDSTORM
ret nz
+
ld a, [$ffcb]
cp 1
- jr z, .asm_3cbc7
+ jr z, .enemy_first
-; Player first
+.player_first
call SetPlayerTurn
- call .asm_3cbd0
+ call .SandstormDamage
call SetEnemyTurn
- jr .asm_3cbd0
+ jr .SandstormDamage
-.asm_3cbc7
-; Enemy first
+.enemy_first
call SetEnemyTurn
- call .asm_3cbd0
+ call .SandstormDamage
call SetPlayerTurn
-.asm_3cbd0
+.SandstormDamage
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVar
bit SUBSTATUS_UNDERGROUND, a
@@ -1779,10 +1787,9 @@
ld hl, BattleMonType1
ld a, [hBattleTurn]
and a
- jr z, .asm_3cbe3
+ jr z, .ok
ld hl, EnemyMonType1
-
-.asm_3cbe3
+.ok
ld a, [hli]
cp ROCK
ret z
@@ -1799,12 +1806,12 @@
cp STEEL
ret z
- call Function3c8e4
+ call SwitchTurnCore
xor a
ld [$cfca], a
- ld de, $010b
+ ld de, ANIM_IN_SANDSTORM
call Function3ee17
- call Function3c8e4
+ call SwitchTurnCore
call GetEighthMaxHP
call Function3cc3f
@@ -1811,14 +1818,14 @@
ld hl, BattleText_0x8084d
jp StdBattleTextBox
-.asm_3cc13
+.ended
ld hl, .WeatherEndedMessages
- call .asm_3cc1e
+ call .PrintWeatherMessage
xor a
ld [Weather], a
ret
-.asm_3cc1e
+.PrintWeatherMessage
ld a, [Weather]
dec a
ld c, a
@@ -1852,15 +1859,13 @@
; 3cc45
-
Function3cc45: ; 3cc45
ld hl, BattleMonHP
ld a, [hBattleTurn]
and a
- jr z, .asm_3cc50
+ jr z, .ok
ld hl, EnemyMonHP
-
-.asm_3cc50
+.ok
inc hl
ld a, [hl]
ld [$d1ec], a
@@ -1885,16 +1890,17 @@
ret
; 3cc76
-Function3cc76: ; 3cc76
+GetSixteenthMaxHP: ; 3cc76
call GetQuarterMaxHP
+ ; quarter result
srl c
srl c
+ ; round up
ld a, c
and a
- jr nz, .asm_3cc82
+ jr nz, .ok
inc c
-
-.asm_3cc82
+.ok
ret
; 3cc83
@@ -1940,7 +1946,7 @@
; output: bc
call GetMaxHP
-; halve reslut
+; halve result
srl b
rr c
@@ -1957,18 +1963,12 @@
GetMaxHP: ; 3ccac
; output: bc, Buffer1-2
-; player
ld hl, BattleMonMaxHP
-
-; whose turn?
ld a, [hBattleTurn]
and a
- jr z, .gethp
-
-; enemy
+ jr z, .ok
ld hl, EnemyMonMaxHP
-
-.gethp
+.ok
ld a, [hli]
ld [Buffer2], a
ld b, a
@@ -1983,10 +1983,9 @@
ld hl, BattleMonHP
ld a, [hBattleTurn]
and a
- jr z, .asm_3cccd
+ jr z, .ok
ld hl, EnemyMonHP
-
-.asm_3cccd
+.ok
ld a, [hli]
ld b, a
ld a, [hli]
@@ -2004,10 +2003,9 @@
ld hl, BattleMonHP + 1
ld a, [hBattleTurn]
and a
- jr z, .asm_3cce9
+ jr z, .ok
ld hl, EnemyMonHP + 1
-
-.asm_3cce9
+.ok
ld a, c
sub [hl]
dec hl
@@ -2021,10 +2019,9 @@
ld hl, EnemyMonMaxHP
ld a, [hBattleTurn]
and a
- jr z, .asm_3ccfa
+ jr z, .ok
ld hl, BattleMonMaxHP
-
-.asm_3ccfa
+.ok
ld a, [hli]
ld [Buffer2], a
ld a, [hld]
@@ -2040,6 +2037,7 @@
adc b
ld [hli], a
ld [$d1ef], a
+
ld a, [Buffer1]
ld c, a
ld a, [hld]
@@ -2055,11 +2053,11 @@
ld a, c
ld [hl], a
ld [$d1ee], a
-
.asm_3cd2d
- call Function3c8e4
+
+ call SwitchTurnCore
call Function3cd36
- jp Function3c8e4
+ jp SwitchTurnCore
; 3cd36
Function3cd36: ; 3cd36
@@ -2072,7 +2070,7 @@
hlcoord 10, 9
ld a, [hBattleTurn]
and a
- ld a, $1
+ ld a, 1
jr z, .asm_3cd4a
hlcoord 2, 2
xor a
@@ -2099,18 +2097,22 @@
ld a, d
and a
jp z, LostBattle
+
ld hl, BattleMonHP
ld a, [hli]
or [hl]
call nz, Function3df48
+
ld a, $1
ld [hBGMapMode], a
ld c, 60
call DelayFrames
+
ld a, [IsInBattle]
dec a
jr nz, .asm_3cd8c
- ld a, $1
+
+ ld a, 1
ld [BattleEnded], a
ret
@@ -2117,13 +2119,16 @@
.asm_3cd8c
call Function3cf35
jp z, Function3cfa4
+
ld hl, BattleMonHP
ld a, [hli]
or [hl]
jr nz, .asm_3cdba
+
call Function3d1f8
jr nc, .asm_3cda4
- ld a, $1
+
+ ld a, 1
ld [BattleEnded], a
ret
@@ -2131,6 +2136,7 @@
call Function3d227
call Function3d2e0
jp c, Function3c0e5
+
ld a, $1
ld [$d0ec], a
call Function3cf4a
@@ -2387,7 +2393,7 @@
and a
jr z, .asm_3cf6d
call Function3e8e4
- ld a, [$d430]
+ ld a, [wBattleAction]
cp $f
ret z
call Function30b4
@@ -2483,7 +2489,7 @@
ld c, $3
callba Function11c000
call Functiona80
- ld hl, $c6ec
+ ld hl, wPayDayMoney
ld a, [hli]
or [hl]
inc hl
@@ -2651,7 +2657,7 @@
call Function3ceaa
pop de
jr nz, .asm_3d11e
- ld hl, $c6ec
+ ld hl, wPayDayMoney
ld a, [hli]
or [hl]
jr nz, .asm_3d11e
@@ -3212,7 +3218,7 @@
Function3d490: ; 3d490
- ld [hConnectionStripLength], a
+ ld [$ffaf], a
ld c, a
.asm_3d493
push bc
@@ -3222,7 +3228,7 @@
push hl
call Function3d4ae
pop hl
- ld de, 20
+ ld de, SCREEN_WIDTH
add hl, de
dec b
jr nz, .asm_3d497
@@ -3236,24 +3242,24 @@
; 3d4ae
Function3d4ae: ; 3d4ae
- ld a, [hConnectionStripLength]
+ ld a, [$ffaf]
ld c, a
cp $8
- jr nz, .asm_3d4bc
-.asm_3d4b5
+ jr nz, .back
+.forward
ld a, [hli]
ld [hld], a
dec hl
dec c
- jr nz, .asm_3d4b5
+ jr nz, .forward
ret
-.asm_3d4bc
+.back
ld a, [hld]
ld [hli], a
inc hl
dec c
- jr nz, .asm_3d4bc
+ jr nz, .back
ret
; 3d4c3
@@ -3320,7 +3326,7 @@
ld a, [InLinkBattle]
and a
jr z, .asm_3d541
- ld a, [$d430]
+ ld a, [wBattleAction]
sub NUM_MOVES
ld b, a
jr .asm_3d555
@@ -3868,7 +3874,7 @@
ld b, a
callab GetItem
ld a, b
- cp $48
+ cp HELD_ESCAPE
pop de
pop hl
jr nz, .asm_3d916
@@ -3977,8 +3983,8 @@
call Function3d2e0
jr c, .asm_3d9f5
-; Got away safely
- ld a, [$d430]
+ ; Got away safely
+ ld a, [wBattleAction]
cp $f
ld a, $2
jr z, .asm_3d9cf
@@ -4076,7 +4082,7 @@
Function3da85: ; 3da85
ld hl, BattleMonDVs
ld a, [PlayerSubStatus5]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
ret z
ld hl, PartyMon1DVs
ld a, [CurBattleMon]
@@ -4086,7 +4092,7 @@
Function3da97: ; 3da97
ld hl, EnemyMonDVs
ld a, [EnemySubStatus5]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
ret z
ld hl, $c6f2
ld a, [IsInBattle]
@@ -4205,7 +4211,7 @@
ld [LastEnemyCounterMove], a
ld [LastPlayerCounterMove], a
ld [LastPlayerMove], a
- call Function3e4a8
+ call CheckAmuletCoin
call Function3ee27
xor a
ld [$c731], a
@@ -4213,13 +4219,13 @@
xor a
ld [$cfca], a
ld [$c689], a
- ld de, $0101
+ ld de, ANIM_SEND_OUT_MON
call Function3ee17
call Function3da74
jr nc, .asm_3dbbc
ld a, $1
ld [$c689], a
- ld de, $0101
+ ld de, ANIM_SEND_OUT_MON
call Function3ee17
.asm_3dbbc
@@ -4407,7 +4413,7 @@
xor a
ld [hBattleTurn], a
ld [$cfca], a
- ld de, $0102
+ ld de, ANIM_RETURN_MON
call Function3ee17
pop af
ld [hBattleTurn], a
@@ -4536,15 +4542,15 @@
push de
push bc
call EmptyBattleTextBox
- ld a, $69
+ ld a, RECOVER
ld [FXAnimIDLo], a
- call Function3c8e4
+ call SwitchTurnCore
xor a
ld [$cfca], a
ld [FXAnimIDHi], a
ld a, $37
call Predef
- call Function3c8e4
+ call SwitchTurnCore
pop bc
pop de
pop hl
@@ -4563,7 +4569,7 @@
jr nz, .asm_3ddf2
dec hl
ld b, [hl]
- ld a, $b
+ ld a, BATTLE_VARS_STATUS_OPP
call _GetBattleVar
and b
ret z
@@ -4572,20 +4578,20 @@
push bc
call UpdateOpponentInParty
pop bc
- ld a, $9
+ ld a, BATTLE_VARS_SUBSTATUS5_OPP
call _GetBattleVar
and [hl]
- res 0, [hl]
- ld a, $5
+ res SUBSTATUS_TOXIC, [hl]
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
call _GetBattleVar
and [hl]
- res 0, [hl]
+ res SUBSTATUS_NIGHTMARE, [hl]
ld a, b
cp $7f
jr nz, .asm_3de26
- ld a, $7
+ ld a, BATTLE_VARS_SUBSTATUS3_OPP
call _GetBattleVar
- res 7, [hl]
+ res SUBSTATUS_CONFUSED, [hl]
.asm_3de26
ld hl, Function365fd
@@ -4595,10 +4601,10 @@
ld hl, Function365d7
.asm_3de31
- call Function3c8e4
+ call SwitchTurnCore
ld a, BANK(Function365fd)
rst FarCall
- call Function3c8e4
+ call SwitchTurnCore
call Function3ddc8
call Function3ddac
ld a, $1
@@ -4618,23 +4624,23 @@
Function3de51: ; 3de51
- ld a, $7
+ ld a, BATTLE_VARS_SUBSTATUS3_OPP
call GetBattleVar
- bit 7, a
+ bit SUBSTATUS_CONFUSED, a
ret z
callab GetOpponentItem
ld a, b
- cp $10
+ cp HELD_HEAL_CONFUSION
jr z, .asm_3de67
- cp $f
+ cp HELD_HEAL_STATUS
ret nz
.asm_3de67
ld a, [hl]
ld [$d265], a
- ld a, $7
+ ld a, BATTLE_VARS_SUBSTATUS3_OPP
call _GetBattleVar
- res 7, [hl]
+ res SUBSTATUS_CONFUSED, [hl]
call GetItemName
call Function3ddc8
ld hl, BattleText_0x80dab
@@ -4730,13 +4736,13 @@
; 3defc
.data_3defc
- dbw $1f, BattleCommand70
- dbw $20, BattleCommand71
- dbw $21, BattleCommand72
- dbw $22, BattleCommand73
- dbw $23, BattleCommand74
- dbw $24, BattleCommand75
- dbw $25, BattleCommand76
+ dbw HELD_ATTACK_UP, BattleCommand70
+ dbw HELD_DEFENSE_UP, BattleCommand71
+ dbw HELD_SPEED_UP, BattleCommand72
+ dbw HELD_SP_ATTACK_UP, BattleCommand73
+ dbw HELD_SP_DEFENSE_UP, BattleCommand74
+ dbw HELD_ACCURACY_UP, BattleCommand75
+ dbw HELD_EVASION_UP, BattleCommand76
db $ff
; 3df12
@@ -4793,9 +4799,9 @@
xor a
ld [hBGMapMode], a
-; Clear the area
+ ; Clear the area
hlcoord 9, 7
- ld bc, $050b
+ lb bc, 5, 11
call ClearBox
callba DrawPlayerExpBar
@@ -4804,7 +4810,7 @@
ld [hl], $73 ; vertical bar
call PrintPlayerHUD
-; HP bar
+ ; HP bar
hlcoord 10, 9
ld b, OTPARTYMON
xor a
@@ -4812,7 +4818,7 @@
ld a, PREDEF_DRAW_PLAYER_HP
call Predef
-; Exp bar
+ ; Exp bar
push de
ld a, [CurBattleMon]
ld hl, PartyMon1Exp + 2
@@ -4837,24 +4843,24 @@
ld hl, BattleMonHP
ld a, [hli]
or [hl]
- jr z, .asm_3dfb2
+ jr z, .no_danger
ld a, [$c6fd]
and a
- jr nz, .asm_3dfbe
+ jr nz, .done
ld a, [PlayerHPPal]
cp $2
- jr z, .asm_3dfb9
+ jr z, .danger
-.asm_3dfb2
+.no_danger
ld hl, Danger
res 7, [hl]
- jr .asm_3dfbe
+ jr .done
-.asm_3dfb9
+.danger
ld hl, Danger
set 7, [hl]
-.asm_3dfbe
+.done
ret
; 3dfbf
@@ -4893,11 +4899,11 @@
ld a, $3
ld [MonType], a
callab GetGender
- ld a, $7f
+ ld a, " "
jr c, .asm_3e013
- ld a, $ef
+ ld a, "♂"
jr nz, .asm_3e013
- ld a, $f5
+ ld a, "♀"
.asm_3e013
hlcoord 17, 8
@@ -4938,7 +4944,7 @@
xor a
ld [hBGMapMode], a
hlcoord 1, 0
- ld bc, $040b
+ lb bc, 4, 11
call ClearBox
callba Function2c0c5
ld a, [TempEnemyMonSpecies]
@@ -4955,10 +4961,9 @@
ld hl, EnemyMonDVs
ld de, TempMonDVs
ld a, [EnemySubStatus5]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
jr z, .asm_3e080
ld hl, $c6f2
-
.asm_3e080
ld a, [hli]
ld [de], a
@@ -4968,11 +4973,11 @@
ld a, $3
ld [MonType], a
callab GetGender
- ld a, $7f
+ ld a, " "
jr c, .asm_3e09a
- ld a, $ef
+ ld a, "♂"
jr nz, .asm_3e09a
- ld a, $f5
+ ld a, "♀"
.asm_3e09a
hlcoord 9, 1
@@ -5006,13 +5011,13 @@
jr nz, .asm_3e0d1
ld c, a
ld e, a
- ld d, $6
+ ld d, HP_BAR_LENGTH
jp .asm_3e11a
.asm_3e0d1
xor a
ld [hMultiplicand], a
- ld a, $30
+ ld a, HP_BAR_LENGTH_PX
ld [hMultiplier], a
call Multiply
ld hl, EnemyMonMaxHP
@@ -5050,7 +5055,7 @@
call Divide
ld a, [$ffb6]
ld e, a
- ld a, $6
+ ld a, HP_BAR_LENGTH
ld d, a
ld c, a
.asm_3e11a
@@ -5180,13 +5185,13 @@
.asm_3e1f1
callba Function107bb
- ld a, $5
+ ld a, POKE_BALL
ld [CurItem], a
call DoItemEffect
jr .asm_3e209
.asm_3e201
- ld a, $b1
+ ld a, PARK_BALL
ld [CurItem], a
call DoItemEffect
@@ -5365,7 +5370,7 @@
and a
jr nz, .asm_3e378
ld a, [EnemySubStatus5]
- bit 7, a
+ bit SUBSTATUS_CANT_RUN, a
jr z, .asm_3e381
.asm_3e378
@@ -5414,7 +5419,7 @@
ret
.asm_3e3cf
- ld a, [$d430]
+ ld a, [wBattleAction]
cp $e
jp z, .asm_3e3ca
cp $d
@@ -5527,14 +5532,14 @@
-Function3e4a8: ; 3e4a8
+CheckAmuletCoin: ; 3e4a8
ld a, [BattleMonItem]
ld b, a
callab GetItem
ld a, b
- cp $4c
+ cp HELD_AMULET_COIN
ret nz
- ld a, $1
+ ld a, 1
ld [$c73d], a
ret
; 3e4bc
@@ -5805,7 +5810,7 @@
.asm_3e682
ld a, [PlayerSubStatus5]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
jr nz, .asm_3e69e
ld hl, PartyMon1Moves
ld a, [CurBattleMon]
@@ -5813,7 +5818,7 @@
push hl
call .asm_3e6a5
pop hl
- ld bc, $0015
+ ld bc, PartyMon1PP - PartyMon1Moves
add hl, bc
call .asm_3e6a5
@@ -6015,7 +6020,7 @@
and a
call z, Function3e8e4
call Function30b4
- ld a, [$d430]
+ ld a, [wBattleAction]
cp $e
jp z, .asm_3e8bd
cp $d
@@ -6268,9 +6273,8 @@
and a
jr z, .InitDVs
-; ????
ld a, [EnemySubStatus5]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
jr z, .InitDVs
; Unknown
@@ -6478,15 +6482,14 @@
and a
jr z, .TreeMon
-; ????
ld a, [EnemySubStatus5]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
jp nz, .Moves
.TreeMon
; If we're headbutting trees, some monsters enter battle asleep
call CheckSleepingTreeMon
- ld a, 7 ; Asleep for 7 turns
+ ld a, SLP ; Asleep for 7 turns
jr c, .UpdateStatus
; Otherwise, no status
xor a
@@ -7588,7 +7591,7 @@
ld a, [hl]
ld [BattleMonLevel], a
ld a, [PlayerSubStatus5]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
jr nz, .asm_3f012
ld hl, $0026
add hl, bc
@@ -8687,7 +8690,7 @@
; 3f71d
Function3f71d: ; 3f71d
- ld hl, $c6ec
+ ld hl, wPayDayMoney
ld a, [hli]
or [hl]
inc hl
@@ -8696,7 +8699,7 @@
ld a, [$c73d]
and a
jr z, .asm_3f73d
- ld hl, $c6ee
+ ld hl, wPayDayMoney + 2
sla [hl]
dec hl
rl [hl]
@@ -8709,7 +8712,7 @@
ld [hl], a
.asm_3f73d
- ld hl, $c6ee
+ ld hl, wPayDayMoney + 2
ld de, Money + 2
call Function3d0be
ld hl, BattleText_0x80730
@@ -9426,7 +9429,7 @@
Function3fc5b: ; 3fc5b
ld hl, Sprites
xor a
- ld [hConnectionStripLength], a
+ ld [$ffaf], a
ld b, $6
ld e, $a8
.asm_3fc65
@@ -9437,10 +9440,10 @@
inc hl
ld [hl], e
inc hl
- ld a, [hConnectionStripLength]
+ ld a, [$ffaf]
ld [hli], a
inc a
- ld [hConnectionStripLength], a
+ ld [$ffaf], a
ld a, $1
ld [hli], a
ld a, d
@@ -9448,9 +9451,9 @@
ld d, a
dec c
jr nz, .asm_3fc69
- ld a, [hConnectionStripLength]
+ ld a, [$ffaf]
add $3
- ld [hConnectionStripLength], a
+ ld [$ffaf], a
ld a, e
add $8
ld e, a
@@ -9487,7 +9490,7 @@
ld [hBattleTurn], a
ld a, 1
ld [$c689], a
- ld de, $0101
+ ld de, ANIM_SEND_OUT_MON
call Function3ee17
.asm_3fcc2
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -16,10 +16,10 @@
and a
jr z, DoTurn
- ld a, [$d430]
+ ld a, [wBattleAction]
cp $e
jr z, DoTurn
- cp $4
+ cp NUM_MOVES
ret nc
; fallthrough
@@ -32,7 +32,7 @@
xor a
ld [$c6b4], a
-; Effect command checkturn is called for every move.
+ ; Effect command checkturn is called for every move.
call CheckTurn
ld a, [$c6b4]
@@ -146,41 +146,38 @@
CheckPlayerTurn:
-; check recharge
ld hl, PlayerSubStatus4
- bit 5, [hl]
- jr z, .CheckSleep
- res 5, [hl]
+ bit SUBSTATUS_RECHARGE, [hl]
+ jr z, .no_recharge
-; 'must recharge!'
+ res SUBSTATUS_RECHARGE, [hl]
ld hl, MustRechargeText
call StdBattleTextBox
-
call CantMove
jp Function34385
+.no_recharge
-.CheckSleep
+
ld hl, BattleMonStatus
ld a, [hl]
- and $7
- jr z, .CheckFrozen
+ and SLP
+ jr z, .not_asleep
+
dec a
ld [BattleMonStatus], a
- and $7
- jr z, .WokeUp
+ and SLP
+ jr z, .woke_up
+
xor a
ld [$cfca], a
ld de, ANIM_SLP
call FarPlayBattleAnimation
- jr .FastAsleep
+ jr .fast_asleep
-
-.WokeUp
-; 'woke up!'
+.woke_up
ld hl, WokeUpText
call StdBattleTextBox
-
call CantMove
call UpdateBattleMonInParty
ld hl, Function3df48
@@ -188,38 +185,37 @@
ld a, $1
ld [$ffd4], a
ld hl, PlayerSubStatus1
- res 0, [hl]
- jr .CheckFrozen
+ res SUBSTATUS_NIGHTMARE, [hl]
+ jr .not_asleep
-
-.FastAsleep
-; 'fast asleep!'
+.fast_asleep
ld hl, FastAsleepText
call StdBattleTextBox
-; Snore and Sleep Talk bypass sleep.
+ ; Snore and Sleep Talk bypass sleep.
ld a, [CurPlayerMove]
cp SNORE
- jr z, .CheckFrozen
+ jr z, .not_asleep
cp SLEEP_TALK
- jr z, .CheckFrozen
+ jr z, .not_asleep
+
call CantMove
jp Function34385
+.not_asleep
-.CheckFrozen
+
ld hl, BattleMonStatus
- bit 5, [hl]
- jr z, .CheckFlinch
+ bit FRZ, [hl]
+ jr z, .not_frozen
-; Flame Wheel and Sacred Fire thaw the user.
+ ; Flame Wheel and Sacred Fire thaw the user.
ld a, [CurPlayerMove]
cp FLAME_WHEEL
- jr z, .CheckFlinch
+ jr z, .not_frozen
cp SACRED_FIRE
- jr z, .CheckFlinch
+ jr z, .not_frozen
-; 'frozen solid!'
ld hl, FrozenSolidText
call StdBattleTextBox
@@ -226,15 +222,14 @@
call CantMove
jp Function34385
+.not_frozen
-.CheckFlinch
+
ld hl, PlayerSubStatus3
- bit 3, [hl] ; flinch
- jr z, .CheckDisabled
+ bit SUBSTATUS_FLINCHED, [hl]
+ jr z, .not_flinched
- res 3, [hl]
-
-; 'flinched!'
+ res SUBSTATUS_FLINCHED, [hl]
ld hl, FlinchedText
call StdBattleTextBox
@@ -241,123 +236,116 @@
call CantMove
jp Function34385
+.not_flinched
-.CheckDisabled
+
ld hl, PlayerDisableCount
ld a, [hl]
and a
- jr z, .CheckConfused
+ jr z, .not_disabled
+
dec a
ld [hl], a
and $f
- jr nz, .CheckConfused
+ jr nz, .not_disabled
+
ld [hl], a
ld [DisabledMove], a
-
-; 'disabled no more!'
ld hl, DisabledNoMoreText
call StdBattleTextBox
+.not_disabled
-.CheckConfused
+
ld a, [PlayerSubStatus3]
add a
- jr nc, .CheckAttract
+ jr nc, .not_confused
ld hl, PlayerConfuseCount
dec [hl]
- jr nz, .Confused
+ jr nz, .confused
ld hl, PlayerSubStatus3
- res 7, [hl]
-
-; 'confused no more!'
+ res SUBSTATUS_CONFUSED, [hl]
ld hl, ConfusedNoMoreText
call StdBattleTextBox
+ jr .not_confused
- jr .CheckAttract
-
-
-.Confused
-; 'confused!'
+.confused
ld hl, IsConfusedText
call StdBattleTextBox
-
xor a
ld [$cfca], a
ld de, ANIM_CONFUSED
call FarPlayBattleAnimation
-; 50% chance of hitting itself
+ ; 50% chance of hitting itself
call BattleRandom
cp $80
- jr nc, .CheckAttract
+ jr nc, .not_confused
+ ; clear confussion-dependent substatus
ld hl, PlayerSubStatus3
ld a, [hl]
- and $80
+ and 1 << SUBSTATUS_CONFUSED
ld [hl], a
call HitConfusion
-
call CantMove
jp Function34385
+.not_confused
-.CheckAttract
+
ld a, [PlayerSubStatus1]
- add a ; check bit 7
- jr nc, .CheckDisabledMove
+ add a ; bit SUBSTATUS_ATTRACT
+ jr nc, .not_infatuated
-; 'in love with'
ld hl, InLoveWithText
call StdBattleTextBox
-
xor a
ld [$cfca], a
-
ld de, ANIM_IN_LOVE
call FarPlayBattleAnimation
-; 50% chance of infatuation
+ ; 50% chance of infatuation
call BattleRandom
cp $80
- jr c, .CheckDisabledMove
+ jr c, .not_infatuated
-; 'infatuation kept it from attacking!'
ld hl, InfatuationText
call StdBattleTextBox
-
call CantMove
jp Function34385
+.not_infatuated
-.CheckDisabledMove
-; We can't disable a move that doesn't exist.
+
+ ; We can't disable a move that doesn't exist.
ld a, [DisabledMove]
and a
- jr z, .CheckParalyzed
+ jr z, .no_disabled_move
-; Are we using the disabled move?
+ ; Are we using the disabled move?
ld hl, CurPlayerMove
cp [hl]
- jr nz, .CheckParalyzed
+ jr nz, .no_disabled_move
call MoveDisabled
call CantMove
jp Function34385
+.no_disabled_move
-.CheckParalyzed
+
ld hl, BattleMonStatus
- bit 6, [hl]
+ bit PAR, [hl]
ret z
-; 25% chance to be fully paralyzed
+ ; 25% chance to be fully paralyzed
call BattleRandom
cp $3f
ret nc
-; 'fully paralyzed!'
ld hl, FullyParalyzedText
call StdBattleTextBox
call CantMove
@@ -368,12 +356,12 @@
CantMove: ; 341f0
ld a, BATTLE_VARS_SUBSTATUS1
call _GetBattleVar
- res 6, [hl]
+ res SUBSTATUS_ENCORED, [hl]
ld a, BATTLE_VARS_SUBSTATUS3
call _GetBattleVar
ld a, [hl]
- and $ec
+ and $ff ^ (1<<SUBSTATUS_BIDE + 1<<SUBSTATUS_ROLLOUT + 1<<SUBSTATUS_CHARGED)
ld [hl], a
call ResetFuryCutterCount
@@ -383,12 +371,12 @@
cp FLY
jr z, .asm_3420f
- cp $5b
+ cp DIG
ret nz
.asm_3420f
- res 5, [hl]
- res 6, [hl]
+ res SUBSTATUS_UNDERGROUND, [hl]
+ res SUBSTATUS_FLYING, [hl]
jp Function37ece
; 34216
@@ -404,30 +392,29 @@
CheckEnemyTurn: ; 3421f
-; check recharge
ld hl, EnemySubStatus4
- bit 5, [hl]
- jr z, .CheckSleep
- res 5, [hl]
+ bit SUBSTATUS_RECHARGE, [hl]
+ jr z, .no_recharge
-; 'must recharge!'
+ res SUBSTATUS_RECHARGE, [hl]
ld hl, MustRechargeText
call StdBattleTextBox
call CantMove
jp Function34385
+.no_recharge
-.CheckSleep
+
ld hl, EnemyMonStatus
ld a, [hl]
- and $7
- jr z, .CheckFrozen
+ and SLP
+ jr z, .not_asleep
+
dec a
ld [EnemyMonStatus], a
and a
- jr z, .WokeUp
+ jr z, .woke_up
-; 'fast asleep!'
ld hl, FastAsleepText
call StdBattleTextBox
xor a
@@ -434,11 +421,9 @@
ld [$cfca], a
ld de, ANIM_SLP
call FarPlayBattleAnimation
- jr .FastAsleep
+ jr .fast_asleep
-
-.WokeUp
-; 'woke up!'
+.woke_up
ld hl, WokeUpText
call StdBattleTextBox
call CantMove
@@ -448,46 +433,44 @@
ld a, $1
ld [$ffd4], a
ld hl, EnemySubStatus1
- res 0, [hl]
- jr .CheckFrozen
+ res SUBSTATUS_NIGHTMARE, [hl]
+ jr .not_asleep
-
-.FastAsleep
-; Snore and Sleep Talk bypass sleep.
+.fast_asleep
+ ; Snore and Sleep Talk bypass sleep.
ld a, [CurEnemyMove]
cp SNORE
- jr z, .CheckFrozen
+ jr z, .not_asleep
cp SLEEP_TALK
- jr z, .CheckFrozen
+ jr z, .not_asleep
call CantMove
jp Function34385
+.not_asleep
-.CheckFrozen
+
ld hl, EnemyMonStatus
- bit 5, [hl]
- jr z, .CheckFlinch
+ bit FRZ, [hl]
+ jr z, .not_frozen
ld a, [CurEnemyMove]
- cp $ac
- jr z, .CheckFlinch
- cp $dd
- jr z, .CheckFlinch
+ cp FLAME_WHEEL
+ jr z, .not_frozen
+ cp SACRED_FIRE
+ jr z, .not_frozen
-; 'frozen solid!'
ld hl, FrozenSolidText
call StdBattleTextBox
call CantMove
jp Function34385
+.not_frozen
-.CheckFlinch
+
ld hl, EnemySubStatus3
- bit 3, [hl]
- jr z, .CheckDisabled
+ bit SUBSTATUS_FLINCHED, [hl]
+ jr z, .not_flinched
- res 3, [hl]
-
-; 'flinched!'
+ res SUBSTATUS_FLINCHED, [hl]
ld hl, FlinchedText
call StdBattleTextBox
@@ -494,47 +477,44 @@
call CantMove
jp Function34385
+.not_flinched
-.CheckDisabled
+
ld hl, EnemyDisableCount
ld a, [hl]
and a
- jr z, .CheckConfused
+ jr z, .not_disabled
dec a
ld [hl], a
and $f
- jr nz, .CheckConfused
+ jr nz, .not_disabled
ld [hl], a
ld [EnemyDisabledMove], a
-; 'disabled no more!'
ld hl, DisabledNoMoreText
call StdBattleTextBox
+.not_disabled
-.CheckConfused
+
ld a, [EnemySubStatus3]
- add a
- jr nc, .CheckAttract
+ add a ; bit SUBSTATUS_CONFUSED
+ jr nc, .not_confused
ld hl, $c67b
dec [hl]
- jr nz, .Confused
+ jr nz, .confused
ld hl, EnemySubStatus3
- res 7, [hl]
-
-; 'confused no more!'
+ res SUBSTATUS_CONFUSED, [hl]
ld hl, ConfusedNoMoreText
call StdBattleTextBox
+ jr .not_confused
- jr .CheckAttract
-
-.Confused
-; 'confused!'
+.confused
ld hl, IsConfusedText
call StdBattleTextBox
@@ -543,83 +523,74 @@
ld de, ANIM_CONFUSED
call FarPlayBattleAnimation
-; 50% chance of hitting itself
+ ; 50% chance of hitting itself
call BattleRandom
cp $80
- jr nc, .CheckAttract
+ jr nc, .not_confused
+ ; clear confusion-dependent substatus
ld hl, EnemySubStatus3
ld a, [hl]
- and %10000000
+ and 1 << SUBSTATUS_CONFUSED
ld [hl], a
-; 'hurt itself in its confusion!'
ld hl, HurtItselfText
call StdBattleTextBox
-
call Function355dd
-
call BattleCommand62
-
call BattleCommand0a
-
xor a
ld [$cfca], a
-; Flicker the monster pic unless flying or underground.
- ld de, $0115
+ ; Flicker the monster pic unless flying or underground.
+ ld de, ANIM_HIT_CONFUSION
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call GetBattleVar
- and $60
+ and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
call z, PlayFXAnimID
ld c, $1
call Function35d1c
-
call BattleCommand0c
-
call CantMove
jp Function34385
+.not_confused
-.CheckAttract
+
ld a, [EnemySubStatus1]
- add a ; check bit 7
- jr nc, .CheckDisabledMove
+ add a ; bit SUBSTATUS_ATTRACT
+ jr nc, .not_infatuated
-; 'in love with'
ld hl, InLoveWithText
call StdBattleTextBox
-
xor a
ld [$cfca], a
-
ld de, ANIM_IN_LOVE
call FarPlayBattleAnimation
-; 50% chance of infatuation
+ ; 50% chance of infatuation
call BattleRandom
cp $80
- jr c, .CheckDisabledMove
+ jr c, .not_infatuated
-; 'infatuation kept it from attacking!'
ld hl, InfatuationText
call StdBattleTextBox
-
call CantMove
jp Function34385
+.not_infatuated
-.CheckDisabledMove
-; We can't disable a move that doesn't exist.
+
+ ; We can't disable a move that doesn't exist.
ld a, [EnemyDisabledMove]
and a
- jr z, .CheckParalyzed
+ jr z, .no_disabled_move
-; Are we using the disabled move?
+ ; Are we using the disabled move?
ld hl, CurEnemyMove
cp [hl]
- jr nz, .CheckParalyzed
+ jr nz, .no_disabled_move
call MoveDisabled
@@ -626,21 +597,20 @@
call CantMove
jp Function34385
+.no_disabled_move
-.CheckParalyzed
+
ld hl, EnemyMonStatus
- bit 6, [hl]
+ bit PAR, [hl]
ret z
-; 25% chance to be fully paralyzed
+ ; 25% chance to be fully paralyzed
call BattleRandom
cp $3f
ret nc
-; 'fully paralyzed!'
ld hl, FullyParalyzedText
call StdBattleTextBox
-
call CantMove
; fallthrough
@@ -656,10 +626,10 @@
MoveDisabled: ; 3438d
-; Make sure any charged moves fail
+ ; Make sure any charged moves fail
ld a, BATTLE_VARS_SUBSTATUS3
call _GetBattleVar
- res 4, [hl]
+ res SUBSTATUS_CHARGED, [hl]
ld a, BATTLE_VARS_MOVE
call GetBattleVar
@@ -666,7 +636,6 @@
ld [$d265], a
call GetMoveName
-; 'disabled!'
ld hl, DisabledMoveText
jp StdBattleTextBox
; 343a5
@@ -674,7 +643,6 @@
HitConfusion: ; 343a5
-; 'hurt itself in its confusion!'
ld hl, HurtItselfText
call StdBattleTextBox
@@ -682,30 +650,25 @@
ld [CriticalHit], a
call Function355dd
-
call BattleCommand62
-
call BattleCommand0a
xor a
ld [$cfca], a
-; Flicker the monster pic unless flying or underground.
- ld de, $0115
+ ; Flicker the monster pic unless flying or underground.
+ ld de, ANIM_HIT_CONFUSION
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call GetBattleVar
- and $60
+ and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
call z, PlayFXAnimID
ld hl, Function3df48
call CallBattleCore
-
ld a, $1
ld [$ffd4], a
-
ld c, $1
call Function35d7e
-
jp BattleCommand0c
; 343db
@@ -713,7 +676,7 @@
BattleCommand02: ; 343db
; checkobedience
-; Enemy can't disobey
+ ; Enemy can't disobey
ld a, [hBattleTurn]
and a
ret nz
@@ -721,7 +684,7 @@
call Function34548
ret nz
-; If we've already checked this turn
+ ; If we've already checked this turn
ld a, [AlreadyDisobeyed]
and a
ret nz
@@ -729,7 +692,8 @@
xor a
ld [AlreadyDisobeyed], a
-; No obedience in link battles (since no handling exists for enemy)
+ ; No obedience in link battles
+ ; (since no handling exists for enemy)
ld a, [InLinkBattle]
and a
ret nz
@@ -738,8 +702,8 @@
and a
ret nz
-; If the monster's id doesn't match the player's,
-; some conditions need to be met.
+ ; If the monster's id doesn't match the player's,
+ ; some conditions need to be met.
ld a, PartyMon1ID - PartyMon1
call BattlePartyAttr
@@ -753,30 +717,30 @@
.obeylevel
-; The maximum obedience level is constrained by owned badges:
+ ; The maximum obedience level is constrained by owned badges:
ld hl, JohtoBadges
-; risingbadge
+ ; risingbadge
bit 7, [hl]
- ld a, 101
+ ld a, MAX_LEVEL + 1
jr nz, .getlevel
-; stormbadge
+ ; stormbadge
bit 5, [hl]
ld a, 70
jr nz, .getlevel
-; fogbadge
+ ; fogbadge
bit 3, [hl]
ld a, 50
jr nz, .getlevel
-; hivebadge
+ ; hivebadge
bit 1, [hl]
ld a, 30
jr nz, .getlevel
-; no badges
+ ; no badges
ld a, 10
@@ -852,12 +816,9 @@
cp b
jr nc, .DoNothing
-; 'won't obey!'
ld hl, WontObeyText
call StdBattleTextBox
-
call HitConfusion
-
jp Function3450c
@@ -865,12 +826,11 @@
call BattleRandom
add a
swap a
- and 7
+ and SLP
jr z, .Nap
ld [BattleMonStatus], a
-; 'began to nap!'
ld hl, BeganToNapText
jr .Print
@@ -879,22 +839,18 @@
call BattleRandom
and 3
-; 'loafing around!'
ld hl, LoafingAroundText
and a
jr z, .Print
-; 'won't obey!'
ld hl, WontObeyText
dec a
jr z, .Print
-; 'turned away!'
ld hl, TurnedAwayText
dec a
jr z, .Print
-; 'ignored orders!'
ld hl, IgnoredOrdersText
@@ -965,7 +921,7 @@
.RandomMove
call BattleRandom
- and 3
+ and 3 ; TODO NUM_MOVES
cp b
jr nc, .RandomMove
@@ -1113,7 +1069,7 @@
inc de
ld a, [de]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
ret nz
ld a, [hBattleTurn]
@@ -1147,13 +1103,13 @@
.asm_345b8
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
and $3f
jr z, .asm_345e3
dec [hl]
- ld b, $0
+ ld b, 0
ret
.asm_345c5
@@ -1160,7 +1116,7 @@
ld hl, EnemyMonMoves
ld a, [CurEnemyMoveNum]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
cp MIMIC
@@ -1467,12 +1423,12 @@
cp $ff
jr z, .end
-; foresight
+ ; foresight
cp $fe
jr nz, .asm_34757
ld a, BATTLE_VARS_SUBSTATUS1_OPP
call GetBattleVar
- bit 3, a
+ bit SUBSTATUS_IDENTIFIED, a
jr nz, .end
jr .asm_34743
@@ -3448,16 +3404,14 @@
cp SPECIAL
jr nc, .special
-
-; Physical
+.physical
ld hl, EnemyMonDefense
ld a, [hli]
ld b, a
ld c, [hl]
-; Reflect
ld a, [EnemyScreens]
- bit 4, a
+ bit SCREENS_REFLECT, a
jr z, .physicalcrit
sla c
rl b
@@ -3474,7 +3428,6 @@
ld hl, PlayerStats
jr .thickclub
-
.special
ld hl, EnemyMonSpclDef
ld a, [hli]
@@ -3481,9 +3434,8 @@
ld b, a
ld c, [hl]
-; Light Screen
ld a, [EnemyScreens]
- bit 3, a
+ bit SCREENS_LIGHT_SCREEN, a
jr z, .specialcrit
sla c
rl b
@@ -3709,16 +3661,14 @@
cp SPECIAL
jr nc, .Special
-
-; Physical
+.physical
ld hl, BattleMonDefense
ld a, [hli]
ld b, a
ld c, [hl]
-; Reflect
ld a, [PlayerScreens]
- bit 4, a
+ bit SCREENS_REFLECT, a
jr z, .physicalcrit
sla c
rl b
@@ -3735,7 +3685,6 @@
ld hl, EnemyStats
jr .thickclub
-
.Special
ld hl, BattleMonSpclDef
ld a, [hli]
@@ -3742,9 +3691,8 @@
ld b, a
ld c, [hl]
-; Light Screen
ld a, [PlayerScreens]
- bit 3, a
+ bit SCREENS_LIGHT_SCREEN, a
jr z, .specialcrit
sla c
rl b
@@ -3788,14 +3736,14 @@
jp nz, .asm_354ef
ld a, [PlayerSubStatus3]
bit 2, a
- jr nz, .asm_35482 ; 3546f $11
- ld c, $14
+ jr nz, .asm_35482
+ ld c, 20
call DelayFrames
xor a
ld [PlayerRolloutCount], a
ld [DefaultFlypoint], a
ld [$c72d], a
- jr .asm_3548d ; 35480 $b
+ jr .asm_3548d
.asm_35482
ld a, [PlayerRolloutCount]
ld b, a
@@ -3816,7 +3764,7 @@
ld a, [CurBattleMon]
cp [hl]
ld hl, BattleMonStatus
- jr z, .asm_354b2 ; 354ab $5
+ jr z, .asm_354b2
ld a, $20
call Function355bd
.asm_354b2
@@ -3883,7 +3831,7 @@
ld a, [DefaultFlypoint]
ld c, a
- ld b, $0
+ ld b, 0
ld hl, OTPartySpecies
add hl, bc
ld a, [hl]
@@ -3894,7 +3842,7 @@
.asm_35532
ld a, [DefaultFlypoint]
ld hl, OTPartyMonNicknames
- ld bc, $000b
+ ld bc, NAME_LENGTH
call AddNTimes
ld de, StringBuffer1
call CopyBytes
@@ -4018,7 +3966,7 @@
ld b, a
ld c, [hl]
ld a, [de]
- bit 4, a
+ bit SCREENS_REFLECT, a
jr z, .asm_35604
sla c
@@ -4078,7 +4026,6 @@
ld c, 1
.asm_35631
-
xor a
ld hl, hDividend
ld [hli], a
@@ -4125,7 +4072,6 @@
ld b, $4
call Divide
-
; Item boosts
call GetUserItem
@@ -4537,13 +4483,13 @@
ld a, BATTLE_VARS_LAST_MOVE_OPP
call GetBattleVar
and a
- jp z, Function35923
+ jp z, .asm_35923
cp STRUGGLE
- jp z, Function35923
+ jp z, .asm_35923
cp ENCORE
- jp z, Function35923
+ jp z, .asm_35923
cp MIRROR_MOVE
- jp z, Function35923
+ jp z, .asm_35923
ld b, a
.asm_3588e
@@ -4555,14 +4501,14 @@
add hl, bc
ld a, [hl]
and $3f
- jp z, Function35923
+ jp z, .asm_35923
ld a, [AttackMissed]
and a
- jp nz, Function35923
+ jp nz, .asm_35923
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call _GetBattleVar
bit 4, [hl]
- jp nz, Function35923
+ jp nz, .asm_35923
set 4, [hl]
call BattleRandom
and $3
@@ -4575,10 +4521,11 @@
ld a, [hBattleTurn]
and a
jr z, .asm_358ef
+
push hl
ld a, [LastPlayerMove]
ld b, a
- ld c, $0
+ ld c, 0
ld hl, BattleMonMoves
.asm_358cc
ld a, [hli]
@@ -4586,15 +4533,16 @@
jr z, .asm_358dd
inc c
ld a, c
- cp $4
+ cp NUM_MOVES
jr c, .asm_358cc
pop hl
res 4, [hl]
xor a
ld [de], a
- jr Function35923
+ jr .asm_35923
.asm_358dd
pop hl
+
ld a, c
ld [CurMoveNum], a
ld a, b
@@ -4603,11 +4551,12 @@
ld de, wPlayerMoveStruct
call GetMoveData
jr .asm_3591a
+
.asm_358ef
push hl
ld a, [LastEnemyMove]
ld b, a
- ld c, $0
+ ld c, 0
ld hl, EnemyMonMoves
.asm_358f9
ld a, [hli]
@@ -4615,15 +4564,16 @@
jr z, .asm_3590a
inc c
ld a, c
- cp $4
+ cp NUM_MOVES
jr c, .asm_358f9
pop hl
res 4, [hl]
xor a
ld [de], a
- jr Function35923
+ jr .asm_35923
.asm_3590a
pop hl
+
ld a, c
ld [CurEnemyMoveNum], a
ld a, b
@@ -4631,15 +4581,13 @@
dec a
ld de, wEnemyMoveStruct
call GetMoveData
+
.asm_3591a
call AnimateCurrentMove
-
ld hl, GotAnEncoreText
jp StdBattleTextBox
-; 35923
-
-Function35923: ; 35923
+.asm_35923
jp PrintDidntAffect2
; 35926
@@ -4766,17 +4714,17 @@
ld a, [AttackMissed]
and a
- jr nz, .asm_35a50 ; 359ea $64
+ jr nz, .asm_35a50
ld hl, BattleMonType1
ld a, [hBattleTurn]
and a
- jr z, .asm_359f7 ; 359f2 $3
+ jr z, .asm_359f7
ld hl, EnemyMonType1
.asm_359f7
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
and a
- jr z, .asm_35a50 ; 359fd $51
+ jr z, .asm_35a50
push hl
dec a
ld hl, Moves + MOVE_TYPE
@@ -4784,19 +4732,19 @@
ld d, a
pop hl
cp CURSE_T
- jr z, .asm_35a50 ; 35a0b $43
+ jr z, .asm_35a50
call AnimateCurrentMove
-
call SwitchTurn
+
.asm_35a13
call BattleRandom
and $1f
- cp $a
- jr c, .asm_35a24 ; 35a1a $8
- cp $14
- jr c, .asm_35a13 ; 35a1e $f3
- cp $1c
- jr nc, .asm_35a13 ; 35a22 $ef
+ cp UNUSED_TYPES
+ jr c, .asm_35a24
+ cp UNUSED_TYPES_END
+ jr c, .asm_35a13
+ cp TYPES_END
+ jr nc, .asm_35a13
.asm_35a24
ld [hli], a
ld [hld], a
@@ -4814,7 +4762,7 @@
pop hl
ld a, [$d265]
cp $a
- jr nc, .asm_35a13 ; 35a3c $d5
+ jr nc, .asm_35a13
call SwitchTurn
ld a, [hl]
@@ -4823,6 +4771,7 @@
call Predef
ld hl, TransformedTypeText
jp StdBattleTextBox
+
.asm_35a50
jp Function37354
; 35a53
@@ -4833,9 +4782,11 @@
call CheckSubstituteOpp
jr nz, .asm_35a6e
+
ld a, [AttackMissed]
and a
jr nz, .asm_35a6e
+
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call _GetBattleVar
set SUBSTATUS_LOCK_ON, [hl]
@@ -4854,19 +4805,23 @@
; sketch
call Function372d8
+
ld a, [InLinkBattle]
and a
- jr z, .asm_35a83 ; 35a7b $6
+ jr z, .asm_35a83
call AnimateFailedMove
jp PrintNothingHappened
.asm_35a83
+
call CheckSubstituteOpp
jp nz, .asm_35b10
+
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call _GetBattleVar
- bit 3, [hl]
+ bit SUBSTATUS_TRANSFORMED, [hl]
jp nz, .asm_35b10
- ld a, $2
+
+ ld a, PartyMon1Moves - PartyMon1
call UserPartyAttr
ld d, h
ld e, l
@@ -4873,7 +4828,7 @@
ld hl, BattleMonMoves
ld a, [hBattleTurn]
and a
- jr z, .asm_35aa5 ; 35aa0 $3
+ jr z, .asm_35aa5
ld hl, EnemyMonMoves
.asm_35aa5
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
@@ -4881,23 +4836,23 @@
ld [$d265], a
ld b, a
and a
- jr z, .asm_35b10 ; 35aaf $5f
+ jr z, .asm_35b10
cp STRUGGLE
- jr z, .asm_35b10 ; 35ab3 $5b
- ld c, $4
+ jr z, .asm_35b10
+ ld c, NUM_MOVES
.asm_35ab7
ld a, [hli]
cp b
- jr z, .asm_35b10 ; 35ab9 $55
+ jr z, .asm_35b10
dec c
- jr nz, .asm_35ab7 ; 35abc $f9
+ jr nz, .asm_35ab7
dec hl
- ld c, $4
+ ld c, NUM_MOVES
.asm_35ac1
dec c
ld a, [hld]
cp SKETCH
- jr nz, .asm_35ac1 ; 35ac5 $fa
+ jr nz, .asm_35ac1
inc hl
ld a, b
ld [hl], a
@@ -4913,14 +4868,14 @@
pop bc
ld a, [hBattleTurn]
and a
- jr z, .asm_35af6 ; 35add $17
+ jr z, .asm_35af6
ld a, [IsInBattle]
dec a
- jr nz, .asm_35af6 ; 35ae3 $11
+ jr nz, .asm_35af6
ld a, [hl]
push bc
ld hl, $c739
- ld b, $0
+ ld b, 0
add hl, bc
ld [hl], a
ld hl, $c735
@@ -4927,12 +4882,12 @@
add hl, bc
pop bc
ld [hl], b
- jr .asm_35b04 ; 35af4 $e
+ jr .asm_35b04
.asm_35af6
ld a, [hl]
push af
ld l, c
- ld h, $0
+ ld h, 0
add hl, de
ld a, b
ld [hl], a
@@ -4955,10 +4910,9 @@
BattleCommand47: ; 35b16
; defrostopponent
+; Thaw the opponent if frozen, and
+; raise the user's Attack one stage.
-; If the opponent isn't frozen, raise Attack one stage.
-; If the opponent is frozen, thaw them and raise Accuracy two stages.
-
call AnimateCurrentMove
ld a, BATTLE_VARS_STATUS_OPP
@@ -4965,7 +4919,6 @@
call _GetBattleVar
call Defrost
-; Sharply raise accuracy
ld a, BATTLE_VARS_MOVE_EFFECT
call _GetBattleVar
ld a, [hl]
@@ -4972,7 +4925,7 @@
push hl
push af
- ld a, $a ; meditate, sharpen
+ ld a, EFFECT_ATTACK_UP
ld [hl], a
call BattleCommand1c
@@ -4989,13 +4942,13 @@
call Function372d8
ld a, [AttackMissed]
and a
- jr nz, .asm_35ba3 ; 35b3a $67
+ jr nz, .asm_35ba3
ld a, [hBattleTurn]
and a
ld hl, BattleMonMoves + 1
ld a, [DisabledMove]
ld d, a
- jr z, .asm_35b4f ; 35b46 $7
+ jr z, .asm_35b4f
ld hl, EnemyMonMoves + 1
ld a, [EnemyDisabledMove]
ld d, a
@@ -5003,12 +4956,12 @@
ld a, BATTLE_VARS_STATUS
call GetBattleVar
and SLP
- jr z, .asm_35ba3 ; 35b56 $4b
+ jr z, .asm_35ba3
ld a, [hl]
and a
- jr z, .asm_35ba3 ; 35b5a $47
+ jr z, .asm_35ba3
call .asm_35ba9
- jr c, .asm_35ba3 ; 35b5f $42
+ jr c, .asm_35ba3
dec hl
.asm_35b62
push hl
@@ -5020,23 +4973,23 @@
ld a, [hl]
pop hl
and a
- jr z, .asm_35b62 ; 35b6f $f1
+ jr z, .asm_35b62
ld e, a
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
cp e
- jr z, .asm_35b62 ; 35b78 $e8
+ jr z, .asm_35b62
ld a, e
cp d
- jr z, .asm_35b62 ; 35b7c $e4
+ jr z, .asm_35b62
call .asm_35bdf
- jr z, .asm_35b62 ; 35b81 $df
+ jr z, .asm_35b62
ld a, BATTLE_VARS_MOVE
call _GetBattleVar
ld a, e
ld [hl], a
call Function34548
- jr nz, .asm_35b9a ; 35b8d $b
+ jr nz, .asm_35b9a
ld a, [$c689]
push af
call BattleCommand0a
@@ -5150,15 +5103,15 @@
ld hl, EnemyMonMoves
ld a, [hBattleTurn]
and a
- jr z, .asm_35c24 ; 35c1f $3
+ jr z, .asm_35c24
ld hl, BattleMonMoves
.asm_35c24
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
and a
- jr z, .asm_35c91 ; 35c2a $65
+ jr z, .asm_35c91
cp STRUGGLE
- jr z, .asm_35c91 ; 35c2e $61
+ jr z, .asm_35c91
ld b, a
ld c, $ff
.asm_35c33
@@ -5165,7 +5118,7 @@
inc c
ld a, [hli]
cp b
- jr nz, .asm_35c33 ; 35c36 $fb
+ jr nz, .asm_35c33
ld [$d265], a
dec hl
ld b, $0
@@ -5175,7 +5128,7 @@
pop bc
ld a, [hl]
and $3f
- jr z, .asm_35c91 ; 35c46 $49
+ jr z, .asm_35c91
push bc
call GetMoveName
call BattleRandom
@@ -5186,7 +5139,7 @@
ld a, [hl]
and $3f
cp b
- jr nc, .asm_35c5b ; 35c58 $1
+ jr nc, .asm_35c5b
ld b, a
.asm_35c5b
ld a, [hl]
@@ -5202,14 +5155,14 @@
ld e, a
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call GetBattleVar
- bit 3, a
- jr nz, .asm_35c82 ; 35c70 $10
+ bit SUBSTATUS_TRANSFORMED, a
+ jr nz, .asm_35c82
ld a, [hBattleTurn]
and a
- jr nz, .asm_35c81 ; 35c75 $a
+ jr nz, .asm_35c81
ld a, [IsInBattle]
dec a
- jr nz, .asm_35c81 ; 35c7b $4
+ jr nz, .asm_35c81
ld hl, $c739
add hl, bc
.asm_35c81
@@ -5233,7 +5186,7 @@
ld hl, EnemyMonHP
ld a, [hBattleTurn]
and a
- jr z, .asm_35c9f ; 35c9a $3
+ jr z, .asm_35c9f
ld hl, BattleMonHP
.asm_35c9f
ld de, CurDamage
@@ -5243,7 +5196,7 @@
call StringCmp
pop de
pop hl
- jr c, .asm_35cc7 ; 35cab $1a
+ jr c, .asm_35cc7
ld a, [hli]
ld [de], a
inc de
@@ -5251,7 +5204,7 @@
dec a
ld [de], a
inc a
- jr nz, .asm_35cba ; 35cb4 $4
+ jr nz, .asm_35cba
dec de
ld a, [de]
dec a
@@ -5259,7 +5212,7 @@
.asm_35cba
ld a, [CriticalHit]
cp $2
- jr nz, .asm_35cc5 ; 35cbf $4
+ jr nz, .asm_35cc5
xor a
ld [CriticalHit], a
.asm_35cc5
@@ -5280,7 +5233,7 @@
ld de, PartyMon1Status
ld a, [hBattleTurn]
and a
- jr z, .asm_35cdb ; 35cd6 $3
+ jr z, .asm_35cdb
ld de, OTPartyMon1Status
.asm_35cdb
ld a, BATTLE_VARS_STATUS
@@ -5311,10 +5264,9 @@
FarPlayBattleAnimation: ; 35d00
; play animation de
-; battle animations disabled?
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVar
- and 1 << 6 | 1 << 5
+ and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
ret nz
; fallthrough
@@ -5540,8 +5492,9 @@
call GetOpponentItem
ld a, b
- cp $17
- jr nz, .asm_35e70 ; 35e62 $c
+ cp HELD_PREVENT_SLEEP
+ jr nz, .asm_35e70
+
ld a, [hl]
ld [$d265], a
call GetItemName
@@ -5554,7 +5507,7 @@
ld d, h
ld e, l
ld a, [de]
- and 7
+ and SLP
ld hl, AlreadyAsleepText
jr nz, .asm_35ec6
@@ -5608,24 +5561,23 @@
Function35ece: ; 35ece
-; Enemy turn
+ ; Enemy turn
ld a, [hBattleTurn]
and a
jr z, .asm_35eec
-; Not in link battle
+ ; Not in link battle
ld a, [InLinkBattle]
and a
jr nz, .asm_35eec
-
ld a, [$cfc0]
and a
jr nz, .asm_35eec
-; Not locked-on by the enemy
+ ; Not locked-on by the enemy
ld a, [PlayerSubStatus5]
- bit 5, a
+ bit SUBSTATUS_LOCK_ON, a
jr nz, .asm_35eec
call BattleRandom
@@ -5654,7 +5606,7 @@
ret z
call GetOpponentItem
ld a, b
- cp $14
+ cp HELD_PREVENT_POISON
ret z
ld a, [EffectFailed]
and a
@@ -5662,7 +5614,7 @@
call Function37962
ret nz
call Function35ff5
- ld de, $0106
+ ld de, ANIM_PSN
call Function37e54
call RefreshBattleHuds
@@ -5681,60 +5633,64 @@
ld a, [TypeModifier]
and $7f
jp z, .asm_35fb8
+
call Function35fe1
jp z, .asm_35fb8
+
ld a, BATTLE_VARS_STATUS_OPP
call GetBattleVar
ld b, a
ld hl, AlreadyPoisonedText
- and $8
+ and 1 << PSN
jp nz, .asm_35fb8
+
call GetOpponentItem
ld a, b
- cp $14
- jr nz, .asm_35f5f ; 35f51 $c
+ cp HELD_PREVENT_POISON
+ jr nz, .asm_35f5f
ld a, [hl]
ld [$d265], a
call GetItemName
ld hl, ProtectedByText
- jr .asm_35fb8 ; 35f5d $59
+ jr .asm_35fb8
+
.asm_35f5f
ld hl, DidntAffect1Text
ld a, BATTLE_VARS_STATUS_OPP
call GetBattleVar
and a
- jr nz, .asm_35fb8 ; 35f68 $4e
+ jr nz, .asm_35fb8
ld a, [hBattleTurn]
and a
- jr z, .asm_35f89 ; 35f6d $1a
+ jr z, .asm_35f89
ld a, [InLinkBattle]
and a
- jr nz, .asm_35f89 ; 35f73 $14
+ jr nz, .asm_35f89
ld a, [$cfc0]
and a
- jr nz, .asm_35f89 ; 35f79 $e
+ jr nz, .asm_35f89
ld a, [PlayerSubStatus5]
- bit 5, a
- jr nz, .asm_35f89 ; 35f80 $7
+ bit SUBSTATUS_LOCK_ON, a
+ jr nz, .asm_35f89
call BattleRandom
cp $40
- jr c, .asm_35fb8 ; 35f87 $2f
+ jr c, .asm_35fb8
.asm_35f89
call CheckSubstituteOpp
- jr nz, .asm_35fb8 ; 35f8c $2a
+ jr nz, .asm_35fb8
ld a, [AttackMissed]
and a
- jr nz, .asm_35fb8 ; 35f92 $24
+ jr nz, .asm_35fb8
call Function35fc9
- jr z, .asm_35fa4 ; 35f97 $b
+ jr z, .asm_35fa4
call Function35fc0
ld hl, WasPoisonedText
call StdBattleTextBox
- jr .asm_35fb1 ; 35fa2 $d
+ jr .asm_35fb1
.asm_35fa4
- set 0, [hl]
+ set SUBSTATUS_TOXIC, [hl]
xor a
ld [de], a
call Function35fc0
@@ -5919,7 +5875,7 @@
ret z
call GetOpponentItem
ld a, b
- cp $15
+ cp HELD_PREVENT_BURN
ret z
ld a, [EffectFailed]
and a
@@ -5928,11 +5884,11 @@
ret nz
ld a, BATTLE_VARS_STATUS_OPP
call _GetBattleVar
- set 4, [hl]
+ set BRN, [hl]
call UpdateOpponentInParty
ld hl, Function3ec76
call CallBattleCore
- ld de, $0105
+ ld de, ANIM_BRN
call Function37e54
call RefreshBattleHuds
@@ -5946,7 +5902,7 @@
Defrost: ; 360dd
ld a, [hl]
- and $20
+ and 1 << FRZ
ret z
xor a
@@ -5986,13 +5942,13 @@
and $7f
ret z
ld a, [Weather]
- cp $2
+ cp WEATHER_SUN
ret z
call Function36e5b
ret z
call GetOpponentItem
ld a, b
- cp $16
+ cp HELD_PREVENT_FREEZE
ret z
ld a, [EffectFailed]
and a
@@ -6001,9 +5957,9 @@
ret nz
ld a, BATTLE_VARS_STATUS_OPP
call _GetBattleVar
- set 5, [hl]
+ set FRZ, [hl]
call UpdateOpponentInParty
- ld de, $0108
+ ld de, ANIM_FRZ
call Function37e54
call RefreshBattleHuds
@@ -6017,7 +5973,7 @@
ld hl, $c740
ld a, [hBattleTurn]
and a
- jr z, .asm_36162 ; 3615d $3
+ jr z, .asm_36162
ld hl, $c73f
.asm_36162
ld [hl], $1
@@ -6041,7 +5997,7 @@
ret z
call GetOpponentItem
ld a, b
- cp $18
+ cp HELD_PREVENT_PARALYZE
ret z
ld a, [EffectFailed]
and a
@@ -6050,11 +6006,11 @@
ret nz
ld a, BATTLE_VARS_STATUS_OPP
call _GetBattleVar
- set 6, [hl]
+ set PAR, [hl]
call UpdateOpponentInParty
ld hl, Function3ec39
call CallBattleCore
- ld de, $0109
+ ld de, ANIM_PAR
call Function37e54
call RefreshBattleHuds
call PrintParalyze
@@ -6147,7 +6103,7 @@
ld a, [LoweredStat]
and $f
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld b, [hl]
inc b
@@ -6178,7 +6134,7 @@
.asm_36243
push bc
sla c
- ld b, $0
+ ld b, 0
add hl, bc
ld a, c
add e
@@ -6188,10 +6144,10 @@
.asm_3624f
pop bc
ld a, [hld]
- sub $e7
+ sub 999 % $100
jr nz, .asm_3625b ; 0x36253 $6
ld a, [hl]
- sbc $3
+ sbc 999 / $100
jp z, Function3626e
.asm_3625b
ld a, [hBattleTurn]
@@ -7530,7 +7486,7 @@
call BattleRandom
and $3
cp $2
- jr c, .asm_36a39 ; 36a32 $5
+ jr c, .asm_36a39
call BattleRandom
and $3
.asm_36a39
@@ -7539,16 +7495,16 @@
ld [de], a
inc a
ld [bc], a
- jr .asm_36a6b ; 36a3d $2c
+ jr .asm_36a6b
.asm_36a3f
ld a, $1
- jr .asm_36a3a ; 36a41 $f7
+ jr .asm_36a3a
.asm_36a43
ld a, [de]
dec a
ld [de], a
- jr nz, .asm_36a6b ; 36a46 $23
+ jr nz, .asm_36a6b
.asm_36a48
ld a, BATTLE_VARS_SUBSTATUS3
call _GetBattleVar
@@ -7583,7 +7539,7 @@
.asm_36a73
ld a, [hld]
cp $5 ; critical
- jr nz, .asm_36a73 ; 36a76 $fb
+ jr nz, .asm_36a73
inc hl
ld a, h
ld [BattleScriptBufferLoc + 1], a
@@ -7597,14 +7553,18 @@
ld a, [AttackMissed]
and a
ret nz
+
call CheckSubstituteOpp
- jr nz, .asm_36a9a ; 36a8a $e
+ jr nz, .asm_36a9a
+
ld a, BATTLE_VARS_STATUS_OPP
call GetBattleVar
- and $27
- jr nz, .asm_36a9a ; 36a93 $5
+ and 1 << FRZ | SLP
+ jr nz, .asm_36a9a
+
call Function36abf
- jr z, Function36ab5 ; 36a98 $1b
+ jr z, Function36ab5
+
.asm_36a9a
ld a, 1
ld [AttackMissed], a
@@ -7615,12 +7575,15 @@
BattleCommand25: ; 36aa0
call CheckSubstituteOpp
ret nz
+
ld a, BATTLE_VARS_STATUS_OPP
call GetBattleVar
- and $27
+ and 1 << FRZ | SLP
ret nz
+
call Function36abf
ret nz
+
ld a, [EffectFailed]
and a
ret nz
@@ -7632,7 +7595,7 @@
Function36ab5: ; 36ab5
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call _GetBattleVar
- set 3, [hl]
+ set SUBSTATUS_FLINCHED, [hl]
jp EndRechargeOpp
; 36abf
@@ -7657,7 +7620,7 @@
call GetUserItem
ld a, b
- cp HELD_TRADE_EVOLVE ; king's rock
+ cp HELD_TRADE_EVOLVE ; Only King's Rock has this effect
ret nz
call CheckSubstituteOpp
@@ -7673,7 +7636,7 @@
call EndRechargeOpp
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call _GetBattleVar
- set 3, [hl]
+ set SUBSTATUS_FLINCHED, [hl]
ret
; 36af3
@@ -7684,13 +7647,13 @@
call ResetDamage
ld a, [TypeModifier]
and $7f
- jr z, .asm_36b2f ; 36afb $32
+ jr z, .asm_36b2f
ld hl, EnemyMonLevel
ld de, BattleMonLevel
ld bc, wPlayerMoveStruct + MOVE_ACC
ld a, [hBattleTurn]
and a
- jr z, .asm_36b12 ; 36b09 $7
+ jr z, .asm_36b12
push hl
ld h, d
ld l, e
@@ -7699,12 +7662,12 @@
.asm_36b12
ld a, [de]
sub [hl]
- jr c, .asm_36b2f ; 36b14 $19
+ jr c, .asm_36b2f
add a
ld e, a
ld a, [bc]
add e
- jr nc, .asm_36b1e ; 36b1a $2
+ jr nc, .asm_36b1e
ld a, $ff
.asm_36b1e
ld [bc], a
@@ -7728,15 +7691,13 @@
BattleCommand3a: ; 36b3a
; checkcharge
-; charged?
ld a, BATTLE_VARS_SUBSTATUS3
call _GetBattleVar
- bit 4, [hl]
+ bit SUBSTATUS_CHARGED, [hl]
ret z
-; go to town
- res 4, [hl]
- res 5, [hl]
- res 6, [hl]
+ res SUBSTATUS_CHARGED, [hl]
+ res SUBSTATUS_UNDERGROUND, [hl]
+ res SUBSTATUS_FLYING, [hl]
ld b, $39 ; charge
jp SkipToBattleCommand
; 36b4d
@@ -7748,7 +7709,7 @@
call BattleCommand38
ld a, BATTLE_VARS_STATUS
call GetBattleVar
- and $7
+ and SLP
jr z, .asm_36b65
call BattleCommandaa
@@ -7759,7 +7720,7 @@
.asm_36b65
ld a, BATTLE_VARS_SUBSTATUS3
call _GetBattleVar
- set 4, [hl]
+ set SUBSTATUS_CHARGED, [hl]
ld hl, IgnoredOrders2Text
ld a, [AlreadyDisobeyed]
@@ -7774,12 +7735,12 @@
call Function37e36
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
- cp $13
- jr z, .asm_36b96 ; 36b8b $9
- cp $5b
- jr z, .asm_36b96 ; 36b8f $5
+ cp FLY
+ jr z, .asm_36b96
+ cp DIG
+ jr z, .asm_36b96
call BattleCommand0c
- jr .asm_36b99 ; 36b94 $3
+ jr .asm_36b99
.asm_36b96
call Function37ec0
.asm_36b99
@@ -7788,19 +7749,19 @@
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVar
ld b, a
- cp $13
- jr z, .asm_36bb0 ; 36ba6 $8
- cp $5b
- jr nz, .asm_36bb2 ; 36baa $6
- set 5, [hl]
- jr .asm_36bb2 ; 36bae $2
+ cp FLY
+ jr z, .asm_36bb0
+ cp DIG
+ jr nz, .asm_36bb2
+ set SUBSTATUS_UNDERGROUND, [hl]
+ jr .asm_36bb2
.asm_36bb0
- set 6, [hl]
+ set SUBSTATUS_FLYING, [hl]
.asm_36bb2
call Function34548
- jr nz, .asm_36bc3 ; 36bb5 $c
+ jr nz, .asm_36bc3
ld a, BATTLE_VARS_LAST_COUNTER_MOVE
call _GetBattleVar
ld [hl], b
@@ -7811,7 +7772,7 @@
.asm_36bc3
call ResetDamage
- ld hl, .text_36bdb
+ ld hl, .UsedText
call BattleTextBox
ld a, BATTLE_VARS_MOVE_EFFECT
@@ -7821,9 +7782,8 @@
jp z, SkipToBattleCommand
jp EndMoveEffect
-.text_36bdb
-; [user]
- TX_FAR UnknownText_0x1c0d0e
+.UsedText
+ TX_FAR UnknownText_0x1c0d0e ; "[USER]"
start_asm
ld a, BATTLE_VARS_MOVE_ANIM
@@ -7830,28 +7790,28 @@
call GetBattleVar
cp RAZOR_WIND
ld hl, .RazorWind
- jr z, .asm_36c0d
+ jr z, .done
cp SOLARBEAM
ld hl, .Solarbeam
- jr z, .asm_36c0d
+ jr z, .done
cp SKULL_BASH
ld hl, .SkullBash
- jr z, .asm_36c0d
+ jr z, .done
cp SKY_ATTACK
ld hl, .SkyAttack
- jr z, .asm_36c0d
+ jr z, .done
cp FLY
ld hl, .Fly
- jr z, .asm_36c0d
+ jr z, .done
cp DIG
ld hl, .Dig
-.asm_36c0d
+.done
ret
.RazorWind
@@ -7912,7 +7872,7 @@
ret nz
ld a, BATTLE_VARS_SUBSTATUS4_OPP
call GetBattleVar
- bit 4, a
+ bit SUBSTATUS_SUBSTITUTE, a
ret nz
call BattleRandom
and 3
@@ -7954,9 +7914,9 @@
ld a, BATTLE_VARS_SUBSTATUS4
call _GetBattleVar
- bit 1, [hl]
- jr nz, .asm_36c92 ; 36c85 $b
- set 1, [hl]
+ bit SUBSTATUS_MIST, [hl]
+ jr nz, .asm_36c92
+ set SUBSTATUS_MIST, [hl]
call AnimateCurrentMove
ld hl, MistText
jp StdBattleTextBox
@@ -7971,9 +7931,9 @@
ld a, BATTLE_VARS_SUBSTATUS4
call _GetBattleVar
- bit 2, [hl]
- jr nz, .asm_36cac ; 36c9f $b
- set 2, [hl]
+ bit SUBSTATUS_FOCUS_ENERGY, [hl]
+ jr nz, .asm_36cac
+ set SUBSTATUS_FOCUS_ENERGY, [hl]
call AnimateCurrentMove
ld hl, GettingPumpedText
jp StdBattleTextBox
@@ -7989,7 +7949,7 @@
ld hl, BattleMonMaxHP
ld a, [hBattleTurn]
and a
- jr z, .asm_36cbd ; 36cb8 $3
+ jr z, .asm_36cbd
ld hl, EnemyMonMaxHP
.asm_36cbd
ld a, BATTLE_VARS_MOVE_ANIM
@@ -8005,7 +7965,7 @@
rr c
ld a, b
or c
- jr nz, .asm_36cd8 ; 36cd5 $1
+ jr nz, .asm_36cd8
inc c
.asm_36cd8
ld a, [hli]
@@ -8024,7 +7984,7 @@
sbc b
ld [hl], a
ld [$d1ef], a
- jr nc, .asm_36cfe ; 36cf4 $8
+ jr nc, .asm_36cfe
xor a
ld [hli], a
ld [hl], a
@@ -8036,7 +7996,7 @@
ld a, [hBattleTurn]
and a
ld a, $1
- jr z, .asm_36d0c ; 36d06 $4
+ jr z, .asm_36d0c
hlcoord 2, 2
xor a
.asm_36d0c
@@ -8054,7 +8014,7 @@
call GetOpponentItem
ld a, b
- cp $19
+ cp HELD_PREVENT_CONFUSE
ret z
ld a, [EffectFailed]
and a
@@ -8065,7 +8025,7 @@
ret nz
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call _GetBattleVar
- bit 7, [hl]
+ bit SUBSTATUS_CONFUSED, [hl]
ret nz
jr Function36d70
@@ -8075,7 +8035,7 @@
call GetOpponentItem
ld a, b
- cp $19
+ cp HELD_PREVENT_CONFUSE
jr nz, .asm_36d53
ld a, [hl]
ld [$d265], a
@@ -8087,7 +8047,7 @@
.asm_36d53
ld a, BATTLE_VARS_SUBSTATUS3_OPP
call _GetBattleVar
- bit 7, [hl]
+ bit SUBSTATUS_CONFUSED, [hl]
jr z, .asm_36d65
call AnimateFailedMove
ld hl, AlreadyConfusedText
@@ -8112,7 +8072,7 @@
ld bc, PlayerConfuseCount
.asm_36d7b
- set 7, [hl]
+ set SUBSTATUS_CONFUSED, [hl]
call BattleRandom
and 3
inc a
@@ -8130,7 +8090,7 @@
call AnimateCurrentMove
.asm_36d99
- ld de, $0103
+ ld de, ANIM_CONFUSED
call Function37e54
ld hl, BecameConfusedText
@@ -8138,9 +8098,9 @@
call GetOpponentItem
ld a, b
- cp $f
+ cp HELD_HEAL_STATUS
jr z, .asm_36db0
- cp $10
+ cp HELD_HEAL_CONFUSION
ret nz
.asm_36db0
ld hl, Function3de51
@@ -8165,15 +8125,15 @@
ld a, BATTLE_VARS_STATUS_OPP
call GetBattleVar
- bit 6, a
- jr nz, .asm_36e49 ; 36dce $79
+ bit PAR, a
+ jr nz, .asm_36e49
ld a, [TypeModifier]
and $7f
- jr z, .asm_36e55 ; 36dd5 $7e
+ jr z, .asm_36e55
call GetOpponentItem
ld a, b
- cp $18
- jr nz, .asm_36def ; 36ddd $10
+ cp HELD_PREVENT_PARALYZE
+ jr nz, .asm_36def
ld a, [hl]
ld [$d265], a
call GetItemName
@@ -8180,33 +8140,34 @@
call AnimateFailedMove
ld hl, ProtectedByText
jp StdBattleTextBox
+
.asm_36def
ld a, [hBattleTurn]
and a
- jr z, .asm_36e0e ; 36df2 $1a
+ jr z, .asm_36e0e
ld a, [InLinkBattle]
and a
- jr nz, .asm_36e0e ; 36df8 $14
+ jr nz, .asm_36e0e
ld a, [$cfc0]
and a
- jr nz, .asm_36e0e ; 36dfe $e
+ jr nz, .asm_36e0e
ld a, [PlayerSubStatus5]
- bit 5, a
- jr nz, .asm_36e0e ; 36e05 $7
+ bit SUBSTATUS_LOCK_ON, a
+ jr nz, .asm_36e0e
call BattleRandom
cp $40
- jr c, .asm_36e52 ; 36e0c $44
+ jr c, .asm_36e52
.asm_36e0e
ld a, BATTLE_VARS_STATUS_OPP
call _GetBattleVar
and a
- jr nz, .asm_36e52 ; 36e14 $3c
+ jr nz, .asm_36e52
ld a, [AttackMissed]
and a
- jr nz, .asm_36e52 ; 36e1a $36
+ jr nz, .asm_36e52
call CheckSubstituteOpp
- jr nz, .asm_36e52 ; 36e1f $31
- ld c, $1e
+ jr nz, .asm_36e52
+ ld c, 30
call DelayFrames
call AnimateCurrentMove
ld a, $1
@@ -8213,7 +8174,7 @@
ld [$ffd4], a
ld a, BATTLE_VARS_STATUS_OPP
call _GetBattleVar
- set 6, [hl]
+ set PAR, [hl]
call UpdateOpponentInParty
ld hl, Function3ec39
call CallBattleCore
@@ -8234,8 +8195,9 @@
Function36e5b: ; 36e5b
-; Compare move type to user type.
-; Return z if matching the user type (unless the move is Normal).
+; Compare move type to opponent type.
+; Return z if matching the opponent type,
+; unless the move is Normal (Tri Attack).
push hl
@@ -8285,7 +8247,7 @@
ld a, BATTLE_VARS_SUBSTATUS4
call GetBattleVar
bit SUBSTATUS_SUBSTITUTE, a
- jr nz, .asm_36ef4 ; 36e97 $5b
+ jr nz, .asm_36ef4
ld a, [hli]
ld b, [hl]
@@ -8303,10 +8265,10 @@
ld a, [hl]
sbc 0
ld d, a
- jr c, .asm_36eff ; 36eae $4f
+ jr c, .asm_36eff
ld a, d
or e
- jr z, .asm_36eff ; 36eb2 $4b
+ jr z, .asm_36eff
ld [hl], d
inc hl
ld [hl], e
@@ -8328,15 +8290,15 @@
ld [hl], a
ld [de], a
call Function37ed5
- jr c, .asm_36ee8 ; 36ed5 $11
+ jr c, .asm_36ee8
xor a
ld [$cfca], a
ld [FXAnimIDHi], a
ld [$c689], a
- ld a, $a4
+ ld a, SUBSTITUTE
call Function37e44
- jr .asm_36eeb ; 36ee6 $3
+ jr .asm_36eeb
.asm_36ee8
call BattleCommanda6
@@ -8430,34 +8392,34 @@
call BattleCommandaa
ld a, [AttackMissed]
and a
- jr nz, .asm_36f9a ; 36f50 $48
+ jr nz, .asm_36f9a
ld hl, BattleMonMoves
ld a, [hBattleTurn]
and a
- jr z, .asm_36f5d ; 36f58 $3
+ jr z, .asm_36f5d
ld hl, EnemyMonMoves
.asm_36f5d
call CheckHiddenOpponent
- jr nz, .asm_36f9a ; 36f60 $38
+ jr nz, .asm_36f9a
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
and a
- jr z, .asm_36f9a ; 36f68 $30
+ jr z, .asm_36f9a
cp STRUGGLE
- jr z, .asm_36f9a ; 36f6c $2c
+ jr z, .asm_36f9a
ld b, a
ld c, NUM_MOVES
.asm_36f71
ld a, [hli]
cp b
- jr z, .asm_36f9a ; 36f73 $25
+ jr z, .asm_36f9a
dec c
- jr nz, .asm_36f71 ; 36f76 $f9
+ jr nz, .asm_36f71
dec hl
.asm_36f79
ld a, [hld]
cp MIMIC
- jr nz, .asm_36f79 ; 36f7c $fb
+ jr nz, .asm_36f79
inc hl
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
@@ -8530,13 +8492,13 @@
ld a, [AttackMissed]
and a
- jr nz, .asm_37059 ; 36ff1 $66
+ jr nz, .asm_37059
ld de, EnemyDisableCount
ld hl, EnemyMonMoves
ld a, [hBattleTurn]
and a
- jr z, .asm_37004 ; 36ffc $6
+ jr z, .asm_37004
ld de, PlayerDisableCount
ld hl, BattleMonMoves
.asm_37004
@@ -8543,14 +8505,14 @@
ld a, [de]
and a
- jr nz, .asm_37059 ; 37006 $51
+ jr nz, .asm_37059
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
and a
- jr z, .asm_37059 ; 3700e $49
+ jr z, .asm_37059
cp STRUGGLE
- jr z, .asm_37059 ; 37012 $45
+ jr z, .asm_37059
ld b, a
ld c, $ff
@@ -8558,12 +8520,12 @@
inc c
ld a, [hli]
cp b
- jr nz, .asm_37017 ; 3701a $fb
+ jr nz, .asm_37017
ld a, [hBattleTurn]
and a
ld hl, EnemyMonPP
- jr z, .asm_37027 ; 37022 $3
+ jr z, .asm_37027
ld hl, BattleMonPP
.asm_37027
ld b, 0
@@ -8570,11 +8532,11 @@
add hl, bc
ld a, [hl]
and a
- jr z, .asm_37059 ; 3702c $2b
+ jr z, .asm_37059
.asm_3702e
call BattleRandom
and 7
- jr z, .asm_3702e ; 37033 $f9
+ jr z, .asm_3702e
inc a
inc c
swap c
@@ -8584,7 +8546,7 @@
ld hl, DisabledMove
ld a, [hBattleTurn]
and a
- jr nz, .asm_37047 ; 37044 $1
+ jr nz, .asm_37047
inc hl
.asm_37047
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
@@ -8614,7 +8576,7 @@
.ok
add a
- ld hl, $c6ee
+ ld hl, wPayDayMoney + 2
add [hl]
ld [hld], a
jr nc, .done
@@ -8640,11 +8602,11 @@
ld de, EnemyMonType1
.asm_37090
push de
- ld c, $0
+ ld c, 0
ld de, StringBuffer1
.asm_37096
push hl
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
pop hl
@@ -8702,17 +8664,17 @@
add hl, bc
ld a, [hl]
cp $ff
- jr z, .asm_370d9_b ; 370e8 $ef
+ jr z, .asm_370d9_b
cp CURSE_T
- jr z, .asm_370d9_b ; 370ec $eb
+ jr z, .asm_370d9_b
ld a, [de]
cp [hl]
- jr z, .asm_370d9_b ; 370f0 $e7
+ jr z, .asm_370d9_b
inc de
ld a, [de]
dec de
cp [hl]
- jr z, .asm_370d9_b ; 370f6 $e1
+ jr z, .asm_370d9_b
ld a, [hl]
ld [de], a
inc de
@@ -8767,7 +8729,7 @@
ld hl, BattleMonMaxHP
ld a, [hBattleTurn]
and a
- jr z, .asm_3714f ; 37147 $6
+ jr z, .asm_3714f
ld de, EnemyMonHP
ld hl, EnemyMonMaxHP
.asm_3714f
@@ -8785,7 +8747,7 @@
jp z, .asm_371c4
ld a, b
cp REST
- jr nz, .asm_37199 ; 37166 $31
+ jr nz, .asm_37199
push hl
push de
push af
@@ -8797,17 +8759,17 @@
call _GetBattleVar
ld a, [hl]
and a
- ld [hl], 3
+ ld [hl], REST_TURNS + 1
ld hl, WentToSleepText
- jr z, .asm_37186 ; 37181 $3
+ jr z, .asm_37186
ld hl, RestedText
.asm_37186
call StdBattleTextBox
ld a, [hBattleTurn]
and a
- jr nz, .asm_37193 ; 3718c $5
+ jr nz, .asm_37193
call Function365d7
- jr .asm_37196 ; 37191 $3
+ jr .asm_37196
.asm_37193
call Function365fd
.asm_37196
@@ -8815,10 +8777,10 @@
pop de
pop hl
.asm_37199
- jr z, .asm_371a3 ; 37199 $8
+ jr z, .asm_371a3
ld hl, GetHalfMaxHP
call CallBattleCore
- jr .asm_371a9 ; 371a1 $6
+ jr .asm_371a9
.asm_371a3
ld hl, GetMaxHP
call CallBattleCore
@@ -8846,7 +8808,7 @@
call Function372d8
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call _GetBattleVar
- bit 3, [hl]
+ bit SUBSTATUS_TRANSFORMED, [hl]
jp nz, Function372d2
call CheckHiddenOpponent
jp nz, Function372d2
@@ -8859,21 +8821,21 @@
call _GetBattleVar
bit SUBSTATUS_SUBSTITUTE, [hl]
push af
- jr z, .asm_37200 ; 371f4 $a
+ jr z, .asm_37200
call Function34548
- jr nz, .asm_37200 ; 371f9 $5
+ jr nz, .asm_37200
ld a, SUBSTITUTE
call Function37e44
.asm_37200
ld a, BATTLE_VARS_SUBSTATUS5
call _GetBattleVar
- set 3, [hl]
+ set SUBSTATUS_TRANSFORMED, [hl]
call ResetActorDisable
ld hl, BattleMonSpecies
ld de, EnemyMonSpecies
ld a, [hBattleTurn]
and a
- jr nz, .asm_3721f ; 37213 $a
+ jr nz, .asm_3721f
ld hl, EnemyMonSpecies
ld de, BattleMonSpecies
xor a
@@ -8889,7 +8851,7 @@
call CopyBytes
ld a, [hBattleTurn]
and a
- jr z, .asm_3723a ; 3722e $a
+ jr z, .asm_3723a
ld a, [de]
ld [$c6f2], a
inc de
@@ -8927,15 +8889,15 @@
ld a, [de]
inc de
and a
- jr z, .asm_3726c ; 37262 $8
+ jr z, .asm_3726c
cp SKETCH
ld a, 1
- jr z, .asm_3726c ; 37268 $2
+ jr z, .asm_3726c
ld a, 5
.asm_3726c
ld [hli], a
dec b
- jr nz, .asm_3725f ; 3726e $ef
+ jr nz, .asm_3725f
pop hl
ld a, [hl]
ld [$d265], a
@@ -8949,17 +8911,17 @@
ld bc, $0008
call BattleSideCopy
call Function37ed5
- jr c, .asm_372a8 ; 37293 $13
+ jr c, .asm_372a8
ld a, [hBattleTurn]
and a
ld a, [$c6fe]
- jr z, .asm_372a0 ; 3729b $3
+ jr z, .asm_372a0
ld a, [$c6fa]
.asm_372a0
and a
- jr nz, .asm_372a8 ; 372a1 $5
+ jr nz, .asm_372a8
call Function37e36
- jr .asm_372ae ; 372a6 $6
+ jr .asm_372ae
.asm_372a8
call BattleCommandaa
call BattleCommanda6
@@ -9062,7 +9024,7 @@
jr nz, .failed
set SCREENS_REFLECT, [hl]
-; LightScreenCount -> ReflectCount
+ ; LightScreenCount -> ReflectCount
inc bc
ld a, 5
@@ -9431,10 +9393,9 @@
ld [CurPartySpecies], a
ld hl, EnemyMonDVs
ld a, [EnemySubStatus5]
- bit 3, a
+ bit SUBSTATUS_TRANSFORMED, a
jr z, .asm_37829
ld hl, $c6f2
-
.asm_37829
ld a, [hli]
ld [$d123], a
@@ -9828,10 +9789,10 @@
call CallBattleCore
ld a, [OTPartyCount]
- add 4
+ add NUM_MOVES
ld b, a
- ld a, [$d430]
- cp 4
+ ld a, [wBattleAction]
+ cp NUM_MOVES
jr c, .asm_37aa0
cp b
jr c, .asm_37aa8
@@ -9838,8 +9799,8 @@
.asm_37aa0
ld a, [CurOTMon]
- add 4
- ld [$d430], a
+ add NUM_MOVES
+ ld [wBattleAction], a
.asm_37aa8
jp Function1c17
; 37aab
@@ -9877,7 +9838,7 @@
ld a, BATTLE_VARS_SUBSTATUS5
call _GetBattleVar
- res 3, [hl]
+ res SUBSTATUS_TRANSFORMED, [hl]
res 4, [hl]
; New mon hasn't used a move yet.
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -1,6 +1,8 @@
MAX_LEVEL EQU 100
NUM_MOVES EQU 4
+REST_TURNS EQU 2
+
ATTACK EQU 0
DEFENSE EQU 1
SPEED EQU 2
@@ -110,6 +112,7 @@
SUBSTATUS_CANT_RUN EQU 7
SUBSTATUS_DESTINY_BOND EQU 6
SUBSTATUS_LOCK_ON EQU 5
+SUBSTATUS_TRANSFORMED EQU 3
SUBSTATUS_TOXIC EQU 0
; environmental
@@ -119,6 +122,7 @@
SCREENS_SPIKES EQU 0
; weather
+WEATHER_NONE EQU 0
WEATHER_RAIN EQU 1
WEATHER_SUN EQU 2
WEATHER_SANDSTORM EQU 3
--- a/constants/item_constants.asm
+++ b/constants/item_constants.asm
@@ -267,6 +267,7 @@
HELD_LEFTOVERS EQU $03
HELD_RESTORE_PP EQU $06
HELD_CLEANSE_TAG EQU $08
+
HELD_HEAL_POISON EQU $0a
HELD_HEAL_FREEZE EQU $0b
HELD_HEAL_BURN EQU $0c
@@ -274,7 +275,24 @@
HELD_HEAL_PARALYZE EQU $0e
HELD_HEAL_STATUS EQU $0f
HELD_HEAL_CONFUSION EQU $10
+
+HELD_PREVENT_POISON EQU $14
+HELD_PREVENT_BURN EQU $15
+HELD_PREVENT_FREEZE EQU $16
+HELD_PREVENT_SLEEP EQU $17
+HELD_PREVENT_PARALYZE EQU $18
+HELD_PREVENT_CONFUSE EQU $19
+
+HELD_ATTACK_UP EQU $1f
+HELD_DEFENSE_UP EQU $20
+HELD_SPEED_UP EQU $21
+HELD_SP_ATTACK_UP EQU $22
+HELD_SP_DEFENSE_UP EQU $23
+HELD_ACCURACY_UP EQU $24
+HELD_EVASION_UP EQU $25
+
HELD_METAL_POWDER EQU $2a
+
HELD_NORMAL_BOOST EQU $32
HELD_FIGHTING_BOOST EQU $33
HELD_FLYING_BOOST EQU $34
@@ -292,6 +310,7 @@
HELD_DRAGON_BOOST EQU $40
HELD_DARK_BOOST EQU $41
HELD_STEEL_BOOST EQU $42
+
HELD_ESCAPE EQU $48
HELD_CRITICAL_UP EQU $49
HELD_QUICK_CLAW EQU $4a
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -72,9 +72,9 @@
; screen
HP_BAR_LENGTH EQU 6
-HP_BAR_LENGTH_PX EQU 48
+HP_BAR_LENGTH_PX EQU HP_BAR_LENGTH * 8
EXP_BAR_LENGTH EQU 8
-EXP_BAR_LENGTH_PX EQU 64
+EXP_BAR_LENGTH_PX EQU EXP_BAR_LENGTH * 8
SCREEN_WIDTH EQU 20
SCREEN_HEIGHT EQU 18
--- a/constants/type_constants.asm
+++ b/constants/type_constants.asm
@@ -25,8 +25,8 @@
const TYPE_17
const TYPE_18
const CURSE_T
+UNUSED_TYPES_END EQU const_value
-
SPECIAL EQU const_value
const FIRE
const WATER
@@ -37,3 +37,4 @@
const DRAGON
const DARK
+TYPES_END EQU const_value
--- a/main.asm
+++ b/main.asm
@@ -57004,7 +57004,7 @@
jr StatsScreenInit_gotaddress
Function4dc8f: ; 4dc8f
- ld hl, Function4dcf7
+ ld hl, StatsScreenBattle
jr StatsScreenInit_gotaddress
StatsScreenInit_gotaddress: ; 4dc94
@@ -57063,7 +57063,7 @@
ret
; 0x4dcf7
-Function4dcf7: ; 4dcf7
+StatsScreenBattle: ; 4dcf7
xor a
ld [$cf63], a
ld [$cf64], a
--- a/wram.asm
+++ b/wram.asm
@@ -552,8 +552,12 @@
CurEnemyMoveNum:: ; c6e9
ds 1
- ds 10
+ ds 2
+wPayDayMoney:: ds 3 ; c6ec
+
+ ds 5
+
AlreadyDisobeyed:: ; c6f4
ds 1
@@ -1176,8 +1180,12 @@
OTPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d3a8
OTPartyMonNicknames:: ds PKMN_NAME_LENGTH * PARTY_LENGTH ; d3ea
+ ds 4
-SECTION "Map Events", WRAMX[$d432], BANK[1]
+wBattleAction:: ds 1 ; d430
+
+ ds 1
+
MapStatus:: ; d432
ds 1
MapEventStatus:: ; d433