Remove bodge macro in circledraw and use jmp in other addressing mode

This commit is contained in:
hugova 2025-07-03 17:50:25 +02:00
parent f54ecb75b9
commit 590d7533d9
3 changed files with 162 additions and 161 deletions

View file

@ -9,7 +9,9 @@
Y_rel = $E2
Y_copy = $E3
temp_ = $E4
temo__ = $E5
temp__ = $E5
temp___ = $ED
jmp_location_pointer = $EE ;16 bit value (uses EF)
byte_to_paint_qaa = byte_to_paint
byte_to_paint_qcb = $EB ;16bit value (uses EC)
@ -17,15 +19,13 @@
btp_mem_pos_center = $E6 ; 16bit value (uses E7)
btp_mem_pos_center_two = btp_mem_pos_center
temp__ = $D0
temp___ = $D1
btp_mem_pos_qaa = btp_mem_pos
btp_mem_pos_qcb = $D2 ; 16bit value (uses D3)
btp_mem_pos_qdb = $D4 ;16bit value (uses D5)
btp_mem_pos_qda =$D6 ; 16bit value (uses D7)
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 = $D8
btp_mem_pos_qca = $DA
btp_mem_pos_qba = $DC
btp_mem_pos_qbb = $DE
btp_mem_pos_qab = $D6
btp_mem_pos_qca = $D8
btp_mem_pos_qba = $DA
btp_mem_pos_qbb = $DC

View file

@ -3,8 +3,13 @@
.proc circle
.include "circle.inc"
;; X_rel = radius (share the same address)
;; Because loop is so big, We need to save position in pointer
LDA #<while_x_bigger_then_y
STA jmp_location_pointer
LDA #>while_x_bigger_then_y
STA jmp_location_pointer + 1
;; X_rel = radius (share the same address)
;;Y_rel =0
LDA #$00
STA Y_rel
@ -70,7 +75,149 @@ while_x_bigger_then_y:
SEC
;;Draw pixels and does the ypos incrementation logic
;; WARNING expects C=1 before and C =0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
JSR circle_help
;; WARNING expects C=1 before and C =0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;;We have named the parts of the circle as such.
;; |
;; qbb (7) | qab (8)
;; |
;; qba (2) | qaa (1)
;;---------------X-----------------> X
;; qca (4) | qda (3)
;; |
;; qcb (5) | qdb (6)
;; |
;; v Y
;; 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!
calculate:
;; qab = 2*center - qcb
;; qca = 2*center - qaa
;; qba = 2*center - qda
;; qbb = 2*center - qdb
;; a = 2*center - b comes from that a = center -(b-center)
LDA btp_mem_pos_center_two
SBC btp_mem_pos_qcb
STA btp_mem_pos_qab
LDA btp_mem_pos_center_two + 1
SBC btp_mem_pos_qcb + 1
STA btp_mem_pos_qab + 1
LDA btp_mem_pos_center_two
SBC btp_mem_pos
STA btp_mem_pos_qca
LDA btp_mem_pos_center_two + 1
SBC btp_mem_pos + 1
STA btp_mem_pos_qca + 1
LDA btp_mem_pos_center_two
SBC btp_mem_pos_qda
STA btp_mem_pos_qba
LDA btp_mem_pos_center_two + 1
SBC btp_mem_pos_qda + 1
STA btp_mem_pos_qba + 1
LDA btp_mem_pos_center_two
SBC btp_mem_pos_qdb
STA btp_mem_pos_qbb
LDA btp_mem_pos_center_two + 1
SBC btp_mem_pos_qdb + 1
STA btp_mem_pos_qbb + 1
end_calculation:
;; Lets draw all half-quatrons of the circle. This draws only 8 pixels per iteration.
;; Note that I have the draw_qxx in listed pairs. Each pair chair the same Y-register :)
STY Y_copy
draw_qaa:
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_qba: ;;mirror_technique
LDX byte_to_paint
LDA inverse_factor_value, X;; (see END.s)
TAX
ORA (btp_mem_pos_qba), Y
STA (btp_mem_pos_qba), Y
draw_qda:; y is inverted
;; invert Y, this is shared with qca
LDA #$07
SBC Y_copy
TAY
LDA byte_to_paint
ORA (btp_mem_pos_qda), Y
STA (btp_mem_pos_qda), Y
draw_qca: ;;mirror technique
TXA
ORA (btp_mem_pos_qca), Y
STA (btp_mem_pos_qca), Y
draw_qcb:; xy swoped
LDA log, X
TAY
;;modify X_pos
LDX Y_copy
LDA binary_factor, X; (see END.s)
TAX
ORA (btp_mem_pos_qcb), Y
STA (btp_mem_pos_qcb), Y
draw_qdb:; xy swaped and y is inverted.
LDA inverse_factor_value, X
STA temp__
;;Uses modifyed Y from above
ORA (btp_mem_pos_qdb), Y
STA (btp_mem_pos_qdb), Y
draw_qbb:
STY temp_
LDA #$07
SBC temp_
TAY
TXA
ORA (btp_mem_pos_qbb), Y
STA (btp_mem_pos_qbb), Y
draw_qab:; xy swoped + mirroring
LDA temp__
ORA (btp_mem_pos_qab), Y
STA (btp_mem_pos_qab), Y
;;Recover the Y value (we changed it because evrything is inverted)
LDY Y_copy
increment_y_pos:
INC Y_rel ; y++
DEY
BPL increment_y_pos_end
move_8px_down:
LDY #$07
;; Switch to chunk bellow
; So we subtract #$0140
; C = 1 because branching!
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$40, #$01, ! ;-320
;; Y is inverted
Add_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$3f, #$01,! ;+320
;; X and Y has swopped
Sub_16 btp_mem_pos_qcb, btp_mem_pos_qcb + 1, #$07, #$00,! ;-8
;; X and Y has swoped and Y has inverted
Add_16 btp_mem_pos_qdb, btp_mem_pos_qdb +1, #$07, #$00,! ;+8
increment_y_pos_end:
;;t1 += y
@ -114,7 +261,8 @@ endif:
LDA X_rel
CMP Y_rel
BCS while_x_bigger_then_y
BCC end
JMP (jmp_location_pointer)
end:
RTS
.include "routines/circle/circle_help.s"
.endproc

View file

@ -1,147 +0,0 @@
.proc circle_help ; This is because jmp cant jump that long!
.include "circle.inc"
;; WARNING expects C=1 before and C =0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;;We have named the parts of the circle as such.
;; |
;; qbb (7) | qab (8)
;; |
;; qba (2) | qaa (1)
;;---------------X-----------------> X
;; qca (4) | qda (3)
;; |
;; qcb (5) | qdb (6)
;; |
;; v Y
;; 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!
calculate:
;; qab = 2*center - qcb
;; qca = 2*center - qaa
;; qba = 2*center - qda
;; qbb = 2*center - qdb
;; a = 2*center - b comes from that a = center -(b-center)
LDA btp_mem_pos_center_two
SBC btp_mem_pos_qcb
STA btp_mem_pos_qab
LDA btp_mem_pos_center_two + 1
SBC btp_mem_pos_qcb + 1
STA btp_mem_pos_qab + 1
LDA btp_mem_pos_center_two
SBC btp_mem_pos
STA btp_mem_pos_qca
LDA btp_mem_pos_center_two + 1
SBC btp_mem_pos + 1
STA btp_mem_pos_qca + 1
LDA btp_mem_pos_center_two
SBC btp_mem_pos_qda
STA btp_mem_pos_qba
LDA btp_mem_pos_center_two + 1
SBC btp_mem_pos_qda + 1
STA btp_mem_pos_qba + 1
LDA btp_mem_pos_center_two
SBC btp_mem_pos_qdb
STA btp_mem_pos_qbb
LDA btp_mem_pos_center_two + 1
SBC btp_mem_pos_qdb + 1
STA btp_mem_pos_qbb + 1
end_calculation:
;; Lets draw all half-quatrons of the circle. This draws only 8 pixels per iteration.
;; Note that I have the draw_qxx in listed pairs. Each pair chair the same Y-register :)
STY Y_copy
draw_qaa:
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_qba: ;;mirror_technique
LDX byte_to_paint
LDA inverse_factor_value, X;; (see END.s)
TAX
ORA (btp_mem_pos_qba), Y
STA (btp_mem_pos_qba), Y
draw_qda:; y is inverted
;; invert Y, this is shared with qca
LDA #$07
SBC Y_copy
TAY
LDA byte_to_paint
ORA (btp_mem_pos_qda), Y
STA (btp_mem_pos_qda), Y
draw_qca: ;;mirror technique
TXA
ORA (btp_mem_pos_qca), Y
STA (btp_mem_pos_qca), Y
draw_qcb:; xy swoped
LDA log, X
TAY
;;modify X_pos
LDX Y_copy
LDA binary_factor, X; (see END.s)
TAX
ORA (btp_mem_pos_qcb), Y
STA (btp_mem_pos_qcb), Y
draw_qdb:; xy swaped and y is inverted.
LDA inverse_factor_value, X
STA temp__
;;Uses modifyed Y from above
ORA (btp_mem_pos_qdb), Y
STA (btp_mem_pos_qdb), Y
draw_qbb:
STY temp_
LDA #$07
SBC temp_
TAY
TXA
ORA (btp_mem_pos_qbb), Y
STA (btp_mem_pos_qbb), Y
draw_qab:; xy swoped + mirroring
LDA temp__
ORA (btp_mem_pos_qab), Y
STA (btp_mem_pos_qab), Y
;;Recover the Y value (we changed it because evrything is inverted)
LDY Y_copy
increment_y_pos:
INC Y_rel ; y++
DEY
BPL increment_y_pos_end
move_8px_down:
LDY #$07
;; Switch to chunk bellow
; So we subtract #$0140
; C = 1 because branching!
Sub_16 btp_mem_pos, btp_mem_pos + 1, #$40, #$01, ! ;-320
;; Y is inverted
Add_16 btp_mem_pos_qda, btp_mem_pos_qda + 1, #$3f, #$01,! ;+320
;; X and Y has swopped
Sub_16 btp_mem_pos_qcb, btp_mem_pos_qcb + 1, #$07, #$00,! ;-8
;; X and Y has swoped and Y has inverted
Add_16 btp_mem_pos_qdb, btp_mem_pos_qdb +1, #$07, #$00,! ;+8
increment_y_pos_end:
RTS
.endproc