From 363e3907ff2f0d3784b5c5b5c55b13050503c278 Mon Sep 17 00:00:00 2001 From: hugova Date: Sat, 28 Jun 2025 21:05:25 +0200 Subject: [PATCH] Fix circle-code (wip) Now the test renders the forth quarter of a circle! --- wip-hugo/routines/circle/circle.s | 23 ++++++++++++----------- wip-hugo/routines/circle/circle_test.s | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/wip-hugo/routines/circle/circle.s b/wip-hugo/routines/circle/circle.s index b272ee3..b11f683 100644 --- a/wip-hugo/routines/circle/circle.s +++ b/wip-hugo/routines/circle/circle.s @@ -6,22 +6,23 @@ ;; https://schwarzers.com/algorithms/ - ;; X_pos = X_pos + r (hack, should fix later ( xpos == ypos is not always true)) - CLC - LDA X_pos - ADC radius + ;; X_pos is changed (fix this later) + LDA radius STA X_pos + LDA #$00 + STA Y_pos + ;; t1 = radius >> 4 LDA radius - LSR A - LSR A - LSR A - LSR A + LSR + LSR + LSR + LSR STA t1 while_x_bigger_then_y: - jsr pixel_draw + JSR pixel_draw INC Y_pos ; y++ @@ -32,7 +33,7 @@ while_x_bigger_then_y: STA t1 ;; t2 = t1 - x SEC - LDA t2 + LDA t1 SBC X_pos STA t2 ;; if t2 < 0 then skip to endif @@ -47,6 +48,6 @@ endif: LDA X_pos CMP Y_pos - BNE while_x_bigger_then_y + BCS while_x_bigger_then_y RTS .endproc diff --git a/wip-hugo/routines/circle/circle_test.s b/wip-hugo/routines/circle/circle_test.s index de42b01..bfe18aa 100644 --- a/wip-hugo/routines/circle/circle_test.s +++ b/wip-hugo/routines/circle/circle_test.s @@ -3,7 +3,7 @@ LDA #$50 STA X_pos STA Y_pos - LDA #$08 + LDA #$55 STA radius JSR circle .endscope