make circle draw not write over program mem.

This commit is contained in:
hugova 2025-08-01 19:24:40 +02:00
parent ad961e2d23
commit eff01e5411
4 changed files with 22 additions and 9 deletions

View file

@ -45,6 +45,8 @@ draw_upper_px_in_circle:
SBC radius SBC radius
STA Y_pos STA Y_pos
BCC outside_screen_error
JSR pixel_calc JSR pixel_calc
;; A = byte_to_paint (small_X_offset) ;; A = byte_to_paint (small_X_offset)
;; Y =small_y_offset ;; Y =small_y_offset
@ -93,6 +95,11 @@ draw_lower_px_in_circle: ;similar as above
ADC radius ADC radius
STA Y_pos STA Y_pos
;; Stop this if overflow or if outside screen.
BCS outside_screen_error
CMP #$C8 ;; Screen width
BCS outside_screen_error
JSR pixel_calc JSR pixel_calc
;; A = byte_to_paint (small_X_offset) ;; A = byte_to_paint (small_X_offset)
;; Y =small_y_offset ;; Y =small_y_offset
@ -132,8 +139,13 @@ draw_right_px_in_circle:; similar as above
STY Y_qaa STY Y_qaa
JMP outside_screen_error_end
outside_screen_error:
RTS
outside_screen_error_end:
LDX #$08 ; X=8 always expected inside the loop LDX #$08 ; X=8 always expected inside the loop
SEC SEC
while_x_bigger_then_y: ; C=1 here because above and branching logic while_x_bigger_then_y: ; C=1 here because above and branching logic
draw_pixels: draw_pixels:
draw_qaa: draw_qaa:
@ -286,4 +298,5 @@ endif:
jmp while_x_bigger_then_y jmp while_x_bigger_then_y
end: end:
RTS RTS
.endproc .endproc

View file

@ -2,7 +2,7 @@
.include "circle.inc" .include "circle.inc"
;; Set initial parameters for circle ;; Set initial parameters for circle
LDA #$50 LDA #$00
STA $AD STA $AD
LDA #$50 LDA #$50
STA $AE STA $AE
@ -38,6 +38,6 @@ loop:
;; end loop when x_pos = $70 ;; end loop when x_pos = $70
LDA $AD LDA $AD
CMP #$70 CMP #$ff
BNE loop BNE loop
.endscope .endscope

View file

@ -37,6 +37,6 @@ loop:
;; end loop if radius = $aa ;; end loop if radius = $aa
LDA $AD LDA $AD
CMP #$20 CMP #$ff
BNE loop BNE loop
.endscope .endscope

View file

@ -15,12 +15,12 @@
mainsetup: mainsetup:
;; Note that arithmetic tests may use upp all the memory and the compiler don't complain! ;; Note that arithmetic tests may use upp all the memory and the compiler don't complain!
;.include "routines/arithmatic/mult_test.s" ;.include "routines/arithmatic/mult_test.s"
.include "routines/arithmatic/div_test.s" ;.include "routines/arithmatic/div_test.s"
;.include "routines/arithmatic/div_test_zero.s" ;.include "routines/arithmatic/div_test_zero.s"
;.include "routines/circle/circle_test.s" .include "routines/circle/circle_test.s"
;.include "routines/circle/circle_test_size.s" .include "routines/circle/circle_test_size.s"
;.include "routines/circle/circle_test_position.s" .include "routines/circle/circle_test_position.s"
;.include "routines/line/line_test.s" ;.include "routines/line/line_test.s"
;.include "routines/line/line_test_extensive.s" ;.include "routines/line/line_test_extensive.s"
;.include "routines/text/char_draw_test.s" ;.include "routines/text/char_draw_test.s"
@ -33,10 +33,10 @@ exit:
JMP exit JMP exit
.include "public.inc" .include "public.inc"
;.include "routines/line/line.s" ;.include "routines/line/line.s"
;.include "routines/circle/circle.s" .include "routines/circle/circle.s"
;.include "routines/triangle/triangle.s" ;.include "routines/triangle/triangle.s"
.include "routines/pixel/pixel_draw.s" .include "routines/pixel/pixel_draw.s"
;.include "routines/pixel/pixel_calc.s" .include "routines/pixel/pixel_calc.s"
;.include "routines/pixel/misc_pixel.s" ;.include "routines/pixel/misc_pixel.s"
;.include "routines/text/char_draw.s" ;.include "routines/text/char_draw.s"
.include "routines/memory/memset.s" .include "routines/memory/memset.s"