From 00071d53d5039d73f6bae8fa3b1b9dbe48e183f8 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 6 Dec 2020 00:33:32 +0100 Subject: [PATCH] optimized disc (filled circle) drawing on c64, fixed off by 1 disc width in cx16 version --- compiler/res/prog8lib/c64/graphics.p8 | 16 ++++++---------- compiler/res/prog8lib/cx16/graphics.p8 | 8 ++++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/compiler/res/prog8lib/c64/graphics.p8 b/compiler/res/prog8lib/c64/graphics.p8 index 5c8f9bda2..30331abf5 100644 --- a/compiler/res/prog8lib/c64/graphics.p8 +++ b/compiler/res/prog8lib/c64/graphics.p8 @@ -158,21 +158,17 @@ graphics { ubyte ycenter_plus_xx = ycenter + xx ubyte ycenter_min_xx = ycenter - xx - for internal_plotx in xcenter to xcenter+xx { + internal_plotx = xcenter-xx + repeat xx*2+1 { internal_plot(ycenter_plus_yy) internal_plot(ycenter_min_yy) + internal_plotx++ } - for internal_plotx in xcenter-xx to xcenter-1 { - internal_plot(ycenter_plus_yy) - internal_plot(ycenter_min_yy) - } - for internal_plotx in xcenter to xcenter+yy { - internal_plot(ycenter_plus_xx) - internal_plot(ycenter_min_xx) - } - for internal_plotx in xcenter-yy to xcenter { + internal_plotx = xcenter-yy + repeat yy*2+1 { internal_plot(ycenter_plus_xx) internal_plot(ycenter_min_xx) + internal_plotx++ } yy++ if decisionOver2<=0 diff --git a/compiler/res/prog8lib/cx16/graphics.p8 b/compiler/res/prog8lib/cx16/graphics.p8 index 93c07ee0a..05f72e037 100644 --- a/compiler/res/prog8lib/cx16/graphics.p8 +++ b/compiler/res/prog8lib/cx16/graphics.p8 @@ -110,25 +110,25 @@ graphics { cx16.r0 = xcenter-xx cx16.r1 = ycenter_plus_yy cx16.FB_cursor_position() - repeat xx*2 + repeat xx*2+1 cx16.FB_set_pixel(1) cx16.r0 = xcenter-xx cx16.r1 = ycenter_min_yy cx16.FB_cursor_position() - repeat xx*2 + repeat xx*2+1 cx16.FB_set_pixel(1) cx16.r0 = xcenter-yy cx16.r1 = ycenter_plus_xx cx16.FB_cursor_position() - repeat yy*2 + repeat yy*2+1 cx16.FB_set_pixel(1) cx16.r0 = xcenter-yy cx16.r1 = ycenter_min_xx cx16.FB_cursor_position() - repeat yy*2 + repeat yy*2+1 cx16.FB_set_pixel(1) yy++