Comment SapHealth

Also fixed some Beat Up inconsistencies to make it more readable.
This commit is contained in:
mid-kid
2018-04-04 22:35:47 +02:00
parent 0c446367ce
commit e1da37e033
2 changed files with 37 additions and 12 deletions

View File

@@ -4136,6 +4136,7 @@ BattleCommand_EatDream: ; 36008
SapHealth: ; 36011 SapHealth: ; 36011
; Divide damage by 2, store it in hDividend
ld hl, wCurDamage ld hl, wCurDamage
ld a, [hli] ld a, [hli]
srl a srl a
@@ -4145,10 +4146,11 @@ SapHealth: ; 36011
rr a rr a
ld [hDividend + 1], a ld [hDividend + 1], a
or b or b
jr nz, .ok1 jr nz, .at_least_one
ld a, $1 ld a, 1
ld [hDividend + 1], a ld [hDividend + 1], a
.ok1 .at_least_one
ld hl, wBattleMonHP ld hl, wBattleMonHP
ld de, wBattleMonMaxHP ld de, wBattleMonMaxHP
ld a, [hBattleTurn] ld a, [hBattleTurn]
@@ -4157,12 +4159,16 @@ SapHealth: ; 36011
ld hl, wEnemyMonHP ld hl, wEnemyMonHP
ld de, wEnemyMonMaxHP ld de, wEnemyMonMaxHP
.battlemonhp .battlemonhp
; Store current HP in little endian wBuffer3/4
ld bc, wBuffer4 ld bc, wBuffer4
ld a, [hli] ld a, [hli]
ld [bc], a ld [bc], a
ld a, [hl] ld a, [hl]
dec bc dec bc
ld [bc], a ld [bc], a
; Store max HP in little endian wBuffer1/2
ld a, [de] ld a, [de]
dec bc dec bc
ld [bc], a ld [bc], a
@@ -4170,6 +4176,8 @@ SapHealth: ; 36011
ld a, [de] ld a, [de]
dec bc dec bc
ld [bc], a ld [bc], a
; Add hDividend to current HP and copy it to little endian wBuffer5/6
ld a, [hDividend + 1] ld a, [hDividend + 1]
ld b, [hl] ld b, [hl]
add b add b
@@ -4180,7 +4188,9 @@ SapHealth: ; 36011
adc b adc b
ld [hli], a ld [hli], a
ld [wBuffer6], a ld [wBuffer6], a
jr c, .okay2 jr c, .max_hp
; Substract current HP from max HP (to see if we have more than max HP)
ld a, [hld] ld a, [hld]
ld b, a ld b, a
ld a, [de] ld a, [de]
@@ -4191,8 +4201,10 @@ SapHealth: ; 36011
ld a, [de] ld a, [de]
inc de inc de
sbc b sbc b
jr nc, .okay3 jr nc, .finish
.okay2
.max_hp
; Load max HP into current HP and copy it to little endian wBuffer5/6
ld a, [de] ld a, [de]
ld [hld], a ld [hld], a
ld [wBuffer5], a ld [wBuffer5], a
@@ -4201,7 +4213,8 @@ SapHealth: ; 36011
ld [hli], a ld [hli], a
ld [wBuffer6], a ld [wBuffer6], a
inc de inc de
.okay3
.finish
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
hlcoord 10, 9 hlcoord 10, 9

View File

@@ -5,9 +5,11 @@ BattleCommand_BeatUp: ; 35461
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jp nz, .enemy_beats_up jp nz, .enemy_beats_up
ld a, [wPlayerSubStatus3] ld a, [wPlayerSubStatus3]
bit SUBSTATUS_IN_LOOP, a bit SUBSTATUS_IN_LOOP, a
jr nz, .next_mon jr nz, .next_mon
ld c, 20 ld c, 20
call DelayFrames call DelayFrames
xor a xor a
@@ -51,11 +53,13 @@ BattleCommand_BeatUp: ; 35461
ld [wBeatUpHitAtLeastOnce], a ld [wBeatUpHitAtLeastOnce], a
ld hl, BeatUpAttackText ld hl, BeatUpAttackText
call StdBattleTextBox call StdBattleTextBox
ld a, [wEnemyMonSpecies] ld a, [wEnemyMonSpecies]
ld [wCurSpecies], a ld [wCurSpecies], a
call GetBaseData call GetBaseData
ld a, [wBaseDefense] ld a, [wBaseDefense]
ld c, a ld c, a
push bc push bc
ld a, MON_SPECIES ld a, MON_SPECIES
call GetBeatupMonLocation call GetBeatupMonLocation
@@ -65,12 +69,14 @@ BattleCommand_BeatUp: ; 35461
ld a, [wBaseAttack] ld a, [wBaseAttack]
pop bc pop bc
ld b, a ld b, a
push bc push bc
ld a, MON_LEVEL ld a, MON_LEVEL
call GetBeatupMonLocation call GetBeatupMonLocation
ld a, [hl] ld a, [hl]
ld e, a ld e, a
pop bc pop bc
ld a, [wPlayerMoveStructPower] ld a, [wPlayerMoveStructPower]
ld d, a ld d, a
ret ret
@@ -78,21 +84,22 @@ BattleCommand_BeatUp: ; 35461
.enemy_beats_up .enemy_beats_up
ld a, [wEnemySubStatus3] ld a, [wEnemySubStatus3]
bit SUBSTATUS_IN_LOOP, a bit SUBSTATUS_IN_LOOP, a
jr nz, .not_first_enemy_beatup jr nz, .enemy_next_mon
xor a xor a
ld [wEnemyRolloutCount], a ld [wEnemyRolloutCount], a
ld [wd002], a ld [wd002], a
ld [wBeatUpHitAtLeastOnce], a ld [wBeatUpHitAtLeastOnce], a
jr .enemy_continue jr .enemy_got_mon
.not_first_enemy_beatup .enemy_next_mon
ld a, [wEnemyRolloutCount] ld a, [wEnemyRolloutCount]
ld b, a ld b, a
ld a, [wOTPartyCount] ld a, [wOTPartyCount]
sub b sub b
ld [wd002], a ld [wd002], a
.enemy_continue
.enemy_got_mon
ld a, [wBattleMode] ld a, [wBattleMode]
dec a dec a
jr z, .wild jr z, .wild
@@ -122,19 +129,20 @@ BattleCommand_BeatUp: ; 35461
call AddNTimes call AddNTimes
ld de, wStringBuffer1 ld de, wStringBuffer1
call CopyBytes call CopyBytes
.got_enemy_nick .got_enemy_nick
ld a, MON_HP ld a, MON_HP
call GetBeatupMonLocation call GetBeatupMonLocation
ld a, [hli] ld a, [hli]
or [hl] or [hl]
jp z, .beatup_fail jp z, .beatup_fail
ld a, [wd002] ld a, [wd002]
ld b, a ld b, a
ld a, [wCurOTMon] ld a, [wCurOTMon]
cp b cp b
ld hl, wEnemyMonStatus ld hl, wEnemyMonStatus
jr z, .active_enemy jr z, .active_enemy
ld a, MON_STATUS ld a, MON_STATUS
call GetBeatupMonLocation call GetBeatupMonLocation
.active_enemy .active_enemy
@@ -157,11 +165,13 @@ BattleCommand_BeatUp: ; 35461
.finish_beatup .finish_beatup
ld hl, BeatUpAttackText ld hl, BeatUpAttackText
call StdBattleTextBox call StdBattleTextBox
ld a, [wBattleMonSpecies] ld a, [wBattleMonSpecies]
ld [wCurSpecies], a ld [wCurSpecies], a
call GetBaseData call GetBaseData
ld a, [wBaseDefense] ld a, [wBaseDefense]
ld c, a ld c, a
push bc push bc
ld a, MON_SPECIES ld a, MON_SPECIES
call GetBeatupMonLocation call GetBeatupMonLocation
@@ -171,12 +181,14 @@ BattleCommand_BeatUp: ; 35461
ld a, [wBaseAttack] ld a, [wBaseAttack]
pop bc pop bc
ld b, a ld b, a
push bc push bc
ld a, MON_LEVEL ld a, MON_LEVEL
call GetBeatupMonLocation call GetBeatupMonLocation
ld a, [hl] ld a, [hl]
ld e, a ld e, a
pop bc pop bc
ld a, [wEnemyMoveStructPower] ld a, [wEnemyMoveStructPower]
ld d, a ld d, a
ret ret