From 380728a80a48674ce1dda941e15fd6428223510e Mon Sep 17 00:00:00 2001 From: hugova Date: Sun, 29 Jun 2025 02:04:08 +0200 Subject: [PATCH] add another part of the circle. now 1/4 circle done --- wip-hugo/routines/circle/circle.inc | 4 ++ wip-hugo/routines/circle/circle.s | 55 ++++++++++++++++++++++++++ wip-hugo/routines/circle/circle_test.s | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/wip-hugo/routines/circle/circle.inc b/wip-hugo/routines/circle/circle.inc index 855eead..09ad986 100644 --- a/wip-hugo/routines/circle/circle.inc +++ b/wip-hugo/routines/circle/circle.inc @@ -7,3 +7,7 @@ t2 = $E1 X_rel = radius Y_rel = $E3 + temp = $E4 + temp_ = $E7 + btp_mem_pos_center = $E5 ;; 16bit + btp_mem_pos_inv = $EE ;; 16bit diff --git a/wip-hugo/routines/circle/circle.s b/wip-hugo/routines/circle/circle.s index b8fe78a..3dedbd7 100644 --- a/wip-hugo/routines/circle/circle.s +++ b/wip-hugo/routines/circle/circle.s @@ -19,16 +19,71 @@ LSR STA t1 + +draw_center_px_in_circle: + JSR pixel_draw + LDA btp_mem_pos + STA btp_mem_pos_center + LDA btp_mem_pos + 1 + STA btp_mem_pos_center + 1 + ;; btp_mem_pos_center_two = 2*btp_mem_pos_center | used later for calculating btp_mem_pos_inv + btp_mem_pos_center_two = btp_mem_pos_center + Mult_16 btp_mem_pos_center, btp_mem_pos_center + 1 + + +draw_right_px_in_circle: + CLC + LDA X_pos + ADC radius + STA X_pos ;; We only draw the first pixel using absolute position. ;; After that we use relative position. JSR pixel_draw ;; This sets byte_to_paint, btp_mem_pos and Y + while_x_bigger_then_y: +;STY temp +;LDY #$00 +draw_pixel: LDA byte_to_paint ;A byte containing a single 1. Coresponds to X position in the chunk. ORA (btp_mem_pos), Y STA (btp_mem_pos), Y +draw_pixel_inv: + SEC + LDA btp_mem_pos_center_two + SBC btp_mem_pos + STA btp_mem_pos_inv + LDA btp_mem_pos_center_two + 1 + SBC btp_mem_pos + 1 + STA btp_mem_pos_inv + 1 + +;; calculate the inverted y value Y = 7-Y +STY temp +LDA #$07 +SEC +SBC temp +TAY + +;; calculate byte_to_paint_inv (could be faster with lookup table) + LDA byte_to_paint + STA temp_ + LDA #%10000000 + jmp start_calc +calc: + LSR A +start_calc: + LSR temp_ +BCC calc + +; A = byte_to_paint_inv + ORA (btp_mem_pos_inv), Y + STA (btp_mem_pos_inv), Y + +;;Recover the Y value (we changed it because evrything is inverted) +ldy temp + increment_y_pos: INC Y_rel ; y++ INY diff --git a/wip-hugo/routines/circle/circle_test.s b/wip-hugo/routines/circle/circle_test.s index bfe18aa..b3ded49 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 #$55 + LDA #$35 STA radius JSR circle .endscope