From 87f0b6d5263950a08f622713ed4c522e953d9515 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 4 Apr 2021 11:20:42 +0200 Subject: [PATCH] Improved division waiting --- src/test/kc/examples/mega65/linedrawing.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/test/kc/examples/mega65/linedrawing.c b/src/test/kc/examples/mega65/linedrawing.c index 3960313b0..cd416d7a9 100644 --- a/src/test/kc/examples/mega65/linedrawing.c +++ b/src/test/kc/examples/mega65/linedrawing.c @@ -88,13 +88,8 @@ unsigned int m65_div16u_frac(unsigned int dividend, unsigned int divisor) { *MATH_MULTINB_INT0 = (signed int)divisor; *MATH_MULTINA_INT1 = 0; *MATH_MULTINB_INT1 = 0; - // Wait 16 cycles (only neeeded for some values) - asm { - lda MATH_DIVOUT_FRAC_INT1 @nooptimize - lda MATH_DIVOUT_FRAC_INT1 @nooptimize - lda MATH_DIVOUT_FRAC_INT1 @nooptimize - lda MATH_DIVOUT_FRAC_INT1 @nooptimize - } + // Wait for the result to be ready + while(*MATH_BUSY) ; // Return the most significant bytes of the fractional part of the division result return (unsigned int)*MATH_DIVOUT_FRAC_INT1; }