summaryrefslogtreecommitdiff
path: root/engine/hp_bar.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/hp_bar.asm')
-rwxr-xr-xengine/hp_bar.asm44
1 files changed, 23 insertions, 21 deletions
diff --git a/engine/hp_bar.asm b/engine/hp_bar.asm
index 333b0b90..221bd7a9 100755
--- a/engine/hp_bar.asm
+++ b/engine/hp_bar.asm
@@ -1,9 +1,9 @@
-HPBarLength: ; f9dc (3:79dc)
+HPBarLength:
call GetPredefRegisters
; calculates bc * 48 / de, the number of pixels the HP bar has
; the result is always at least 1
-GetHPBarLength: ; f9df (3:79df)
+GetHPBarLength:
push hl
xor a
ld hl, H_MULTIPLICAND
@@ -45,7 +45,7 @@ GetHPBarLength: ; f9df (3:79df)
ret
; predef $48
-UpdateHPBar: ; fa1d (3:7a1d)
+UpdateHPBar:
UpdateHPBar2:
push hl
ld hl, wHPBarOldHP
@@ -87,6 +87,7 @@ UpdateHPBar2:
call UpdateHPBar_CompareNewHPToOldHP
jr z, .animateHPBarDone
jr nc, .HPIncrease
+; HP decrease
dec bc ; subtract 1 HP
ld a, c
ld [wHPBarNewHP], a
@@ -95,7 +96,7 @@ UpdateHPBar2:
call UpdateHPBar_CalcOldNewHPBarPixels
ld a, e
sub d ; calc pixel difference
- jr .asm_fa7e
+ jr .ok
.HPIncrease
inc bc ; add 1 HP
ld a, c
@@ -105,7 +106,7 @@ UpdateHPBar2:
call UpdateHPBar_CalcOldNewHPBarPixels
ld a, d
sub e ; calc pixel difference
-.asm_fa7e
+.ok
call UpdateHPBar_PrintHPNumber
and a
jr z, .noPixelDifference
@@ -136,14 +137,14 @@ UpdateHPBar2:
; animates the HP bar going up or down for (a) ticks (two waiting frames each)
; stops prematurely if bar is filled up
; e: current health (in pixels) to start with
-UpdateHPBar_AnimateHPBar: ; fab1 (3:7ab1)
+UpdateHPBar_AnimateHPBar:
push hl
.barAnimationLoop
push af
push de
ld d, $6
call DrawHPBar
- ld c, $2
+ ld c, 2
call DelayFrames
pop de
ld a, [wHPBarDelta] ; +1 or -1
@@ -162,7 +163,7 @@ UpdateHPBar_AnimateHPBar: ; fab1 (3:7ab1)
ret
; compares old HP and new HP and sets c and z flags accordingly
-UpdateHPBar_CompareNewHPToOldHP: ; fad1 (3:7ad1)
+UpdateHPBar_CompareNewHPToOldHP:
ld a, d
sub b
ret nz
@@ -171,7 +172,7 @@ UpdateHPBar_CompareNewHPToOldHP: ; fad1 (3:7ad1)
ret
; calcs HP difference between bc and de (into de)
-UpdateHPBar_CalcHPDifference: ; fad7 (3:7ad7)
+UpdateHPBar_CalcHPDifference:
ld a, d
sub b
jr c, .oldHPGreater
@@ -200,38 +201,39 @@ UpdateHPBar_CalcHPDifference: ; fad7 (3:7ad7)
ld de, $0
ret
-UpdateHPBar_PrintHPNumber: ; faf5 (3:7af5)
+UpdateHPBar_PrintHPNumber:
push af
push de
ld a, [wHPBarType]
and a
- jr z, .asm_fb2d
+ jr z, .done ; don't print number in enemy HUD
+; convert from little-endian to big-endian for PrintNumber
ld a, [wHPBarOldHP]
- ld [wcef1], a
- ld a, [wHPBarOldHP+1]
- ld [wcef0], a
+ ld [wHPBarTempHP + 1], a
+ ld a, [wHPBarOldHP + 1]
+ ld [wHPBarTempHP], a
push hl
ld a, [hFlags_0xFFF6]
bit 0, a
jr z, .asm_fb15
ld de, $9
- jr .asm_fb18
+ jr .next
.asm_fb15
ld de, $15
-.asm_fb18
+.next
add hl, de
push hl
- ld a, $7f
+ ld a, " "
ld [hli], a
ld [hli], a
ld [hli], a
pop hl
- ld de, wcef0
- ld bc, $203
+ ld de, wHPBarTempHP
+ lb bc, 2, 3
call PrintNumber
call DelayFrame
pop hl
-.asm_fb2d
+.done
pop de
pop af
ret
@@ -239,7 +241,7 @@ UpdateHPBar_PrintHPNumber: ; faf5 (3:7af5)
; calcs number of HP bar pixels for old and new HP value
; d: new pixels
; e: old pixels
-UpdateHPBar_CalcOldNewHPBarPixels: ; fb30 (3:7b30)
+UpdateHPBar_CalcOldNewHPBarPixels:
push hl
ld hl, wHPBarMaxHP
ld a, [hli] ; max HP into de