pokegold-spaceworld/engine/math/bcd.asm
Narishma-gb e88fe24e15
Use the same Makefile build system as Gen 1+2 repos (#163)
This uses catch-all files like main.asm to reduce the total quantity and size of
build objects (from 1.1 GB to 70 MB).

---------

Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com>
2026-07-05 15:36:09 -04:00

51 lines
398 B
NASM

AddBCD:
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:
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