From 296402bd31946455c500fd524b141c18cf73cf8c Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 25 Aug 2018 22:58:26 -0400 Subject: [PATCH] _Divide results go in hQuotient and hRemainder, not in hDividend and hDivisor Note that the result quotient is four bytes, but hQuotient is a three-byte buffer. This is because no Divide caller ever needed a four-byte quotient, so the buffer didn't include the high byte. --- engine/math/math.asm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/math/math.asm b/engine/math/math.asm index 18aa042ed..f06b5488a 100644 --- a/engine/math/math.asm +++ b/engine/math/math.asm @@ -172,18 +172,18 @@ _Divide:: .done ldh a, [hDividend + 1] - ldh [hDivisor], a + ldh [hRemainder], a ldh a, [hMathBuffer + 4] - ldh [hDividend + 3], a + ldh [hQuotient + 2], a ldh a, [hMathBuffer + 3] - ldh [hDividend + 2], a + ldh [hQuotient + 1], a ldh a, [hMathBuffer + 2] - ldh [hDividend + 1], a + ldh [hQuotient + 0], a ldh a, [hMathBuffer + 1] - ldh [hDividend + 0], a + ldh [hQuotient - 1], a ret