use unsafe flag in macros to make circle draw faster
This commit is contained in:
parent
bdca0cd82a
commit
ba2db967c4
2 changed files with 55 additions and 59 deletions
|
@ -26,15 +26,16 @@ draw_center_px_in_circle:
|
||||||
STA btp_mem_pos_center
|
STA btp_mem_pos_center
|
||||||
LDA btp_mem_pos + 1
|
LDA btp_mem_pos + 1
|
||||||
STA btp_mem_pos_center + 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 = 2*btp_mem_pos_center | used later for calculating btp_mem_pos_inv
|
||||||
Mult_16 btp_mem_pos_center, btp_mem_pos_center + 1
|
Mult_16 btp_mem_pos_center, btp_mem_pos_center + 1
|
||||||
;; fix offset of 8 bytes, idk why this is needed
|
;; fix offset of 8 bytes, idk why this is needed
|
||||||
Sub_16 btp_mem_pos_center, btp_mem_pos_center + 1, #$40, #$01 ;-320
|
Sub_16 btp_mem_pos_center, btp_mem_pos_center + 1, #$40, #$01 ;-320
|
||||||
|
|
||||||
draw_lower_px_in_circle:
|
draw_lower_px_in_circle:
|
||||||
|
CLC
|
||||||
LDA Y_pos
|
LDA Y_pos
|
||||||
STA temp
|
STA temp
|
||||||
CLC
|
|
||||||
ADC radius
|
ADC radius
|
||||||
STA Y_pos
|
STA Y_pos
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ draw_lower_px_in_circle:
|
||||||
LDA temp
|
LDA temp
|
||||||
STA Y_pos
|
STA Y_pos
|
||||||
draw_right_px_in_circle:
|
draw_right_px_in_circle:
|
||||||
;; C = 0, because Mult_16
|
CLC
|
||||||
LDA X_pos
|
LDA X_pos
|
||||||
ADC radius
|
ADC radius
|
||||||
STA X_pos
|
STA X_pos
|
||||||
|
@ -70,22 +71,19 @@ draw_right_px_in_circle:
|
||||||
;; fix offset of 8 bytes, idk why this is needed
|
;; fix offset of 8 bytes, idk why this is needed
|
||||||
Sub_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$40, #$01 ;-320
|
Sub_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$40, #$01 ;-320
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SEC ;; circle_help expect this
|
|
||||||
while_x_bigger_then_y:
|
while_x_bigger_then_y:
|
||||||
;;Draw pixels and does the ypos incrementation logic
|
;;Draw pixels and does the ypos incrementation logic
|
||||||
|
;; WARNING expects C=1 before and C =0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
JSR circle_help
|
JSR circle_help
|
||||||
|
|
||||||
|
|
||||||
;;t1 += y
|
;;t1 += y
|
||||||
CLC
|
; C==0 from circle_help
|
||||||
LDA t1
|
LDA t1
|
||||||
ADC Y_rel
|
ADC Y_rel
|
||||||
STA t1
|
STA t1
|
||||||
;; t2 = t1 - x
|
;; t2 = t1 - x
|
||||||
SEC
|
SEC
|
||||||
LDA t1
|
|
||||||
SBC X_rel
|
SBC X_rel
|
||||||
STA t2
|
STA t2
|
||||||
;; if t2 < 0 then skip to endif
|
;; if t2 < 0 then skip to endif
|
||||||
|
@ -100,18 +98,18 @@ move_8px_left:
|
||||||
;; Next chunk is 8 addresses away. Look in pixel_draw for more detail.
|
;; Next chunk is 8 addresses away. Look in pixel_draw for more detail.
|
||||||
;; -8.
|
;; -8.
|
||||||
;; C = 1 because branching
|
;; C = 1 because branching
|
||||||
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$08, #$00, !
|
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$08, #$00, ! ;+8
|
||||||
|
|
||||||
;; Y is inverted
|
;; Y is inverted
|
||||||
Sub_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$08, #$00, !
|
Sub_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$08, #$00, ! ;+8
|
||||||
;; X and Y has swoped
|
;; X and Y has swoped
|
||||||
Sub_16 btp_mem_pos_qcb, btp_mem_pos_qcb + 1, #$40, #$01 ;-320
|
Sub_16 btp_mem_pos_qcb, btp_mem_pos_qcb + 1, #$40, #$01, ! ;-320
|
||||||
;; X and Y has swoped and Y has inverted
|
;; X and Y has swoped and Y has inverted
|
||||||
Sub_16 btp_mem_pos_qdb, btp_mem_pos_qdb +1, #$40, #$01 ;+320
|
Sub_16 btp_mem_pos_qdb, btp_mem_pos_qdb +1, #$40, #$01, ! ;+320
|
||||||
|
|
||||||
;; Restores byte to paint
|
;; Restores byte to paint
|
||||||
LDA #%00000001
|
LDX #%00000001
|
||||||
STA byte_to_paint
|
STX byte_to_paint
|
||||||
decrement_x_pos_end:
|
decrement_x_pos_end:
|
||||||
LDA t2
|
LDA t2
|
||||||
STA t1 ; t1 = t2
|
STA t1 ; t1 = t2
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
.proc circle_help ; This is because jmp cant jump that long!
|
.proc circle_help ; This is because jmp cant jump that long!
|
||||||
.include "circle.inc"
|
.include "circle.inc"
|
||||||
|
|
||||||
|
;; WARNING expects C=1 before and C =0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
|
||||||
;;We have named the parts of the circle as such.
|
;;We have named the parts of the circle as such.
|
||||||
;; * |
|
;; * |
|
||||||
|
@ -16,10 +18,11 @@
|
||||||
;; The q stands for quarter, whe have 4 quarter, and each quarter is split into 2
|
;; The q stands for quarter, whe have 4 quarter, and each quarter is split into 2
|
||||||
|
|
||||||
;; We first calculate all btp_mem_pos for the inverted half quarters!
|
;; We first calculate all btp_mem_pos for the inverted half quarters!
|
||||||
calculate_inverted_bmp:
|
calculate:
|
||||||
;; qab = 2*center - qcb
|
;; qab = 2*center - qcb
|
||||||
;; qca = 2*center - qaa
|
;; qca = 2*center - qaa
|
||||||
;; qbq = 2*center - qda
|
;; qbq = 2*center - qda
|
||||||
|
;; a = 2*center - b comes from that a = center -(b-center)
|
||||||
|
|
||||||
LDA btp_mem_pos_center_two
|
LDA btp_mem_pos_center_two
|
||||||
SBC btp_mem_pos_qcb
|
SBC btp_mem_pos_qcb
|
||||||
|
@ -41,7 +44,9 @@ STA btp_mem_pos_qba
|
||||||
LDA btp_mem_pos_center_two + 1
|
LDA btp_mem_pos_center_two + 1
|
||||||
SBC btp_mem_pos_qda + 1
|
SBC btp_mem_pos_qda + 1
|
||||||
STA btp_mem_pos_qba + 1
|
STA btp_mem_pos_qba + 1
|
||||||
|
end_calculation:
|
||||||
|
|
||||||
|
;; Lets draw all half-quatrons of the circle. This draws only 8 pixels per iteration.
|
||||||
|
|
||||||
draw_qaa:
|
draw_qaa:
|
||||||
LDA byte_to_paint ;A byte containing a single 1. Coresponds to X position in the chunk.
|
LDA byte_to_paint ;A byte containing a single 1. Coresponds to X position in the chunk.
|
||||||
|
@ -76,8 +81,6 @@ revert_byte_to_paint:
|
||||||
STA (btp_mem_pos_qcb), Y;
|
STA (btp_mem_pos_qcb), Y;
|
||||||
|
|
||||||
draw_qdb:; xy swaped and y is inverted.
|
draw_qdb:; xy swaped and y is inverted.
|
||||||
|
|
||||||
|
|
||||||
;;modify X
|
;;modify X
|
||||||
LDX temp
|
LDX temp
|
||||||
LDA binary_factor, X; (see END.s)
|
LDA binary_factor, X; (see END.s)
|
||||||
|
@ -90,8 +93,7 @@ draw_qdb:; xy swaped and y is inverted.
|
||||||
STA (btp_mem_pos_qdb), Y;
|
STA (btp_mem_pos_qdb), Y;
|
||||||
|
|
||||||
draw_qab:; xy swoped + mirroring
|
draw_qab:; xy swoped + mirroring
|
||||||
|
;SEC
|
||||||
SEC
|
|
||||||
LDA #$07
|
LDA #$07
|
||||||
SBC temp___
|
SBC temp___
|
||||||
TAY
|
TAY
|
||||||
|
@ -138,9 +140,6 @@ draw_qba: ;;mirror_technique
|
||||||
ORA (btp_mem_pos_qba), Y
|
ORA (btp_mem_pos_qba), Y
|
||||||
STA (btp_mem_pos_qba), Y
|
STA (btp_mem_pos_qba), Y
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
increment_y_pos:
|
increment_y_pos:
|
||||||
INC Y_rel ; y++
|
INC Y_rel ; y++
|
||||||
DEY
|
DEY
|
||||||
|
@ -151,13 +150,12 @@ move_8px_down:
|
||||||
; So we subtract #$0140
|
; So we subtract #$0140
|
||||||
; C = 1 because branching!
|
; C = 1 because branching!
|
||||||
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$40, #$01, ! ;-320
|
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$40, #$01, ! ;-320
|
||||||
|
|
||||||
;; Y is inverted
|
;; Y is inverted
|
||||||
Add_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$40, #$01 ;+320
|
Add_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$3f, #$01,! ;+320
|
||||||
;; X and Y has swopped
|
;; X and Y has swopped
|
||||||
Sub_16 btp_mem_pos_qcb, btp_mem_pos_qcb + 1, #$08, #$00
|
Sub_16 btp_mem_pos_qcb, btp_mem_pos_qcb + 1, #$07, #$00,! ;-8
|
||||||
;; X and Y has swoped and Y has inverted
|
;; X and Y has swoped and Y has inverted
|
||||||
Add_16 btp_mem_pos_qdb, btp_mem_pos_qdb +1, #$08, #$00
|
Add_16 btp_mem_pos_qdb, btp_mem_pos_qdb +1, #$07, #$00,! ;+8
|
||||||
increment_y_pos_end:
|
increment_y_pos_end:
|
||||||
RTS
|
RTS
|
||||||
.endproc
|
.endproc
|
||||||
|
|
Loading…
Add table
Reference in a new issue