More comments and constants in move effect command code.

Also add SUBSTATUS_IN_LOOP for multi-hit moves.
This commit is contained in:
yenatch 2014-06-23 12:47:07 -07:00
parent 32a5f21cc7
commit d6fbdfb8de
3 changed files with 125 additions and 114 deletions

View File

@ -75,9 +75,9 @@ Function3c000: ; 3c000
ld a, [CurPartyMon] ld a, [CurPartyMon]
ld [CurBattleMon], a ld [CurBattleMon], a
inc a inc a
ld hl, PartyCount ld hl, PartySpecies - 1
ld c, a ld c, a
ld b, $0 ld b, 0
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
ld [CurPartySpecies], a ld [CurPartySpecies], a
@ -1463,7 +1463,6 @@ Function3c93c: ; 3c93c
ld b, 1 ld b, 1
jr z, .asm_3c9b8 jr z, .asm_3c9b8
ld b, 5 ld b, 5
.asm_3c9b8 .asm_3c9b8
ld a, [de] ld a, [de]
add b add b
@ -1479,7 +1478,6 @@ Function3c93c: ; 3c93c
jr z, .asm_3c9d2 jr z, .asm_3c9d2
ld de, EnemyMonMoves - 1 ld de, EnemyMonMoves - 1
ld hl, EnemyMonPP ld hl, EnemyMonPP
.asm_3c9d2 .asm_3c9d2
inc de inc de
pop bc pop bc
@ -1491,6 +1489,7 @@ Function3c93c: ; 3c93c
add hl, bc add hl, bc
pop de pop de
pop bc pop bc
ld a, [$d265] ld a, [$d265]
cp [hl] cp [hl]
jr nz, .asm_3c9f5 jr nz, .asm_3c9f5
@ -1499,14 +1498,12 @@ Function3c93c: ; 3c93c
ld a, [PlayerSubStatus5] ld a, [PlayerSubStatus5]
jr z, .asm_3c9ee jr z, .asm_3c9ee
ld a, [EnemySubStatus5] ld a, [EnemySubStatus5]
.asm_3c9ee .asm_3c9ee
bit SUBSTATUS_TRANSFORMED, a bit SUBSTATUS_TRANSFORMED, a
jr nz, .asm_3c9f5 jr nz, .asm_3c9f5
ld a, [de] ld a, [de]
add b add b
ld [de], a ld [de], a
.asm_3c9f5 .asm_3c9f5
callab GetUserItem callab GetUserItem
ld a, [hl] ld a, [hl]
@ -2207,7 +2204,7 @@ Function3ce01: ; 3ce01
.asm_3ce16 .asm_3ce16
ld hl, PlayerSubStatus3 ld hl, PlayerSubStatus3
res 2, [hl] res SUBSTATUS_IN_LOOP, [hl]
xor a xor a
ld hl, EnemyDamageTaken ld hl, EnemyDamageTaken
ld [hli], a ld [hli], a
@ -2287,8 +2284,8 @@ Function3ceaa: ; 3ceaa
ld a, [PartyCount] ld a, [PartyCount]
ld b, a ld b, a
ld hl, PartyMon1 ld hl, PartyMon1
ld c, $1 ld c, 1
ld d, $0 ld d, 0
.asm_3ceb5 .asm_3ceb5
push hl push hl
push bc push bc
@ -2322,9 +2319,10 @@ Function3ceaa: ; 3ceaa
pop de pop de
dec b dec b
jr nz, .asm_3ceb5 jr nz, .asm_3ceb5
ld a, d ld a, d
ld e, $0 ld e, 0
ld b, $6 ld b, PARTY_LENGTH
.asm_3cee1 .asm_3cee1
srl a srl a
jr nc, .asm_3cee6 jr nc, .asm_3cee6
@ -2801,7 +2799,7 @@ Function3d1aa: ; 3d1aa
ld b, $0 ld b, $0
predef FlagPredef predef FlagPredef
ld hl, EnemySubStatus3 ld hl, EnemySubStatus3
res 2, [hl] res SUBSTATUS_IN_LOOP, [hl]
xor a xor a
ld [Danger], a ld [Danger], a
ld hl, PlayerDamageTaken ld hl, PlayerDamageTaken
@ -3471,14 +3469,14 @@ Function3d618: ; 3d618
ld a, b ld a, b
inc a inc a
ld c, a ld c, a
ld b, $0 ld b, 0
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
dec a dec a
ld hl, BaseData + 7 ; type ld hl, BaseData + 7 ; type
ld bc, $20 ld bc, $20
call AddNTimes call AddNTimes
ld de, EnemyMonType1 ld de, EnemyMonType
ld bc, 2 ld bc, 2
ld a, BANK(BaseData) ld a, BANK(BaseData)
call FarCopyBytes call FarCopyBytes
@ -3487,13 +3485,13 @@ Function3d618: ; 3d618
call SetPlayerTurn call SetPlayerTurn
callab Function347c8 callab Function347c8
ld a, [$d265] ld a, [$d265]
cp $b cp 10 + 1 ; 1.0 + 0.1
jr nc, .asm_3d663 jr nc, .asm_3d663
ld a, [BattleMonType2] ld a, [BattleMonType2]
ld [wPlayerMoveStruct + MOVE_TYPE], a ld [wPlayerMoveStruct + MOVE_TYPE], a
callab Function347c8 callab Function347c8
ld a, [$d265] ld a, [$d265]
cp $b cp 10 + 1 ; 1.0 + 0.1
jr nc, .asm_3d663 jr nc, .asm_3d663
pop bc pop bc
ret ret

View File

@ -1241,7 +1241,7 @@ BattleCommand05: ; 34631
.FocusEnergy .FocusEnergy
ld a, BATTLE_VARS_SUBSTATUS4 ld a, BATTLE_VARS_SUBSTATUS4
call GetBattleVar call GetBattleVar
bit 2, a bit SUBSTATUS_FOCUS_ENERGY, a
jr z, .CheckCritical jr z, .CheckCritical
; +1 critical level ; +1 critical level
@ -1595,8 +1595,8 @@ BattleCommanda3: ; 34833
call Function347c8 call Function347c8
ld a, [$d265] ld a, [$d265]
and a and a
ld a, $a ld a, 10 ; 1.0
jr nz, .asm_3484a ; 3483c $c jr nz, .asm_3484a
call ResetDamage call ResetDamage
xor a xor a
ld [TypeModifier], a ld [TypeModifier], a
@ -1618,75 +1618,86 @@ Function3484e: ; 3484e
ld hl, PlayerUsedMoves ld hl, PlayerUsedMoves
ld a, [hl] ld a, [hl]
and a and a
jr z, .asm_348b0 ; 0x3485b $53 jr z, .unknown_moves
ld d, $4
ld e, $0 ld d, NUM_MOVES
.asm_34861 ld e, 0
.loop
ld a, [hli] ld a, [hli]
and a and a
jr z, .asm_3489f ; 0x34863 $3a jr z, .exit
push hl push hl
dec a dec a
ld hl, Moves + MOVE_POWER ld hl, Moves + MOVE_POWER
call GetMoveAttr call GetMoveAttr
and a and a
jr z, .asm_3489b ; 0x3486e $2b jr z, .next
inc hl inc hl
call GetMoveByte call GetMoveByte
ld hl, EnemyMonType1 ld hl, EnemyMonType
call Function347d3 call Function347d3
ld a, [$d265] ld a, [$d265]
cp $b cp 10 + 1 ; 1.0 + 0.1
jr nc, .asm_34895 ; 0x3487f $14 jr nc, .super_effective
and a and a
jr z, .asm_3489b ; 0x34882 $17 jr z, .next
cp $a cp 10 ; 1.0
jr nc, .asm_34891 ; 0x34886 $9 jr nc, .neutral
.not_very_effective
ld a, e ld a, e
cp $1 cp 1 ; 0.1
jr nc, .asm_3489b ; 0x3488b $e jr nc, .next
ld e, $1 ld e, 1
jr .asm_3489b ; 0x3488f $a jr .next
.asm_34891
ld e, $2 .neutral
jr .asm_3489b ; 0x34893 $6 ld e, 2
.asm_34895 jr .next
.super_effective
call Function34931 call Function34931
pop hl pop hl
jr .asm_348d7 ; 0x34899 $3c jr .done
.asm_3489b
.next
pop hl pop hl
dec d dec d
jr nz, .asm_34861 ; 0x3489d $c2 jr nz, .loop
.asm_3489f
.exit
ld a, e ld a, e
cp $2 cp 2
jr z, .asm_348d7 ; 0x348a2 $33 jr z, .done
call Function34939 call Function34939
ld a, e ld a, e
and a and a
jr nz, .asm_348d7 ; 0x348a9 $2c jr nz, .done
call Function34939 call Function34939
jr .asm_348d7 ; 0x348ae $27 jr .done
.asm_348b0
.unknown_moves
ld a, [BattleMonType1] ld a, [BattleMonType1]
ld b, a ld b, a
ld hl, EnemyMonType1 ld hl, EnemyMonType1
call Function347d3 call Function347d3
ld a, [$d265] ld a, [$d265]
cp $b cp 10 + 1 ; 1.0 + 0.1
jr c, .asm_348c4 ; 0x348bf $3 jr c, .ok
call Function34931 call Function34931
.asm_348c4 .ok
ld a, [BattleMonType2] ld a, [BattleMonType2]
cp b cp b
jr z, .asm_348d7 ; 0x348c8 $d jr z, .ok2
call Function347d3 call Function347d3
ld a, [$d265] ld a, [$d265]
cp $b cp 10 + 1 ; 1.0 + 0.1
jr c, .asm_348d7 ; 0x348d2 $3 jr c, .ok2
call Function34931 call Function34931
.asm_348d7 .ok2
.done
call Function348de call Function348de
pop bc pop bc
pop de pop de
@ -1702,7 +1713,6 @@ Function348de: ; 348de
ld a, [$d265] ld a, [$d265]
push af push af
.loop .loop
dec b dec b
jr z, .exit jr z, .exit
@ -1722,27 +1732,31 @@ Function348de: ; 348de
call GetMoveByte call GetMoveByte
ld hl, BattleMonType1 ld hl, BattleMonType1
call Function347d3 call Function347d3
ld a, [$d265] ld a, [$d265]
; immune
and a and a
jr z, .loop jr z, .loop
; not very effective
inc c inc c
cp 10 cp 10
jr c, .loop jr c, .loop
; neutral
inc c inc c
inc c inc c
inc c inc c
inc c inc c
inc c inc c
cp 10 cp 10
jr z, .loop jr z, .loop
; super effective
ld c, 100 ld c, 100
jr .loop jr .loop
.exit
.exit
pop af pop af
ld [$d265], a ld [$d265], a
@ -1897,18 +1911,18 @@ Function34941: ; 34941
Function349f4: ; 349f4 Function349f4: ; 349f4
ld a, [OTPartyCount] ld a, [OTPartyCount]
cp 2 cp 2
jr c, .asm_34a26 jr c, .only_one
ld d, a ld d, a
ld e, 0 ld e, 0
ld b, $20 ld b, 1 << (PARTY_LENGTH - 1)
ld c, 0 ld c, 0
ld hl, OTPartyMon1HP ld hl, OTPartyMon1HP
.asm_34a05 .loop
ld a, [CurOTMon] ld a, [CurOTMon]
cp e cp e
jr z, .asm_34a16 jr z, .next
push bc push bc
ld b, [hl] ld b, [hl]
@ -1916,13 +1930,13 @@ Function349f4: ; 349f4
ld a, [hld] ld a, [hld]
or b or b
pop bc pop bc
jr z, .asm_34a16 jr z, .next
ld a, c ld a, c
or b or b
ld c, a ld c, a
.asm_34a16 .next
srl b srl b
push bc push bc
ld bc, PartyMon2 - PartyMon1 ld bc, PartyMon2 - PartyMon1
@ -1930,17 +1944,17 @@ Function349f4: ; 349f4
pop bc pop bc
inc e inc e
dec d dec d
jr nz, .asm_34a05 jr nz, .loop
ld a, c ld a, c
and a and a
jr nz, .asm_34a28 jr nz, .more_than_one
.asm_34a26 .only_one
scf scf
ret ret
.asm_34a28 .more_than_one
and a and a
ret ret
; 34a2a ; 34a2a
@ -2205,15 +2219,15 @@ Function34b20: ; 34b20
Function34b77: ; 34b77 Function34b77: ; 34b77
push bc push bc
ld de, OTPartySpecies ld de, OTPartySpecies
ld b, $20 ld b, 1 << (PARTY_LENGTH - 1)
ld c, 0 ld c, 0
ld hl, OTPartyMon1HP ld hl, OTPartyMon1HP
.asm_34b82 .loop
ld a, [de] ld a, [de]
inc de inc de
cp $ff cp $ff
jr z, .asm_34bac jr z, .done
push hl push hl
push bc push bc
@ -2231,22 +2245,22 @@ Function34b77: ; 34b77
ld a, [hl] ld a, [hl]
sbc b sbc b
pop bc pop bc
jr nc, .asm_34ba1 jr nc, .next
ld a, b ld a, b
or c or c
ld c, a ld c, a
.asm_34ba1 .next
srl b srl b
pop hl pop hl
push bc push bc
ld bc, PartyMon2 - PartyMon1 ld bc, PartyMon2 - PartyMon1
add hl, bc add hl, bc
pop bc pop bc
jr .asm_34b82 jr .loop
.asm_34bac .done
ld a, c ld a, c
pop bc pop bc
and c and c
@ -2339,7 +2353,7 @@ BattleCommand09: ; 34d32
call .UnleashedEnergy call .UnleashedEnergy
ret nz ret nz
; Perfect-accuracy moves ; Perfect-accuracy moves
ld a, BATTLE_VARS_MOVE_EFFECT ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar call GetBattleVar
cp EFFECT_ALWAYS_HIT cp EFFECT_ALWAYS_HIT
@ -2893,9 +2907,9 @@ BattleCommand0d: ; 35023
call GetBattleVarAddr call GetBattleVarAddr
cp FLY cp FLY
jr z, .asm_3504f ; 35032 $1b jr z, .asm_3504f
cp DIG cp DIG
jr z, .asm_3504f ; 35036 $17 jr z, .asm_3504f
; Move effect: ; Move effect:
inc hl inc hl
@ -2929,25 +2943,25 @@ BattleCommand0e: ; 3505e
ld a, BATTLE_VARS_SUBSTATUS1_OPP ld a, BATTLE_VARS_SUBSTATUS1_OPP
call GetBattleVar call GetBattleVar
bit SUBSTATUS_ENDURE, a bit SUBSTATUS_ENDURE, a
jr z, .asm_35072 ; 35065 $b jr z, .asm_35072
call BattleCommand4b call BattleCommand4b
ld b, $0 ld b, $0
jr nc, .asm_3508b ; 3506c $1d jr nc, .asm_3508b
ld b, $1 ld b, $1
jr .asm_3508b ; 35070 $19 jr .asm_3508b
.asm_35072 .asm_35072
call GetOpponentItem call GetOpponentItem
ld a, b ld a, b
cp HELD_FOCUS_BAND cp HELD_FOCUS_BAND
ld b, $0 ld b, $0
jr nz, .asm_3508b ; 3507a $f jr nz, .asm_3508b
call BattleRandom call BattleRandom
cp c cp c
jr nc, .asm_3508b ; 35080 $9 jr nc, .asm_3508b
call BattleCommand4b call BattleCommand4b
ld b, $0 ld b, $0
jr nc, .asm_3508b ; 35087 $2 jr nc, .asm_3508b
ld b, $2 ld b, $2
.asm_3508b .asm_3508b
push bc push bc
@ -2968,7 +2982,7 @@ BattleCommand0e: ; 3505e
and a and a
ret z ret z
dec a dec a
jr nz, .asm_350ab ; 350a3 $6 jr nz, .asm_350ab
ld hl, EnduredText ld hl, EnduredText
jp StdBattleTextBox jp StdBattleTextBox
@ -3019,23 +3033,24 @@ Function350e4: ; 350e4
ld de, DoesntAffectText ld de, DoesntAffectText
ld a, [TypeModifier] ld a, [TypeModifier]
and $7f and $7f
jr z, .asm_35110 ; 0x350ef $1f jr z, .asm_35110
ld a, BATTLE_VARS_MOVE_EFFECT ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar call GetBattleVar
cp EFFECT_FUTURE_SIGHT cp EFFECT_FUTURE_SIGHT
ld hl, ButItFailedText ld hl, ButItFailedText
ld de, ItFailedText ld de, ItFailedText
jr z, .asm_35110 ; 0x350fe $10 jr z, .asm_35110
ld hl, AttackMissedText ld hl, AttackMissedText
ld de, AttackMissed2Text ld de, AttackMissed2Text
ld a, [CriticalHit] ld a, [CriticalHit]
cp $ff cp $ff
jr nz, .asm_35110 ; 0x3510b $3 jr nz, .asm_35110
ld hl, UnaffectedText ld hl, UnaffectedText
.asm_35110 .asm_35110
call Function35157 call Function35157
xor a xor a
ld [CriticalHit], a ld [CriticalHit], a
ld a, BATTLE_VARS_MOVE_EFFECT ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar call GetBattleVar
cp EFFECT_JUMP_KICK cp EFFECT_JUMP_KICK
@ -3046,17 +3061,15 @@ Function350e4: ; 350e4
ld hl, CurDamage ld hl, CurDamage
ld a, [hli] ld a, [hli]
ld b, [hl] ld b, [hl]
rept 3
srl a srl a
rr b rr b
srl a endr
rr b
srl a
rr b
ld [hl], b ld [hl], b
dec hl dec hl
ld [hli], a ld [hli], a
or b or b
jr nz, .asm_3513e ; 0x3513a $2 jr nz, .asm_3513e
inc a inc a
ld [hl], a ld [hl], a
.asm_3513e .asm_3513e
@ -3106,7 +3119,7 @@ BattleCommand0f: ; 35175
dec a dec a
add a add a
ld hl, .ptrs ld hl, .texts
ld b, 0 ld b, 0
ld c, a ld c, a
add hl, bc add hl, bc
@ -3122,9 +3135,9 @@ BattleCommand0f: ; 35175
ld c, 20 ld c, 20
jp DelayFrames jp DelayFrames
.ptrs .texts
dw CriticalHitText ; 'critical hit' dw CriticalHitText
dw OneHitKOText ; 'one-hit ko' dw OneHitKOText
; 35197 ; 35197
@ -3134,10 +3147,9 @@ BattleCommandae: ; 35197
ld hl, PlayerRolloutCount ld hl, PlayerRolloutCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_351a2 jr z, .ok
ld hl, EnemyRolloutCount ld hl, EnemyRolloutCount
.ok
.asm_351a2
xor a xor a
ld [hl], a ld [hl], a
ret ret
@ -3149,7 +3161,7 @@ BattleCommandad: ; 351a5
ld a, BATTLE_VARS_SUBSTATUS3 ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr call GetBattleVarAddr
bit 2, a bit SUBSTATUS_IN_LOOP, a
ret nz ret nz
; fallthrough ; fallthrough
@ -3163,9 +3175,9 @@ BattleCommand10: ; 351ad
and $7f and $7f
cp 10 ; 1.0 cp 10 ; 1.0
ret z ret z
ld hl, SuperEffectiveText ; 'super-effective' ld hl, SuperEffectiveText
jr nc, .print jr nc, .print
ld hl, NotVeryEffectiveText ; 'not very effective' ld hl, NotVeryEffectiveText
.print .print
jp StdBattleTextBox jp StdBattleTextBox
; 351c0 ; 351c0
@ -3304,14 +3316,14 @@ BattleCommanda2: ; 3527b
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
ld a, [$c72b] ld a, [$c72b]
jr z, .asm_35290 ; 3528b $3 jr z, .asm_35290
ld a, [$c72c] ld a, [$c72c]
.asm_35290 .asm_35290
and a and a
jr z, .asm_3529a ; 35291 $7 jr z, .asm_3529a
dec a dec a
add hl, bc add hl, bc
jr nc, .asm_35290 ; 35295 $f9 jr nc, .asm_35290
ld hl, $ffff ld hl, $ffff
.asm_3529a .asm_3529a
ld a, h ld a, h
@ -3440,11 +3452,11 @@ PlayerAttackDamage: ; 352e2
call GetDamageStatsCritical call GetDamageStatsCritical
jr c, .lightball jr c, .lightball
ld hl, $c6c9 ld hl, EnemyStats + SP_DEFENSE * 2
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld c, [hl] ld c, [hl]
ld hl, $c6bc ld hl, PlayerStats + SP_ATTACK * 2
.lightball .lightball
; Note: Returns player special attack at hl in hl. ; Note: Returns player special attack at hl in hl.
@ -3730,7 +3742,7 @@ BattleCommanda1: ; 35461
and a and a
jp nz, .asm_354ef jp nz, .asm_354ef
ld a, [PlayerSubStatus3] ld a, [PlayerSubStatus3]
bit 2, a bit SUBSTATUS_IN_LOOP, a
jr nz, .asm_35482 jr nz, .asm_35482
ld c, 20 ld c, 20
call DelayFrames call DelayFrames
@ -3796,7 +3808,7 @@ BattleCommanda1: ; 35461
.asm_354ef .asm_354ef
ld a, [EnemySubStatus3] ld a, [EnemySubStatus3]
bit 2, a bit SUBSTATUS_IN_LOOP, a
jr nz, .asm_35502 jr nz, .asm_35502
xor a xor a
@ -7423,9 +7435,9 @@ BattleCommand24: ; 369b6
ld a, BATTLE_VARS_SUBSTATUS3 ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr call GetBattleVarAddr
bit 2, [hl] bit SUBSTATUS_IN_LOOP, [hl]
jp nz, .asm_36a43 jp nz, .asm_36a43
set 2, [hl] set SUBSTATUS_IN_LOOP, [hl]
ld a, BATTLE_VARS_MOVE_EFFECT ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVarAddr call GetBattleVarAddr
ld a, [hl] ld a, [hl]
@ -7470,7 +7482,7 @@ BattleCommand24: ; 369b6
.asm_36a1e .asm_36a1e
ld a, BATTLE_VARS_SUBSTATUS3 ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr call GetBattleVarAddr
res 2, [hl] res SUBSTATUS_IN_LOOP, [hl]
call BattleCommanda8 call BattleCommanda8
jp EndMoveEffect jp EndMoveEffect
.asm_36a2b .asm_36a2b
@ -7499,7 +7511,7 @@ BattleCommand24: ; 369b6
.asm_36a48 .asm_36a48
ld a, BATTLE_VARS_SUBSTATUS3 ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr call GetBattleVarAddr
res 2, [hl] res SUBSTATUS_IN_LOOP, [hl]
ld hl, PlayerHitTimesText ld hl, PlayerHitTimesText
ld a, [hBattleTurn] ld a, [hBattleTurn]

View File

@ -101,6 +101,7 @@ SUBSTATUS_FLYING EQU 6
SUBSTATUS_UNDERGROUND EQU 5 SUBSTATUS_UNDERGROUND EQU 5
SUBSTATUS_CHARGED EQU 4 SUBSTATUS_CHARGED EQU 4
SUBSTATUS_FLINCHED EQU 3 SUBSTATUS_FLINCHED EQU 3
SUBSTATUS_IN_LOOP EQU 2
SUBSTATUS_RAMPAGE EQU 1 SUBSTATUS_RAMPAGE EQU 1
SUBSTATUS_BIDE EQU 0 SUBSTATUS_BIDE EQU 0