From 7009e162356ce66f6330c4d3c1b3e187d1a47c32 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 22 Jan 2023 13:56:19 -0800 Subject: [PATCH] fix range checks --- mandel.s | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mandel.s b/mandel.s index d5b62e5..a24f982 100644 --- a/mandel.s +++ b/mandel.s @@ -434,15 +434,15 @@ loop: rts keep_going: - .macro quick_exit arg + .macro quick_exit arg, max .local keep_going .local keep_going2 lda arg + 1 - cmp #(4 << 4) + cmp #((max) << 4) bmi keep_going rts keep_going: - cmp #(256 - (4 << 4)) + cmp #(256 - ((max) << 4)) bpl keep_going2 rts keep_going2: @@ -452,28 +452,25 @@ keep_going: ; zx = zx_2 - zy_2 + cx sub16 zx, zx_2, zy_2 add16 zx, zx, cx - quick_exit zx + quick_exit zx, 2 ; zy = zx_zy + zx_zy + cy add16 zy, zx_zy, zx_zy add16 zy, zy, cy - quick_exit zy + quick_exit zy, 2 ; zx_2 = zx * zx imul16_round zx_2, zx, zx, 4 - quick_exit zx_2 ; zy_2 = zy * zy imul16_round zy_2, zy, zy, 4 - quick_exit zy_2 ; zx_zy = zx * zy imul16_round zx_zy, zx, zy, 4 - quick_exit zx_zy ; dist = zx_2 + zy_2 add16 dist, zx_2, zy_2 - quick_exit dist + quick_exit dist, 4 ; if may be in the lake, look for looping output with a small buffer ; as an optimization vs running to max iters