summaryrefslogtreecommitdiff
path: root/src/home/damage.asm
diff options
context:
space:
mode:
Diffstat (limited to 'src/home/damage.asm')
-rw-r--r--src/home/damage.asm27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/home/damage.asm b/src/home/damage.asm
new file mode 100644
index 0000000..996ea5e
--- /dev/null
+++ b/src/home/damage.asm
@@ -0,0 +1,27 @@
+; [wDamage] += a
+AddToDamage:
+ push hl
+ ld hl, wDamage
+ add [hl]
+ ld [hli], a
+ ld a, 0
+ adc [hl]
+ ld [hl], a
+ pop hl
+ ret
+
+; [wDamage] -= a
+SubtractFromDamage:
+ push de
+ push hl
+ ld e, a
+ ld hl, wDamage
+ ld a, [hl]
+ sub e
+ ld [hli], a
+ ld a, [hl]
+ sbc 0
+ ld [hl], a
+ pop hl
+ pop de
+ ret