reduse zeropage usage of circle-draw

This commit is contained in:
hugova 2025-07-10 16:28:17 +02:00
parent 5e3eb78506
commit b868156138
2 changed files with 29 additions and 34 deletions

View file

@ -6,34 +6,29 @@
;; private args
t1 = $E0
t2 = $E1
X_rel = radius
Y_rel = $E2
Y_copy = $E3
temp_ = $ED
jmp_location_pointer_two = $E4 ;16bit value (uses E5)
jmp_location_pointer = $EE ;16 bit value (uses EF)
X_math = radius
Y_math = $E2
jmp_location_pointer_two = $E3 ;16-bit value (uses E4)
jmp_location_pointer = $E5 ;16-bit value (uses E6)
;; E8 - EA is used by pixel.inc
byte_to_paint_qaa = byte_to_paint
byte_to_paint_qcb = $EB
byte_to_paint_qca = $EC
; E8 - EA is used by pixel.inc
byte_to_paint_qdb = $CF
btp_mem_pos_center = $E6
btp_mem_pos_center_two = btp_mem_pos_center
byte_to_paint_qdb = $ED
btp_mem_pos_qaa = btp_mem_pos
btp_mem_pos_qcb = $D0 ; 16bit value (uses D1)
btp_mem_pos_qdb = $D2 ; 16bit value (uses D3)
btp_mem_pos_qda = $D4 ; 16bit value (uses D5)
;;mirrord
btp_mem_pos_qab = $D6
btp_mem_pos_qca = $D8
btp_mem_pos_qba = $DA
btp_mem_pos_qbb = $DC
btp_mem_pos_qab = $D6 ; 16bit value (uses D7)
btp_mem_pos_qca = $D8 ; 16bit value (uses D9)
btp_mem_pos_qba = $DA ; 16bit value (uses DB)
btp_mem_pos_qbb = $DC ; 16bit value (uses DD)
Y_qda = $DE
Y_qdb = $DF
Y_qbb = $CE
temp__ = $CD
Y_qaa = Y_copy
Y_qbb = $E7 ;; <-- we use E7 here!
Y_qaa = $C0
;;Reuse addresses, be carful here!
temp__ = Y_qaa
temp_ = Y_qda

View file

@ -35,10 +35,10 @@
STA jmp_location_pointer_two + 1
;; X_rel = radius (share the same address)
;;Y_rel =0
;; X_math = radius (share the same address)
;;Y_math =0
LDA #$00
STA Y_rel
STA Y_math
;; t1 = radius >> 4
LDA radius
@ -94,7 +94,7 @@ draw_left_px_in_circle: ;similar as above
LDA temp__
STA X_pos
draw_lower_px_in_circle: ;similar as above
CLC
;; C=0 becuase pixel draw!
LDA Y_pos
ADC radius
STA Y_pos
@ -174,13 +174,13 @@ draw_qab:
STA (btp_mem_pos_qab), Y
;; Y_rel and X_rel is the X and Y in the eye of the algorithm. Thsese are calculated seperatly from the pixel cordinates,
;; Y_math and X_math is the X and Y in the eye of the algorithm. Thsese are calculated seperatly from the pixel cordinates,
;; but are modified at the same time. This is becsuse the pixel cordinate system is complex (see pixel draw)
LDY #$07 ;; Y is expected to be 7 from this point on in the loop
change_Y:
INC Y_rel ; y++
INC Y_math ; y++
qaa_y:
DEC Y_qaa
BPL qaa_y_end
@ -222,11 +222,11 @@ qcb_x_end:
;;t1 += y
CLC
LDA t1
ADC Y_rel
ADC Y_math
STA t1
;; t2 = t1 - x
SEC
SBC X_rel
SBC X_math
STA t2
;; if t2 < 0 then skip to endif
;; we can skipp CMP #$00 because SBC above do the same
@ -234,7 +234,7 @@ qcb_x_end:
JMP (jmp_location_pointer_two)
if:
change_x:
DEC X_rel
DEC X_math
LDA t2
STA t1 ; t1 = t2
qaa_x:
@ -279,8 +279,8 @@ qbb_y_end:
endif:
;; repeat if X > Y
LDA X_rel
CMP Y_rel
LDA X_math
CMP Y_math
BCC end
JMP (jmp_location_pointer)
end: