diff options
Diffstat (limited to 'battle')
-rw-r--r-- | battle/ai/items.asm | 847 | ||||
-rw-r--r-- | battle/ai/scoring.asm | 316 | ||||
-rw-r--r-- | battle/anim_commands.asm | 24 | ||||
-rw-r--r-- | battle/core.asm | 1659 | ||||
-rw-r--r-- | battle/effect_commands.asm | 1817 | ||||
-rw-r--r-- | battle/effects/curse.asm | 6 | ||||
-rw-r--r-- | battle/effects/endure.asm | 2 | ||||
-rw-r--r-- | battle/effects/foresight.asm | 2 | ||||
-rw-r--r-- | battle/effects/metronome.asm | 2 | ||||
-rw-r--r-- | battle/effects/mirror_move.asm | 4 | ||||
-rw-r--r-- | battle/effects/nightmare.asm | 4 | ||||
-rw-r--r-- | battle/effects/protect.asm | 2 | ||||
-rw-r--r-- | battle/effects/rollout.asm | 30 | ||||
-rw-r--r-- | battle/hidden_power.asm | 2 | ||||
-rw-r--r-- | battle/moves/moves.asm | 11 |
15 files changed, 2759 insertions, 1969 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm new file mode 100644 index 000000000..6cd1cad2d --- /dev/null +++ b/battle/ai/items.asm @@ -0,0 +1,847 @@ +Function38000: ; 38000 + and a + ld a, [IsInBattle] + dec a + ret z + ld a, [InLinkBattle] + and a + ret nz + callba Function3e8d1 + ret nz + ld a, [PlayerSubStatus5] + bit SUBSTATUS_CANT_RUN, a + jr nz, Function38041 + ld a, [$c731] + and a + jr nz, Function38041 + ld hl, TrainerClassAttributes + 5 + ld a, [$cfc0] + and a + jr nz, .asm_38032 + ld a, [TrainerClass] + dec a + ld bc, 7 + call AddNTimes + +.asm_38032 + bit 0, [hl] + jp nz, Function38045 + bit 1, [hl] + jp nz, Function38083 + bit 2, [hl] + jp nz, Function380c1 + ; fallthrough +; 38041 + +Function38041: ; 38041 + call Function38105 + ret +; 38045 + +Function38045: ; 38045 + callab Function34941 + ld a, [$c717] + and $f0 + jp z, Function38041 + cp $10 + jr nz, .asm_38061 + call Random + cp $80 + jr c, .asm_38077 + jp Function38041 + +.asm_38061 + cp $20 + jr nz, .asm_3806f + call Random + cp $c8 + jr c, .asm_38077 + jp Function38041 + +.asm_3806f + call Random + cp $a + jp c, Function38041 + +.asm_38077 + ld a, [$c717] + and $f + inc a + ld [$c718], a + jp Function3844b +; 38083 + +Function38083: ; 38083 + callab Function34941 + ld a, [$c717] + and $f0 + jp z, Function38041 + cp $10 + jr nz, .asm_3809f + call Random + cp $14 + jr c, .asm_380b5 + jp Function38041 + +.asm_3809f + cp $20 + jr nz, .asm_380ad + call Random + cp $1e + jr c, .asm_380b5 + jp Function38041 + +.asm_380ad + call Random + cp $c8 + jp c, Function38041 + +.asm_380b5 + ld a, [$c717] + and $f + inc a + ld [$c718], a + jp Function3844b +; 380c1 + +Function380c1: ; 380c1 + callab Function34941 + ld a, [$c717] + and $f0 + jp z, Function38041 + cp $10 + jr nz, .asm_380dd + call Random + cp $32 + jr c, .asm_380f3 + jp Function38041 + +.asm_380dd + cp $20 + jr nz, .asm_380eb + call Random + cp $80 + jr c, .asm_380f3 + jp Function38041 + +.asm_380eb + call Random + cp $32 + jp c, Function38041 + +.asm_380f3 + ld a, [$c717] + and $f + inc a + ld [$c718], a + jp Function3844b +; 380ff + + +Function380ff: ; 380ff + ld a, [EnemySubStatus5] + bit SUBSTATUS_CANT_RUN, a + ret +; 38105 + + +Function38105: ; 38105 + ld a, [$cfc0] + and a + ret nz + ld a, [$c650] + ld b, a + ld a, [$c651] + or b + ret z + call Function38170 + ret nc + ld a, [TrainerClass] + dec a + ld hl, TrainerClassAttributes + 5 + ld bc, 7 + call AddNTimes + ld b, h + ld c, l + ld hl, Unknown_38196 + ld de, $c650 +.asm_3812c + ld a, [hl] + and a + inc a + ret z + ld a, [de] + cp [hl] + jr z, .asm_3813f + inc de + ld a, [de] + cp [hl] + jr z, .asm_3813f + dec de + inc hl + inc hl + inc hl + jr .asm_3812c + +.asm_3813f + inc hl + push hl + push de + ld de, .asm_3814a + push de + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] + +.asm_3814a + pop de + pop hl + inc hl + inc hl + jr c, .asm_3812c + xor a + ld [de], a + inc a + ld [$c70f], a + ld hl, EnemySubStatus3 ; $c66f + res SUBSTATUS_BIDE, [hl] + xor a + ld [EnemyFuryCutterCount], a ; $c680 + ld [$c681], a + ld [$c72c], a + ld hl, EnemySubStatus4 ; $c670 + res SUBSTATUS_RAGE, [hl] + xor a + ld [LastPlayerCounterMove], a ; $c6f9 + scf + ret + + +Function38170: ; 38170 + ld a, [OTPartyCount] + ld d, a + ld e, 0 + ld hl, OTPartyMon1Level + ld bc, OTPartyMon2 - OTPartyMon1 +.asm_3817c + ld a, [hl] + cp e + jr c, .asm_38181 + ld e, a +.asm_38181 + add hl, bc + dec d + jr nz, .asm_3817c + + ld a, [CurOTMon] + ld hl, OTPartyMon1Level + call AddNTimes + ld a, [hl] + cp e + jr nc, .asm_38194 + and a + ret + +.asm_38194 + scf + ret +; 38196 + +Unknown_38196: ; 39196 + dbw FULL_RESTORE, Function38208 + dbw MAX_POTION, Function38220 + dbw HYPER_POTION, Function38284 + dbw SUPER_POTION, Function38292 + dbw POTION, Function382a0 + dbw X_ACCURACY, Function382f9 + dbw FULL_HEAL, Function381be + dbw GUARD_SPEC, Function38305 + dbw DIRE_HIT, Function38311 + dbw X_ATTACK, Function3831d + dbw X_DEFEND, Function38329 + dbw X_SPEED, Function38335 + dbw X_SPECIAL, Function38341 + db $ff +; 381be + +Function381be: ; 381be + call Function381ca + jp c, Function38383 + call Function383a3 + jp Function38385 +; 381ca + +; known jump sources: 381be (e:41be), 38214 (e:4214) +Function381ca: ; 381ca (e:41ca) + ld a, [EnemyMonStatus] ; $d214 + and a + jp z, Function38383 + + ld a, [bc] + bit 6, a + jr nz, .asm_381e7 + ld a, [bc] + bit 4, a + jp nz, Function38385 + call Random + cp $32 + jp c, Function38385 + jp Function38383 + +.asm_381e7 + ld a, [EnemySubStatus5] + bit SUBSTATUS_TOXIC, a + jr z, .asm_381fd + ld a, [$c67c] + cp $4 + jr c, .asm_381fd + call Random + cp $80 + jp c, Function38385 +.asm_381fd + ld a, [EnemyMonStatus] + and 1 << FRZ | SLP + jp z, Function38383 + jp Function38385 +; 38208 + +Function38208: ; 38208 + call Function3822c + jp nc, Function3821a + ld a, [bc] + bit 6, a + jp z, Function38383 + call Function381ca + jp c, Function38383 + +; known jump sources: 3820b (e:420b) +Function3821a: ; 3821a (e:421a) + call Function383b5 + jp Function38385 +; 38220 + +Function38220: ; 38220 + call Function3822c + jp c, Function38383 + call Function383ae + jp Function38385 + +; known jump sources: 38208 (e:4208), 38220 (e:4220), 38284 (e:4284) +Function3822c: ; 3822c (e:422c) + ld a, [bc] + bit 6, a + jr nz, Function38267 + callab AICheckEnemyHalfHP + jp c, Function38383 + ld a, [bc] + bit 5, a + jp nz, Function38254 + callab AICheckEnemyQuarterHP + jp nc, Function38281 + call Random + cp $80 + jp c, Function38281 + jp Function38383 + +Function38254: ; 38254 (e:4254) + callab AICheckEnemyQuarterHP + jp c, Function38383 + call Random + cp $32 + jp c, Function38383 + jr Function38281 + +Function38267: ; 38267 (e:4267) + callab AICheckEnemyHalfHP + jp c, Function38383 + callab AICheckEnemyQuarterHP + jp nc, Function38281 + call Random + cp $32 + jp nc, Function38383 + +Function38281: ; 38281 (e:4281) + jp Function38385 +; 38284 + +Function38284: ; 38284 + call Function3822c + jp c, Function38383 + ld b, 200 + call Function383f4 + jp Function38385 +; 38292 (e:4292) + +Function38292: ; 38292 + call Function3822c + jp c, Function38383 + +Function38298: ; 38298 + ld b, 50 + call Function383ee + jp Function38385 +; 382a0 + +Function382a0: ; 382a0 + call Function3822c + jp c, Function38383 + ld b, 20 + call Function383e8 + jp Function38385 +; 382ae + +Function382ae: ; 382ae + callab AICheckEnemyMaxHP + jr c, .asm_382e4 + push bc + ld de, EnemyMonMaxHP + 1 + ld hl, EnemyMonHP + 1 + ld a, [de] + sub [hl] + jr z, .asm_382e7 + dec hl + dec de + ld c, a + sbc [hl] + and a + jr nz, .asm_382e7 + ld a, c + cp b + jp c, .asm_382d5 + callab AICheckEnemyQuarterHP + jr c, .asm_382e7 + +.asm_382d5 + pop bc + ld a, [bc] + bit 5, a + jp z, Function38385 + call Random + cp $80 + jp c, Function38385 + +.asm_382e4 + jp Function38383 + +.asm_382e7 + pop bc + ld a, [bc] + bit 5, a + jp z, Function38383 + call Random + cp $64 + jp c, Function38385 + jp Function38383 +; 382f9 + +Function382f9: ; 382f9 + call Function3834d + jp c, Function38383 + call Function384f7 + jp Function38385 +; 38305 + +Function38305: ; 38305 + call Function3834d + jp c, Function38383 + call Function38504 + jp Function38385 +; 38311 + +Function38311: ; 38311 + call Function3834d + jp c, Function38383 + call Function38511 + jp Function38385 +; 3831d (e:431d) + +Function3831d: ; 3831d + call Function3834d + jp c, Function38383 + call Function38541 + jp Function38385 +; 38329 + +Function38329: ; 38329 + call Function3834d + jp c, Function38383 + call Function38547 + jp Function38385 +; 38335 + +Function38335: ; 38335 + call Function3834d + jp c, Function38383 + call Function3854d + jp Function38385 +; 38341 + +Function38341: ; 38341 + call Function3834d + jp c, Function38383 + call Function38553 + jp Function38385 +; 3834d + +; known jump sources: 38311 (e:4311) +Function3834d: ; 3834d (e:434d) + ld a, [EnemyTurnsTaken] ; $c6dc + and a + jr nz, .asm_38372 + ld a, [bc] + bit 4, a + jp nz, Function38385 + call Random + cp $80 + jp c, Function38383 + ld a, [bc] + bit 6, a + jp nz, Function38385 + call Random + cp $80 + jp c, Function38383 + jp Function38385 +.asm_38372 + ld a, [bc] + bit 4, a + jp z, Function38383 + call Random + cp $32 + jp nc, Function38383 + jp Function38385 + +Function38383: ; 38383 (e:4383) + scf + ret + +Function38385: ; 38385 (e:4385) + and a + ret + + +Function38387: ; 38387 + call UpdateEnemyMonInParty + callba UpdateEnemyHUD + ld a, $1 + ld [hBGMapMode], a + ld hl, $c6e6 + dec [hl] + scf + ret +; 3839a + +Function3839a: ; 3839a + push de + ld de, SFX_FULL_HEAL + call PlaySFX + pop de + ret +; 383a3 + + +; known jump sources: 381c4 (e:41c4) +Function383a3: ; 383a3 (e:43a3) + call Function3839a + call Function384e0 + ld a, FULL_HEAL + jp Function38568 + +; known jump sources: 38226 (e:4226) +Function383ae: ; 383ae (e:43ae) + ld a, $f + ld [$d1f1], a + jr asm_383c6 + +; known jump sources: 3821a (e:421a) +Function383b5: ; 383b5 (e:43b5) + call Function384e0 + ld a, $e + ld [$d1f1], a + ld hl, EnemySubStatus3 ; $c66f + res SUBSTATUS_CONFUSED, [hl] + xor a + ld [EnemyConfuseCount], a ; $c67b +asm_383c6: ; 383c6 (e:43c6) + ld de, $d1ec + ld hl, EnemyMonHP + 1 ; $d217 + ld a, [hld] + ld [de], a + inc de + ld a, [hl] + ld [de], a + inc de + ld hl, EnemyMonMaxHP + 1 ; $d219 + ld a, [hld] + ld [de], a + inc de + ld [Buffer1], a ; $d1ea (aliases: MagikarpLength) + ld [EnemyMonHP + 1], a ; $d217 + ld a, [hl] + ld [de], a + ld [Buffer2], a ; $d1eb (aliases: MovementType) + ld [EnemyMonHP], a ; $d216 (aliases: EnemyMonHP) + jr asm_38436 +; 383e8 (e:43e8) + +Function383e8: ; 383e8 + ld a, POTION + ld b, 20 + jr Function383f8 + +Function383ee: ; 383ee + ld a, SUPER_POTION + ld b, 50 + jr Function383f8 + +; known jump sources: 3828c (e:428c) +Function383f4: ; 383f4 (e:43f4) + ld a, HYPER_POTION + ld b, 200 + +Function383f8: ; 383f8 + ld [$d1f1], a + ld hl, EnemyMonHP + 1 ; $d217 + ld a, [hl] + ld [$d1ec], a + add b + ld [hld], a + ld [$d1ee], a + ld a, [hl] + ld [$d1ed], a + ld [$d1ef], a + jr nc, .asm_38415 + inc a + ld [hl], a + ld [$d1ef], a +.asm_38415 + inc hl + ld a, [hld] + ld b, a + ld de, EnemyMonMaxHP + 1 ; $d219 + ld a, [de] + dec de + ld [Buffer1], a ; $d1ea (aliases: MagikarpLength) + sub b + ld a, [hli] + ld b, a + ld a, [de] + ld [Buffer2], a ; $d1eb (aliases: MovementType) + sbc b + jr nc, asm_38436 + inc de + ld a, [de] + dec de + ld [hld], a + ld [$d1ee], a + ld a, [de] + ld [hl], a + ld [$d1ef], a +asm_38436: ; 38436 (e:4436) + call Function38571 + hlcoord 2, 2 + xor a + ld [$d10a], a + call Function3839a + predef Functionc6e0 + jp Function38387 + + +Function3844b: ; 3844b + ld a, [OTPartyCount] + ld c, a + ld hl, OTPartyMon1HP + ld d, 0 +.asm_38454 + ld a, [hli] + ld b, a + ld a, [hld] + or b + jr z, .asm_3845b + inc d + +.asm_3845b + push bc + ld bc, PartyMon2 - PartyMon1 + add hl, bc + pop bc + dec c + jr nz, .asm_38454 + ld a, d + cp $2 + jp nc, Function3846c + and a + ret +; 3846c + +Function3846c: ; 3846c + ld a, $1 + ld [$c711], a + ld [$c70f], a + ld hl, EnemySubStatus4 + res SUBSTATUS_RAGE, [hl] + xor a + ld [hBattleTurn], a + callab Function3dc5b + push af + ld a, [CurOTMon] + ld hl, OTPartyMon1Status + ld bc, PartyMon2 - PartyMon1 + call AddNTimes + ld d, h + ld e, l + ld hl, EnemyMonStatus + ld bc, $0004 + call CopyBytes + pop af + jr c, .asm_384a3 + ld hl, UnknownText_0x384d0 + call PrintText + +.asm_384a3 + ld a, $1 + ld [$d264], a + callab NewEnemyMonStatus + callab ResetEnemyStatLevels + ld hl, PlayerSubStatus1 + res SUBSTATUS_IN_LOVE, [hl] + callba Function3d4e1 + callba Function3d57a + xor a + ld [$d264], a + ld a, [InLinkBattle] + and a + ret nz + scf + ret +; 384d0 + +UnknownText_0x384d0: ; 384d0 + text_jump UnknownText_0x1bcf9c + db "@" +; 384d5 + +Function384d5: ; 384d5 + call Function3839a + call Function384e0 + ld a, X_SPEED + jp Function38568 +; 384e0 + +Function384e0: ; 384e0 + ld a, [CurOTMon] + ld hl, OTPartyMon1Status + ld bc, PartyMon2 - PartyMon1 + call AddNTimes + xor a + ld [hl], a + ld [EnemyMonStatus], a + ld hl, EnemySubStatus5 + res SUBSTATUS_TOXIC, [hl] + ret +; 384f7 + +Function384f7: ; 384f7 + call Function3839a + ld hl, EnemySubStatus4 + set SUBSTATUS_UNLEASH, [hl] + ld a, X_ACCURACY + jp Function38568 +; 38504 + +Function38504: ; 38504 + call Function3839a + ld hl, EnemySubStatus4 + set SUBSTATUS_MIST, [hl] + ld a, GUARD_SPEC + jp Function38568 +; 38511 + +Function38511: ; 38511 + call Function3839a + ld hl, EnemySubStatus4 + set SUBSTATUS_FOCUS_ENERGY, [hl] + ld a, DIRE_HIT + jp Function38568 +; 3851e + +Function3851e: ; 3851e + ld [hMultiplier], a + ld hl, EnemyMonMaxHP + ld a, [hli] + ld [hProduct], a + ld a, [hl] + ld [hMultiplicand], a + ld b, $2 + call Divide + ld a, [$ffb6] + ld c, a + ld a, [$ffb5] + ld b, a + ld hl, EnemyMonHP + 1 + ld a, [hld] + ld e, a + ld a, [hl] + ld d, a + ld a, d + sub b + ret nz + ld a, e + sub c + ret +; 38541 + +Function38541: ; 38541 + ld b, ATTACK + ld a, X_ATTACK + jr Function38557 +; 38547 + +Function38547: ; 38547 + ld b, DEFENSE + ld a, X_DEFEND + jr Function38557 +; 3854d + +Function3854d: ; 3854d + ld b, SPEED + ld a, X_SPEED + jr Function38557 +; 38553 + +Function38553: ; 38553 + ld b, SP_ATTACK + ld a, X_SPECIAL + +Function38557 + ld [$d1f1], a + push bc + call Function38571 + pop bc + callba Function361ef + jp Function38387 +; 38568 + + +Function38568: ; 38568 + ld [$d1f1], a + call Function38571 + jp Function38387 +; 38571 + +Function38571: ; 38571 + ld a, [$d1f1] + ld [$d265], a + call GetItemName + ld hl, StringBuffer1 + ld de, $d050 + ld bc, $000d + call CopyBytes + ld hl, UnknownText_0x3858c + jp PrintText +; 3858c + +UnknownText_0x3858c: ; 3858c + text_jump UnknownText_0x1bcfaf + db "@" +; 38591 diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm index 19c652370..7ea1ec8fe 100644 --- a/battle/ai/scoring.asm +++ b/battle/ai/scoring.asm @@ -16,7 +16,7 @@ AIScoring_RedStatus: ; 38591 inc de call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld c, a push hl @@ -28,7 +28,7 @@ AIScoring_RedStatus: ; 38591 pop hl jr nz, .discourage - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] push hl push de push bc @@ -82,7 +82,7 @@ AIScoring_RedStatMods: ; 385e0 inc de call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp EFFECT_ATTACK_UP jr c, .checkmove @@ -119,7 +119,7 @@ AIScoring_RedStatMods: ; 385e0 jr nz, .discourage .encourage - call Function_0x39527 + call Function39527 jr c, .checkmove dec [hl] @@ -173,7 +173,7 @@ AIScoring_RedSuperEffective: ; 38635 jr c, .noteffective ; effective - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .checkmove dec [hl] @@ -185,7 +185,7 @@ AIScoring_RedSuperEffective: ; 38635 push hl push de push bc - ld a, [EnemyMoveType] + ld a, [wEnemyMoveStruct + MOVE_TYPE] ld d, a ld hl, EnemyMonMoves ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 @@ -199,10 +199,10 @@ AIScoring_RedSuperEffective: ; 38635 jr z, .asm_38693 call AIGetEnemyMove - ld a, [EnemyMoveType] + ld a, [wEnemyMoveStruct + MOVE_TYPE] cp d jr z, .checkmove2 - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr nz, .asm_38692 jr .checkmove2 @@ -244,7 +244,7 @@ AIScoring_Offensive: ; 386a2 inc de call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr nz, .checkmove @@ -275,7 +275,7 @@ AIScoring_Smart: ; 386be push hl call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld hl, .table_386f2 ld de, 3 call IsInArray @@ -398,7 +398,7 @@ AIScoring_Sleep: ; 387e3 ret nc .asm_387f0 - call Function_0x39527 + call Function39527 ret c dec [hl] dec [hl] @@ -421,7 +421,7 @@ AIScoring_LeechHit: ; 387f7 call AICheckEnemyMaxHP ret c - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -439,41 +439,34 @@ AIScoring_LeechHit: ; 387f7 AIScoring_LockOn: ; 3881d ld a, [PlayerSubStatus5] - bit 5, a + bit SUBSTATUS_LOCK_ON, a jr nz, .asm_38882 push hl call AICheckEnemyQuarterHP - jr nc, .asm_38877 call AICheckEnemyHalfHP - jr c, .asm_38834 call AICompareSpeed - jr nc, .asm_38877 - .asm_38834 ld a, [PlayerEvaLevel] cp $a jr nc, .asm_3887a - cp $8 jr nc, .asm_38875 ld a, [EnemyAccLevel] cp $5 jr c, .asm_3887a - cp $7 jr c, .asm_38875 ld hl, EnemyMonMoves ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 - .asm_3884f dec c jr z, .asm_38877 @@ -484,24 +477,22 @@ AIScoring_LockOn: ; 3881d call AIGetEnemyMove - ld a, [EnemyMoveAccuracy] - cp $b4 + ld a, [wEnemyMoveStruct + MOVE_ACC] + cp 180 jr nc, .asm_3884f ld a, $1 ld [hBattleTurn], a + push hl push bc - callba Function347c8 - ld a, [$d265] cp $a pop bc pop hl jr c, .asm_3884f - .asm_38875 pop hl ret @@ -513,9 +504,9 @@ AIScoring_LockOn: ; 3881d .asm_3887a pop hl - call Function_0x39527 - + call Function39527 ret c + dec [hl] dec [hl] ret @@ -538,19 +529,17 @@ AIScoring_LockOn: ; 3881d inc de call AIGetEnemyMove - ld a, [EnemyMoveAccuracy] - cp $b4 + ld a, [wEnemyMoveStruct + MOVE_ACC] + cp 180 jr nc, .asm_3888b dec [hl] dec [hl] jr .asm_3888b - .asm_388a2 pop hl jp AIDiscourageMove - ; 388a6 @@ -602,19 +591,16 @@ AIScoring_EvasionUp: ; 388d4 jp nc, AIDiscourageMove call AICheckEnemyMaxHP - jr nc, .asm_388f2 ld a, [PlayerSubStatus5] - bit 0, a + bit SUBSTATUS_TOXIC, a jr nz, .asm_388ef call Random - cp $b2 jr nc, .asm_38911 - .asm_388ef dec [hl] dec [hl] @@ -622,42 +608,34 @@ AIScoring_EvasionUp: ; 388d4 .asm_388f2 call AICheckEnemyQuarterHP - jr nc, .asm_3890f call Random - cp $a jr c, .asm_388ef call AICheckEnemyHalfHP - jr nc, .asm_3890a - call Function_0x39521 - + call Function39521 jr c, .asm_388ef - jr .asm_38911 - .asm_3890a - call Function_0x39527 - + call Function39527 jr c, .asm_38911 - .asm_3890f inc [hl] inc [hl] .asm_38911 ld a, [PlayerSubStatus5] - bit 0, a + bit SUBSTATUS_TOXIC, a jr nz, .asm_38938 ld a, [PlayerSubStatus4] - bit 7, a + bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_38941 ld a, [EnemyEvaLevel] @@ -671,7 +649,7 @@ AIScoring_EvasionUp: ; 388d4 jr nz, .asm_388ef ld a, [PlayerSubStatus1] - bit 6, a + bit SUBSTATUS_ROLLOUT, a jr nz, .asm_388ef @@ -688,9 +666,9 @@ AIScoring_EvasionUp: ; 388d4 ret .asm_38941 - call Function_0x39527 - + call Function39527 ret c + dec [hl] ret ; 38947 @@ -706,7 +684,7 @@ AIScoring_AlwaysHit: ; 38947 ret c .asm_38954 - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -721,30 +699,29 @@ AIScoring_MirrorMove: ; 3895b jr nz, .asm_38968 call AICompareSpeed - ret nc - jp AIDiscourageMove + jp AIDiscourageMove .asm_38968 push hl ld hl, Table_0x39301 ld de, 1 call IsInArray - pop hl ret nc - call Function_0x39527 + call Function39527 ret c + dec [hl] call AICompareSpeed - ret nc - call Random + call Random cp $19 ret c + dec [hl] ret ; 38985 @@ -752,23 +729,19 @@ AIScoring_MirrorMove: ; 3895b AIScoring_AccuracyDown: ; 38985 call AICheckPlayerMaxHP - jr nc, .asm_389a0 call AICheckEnemyHalfHP - jr nc, .asm_389a0 ld a, [PlayerSubStatus5] - bit 0, a + bit SUBSTATUS_TOXIC, a jr nz, .asm_3899d call Random - cp $b2 jr nc, .asm_389bf - .asm_3899d dec [hl] dec [hl] @@ -776,42 +749,34 @@ AIScoring_AccuracyDown: ; 38985 .asm_389a0 call AICheckPlayerQuarterHP - jr nc, .asm_389bd call Random - cp $a jr c, .asm_3899d call AICheckPlayerHalfHP - jr nc, .asm_389b8 - call Function_0x39521 - + call Function39521 jr c, .asm_3899d - jr .asm_389bf - .asm_389b8 - call Function_0x39527 - + call Function39527 jr c, .asm_389bf - .asm_389bd inc [hl] inc [hl] .asm_389bf ld a, [PlayerSubStatus5] - bit 0, a + bit SUBSTATUS_TOXIC, a jr nz, .asm_389e6 ld a, [PlayerSubStatus4] - bit 7, a + bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_389ef ld a, [EnemyEvaLevel] @@ -825,10 +790,9 @@ AIScoring_AccuracyDown: ; 38985 jr nz, .asm_3899d ld a, [PlayerSubStatus1] - bit 6, a + bit SUBSTATUS_ROLLOUT, a jr nz, .asm_3899d - .asm_389e4 inc [hl] ret @@ -842,9 +806,9 @@ AIScoring_AccuracyDown: ; 38985 ret .asm_389ef - call Function_0x39527 - + call Function39527 ret c + dec [hl] ret ; 389f5 @@ -862,7 +826,6 @@ AIScoring_Haze: ; 389f5 jr c, .asm_38a12 jr .asm_389fb - .asm_38a05 ld hl, PlayerAtkLevel ld c, $8 @@ -976,7 +939,7 @@ AIScoring_Bind: ; 38a71 jr nz, .asm_38a91 ld a, [PlayerSubStatus1] - and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ENCORED | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE + and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE jr nz, .asm_38a91 ld a, [PlayerTurnsTaken] @@ -984,7 +947,7 @@ AIScoring_Bind: ; 38a71 jr z, .asm_38a91 .asm_38a8b - call Function_0x39527 + call Function39527 ret c inc [hl] ret @@ -992,7 +955,7 @@ AIScoring_Bind: ; 38a71 .asm_38a91 call AICheckEnemyQuarterHP ret nc - call Function_0x39527 + call Function39527 ret c dec [hl] dec [hl] @@ -1022,7 +985,7 @@ AIScoring_Unused2B: ; 38a9c call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp EFFECT_PROTECT jr z, .asm_38ad5 dec c @@ -1081,14 +1044,14 @@ AIScoring_SpDefenseUp2: ; 38aed ret nc ld a, [BattleMonType1] - cp FIRE + cp SPECIAL jr nc, .asm_38b09 ld a, [BattleMonType2] - cp FIRE + cp SPECIAL ret c .asm_38b09 - call Function_0x39521 + call Function39521 ret c dec [hl] dec [hl] @@ -1128,14 +1091,14 @@ AIScoring_Paralyze: ; 38b26 ret c call AICheckEnemyQuarterHP ret nc - call Function_0x39521 + call Function39521 ret c dec [hl] dec [hl] ret .asm_38b3a - call Function_0x39527 + call Function39527 ret c inc [hl] ret @@ -1143,7 +1106,7 @@ AIScoring_Paralyze: ; 38b26 AIScoring_SpeedDownHit: ; 38b40 - ld a, [EnemyMoveAnimation] + ld a, [wEnemyMoveStruct + MOVE_ANIM] cp ICY_WIND ret nz call AICheckEnemyQuarterHP @@ -1174,7 +1137,7 @@ AIScoring_HyperBeam: ; 38b63 jr c, .asm_38b72 call AICheckEnemyQuarterHP ret c - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -1184,7 +1147,7 @@ AIScoring_HyperBeam: ; 38b63 cp 40 ret c inc [hl] - call Function_0x39527 + call Function39527 ret c inc [hl] ret @@ -1193,10 +1156,10 @@ AIScoring_HyperBeam: ; 38b63 AIScoring_Rage: ; 38b7f ld a, [EnemySubStatus4] - bit 6, a + bit SUBSTATUS_RAGE, a jr z, .asm_38b9b - call Function_0x39527 + call Function39527 jr c, .asm_38b8c dec [hl] @@ -1216,7 +1179,7 @@ AIScoring_Rage: ; 38b7f call AICheckEnemyHalfHP jr nc, .asm_38ba6 - call Function_0x39521 + call Function39521 ret nc dec [hl] ret @@ -1249,7 +1212,7 @@ AIScoring_Mimic: ; 38ba8 jr c, .asm_38bef jr z, .asm_38bd4 - call Function_0x39527 + call Function39527 jr c, .asm_38bd4 dec [hl] @@ -1263,7 +1226,7 @@ AIScoring_Mimic: ; 38ba8 pop hl ret nc - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -1291,12 +1254,12 @@ AIScoring_Counter: ; 38bf1 call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_38c0e - ld a, [EnemyMoveType] - cp $14 + ld a, [wEnemyMoveStruct + MOVE_TYPE] + cp SPECIAL jr nc, .asm_38c0e inc b @@ -1319,12 +1282,12 @@ AIScoring_Counter: ; 38bf1 call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_38c38 - ld a, [EnemyMoveType] - cp $14 + ld a, [wEnemyMoveStruct + MOVE_TYPE] + cp SPECIAL jr nc, .asm_38c38 @@ -1354,15 +1317,14 @@ AIScoring_Encore: ; 38c3b call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_38c68 push hl - ld a, [EnemyMoveType] + ld a, [wEnemyMoveStruct + MOVE_TYPE] ld hl, EnemyMonType1 - ld a, $41 - call Predef + predef Function347d3 pop hl ld a, [$d265] @@ -1433,7 +1395,7 @@ AIScoring_Encore: ; 38c3b AIScoring_PainSplit: ; 38ca4 push hl - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld b, [hl] inc hl ld c, [hl] @@ -1490,7 +1452,7 @@ AIScoring_Spite: ; 38cd5 call AICompareSpeed jp c, AIDiscourageMove - call Function_0x39527 + call Function39527 ret c inc [hl] ret @@ -1596,7 +1558,7 @@ AIScoring_HealBell: ; 38d1f .asm_38d48 and $27 ret z - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -1658,13 +1620,13 @@ AIScoring_Conversion2: ; 38d98 push hl dec a - ld hl, Moves + PlayerMoveType - PlayerMoveStruct - ld bc, Move2 - Move1 + ld hl, Moves + MOVE_TYPE + ld bc, MOVE_LENGTH call AddNTimes ld a, BANK(Moves) call GetFarByte - ld [PlayerMoveType], a + ld [wPlayerMoveStruct + MOVE_TYPE], a xor a ld [hBattleTurn], a @@ -1677,7 +1639,7 @@ AIScoring_Conversion2: ; 38d98 jr c, .asm_38dc9 ret z - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -1713,7 +1675,7 @@ AIScoring_Disable: ; 38dd1 ret .asm_38dee - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a ret nz @@ -1740,7 +1702,7 @@ AIScoring_MeanLook: ; 38dfb jr nz, .asm_38e26 ld a, [PlayerSubStatus1] - and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ENCORED | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE + and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE jr nz, .asm_38e26 push hl @@ -1755,7 +1717,7 @@ AIScoring_MeanLook: ; 38dfb ret .asm_38e26 - call Function_0x39521 + call Function39521 ret c dec [hl] dec [hl] @@ -1792,7 +1754,7 @@ AICheckLastPlayerMon: ; 38e2e AIScoring_Nightmare: ; 38e4a - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -1832,12 +1794,12 @@ AIScoring_Curse: ; 38e5c ld a, [BattleMonType1] cp GHOST jr z, .asm_38e92 - cp FIRE + cp SPECIAL ret nc ld a, [BattleMonType2] - cp FIRE + cp SPECIAL ret nc - call Function_0x39521 + call Function39521 ret c dec [hl] dec [hl] @@ -1892,7 +1854,7 @@ AIScoring_Curse: ; 38e5c ret nz .asm_38ecb - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -1928,7 +1890,7 @@ AIScoring_Protect: ; 38ed2 bit SUBSTATUS_CURSE, a jr nz, .asm_38f0d - bit SUBSTATUS_ENCORED, a + bit SUBSTATUS_ROLLOUT, a jr z, .asm_38f14 ld a, [PlayerRolloutCount] @@ -1936,7 +1898,7 @@ AIScoring_Protect: ; 38ed2 jr c, .asm_38f14 .asm_38f0d - call Function_0x39521 + call Function39521 ret c dec [hl] ret @@ -1992,7 +1954,7 @@ AIScoring_PerishSong: ; 38f4a jr c, .asm_38f75 ld a, [PlayerSubStatus5] - bit 7, a + bit SUBSTATUS_CANT_RUN, a jr nz, .asm_38f6f push hl @@ -2002,16 +1964,16 @@ AIScoring_PerishSong: ; 38f4a pop hl ret c - call Function_0x39527 + call Function39527 ret c inc [hl] ret .asm_38f6f - call Function_0x39527 - + call Function39527 ret c + dec [hl] ret @@ -2043,7 +2005,7 @@ AIScoring_Sandstorm: ; 38f7a call AICheckPlayerHalfHP jr nc, .asm_38fa6 - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -2079,7 +2041,7 @@ AIScoring_Endure: ; 38fac call AIHasMove jr nc, .asm_38fcb - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2091,7 +2053,7 @@ AIScoring_Endure: ; 38fac ld a, [EnemySubStatus5] bit SUBSTATUS_LOCK_ON, a ret z - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -2161,7 +2123,7 @@ AIScoring_Rollout: ; 38fef ret .asm_39020 - call Function_0x39521 + call Function39521 ret c inc [hl] ret @@ -2172,14 +2134,14 @@ AIScoring_Swagger: AIScoring_Attract: ; 39026 ld a, [PlayerTurnsTaken] and a - jr z, .asm_39032 + jr z, .first_turn - call Function_0x39521 + call Function39521 ret c inc [hl] ret -.asm_39032 +.first_turn call Random cp 200 ret nc @@ -2191,7 +2153,7 @@ AIScoring_Attract: ; 39026 AIScoring_Safeguard: ; 3903a call AICheckPlayerHalfHP ret c - call Function_0x39521 + call Function39521 ret c inc [hl] ret @@ -2206,7 +2168,7 @@ AIScoring_Earthquake: ; 39044 ld a, [PlayerSubStatus3] bit SUBSTATUS_UNDERGROUND, a - jr z, .asm_39058 + jr z, .could_dig call AICompareSpeed ret nc @@ -2214,10 +2176,12 @@ AIScoring_Earthquake: ; 39044 dec [hl] ret -.asm_39058 +.could_dig + ; Try to predict if the player + ; will use Dig this turn. call AICompareSpeed ret c - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -2239,13 +2203,13 @@ AIScoring_BatonPass: ; 39062 AIScoring_Pursuit: ; 39072 call AICheckPlayerQuarterHP jr nc, .asm_3907d - call Function_0x39521 + call Function39521 ret c inc [hl] ret .asm_3907d - call Function_0x39527 + call Function39527 ret c dec [hl] dec [hl] @@ -2267,7 +2231,7 @@ AIScoring_RapidSpin: ; 39084 ret z .asm_39097 - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2289,7 +2253,7 @@ AIScoring_HiddenPower: ; 3909e jr c, .asm_390c9 ld a, d - cp $32 + cp 50 jr c, .asm_390c9 ld a, [$d265] @@ -2297,7 +2261,7 @@ AIScoring_HiddenPower: ; 3909e jr nc, .asm_390c7 ld a, d - cp $46 + cp 70 ret c .asm_390c7 @@ -2372,7 +2336,7 @@ AIScoring_WeatherMove: ; 3910d call AICheckPlayerHalfHP jr nc, AIBadWeatherType - call Function_0x39527 + call Function39527 ret c dec [hl] @@ -2476,7 +2440,7 @@ AIScoring_PsychUp: ; 39152 ld a, [EnemyEvaLevel] cp $8 ret nc - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2502,12 +2466,12 @@ AIScoring_MirrorCoat: ; 3918b call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_391a8 - ld a, [EnemyMoveType] - cp FIRE + ld a, [wEnemyMoveStruct + MOVE_TYPE] + cp SPECIAL jr c, .asm_391a8 inc b @@ -2530,12 +2494,12 @@ AIScoring_MirrorCoat: ; 3918b call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .asm_391d2 - ld a, [EnemyMoveType] - cp FIRE + ld a, [wEnemyMoveStruct + MOVE_TYPE] + cp SPECIAL jr c, .asm_391d2 @@ -2574,7 +2538,7 @@ AIScoring_Gust: ; 391d5 .asm_391e9 call AICompareSpeed ret c - call Function_0x39527 + call Function39527 ret c dec [hl] ret @@ -2600,7 +2564,7 @@ AIScoring_Stomp: ; 39200 and a ret z - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2625,7 +2589,7 @@ AIScoring_Solarbeam: ; 3920b ret .asm_3921e - call Function_0x39521 + call Function39521 ret c dec [hl] @@ -2650,13 +2614,13 @@ AIScoring_Thunder: ; 39225 AICompareSpeed: ; 39233 push bc - ld a, [EnemyMonSpd + 1] + ld a, [EnemyMonSpeed + 1] ld b, a - ld a, [BattleMonSpd + 1] + ld a, [BattleMonSpeed + 1] cp b - ld a, [EnemyMonSpd] + ld a, [EnemyMonSpeed] ld b, a - ld a, [BattleMonSpd] + ld a, [BattleMonSpeed] sbc b pop bc ret @@ -2677,8 +2641,8 @@ AICheckEnemyMaxHP: ; 39251 push hl push de push bc - ld de, EnemyMonHPHi - ld hl, EnemyMonMaxHPHi + ld de, EnemyMonHP + ld hl, EnemyMonMaxHP ; fallthrough ; 3925a @@ -2733,7 +2697,7 @@ AICheckEnemyHalfHP: ; 39281 push hl push de push bc - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld b, [hl] inc hl ld c, [hl] @@ -2756,7 +2720,7 @@ AICheckEnemyQuarterHP: ; 39298 push hl push de push bc - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld b, [hl] inc hl ld c, [hl] @@ -2811,7 +2775,7 @@ AIHasMove: ; 392ca call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp b jr z, .asm_392e3 @@ -2898,7 +2862,7 @@ AIScoring_Opportunist: ; 39315 call AICheckEnemyQuarterHP jr nc, .asm_39322 - call Function_0x39527 + call Function39527 ret c .asm_39322 @@ -2992,7 +2956,7 @@ AIScoring_Aggressive: ; 39369 push de push bc call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .nodamage call AIDamageCalc @@ -3043,14 +3007,14 @@ AIScoring_Aggressive: ; 39369 call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] cp 2 jr c, .checkmove2 push hl push de push bc - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld hl, .aggressivemoves ld de, 1 call IsInArray @@ -3077,7 +3041,7 @@ AIScoring_Aggressive: ; 39369 AIDamageCalc: ; 393e7 ld a, 1 ld [hBattleTurn], a - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld de, 1 ld hl, .ConstantDamageEffects call IsInArray @@ -3175,7 +3139,7 @@ AIScoring_StatusImmunity: ; 39453 inc de call AIGetEnemyMove - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp EFFECT_TOXIC jr z, .poisonimmunity cp EFFECT_POISON @@ -3185,7 +3149,7 @@ AIScoring_StatusImmunity: ; 39453 cp EFFECT_PARALYZE jr z, .typeimmunity - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .checkmove @@ -3242,12 +3206,12 @@ AIScoring_Risky: ; 394a9 push hl call AIGetEnemyMove - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] and a jr z, .nextmove ; Don't use risky moves at max hp. - ld a, [EnemyMoveEffect] + ld a, [wEnemyMoveStruct + MOVE_EFFECT] ld de, 1 ld hl, .riskymoves call IsInArray @@ -3314,10 +3278,10 @@ AIGetEnemyMove: ; 39508 push bc dec a ld hl, Moves - ld bc, Move2 - Move1 + ld bc, MOVE_LENGTH call AddNTimes - ld de, EnemyMoveStruct + ld de, wEnemyMoveStruct ld a, BANK(Moves) call FarCopyBytes @@ -3328,14 +3292,14 @@ AIGetEnemyMove: ; 39508 ; 39521 -Function_0x39521: ; 39521 +Function39521: ; 39521 call Random cp 50 ; 1/5 ret ; 39527 -Function_0x39527: ; 39527 +Function39527: ; 39527 call Random cp $80 ; 1/2 ret diff --git a/battle/anim_commands.asm b/battle/anim_commands.asm index 9f26e8f94..f8f4a26ce 100644 --- a/battle/anim_commands.asm +++ b/battle/anim_commands.asm @@ -954,22 +954,18 @@ BattleAnimCmd_DC: ; cc5dc (33:45dc) ld a, [TempBattleMonSpecies] ; $d205 ld [CurPartySpecies], a ; $d108 ld hl, BattleMonDVs ; $c632 - ld a, PREDEF_GET_UNOWN_LETTER - call Predef + predef GetUnownLetter ld de, $8000 - ld a, $3c - call Predef + predef GetFrontpic jr .done .player ld a, [TempEnemyMonSpecies] ; $d204 ld [CurPartySpecies], a ; $d108 ld hl, EnemyMonDVs ; $d20c - ld a, PREDEF_GET_UNOWN_LETTER - call Predef + predef GetUnownLetter ld de, $8000 - ld a, $3d - call Predef + predef GetBackpic .done pop af @@ -1194,20 +1190,16 @@ BattleAnimCmd_E6: ; cc776 (33:4776) jr z, .player ld hl, BattleMonDVs ; $c632 - ld a, PREDEF_GET_UNOWN_LETTER - call Predef + predef GetUnownLetter ld de, $9000 - ld a, $3c - call Predef + predef GetFrontpic jr .done .player ld hl, EnemyMonDVs ; $d20c - ld a, PREDEF_GET_UNOWN_LETTER - call Predef + predef GetUnownLetter ld de, $9310 - ld a, $3d - call Predef + predef GetBackpic .done pop af diff --git a/battle/core.asm b/battle/core.asm index 6cb19b7d6..5503d307d 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -12,8 +12,8 @@ Function3c000: ; 3c000 inc a ld [$d264], a ld hl, OTPartyMon1HP - ld bc, $002f - ld d, $3 + ld bc, OTPartyMon2 - (OTPartyMon1 + 1) + ld d, NUM_MOVES - 1 .asm_3c019 inc d ld a, [hli] @@ -24,7 +24,7 @@ Function3c000: ; 3c000 .asm_3c021 ld a, d - ld [$d430], a + ld [wBattleAction], a ld a, [InLinkBattle] and a jr z, .asm_3c031 @@ -57,9 +57,9 @@ Function3c000: ; 3c000 call Function30b4 ld a, [BattleType] cp $2 - jp z, Function3c0e2 - cp $3 - jp z, Function3c0e2 + jp z, .asm_3c0e2 + cp BATTLETYPE_TUTORIAL + jp z, .asm_3c0e2 xor a ld [CurPartyMon], a .asm_3c06b @@ -114,10 +114,9 @@ Function3c000: ; 3c000 .asm_3c0df jp Function3c12f -; 3c0e2 -Function3c0e2: ; 3c0e2 - jp Function3e139 +.asm_3c0e2 + jp BattleMenu ; 3c0e5 @@ -162,69 +161,75 @@ Function3c0e5: ; 3c0e5 ; 3c12f Function3c12f: ; 3c12f +.loop call Function3c1bf call Function3c3f5 - jp c, .asm_3c1be + jp c, .quit + xor a - ld [$c710], a - ld [$c711], a + ld [wPlayerIsSwitching], a + ld [wEnemyIsSwitching], a ld [$d264], a ld [$c73f], a ld [$c740], a ld [CurDamage], a - ld [$d257], a + ld [CurDamage + 1], a + call Function3c27c call UpdateBattleMonInParty callba AIChooseMove - call Function3d2f1 - jr nz, .asm_3c174 + + call IsMobileBattle + jr nz, .not_disconnected callba Function100da5 callba Function100641 callba Function100dd8 - jp c, .asm_3c1be + jp c, .quit +.not_disconnected -.asm_3c174 call Function3c410 jr c, .asm_3c18a .asm_3c179 - call Function3e139 - jr c, .asm_3c1be + call BattleMenu + jr c, .quit ld a, [BattleEnded] and a - jr nz, .asm_3c1be - ld a, [$d232] + jr nz, .quit + ld a, [$d232] ; roared/whirlwinded/teleported and a - jr nz, .asm_3c1be - + jr nz, .quit .asm_3c18a call Function3c434 jr nz, .asm_3c179 + call Function3c300 - jr c, .asm_3c1be + jr c, .quit + call Function3c314 jr c, .asm_3c19e call Function3c5fe jr .asm_3c1a1 - .asm_3c19e call Function3c664 - .asm_3c1a1 call Function3d2e0 - jr c, .asm_3c1be + jr c, .quit + ld a, [$d232] and a - jr nz, .asm_3c1be + jr nz, .quit + ld a, [BattleEnded] and a - jr nz, .asm_3c1be + jr nz, .quit + call Function3c1d6 ld a, [BattleEnded] and a - jr nz, .asm_3c1be - jp Function3c12f + jr nz, .quit + jp .loop -.asm_3c1be +.quit ret ; 3c1bf @@ -302,7 +307,7 @@ Function3c1d6: ; 3c1d6 ; 3c23c Function3c23c: ; 3c23c - call Function3c710 + call HasPlayerFainted jr nz, .asm_3c24a call Function3d14e ld a, [BattleEnded] @@ -310,7 +315,7 @@ Function3c23c: ; 3c23c jr nz, .asm_3c25a .asm_3c24a - call Function3c70b + call HasEnemyFainted jr nz, .asm_3c258 call Function3cd55 ld a, [BattleEnded] @@ -327,7 +332,7 @@ Function3c23c: ; 3c23c ; 3c25c Function3c25c: ; 3c25c - call Function3c70b + call HasEnemyFainted jr nz, .asm_3c26a call Function3cd55 ld a, [BattleEnded] @@ -335,7 +340,7 @@ Function3c25c: ; 3c25c jr nz, .asm_3c27a .asm_3c26a - call Function3c710 + call HasPlayerFainted jr nz, .asm_3c278 call Function3d14e ld a, [BattleEnded] @@ -397,11 +402,11 @@ Function3c27c: ; 3c27c xor a ld [hl], a ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr push af set SUBSTATUS_CONFUSED, [hl] ld a, BATTLE_VARS_MOVE_ANIM - call _GetBattleVar + call GetBattleVarAddr push hl push af xor a @@ -421,9 +426,9 @@ Function3c27c: ; 3c27c 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 +437,7 @@ Function3c300: ; 3c300 ld a, [InLinkBattle] and a jr z, .asm_3c30d - ld a, [$d430] + ld a, [wBattleAction] cp $f jr z, .asm_3c30f @@ -450,12 +455,12 @@ Function3c314: ; 3c314 ld a, [InLinkBattle] and a jr z, .asm_3c35b - ld a, [$d430] + ld a, [wBattleAction] cp $e jr z, .asm_3c35b cp $d jr z, .asm_3c35b - sub $4 + sub NUM_MOVES jr c, .asm_3c35b ld a, [$d0ec] cp $2 @@ -496,10 +501,10 @@ Function3c314: ; 3c314 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 +513,7 @@ Function3c314: ; 3c314 .asm_3c391 ld a, b - cp $4a + cp HELD_QUICK_CLAW jr nz, .asm_3c3c5 call BattleRandom cp c @@ -537,8 +542,8 @@ Function3c314: ; 3c314 jr .asm_3c3c5 .asm_3c3c5 - ld de, BattleMonSpd - ld hl, EnemyMonSpd + ld de, BattleMonSpeed + ld hl, EnemyMonSpeed ld c, $2 call StringCmp jr z, .asm_3c3d8 @@ -570,7 +575,7 @@ Function3c3f3: ; 3c3f3 Function3c3f5: ; 3c3f5 ld a, [BattleType] - cp $6 + cp BATTLETYPE_CONTEST jr nz, .asm_3c40e ld a, [$dc79] and a @@ -589,23 +594,26 @@ Function3c3f5: ; 3c3f5 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_RAMPAGE + jp nz, .quit + ld hl, PlayerSubStatus1 - bit 6, [hl] - jp nz, Function3c432 + bit SUBSTATUS_ROLLOUT, [hl] + jp nz, .quit + and a ret -; 3c432 -Function3c432: ; 3c432 +.quit scf ret ; 3c434 @@ -614,7 +622,7 @@ Function3c434: ; 3c434 call Function3c410 jp c, .asm_3c4ba ld hl, PlayerSubStatus5 - bit 4, [hl] + bit SUBSTATUS_ENCORED, [hl] jr z, .asm_3c449 ld a, [LastPlayerMove] ld [CurPlayerMove], a @@ -627,18 +635,18 @@ Function3c434: ; 3c434 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 call Function30b4 call UpdateBattleHuds ld a, [CurPlayerMove] - cp $a5 + cp STRUGGLE jr z, .asm_3c476 call PlayClickSFX @@ -653,26 +661,26 @@ Function3c434: ; 3c434 callab UpdateMoveData xor a ld [$c732], a - ld a, [PlayerMoveEffect] - cp $77 + ld a, [wPlayerMoveStruct + MOVE_EFFECT] + cp EFFECT_FURY_CUTTER jr z, .asm_3c494 xor a ld [PlayerFuryCutterCount], a .asm_3c494 - ld a, [PlayerMoveEffect] - cp $51 + ld a, [wPlayerMoveStruct + MOVE_EFFECT] + cp EFFECT_RAGE jr z, .asm_3c4a4 ld hl, PlayerSubStatus4 - res 6, [hl] + res SUBSTATUS_RAGE, [hl] xor a ld [$c72b], a .asm_3c4a4 - ld a, [PlayerMoveEffect] - cp $6f + ld a, [wPlayerMoveStruct + MOVE_EFFECT] + cp EFFECT_PROTECT jr z, .asm_3c4c9 - cp $74 + cp EFFECT_ENDURE jr z, .asm_3c4c9 xor a ld [PlayerProtectCount], a @@ -680,7 +688,7 @@ Function3c434: ; 3c434 .asm_3c4b5 ld hl, PlayerSubStatus3 - res 0, [hl] + res SUBSTATUS_BIDE, [hl] .asm_3c4ba xor a @@ -688,7 +696,7 @@ Function3c434: ; 3c434 ld [PlayerProtectCount], a ld [$c72b], a ld hl, PlayerSubStatus4 - res 6, [hl] + res SUBSTATUS_RAGE, [hl] .asm_3c4c9 call Function3e7c1 @@ -701,7 +709,7 @@ Function3c434: ; 3c434 ld [PlayerProtectCount], a ld [$c72b], a ld hl, PlayerSubStatus4 - res 6, [hl] + res SUBSTATUS_RAGE, [hl] xor a ret ; 3c4df @@ -717,16 +725,16 @@ Function3c4df: ; 3c4df call .asm_3c518 .asm_3c4ed ld hl, PlayerSubStatus5 - bit 4, [hl] + bit SUBSTATUS_ENCORED, [hl] ret z ld a, [PlayerEncoreCount] dec a ld [PlayerEncoreCount], a jr z, .asm_3c50a - ld hl, BattleMonPPMove1 + ld hl, BattleMonPP ld a, [CurMoveNum] ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] and $3f @@ -734,23 +742,23 @@ Function3c4df: ; 3c4df .asm_3c50a ld hl, PlayerSubStatus5 - res 4, [hl] + res SUBSTATUS_ENCORED, [hl] call SetEnemyTurn ld hl, BattleText_0x80c8a jp StdBattleTextBox .asm_3c518 ld hl, EnemySubStatus5 - bit 4, [hl] + bit SUBSTATUS_ENCORED, [hl] ret z ld a, [EnemyEncoreCount] dec a ld [EnemyEncoreCount], a jr z, .asm_3c535 - ld hl, EnemyMonPPMove1 + ld hl, EnemyMonPP ld a, [CurEnemyMoveNum] ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] and $3f @@ -758,7 +766,7 @@ Function3c4df: ; 3c4df .asm_3c535 ld hl, EnemySubStatus5 - res 4, [hl] + res SUBSTATUS_ENCORED, [hl] call SetPlayerTurn ld hl, BattleText_0x80c8a jp StdBattleTextBox @@ -771,7 +779,7 @@ Function3c543: ; 3c543 jr nz, .Stay ld a, [PlayerSubStatus5] - bit 7, a + bit SUBSTATUS_CANT_RUN, a jr nz, .Stay ld a, [$c731] @@ -915,7 +923,7 @@ GetMoveEffect: ; 3c5ec ld a, b dec a ld hl, Moves + MOVE_EFFECT - ld bc, Move2 - Move1 + ld bc, MOVE_LENGTH call AddNTimes ld a, BANK(Moves) call GetFarByte @@ -939,14 +947,14 @@ Function3c5fe: ; 3c5fe ld a, [$d232] and a ret nz - call Function3c710 + call HasPlayerFainted jp z, Function3d14e - call Function3c70b + call HasEnemyFainted jp z, Function3cd55 .asm_3c62f call SetEnemyTurn - call Function3c716 + call ResidualDamage jp z, Function3cd55 call RefreshBattleHuds call Function3c6cf @@ -955,12 +963,12 @@ Function3c5fe: ; 3c5fe ld a, [$d232] and a ret nz - call Function3c70b + call HasEnemyFainted jp z, Function3cd55 - call Function3c710 + call HasPlayerFainted jp z, Function3d14e call SetPlayerTurn - call Function3c716 + call ResidualDamage jp z, Function3d14e call RefreshBattleHuds xor a @@ -981,13 +989,13 @@ Function3c664: ; 3c664 ret nz call Function3d2e0 ret c - call Function3c70b + call HasEnemyFainted jp z, Function3cd55 - call Function3c710 + call HasPlayerFainted jp z, Function3d14e push bc call SetPlayerTurn - call Function3c716 + call ResidualDamage pop bc jp z, Function3d14e push bc @@ -1003,14 +1011,14 @@ Function3c664: ; 3c664 ld a, [$d232] and a ret nz - call Function3c710 + call HasPlayerFainted jp z, Function3d14e - call Function3c70b + call HasEnemyFainted jp z, Function3cd55 .asm_3c6be call SetEnemyTurn - call Function3c716 + call ResidualDamage jp z, Function3cd55 call RefreshBattleHuds xor a @@ -1033,32 +1041,32 @@ Function3c6de: ; 3c6de ; 3c6ed Function3c6ed: ; 3c6ed - ld a, $5 - call _GetBattleVar - res 2, [hl] - res 5, [hl] - ld a, $9 - call _GetBattleVar - res 6, [hl] + ld a, BATTLE_VARS_SUBSTATUS1_OPP + call GetBattleVarAddr + res SUBSTATUS_PROTECT, [hl] + res SUBSTATUS_ENDURE, [hl] + ld a, BATTLE_VARS_SUBSTATUS5_OPP + call GetBattleVarAddr + res SUBSTATUS_DESTINY_BOND, [hl] ret ; 3c6fe Function3c6fe: ; 3c6fe - ld a, $4 - call _GetBattleVar - res 6, [hl] + ld a, BATTLE_VARS_SUBSTATUS5 + call GetBattleVarAddr + res SUBSTATUS_DESTINY_BOND, [hl] ret ; 3c706 -Function3c706: ; 3c706 +HasUserFainted: ; 3c706 ld a, [hBattleTurn] and a - jr z, Function3c710 -Function3c70b: ; 3c70b - ld hl, EnemyMonHPHi + jr z, HasPlayerFainted +HasEnemyFainted: ; 3c70b + ld hl, EnemyMonHP jr Function3c713 -Function3c710: ; 3c710 +HasPlayerFainted: ; 3c710 ld hl, BattleMonHP Function3c713: ; 3c713 @@ -1067,108 +1075,121 @@ Function3c713: ; 3c713 ret ; 3c716 -Function3c716: ; 3c716 - call Function3c706 +ResidualDamage: ; 3c716 +; Return z if the user fainted before +; or as a result of residual damage. +; For Sandstorm damage, see HandleWeather. + + call HasUserFainted ret z - ld a, $a + + ld a, BATTLE_VARS_STATUS call GetBattleVar - and $18 - jr z, .asm_3c768 - ld hl, BattleText_0x807e2 - ld de, $0106 - and $10 - jr z, .asm_3c733 - ld hl, BattleText_0x807f8 - ld de, $0105 - -.asm_3c733 + and 1 << PSN | 1 << BRN + jr z, .did_psn_brn + + ld hl, HurtByPoisonText + ld de, ANIM_PSN + and 1 << BRN + jr z, .got_anim + ld hl, HurtByBurnText + ld de, ANIM_BRN +.got_anim + push de call StdBattleTextBox pop de + xor a ld [$cfca], a call Function3ee0f call GetEighthMaxHP - ld de, $c674 + ld de, PlayerToxicCount ld a, [hBattleTurn] and a jr z, .asm_3c74d - ld de, $c67c - + ld de, EnemyToxicCount .asm_3c74d - ld a, $4 + + ld a, BATTLE_VARS_SUBSTATUS5 call GetBattleVar - bit 0, a - jr z, .asm_3c765 - call Function3cc76 + bit SUBSTATUS_TOXIC, a + jr z, .did_toxic + call GetSixteenthMaxHP ld a, [de] inc a ld [de], a - ld hl, $0000 -.asm_3c75f + ld hl, 0 +.add add hl, bc dec a - jr nz, .asm_3c75f + jr nz, .add ld b, h ld c, l +.did_toxic -.asm_3c765 call Function3cc3f +.did_psn_brn -.asm_3c768 - call Function3c706 - jp z, .asm_3c7f7 - ld a, $3 - call _GetBattleVar - bit 7, [hl] + call HasUserFainted + jp z, .fainted + + ld a, BATTLE_VARS_SUBSTATUS4 + call GetBattleVarAddr + 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 ld [hBGMapMode], a call Function3ccef - ld hl, BattleText_0x8080e + ld hl, LeechSeedSapsText call StdBattleTextBox - .asm_3c7a1 - call Function3c706 - jr z, .asm_3c7f7 - ld a, $0 - call _GetBattleVar - bit 0, [hl] + + call HasUserFainted + jr z, .fainted + + ld a, BATTLE_VARS_SUBSTATUS1 + call GetBattleVarAddr + 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 - ld hl, BattleText_0x80822 + ld hl, HasANightmareText call StdBattleTextBox - .asm_3c7c5 - call Function3c706 - jr z, .asm_3c7f7 - ld a, $0 - call _GetBattleVar - bit 1, [hl] + + call HasUserFainted + jr z, .fainted + + ld a, BATTLE_VARS_SUBSTATUS1 + call GetBattleVarAddr + 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 - ld hl, BattleText_0x80836 + ld hl, HurtByCurseText call StdBattleTextBox .asm_3c7e9 @@ -1176,16 +1197,16 @@ Function3c716: ; 3c716 ld a, [hBattleTurn] and a jr z, .asm_3c7f4 - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP .asm_3c7f4 ld a, [hli] or [hl] ret nz -.asm_3c7f7 +.fainted call RefreshBattleHuds - ld c, $14 + ld c, 20 call DelayFrames xor a ret @@ -1212,21 +1233,21 @@ Function3c801: ; 3c801 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] ld [$d265], a push af - ld hl, BattleText_0x80864 + ld hl, PerishCountText call StdBattleTextBox pop af ret nz - ld a, $0 - call _GetBattleVar - res 4, [hl] + ld a, BATTLE_VARS_SUBSTATUS1 + call GetBattleVarAddr + res SUBSTATUS_PERISH, [hl] ld a, [hBattleTurn] and a jr nz, .asm_3c85c @@ -1243,7 +1264,7 @@ Function3c801: ; 3c801 ret .asm_3c85c - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP xor a ld [hli], a ld [hl], a @@ -1285,9 +1306,9 @@ Function3c874: ; 3c874 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 +1316,19 @@ Function3c874: ; 3c874 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 + predef PlayBattleAnim + call SwitchTurnCore .asm_3c8d3 - call Function3cc76 + call GetSixteenthMaxHP call Function3cc3f ld hl, BattleText_0x80de2 jr .asm_3c8e1 @@ -1320,9 +1340,9 @@ Function3c874: ; 3c874 jp StdBattleTextBox ; 3c8e4 -Function3c8e4: ; 3c8e4 +SwitchTurnCore: ; 3c8e4 ld a, [hBattleTurn] - xor $1 + xor 1 ld [hBattleTurn], a ret ; 3c8eb @@ -1352,7 +1372,7 @@ Function3c8eb: ; 3c8eb ld a, [hBattleTurn] and a jr z, .asm_3c922 - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP .asm_3c922 ld a, [hli] @@ -1367,8 +1387,8 @@ Function3c8eb: ; 3c8eb ret z .asm_3c92d - call Function3cc76 - call Function3c8e4 + call GetSixteenthMaxHP + call SwitchTurnCore call Function3ccef ld hl, BattleText_0x80880 jp StdBattleTextBox @@ -1390,14 +1410,14 @@ Function3c93c: ; 3c93c .asm_3c957 callab GetUserItem ld a, b - cp $6 + cp HELD_RESTORE_PP jr nz, .asm_3c9ae ld hl, PartyMon1PP ld a, [CurBattleMon] call GetPartyLocation ld d, h ld e, l - ld hl, PartyMon1Move1 + ld hl, PartyMon1Moves ld a, [CurBattleMon] call GetPartyLocation ld a, [hBattleTurn] @@ -1408,12 +1428,12 @@ Function3c93c: ; 3c93c ld a, [IsInBattle] dec a jr z, .asm_3c99b - ld hl, OTPartyMon1PPMove1 + ld hl, OTPartyMon1PP ld a, [CurOTMon] call GetPartyLocation ld d, h ld e, l - ld hl, OTPartyMon1Move1 + ld hl, OTPartyMon1Moves ld a, [CurOTMon] call GetPartyLocation @@ -1430,18 +1450,19 @@ Function3c93c: ; 3c93c inc de inc c ld a, c - cp $4 + cp NUM_MOVES jr nz, .asm_3c99d .asm_3c9ae ret .asm_3c9af + ; lousy hack ld a, [hl] - cp $a6 - ld b, $1 + cp SKETCH + ld b, 1 jr z, .asm_3c9b8 - ld b, $5 + ld b, 5 .asm_3c9b8 ld a, [de] @@ -1451,18 +1472,18 @@ Function3c93c: ; 3c93c push bc ld a, [hl] ld [$d265], a - ld de, BattleMonItem - ld hl, BattleMonPPMove1 + ld de, BattleMonMoves - 1 + ld hl, BattleMonPP ld a, [hBattleTurn] and a jr z, .asm_3c9d2 - ld de, EnemyMonItem - ld hl, EnemyMonPPMove1 + ld de, EnemyMonMoves - 1 + ld hl, EnemyMonPP .asm_3c9d2 inc de pop bc - ld b, $0 + ld b, 0 add hl, bc push hl ld h, d @@ -1480,7 +1501,7 @@ Function3c93c: ; 3c93c ld a, [EnemySubStatus5] .asm_3c9ee - bit 3, a + bit SUBSTATUS_TRANSFORMED, a jr nz, .asm_3c9f5 ld a, [de] add b @@ -1507,9 +1528,9 @@ Function3c93c: ; 3c93c .asm_3ca14 call GetItemName - call Function3c8e4 + call SwitchTurnCore call Function3ddc8 - call Function3c8e4 + call SwitchTurnCore ld hl, BattleText_0x80899 jp StdBattleTextBox ; 3ca26 @@ -1542,27 +1563,32 @@ Function3ca26: ; 3ca26 ld [hl], a cp $1 ret nz + ld hl, BattleText_0x808b6 call StdBattleTextBox - ld a, $10 - call _GetBattleVar + + ld a, BATTLE_VARS_MOVE + call GetBattleVarAddr push af - ld a, $f8 + ld a, FUTURE_SIGHT ld [hl], a + callab UpdateMoveData xor a ld [AttackMissed], a ld [AlreadyDisobeyed], a - ld a, $a + ld a, 10 ld [TypeModifier], a callab DoMove xor a ld [CurDamage], a - ld [$d257], a - ld a, $10 - call _GetBattleVar + ld [CurDamage + 1], a + + ld a, BATTLE_VARS_MOVE + call GetBattleVarAddr pop af ld [hl], a + call UpdateBattleMonInParty jp UpdateEnemyMonInParty ; 3ca8f @@ -1578,7 +1604,7 @@ Function3ca8f: ; 3ca8f call .asm_3cac9 .asm_3ca9d ld a, [BattleMonStatus] - bit 5, a + bit FRZ, a ret z ld a, [$c73f] and a @@ -1591,7 +1617,7 @@ Function3ca8f: ; 3ca8f ld a, [CurBattleMon] ld hl, PartyMon1Status call GetPartyLocation - ld [hl], $0 + ld [hl], 0 call UpdateBattleHuds call SetEnemyTurn ld hl, DefrostedOpponentText @@ -1599,7 +1625,7 @@ Function3ca8f: ; 3ca8f .asm_3cac9 ld a, [EnemyMonStatus] - bit 5, a + bit FRZ, a ret z ld a, [$c740] and a @@ -1609,15 +1635,16 @@ Function3ca8f: ; 3ca8f ret nc xor a ld [EnemyMonStatus], a + ld a, [IsInBattle] dec a jr z, .asm_3caef ld a, [CurOTMon] ld hl, OTPartyMon1Status call GetPartyLocation - ld [hl], $0 - + ld [hl], 0 .asm_3caef + call UpdateBattleHuds call SetPlayerTurn ld hl, DefrostedOpponentText @@ -1635,24 +1662,24 @@ Function3cafb: ; 3cafb call .asm_3cb1c .asm_3cb09 ld a, [PlayerScreens] - bit 2, a + bit SCREENS_SAFEGUARD, a ret z ld hl, $c701 dec [hl] ret nz - res 2, a + res SCREENS_SAFEGUARD, a ld [PlayerScreens], a xor a jr .asm_3cb2e .asm_3cb1c ld a, [EnemyScreens] - bit 2, a + bit SCREENS_SAFEGUARD, a ret z ld hl, $c705 dec [hl] ret nz - res 2, a + res SCREENS_SAFEGUARD, a ld [EnemyScreens], a ld a, $1 @@ -1676,7 +1703,7 @@ Function3cb36: ; 3cb36 .CheckPlayer call SetPlayerTurn ld de, .Your - call .asm_3cb6f + call .Copy ld hl, PlayerScreens ld de, PlayerLightScreenCount jr .FadeScreens @@ -1684,7 +1711,7 @@ Function3cb36: ; 3cb36 .CheckEnemy call SetEnemyTurn ld de, .Enemy - call .asm_3cb6f + call .Copy ld hl, EnemyScreens ld de, EnemyLightScreenCount @@ -1695,7 +1722,7 @@ Function3cb36: ; 3cb36 call nz, FadeReflect ret -.asm_3cb6f +.Copy ld hl, StringBuffer1 jp CopyName2 ; 3cb75 @@ -1734,37 +1761,37 @@ FadeReflect: ; 3cb91 ; 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 @@ -1773,10 +1800,9 @@ HandleWeather: ; 3cb9e 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 @@ -1793,26 +1819,26 @@ HandleWeather: ; 3cb9e 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 - ld hl, BattleText_0x8084d + ld hl, SandstormHitsText 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 @@ -1846,15 +1872,13 @@ Function3cc3f: ; 3cc3f ; 3cc45 - Function3cc45: ; 3cc45 ld hl, BattleMonHP ld a, [hBattleTurn] and a - jr z, .asm_3cc50 - ld hl, EnemyMonHPHi - -.asm_3cc50 + jr z, .ok + ld hl, EnemyMonHP +.ok inc hl ld a, [hl] ld [$d1ec], a @@ -1879,16 +1903,17 @@ Function3cc45: ; 3cc45 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 @@ -1934,7 +1959,7 @@ GetHalfMaxHP: ; 3cc9f ; output: bc call GetMaxHP -; halve reslut +; halve result srl b rr c @@ -1951,18 +1976,12 @@ GetHalfMaxHP: ; 3cc9f 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 @@ -1977,10 +1996,9 @@ Function3ccc2: ; 3ccc2 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] @@ -1998,10 +2016,9 @@ Function3ccde: ; 3ccde 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 @@ -2015,25 +2032,25 @@ Function3ccef: ; 3ccef 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 [Buffer1 + 1], a ld a, [hld] - ld [Buffer1], a + ld [Buffer1 + 0], a dec hl ld a, [hl] - ld [$d1ec], a + ld [Buffer1 + 2], a add c ld [hld], a - ld [$d1ee], a + ld [Buffer1 + 4], a ld a, [hl] - ld [$d1ed], a + ld [Buffer1 + 3], a adc b ld [hli], a - ld [$d1ef], a + ld [Buffer1 + 5], a + ld a, [Buffer1] ld c, a ld a, [hld] @@ -2045,15 +2062,15 @@ Function3ccef: ; 3ccef jr c, .asm_3cd2d ld a, b ld [hli], a - ld [$d1ef], a + ld [Buffer1 + 5], a ld a, c ld [hl], a - ld [$d1ee], a - + ld [Buffer1 + 4], a .asm_3cd2d - call Function3c8e4 + + call SwitchTurnCore call Function3cd36 - jp Function3c8e4 + jp SwitchTurnCore ; 3cd36 Function3cd36: ; 3cd36 @@ -2061,21 +2078,18 @@ Function3cd36: ; 3cd36 jp UpdateBattleHuds ; 3cd3c - Function3cd3c: ; 3cd3c hlcoord 10, 9 ld a, [hBattleTurn] and a - ld a, $1 - jr z, .asm_3cd4a + ld a, 1 + jr z, .ok hlcoord 2, 2 xor a - -.asm_3cd4a +.ok push bc ld [$d10a], a - ld a, $b - call Predef + predef Functionc6e0 pop bc ret ; 3cd55 @@ -2093,31 +2107,38 @@ Function3cd55: ; 3cd55 ld a, d and a jp z, LostBattle + ld hl, BattleMonHP ld a, [hli] or [hl] - call nz, Function3df48 + call nz, UpdatePlayerHUD + ld a, $1 ld [hBGMapMode], a - ld c, $3c + ld c, 60 call DelayFrames + ld a, [IsInBattle] dec a jr nz, .asm_3cd8c - ld a, $1 + + ld a, 1 ld [BattleEnded], a ret .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 @@ -2125,6 +2146,7 @@ Function3cd55: ; 3cd55 call Function3d227 call Function3d2e0 jp c, Function3c0e5 + ld a, $1 ld [$d0ec], a call Function3cf4a @@ -2147,7 +2169,7 @@ Function3cdca: ; 3cdca jr z, .asm_3cde6 call ClearSprites hlcoord 1, 0 - ld bc, $040a + lb bc, 4, 10 call ClearBox call Function3d2b3 ld a, $1 @@ -2264,27 +2286,29 @@ Function3ce01: ; 3ce01 Function3ceaa: ; 3ceaa ld a, [PartyCount] ld b, a - ld hl, PartyMon1Species + ld hl, PartyMon1 ld c, $1 ld d, $0 .asm_3ceb5 push hl push bc - ld bc, $0022 + ld bc, PartyMon1HP - PartyMon1 add hl, bc ld a, [hli] or [hl] pop bc pop hl jr z, .asm_3ced1 + push hl push bc - ld bc, $0001 + ld bc, PartyMon1Item - PartyMon1 add hl, bc pop bc ld a, [hl] pop hl - cp $39 + + cp EXP_SHARE jr nz, .asm_3ced1 ld a, d or c @@ -2293,7 +2317,7 @@ Function3ceaa: ; 3ceaa .asm_3ced1 sla c push de - ld de, $0030 + ld de, PartyMon2 - PartyMon1 add hl, de pop de dec b @@ -2331,7 +2355,7 @@ Function3cef1: ; 3cef1 call Function37b6 call Function3d43b hlcoord 9, 7 - ld bc, $050b + lb bc, 5, 11 call ClearBox ld hl, BattleText_0x80a75 jp StdBattleTextBox @@ -2345,7 +2369,7 @@ Function3cf14: ; 3cf14 ld de, SFX_UNKNOWN_2A call PlaySFX hlcoord 1, 0 - ld bc, $040a + lb bc, 4, 10 call ClearBox ld hl, BattleText_0x809a8 jp StdBattleTextBox @@ -2356,7 +2380,7 @@ Function3cf35: ; 3cf35 ld b, a xor a ld hl, OTPartyMon1HP - ld de, $0030 + ld de, PartyMon2 - PartyMon1 .asm_3cf40 or [hl] inc hl @@ -2379,7 +2403,7 @@ Function3cf4a: ; 3cf4a and a jr z, .asm_3cf6d call Function3e8e4 - ld a, [$d430] + ld a, [wBattleAction] cp $f ret z call Function30b4 @@ -2415,7 +2439,7 @@ EnemyPartyMonEntrance: ; 3cf78 call SetEnemyTurn call SpikesDamage xor a - ld [EnemyMoveAnimation], a + ld [wEnemyMoveStruct + MOVE_ANIM], a ld [$d0ec], a inc a ret @@ -2433,7 +2457,7 @@ Function3cfa4: ; 3cfa4 callab Function39939 ld hl, BattleText_0x809da call StdBattleTextBox - call Function3d2f1 + call IsMobileBattle jr z, .asm_3cff5 ld a, [InLinkBattle] and a @@ -2445,11 +2469,9 @@ Function3cfa4: ; 3cfa4 ld c, $28 call DelayFrames ld a, [BattleType] - cp $1 + cp BATTLETYPE_CANLOSE jr nz, .asm_3cfe8 - ld a, $2 - call Predef - + predef Functionc658 .asm_3cfe8 ld a, [$c2cc] bit 0, a @@ -2475,7 +2497,7 @@ Function3cfa4: ; 3cfa4 ld c, $3 callba Function11c000 call Functiona80 - ld hl, $c6ec + ld hl, wPayDayMoney ld a, [hli] or [hl] inc hl @@ -2494,7 +2516,7 @@ Function3d02b: ; 3d02b push af ld a, $0 jr nc, .asm_3d044 - ld a, [$d854] + ld a, [wMomSavingMoney] and $7 cp $3 jr nz, .asm_3d044 @@ -2525,7 +2547,7 @@ Function3d02b: ; 3d02b call Function3d099 pop af jr nc, .asm_3d07b - ld a, [$d854] + ld a, [wMomSavingMoney] and $7 jr z, .asm_3d07b ld hl, SentToMomTexts @@ -2547,7 +2569,7 @@ Function3d02b: ; 3d02b Function3d081: ; 3d081 push bc ld hl, $c688 - ld de, $d853 + ld de, wMomsMoney + 2 call Function3d0be pop bc ret @@ -2556,7 +2578,7 @@ Function3d081: ; 3d081 Function3d08d: ; 3d08d push bc ld hl, $c688 - ld de, $d850 + ld de, Money + 2 call Function3d0be pop bc ret @@ -2585,13 +2607,13 @@ SentToMomTexts: ; 3d0ab Function3d0b1: ; 3d0b1 - ld hl, $d853 + ld hl, wMomsMoney + 2 ld a, [hld] - cp $3f + cp 999999 % $100 ld a, [hld] - sbc $42 + sbc 999999 / $100 % $100 ld a, [hl] - sbc $f + sbc 999999 / $10000 % $100 ret ; 3d0be @@ -2616,17 +2638,17 @@ Function3d0be: ; 3d0be jr nz, .asm_3d0ce pop hl ld a, [hld] - cp $3f + cp 999999 % $100 ld a, [hld] - sbc $42 + sbc 999999 / $100 % $100 ld a, [hl] - sbc $f + sbc 999999 / $10000 % $100 ret c - ld [hl], $f + ld [hl], 999999 / $10000 % $100 inc hl - ld [hl], $42 + ld [hl], 999999 / $100 % $100 inc hl - ld [hl], $3f + ld [hl], 999999 % $100 ret ; 3d0ea @@ -2643,7 +2665,7 @@ Function3d0ea: ; 3d0ea call Function3ceaa pop de jr nz, .asm_3d11e - ld hl, $c6ec + ld hl, wPayDayMoney ld a, [hli] or [hl] jr nz, .asm_3d11e @@ -2724,7 +2746,7 @@ KantoGymLeaders: Function3d14e: ; 3d14e call Function3cef1 - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] or [hl] call z, Function3cf14 @@ -2735,7 +2757,7 @@ Function3d14e: ; 3d14e ld a, d and a jp z, LostBattle - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] or [hl] jr nz, .asm_3d185 @@ -2777,8 +2799,7 @@ Function3d1aa: ; 3d1aa ld c, a ld hl, $c664 ld b, $0 - ld a, $3 - call Predef + predef FlagPredef ld hl, EnemySubStatus3 res 2, [hl] xor a @@ -2833,7 +2854,7 @@ Function3d1f8: ; 3d1f8 cp $1 jr z, .asm_3d20a ld hl, PartyMon1Speed - ld de, EnemyMonSpd + ld de, EnemyMonSpeed jp Function3d8b3 ; 3d227 @@ -2854,7 +2875,7 @@ Function3d227: ; 3d227 ld [$d0ec], a call Function3d2e0 jr c, .asm_3d251 - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] or [hl] jr nz, .asm_3d26c @@ -2920,7 +2941,6 @@ Function3d2b3: ; 3d2b3 ; 3d2e0 - Function3d2e0: ; 3d2e0 ld a, [InLinkBattle] cp $4 @@ -2936,7 +2956,7 @@ Function3d2e0: ; 3d2e0 ret ; 3d2f1 -Function3d2f1: ; 3d2f1 +IsMobileBattle: ; 3d2f1 ld a, [InLinkBattle] cp $4 ret @@ -2962,25 +2982,25 @@ Function3d313: ; 3d313 ; 3d329 Function3d329: ; 3d329 - call Function3d2f1 - jr z, .asm_3d335 + call IsMobileBattle + jr z, .mobile callba PartyMenuSelect ret -.asm_3d335 +.mobile callba Function100cb5 ret ; 3d33c PickPartyMonInBattle: ; 3d33c -.asm_3d33c +.loop ld a, $2 ; Which PKMN? ld [PartyMenuActionText], a call Function3d313 call Function3d329 ret c call Function3d887 - jr z, .asm_3d33c + jr z, .loop xor a ret ; 3d34f @@ -3108,14 +3128,14 @@ LostBattle: ; 3d38e and $c0 add 2 ld [$d0ee], a - jr .asm_3d412 + jr .text .asm_3d40a ld hl, LostAgainstText - call Function3d2f1 + call IsMobileBattle jr z, .asm_3d417 -.asm_3d412 +.text call StdBattleTextBox .end @@ -3204,7 +3224,7 @@ Function3d444: ; 3d444 Function3d490: ; 3d490 - ld [hConnectionStripLength], a + ld [$ffaf], a ld c, a .asm_3d493 push bc @@ -3214,7 +3234,7 @@ Function3d490: ; 3d490 push hl call Function3d4ae pop hl - ld de, 20 + ld de, SCREEN_WIDTH add hl, de dec b jr nz, .asm_3d497 @@ -3228,24 +3248,24 @@ Function3d490: ; 3d490 ; 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 @@ -3273,7 +3293,6 @@ Function3d4e1: ; 3d4e1 call Function3d533 jr c, .asm_3d4f1 call Function3d599 - .asm_3d4f1 call Function3d6ca call Function3d74b @@ -3288,7 +3307,7 @@ Function3d4e1: ; 3d4e1 ld [$c6fc], a ld [$d0ec], a inc a - ld [$c711], a + ld [wEnemyIsSwitching], a call Function309d jp Function3e3ad ; 3d517 @@ -3298,11 +3317,10 @@ Function3d517: ; 3d517 call Function3d533 jr c, .asm_3d522 call Function3d599 - .asm_3d522 call Function3d6ca - ld a, $1 - ld [$c711], a + ld a, 1 + ld [wEnemyIsSwitching], a call Function3d7a0 call Function3d7b8 jp Function3d7c7 @@ -3312,8 +3330,9 @@ Function3d533: ; 3d533 ld a, [InLinkBattle] and a jr z, .asm_3d541 - ld a, [$d430] - sub $4 + + ld a, [wBattleAction] + sub NUM_MOVES ld b, a jr .asm_3d555 @@ -3363,14 +3382,12 @@ Function3d581: ; 3d581 ld a, [CurBattleMon] ld c, a ld hl, $c664 - ld b, $1 + ld b, SET_FLAG push bc - ld a, $3 - call Predef + predef FlagPredef pop bc ld hl, $c6fc - ld a, $3 - jp Predef + predef_jump FlagPredef ; 3d599 Function3d599: ; 3d599 @@ -3412,25 +3429,25 @@ Function3d599: ; 3d599 Function3d5d7: ; 3d5d7 push bc - ld hl, OTPartyMon1Move1 + ld hl, OTPartyMon1Moves ld a, b call GetPartyLocation pop bc - ld e, $5 -.asm_3d5e2 + ld e, NUM_MOVES + 1 +.loop dec e - jr z, .asm_3d617 + jr z, .done ld a, [hli] and a - jr z, .asm_3d617 + jr z, .done push hl push de push bc dec a - ld hl, Moves + MOVE_ANIM - ld bc, Move2 - Move1 + ld hl, Moves + ld bc, MOVE_LENGTH call AddNTimes - ld de, EnemyMoveAnimation + ld de, wEnemyMoveStruct ld a, BANK(Moves) call FarCopyBytes call SetEnemyTurn @@ -3439,13 +3456,12 @@ Function3d5d7: ; 3d5d7 pop de pop hl ld a, [$d265] - cp $b - jr c, .asm_3d5e2 + cp 10 + 1 ; 1.0 + 0.1 + jr c, .loop ld hl, Buffer1 set 0, [hl] ret - -.asm_3d617 +.done ret ; 3d618 @@ -3467,14 +3483,14 @@ Function3d618: ; 3d618 ld a, BANK(BaseData) call FarCopyBytes ld a, [BattleMonType1] - ld [PlayerMoveType], a + ld [wPlayerMoveStruct + MOVE_TYPE], a call SetPlayerTurn callab Function347c8 ld a, [$d265] cp $b jr nc, .asm_3d663 ld a, [BattleMonType2] - ld [PlayerMoveType], a + ld [wPlayerMoveStruct + MOVE_TYPE], a callab Function347c8 ld a, [$d265] cp $b @@ -3572,7 +3588,7 @@ Function3d6ca: ; 3d6ca inc a ld hl, OTPartyCount ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] ld [TempEnemyMonSpecies], a @@ -3584,14 +3600,12 @@ Function3d6ca: ; 3d6ca ld a, [$def4] and a jr nz, .asm_3d708 - ld hl, EnemyMonAtkDefDV - ld a, $2d - call Predef + ld hl, EnemyMonDVs + predef GetUnownLetter ld a, [UnownLetter] ld [$def4], a - .asm_3d708 - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] ld [$c6ea], a ld a, [hl] @@ -3610,7 +3624,7 @@ Function3d714: ; 3d714 and a jp nz, .asm_3d749 ld a, [Options] - bit 6, a + bit BATTLE_SHIFT, a jr nz, .asm_3d749 ld a, [CurPartyMon] push af @@ -3676,7 +3690,7 @@ Function3d7a0: ; 3d7a0 call Function1c07 call ClearSprites hlcoord 1, 0 - ld bc, $040a + lb bc, 4, 10 call ClearBox call WaitBGMap jp Function3ee27 @@ -3694,25 +3708,26 @@ Function3d7c7: ; 3d7c7 ld [CurPartySpecies], a ld [CurSpecies], a call GetBaseData - ld a, $1 + ld a, OTPARTYMON ld [MonType], a - ld a, $1f - call Predef + predef Function5084a call Function3f47c + xor a ld [$cfca], a ld [$c689], a call SetEnemyTurn - ld de, $0101 + ld de, ANIM_SEND_OUT_MON call Function3ee17 + call Function3da79 jr nc, .asm_3d800 - ld a, $1 + ld a, 1 ; shiny anim ld [$c689], a - ld de, $0101 + ld de, ANIM_SEND_OUT_MON call Function3ee17 - .asm_3d800 + ld bc, TempMonSpecies callba Function4e53f jr c, .asm_3d82c @@ -3721,8 +3736,7 @@ Function3d7c7: ; 3d7c7 hlcoord 12, 0 ld d, $0 ld e, $0 - ld a, $47 - call Predef + predef Functiond008e jr .asm_3d82c .asm_3d821 @@ -3732,7 +3746,7 @@ Function3d7c7: ; 3d7c7 call Function37b6 .asm_3d82c - call Function3e036 + call UpdateEnemyHUD ld a, $1 ld [hBGMapMode], a ret @@ -3751,7 +3765,7 @@ NewEnemyMonStatus: ; 3d834 ld [hl], a ld [EnemyDisableCount], a ld [EnemyFuryCutterCount], a - ld [$c681], a + ld [EnemyProtectCount], a ld [$c72c], a ld [EnemyDisabledMove], a ld [$c6fa], a @@ -3759,7 +3773,7 @@ NewEnemyMonStatus: ; 3d834 ld [$c731], a ld [EnemyTurnsTaken], a ld hl, PlayerSubStatus5 - res 7, [hl] + res SUBSTATUS_CANT_RUN, [hl] ret ; 3d867 @@ -3779,7 +3793,7 @@ Function3d873: ; 3d873 ld e, a xor a ld hl, PartyMon1HP - ld bc, $002f + ld bc, PartyMon2 - (PartyMon1 + 1) .asm_3d87e or [hl] inc hl @@ -3826,15 +3840,15 @@ Function3d8b3: ; 3d8b3 ld a, [BattleType] cp $2 jp z, .asm_3d9a2 - cp $6 + cp BATTLETYPE_CONTEST jp z, .asm_3d9a2 - cp $9 + cp BATTLETYPE_TRAP jp z, .asm_3d98d - cp $b + cp BATTLETYPE_CELEBI jp z, .asm_3d98d - cp $7 + cp BATTLETYPE_SHINY jp z, .asm_3d98d - cp $c + cp BATTLETYPE_SUICUNE jp z, .asm_3d98d ld a, [InLinkBattle] @@ -3846,7 +3860,7 @@ Function3d8b3: ; 3d8b3 jp nz, .asm_3d992 ld a, [EnemySubStatus5] - bit 7, a + bit SUBSTATUS_CANT_RUN, a jp nz, .asm_3d98d ld a, [$c730] @@ -3860,7 +3874,7 @@ Function3d8b3: ; 3d8b3 ld b, a callab GetItem ld a, b - cp $48 + cp HELD_ESCAPE pop de pop hl jr nz, .asm_3d916 @@ -3969,8 +3983,8 @@ Function3d8b3: ; 3d8b3 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 @@ -4011,21 +4025,21 @@ Function3d8b3: ; 3d8b3 Function3da0d: ; 3da0d - ld a, $0 + ld a, PartyMon1Species - PartyMon1 call GetPartyParamLocation ld de, BattleMonSpecies - ld bc, $0006 + ld bc, 1 + 1 + NUM_MOVES ; species, item, moves ; BattleMonDVs - BattleMonSpecies call CopyBytes - ld bc, $000f + ld bc, PartyMon1DVs - (PartyMon1Species + 1 + 1 + NUM_MOVES) add hl, bc - ld de, BattleMonAtkDefDV - ld bc, $0007 + ld de, BattleMonDVs + ld bc, 2 + NUM_MOVES + 1 ; DVs, PP, happiness ; BattleMonLevel - BattleMonDVs call CopyBytes inc hl inc hl inc hl ld de, BattleMonLevel - ld bc, $0011 + ld bc, 1 + 1 + 1 + 2 + 2 * 6 ; level, status, unused, stats call CopyBytes ld a, [BattleMonSpecies] ld [TempBattleMonSpecies], a @@ -4036,15 +4050,15 @@ Function3da0d: ; 3da0d ld [BattleMonType1], a ld a, [BaseType2] ld [BattleMonType2], a - ld hl, PartyMon1Nickname + ld hl, PartyMonNicknames ld a, [CurBattleMon] call SkipNames ld de, BattleMonNick - ld bc, $000b + ld bc, PKMN_NAME_LENGTH call CopyBytes - ld hl, BattleMonAtk + ld hl, BattleMonAttack ld de, PlayerStats - ld bc, $000a + ld bc, 2 * 5 call CopyBytes call Function3ec2c call BadgeStatBoosts @@ -4066,9 +4080,9 @@ Function3da7c: ; 3da7c ; 3da85 Function3da85: ; 3da85 - ld hl, BattleMonAtkDefDV + ld hl, BattleMonDVs ld a, [PlayerSubStatus5] - bit 3, a + bit SUBSTATUS_TRANSFORMED, a ret z ld hl, PartyMon1DVs ld a, [CurBattleMon] @@ -4076,15 +4090,15 @@ Function3da85: ; 3da85 ; 3da97 Function3da97: ; 3da97 - ld hl, EnemyMonAtkDefDV + ld hl, EnemyMonDVs ld a, [EnemySubStatus5] - bit 3, a + bit SUBSTATUS_TRANSFORMED, a ret z ld hl, $c6f2 ld a, [IsInBattle] dec a ret z - ld hl, OTPartyMon1AtkDefDV + ld hl, OTPartyMon1DVs ld a, [CurOTMon] jp GetPartyLocation ; 3dab1 @@ -4106,31 +4120,31 @@ Function3dabd: ; 3dabd ld hl, OTPartyMon1Species call GetPartyLocation ld de, EnemyMonSpecies - ld bc, $0006 + ld bc, 1 + 1 + NUM_MOVES call CopyBytes - ld bc, $000f + ld bc, OTPartyMon1DVs - (OTPartyMon1Species + 1 + 1 + NUM_MOVES) add hl, bc - ld de, EnemyMonAtkDefDV - ld bc, $0007 + ld de, EnemyMonDVs + ld bc, 2 + NUM_MOVES + 1 call CopyBytes inc hl inc hl inc hl ld de, EnemyMonLevel - ld bc, $0011 + ld bc, 1 + 1 + 1 + 2 + 2 * 6 call CopyBytes ld a, [EnemyMonSpecies] ld [CurSpecies], a call GetBaseData - ld hl, OTPartyMon1Nickname + ld hl, OTPartyMonNicknames ld a, [CurPartyMon] call SkipNames ld de, EnemyMonNick - ld bc, $000b + ld bc, PKMN_NAME_LENGTH call CopyBytes - ld hl, EnemyMonAtk + ld hl, EnemyMonAttack ld de, EnemyStats - ld bc, $000a + ld bc, 2 * 5 call CopyBytes call Function3ec30 ld hl, BaseType1 @@ -4140,9 +4154,9 @@ Function3dabd: ; 3dabd inc de ld a, [hl] ld [de], a - ld hl, BaseHP + ld hl, BaseStats ld de, EnemyMonBaseStats - ld b, $5 + ld b, 5 .asm_3db25 ld a, [hli] ld [de], a @@ -4169,7 +4183,7 @@ Function3db32: ; 3db32 call Function3db5f call EmptyBattleTextBox call Function309d - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] or [hl] ret @@ -4177,12 +4191,11 @@ Function3db32: ; 3db32 Function3db5f: ; 3db5f - ld hl, BattleMonAtkDefDV - ld a, $2d - call Predef + ld hl, BattleMonDVs + predef GetUnownLetter hlcoord 1, 5 - ld b, $7 - ld c, $8 + ld b, 7 + ld c, 8 call ClearBox call WaitBGMap xor a @@ -4193,11 +4206,11 @@ Function3db5f: ; 3db5f ld [$d0d2], a ld [CurMoveNum], a ld [TypeModifier], a - ld [PlayerMoveAnimation], a + ld [wPlayerMoveStruct + MOVE_ANIM], a ld [LastEnemyCounterMove], a ld [LastPlayerCounterMove], a ld [LastPlayerMove], a - call Function3e4a8 + call CheckAmuletCoin call Function3ee27 xor a ld [$c731], a @@ -4205,17 +4218,17 @@ Function3db5f: ; 3db5f 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 - ld a, $0 + ld a, PartyMon1Species - PartyMon1 call GetPartyParamLocation ld b, h ld c, l @@ -4227,7 +4240,7 @@ Function3db5f: ; 3db5f call Function37b6 .asm_3dbd6 - call Function3df48 + call UpdatePlayerHUD ld a, $1 ld [hBGMapMode], a ret @@ -4273,20 +4286,20 @@ BreakAttraction: ; 3dc18 SpikesDamage: ; 3dc23 ld hl, PlayerScreens - ld de, BattleMonType1 - ld bc, Function3df48 + ld de, BattleMonType + ld bc, UpdatePlayerHUD ld a, [hBattleTurn] and a jr z, .ok ld hl, EnemyScreens - ld de, EnemyMonType1 - ld bc, Function3e036 + ld de, EnemyMonType + ld bc, UpdateEnemyHUD .ok bit SCREENS_SPIKES, [hl] ret z -; Flying-types aren't affected by Spikes. + ; Flying-types aren't affected by Spikes. ld a, [de] cp FLYING ret z @@ -4313,15 +4326,17 @@ SpikesDamage: ; 3dc23 ; 3dc5b Function3dc5b: ; 3dc5b - ld a, $10 + ld a, BATTLE_VARS_MOVE call GetBattleVar ld b, a call GetMoveEffect ld a, b - cp $80 + cp EFFECT_PURSUIT jr nz, .asm_3dce4 + ld a, [CurBattleMon] push af + ld hl, DoPlayerTurn ld a, [hBattleTurn] and a @@ -4329,25 +4344,29 @@ Function3dc5b: ; 3dc5b ld hl, DoEnemyTurn ld a, [$c71a] ld [CurBattleMon], a - .asm_3dc7e ld a, BANK(DoPlayerTurn) rst FarCall - ld a, $10 - call _GetBattleVar + + ld a, BATTLE_VARS_MOVE + call GetBattleVarAddr ld a, $ff ld [hl], a + pop af ld [CurBattleMon], a + ld a, [hBattleTurn] and a jr z, .asm_3dcc0 + ld a, [$c71a] call Function399f ld hl, BattleMonHP ld a, [hli] or [hl] jr nz, .asm_3dce4 + ld a, $f0 ld [CryTracks], a ld a, [BattleMonSpecies] @@ -4356,17 +4375,17 @@ Function3dc5b: ; 3dc5b ld c, a ld hl, $c664 ld b, $0 - ld a, $3 - call Predef + predef FlagPredef call Function3d43b ld hl, BattleText_0x80a75 jr .asm_3dcdf .asm_3dcc0 - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] or [hl] jr nz, .asm_3dce4 + ld de, SFX_KINESIS call PlaySFX call WaitSFX @@ -4392,7 +4411,7 @@ Function3dce6: ; 3dce6 xor a ld [hBattleTurn], a ld [$cfca], a - ld de, $0102 + ld de, ANIM_RETURN_MON call Function3ee17 pop af ld [hBattleTurn], a @@ -4428,8 +4447,8 @@ Function3dd2f: ; 3dd2f ld a, b cp $1 ret nz - ld de, EnemyMonHPLo - ld hl, EnemyMonMaxHPHi + ld de, EnemyMonHP + 1 + ld hl, EnemyMonMaxHP ld a, [hBattleTurn] and a jr z, .asm_3dd4a @@ -4502,8 +4521,7 @@ Function3dd2f: ; 3dd2f .asm_3dda4 ld [$d10a], a - ld a, $b - call Predef + predef Functionc6e0 Function3ddac: call RefreshBattleHuds callab GetOpponentItem @@ -4521,15 +4539,14 @@ Function3ddc8: ; 3ddc8 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 + predef PlayBattleAnim + call SwitchTurnCore pop bc pop de pop hl @@ -4548,8 +4565,8 @@ Function3dde9: ; 3dde9 jr nz, .asm_3ddf2 dec hl ld b, [hl] - ld a, $b - call _GetBattleVar + ld a, BATTLE_VARS_STATUS_OPP + call GetBattleVarAddr and b ret z xor a @@ -4557,20 +4574,20 @@ Function3dde9: ; 3dde9 push bc call UpdateOpponentInParty pop bc - ld a, $9 - call _GetBattleVar + ld a, BATTLE_VARS_SUBSTATUS5_OPP + call GetBattleVarAddr and [hl] - res 0, [hl] - ld a, $5 - call _GetBattleVar + res SUBSTATUS_TOXIC, [hl] + ld a, BATTLE_VARS_SUBSTATUS1_OPP + call GetBattleVarAddr and [hl] - res 0, [hl] + res SUBSTATUS_NIGHTMARE, [hl] ld a, b cp $7f jr nz, .asm_3de26 - ld a, $7 - call _GetBattleVar - res 7, [hl] + ld a, BATTLE_VARS_SUBSTATUS3_OPP + call GetBattleVarAddr + res SUBSTATUS_CONFUSED, [hl] .asm_3de26 ld hl, Function365fd @@ -4580,10 +4597,10 @@ Function3dde9: ; 3dde9 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 @@ -4603,23 +4620,23 @@ Function3dde9: ; 3dde9 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 - call _GetBattleVar - res 7, [hl] + ld a, BATTLE_VARS_SUBSTATUS3_OPP + call GetBattleVarAddr + res SUBSTATUS_CONFUSED, [hl] call GetItemName call Function3ddc8 ld hl, BattleText_0x80dab @@ -4715,13 +4732,13 @@ Function3deb6: ; 3deb6 ; 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 @@ -4750,7 +4767,7 @@ Function3df2c: ; 3df2c ld hl, PlayerHPPal call SetHPPal call CheckDanger - call Function3e043 + call DrawEnemyHUD ld hl, EnemyHPPal call SetHPPal pop bc @@ -4761,7 +4778,7 @@ Function3df2c: ; 3df2c -Function3df48:: ; 3df48 +UpdatePlayerHUD:: ; 3df48 push hl push de push bc @@ -4778,9 +4795,9 @@ DrawPlayerHUD: ; 3df58 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 @@ -4789,15 +4806,14 @@ DrawPlayerHUD: ; 3df58 ld [hl], $73 ; vertical bar call PrintPlayerHUD -; HP bar + ; HP bar hlcoord 10, 9 - ld b, OTPARTYMON + ld b, 1 xor a ld [MonType], a - ld a, PREDEF_DRAW_PLAYER_HP - call Predef + predef DrawPlayerHP -; Exp bar + ; Exp bar push de ld a, [CurBattleMon] ld hl, PartyMon1Exp + 2 @@ -4822,24 +4838,24 @@ CheckDanger: ; 3df9e 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 + cp HP_RED + 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 @@ -4878,11 +4894,11 @@ PrintPlayerHUD: ; 3dfbf 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 @@ -4891,13 +4907,12 @@ PrintPlayerHUD: ; 3dfbf push af push hl ld de, BattleMonStatus - ld a, $21 - call Predef + predef Function50d2e pop hl pop bc ret nz ld a, b - cp $7f + cp " " jr nz, .asm_3e02d dec hl @@ -4907,25 +4922,28 @@ PrintPlayerHUD: ; 3dfbf jp PrintLevel ; 3e036 -Function3e036:: ; 3e036 +UpdateEnemyHUD:: ; 3e036 push hl push de push bc - call Function3e043 - call Function3e127 + call DrawEnemyHUD + call UpdateEnemyHPPal pop bc pop de pop hl ret ; 3e043 -Function3e043: ; 3e043 +DrawEnemyHUD: ; 3e043 xor a ld [hBGMapMode], a + hlcoord 1, 0 - ld bc, $040b + lb bc, 4, 11 call ClearBox + callba Function2c0c5 + ld a, [TempEnemyMonSpecies] ld [CurSpecies], a ld [CurPartySpecies], a @@ -4937,52 +4955,52 @@ Function3e043: ; 3e043 ld h, b ld l, c dec hl - ld hl, EnemyMonAtkDefDV + + ld hl, EnemyMonDVs ld de, TempMonDVs ld a, [EnemySubStatus5] - bit 3, a - jr z, .asm_3e080 + bit SUBSTATUS_TRANSFORMED, a + jr z, .ok ld hl, $c6f2 - -.asm_3e080 +.ok ld a, [hli] ld [de], a inc de ld a, [hl] ld [de], a + 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 ld [hl], a + hlcoord 6, 1 push af push hl ld de, EnemyMonStatus - ld a, $21 - call Predef + predef Function50d2e pop hl pop bc jr nz, .asm_3e0be ld a, b - cp $7f + cp " " jr nz, .asm_3e0b5 dec hl - .asm_3e0b5 ld a, [EnemyMonLevel] ld [TempMonLevel], a call PrintLevel - .asm_3e0be - ld hl, EnemyMonHPHi + + ld hl, EnemyMonHP ld a, [hli] ld [$ffb5], a ld a, [hld] @@ -4991,16 +5009,16 @@ Function3e043: ; 3e043 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, EnemyMonMaxHPHi + ld hl, EnemyMonMaxHP ld a, [hli] ld b, a ld a, [hl] @@ -5035,19 +5053,20 @@ Function3e043: ; 3e043 call Divide ld a, [$ffb6] ld e, a - ld a, $6 + ld a, HP_BAR_LENGTH ld d, a ld c, a + .asm_3e11a xor a ld [$d10a], a hlcoord 2, 2 - ld b, $0 + ld b, 0 call DrawHPBar ret ; 3e127 -Function3e127: ; 3e127 +UpdateEnemyHPPal: ; 3e127 ld hl, EnemyHPPal call Function3e12e ret @@ -5066,52 +5085,56 @@ Function3e138: ; 3e138 ret ; 3e139 -Function3e139: ; 3e139 +BattleMenu: ; 3e139 xor a ld [hBGMapMode], a call Function30bf + ld a, [BattleType] cp $2 - jr z, .asm_3e156 - cp $3 - jr z, .asm_3e156 + jr z, .ok + cp BATTLETYPE_TUTORIAL + jr z, .ok call EmptyBattleTextBox call UpdateBattleHuds call EmptyBattleTextBox call Function309d +.ok -.asm_3e156 +.loop ld a, [BattleType] - cp $6 - jr nz, .asm_3e165 - callba Function24f13 - jr .asm_3e175 + cp BATTLETYPE_CONTEST + jr nz, .not_contest + callba ContestBattleMenu + jr .next +.not_contest -.asm_3e165 + ; Auto input: choose "ITEM" ld a, [InputType] or a jr z, .asm_3e171 callba Function1de294 .asm_3e171 - call Function3e19b + + call LoadBattleMenu2 ret c -.asm_3e175 +.next ld a, $1 ld [hBGMapMode], a ld a, [$d0d2] cp $1 - jp z, Function3e192 + jp z, BattleMenu_Fight cp $3 - jp z, Function3e1c7 + jp z, BattleMenu_Pack cp $2 - jp z, Function3e28d + jp z, BattleMenu_PKMN cp $4 - jp z, Function3e489 - jr .asm_3e156 + jp z, BattleMenu_Run + jr .loop ; 3e192 -Function3e192: ; 3e192 +BattleMenu_Fight: ; 3e192 xor a ld [$d267], a call Function30b4 @@ -5119,59 +5142,64 @@ Function3e192: ; 3e192 ret ; 3e19b -Function3e19b: ; 3e19b - call Function3d2f1 - jr z, .asm_3e1a8 - callba LoadBattleMenuDataHeader +LoadBattleMenu2: ; 3e19b + call IsMobileBattle + jr z, .mobile + + callba LoadBattleMenu and a ret -.asm_3e1a8 +.mobile callba Function100b12 ld a, [$cd2b] and a ret z + ld hl, $cd2a bit 4, [hl] - jr nz, .asm_3e1c5 + jr nz, .error ld hl, BattleText_0x81863 call StdBattleTextBox - ld c, $3c + ld c, 60 call DelayFrames - -.asm_3e1c5 +.error scf ret ; 3e1c7 -Function3e1c7: ; 3e1c7 +BattleMenu_Pack: ; 3e1c7 ld a, [InLinkBattle] and a - jp nz, Function3e22b + jp nz, ItemsCantBeUsed + ld a, [$cfc0] and a - jp nz, Function3e22b + jp nz, ItemsCantBeUsed + call Function1d6e + ld a, [BattleType] - cp $3 - jr z, .asm_3e1f1 - cp $6 - jr z, .asm_3e201 - callba Function10493 + cp BATTLETYPE_TUTORIAL + jr z, .tutorial + cp BATTLETYPE_CONTEST + jr z, .contest + + callba BattlePack ld a, [$d0ec] and a jr z, .asm_3e20d jr .asm_3e209 -.asm_3e1f1 +.tutorial callba Function107bb - ld a, $5 + ld a, POKE_BALL ld [CurItem], a call DoItemEffect jr .asm_3e209 -.asm_3e201 - ld a, $b1 +.contest + ld a, PARK_BALL ld [CurItem], a call DoItemEffect @@ -5189,13 +5217,13 @@ Function3e1c7: ; 3e1c7 call WaitBGMap call Function3ee27 call Function309d - jp Function3e139 + jp BattleMenu ; 3e22b -Function3e22b: ; 3e22b +ItemsCantBeUsed: ; 3e22b ld hl, BattleText_0x80bf3 call StdBattleTextBox - jp Function3e139 + jp BattleMenu ; 3e234 Function3e234: ; 3e234 @@ -5214,7 +5242,7 @@ Function3e234: ; 3e234 call Function3ed9f call ClearSprites ld a, [BattleType] - cp $3 + cp BATTLETYPE_TUTORIAL jr z, .asm_3e25d call Function3f43d @@ -5243,7 +5271,7 @@ Function3e234: ; 3e234 ret ; 3e28d -Function3e28d: ; 3e28d +BattleMenu_PKMN: ; 3e28d call Function1d6e Function3e290: call Function1c07 @@ -5290,11 +5318,11 @@ Function3e299: call Function309d call ClearSGB call Function32f9 - jp Function3e139 + jp BattleMenu ; 3e2f5 Function3e2f5: ; 3e2f5 - call Function3d2f1 + call IsMobileBattle jr z, .asm_3e301 callba Function24e99 ret @@ -5350,7 +5378,7 @@ Function3e358: ; 3e358 and a jr nz, .asm_3e378 ld a, [EnemySubStatus5] - bit 7, a + bit SUBSTATUS_CANT_RUN, a jr z, .asm_3e381 .asm_3e378 @@ -5378,8 +5406,8 @@ Function3e358: ; 3e358 ; 3e3ad Function3e3ad: ; 3e3ad - ld a, $1 - ld [$c710], a + ld a, 1 + ld [wPlayerIsSwitching], a ld a, [InLinkBattle] and a jr z, .asm_3e3c1 @@ -5399,12 +5427,12 @@ Function3e3ad: ; 3e3ad ret .asm_3e3cf - ld a, [$d430] + ld a, [wBattleAction] cp $e jp z, .asm_3e3ca cp $d jp z, .asm_3e3ca - cp $4 + cp NUM_MOVES jp c, .asm_3e3ca cp $f jr nz, .asm_3e3e9 @@ -5444,9 +5472,9 @@ BattleMonEntrance: ; 3e40b call SetEnemyTurn call Function3dc5b - jr c, .asm_3e423 + jr c, .ok call Function3dce6 -.asm_3e423 +.ok hlcoord 9, 7 lb bc, 5, 11 @@ -5493,13 +5521,12 @@ PassedBattleMonEntrance: ; 3e459 ; 3e489 - -Function3e489: ; 3e489 +BattleMenu_Run: ; 3e489 call Function30b4 ld a, $3 ld [$cfa9], a - ld hl, BattleMonSpd - ld de, EnemyMonSpd + ld hl, BattleMonSpeed + ld de, EnemyMonSpeed call Function3d8b3 ld a, $0 ld [$d266], a @@ -5507,31 +5534,30 @@ Function3e489: ; 3e489 ld a, [$d0ec] and a ret nz - jp Function3e139 + jp BattleMenu ; 3e4a8 - -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 Function3e4bc: ; 3e4bc - call Function3d2f1 + call IsMobileBattle jr nz, .asm_3e4c8 callba Function100b9f ret .asm_3e4c8 - ld hl, EnemyMonMove1 + ld hl, EnemyMonMoves ld a, [$d235] dec a jr z, .asm_3e4e2 @@ -5539,49 +5565,49 @@ Function3e4bc: ; 3e4bc jr z, .asm_3e4dd call Function3e786 ret z - ld hl, BattleMonMove1 + ld hl, BattleMonMoves jr .asm_3e4e2 .asm_3e4dd - ld a, $2 + ld a, PartyMon1Moves - PartyMon1 call GetPartyParamLocation .asm_3e4e2 ld de, $d25e - ld bc, $0004 + ld bc, NUM_MOVES call CopyBytes xor a ld [hBGMapMode], a - hlcoord 4, 12 - ld b, $4 - ld c, $e + + hlcoord 4, 17 - NUM_MOVES - 1 + ld b, 4 + ld c, 14 ld a, [$d235] cp $2 jr nz, .asm_3e503 - hlcoord 4, 8 - ld b, $4 - ld c, $e - + hlcoord 4, 17 - NUM_MOVES - 1 - 4 + ld b, 4 + ld c, 14 .asm_3e503 call TextBox - hlcoord 6, 13 + + hlcoord 6, 17 - NUM_MOVES ld a, [$d235] cp $2 jr nz, .asm_3e513 - hlcoord 6, 9 - + hlcoord 6, 17 - NUM_MOVES - 4 .asm_3e513 - ld a, $14 + ld a, SCREEN_WIDTH ld [Buffer1], a - ld a, $20 - call Predef - ld b, $5 + predef ListMoves + + ld b, 5 ld a, [$d235] cp $2 - ld a, $d + ld a, 17 - NUM_MOVES jr nz, .asm_3e52c - ld b, $5 - ld a, $9 + ld b, 5 + ld a, 17 - NUM_MOVES - 4 .asm_3e52c ld [$cfa1], a @@ -5641,23 +5667,24 @@ Function3e4bc: ; 3e4bc and a jr z, .asm_3e5a3 hlcoord 5, 13 - ld bc, $0014 + ld bc, SCREEN_WIDTH dec a call AddNTimes - ld [hl], $ec + ld [hl], "▷" .asm_3e5a3 ld a, $1 ld [hBGMapMode], a call Function1bd3 - bit 6, a + bit 6, a ; D_UP jp nz, .asm_3e61d - bit 7, a + bit 7, a ; D_DOWN jp nz, .asm_3e62e - bit 2, a - jp nz, Function3e643 - bit 1, a + bit 2, a ; B_BUTTON + jp nz, .asm_3e643 + bit 1, a ; A_BUTTON push af + xor a ld [$d0e3], a ld a, [$cfa9] @@ -5667,6 +5694,7 @@ Function3e4bc: ; 3e4bc ld a, [$d235] dec a jr nz, .asm_3e5d0 + pop af ret @@ -5675,16 +5703,18 @@ Function3e4bc: ; 3e4bc ld a, b ld [CurMoveNum], a jr nz, .asm_3e5d9 + pop af ret .asm_3e5d9 pop af ret nz - ld hl, BattleMonPPMove1 + + ld hl, BattleMonPP ld a, [$cfa9] ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] and $3f @@ -5699,9 +5729,9 @@ Function3e4bc: ; 3e4bc and a jr nz, .asm_3e606 ld a, [$cfa9] - ld hl, BattleMonMove1 + ld hl, BattleMonMoves ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] @@ -5737,7 +5767,7 @@ Function3e4bc: ; 3e4bc jp .asm_3e57a ; 3e62e -.asm_3e62e: ; 3e62e +.asm_3e62e ; 3e62e ld a, [$cfa9] ld b, a ld a, [$d0eb] @@ -5750,7 +5780,7 @@ Function3e4bc: ; 3e4bc jp .asm_3e57a ; 3e643 -Function3e643: ; 3e643 +.asm_3e643 ; 3e643 ld a, [$d0e3] and a jr z, .asm_3e6bf @@ -5789,7 +5819,7 @@ Function3e643: ; 3e643 .asm_3e682 ld a, [PlayerSubStatus5] - bit 3, a + bit SUBSTATUS_TRANSFORMED, a jr nz, .asm_3e69e ld hl, PartyMon1Moves ld a, [CurBattleMon] @@ -5797,7 +5827,7 @@ Function3e643: ; 3e643 push hl call .asm_3e6a5 pop hl - ld bc, $0015 + ld bc, PartyMon1PP - PartyMon1Moves add hl, bc call .asm_3e6a5 @@ -5897,11 +5927,10 @@ MoveInfoBox: ; 3e6c8 ld [hl], "/" callab UpdateMoveData - ld a, [PlayerMoveAnimation] + ld a, [wPlayerMoveStruct + MOVE_ANIM] ld b, a hlcoord 2, 10 - ld a, PREDEF_PRINT_MOVE_TYPE - call Predef + predef PrintMoveType .done ret @@ -5918,10 +5947,9 @@ Function3e75f: ; 3e75f hlcoord 5, 11 ld a, [InLinkBattle] cp $4 - jr c, .asm_3e76c + jr c, .ok hlcoord 5, 11 - -.asm_3e76c +.ok push hl ld de, StringBuffer1 ld bc, $0102 @@ -5987,7 +6015,7 @@ Function3e786: ; 3e786 Function3e7c1: ; 3e7c1 - ld a, [$c711] + ld a, [wEnemyIsSwitching] and a ret nz ld a, [InLinkBattle] @@ -5999,34 +6027,35 @@ Function3e7c1: ; 3e7c1 and a call z, Function3e8e4 call Function30b4 - ld a, [$d430] + ld a, [wBattleAction] cp $e jp z, .asm_3e8bd cp $d jp z, .asm_3e82c - cp $4 + cp NUM_MOVES jp nc, Function3e8c1 ld [CurEnemyMoveNum], a ld c, a ld a, [EnemySubStatus1] - bit 6, a + bit SUBSTATUS_ROLLOUT, a jp nz, .asm_3e882 ld a, [EnemySubStatus3] - and $13 + and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE jp nz, .asm_3e882 + ld hl, EnemySubStatus5 - bit 4, [hl] + bit SUBSTATUS_ENCORED, [hl] ld a, [LastEnemyMove] jp nz, .asm_3e87f - ld hl, EnemyMonMove1 - ld b, $0 + ld hl, EnemyMonMoves + ld b, 0 add hl, bc ld a, [hl] jp .asm_3e87f .asm_3e817 ld hl, EnemySubStatus5 - bit 4, [hl] + bit SUBSTATUS_ENCORED, [hl] jr z, .asm_3e824 ld a, [LastEnemyMove] jp .asm_3e87f @@ -6041,9 +6070,9 @@ Function3e7c1: ; 3e7c1 jr .asm_3e87f .asm_3e830 - ld hl, EnemyMonMove1 - ld de, EnemyMonPPMove1 - ld b, $4 + ld hl, EnemyMonMoves + ld de, EnemyMonPP + ld b, NUM_MOVES .asm_3e838 ld a, [hl] and a @@ -6067,11 +6096,11 @@ Function3e7c1: ; 3e7c1 dec a jr nz, .asm_3e882 .asm_3e855 - ld hl, EnemyMonMove1 + ld hl, EnemyMonMoves call BattleRandom - and $3 + and 3 ; TODO factor in NUM_MOVES ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [EnemyDisableCount] swap a @@ -6082,7 +6111,7 @@ Function3e7c1: ; 3e7c1 ld a, [hl] and a jr z, .asm_3e855 - ld hl, EnemyMonPPMove1 + ld hl, EnemyMonPP add hl, bc ld b, a ld a, [hl] @@ -6104,56 +6133,56 @@ Function3e7c1: ; 3e7c1 ld [$c733], a .asm_3e894 - ld a, [EnemyMoveEffect] - cp $77 + ld a, [wEnemyMoveStruct + MOVE_EFFECT] + cp EFFECT_FURY_CUTTER jr z, .asm_3e89f xor a ld [EnemyFuryCutterCount], a .asm_3e89f - ld a, [EnemyMoveEffect] - cp $51 + ld a, [wEnemyMoveStruct + MOVE_EFFECT] + cp EFFECT_RAGE jr z, .asm_3e8af ld hl, EnemySubStatus4 - res 6, [hl] + res SUBSTATUS_RAGE, [hl] xor a ld [$c72c], a .asm_3e8af - ld a, [EnemyMoveEffect] - cp $6f + ld a, [wEnemyMoveStruct + MOVE_EFFECT] + cp EFFECT_PROTECT ret z - cp $74 + cp EFFECT_ENDURE ret z xor a - ld [$c681], a + ld [EnemyProtectCount], a ret .asm_3e8bd - ld a, $a5 + ld a, STRUGGLE jr .asm_3e87f ; 3e8c1 Function3e8c1: ; 3e8c1 xor a ld [EnemyFuryCutterCount], a - ld [$c681], a + ld [EnemyProtectCount], a ld [$c72c], a ld hl, EnemySubStatus4 - res 6, [hl] + res SUBSTATUS_RAGE, [hl] ret ; 3e8d1 Function3e8d1: ; 3e8d1 ld a, [EnemySubStatus4] - and $20 + and 1 << SUBSTATUS_RECHARGE ret nz ld hl, EnemySubStatus3 ld a, [hl] - and $13 + and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE ret nz ld hl, EnemySubStatus1 - bit 6, [hl] + bit SUBSTATUS_ROLLOUT, [hl] ret ; 3e8e4 @@ -6251,9 +6280,8 @@ LoadEnemyMon: ; 3e8eb and a jr z, .InitDVs -; ???? ld a, [EnemySubStatus5] - bit 3, a + bit SUBSTATUS_TRANSFORMED, a jr z, .InitDVs ; Unknown @@ -6366,8 +6394,7 @@ LoadEnemyMon: ; 3e8eb ; Get letter based on DVs ld hl, EnemyMonDVs - ld a, PREDEF_GET_UNOWN_LETTER - call Predef + predef GetUnownLetter ; Can't use any letters that haven't been unlocked ; If combined with forced shiny battletype, causes an infinite loop call CheckUnownLetter @@ -6448,8 +6475,7 @@ LoadEnemyMon: ; 3e8eb ld de, EnemyMonMaxHP ld b, $00 ld hl, $d201 ; ? - ld a, PREDEF_FILLSTATS - call Predef + predef Functione167 ; If we're in a trainer battle, ; get the rest of the parameters from the party struct @@ -6461,15 +6487,14 @@ LoadEnemyMon: ; 3e8eb 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 @@ -6483,9 +6508,9 @@ LoadEnemyMon: ; 3e8eb ld [hli], a ; Full HP... - ld a, [EnemyMonMaxHPHi] + ld a, [EnemyMonMaxHP] ld [hli], a - ld a, [EnemyMonMaxHPLo] + ld a, [EnemyMonMaxHP + 1] ld [hl], a ; ...unless it's a RoamMon @@ -6501,13 +6526,13 @@ LoadEnemyMon: ; 3e8eb jr z, .InitRoamHP ; Update from the struct if it has ld a, [hl] - ld [EnemyMonHPLo], a + ld [EnemyMonHP + 1], a jr .Moves .InitRoamHP ; HP only uses the lo byte in the RoamMon struct since ; Raikou/Entei/Suicune will have < 256 hp at level 40 - ld a, [EnemyMonHPLo] + ld a, [EnemyMonHP + 1] ld [hl], a jr .Moves @@ -6518,9 +6543,9 @@ LoadEnemyMon: ; 3e8eb ld a, [CurPartyMon] call GetPartyLocation ld a, [hld] - ld [EnemyMonHPLo], a + ld [EnemyMonHP + 1], a ld a, [hld] - ld [EnemyMonHPHi], a + ld [EnemyMonHP], a ; Make sure everything knows which monster the opponent is using ld a, [CurPartyMon] @@ -6533,7 +6558,6 @@ LoadEnemyMon: ; 3e8eb .Moves -; ???? ld hl, BaseType1 ld de, EnemyMonType1 ld a, [hli] @@ -6568,8 +6592,7 @@ LoadEnemyMon: ; 3e8eb ; Make sure the predef knows this isn't a partymon ld [MagikarpLength], a ; Fill moves based on level - ld a, PREDEF_FILLMOVES - call Predef + predef FillMoves .PP ; Trainer battle? @@ -6580,8 +6603,7 @@ LoadEnemyMon: ; 3e8eb ; Fill wild PP ld hl, EnemyMonMoves ld de, EnemyMonPP - ld a, PREDEF_FILLPP - call Predef + predef FillPP jr .Finish .TrainerPP @@ -6634,8 +6656,7 @@ LoadEnemyMon: ; 3e8eb ld c, a ld b, 1 ; set ld hl, PokedexSeen - ld a, PREDEF_FLAG - call Predef + predef FlagPredef ld hl, EnemyMonStats ld de, EnemyStats @@ -6795,7 +6816,7 @@ Function3ebd8: ; 3ebd8 ld a, [OtherTrainerClass] ld [TrainerClass], a ld de, VTiles2 - callab Function5120d + callab GetTrainerPic hlcoord 19, 0 ld c, $0 .asm_3ebf3 @@ -6866,7 +6887,7 @@ Function3ec39: ; 3ec39 and a jr z, .asm_3ec5a ld a, [BattleMonStatus] - and $40 + and 1 << PAR ret z ld hl, $c645 ld a, [hld] @@ -6887,7 +6908,7 @@ Function3ec39: ; 3ec39 .asm_3ec5a ld a, [EnemyMonStatus] - and $40 + and 1 << PAR ret z ld hl, $d21f ld a, [hld] @@ -6912,7 +6933,7 @@ Function3ec76: ; 3ec76 and a jr z, .asm_3ec93 ld a, [BattleMonStatus] - and $10 + and 1 << BRN ret z ld hl, $c641 ld a, [hld] @@ -6931,7 +6952,7 @@ Function3ec76: ; 3ec76 .asm_3ec93 ld a, [EnemyMonStatus] - and $10 + and 1 << BRN ret z ld hl, $d21b ld a, [hld] @@ -6966,11 +6987,11 @@ Function3ecb7: ; 3ecb7 ld a, [$d265] and a ld a, c - ld hl, BattleMonAtk + ld hl, BattleMonAttack ld de, PlayerStats ld bc, PlayerAtkLevel jr z, .asm_3ecd2 - ld hl, EnemyMonAtk + ld hl, EnemyMonAttack ld de, EnemyStats ld bc, EnemyAtkLevel @@ -7104,7 +7125,7 @@ BadgeStatBoosts: ; 3ed45 or c ld b, a - ld hl, BattleMonAtk + ld hl, BattleMonAttack ld c, 4 .CheckBadge ld a, b @@ -7274,8 +7295,7 @@ Function3ee17: ; 3ee17 ld a, d ld [FXAnimIDHi], a call WaitBGMap - ld a, $37 - jp Predef + predef_jump PlayBattleAnim ; 3ee27 Function3ee27: ; 3ee27 @@ -7320,8 +7340,7 @@ Function3ee3b: ; 3ee3b ld c, a ld b, $2 ld d, $0 - ld a, $3 - call Predef + predef FlagPredef ld a, c and a pop bc @@ -7423,7 +7442,7 @@ Function3ee3b: ; 3ee3b ld a, [$ffb5] ld [StringBuffer2], a ld a, [CurPartyMon] - ld hl, PartyMon1Nickname + ld hl, PartyMonNicknames call GetNick ld hl, UnknownText_0x3f11b call BattleTextBox @@ -7494,8 +7513,7 @@ Function3ee3b: ; 3ee3b .asm_3ef74 xor a ld [MonType], a - ld a, $1f - call Predef + predef Function5084a callab Function50e1b pop bc ld hl, PartyMon1Level - PartyMon1 @@ -7531,8 +7549,7 @@ Function3ee3b: ; 3ee3b add hl, bc push bc ld b, $1 - ld a, $c - call Predef + predef Functione167 pop bc pop de ld hl, $0025 @@ -7571,7 +7588,7 @@ Function3ee3b: ; 3ee3b 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 @@ -7585,7 +7602,7 @@ Function3ee3b: ; 3ee3b call Function3ecab callab Function3ec2c callab BadgeStatBoosts - callab Function3df48 + callab UpdatePlayerHUD call EmptyBattleTextBox call Function309d ld a, $1 @@ -7608,16 +7625,14 @@ Function3ee3b: ; 3ee3b .asm_3f057 xor a ld [MonType], a - ld a, $1f - call Predef + predef Function5084a hlcoord 9, 0 ld b, $a ld c, $9 call TextBox hlcoord 11, 1 ld bc, $0004 - ld a, $28 - call Predef + predef Function50b7b ld c, $1e call DelayFrames call Functiona80 @@ -7637,8 +7652,7 @@ Function3ee3b: ; 3ee3b ld a, b ld [CurPartyLevel], a push bc - ld a, $1a - call Predef + predef LearnLevelMoves pop bc ld a, b cp c @@ -7649,8 +7663,7 @@ Function3ee3b: ; 3ee3b ld a, [CurPartyMon] ld c, a ld b, $1 - ld a, $3 - call Predef + predef FlagPredef pop af ld [CurPartyLevel], a @@ -7767,8 +7780,7 @@ Function3f136: ; 3f136 ld [DefaultFlypoint], a xor a ld [MonType], a - ld a, $1f - call Predef + predef Function5084a ld a, [TempMonLevel] ld b, a ld e, a @@ -7951,14 +7963,14 @@ Function3f26d: ; 3f26d jr nz, .asm_3f2ce .asm_3f27c - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] or [hl] ld hl, UnknownText_0x3f2d1 jr z, .asm_3f2ce xor a ld [hMultiplicand], a - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] ld [$c6ea], a ld [$ffb5], a @@ -7968,7 +7980,7 @@ Function3f26d: ; 3f26d ld a, $19 ld [hMultiplier], a call Multiply - ld hl, EnemyMonMaxHPHi + ld hl, EnemyMonMaxHP ld a, [hli] ld b, [hl] srl a @@ -8043,7 +8055,7 @@ UnknownText_0x3f2fa: ; 3f2fa Function3f2ff: ; 3f2ff push de push bc - ld hl, EnemyMonHPLo + ld hl, EnemyMonHP + 1 ld de, $c6eb ld b, [hl] dec hl @@ -8058,7 +8070,7 @@ Function3f2ff: ; 3f2ff ld a, $19 ld [hMultiplier], a call Multiply - ld hl, EnemyMonMaxHPHi + ld hl, EnemyMonMaxHP ld a, [hli] ld b, [hl] srl a @@ -8279,9 +8291,10 @@ Function3f41c: ; 3f41c Function3f43d: ; 3f43d ld a, [PlayerSubStatus4] - bit 4, a + bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_DD jr nz, Function3f46f + Function3f447: ; 3f447 ld a, [$c6fe] and a @@ -8291,12 +8304,10 @@ Function3f447: ; 3f447 push af ld a, [BattleMonSpecies] ld [CurPartySpecies], a - ld hl, BattleMonAtkDefDV - ld a, $2d - call Predef + ld hl, BattleMonDVs + predef GetUnownLetter ld de, $9310 - ld a, $3d - call Predef + predef GetBackpic pop af ld [CurPartySpecies], a ret @@ -8316,26 +8327,26 @@ Function3f46f: ; 3f46f Function3f47c: ; 3f47c ld a, [EnemySubStatus4] - bit 4, a + bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_DD jr nz, Function3f4b4 + Function3f486: ; 3f486 ld a, [$c6fa] and a ld hl, BattleAnimCmd_E2 jr nz, Function3f4b4 + ld a, [CurPartySpecies] push af ld a, [EnemyMonSpecies] ld [CurSpecies], a ld [CurPartySpecies], a call GetBaseData - ld hl, EnemyMonAtkDefDV - ld a, $2d - call Predef + ld hl, EnemyMonDVs + predef GetUnownLetter ld de, VTiles2 - ld a, $3e - call Predef + predef Function5108b pop af ld [CurPartySpecies], a ret @@ -8410,7 +8421,7 @@ Function3f4dd: ; 3f4dd call ClearSprites ld a, [IsInBattle] cp $1 - call z, Function3e036 + call z, UpdateEnemyHUD ld a, $1 ld [hBGMapMode], a ret @@ -8441,7 +8452,7 @@ Function3f568: ; 3f568 ld a, $6 ld [rSVBK], a ld hl, $d000 - ld bc, VBlank5 + ld bc, $400 ld a, $2 call ByteFill ld a, [rVBK] @@ -8465,28 +8476,29 @@ Function3f594: ; 3f594 xor a ld [TempEnemyMonSpecies], a callab Function3957b - callab Function39771 + callab ReadTrainerParty + ld a, [TrainerClass] - cp $9 - jr nz, .asm_3f5b8 + cp RIVAL1 + jr nz, .ok xor a ld [OTPartyMon1Item], a +.ok -.asm_3f5b8 ld de, VTiles2 - callab Function5120d + callab GetTrainerPic xor a ld [$ffad], a dec a ld [$c6e6], a hlcoord 12, 0 - ld bc, $0707 - ld a, $13 - call Predef + lb bc, 7, 7 + predef FillBox ld a, $ff ld [CurOTMon], a - ld a, $2 + ld a, TRAINER_BATTLE ld [IsInBattle], a + call IsJohtoGymLeader jr nc, .asm_3f606 xor a @@ -8495,14 +8507,13 @@ Function3f594: ; 3f594 ld b, a .asm_3f5ea push bc - ld a, $22 + ld a, PartyMon1HP - PartyMon1 call GetPartyParamLocation ld a, [hli] or [hl] jr z, .asm_3f5fc ld c, $4 callab ChangeHappiness - .asm_3f5fc pop bc dec b @@ -8510,7 +8521,6 @@ Function3f594: ; 3f594 ld hl, CurPartyMon inc [hl] jr .asm_3f5ea - .asm_3f606 ret ; 3f607 @@ -8520,44 +8530,40 @@ Function3f607: ; 3f607 ld [IsInBattle], a callba Function10605d call LoadEnemyMon - ld hl, EnemyMonMove1 + ld hl, EnemyMonMoves ld de, $c735 - ld bc, $0004 + ld bc, NUM_MOVES call CopyBytes - ld hl, EnemyMonPPMove1 + ld hl, EnemyMonPP ld de, $c739 - ld bc, $0004 + ld bc, NUM_MOVES call CopyBytes - ld hl, EnemyMonAtkDefDV - ld a, $2d - call Predef + ld hl, EnemyMonDVs + predef GetUnownLetter ld a, [CurPartySpecies] - cp $c9 + cp UNOWN jr nz, .asm_3f648 ld a, [$def4] and a jr nz, .asm_3f648 ld a, [UnownLetter] ld [$def4], a - .asm_3f648 ld de, VTiles2 - ld a, $3e - call Predef + predef Function5108b xor a ld [TrainerClass], a ld [$ffad], a hlcoord 12, 0 - ld bc, $0707 - ld a, $13 - call Predef + lb bc, 7, 7 + predef FillBox ret ; 3f662 Function3f662: ; 3f662 - ld hl, EnemyMonMove1 + ld hl, EnemyMonMoves ld de, $d25e - ld b, 4 + ld b, NUM_MOVES .loop ld a, [de] inc de @@ -8571,7 +8577,7 @@ Function3f662: ; 3f662 push hl dec a ld hl, Moves + MOVE_PP - ld bc, Move2 - Move1 + ld bc, MOVE_LENGTH call AddNTimes ld a, BANK(Moves) call GetFarByte @@ -8618,7 +8624,7 @@ Function3f6a5: ; 3f6a5 and a jr z, .asm_3f6b7 call Function3f759 - ld c, $96 + ld c, 150 call DelayFrames call Function3f77c ret @@ -8630,8 +8636,7 @@ Function3f6a5: ; 3f6a5 call Function3f71d xor a ld [$d1e9], a - ld a, $1c - call Predef + predef Function421e6 callba Function2ed44 ret ; 3f6d0 @@ -8661,16 +8666,16 @@ Function3f6d0: ; 3f6d0 ld [$d0e1], a ld hl, PlayerSubStatus1 ld b, $18 -.asm_3f715 +.loop ld [hli], a dec b - jr nz, .asm_3f715 + jr nz, .loop call WaitSFX ret ; 3f71d Function3f71d: ; 3f71d - ld hl, $c6ec + ld hl, wPayDayMoney ld a, [hli] or [hl] inc hl @@ -8679,7 +8684,7 @@ Function3f71d: ; 3f71d ld a, [$c73d] and a jr z, .asm_3f73d - ld hl, $c6ee + ld hl, wPayDayMoney + 2 sla [hl] dec hl rl [hl] @@ -8692,8 +8697,8 @@ Function3f71d: ; 3f71d ld [hl], a .asm_3f73d - ld hl, $c6ee - ld de, $d850 + ld hl, wPayDayMoney + 2 + ld de, Money + 2 call Function3d0be ld hl, BattleText_0x80730 call StdBattleTextBox @@ -8966,7 +8971,7 @@ Function3f998: ; 3f998 and $f jr z, .asm_3f9af call GetRoamMonHP - ld a, [EnemyMonHPLo] + ld a, [EnemyMonHP + 1] ld [hl], a jr .asm_3f9ca @@ -8994,74 +8999,74 @@ Function3f998: ; 3f998 GetRoamMonMapGroup: ; 3f9d1 ld a, [TempEnemyMonSpecies] ld b, a - ld a, [RoamMon1Species] + ld a, [wRoamMon1Species] cp b - ld hl, RoamMon1MapGroup + ld hl, wRoamMon1MapGroup ret z - ld a, [RoamMon2Species] + ld a, [wRoamMon2Species] cp b - ld hl, RoamMon2MapGroup + ld hl, wRoamMon2MapGroup ret z - ld hl, RoamMon3MapGroup + ld hl, wRoamMon3MapGroup ret ; 3f9e9 GetRoamMonMapNumber: ; 3f9e9 ld a, [TempEnemyMonSpecies] ld b, a - ld a, [RoamMon1Species] + ld a, [wRoamMon1Species] cp b - ld hl, RoamMon1MapNumber + ld hl, wRoamMon1MapNumber ret z - ld a, [RoamMon2Species] + ld a, [wRoamMon2Species] cp b - ld hl, RoamMon2MapNumber + ld hl, wRoamMon2MapNumber ret z - ld hl, RoamMon3MapNumber + ld hl, wRoamMon3MapNumber ret ; 3fa01 GetRoamMonHP: ; 3fa01 -; output: hl = RoamMonHP +; output: hl = wRoamMonHP ld a, [TempEnemyMonSpecies] ld b, a - ld a, [RoamMon1Species] + ld a, [wRoamMon1Species] cp b - ld hl, RoamMon1HP + ld hl, wRoamMon1HP ret z - ld a, [RoamMon2Species] + ld a, [wRoamMon2Species] cp b - ld hl, RoamMon2HP + ld hl, wRoamMon2HP ret z - ld hl, RoamMon3HP + ld hl, wRoamMon3HP ret ; 3fa19 GetRoamMonDVs: ; 3fa19 -; output: hl = RoamMonDVs +; output: hl = wRoamMonDVs ld a, [TempEnemyMonSpecies] ld b, a - ld a, [RoamMon1Species] + ld a, [wRoamMon1Species] cp b - ld hl, RoamMon1DVs + ld hl, wRoamMon1DVs ret z - ld a, [RoamMon2Species] + ld a, [wRoamMon2Species] cp b - ld hl, RoamMon2DVs + ld hl, wRoamMon2DVs ret z - ld hl, RoamMon3DVs + ld hl, wRoamMon3DVs ret ; 3fa31 GetRoamMonSpecies: ; 3fa31 ld a, [TempEnemyMonSpecies] - ld hl, RoamMon1Species + ld hl, wRoamMon1Species cp [hl] ret z - ld hl, RoamMon2Species + ld hl, wRoamMon2Species cp [hl] ret z - ld hl, RoamMon3Species + ld hl, wRoamMon3Species ret ; 3fa42 @@ -9305,8 +9310,7 @@ Function3fb6c: ; 3fb6c ld [$ffad], a hlcoord 2, 6 ld bc, $0606 - ld a, $13 - call Predef + predef FillBox xor a ld [hWY], a ld [rWY], a @@ -9328,7 +9332,7 @@ Function3fbd6: ; 3fbd6 ld a, $6 ld [rSVBK], a ld hl, $d000 - ld bc, VBlank5 + ld bc, $400 ld a, $7f call ByteFill ld de, $d000 @@ -9377,8 +9381,7 @@ GetBattleBackpic: ; 3fbff .Decompress ld de, $9310 ld c, $31 - ld a, PREDEF_DECOMPRESS - call Predef + predef DecompressPredef ret ; 3fc30 @@ -9401,15 +9404,14 @@ Function3fc30: ; 3fc30 ld [$ffad], a hlcoord 2, 6 ld bc, $0606 - ld a, $13 - call Predef + predef FillBox ret ; 3fc5b Function3fc5b: ; 3fc5b ld hl, Sprites xor a - ld [hConnectionStripLength], a + ld [$ffaf], a ld b, $6 ld e, $a8 .asm_3fc65 @@ -9420,10 +9422,10 @@ Function3fc5b: ; 3fc5b 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 @@ -9431,9 +9433,9 @@ Function3fc5b: ; 3fc5b 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 @@ -9470,7 +9472,7 @@ BattleStartMessage: ; 3fc8b ld [hBattleTurn], a ld a, 1 ld [$c689], a - ld de, $0101 + ld de, ANIM_SEND_OUT_MON call Function3ee17 .asm_3fcc2 @@ -9483,8 +9485,7 @@ BattleStartMessage: ; 3fc8b hlcoord 12, 0 ld d, $0 ld e, $1 - ld a, $47 - call Predef + predef Functiond008e jr .asm_3fceb .asm_3fce0 @@ -9507,8 +9508,8 @@ BattleStartMessage: ; 3fc8b ld hl, PokemonFellFromTreeText cp BATTLETYPE_TREE jr z, .asm_3fd0e - ld hl, WildPokemonAppearedText2 - cp $b + ld hl, WildCelebiAppearedText + cp BATTLETYPE_CELEBI jr z, .asm_3fd0e ld hl, WildPokemonAppearedText diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index d16528d22..dc82b4500 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -16,10 +16,10 @@ DoEnemyTurn: ; 3400a 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 @@ DoTurn: ; 3401d 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,218 +146,206 @@ BattleCommand01: ; 34084 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 + ld hl, UpdatePlayerHUD call CallBattleCore 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 call CantMove jp Function34385 +.not_frozen -.CheckFlinch - ld hl, PlayerSubStatus3 - bit 3, [hl] ; flinch - jr z, .CheckDisabled - res 3, [hl] + ld hl, PlayerSubStatus3 + bit SUBSTATUS_FLINCHED, [hl] + jr z, .not_flinched -; 'flinched!' + res SUBSTATUS_FLINCHED, [hl] ld hl, FlinchedText call StdBattleTextBox 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 @@ -367,13 +355,13 @@ CheckPlayerTurn: CantMove: ; 341f0 ld a, BATTLE_VARS_SUBSTATUS1 - call _GetBattleVar - res 6, [hl] + call GetBattleVarAddr + res SUBSTATUS_ROLLOUT, [hl] ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr ld a, [hl] - and $ec + and $ff ^ (1<<SUBSTATUS_BIDE + 1<<SUBSTATUS_RAMPAGE + 1<<SUBSTATUS_CHARGED) ld [hl], a call ResetFuryCutterCount @@ -383,12 +371,12 @@ CantMove: ; 341f0 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,137 +392,129 @@ Function34216: ; 34216 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 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 UpdateEnemyMonInParty - ld hl, Function3e036 + ld hl, UpdateEnemyHUD call CallBattleCore 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 - res 3, [hl] + ld hl, EnemySubStatus3 + bit SUBSTATUS_FLINCHED, [hl] + jr z, .not_flinched -; 'flinched!' + res SUBSTATUS_FLINCHED, [hl] ld hl, FlinchedText call StdBattleTextBox 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 .CheckAttract + jr .not_confused -.Confused -; 'confused!' +.confused ld hl, IsConfusedText call StdBattleTextBox @@ -543,104 +523,94 @@ CheckEnemyTurn: ; 3421f 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 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,17 +626,16 @@ Function34385: ; 34385 MoveDisabled: ; 3438d -; Make sure any charged moves fail + ; Make sure any charged moves fail ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar - res 4, [hl] + call GetBattleVarAddr + res SUBSTATUS_CHARGED, [hl] ld a, BATTLE_VARS_MOVE call GetBattleVar ld [$d265], a call GetMoveName -; 'disabled!' ld hl, DisabledMoveText jp StdBattleTextBox ; 343a5 @@ -674,7 +643,6 @@ MoveDisabled: ; 3438d HitConfusion: ; 343a5 -; 'hurt itself in its confusion!' ld hl, HurtItselfText call StdBattleTextBox @@ -682,30 +650,25 @@ HitConfusion: ; 343a5 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 + ld hl, UpdatePlayerHUD call CallBattleCore - ld a, $1 ld [$ffd4], a - ld c, $1 call Function35d7e - jp BattleCommand0c ; 343db @@ -713,7 +676,7 @@ HitConfusion: ; 343a5 BattleCommand02: ; 343db ; checkobedience -; Enemy can't disobey + ; Enemy can't disobey ld a, [hBattleTurn] and a ret nz @@ -721,7 +684,7 @@ BattleCommand02: ; 343db 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 @@ BattleCommand02: ; 343db 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 @@ BattleCommand02: ; 343db 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 @@ BattleCommand02: ; 343db .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,25 +816,21 @@ BattleCommand02: ; 343db cp b jr nc, .DoNothing -; 'won't obey!' ld hl, WontObeyText call StdBattleTextBox - call HitConfusion - - jp Function3450c + jp .asm_3450c .Nap 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,33 +839,29 @@ BattleCommand02: ; 343db 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 .Print call StdBattleTextBox - jp Function3450c + jp .asm_3450c .UseInstead ; Can't use another move if the monster only has one! - ld a, [BattleMonMove2] + ld a, [BattleMonMoves + 1] and a jr z, .DoNothing @@ -965,7 +921,7 @@ BattleCommand02: ; 343db .RandomMove call BattleRandom - and 3 + and 3 ; TODO NUM_MOVES cp b jr nc, .RandomMove @@ -1003,19 +959,15 @@ BattleCommand02: ; 343db pop af ld [CurMoveNum], a - ; fallthrough -; 3450c - -Function3450c: ; 3450c +.asm_3450c xor a ld [LastPlayerMove], a ld [LastEnemyCounterMove], a + ; Break Encore too. ld hl, PlayerSubStatus5 - res 4, [hl] - -; Break encore too. + res SUBSTATUS_ENCORED, [hl] xor a ld [PlayerEncoreCount], a @@ -1038,7 +990,7 @@ IgnoreSleepOnly: ; 3451f .CheckSleep ld a, BATTLE_VARS_STATUS call GetBattleVar - and 7 + and SLP ret z ; 'ignored orders…sleeping!' @@ -1113,7 +1065,7 @@ BattleCommand04: ; 34555 inc de ld a, [de] - bit 3, a + bit SUBSTATUS_TRANSFORMED, a ret nz ld a, [hBattleTurn] @@ -1147,20 +1099,20 @@ BattleCommand04: ; 34555 .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 ld hl, EnemyMonMoves ld a, [CurEnemyMoveNum] ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hl] cp MIMIC @@ -1410,7 +1362,7 @@ BattleCommand07: ; 346d2 .go ld a, BATTLE_VARS_MOVE_TYPE - call _GetBattleVar + call GetBattleVarAddr ld [$d265], a push hl @@ -1467,12 +1419,12 @@ BattleCommand07: ; 346d2 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 @@ -1584,7 +1536,7 @@ Function347d3: ; 347d3 ld b, [hl] inc hl ld c, [hl] - ld a, $a + ld a, 10 ; 1.0 ld [$d265], a ld hl, TypeMatchup .asm_347e7 @@ -1675,7 +1627,7 @@ Function3484e: ; 3484e jr z, .asm_3489f ; 0x34863 $3a push hl dec a - ld hl, Moves + PlayerMovePower - PlayerMoveStruct + ld hl, Moves + MOVE_POWER call GetMoveAttr and a jr z, .asm_3489b ; 0x3486e $2b @@ -1744,8 +1696,8 @@ Function3484e: ; 3484e Function348de: ; 348de - ld de, EnemyMonMove1 - ld b, 5 + ld de, EnemyMonMoves + ld b, NUM_MOVES + 1 ld c, 0 ld a, [$d265] @@ -1761,7 +1713,7 @@ Function348de: ; 348de inc de dec a - ld hl, Moves + PlayerMovePower - PlayerMoveStruct + ld hl, Moves + MOVE_POWER call GetMoveAttr and a jr z, .loop @@ -1775,7 +1727,7 @@ Function348de: ; 348de jr z, .loop inc c - cp $a + cp 10 jr c, .loop inc c @@ -1784,10 +1736,10 @@ Function348de: ; 348de inc c inc c - cp $a + cp 10 jr z, .loop - ld c, $64 + ld c, 100 jr .loop .exit @@ -1797,9 +1749,9 @@ Function348de: ; 348de ld a, c and a jr z, .doubledown ; double down - cp $5 + cp 5 jr c, Function34931 ; down - cp $64 + cp 100 ret c jr Function34939 ; up @@ -1833,11 +1785,11 @@ Function34941: ; 34941 ret c ld a, [EnemySubStatus1] - bit 4, a + bit SUBSTATUS_PERISH, a jr z, .asm_34986 - ld a, [$c67f] - cp $1 + ld a, [EnemyPerishCount] + cp 1 jr nz, .asm_34986 call Function349f4 @@ -1969,10 +1921,11 @@ Function349f4: ; 349f4 ld a, c or b ld c, a + .asm_34a16 srl b push bc - ld bc, $30 + ld bc, PartyMon2 - PartyMon1 add hl, bc pop bc inc e @@ -2010,7 +1963,7 @@ Function34a2a: ; 34a2a push hl push bc - ld bc, $0022 + ld bc, PartyMon1HP - PartyMon1 add hl, bc pop bc ld a, [hli] @@ -2023,7 +1976,7 @@ Function34a2a: ; 34a2a call GetBaseData ld a, [LastEnemyCounterMove] dec a - ld hl, Moves + PlayerMovePower - PlayerMoveStruct + ld hl, Moves + MOVE_POWER call GetMoveAttr and a jr z, .asm_34a77 @@ -2045,7 +1998,7 @@ Function34a2a: ; 34a2a ret z push bc - ld bc, $30 + ld bc, PartyMon2 - PartyMon1 add hl, bc pop bc @@ -2074,7 +2027,7 @@ Function34a85: ; 34a85 .asm_34a98 srl b push bc - ld bc, $2f + ld bc, PartyMon2HP - (PartyMon1HP + 1) add hl, bc pop bc dec e @@ -2093,7 +2046,7 @@ Function34aa7: ; 34aa7 ld a, $ff ld [$c716], a - ld hl, OTPartyMon1Move1 + ld hl, OTPartyMon1Moves ld b, $20 ld d, $0 ld e, $0 @@ -2104,7 +2057,7 @@ Function34aa7: ; 34aa7 push hl push bc - ld b, $4 + ld b, NUM_MOVES ld c, $0 .asm_34abf ld a, [hli] @@ -2113,7 +2066,7 @@ Function34aa7: ; 34aa7 jr z, .asm_34aef dec a - ld hl, Moves + PlayerMovePower - PlayerMoveStruct + ld hl, Moves + MOVE_POWER call GetMoveAttr and a jr z, .asm_34ae9 @@ -2159,7 +2112,7 @@ Function34aa7: ; 34aa7 .asm_34b00 push bc - ld bc, $0030 + ld bc, PartyMon2 - PartyMon1 add hl, bc pop bc srl b @@ -2206,7 +2159,7 @@ Function34b20: ; 34b20 jr z, .asm_34b4a dec a - ld hl, Moves + PlayerMovePower - PlayerMoveStruct + ld hl, Moves + MOVE_POWER call GetMoveAttr and a jr z, .asm_34b4a @@ -2288,7 +2241,7 @@ Function34b77: ; 34b77 srl b pop hl push bc - ld bc, $0030 + ld bc, PartyMon2 - PartyMon1 add hl, bc pop bc jr .asm_34b82 @@ -2394,12 +2347,12 @@ BattleCommand09: ; 34d32 call .StatModifiers - ld a, [PlayerMoveAccuracy] + ld a, [wPlayerMoveStruct + MOVE_ACC] ld b, a ld a, [hBattleTurn] and a jr z, .BrightPowder - ld a, [EnemyMoveAccuracy] + ld a, [wEnemyMoveStruct + MOVE_ACC] ld b, a .BrightPowder @@ -2485,7 +2438,7 @@ BattleCommand09: ; 34d32 ; Return nz if we are locked-on and aren't trying to use Earthquake, ; Fissure or Magnitude on a monster that is flying. ld a, BATTLE_VARS_SUBSTATUS5_OPP - call _GetBattleVar + call GetBattleVarAddr bit SUBSTATUS_LOCK_ON, [hl] res SUBSTATUS_LOCK_ON, [hl] ret z @@ -2591,7 +2544,7 @@ BattleCommand09: ; 34d32 ld a, [hBattleTurn] and a - ld hl, PlayerMoveAccuracy + ld hl, wPlayerMoveStruct + MOVE_ACC ld a, [PlayerAccLevel] ld b, a ld a, [EnemyEvaLevel] @@ -2599,7 +2552,7 @@ BattleCommand09: ; 34d32 jr z, .asm_34e60 - ld hl, EnemyMoveAccuracy + ld hl, wEnemyMoveStruct + MOVE_ACC ld a, [EnemyAccLevel] ld b, a ld a, [PlayerEvaLevel] @@ -2694,11 +2647,11 @@ BattleCommand90: ; 34ecc jr nz, .failed push hl - ld hl, PlayerMoveEffectChance + ld hl, wPlayerMoveStruct + MOVE_CHANCE ld a, [hBattleTurn] and a jr z, .asm_34ee1 - ld hl, EnemyMoveEffectChance + ld hl, wEnemyMoveStruct + MOVE_CHANCE .asm_34ee1 call BattleRandom @@ -2937,7 +2890,7 @@ BattleCommand0d: ; 35023 call Function350e4 ld a, BATTLE_VARS_MOVE_ANIM - call _GetBattleVar + call GetBattleVarAddr cp FLY jr z, .asm_3504f ; 35032 $1b @@ -2962,7 +2915,7 @@ BattleCommand0d: ; 35023 .asm_3504f ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr res SUBSTATUS_UNDERGROUND, [hl] res SUBSTATUS_FLYING, [hl] call Function37ece @@ -3195,7 +3148,7 @@ BattleCommandad: ; 351a5 ; supereffectivelooptext ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr bit 2, a ret nz @@ -3223,7 +3176,7 @@ BattleCommand11: ; 351c0 ; Faint the user if it fainted an opponent using Destiny Bond. - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hBattleTurn] and a jr z, .asm_351cb @@ -3270,8 +3223,7 @@ BattleCommand11: ; 351c0 ld [$d1ef], a ld h, b ld l, c - ld a, $b - call Predef + predef Functionc6e0 call RefreshBattleHuds call SwitchTurn @@ -3437,7 +3389,7 @@ PlayerAttackDamage: ; 352e2 call ResetDamage - ld hl, PlayerMovePower + ld hl, wPlayerMoveStruct + MOVE_POWER ld a, [hli] and a ld d, a @@ -3447,22 +3399,20 @@ PlayerAttackDamage: ; 352e2 cp SPECIAL jr nc, .special - -; Physical - ld hl, EnemyMonDef +.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 .physicalcrit - ld hl, BattleMonAtk + ld hl, BattleMonAttack call GetDamageStatsCritical jr c, .thickclub @@ -3473,16 +3423,14 @@ PlayerAttackDamage: ; 352e2 ld hl, PlayerStats jr .thickclub - .special ld hl, EnemyMonSpclDef ld a, [hli] 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 @@ -3585,7 +3533,7 @@ GetDamageStats: ; 3537e ld a, [hBattleTurn] and a jr nz, .enemy - ld a, [PlayerMoveType] + ld a, [wPlayerMoveStruct + MOVE_TYPE] cp SPECIAL ; special ld a, [PlayerSAtkLevel] @@ -3599,7 +3547,7 @@ GetDamageStats: ; 3537e jr .end .enemy - ld a, [EnemyMoveType] + ld a, [wEnemyMoveStruct + MOVE_TYPE] cp SPECIAL ; special ld a, [EnemySAtkLevel] @@ -3698,8 +3646,8 @@ EnemyAttackDamage: ; 353f6 call ResetDamage ; No damage dealt with 0 power. - ld hl, EnemyMovePower - ld a, [hli] ; hl = EnemyMoveType + ld hl, wEnemyMoveStruct + MOVE_POWER + ld a, [hli] ; hl = wEnemyMoveStruct + MOVE_TYPE ld d, a and a ret z @@ -3708,22 +3656,20 @@ EnemyAttackDamage: ; 353f6 cp SPECIAL jr nc, .Special - -; Physical - ld hl, BattleMonDef +.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 .physicalcrit - ld hl, EnemyMonAtk + ld hl, EnemyMonAttack call GetDamageStatsCritical jr c, .thickclub @@ -3734,16 +3680,14 @@ EnemyAttackDamage: ; 353f6 ld hl, EnemyStats jr .thickclub - .Special ld hl, BattleMonSpclDef ld a, [hli] 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 @@ -3787,14 +3731,14 @@ BattleCommanda1: ; 35461 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 @@ -3803,7 +3747,7 @@ BattleCommanda1: ; 35461 ld [DefaultFlypoint], a .asm_3548d ld a, [DefaultFlypoint] - ld hl, PartyMon1Nickname + ld hl, PartyMonNicknames call GetNick ld a, $22 call Function355bd @@ -3815,7 +3759,7 @@ BattleCommanda1: ; 35461 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 @@ -3846,7 +3790,7 @@ BattleCommanda1: ; 35461 ld a, [hl] ld e, a pop bc - ld a, [PlayerMovePower] + ld a, [wPlayerMoveStruct + MOVE_POWER] ld d, a ret @@ -3882,7 +3826,7 @@ BattleCommanda1: ; 35461 ld a, [DefaultFlypoint] ld c, a - ld b, $0 + ld b, 0 ld hl, OTPartySpecies add hl, bc ld a, [hl] @@ -3892,8 +3836,8 @@ BattleCommanda1: ; 35461 .asm_35532 ld a, [DefaultFlypoint] - ld hl, OTPartyMon1Nickname - ld bc, $000b + ld hl, OTPartyMonNicknames + ld bc, NAME_LENGTH call AddNTimes ld de, StringBuffer1 call CopyBytes @@ -3951,7 +3895,7 @@ BattleCommanda1: ; 35461 ld a, [hl] ld e, a pop bc - ld a, [EnemyMovePower] + ld a, [wEnemyMoveStruct + MOVE_POWER] ld d, a ret ; 355b0 @@ -4003,12 +3947,12 @@ Function355dd: ; 355dd call ResetDamage ld a, [hBattleTurn] and a - ld hl, BattleMonDef + ld hl, BattleMonDefense ld de, PlayerScreens ld a, [BattleMonLevel] jr z, .asm_355f7 - ld hl, EnemyMonDef + ld hl, EnemyMonDefense ld de, EnemyScreens ld a, [EnemyMonLevel] .asm_355f7 @@ -4017,7 +3961,7 @@ Function355dd: ; 355dd ld b, a ld c, [hl] ld a, [de] - bit 4, a + bit SCREENS_REFLECT, a jr z, .asm_35604 sla c @@ -4077,7 +4021,6 @@ BattleCommand62: ; 35612 ld c, 1 .asm_35631 - xor a ld hl, hDividend ld [hli], a @@ -4124,7 +4067,6 @@ BattleCommand62: ; 35612 ld b, $4 call Divide - ; Item boosts call GetUserItem @@ -4344,7 +4286,7 @@ BattleCommand3f: ; 35726 ld a, $0 jr .asm_3578c ; 35769 $21 .asm_3576b - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hBattleTurn] and a jr z, .asm_35776 ; 35771 $3 @@ -4375,7 +4317,7 @@ BattleCommand3f: ; 35726 ld a, [hBattleTurn] and a jr z, .asm_3579d ; 35798 $3 - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP .asm_3579d xor a ld [$ffb3], a @@ -4432,14 +4374,14 @@ BattleCommand3f: ; 35726 ld a, [hl] jr nz, .asm_357f8 - ld hl, PlayerMovePower + ld hl, wPlayerMoveStruct + MOVE_POWER ld [hl], a push hl call PlayerAttackDamage jr .asm_35800 .asm_357f8 - ld hl, EnemyMovePower + ld hl, wEnemyMoveStruct + MOVE_POWER ld [hl], a push hl call EnemyAttackDamage @@ -4529,20 +4471,20 @@ BattleCommand41: ; 35864 ld de, EnemyEncoreCount ld a, [hBattleTurn] and a - jr z, .asm_35875 ; 3586d $6 + jr z, .ok ld hl, BattleMonMoves ld de, PlayerEncoreCount -.asm_35875 +.ok ld a, BATTLE_VARS_LAST_MOVE_OPP call GetBattleVar and a - jp z, Function35923 + jp z, .failed cp STRUGGLE - jp z, Function35923 + jp z, .failed cp ENCORE - jp z, Function35923 + jp z, .failed cp MIRROR_MOVE - jp z, Function35923 + jp z, .failed ld b, a .asm_3588e @@ -4554,15 +4496,15 @@ BattleCommand41: ; 35864 add hl, bc ld a, [hl] and $3f - jp z, Function35923 + jp z, .failed ld a, [AttackMissed] and a - jp nz, Function35923 + jp nz, .failed ld a, BATTLE_VARS_SUBSTATUS5_OPP - call _GetBattleVar - bit 4, [hl] - jp nz, Function35923 - set 4, [hl] + call GetBattleVarAddr + bit SUBSTATUS_ENCORED, [hl] + jp nz, .failed + set SUBSTATUS_ENCORED, [hl] call BattleRandom and $3 inc a @@ -4574,10 +4516,11 @@ BattleCommand41: ; 35864 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] @@ -4585,28 +4528,31 @@ BattleCommand41: ; 35864 jr z, .asm_358dd inc c ld a, c - cp $4 + cp NUM_MOVES jr c, .asm_358cc pop hl - res 4, [hl] + res SUBSTATUS_ENCORED, [hl] xor a ld [de], a - jr Function35923 + jr .failed + .asm_358dd pop hl + ld a, c ld [CurMoveNum], a ld a, b ld [CurPlayerMove], a dec a - ld de, PlayerMoveStruct + 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] @@ -4614,31 +4560,30 @@ BattleCommand41: ; 35864 jr z, .asm_3590a inc c ld a, c - cp $4 + cp NUM_MOVES jr c, .asm_358f9 pop hl - res 4, [hl] + res SUBSTATUS_ENCORED, [hl] xor a ld [de], a - jr Function35923 + jr .failed .asm_3590a pop hl + ld a, c ld [CurEnemyMoveNum], a ld a, b ld [CurEnemyMove], a dec a - ld de, EnemyMoveStruct + ld de, wEnemyMoveStruct call GetMoveData + .asm_3591a call AnimateCurrentMove - ld hl, GotAnEncoreText jp StdBattleTextBox -; 35923 - -Function35923: ; 35923 +.failed jp PrintDidntAffect2 ; 35926 @@ -4653,14 +4598,13 @@ BattleCommand42: ; 35926 jp nz, Function359cd call AnimateCurrentMove ld hl, $c63f - ld de, EnemyMonMaxHPLo + ld de, EnemyMonMaxHP + 1 call .asm_3597d ld a, $1 ld [$d10a], a hlcoord 10, 9 - ld a, $b - call Predef - ld hl, EnemyMonHPHi + predef Functionc6e0 + ld hl, EnemyMonHP ld a, [hli] ld [$d1ed], a ld a, [hli] @@ -4674,8 +4618,7 @@ BattleCommand42: ; 35926 ld [$d10a], a call ResetDamage hlcoord 2, 2 - ld a, $b - call Predef + predef Functionc6e0 callba Function178000 ld hl, SharedPainText @@ -4765,43 +4708,43 @@ BattleCommand44: ; 359e6 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 + PlayerMoveType - PlayerMoveStruct + ld hl, Moves + MOVE_TYPE call GetMoveAttr 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 push hl ld a, BATTLE_VARS_MOVE_TYPE - call _GetBattleVar + call GetBattleVarAddr push af push hl ld a, d @@ -4813,15 +4756,15 @@ BattleCommand44: ; 359e6 pop hl ld a, [$d265] cp $a - jr nc, .asm_35a13 ; 35a3c $d5 + jr nc, .asm_35a13 call SwitchTurn ld a, [hl] ld [$d265], a - ld a, $29 - call Predef + predef GetTypeName ld hl, TransformedTypeText jp StdBattleTextBox + .asm_35a50 jp Function37354 ; 35a53 @@ -4832,11 +4775,13 @@ BattleCommand45: ; 35a53 call CheckSubstituteOpp jr nz, .asm_35a6e + ld a, [AttackMissed] and a jr nz, .asm_35a6e + ld a, BATTLE_VARS_SUBSTATUS5_OPP - call _GetBattleVar + call GetBattleVarAddr set SUBSTATUS_LOCK_ON, [hl] call AnimateCurrentMove @@ -4853,26 +4798,30 @@ BattleCommand46: ; 35a74 ; 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] + call GetBattleVarAddr + bit SUBSTATUS_TRANSFORMED, [hl] jp nz, .asm_35b10 - ld a, $2 + + ld a, PartyMon1Moves - PartyMon1 call UserPartyAttr ld d, h ld e, l 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 @@ -4880,58 +4829,58 @@ BattleCommand46: ; 35a74 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 push bc push hl dec a - ld hl, Moves + PlayerMovePP - PlayerMoveStruct + ld hl, Moves + MOVE_PP call GetMoveAttr pop hl - ld bc, $0006 + ld bc, BattleMonPP - BattleMonMoves add hl, bc ld [hl], a 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 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 @@ -4954,24 +4903,22 @@ BattleCommand46: ; 35a74 BattleCommand47: ; 35b16 ; defrostopponent - -; If the opponent isn't frozen, raise Attack one stage. -; If the opponent is frozen, thaw them and raise Accuracy two stages. +; Thaw the opponent if frozen, and +; raise the user's Attack one stage. call AnimateCurrentMove ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar + call GetBattleVarAddr call Defrost -; Sharply raise accuracy ld a, BATTLE_VARS_MOVE_EFFECT - call _GetBattleVar + call GetBattleVarAddr ld a, [hl] push hl push af - ld a, $a ; meditate, sharpen + ld a, EFFECT_ATTACK_UP ld [hl], a call BattleCommand1c @@ -4988,54 +4935,54 @@ BattleCommand48: ; 35b33 call Function372d8 ld a, [AttackMissed] and a - jr nz, .asm_35ba3 ; 35b3a $67 + jr nz, .asm_35ba3 ld a, [hBattleTurn] and a - ld hl, BattleMonMove2 + ld hl, BattleMonMoves + 1 ld a, [DisabledMove] ld d, a - jr z, .asm_35b4f ; 35b46 $7 - ld hl, EnemyMonMove2 + jr z, .asm_35b4f + ld hl, EnemyMonMoves + 1 ld a, [EnemyDisabledMove] ld d, a .asm_35b4f ld a, BATTLE_VARS_STATUS call GetBattleVar - and $7 - jr z, .asm_35ba3 ; 35b56 $4b + and SLP + 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 call BattleRandom - and $3 + and 3 ; TODO factor in NUM_MOVES ld c, a - ld b, $0 + ld b, 0 add hl, bc 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 + call GetBattleVarAddr 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 @@ -5068,11 +5015,11 @@ BattleCommand48: ; 35b33 ld a, [EnemyDisabledMove] .asm_35bbe ld b, a - ld a, $10 + ld a, BATTLE_VARS_MOVE call GetBattleVar ld c, a dec hl - ld d, $4 + ld d, NUM_MOVES .asm_35bc8 ld a, [hl] and a @@ -5112,17 +5059,17 @@ BattleCommand48: ; 35b33 pop de pop hl - cp $91 + cp EFFECT_SKULL_BASH ret z - cp $27 + cp EFFECT_RAZOR_WIND ret z - cp $4b + cp EFFECT_SKY_ATTACK ret z - cp $97 + cp EFFECT_SOLARBEAM ret z - cp $9b + cp EFFECT_FLY ret z - cp $1a + cp EFFECT_BIDE ret ; 35bff @@ -5131,8 +5078,8 @@ BattleCommand49: ; 35bff ; destinybond ld a, BATTLE_VARS_SUBSTATUS5 - call _GetBattleVar - set 6, [hl] + call GetBattleVarAddr + set SUBSTATUS_DESTINY_BOND, [hl] call AnimateCurrentMove ld hl, DestinyBondEffectText jp StdBattleTextBox @@ -5149,22 +5096,22 @@ BattleCommand4a: ; 35c0f 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 - cp $a5 - jr z, .asm_35c91 ; 35c2e $61 + jr z, .asm_35c91 + cp STRUGGLE + jr z, .asm_35c91 ld b, a ld c, $ff .asm_35c33 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 @@ -5174,25 +5121,25 @@ BattleCommand4a: ; 35c0f pop bc ld a, [hl] and $3f - jr z, .asm_35c91 ; 35c46 $49 + jr z, .asm_35c91 push bc call GetMoveName call BattleRandom - and $3 + and 3 inc a inc a ld b, a 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] sub b ld [hl], a push af - ld a, $17 + ld a, PartyMon1PP - PartyMon1 call OpponentPartyAttr ld d, b pop af @@ -5201,14 +5148,14 @@ BattleCommand4a: ; 35c0f 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 @@ -5229,10 +5176,10 @@ BattleCommand4a: ; 35c0f BattleCommand4b: ; 35c94 ; falseswipe - ld hl, EnemyMonHPHi + 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 @@ -5242,7 +5189,7 @@ BattleCommand4b: ; 35c94 call StringCmp pop de pop hl - jr c, .asm_35cc7 ; 35cab $1a + jr c, .asm_35cc7 ld a, [hli] ld [de], a inc de @@ -5250,7 +5197,7 @@ BattleCommand4b: ; 35c94 dec a ld [de], a inc a - jr nz, .asm_35cba ; 35cb4 $4 + jr nz, .asm_35cba dec de ld a, [de] dec a @@ -5258,7 +5205,7 @@ BattleCommand4b: ; 35c94 .asm_35cba ld a, [CriticalHit] cp $2 - jr nz, .asm_35cc5 ; 35cbf $4 + jr nz, .asm_35cc5 xor a ld [CriticalHit], a .asm_35cc5 @@ -5274,22 +5221,22 @@ BattleCommand4c: ; 35cc9 ; healbell ld a, BATTLE_VARS_SUBSTATUS1 - call _GetBattleVar - res 0, [hl] + call GetBattleVarAddr + res SUBSTATUS_NIGHTMARE, [hl] 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 - call _GetBattleVar + call GetBattleVarAddr xor a ld [hl], a ld h, d ld l, e - ld bc, $30 - ld d, $6 + ld bc, PartyMon2 - PartyMon1 + ld d, PartyEnd - PartySpecies .asm_35ce9 ld [hl], a add hl, bc @@ -5310,10 +5257,9 @@ BattleCommand4c: ; 35cc9 FarPlayBattleAnimation: ; 35d00 ; play animation de -; battle animations disabled? ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVar - and $60 ; bit 6 | 5 + and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret nz ; fallthrough @@ -5347,38 +5293,40 @@ Function35d1c: ; 35d1c jr nz, .asm_35d31 ld a, [EnemySubStatus4] - bit 4, a + bit SUBSTATUS_SUBSTITUTE, a jp nz, Function35de0 .asm_35d31 ld a, [hld] ld b, a - ld a, [EnemyMonHPLo] + ld a, [EnemyMonHP + 1] ld [$d1ec], a sub b - ld [EnemyMonHPLo], a + ld [EnemyMonHP + 1], a ld a, [hl] ld b, a - ld a, [EnemyMonHPHi] - ld [$d1ed], a + ld a, [EnemyMonHP] + ld [$d1ec + 1], a sbc b - ld [EnemyMonHPHi], a + ld [EnemyMonHP], a jr nc, .asm_35d59 ld a, [$d1ed] ld [hli], a ld a, [$d1ec] ld [hl], a + xor a - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld [hli], a ld [hl], a + .asm_35d59 - ld hl, EnemyMonMaxHPHi + ld hl, EnemyMonMaxHP ld a, [hli] ld [$d1eb], a ld a, [hl] ld [$d1ea], a - ld hl, EnemyMonHPHi + ld hl, EnemyMonHP ld a, [hli] ld [$d1ef], a ld a, [hl] @@ -5386,8 +5334,7 @@ Function35d1c: ; 35d1c hlcoord 2, 2 xor a ld [$d10a], a - ld a, $b - call Predef + predef Functionc6e0 .asm_35d7b jp RefreshBattleHuds ; 35d7e @@ -5406,35 +5353,37 @@ Function35d7e: ; 35d7e jr nz, .asm_35d93 ld a, [PlayerSubStatus4] - bit 4, a + bit SUBSTATUS_SUBSTITUTE, a jp nz, Function35de0 .asm_35d93 ld a, [hld] ld b, a - ld a, [$c63d] + ld a, [BattleMonHP + 1] ld [$d1ec], a sub b - ld [$c63d], a + ld [BattleMonHP + 1], a ld [$d1ee], a ld b, [hl] ld a, [BattleMonHP] - ld [$d1ed], a + ld [$d1ec + 1], a sbc b ld [BattleMonHP], a - ld [$d1ef], a + ld [$d1ee + 1], a jr nc, .asm_35dc5 - ld a, [$d1ed] + ld a, [$d1ec + 1] ld [hli], a ld a, [$d1ec] ld [hl], a xor a + ld hl, BattleMonHP ld [hli], a ld [hl], a ld hl, $d1ee ld [hli], a ld [hl], a + .asm_35dc5 ld hl, BattleMonMaxHP ld a, [hli] @@ -5444,8 +5393,7 @@ Function35d7e: ; 35d7e hlcoord 10, 9 ld a, $1 ld [$d10a], a - ld a, $b - call Predef + predef Functionc6e0 .asm_35ddd jp RefreshBattleHuds ; 35de0 @@ -5456,29 +5404,28 @@ Function35de0: ; 35de0 ld hl, SubTookDamageText call StdBattleTextBox - ld de, $c6e0 + ld de, EnemySubstituteHP ld a, [hBattleTurn] and a - jr z, .asm_35df1 + jr z, .got_hp + ld de, PlayerSubstituteHP +.got_hp - ld de, $c6df -.asm_35df1 ld hl, CurDamage ld a, [hli] and a - jr nz, .asm_35dff + jr nz, .broke ld a, [de] sub [hl] ld [de], a - jr z, .asm_35dff + jr z, .broke + jr nc, .done - jr nc, .asm_35e3d - -.asm_35dff +.broke ld a, BATTLE_VARS_SUBSTATUS4_OPP - call _GetBattleVar - res 4, [hl] + call GetBattleVarAddr + res SUBSTATUS_SUBSTITUTE, [hl] ld hl, SubFadedText call StdBattleTextBox @@ -5487,28 +5434,27 @@ Function35de0: ; 35de0 call BattleCommanda7 ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVar - and $60 ; fly | dig + and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND call z, Function37ec7 call SwitchTurn ld a, BATTLE_VARS_MOVE_EFFECT - call _GetBattleVar + call GetBattleVarAddr cp EFFECT_MULTI_HIT - jr z, .asm_35e3a + jr z, .ok cp EFFECT_DOUBLE_HIT - jr z, .asm_35e3a + jr z, .ok cp EFFECT_TWINEEDLE - jr z, .asm_35e3a + jr z, .ok cp EFFECT_TRIPLE_KICK - jr z, .asm_35e3a + jr z, .ok cp EFFECT_BEAT_UP - jr z, .asm_35e3a - + jr z, .ok xor a ld [hl], a -.asm_35e3a +.ok call RefreshBattleHuds -.asm_35e3d +.done jp ResetDamage ; 35e40 @@ -5516,7 +5462,7 @@ Function35de0: ; 35de0 UpdateMoveData: ; 35e40 ld a, BATTLE_VARS_MOVE_ANIM - call _GetBattleVar + call GetBattleVarAddr ld d, h ld e, l @@ -5537,8 +5483,9 @@ BattleCommand14: ; 35e5c 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 @@ -5547,11 +5494,11 @@ BattleCommand14: ; 35e5c .asm_35e70 ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar + call GetBattleVarAddr ld d, h ld e, l ld a, [de] - and 7 + and SLP ld hl, AlreadyAsleepText jr nz, .asm_35ec6 @@ -5605,24 +5552,23 @@ BattleCommand14: ; 35e5c 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 @@ -5641,7 +5587,7 @@ BattleCommand13: ; 35eee call CheckSubstituteOpp ret nz ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar + call GetBattleVarAddr and a ret nz ld a, [TypeModifier] @@ -5651,7 +5597,7 @@ BattleCommand13: ; 35eee ret z call GetOpponentItem ld a, b - cp $14 + cp HELD_PREVENT_POISON ret z ld a, [EffectFailed] and a @@ -5659,7 +5605,7 @@ BattleCommand13: ; 35eee call Function37962 ret nz call Function35ff5 - ld de, $0106 + ld de, ANIM_PSN call Function37e54 call RefreshBattleHuds @@ -5678,60 +5624,65 @@ BattleCommand2f: ; 35f2c 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 - call Function35fc0 + jr z, .asm_35fa4 + call Function35fc0 ld hl, WasPoisonedText call StdBattleTextBox + jr .asm_35fb1 - jr .asm_35fb1 ; 35fa2 $d .asm_35fa4 - set 0, [hl] + set SUBSTATUS_TOXIC, [hl] xor a ld [de], a call Function35fc0 @@ -5760,13 +5711,13 @@ Function35fc0: ; 35fc0 Function35fc9: ; 35fc9 ld a, BATTLE_VARS_SUBSTATUS5_OPP - call _GetBattleVar + call GetBattleVarAddr ld a, [hBattleTurn] and a - ld de, $c67c - jr z, .asm_35fd9 - ld de, $c674 -.asm_35fd9 + ld de, EnemyToxicCount + jr z, .ok + ld de, PlayerToxicCount +.ok ld a, BATTLE_VARS_MOVE_EFFECT call GetBattleVar cp EFFECT_TOXIC @@ -5778,9 +5729,9 @@ Function35fe1: ; 35fe1 ld de, EnemyMonType1 ld a, [hBattleTurn] and a - jr z, .asm_35fec + jr z, .ok ld de, BattleMonType1 -.asm_35fec +.ok ld a, [de] inc de cp POISON @@ -5793,7 +5744,7 @@ Function35fe1: ; 35fe1 Function35ff5: ; 35ff5 ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar + call GetBattleVarAddr set PSN, [hl] jp UpdateOpponentInParty ; 35fff @@ -5834,8 +5785,8 @@ Function36011: ; 36011 ld a, [hBattleTurn] and a jr z, .asm_36037 ; 0x3602f $6 - ld hl, EnemyMonHPHi - ld de, EnemyMonMaxHPHi + ld hl, EnemyMonHP + ld de, EnemyMonMaxHP .asm_36037 ld bc, $d1ed ld a, [hli] @@ -5891,8 +5842,7 @@ Function36011: ; 36011 xor a .asm_3607e ld [$d10a], a - ld a, $b - call Predef + predef Functionc6e0 call RefreshBattleHuds jp UpdateBattleMonInParty ; 3608c @@ -5906,7 +5856,7 @@ BattleCommand17: ; 3608c call CheckSubstituteOpp ret nz ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar + call GetBattleVarAddr and a jp nz, Defrost ld a, [TypeModifier] @@ -5916,7 +5866,7 @@ BattleCommand17: ; 3608c ret z call GetOpponentItem ld a, b - cp $15 + cp HELD_PREVENT_BURN ret z ld a, [EffectFailed] and a @@ -5924,12 +5874,12 @@ BattleCommand17: ; 3608c call Function37962 ret nz ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar - set 4, [hl] + call GetBattleVarAddr + set BRN, [hl] call UpdateOpponentInParty ld hl, Function3ec76 call CallBattleCore - ld de, $0105 + ld de, ANIM_BRN call Function37e54 call RefreshBattleHuds @@ -5943,7 +5893,7 @@ BattleCommand17: ; 3608c Defrost: ; 360dd ld a, [hl] - and $20 + and 1 << FRZ ret z xor a @@ -5976,20 +5926,20 @@ BattleCommand18: ; 36102 call CheckSubstituteOpp ret nz ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar + call GetBattleVarAddr and a ret nz ld a, [TypeModifier] 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 @@ -5997,10 +5947,10 @@ BattleCommand18: ; 36102 call Function37962 ret nz ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar - set 5, [hl] + call GetBattleVarAddr + set FRZ, [hl] call UpdateOpponentInParty - ld de, $0108 + ld de, ANIM_FRZ call Function37e54 call RefreshBattleHuds @@ -6014,7 +5964,7 @@ BattleCommand18: ; 36102 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 @@ -6030,7 +5980,7 @@ BattleCommand19: ; 36165 call CheckSubstituteOpp ret nz ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar + call GetBattleVarAddr and a ret nz ld a, [TypeModifier] @@ -6038,7 +5988,7 @@ BattleCommand19: ; 36165 ret z call GetOpponentItem ld a, b - cp $18 + cp HELD_PREVENT_PARALYZE ret z ld a, [EffectFailed] and a @@ -6046,12 +5996,12 @@ BattleCommand19: ; 36165 call Function37962 ret nz ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar - set 6, [hl] + call GetBattleVarAddr + set PAR, [hl] call UpdateOpponentInParty ld hl, Function3ec39 call CallBattleCore - ld de, $0109 + ld de, ANIM_PAR call Function37e54 call RefreshBattleHuds call PrintParalyze @@ -6144,7 +6094,7 @@ Function361ef: ; 361ef ld a, [LoweredStat] and $f ld c, a - ld b, $0 + ld b, 0 add hl, bc ld b, [hl] inc b @@ -6175,7 +6125,7 @@ Function361ef: ; 361ef .asm_36243 push bc sla c - ld b, $0 + ld b, 0 add hl, bc ld a, c add e @@ -6185,10 +6135,10 @@ Function361ef: ; 361ef .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] @@ -6393,12 +6343,12 @@ BattleCommand1d: ; 362e3 jr nc, .Hit push hl - ld hl, EnemyMonAtk + 1 + ld hl, EnemyMonAttack + 1 ld de, EnemyStats ld a, [hBattleTurn] and a jr z, .asm_36366 - ld hl, BattleMonAtk + 1 + ld hl, BattleMonAttack + 1 ld de, PlayerStats .asm_36366 call Function3641a @@ -6800,8 +6750,8 @@ BattleCommandac: ; 3658f BattleCommandaf: ; 365a7 ; curl ld a, BATTLE_VARS_SUBSTATUS2 - call _GetBattleVar - set 0, [hl] + call GetBattleVarAddr + set SUBSTATUS_CURLED, [hl] ret ; 365af @@ -6837,7 +6787,7 @@ BattleCommanda7: ; 365c3 Function365d7: ; 365d7 ld hl, PlayerAtkLevel ld de, PlayerStats - ld bc, BattleMonAtk + ld bc, BattleMonAttack ld a, $5 call Function3661d @@ -6860,7 +6810,7 @@ Function365d7: ; 365d7 Function365fd: ; 365fd ld hl, EnemyAtkLevel ld de, EnemyStats - ld bc, EnemyMonAtk + ld bc, EnemyMonAttack ld a, $5 call Function3661d @@ -6964,14 +6914,14 @@ BattleCommand21: ; 36671 dec [hl] jr nz, .asm_366dc ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr res 0, [hl] ld hl, UnleashedEnergyText call StdBattleTextBox ld a, BATTLE_VARS_MOVE_POWER - call _GetBattleVar + call GetBattleVarAddr ld a, 1 ld [hl], a ld hl, PlayerDamageTaken + 1 @@ -7005,7 +6955,7 @@ BattleCommand21: ; 36671 ld [de], a ld a, BATTLE_VARS_MOVE_ANIM - call _GetBattleVar + call GetBattleVarAddr ld a, BIDE ld [hl], a @@ -7031,14 +6981,14 @@ BattleCommand22: ; 366e5 ld bc, EnemyRolloutCount .asm_366f6 ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr set 0, [hl] xor a ld [de], a inc de ld [de], a - ld [PlayerMoveEffect], a - ld [EnemyMoveEffect], a + ld [wPlayerMoveStruct + MOVE_EFFECT], a + ld [wEnemyMoveStruct + MOVE_EFFECT], a call BattleRandom and $1 inc a @@ -7061,7 +7011,7 @@ BattleCommand3e: ; 3671a ld de, EnemyRolloutCount .asm_36725 ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr bit 1, [hl] ret z ld a, [de] @@ -7094,20 +7044,20 @@ BattleCommand3d: ; 36751 ; No rampage during Sleep Talk. ld a, BATTLE_VARS_STATUS call GetBattleVar - and 7 + and SLP ret nz ld de, PlayerRolloutCount ld a, [hBattleTurn] and a - jr z, .asm_36764 ; 3675f $3 + jr z, .ok ld de, EnemyRolloutCount -.asm_36764 +.ok ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar - set 1, [hl] + call GetBattleVarAddr + set SUBSTATUS_RAMPAGE, [hl] call BattleRandom - and $1 + and 1 inc a ld [de], a ld a, 1 @@ -7121,24 +7071,24 @@ BattleCommanda0: ; 36778 ld a, [BattleType] cp BATTLETYPE_SHINY - jr z, .asm_367b9 - cp $9 - jr z, .asm_367b9 - cp $b - jr z, .asm_367b9 + jr z, .failed + cp BATTLETYPE_TRAP + jr z, .failed + cp BATTLETYPE_CELEBI + jr z, .failed cp BATTLETYPE_SUICUNE - jr z, .asm_367b9 + jr z, .failed ld a, BATTLE_VARS_SUBSTATUS5_OPP call GetBattleVar bit SUBSTATUS_CANT_RUN, a - jr nz, .asm_367b9 + jr nz, .failed ld a, [hBattleTurn] and a jr nz, .asm_367bf ld a, [IsInBattle] dec a - jr nz, .asm_367b9 + jr nz, .failed ld a, [$d143] ld b, a ld a, [BattleMonLevel] @@ -7156,14 +7106,14 @@ BattleCommanda0: ; 36778 cp b jr nc, .asm_367df ; 367b7 $26 -.asm_367b9 +.failed call AnimateFailedMove jp PrintButItFailed .asm_367bf ld a, [IsInBattle] dec a - jr nz, .asm_367b9 ; 367c3 $f4 + jr nz, .failed ld a, [BattleMonLevel] ld b, a ld a, [$d143] @@ -7216,7 +7166,7 @@ BattleCommand23: ; 3680f jp z, .asm_36969 cp $9 jp z, .asm_36969 - cp $b + cp BATTLETYPE_CELEBI jp z, .asm_36969 cp BATTLETYPE_SUICUNE jp z, .asm_36969 @@ -7254,7 +7204,7 @@ BattleCommand23: ; 3680f inc a ld [$d232], a call Function36804 - ld a, [PlayerMoveAnimation] + ld a, [wPlayerMoveStruct + MOVE_ANIM] jp .asm_36975 .asm_36869 call Function349f4 @@ -7345,7 +7295,7 @@ BattleCommand23: ; 3680f inc a ld [$d232], a call Function36804 - ld a, [EnemyMoveAnimation] + ld a, [wEnemyMoveStruct + MOVE_ANIM] jr .asm_36975 .asm_36908 @@ -7472,12 +7422,12 @@ BattleCommand24: ; 369b6 .asm_369c7 ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr bit 2, [hl] jp nz, .asm_36a43 set 2, [hl] ld a, BATTLE_VARS_MOVE_EFFECT - call _GetBattleVar + call GetBattleVarAddr ld a, [hl] cp EFFECT_TWINEEDLE jr z, .asm_36a3f @@ -7519,7 +7469,7 @@ BattleCommand24: ; 369b6 .asm_36a1e ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr res 2, [hl] call BattleCommanda8 jp EndMoveEffect @@ -7527,7 +7477,7 @@ BattleCommand24: ; 369b6 call BattleRandom and $3 cp $2 - jr c, .asm_36a39 ; 36a32 $5 + jr c, .asm_36a39 call BattleRandom and $3 .asm_36a39 @@ -7536,19 +7486,19 @@ BattleCommand24: ; 369b6 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 + call GetBattleVarAddr res 2, [hl] ld hl, PlayerHitTimesText @@ -7580,7 +7530,7 @@ BattleCommand24: ; 369b6 .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 @@ -7594,14 +7544,18 @@ BattleCommand94: ; 36a82 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 @@ -7612,12 +7566,15 @@ BattleCommand94: ; 36a82 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 @@ -7628,8 +7585,8 @@ BattleCommand25: ; 36aa0 Function36ab5: ; 36ab5 ld a, BATTLE_VARS_SUBSTATUS3_OPP - call _GetBattleVar - set 3, [hl] + call GetBattleVarAddr + set SUBSTATUS_FLINCHED, [hl] jp EndRechargeOpp ; 36abf @@ -7654,13 +7611,13 @@ BattleCommand4d: ; 36ac9 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 ret nz ld a, BATTLE_VARS_MOVE_EFFECT - call _GetBattleVar + call GetBattleVarAddr ld d, h ld e, l call GetUserItem @@ -7669,8 +7626,8 @@ BattleCommand4d: ; 36ac9 ret nc call EndRechargeOpp ld a, BATTLE_VARS_SUBSTATUS3_OPP - call _GetBattleVar - set 3, [hl] + call GetBattleVarAddr + set SUBSTATUS_FLINCHED, [hl] ret ; 36af3 @@ -7681,27 +7638,27 @@ BattleCommand26: ; 36af3 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, PlayerMoveAccuracy + 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 pop de - ld bc, EnemyMoveAccuracy + ld bc, wEnemyMoveStruct + MOVE_ACC .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 @@ -7725,15 +7682,13 @@ BattleCommand26: ; 36af3 BattleCommand3a: ; 36b3a ; checkcharge -; charged? ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar - bit 4, [hl] + call GetBattleVarAddr + 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 @@ -7745,7 +7700,7 @@ BattleCommand39: ; 36b4d call BattleCommand38 ld a, BATTLE_VARS_STATUS call GetBattleVar - and $7 + and SLP jr z, .asm_36b65 call BattleCommandaa @@ -7755,8 +7710,8 @@ BattleCommand39: ; 36b4d .asm_36b65 ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar - set 4, [hl] + call GetBattleVarAddr + set SUBSTATUS_CHARGED, [hl] ld hl, IgnoredOrders2Text ld a, [AlreadyDisobeyed] @@ -7771,44 +7726,44 @@ BattleCommand39: ; 36b4d 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 ld a, BATTLE_VARS_SUBSTATUS3 - call _GetBattleVar + call GetBattleVarAddr 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 + call GetBattleVarAddr ld [hl], b ld a, BATTLE_VARS_LAST_MOVE - call _GetBattleVar + call GetBattleVarAddr ld [hl], b .asm_36bc3 call ResetDamage - ld hl, .text_36bdb + ld hl, .UsedText call BattleTextBox ld a, BATTLE_VARS_MOVE_EFFECT @@ -7818,37 +7773,36 @@ BattleCommand39: ; 36b4d 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 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 @@ -7909,7 +7863,7 @@ BattleCommand3b: ; 36c2d ret nz ld a, BATTLE_VARS_SUBSTATUS4_OPP call GetBattleVar - bit 4, a + bit SUBSTATUS_SUBSTITUTE, a ret nz call BattleRandom and 3 @@ -7950,10 +7904,10 @@ BattleCommand28: ; 36c7e ; mist ld a, BATTLE_VARS_SUBSTATUS4 - call _GetBattleVar - bit 1, [hl] - jr nz, .asm_36c92 ; 36c85 $b - set 1, [hl] + call GetBattleVarAddr + bit SUBSTATUS_MIST, [hl] + jr nz, .asm_36c92 + set SUBSTATUS_MIST, [hl] call AnimateCurrentMove ld hl, MistText jp StdBattleTextBox @@ -7967,10 +7921,10 @@ BattleCommand29: ; 36c98 ; focusenergy ld a, BATTLE_VARS_SUBSTATUS4 - call _GetBattleVar - bit 2, [hl] - jr nz, .asm_36cac ; 36c9f $b - set 2, [hl] + call GetBattleVarAddr + bit SUBSTATUS_FOCUS_ENERGY, [hl] + jr nz, .asm_36cac + set SUBSTATUS_FOCUS_ENERGY, [hl] call AnimateCurrentMove ld hl, GettingPumpedText jp StdBattleTextBox @@ -7986,8 +7940,8 @@ BattleCommand27: ; 36cb2 ld hl, BattleMonMaxHP ld a, [hBattleTurn] and a - jr z, .asm_36cbd ; 36cb8 $3 - ld hl, EnemyMonMaxHPHi + jr z, .asm_36cbd + ld hl, EnemyMonMaxHP .asm_36cbd ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar @@ -8002,7 +7956,7 @@ BattleCommand27: ; 36cb2 rr c ld a, b or c - jr nz, .asm_36cd8 ; 36cd5 $1 + jr nz, .asm_36cd8 inc c .asm_36cd8 ld a, [hli] @@ -8021,7 +7975,7 @@ BattleCommand27: ; 36cb2 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 @@ -8033,13 +7987,12 @@ BattleCommand27: ; 36cb2 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 ld [$d10a], a - ld a, $b - call Predef + predef Functionc6e0 call RefreshBattleHuds ld hl, RecoilText jp StdBattleTextBox @@ -8051,7 +8004,7 @@ BattleCommand2b: ; 36d1d call GetOpponentItem ld a, b - cp $19 + cp HELD_PREVENT_CONFUSE ret z ld a, [EffectFailed] and a @@ -8061,8 +8014,8 @@ BattleCommand2b: ; 36d1d call CheckSubstituteOpp ret nz ld a, BATTLE_VARS_SUBSTATUS3_OPP - call _GetBattleVar - bit 7, [hl] + call GetBattleVarAddr + bit SUBSTATUS_CONFUSED, [hl] ret nz jr Function36d70 @@ -8072,7 +8025,7 @@ BattleCommand2a: ; 36d3b call GetOpponentItem ld a, b - cp $19 + cp HELD_PREVENT_CONFUSE jr nz, .asm_36d53 ld a, [hl] ld [$d265], a @@ -8083,8 +8036,8 @@ BattleCommand2a: ; 36d3b .asm_36d53 ld a, BATTLE_VARS_SUBSTATUS3_OPP - call _GetBattleVar - bit 7, [hl] + call GetBattleVarAddr + bit SUBSTATUS_CONFUSED, [hl] jr z, .asm_36d65 call AnimateFailedMove ld hl, AlreadyConfusedText @@ -8109,7 +8062,7 @@ Function36d70: ; 36d70 ld bc, PlayerConfuseCount .asm_36d7b - set 7, [hl] + set SUBSTATUS_CONFUSED, [hl] call BattleRandom and 3 inc a @@ -8127,7 +8080,7 @@ Function36d70: ; 36d70 call AnimateCurrentMove .asm_36d99 - ld de, $0103 + ld de, ANIM_CONFUSED call Function37e54 ld hl, BecameConfusedText @@ -8135,9 +8088,9 @@ Function36d70: ; 36d70 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 @@ -8162,55 +8115,56 @@ BattleCommand30: ; 36dc7 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 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 + call GetBattleVarAddr 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 ld [$ffd4], a ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar - set 6, [hl] + call GetBattleVarAddr + set PAR, [hl] call UpdateOpponentInParty ld hl, Function3ec39 call CallBattleCore @@ -8231,8 +8185,9 @@ BattleCommand30: ; 36dc7 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 @@ -8271,17 +8226,19 @@ BattleCommand31: ; 36e7c call BattleCommandaa ld hl, BattleMonMaxHP - ld de, $c6df + ld de, PlayerSubstituteHP ld a, [hBattleTurn] and a - jr z, .asm_36e90 ; 36e88 $6 - ld hl, EnemyMonMaxHPHi - ld de, $c6e0 -.asm_36e90 + jr z, .got_hp + ld hl, EnemyMonMaxHP + ld de, EnemySubstituteHP +.got_hp + ld a, BATTLE_VARS_SUBSTATUS4 call GetBattleVar - bit 4, a - jr nz, .asm_36ef4 ; 36e97 $5b + bit SUBSTATUS_SUBSTITUTE, a + jr nz, .asm_36ef4 + ld a, [hli] ld b, [hl] srl a @@ -8296,49 +8253,56 @@ BattleCommand31: ; 36e7c sub b ld e, a ld a, [hl] - sbc $0 + 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 + ld a, BATTLE_VARS_SUBSTATUS4 - call _GetBattleVar - set 4, [hl] + call GetBattleVarAddr + set SUBSTATUS_SUBSTITUTE, [hl] + ld hl, $c730 ld de, $c72e ld a, [hBattleTurn] and a - jr z, .asm_36ecf ; 36ec7 $6 + jr z, .asm_36ecf ld hl, $c731 ld de, $c72f .asm_36ecf + xor a 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 .asm_36eeb ld hl, MadeSubstituteText call StdBattleTextBox jp RefreshBattleHuds + .asm_36ef4 call Function34548 call nz, BattleCommand0c ld hl, HasSubstituteText - jr .asm_36f08 ; 36efd $9 + jr .asm_36f08 + .asm_36eff call Function34548 call nz, BattleCommand0c @@ -8350,8 +8314,8 @@ BattleCommand31: ; 36e7c BattleCommand32: ; 36f0b ; rechargenextturn ld a, BATTLE_VARS_SUBSTATUS4 - call _GetBattleVar - set 5, [hl] + call GetBattleVarAddr + set SUBSTATUS_RECHARGE, [hl] ret ; 36f13 @@ -8359,8 +8323,8 @@ BattleCommand32: ; 36f0b EndRechargeOpp: ; 36f13 push hl ld a, BATTLE_VARS_SUBSTATUS4_OPP - call _GetBattleVar - res 5, [hl] + call GetBattleVarAddr + res SUBSTATUS_RECHARGE, [hl] pop hl ret ; 36f1d @@ -8369,8 +8333,8 @@ EndRechargeOpp: ; 36f13 BattleCommand97: ; 36f1d ; rage ld a, BATTLE_VARS_SUBSTATUS4 - call _GetBattleVar - set 6, [hl] + call GetBattleVarAddr + set SUBSTATUS_RAGE, [hl] ret ; 36f25 @@ -8418,42 +8382,42 @@ BattleCommand33: ; 36f46 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 - cp $a5 - jr z, .asm_36f9a ; 36f6c $2c + jr z, .asm_36f9a + cp STRUGGLE + jr z, .asm_36f9a ld b, a - ld c, $4 + 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 $66 - jr nz, .asm_36f79 ; 36f7c $fb + cp MIMIC + jr nz, .asm_36f79 inc hl ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar ld [hl], a ld [$d265], a - ld bc, $0006 + ld bc, BattleMonPP - BattleMonMoves add hl, bc - ld [hl], $5 + ld [hl], 5 call GetMoveName call AnimateCurrentMove ld hl, LearnedMoveText @@ -8467,34 +8431,39 @@ BattleCommand35: ; 36f9d ; leechseed ld a, [AttackMissed] and a - jr nz, .asm_36fd8 ; 36fa1 $35 + jr nz, .evaded call CheckSubstituteOpp - jr nz, .asm_36fd8 ; 36fa6 $30 + jr nz, .evaded + ld de, EnemyMonType1 ld a, [hBattleTurn] and a - jr z, .asm_36fb3 ; 36fae $3 + jr z, .ok ld de, BattleMonType1 -.asm_36fb3 +.ok + ld a, [de] - cp $16 - jr z, .asm_36fd2 ; 36fb6 $1a + cp GRASS + jr z, .grass inc de ld a, [de] - cp $16 - jr z, .asm_36fd2 ; 36fbc $14 + cp GRASS + jr z, .grass + ld a, BATTLE_VARS_SUBSTATUS4_OPP - call _GetBattleVar - bit 7, [hl] - jr nz, .asm_36fd8 ; 36fc5 $11 - set 7, [hl] + call GetBattleVarAddr + bit SUBSTATUS_LEECH_SEED, [hl] + jr nz, .evaded + set SUBSTATUS_LEECH_SEED, [hl] call AnimateCurrentMove ld hl, WasSeededText jp StdBattleTextBox -.asm_36fd2 + +.grass call AnimateFailedMove jp PrintDoesntAffect -.asm_36fd8 + +.evaded call AnimateFailedMove ld hl, EvadedText jp StdBattleTextBox @@ -8513,46 +8482,51 @@ BattleCommand37: ; 36fed 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 + 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 - cp $a5 - jr z, .asm_37059 ; 37012 $45 + jr z, .asm_37059 + cp STRUGGLE + jr z, .asm_37059 + ld b, a ld c, $ff .asm_37017 inc c ld a, [hli] cp b - jr nz, .asm_37017 ; 3701a $fb + jr nz, .asm_37017 + ld a, [hBattleTurn] and a - ld hl, EnemyMonPPMove1 - jr z, .asm_37027 ; 37022 $3 + ld hl, EnemyMonPP + jr z, .asm_37027 ld hl, BattleMonPP .asm_37027 - ld b, $0 + ld b, 0 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 + and 7 + jr z, .asm_3702e inc a inc c swap c @@ -8562,7 +8536,7 @@ BattleCommand37: ; 36fed 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 @@ -8583,22 +8557,24 @@ BattleCommand1e: ; 3705c xor a ld hl, StringBuffer1 ld [hli], a + ld a, [hBattleTurn] and a ld a, [BattleMonLevel] - jr z, .asm_3706c ; 37067 $3 + jr z, .ok ld a, [EnemyMonLevel] -.asm_3706c +.ok + add a - ld hl, $c6ee + ld hl, wPayDayMoney + 2 add [hl] ld [hld], a - jr nc, .asm_37079 ; 37072 $5 + jr nc, .done inc [hl] dec hl - jr nz, .asm_37079 ; 37076 $1 + jr nz, .done inc [hl] -.asm_37079 +.done ld hl, CoinsScatteredText jp StdBattleTextBox ; 3707f @@ -8611,25 +8587,25 @@ BattleCommand1f: ; 3707f ld de, BattleMonType1 ld a, [hBattleTurn] and a - jr z, .asm_37090 ; 37088 $6 + jr z, .asm_37090 ld hl, EnemyMonMoves 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 and a - jr z, .asm_370b2 ; 3709d $13 + jr z, .asm_370b2 push hl push bc dec a - ld hl, Moves + PlayerMoveType - PlayerMoveStruct + ld hl, Moves + MOVE_TYPE call GetMoveAttr ld [de], a inc de @@ -8637,8 +8613,8 @@ BattleCommand1f: ; 3707f pop hl inc c ld a, c - cp $4 - jr c, .asm_37096 ; 370b0 $e4 + cp NUM_MOVES + jr c, .asm_37096 .asm_370b2 ld a, $ff ld [de], a @@ -8651,43 +8627,44 @@ BattleCommand1f: ; 3707f .asm_370bd ld a, [hl] cp $ff - jr z, .asm_370d3 ; 370c0 $11 - cp $13 - jr z, .asm_370d0 ; 370c4 $a + jr z, .asm_370d3 + cp CURSE_T + jr z, .asm_370d0 ld a, [de] cp [hl] - jr z, .asm_370d0 ; 370c8 $6 + jr z, .asm_370d0 inc de ld a, [de] dec de cp [hl] - jr nz, .asm_370d9 ; 370ce $9 + jr nz, .asm_370d9_a .asm_370d0 inc hl - jr .asm_370bd ; 370d1 $ea + jr .asm_370bd .asm_370d3 call AnimateFailedMove jp PrintButItFailed -.asm_370d9 +.asm_370d9_a +.asm_370d9_b call BattleRandom - and $3 + and 3 ; TODO factor in NUM_MOVES ld c, a - ld b, $0 + ld b, 0 ld hl, StringBuffer1 add hl, bc ld a, [hl] cp $ff - jr z, .asm_370d9 ; 370e8 $ef - cp $13 - jr z, .asm_370d9 ; 370ec $eb + jr z, .asm_370d9_b + cp CURSE_T + jr z, .asm_370d9_b ld a, [de] cp [hl] - jr z, .asm_370d9 ; 370f0 $e7 + jr z, .asm_370d9_b inc de ld a, [de] dec de cp [hl] - jr z, .asm_370d9 ; 370f6 $e1 + jr z, .asm_370d9_b ld a, [hl] ld [de], a inc de @@ -8727,10 +8704,10 @@ BattleCommand20: ; 3710e .Fill ld b, PlayerStatLevelsEnd - PlayerStatLevels -.asm_37139 +.next ld [hli], a dec b - jr nz, .asm_37139 + jr nz, .next ret ; 3713e @@ -8742,9 +8719,9 @@ BattleCommand2c: ; 3713e ld hl, BattleMonMaxHP ld a, [hBattleTurn] and a - jr z, .asm_3714f ; 37147 $6 - ld de, EnemyMonHPHi - ld hl, EnemyMonMaxHPHi + jr z, .asm_3714f + ld de, EnemyMonHP + ld hl, EnemyMonMaxHP .asm_3714f ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar @@ -8752,37 +8729,37 @@ BattleCommand2c: ; 3713e push hl push de push bc - ld c, $2 + ld c, 2 call StringCmp pop bc pop de pop hl jp z, .asm_371c4 ld a, b - cp $9c - jr nz, .asm_37199 ; 37166 $31 + cp REST + jr nz, .asm_37199 push hl push de push af call BattleCommandaa ld a, BATTLE_VARS_SUBSTATUS5 - call _GetBattleVar - res 0, [hl] + call GetBattleVarAddr + res SUBSTATUS_TOXIC, [hl] ld a, BATTLE_VARS_STATUS - call _GetBattleVar + call GetBattleVarAddr 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 @@ -8790,10 +8767,10 @@ BattleCommand2c: ; 3713e 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 @@ -8820,8 +8797,8 @@ BattleCommand2d: ; 371cd call Function372d8 ld a, BATTLE_VARS_SUBSTATUS5_OPP - call _GetBattleVar - bit 3, [hl] + call GetBattleVarAddr + bit SUBSTATUS_TRANSFORMED, [hl] jp nz, Function372d2 call CheckHiddenOpponent jp nz, Function372d2 @@ -8831,24 +8808,24 @@ BattleCommand2d: ; 371cd ld a, $1 ld [$c689], a ld a, BATTLE_VARS_SUBSTATUS4 - call _GetBattleVar - bit 4, [hl] + call GetBattleVarAddr + bit SUBSTATUS_SUBSTITUTE, [hl] push af - jr z, .asm_37200 ; 371f4 $a + jr z, .asm_37200 call Function34548 - jr nz, .asm_37200 ; 371f9 $5 - ld a, $a4 + jr nz, .asm_37200 + ld a, SUBSTITUTE call Function37e44 .asm_37200 ld a, BATTLE_VARS_SUBSTATUS5 - call _GetBattleVar - set 3, [hl] + call GetBattleVarAddr + 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 @@ -8860,11 +8837,11 @@ BattleCommand2d: ; 371cd inc hl inc de inc de - ld bc, $0004 + ld bc, NUM_MOVES 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 @@ -8897,20 +8874,20 @@ BattleCommand2d: ; 371cd pop hl ld bc, $ffe8 add hl, bc - ld b, $4 + ld b, NUM_MOVES .asm_3725f 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 @@ -8924,17 +8901,17 @@ BattleCommand2d: ; 371cd 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 @@ -8945,7 +8922,7 @@ BattleCommand2d: ; 371cd ld a, $2 ld [$c689], a pop af - ld a, $a4 + ld a, SUBSTITUTE call nz, Function37e44 ld hl, TransformedText jp StdBattleTextBox @@ -8977,12 +8954,12 @@ Function372d2: ; 372d2 Function372d8: ; 372d8 ld a, BATTLE_VARS_LAST_COUNTER_MOVE - call _GetBattleVar + call GetBattleVarAddr xor a ld [hl], a ld a, BATTLE_VARS_LAST_MOVE - call _GetBattleVar + call GetBattleVarAddr xor a ld [hl], a ret @@ -9024,23 +9001,23 @@ BattleCommand2e: ; 372fc cp EFFECT_LIGHT_SCREEN jr nz, .Reflect - bit 3, [hl] - jr nz, .asm_37337 - set 3, [hl] - ld a, $5 + bit SCREENS_LIGHT_SCREEN, [hl] + jr nz, .failed + set SCREENS_LIGHT_SCREEN, [hl] + ld a, 5 ld [bc], a ld hl, LightScreenEffectText jr .asm_37331 .Reflect - bit 4, [hl] - jr nz, .asm_37337 - set 4, [hl] + bit SCREENS_REFLECT, [hl] + jr nz, .failed + set SCREENS_REFLECT, [hl] -; LightScreenCount -> ReflectCount + ; LightScreenCount -> ReflectCount inc bc - ld a, $5 + ld a, 5 ld [bc], a ld hl, ReflectEffectText @@ -9048,7 +9025,7 @@ BattleCommand2e: ; 372fc call AnimateCurrentMove jp StdBattleTextBox -.asm_37337 +.failed call AnimateFailedMove jp PrintButItFailed ; 3733d @@ -9121,7 +9098,7 @@ PrintParalyze: ; 37372 CheckSubstituteOpp: ; 37378 ld a, BATTLE_VARS_SUBSTATUS4_OPP call GetBattleVar - bit 4, a + bit SUBSTATUS_SUBSTITUTE, a ret ; 37380 @@ -9133,7 +9110,7 @@ BattleCommand1a: ; 37380 ld c, $3 call DelayFrames ld a, BATTLE_VARS_STATUS - call _GetBattleVar + call GetBattleVarAddr xor a ld [hli], a inc hl @@ -9144,15 +9121,15 @@ BattleCommand1a: ; 37380 call BattleCommand0a call Function37e36 ld a, BATTLE_VARS_SUBSTATUS4 - call _GetBattleVar - res 7, [hl] + call GetBattleVarAddr + res SUBSTATUS_LEECH_SEED, [hl] ld a, BATTLE_VARS_SUBSTATUS5_OPP - call _GetBattleVar - res 6, [hl] + call GetBattleVarAddr + res SUBSTATUS_DESTINY_BOND, [hl] call Function37ed5 ret nc callba DrawPlayerHUD - callba Function3e043 + callba DrawEnemyHUD call WaitBGMap jp RefreshBattleHuds ; 373c9 @@ -9219,7 +9196,7 @@ BattleCommand51: ; 37517 ; Don't trap if the opponent is already trapped. ld a, BATTLE_VARS_SUBSTATUS5 - call _GetBattleVar + call GetBattleVarAddr bit SUBSTATUS_CANT_RUN, [hl] jr nz, .failed @@ -9245,7 +9222,7 @@ BattleCommand53: ; 37563 ; Thaw the user. ld a, BATTLE_VARS_STATUS - call _GetBattleVar + call GetBattleVarAddr bit FRZ, [hl] ret z res FRZ, [hl] @@ -9360,30 +9337,30 @@ BattleCommand5f: ; 377ce ; attract ld a, [AttackMissed] and a - jr nz, .asm_377f2 + jr nz, .failed call Function377f5 - jr c, .asm_377f2 + jr c, .failed call CheckHiddenOpponent - jr nz, .asm_377f2 + jr nz, .failed ld a, BATTLE_VARS_SUBSTATUS1_OPP - call _GetBattleVar - bit 7, [hl] - jr nz, .asm_377f2 + call GetBattleVarAddr + bit SUBSTATUS_IN_LOVE, [hl] + jr nz, .failed - set 7, [hl] + set SUBSTATUS_IN_LOVE, [hl] call AnimateCurrentMove ; 'fell in love!' ld hl, FellInLoveText jp StdBattleTextBox -.asm_377f2 +.failed jp Function37354 ; 377f5 Function377f5: ; 377f5 - ld a, 0 + ld a, PartyMon1Species - PartyMon1 call BattlePartyAttr ld a, [hl] ld [CurPartySpecies], a @@ -9404,12 +9381,11 @@ Function377f5: ; 377f5 push bc ld a, [TempEnemyMonSpecies] ld [CurPartySpecies], a - ld hl, EnemyMonAtkDefDV + 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 @@ -9444,22 +9420,22 @@ BattleCommand60: ; 3784b ld hl, BattleMonHappiness ld a, [hBattleTurn] and a - jr z, .asm_37857 ; 37852 $3 + jr z, .ok ld hl, EnemyMonHappiness -.asm_37857 +.ok xor a - ld [$ffb4], a - ld [$ffb5], a + ld [hMultiplicand], a + ld [hMultiplicand + 1], a ld a, [hl] - ld [$ffb6], a - ld a, $a - ld [$ffb7], a + ld [hMultiplicand + 2], a + ld a, 10 + ld [hMultiplier], a call Multiply - ld a, $19 - ld [$ffb7], a - ld b, $4 + ld a, 25 + ld [hDivisor], a + ld b, 4 call Divide - ld a, [$ffb6] + ld a, [hQuotient + 2] ld d, a pop bc ret @@ -9471,23 +9447,27 @@ BattleCommand61: ; 37874 ld a, [InLinkBattle] cp $3 - jr z, .asm_3787d ; 37879 $2 + jr z, .asm_3787d push bc push de .asm_3787d + call BattleCommand07 + ld a, [InLinkBattle] cp $3 - jr z, .asm_37889 ; 37885 $2 + jr z, .asm_37889 pop de pop bc .asm_37889 + ld a, [$d265] and a jp z, AnimateFailedMove ld a, [AttackMissed] and a jp nz, AnimateFailedMove + push bc call BattleRandom ld b, a @@ -9502,6 +9482,7 @@ BattleCommand61: ; 37874 inc c inc hl jr .asm_378a1 ; 378ab $f4 + .asm_378ad ld a, c ld [$c689], a @@ -9509,6 +9490,7 @@ BattleCommand61: ; 37874 ld d, [hl] pop bc ret + .asm_378b7 pop bc ld a, $3 @@ -9524,6 +9506,7 @@ BattleCommand61: ; 37874 ld a, BANK(AICheckPlayerMaxHP) rst FarCall jr c, .asm_378f3 ; 378d1 $20 + ld hl, GetQuarterMaxHP call CallBattleCore call SwitchTurn @@ -9535,6 +9518,7 @@ BattleCommand61: ; 37874 call SwitchTurn call UpdateOpponentInParty jr .asm_37904 ; 378f1 $11 + .asm_378f3 call SwitchTurn call Function37ed5 @@ -9546,9 +9530,9 @@ BattleCommand61: ; 37874 jp EndMoveEffect .table_37907 - db $66, 40 - db $b3, 80 - db $cc, 120 + db 40 percent, 40 + db 70 percent + 1, 80 + db 80 percent, 120 db $ff ; 3790e @@ -9569,12 +9553,12 @@ BattleCommand63: ; 3790e xor a ld [$ffb4], a ld [$ffb5], a - ld a, $a + ld a, 10 ld [$ffb7], a call Multiply - ld a, $19 + ld a, 25 ld [$ffb7], a - ld b, $4 + ld b, 4 call Divide ld a, [$ffb6] ld d, a @@ -9587,22 +9571,22 @@ BattleCommand64: ; 37939 ; safeguard ld hl, PlayerScreens - ld de, $c701 + ld de, PlayerSafeguardCount ld a, [hBattleTurn] and a - jr z, .asm_3794a ; 37942 $6 + jr z, .ok ld hl, EnemyScreens - ld de, $c705 -.asm_3794a - bit 2, [hl] - jr nz, .asm_3795c ; 3794c $e - set 2, [hl] - ld a, $5 + ld de, EnemySafeguardCount +.ok + bit SCREENS_SAFEGUARD, [hl] + jr nz, .failed + set SCREENS_SAFEGUARD, [hl] + ld a, 5 ld [de], a call AnimateCurrentMove ld hl, CoveredByVeilText jp StdBattleTextBox -.asm_3795c +.failed call AnimateFailedMove jp PrintButItFailed ; 37962 @@ -9617,7 +9601,7 @@ Function37962: ; 37962 ld hl, PlayerScreens .asm_3796e - bit 2, [hl] + bit SCREENS_SAFEGUARD, [hl] pop hl ret ; 37972 @@ -9631,9 +9615,9 @@ BattleCommand65: ; 37972 jr z, .asm_3797d ; 37978 $3 ld hl, PlayerScreens .asm_3797d - bit 2, [hl] + bit SCREENS_SAFEGUARD, [hl] ret z - ld a, $1 + ld a, 1 ld [AttackMissed], a call BattleCommandaa ld hl, SafeguardProtectText @@ -9649,14 +9633,14 @@ BattleCommand66: ; 37991 call BattleRandom ld b, a ld hl, .Magnitudes -.asm_37999 +.loop ld a, [hli] cp b - jr nc, .asm_379a1 ; 3799b $4 + jr nc, .ok inc hl inc hl - jr .asm_37999 ; 3799f $f8 -.asm_379a1 + jr .loop +.ok ld d, [hl] push de inc hl @@ -9795,18 +9779,18 @@ BatonPass_LinkEnemySwitch: ; 37a82 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 .asm_37aa0 ld a, [CurOTMon] - add 4 - ld [$d430], a + add NUM_MOVES + ld [wBattleAction], a .asm_37aa8 jp Function1c17 ; 37aab @@ -9821,21 +9805,21 @@ FailedBatonPass: ; 37aab ResetBatonPassStatus: ; 37ab1 ; Reset status changes that aren't passed by Baton Pass. -; Nightmare isn't passed. + ; Nightmare isn't passed. ld a, BATTLE_VARS_STATUS call GetBattleVar and SLP jr nz, .ok ld a, BATTLE_VARS_SUBSTATUS1 - call _GetBattleVar + call GetBattleVarAddr res SUBSTATUS_NIGHTMARE, [hl] .ok -; Disable isn't passed. + ; Disable isn't passed. call ResetActorDisable -; Attraction isn't passed. + ; Attraction isn't passed. ld hl, PlayerSubStatus1 res SUBSTATUS_IN_LOVE, [hl] ld hl, EnemySubStatus1 @@ -9843,13 +9827,13 @@ ResetBatonPassStatus: ; 37ab1 ld hl, PlayerSubStatus5 ld a, BATTLE_VARS_SUBSTATUS5 - call _GetBattleVar - res 3, [hl] - res 4, [hl] + call GetBattleVarAddr + res SUBSTATUS_TRANSFORMED, [hl] + res SUBSTATUS_ENCORED, [hl] -; New mon hasn't used a move yet. + ; New mon hasn't used a move yet. ld a, BATTLE_VARS_LAST_MOVE - call _GetBattleVar + call GetBattleVarAddr ld [hl], 0 xor a @@ -9918,20 +9902,25 @@ CheckAnyOtherAliveMons: ; 37b01 BattleCommand68: ; 37b1d - ld hl, $c711 +; pursuit +; Double damage if the opponent is switching. + + ld hl, wEnemyIsSwitching ld a, [hBattleTurn] and a - jr z, .asm_37b28 ; 37b23 $3 - ld hl, $c710 -.asm_37b28 + jr z, .ok + ld hl, wPlayerIsSwitching +.ok ld a, [hl] and a ret z + ld hl, CurDamage + 1 sla [hl] dec hl rl [hl] ret nc + ld a, $ff ld [hli], a ld [hl], a @@ -9943,13 +9932,14 @@ BattleCommand69: ; 37b39 ; clearhazards ld a, BATTLE_VARS_SUBSTATUS4 - call _GetBattleVar - bit 7, [hl] + call GetBattleVarAddr + bit SUBSTATUS_LEECH_SEED, [hl] jr z, .asm_37b4a ; 37b40 $8 - res 7, [hl] + res SUBSTATUS_LEECH_SEED, [hl] ld hl, ShedLeechSeedText call StdBattleTextBox .asm_37b4a + ld hl, PlayerScreens ld de, $c730 ld a, [hBattleTurn] @@ -9958,14 +9948,15 @@ BattleCommand69: ; 37b39 ld hl, EnemyScreens ld de, $c731 .asm_37b5b - bit 0, [hl] + bit SCREENS_SPIKES, [hl] jr z, .asm_37b69 ; 37b5d $a - res 0, [hl] + res SCREENS_SPIKES, [hl] ld hl, BlewSpikesText push de call StdBattleTextBox pop de .asm_37b69 + ld a, [de] and a ret z @@ -10130,14 +10121,14 @@ BattleCommand95: ; 37c1a pop bc callab Function3cc3f call UpdateUserInParty - ld a, $5 + ld a, 5 .asm_37c41 push af call BattleCommand77 pop af dec a - jr nz, .asm_37c41 ; 37c47 $f8 + jr nz, .asm_37c41 ld hl, BellyDrumText jp StdBattleTextBox @@ -10262,9 +10253,9 @@ BattleCommand9d: ; 37ce6 ld hl, $c6fa ld a, [hBattleTurn] and a - jr z, .asm_37cf1 ; 37cec $3 + jr z, .ok ld hl, $c6fe -.asm_37cf1 +.ok ld a, [hl] and a ret z @@ -10327,10 +10318,10 @@ BattleCommand9c: ; 37d34 call GetBattleVar ld b, a ld a, BATTLE_VARS_LAST_COUNTER_MOVE - call _GetBattleVar + call GetBattleVarAddr ld [hl], b ld a, BATTLE_VARS_LAST_MOVE - call _GetBattleVar + call GetBattleVarAddr ld [hl], b .asm_37d4b ld hl, $c71d @@ -10358,12 +10349,12 @@ BattleCommand9c: ; 37d34 ld hl, CurDamage ld a, [hl] ld [de], a - ld [hl], $0 + ld [hl], 0 inc hl inc de ld a, [hl] ld [de], a - ld [hl], $0 + ld [hl], 0 jp EndMoveEffect .asm_37d87 pop bc @@ -10378,17 +10369,17 @@ BattleCommand9f: ; 37d94 ; thunderaccuracy ld a, BATTLE_VARS_MOVE_TYPE - call _GetBattleVar + call GetBattleVarAddr inc hl ld a, [Weather] cp WEATHER_RAIN - jr z, .asm_37da7 ; 37d9f $6 + jr z, .rain cp WEATHER_SUN ret nz - ld [hl], $80 + ld [hl], 50 percent + 1 ret -.asm_37da7 - ld [hl], $ff +.rain + ld [hl], 100 percent ret ; 37daa @@ -10396,7 +10387,7 @@ BattleCommand9f: ; 37d94 CheckHiddenOpponent: ; 37daa ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar - and $60 ; fly | dig + and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret ; 37db2 @@ -10621,7 +10612,7 @@ SkipToBattleCommand: ; 37e8c GetMoveAttr: ; 37ea1 ; Assuming hl = Moves + x, return attribute x of move a. push bc - ld bc, Move2 - Move1 + ld bc, MOVE_LENGTH call AddNTimes call GetMoveByte pop bc @@ -10632,7 +10623,7 @@ GetMoveAttr: ; 37ea1 GetMoveData: ; 37ead ; Copy move struct a to de. ld hl, Moves - ld bc, Move2 - Move1 + ld bc, MOVE_LENGTH call AddNTimes ld a, Bank(Moves) jp FarCopyBytes @@ -10675,5 +10666,3 @@ Function37ed5: ; 37ed5 ret ; 37ee2 - - diff --git a/battle/effects/curse.asm b/battle/effects/curse.asm index fc08beae6..27f821ffc 100644 --- a/battle/effects/curse.asm +++ b/battle/effects/curse.asm @@ -66,11 +66,11 @@ BattleCommand54: ; 37588 jr nz, .failed ld a, BATTLE_VARS_SUBSTATUS1_OPP - call _GetBattleVar - bit 1, [hl] + call GetBattleVarAddr + bit SUBSTATUS_CURSE, [hl] jr nz, .failed - set 1, [hl] + set SUBSTATUS_CURSE, [hl] call AnimateCurrentMove ld hl, GetHalfMaxHP call CallBattleCore diff --git a/battle/effects/endure.asm b/battle/effects/endure.asm index f449dcebd..9d99c8236 100644 --- a/battle/effects/endure.asm +++ b/battle/effects/endure.asm @@ -7,7 +7,7 @@ BattleCommand5a: ; 3766f ret c ld a, BATTLE_VARS_SUBSTATUS1 - call _GetBattleVar + call GetBattleVarAddr set SUBSTATUS_ENDURE, [hl] call AnimateCurrentMove diff --git a/battle/effects/foresight.asm b/battle/effects/foresight.asm index 7a8f33493..84c10670b 100644 --- a/battle/effects/foresight.asm +++ b/battle/effects/foresight.asm @@ -9,7 +9,7 @@ BattleCommand57: ; 376a0 jr nz, .failed ld a, BATTLE_VARS_SUBSTATUS1_OPP - call _GetBattleVar + call GetBattleVarAddr bit SUBSTATUS_IDENTIFIED, [hl] jr nz, .failed diff --git a/battle/effects/metronome.asm b/battle/effects/metronome.asm index 3762ec372..97052a66c 100644 --- a/battle/effects/metronome.asm +++ b/battle/effects/metronome.asm @@ -36,7 +36,7 @@ BattleCommand34: ; 37418 ld a, BATTLE_VARS_MOVE - call _GetBattleVar + call GetBattleVarAddr ld [hl], b call UpdateMoveData jp ResetTurn diff --git a/battle/effects/mirror_move.asm b/battle/effects/mirror_move.asm index 60748bdae..a9dfa7931 100644 --- a/battle/effects/mirror_move.asm +++ b/battle/effects/mirror_move.asm @@ -4,7 +4,7 @@ BattleCommand1b: ; 373c9 call Function372d8 ld a, BATTLE_VARS_MOVE - call _GetBattleVar + call GetBattleVarAddr ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar @@ -28,7 +28,7 @@ BattleCommand1b: ; 373c9 push af ld a, BATTLE_VARS_MOVE_ANIM - call _GetBattleVar + call GetBattleVarAddr ld d, h ld e, l pop af diff --git a/battle/effects/nightmare.asm b/battle/effects/nightmare.asm index cd3210cab..01f17ff71 100644 --- a/battle/effects/nightmare.asm +++ b/battle/effects/nightmare.asm @@ -14,14 +14,14 @@ BattleCommand52: ; 37536 ; Only works on a sleeping opponent. ld a, BATTLE_VARS_STATUS_OPP - call _GetBattleVar + call GetBattleVarAddr and SLP jr z, .failed ; Bail if the opponent is already having a nightmare. ld a, BATTLE_VARS_SUBSTATUS1_OPP - call _GetBattleVar + call GetBattleVarAddr bit SUBSTATUS_NIGHTMARE, [hl] jr nz, .failed diff --git a/battle/effects/protect.asm b/battle/effects/protect.asm index a28c0461e..be9284135 100644 --- a/battle/effects/protect.asm +++ b/battle/effects/protect.asm @@ -4,7 +4,7 @@ BattleCommand55: ; 37618 ret c ld a, BATTLE_VARS_SUBSTATUS1 - call _GetBattleVar + call GetBattleVarAddr set SUBSTATUS_PROTECT, [hl] call AnimateCurrentMove diff --git a/battle/effects/rollout.asm b/battle/effects/rollout.asm index 13c91a8d9..d3a765de5 100644 --- a/battle/effects/rollout.asm +++ b/battle/effects/rollout.asm @@ -1,22 +1,24 @@ +MAX_ROLLOUT_COUNT EQU 5 + + BattleCommand5b: ; 37718 ; checkcurl ld de, PlayerRolloutCount ld a, [hBattleTurn] and a - jr z, .asm_37723 + jr z, .ok ld de, EnemyRolloutCount - -.asm_37723 +.ok ld a, BATTLE_VARS_SUBSTATUS1 call GetBattleVar - bit SUBSTATUS_ENCORED, a - jr z, .asm_37731 + bit SUBSTATUS_ROLLOUT, a + jr z, .reset ld b, $4 ; doturn jp SkipToBattleCommand -.asm_37731 +.reset xor a ld [de], a ret @@ -28,7 +30,7 @@ BattleCommand5c: ; 37734 ld a, BATTLE_VARS_STATUS call GetBattleVar - and 7 + and SLP ret nz ld hl, PlayerRolloutCount @@ -50,7 +52,7 @@ BattleCommand5c: ; 37734 jr z, .hit ld a, BATTLE_VARS_SUBSTATUS1 - call _GetBattleVar + call GetBattleVarAddr res 6, [hl] ret @@ -58,23 +60,23 @@ BattleCommand5c: ; 37734 inc [hl] ld a, [hl] ld b, a - cp $5 + cp MAX_ROLLOUT_COUNT jr c, .asm_3776e ld a, BATTLE_VARS_SUBSTATUS1 - call _GetBattleVar - res 6, [hl] + call GetBattleVarAddr + res SUBSTATUS_ROLLOUT, [hl] jr .asm_37775 .asm_3776e ld a, BATTLE_VARS_SUBSTATUS1 - call _GetBattleVar - set 6, [hl] + call GetBattleVarAddr + set SUBSTATUS_ROLLOUT, [hl] .asm_37775 ld a, BATTLE_VARS_SUBSTATUS2 call GetBattleVar - bit 0, a + bit SUBSTATUS_CURLED, a jr z, .asm_3777f inc b .asm_3777f diff --git a/battle/hidden_power.asm b/battle/hidden_power.asm index b02b31d12..4d1ad9dc3 100644 --- a/battle/hidden_power.asm +++ b/battle/hidden_power.asm @@ -96,7 +96,7 @@ HiddenPowerDamage: ; fbced ; Overwrite the current move type. push af ld a, BATTLE_VARS_MOVE_TYPE - call _GetBattleVar + call GetBattleVarAddr pop af ld [hl], a diff --git a/battle/moves/moves.asm b/battle/moves/moves.asm index d37376378..3877e9960 100644 --- a/battle/moves/moves.asm +++ b/battle/moves/moves.asm @@ -1,22 +1,17 @@ Moves: ; 41afb - -; Characteristics of each move - -; animation, effect, power, type, accuracy, PP, effect chance +; Characteristics of each move. move: MACRO db \1 ; animation db \2 ; effect db \3 ; power db \4 ; type - db \5 * $ff / 100 ; accuracy (percent) + db \5 percent ; accuracy db \6 ; pp - db \7 * $ff / 100 ; effect chance (percent) + db \7 percent ; effect chance ENDM -Move1: move POUND, EFFECT_NORMAL_HIT, 40, NORMAL, 100, 35, 0 -Move2: move KARATE_CHOP, EFFECT_NORMAL_HIT, 50, FIGHTING, 100, 25, 0 move DOUBLESLAP, EFFECT_MULTI_HIT, 15, NORMAL, 85, 10, 0 move COMET_PUNCH, EFFECT_MULTI_HIT, 18, NORMAL, 85, 15, 0 |