Redused paint_pixel to 1 call in draw line

This commit is contained in:
hugova 2025-03-05 22:42:00 +01:00
parent 76f29f6b81
commit 9694d8d55b
4 changed files with 45 additions and 11 deletions

View file

@ -9,3 +9,6 @@
dx_2 = dy_2
V = $0809
D = $0a0b
;;These are also used in pixel_draw. Look there to find out more
byte_to_paint = $FE ;Byte with one 1 that corasponds to a pixel.
btp_mem_pos =$494A; byte to paint memory position ;Position of byte on screen

View file

@ -32,7 +32,6 @@
;dy_2 = dy*2
mult_16 >dy_2, <dy_2, !
;; D = 2*dy - dx
;; In loop we have that D = D -V
;; So D needs to be at least >=V.
@ -49,10 +48,33 @@
Add_16 >D, <D, #$ff, #$01, !
Sub_16 >D, <D, dx, #$00
start_paint:
LDY #$00
jsr pixel_draw ;;only used first pixel. after this relative position is abused
;byte_to_paint = $FE ;Byte with one 1 that corasponds to a pixel.
;btp_mem_pos =$494A; byte to paint memory position ;Position of byte on screen
jmp increment_x_pos_end
for_x:
jsr pixel_draw
;;Increment X until X_pos = X_end and Y_pos = Y_end
INC X_pos
;; Lets increment btp_mem_pos with +8
;; Read more in pixel_draw to understand this!
increment_x_pos:
INC X_pos;; legacy
CLC
LDA byte_to_paint
ROR byte_to_paint
LDX #$00
ORA (>btp_mem_pos, X)
STA (>btp_mem_pos, X)
BCS move_8px_left
jmp increment_x_pos_end
move_8px_left:
;; add +8 to btp_mem_pos. Find more of why in pixel_draw
Add_16 >btp_mem_pos, <btp_mem_pos, #$08, #$00
;; reset byte_to_paint
LDA #%10000000
STA byte_to_paint
increment_x_pos_end:
LDX X_pos
CPX X_end
BEQ end
@ -60,11 +82,21 @@ for_x:
;;else case 1.
Lag_16 >D, <D, #$00, #$02, case_2
case_1:; C =1 so we can use !
Sub_16 >D, <D, >V, <V ; D = D - V
increment_y_pos:
INC Y_pos
Sub_16 >D, <D, >V, <V, !; D = D - V
JMP for_x
Add_16 >btp_mem_pos, <btp_mem_pos, #$01, #$00
INY
CPY #$08 ;
BEQ move_8px_down
jmp for_x
move_8px_down:
;; +320-8 bytes
LDY #$00
Add_16 >btp_mem_pos, <btp_mem_pos,#$38 , #$01
jmp for_x
case_2: ;; C =0 because LAG_16 so we can use !
Add_16 >D, <D, >dy_2, <dy_2, !;D = D + 2*dy
Add_16 >D, <D, >dy_2, <dy_2 ;D = D + 2*dy
JMP for_x
end:
RTS

View file

@ -7,7 +7,7 @@
X_pos_ = $0E
Y_end_ = $10
X_end_ = $11
LDA #$a0
LDA #$00
STA X_pos_
LDA #$30
STA Y_pos_
@ -28,7 +28,7 @@ time_start
jsr line
INC Y_end
LDA Y_end
CMP #$40
CMP #$50
BEQ end__
jmp @loop
end__:

View file

@ -13,7 +13,6 @@
TAX
;;Store pixel in byte_to_paint
TAX
LDA #%10000000
INX
@shift_btp:
@ -87,7 +86,7 @@ end__:
;;Let draw some stuff
LDX #$00
LDA byte_to_paint
LDA byte_to_paint ;; note that both bytes are used!
ORA (>btp_mem_pos, X)
STA (>btp_mem_pos, X)
RTS