reduse zeropage usage of circle-draw
This commit is contained in:
parent
5e3eb78506
commit
b868156138
2 changed files with 29 additions and 34 deletions
|
@ -6,34 +6,29 @@
|
||||||
;; private args
|
;; private args
|
||||||
t1 = $E0
|
t1 = $E0
|
||||||
t2 = $E1
|
t2 = $E1
|
||||||
X_rel = radius
|
X_math = radius
|
||||||
Y_rel = $E2
|
Y_math = $E2
|
||||||
Y_copy = $E3
|
jmp_location_pointer_two = $E3 ;16-bit value (uses E4)
|
||||||
temp_ = $ED
|
jmp_location_pointer = $E5 ;16-bit value (uses E6)
|
||||||
jmp_location_pointer_two = $E4 ;16bit value (uses E5)
|
;; E8 - EA is used by pixel.inc
|
||||||
jmp_location_pointer = $EE ;16 bit value (uses EF)
|
|
||||||
byte_to_paint_qaa = byte_to_paint
|
byte_to_paint_qaa = byte_to_paint
|
||||||
byte_to_paint_qcb = $EB
|
byte_to_paint_qcb = $EB
|
||||||
byte_to_paint_qca = $EC
|
byte_to_paint_qca = $EC
|
||||||
|
byte_to_paint_qdb = $ED
|
||||||
; 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
|
|
||||||
|
|
||||||
btp_mem_pos_qaa = btp_mem_pos
|
btp_mem_pos_qaa = btp_mem_pos
|
||||||
btp_mem_pos_qcb = $D0 ; 16bit value (uses D1)
|
btp_mem_pos_qcb = $D0 ; 16bit value (uses D1)
|
||||||
btp_mem_pos_qdb = $D2 ;16bit value (uses D3)
|
btp_mem_pos_qdb = $D2 ; 16bit value (uses D3)
|
||||||
btp_mem_pos_qda =$D4 ; 16bit value (uses D5)
|
btp_mem_pos_qda = $D4 ; 16bit value (uses D5)
|
||||||
|
btp_mem_pos_qab = $D6 ; 16bit value (uses D7)
|
||||||
;;mirrord
|
btp_mem_pos_qca = $D8 ; 16bit value (uses D9)
|
||||||
btp_mem_pos_qab = $D6
|
btp_mem_pos_qba = $DA ; 16bit value (uses DB)
|
||||||
btp_mem_pos_qca = $D8
|
btp_mem_pos_qbb = $DC ; 16bit value (uses DD)
|
||||||
btp_mem_pos_qba = $DA
|
|
||||||
btp_mem_pos_qbb = $DC
|
|
||||||
|
|
||||||
Y_qda = $DE
|
Y_qda = $DE
|
||||||
Y_qdb = $DF
|
Y_qdb = $DF
|
||||||
Y_qbb = $CE
|
Y_qbb = $E7 ;; <-- we use E7 here!
|
||||||
temp__ = $CD
|
Y_qaa = $C0
|
||||||
Y_qaa = Y_copy
|
;;Reuse addresses, be carful here!
|
||||||
|
temp__ = Y_qaa
|
||||||
|
temp_ = Y_qda
|
||||||
|
|
|
@ -35,10 +35,10 @@
|
||||||
STA jmp_location_pointer_two + 1
|
STA jmp_location_pointer_two + 1
|
||||||
|
|
||||||
|
|
||||||
;; X_rel = radius (share the same address)
|
;; X_math = radius (share the same address)
|
||||||
;;Y_rel =0
|
;;Y_math =0
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA Y_rel
|
STA Y_math
|
||||||
|
|
||||||
;; t1 = radius >> 4
|
;; t1 = radius >> 4
|
||||||
LDA radius
|
LDA radius
|
||||||
|
@ -94,7 +94,7 @@ draw_left_px_in_circle: ;similar as above
|
||||||
LDA temp__
|
LDA temp__
|
||||||
STA X_pos
|
STA X_pos
|
||||||
draw_lower_px_in_circle: ;similar as above
|
draw_lower_px_in_circle: ;similar as above
|
||||||
CLC
|
;; C=0 becuase pixel draw!
|
||||||
LDA Y_pos
|
LDA Y_pos
|
||||||
ADC radius
|
ADC radius
|
||||||
STA Y_pos
|
STA Y_pos
|
||||||
|
@ -174,13 +174,13 @@ draw_qab:
|
||||||
STA (btp_mem_pos_qab), Y
|
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)
|
;; 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
|
LDY #$07 ;; Y is expected to be 7 from this point on in the loop
|
||||||
|
|
||||||
change_Y:
|
change_Y:
|
||||||
INC Y_rel ; y++
|
INC Y_math ; y++
|
||||||
qaa_y:
|
qaa_y:
|
||||||
DEC Y_qaa
|
DEC Y_qaa
|
||||||
BPL qaa_y_end
|
BPL qaa_y_end
|
||||||
|
@ -222,11 +222,11 @@ qcb_x_end:
|
||||||
;;t1 += y
|
;;t1 += y
|
||||||
CLC
|
CLC
|
||||||
LDA t1
|
LDA t1
|
||||||
ADC Y_rel
|
ADC Y_math
|
||||||
STA t1
|
STA t1
|
||||||
;; t2 = t1 - x
|
;; t2 = t1 - x
|
||||||
SEC
|
SEC
|
||||||
SBC X_rel
|
SBC X_math
|
||||||
STA t2
|
STA t2
|
||||||
;; if t2 < 0 then skip to endif
|
;; if t2 < 0 then skip to endif
|
||||||
;; we can skipp CMP #$00 because SBC above do the same
|
;; we can skipp CMP #$00 because SBC above do the same
|
||||||
|
@ -234,7 +234,7 @@ qcb_x_end:
|
||||||
JMP (jmp_location_pointer_two)
|
JMP (jmp_location_pointer_two)
|
||||||
if:
|
if:
|
||||||
change_x:
|
change_x:
|
||||||
DEC X_rel
|
DEC X_math
|
||||||
LDA t2
|
LDA t2
|
||||||
STA t1 ; t1 = t2
|
STA t1 ; t1 = t2
|
||||||
qaa_x:
|
qaa_x:
|
||||||
|
@ -279,8 +279,8 @@ qbb_y_end:
|
||||||
|
|
||||||
endif:
|
endif:
|
||||||
;; repeat if X > Y
|
;; repeat if X > Y
|
||||||
LDA X_rel
|
LDA X_math
|
||||||
CMP Y_rel
|
CMP Y_math
|
||||||
BCC end
|
BCC end
|
||||||
JMP (jmp_location_pointer)
|
JMP (jmp_location_pointer)
|
||||||
end:
|
end:
|
||||||
|
|
Loading…
Add table
Reference in a new issue