diff options
author | Pokeglitch <pokeglitchx@gmail.com> | 2018-06-16 10:24:17 -0400 |
---|---|---|
committer | Pokeglitch <pokeglitchx@gmail.com> | 2018-06-16 10:24:17 -0400 |
commit | f11e353fbb7d08f33ac58b49f586f65fb800cfba (patch) | |
tree | 75d14b6d688b54a22d3da14461506fcea1289f85 /engine/bcd.asm | |
parent | 758398b87df2b172e85492efad9272d5e7965ac9 (diff) |
More Bank 3 routines
Diffstat (limited to 'engine/bcd.asm')
-rwxr-xr-x | engine/bcd.asm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/engine/bcd.asm b/engine/bcd.asm new file mode 100755 index 0000000..53f0b20 --- /dev/null +++ b/engine/bcd.asm @@ -0,0 +1,55 @@ +INCLUDE "constants.asm"
+
+SECTION "BCD", ROMX[$4de3], BANK[$03]
+
+AddBCD: ; 03:4de3
+ and a
+ ld b, c
+.add
+ ld a, [de]
+ adc [hl]
+ daa
+ ld [de], a
+ dec de
+ dec hl
+ dec c
+ jr nz, .add
+ jr nc, .done
+
+ ld a, $99
+ inc de
+
+.fill
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .fill
+
+.done
+ ret
+
+
+SubBCD: ; 03:4df9
+ and a
+ ld b, c
+.sub
+ ld a, [de]
+ sbc [hl]
+ daa
+ ld [de], a
+ dec de
+ dec hl
+ dec c
+ jr nz, .sub
+ jr nc, .done
+ ld a, 0
+ inc de
+
+.fill
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .fill
+ scf
+.done
+ ret
\ No newline at end of file |