From 484bafa8289ffc705679e2f55ea36c92e24bbc92 Mon Sep 17 00:00:00 2001 From: hugova Date: Sat, 28 Jun 2025 21:10:59 +0200 Subject: [PATCH] Fix quartercircle offset isse (before the circle had the offset (0,0) always!) --- wip-hugo/routines/circle/circle.inc | 6 ++++-- wip-hugo/routines/circle/circle.s | 18 +++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/wip-hugo/routines/circle/circle.inc b/wip-hugo/routines/circle/circle.inc index 598af41..855eead 100644 --- a/wip-hugo/routines/circle/circle.inc +++ b/wip-hugo/routines/circle/circle.inc @@ -3,5 +3,7 @@ ;; public args radius = ARGVEC + 2 ;; private args - t1 = $E0 - t2 = $E1 + t1 = $E0 + t2 = $E1 + X_rel = radius + Y_rel = $E3 diff --git a/wip-hugo/routines/circle/circle.s b/wip-hugo/routines/circle/circle.s index b11f683..2da3b60 100644 --- a/wip-hugo/routines/circle/circle.s +++ b/wip-hugo/routines/circle/circle.s @@ -5,13 +5,11 @@ ;; We use the algorithm jerkos method ;; https://schwarzers.com/algorithms/ + ;; X_rel = radius (share the same address) - ;; X_pos is changed (fix this later) - LDA radius - STA X_pos - + ;;Y_rel =0 LDA #$00 - STA Y_pos + STA Y_rel ;; t1 = radius >> 4 LDA radius @@ -25,28 +23,30 @@ while_x_bigger_then_y: JSR pixel_draw INC Y_pos ; y++ + INC Y_rel ;;t1 += y CLC LDA t1 - ADC Y_pos + ADC Y_rel STA t1 ;; t2 = t1 - x SEC LDA t1 - SBC X_pos + SBC X_rel STA t2 ;; if t2 < 0 then skip to endif CMP #$00 BMI endif if: DEC X_pos ; x-- + DEC X_rel LDA t2 STA t1 ; t1 = t2 endif: ;; repeat if X > Y - LDA X_pos - CMP Y_pos + LDA X_rel + CMP Y_rel BCS while_x_bigger_then_y RTS