diff options
author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2020-11-05 23:50:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-05 23:50:03 -0500 |
commit | d3f13528754b985e892385dbd88c3c9a95681f1b (patch) | |
tree | 4a18885606996ff59bb714afb5db9a548e2f94a7 /engine/math/bcd.asm | |
parent | abaf9fee7c73e708ef8c3e7a1ed710bfc9ec6f6e (diff) | |
parent | e16dec874a239c162680b169391d3c0c7ee1fc70 (diff) |
Merge pull request #301 from Rangi42/master
Sync home and macro code with pokeyellow
Diffstat (limited to 'engine/math/bcd.asm')
-rw-r--r-- | engine/math/bcd.asm | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/engine/math/bcd.asm b/engine/math/bcd.asm index 1e5aedc9..5747a684 100644 --- a/engine/math/bcd.asm +++ b/engine/math/bcd.asm @@ -1,6 +1,9 @@ +; divide hMoney by hDivideBCDDivisor +; return output in hDivideBCDQuotient (same as hDivideBCDDivisor) +; used only to halve player money upon losing a fight DivideBCDPredef:: DivideBCDPredef2:: -DivideBCDPredef3:: +DivideBCDPredef3:: ; only used function DivideBCDPredef4:: call GetPredefRegisters @@ -10,7 +13,7 @@ DivideBCD:: ldh [hDivideBCDBuffer+1], a ldh [hDivideBCDBuffer+2], a ld d, $1 -.mulBy10Loop +.mulBy10Loop ; multiply the divisor by 10 until the leading digit is nonzero ; to set up the standard long division algorithm ldh a, [hDivideBCDDivisor] @@ -40,6 +43,7 @@ DivideBCD:: and $f0 ldh [hDivideBCDDivisor+2], a jr .mulBy10Loop + .next push de push de @@ -104,7 +108,7 @@ DivideBCD:: ldh a, [hDivideBCDBuffer+2] ldh [hDivideBCDQuotient+2], a pop de - ld a, $6 + ld a, $6 sub d and a ret z @@ -151,8 +155,8 @@ DivideBCD_getNextDigit: pop bc ret c inc b - ld de, hMoney+2 ; since SubBCD works starting from the least significant digit - ld hl, hDivideBCDDivisor+2 + ld de, hMoney + 2 ; since SubBCD works starting from the least significant digit + ld hl, hDivideBCDDivisor + 2 push bc call SubBCD pop bc |