Add all optimisations done on line_down to line_down_inv. DIx a problem that the pixel was drawin a bit to late in the loop on line_down.

This commit is contained in:
hugova 2025-03-06 01:50:37 +01:00
parent ecc138f2bc
commit 0797e69106
4 changed files with 44 additions and 41 deletions

View file

@ -10,12 +10,6 @@
.endif
;; If b_low != A
.if .match(.mid (0, 1, {b_low}), A )
.elseif .match(.mid (0, 1, {b_low}), X)
LDX
kssk
.match(.mid (0, 1, {b_low}), Y)
LDY
kkdkd
.else
LDA b_low
.endif
@ -23,15 +17,7 @@ kkdkd
ADC a_low
STA a_low
LDA b_hi
.if .match(.mid (0, 1, {b_low}), X )
LDX
kdkdkd
.elseif .match(.mid (0, 1, {b_low}), Y )
LDY
dkkdk
.else
LDA b_hi
.endif
ADC a_hi
STA a_hi
.endmacro

View file

@ -48,21 +48,20 @@
Add_16 >D, <D, #$ff, #$01, !
Sub_16 >D, <D, dx, #$00
LDY #$00
jsr pixel_draw ;;only used first pixel. after this relative position is abused
for_x:
;; Lets increment btp_mem_pos with +8
;; Read more in pixel_draw to understand this!
increment_pixel_x:
CLC
LDA byte_to_paint
ROR byte_to_paint
LDX #$00
LDA byte_to_paint
ORA (>btp_mem_pos, X)
STA (>btp_mem_pos, X)
increment_pixel_x:
CLC
ROR byte_to_paint
BCS move_8px_left
jmp increment_pixel_x_end
JMP increment_pixel_x_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
@ -79,17 +78,18 @@ increment_pixel_x_end:
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:
increment_y_pos:
Add_16 >btp_mem_pos, <btp_mem_pos, #$01, #$00
INY
CPY #$08 ;
BEQ move_8px_down
jmp for_x
move_8px_down:
move_8px_down: ; Z=1 --> C=1
;; +320-8 bytes
LDY #$00
Add_16 >btp_mem_pos, <btp_mem_pos,#$38 , #$01
jmp for_x
increment_y_pos_end:
case_2: ;; C =0 because LAG_16 so we can use !
Add_16 >D, <D, >dy_2, <dy_2, ! ;D = D + 2*dy
JMP for_x

View file

@ -8,16 +8,6 @@
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Min 45deg!
.include "line.inc"; Defines memory positions, ex X_pos
;example values ~~~~~ SHOULD BE PRECOMPILED
;LDA #$00
;STA X_pos
;STA Y_pos
;LDA #$40
;STA X_end
;LDA #$a0
;STA Y_end
;;~~~~~~~~~~
;;We need to clear this memory
LDA #$00
STA <V
@ -52,23 +42,50 @@
Add_16 >D, <D, #$ff, #$01
Sub_16 >D, <D, dy, #$00
LDY #$00
jsr pixel_draw ;;only used first pixel. after this relative position is abused
CLC ; this makes it that C =0 always on for_x
for_y:
jsr pixel_draw
;;Increment Y until Y_pos = Y_end and X_pos = X_end
INC Y_pos
LDY Y_pos
CPY Y_end
LDX #$00
LDA byte_to_paint
ORA (>btp_mem_pos, X)
STA (>btp_mem_pos, X)
increment_y_pos:
Add_16 >btp_mem_pos, <btp_mem_pos, #$01, #$00, ! ; I know that C ==0 on for_y
INY
CPY #$08 ;
BEQ move_8px_down
jmp increment_y_pos_end
move_8px_down:
;; +320-8 bytes
LDY #$00
Add_16 >btp_mem_pos, <btp_mem_pos,#$38 , #$01
increment_y_pos_end:
INC Y_pos;; legacy
LDX Y_pos
CPX Y_end
BEQ end
;;If D < %00000010 00000000: case_2
;;else case 1.
Lag_16 >D, <D, #$00, #$02, case_2
case_1:
INC X_pos
Sub_16 >D, <D, >V, <V; D = D - V
increment_pixel_x:
CLC
LDA byte_to_paint
ROR byte_to_paint
BCS move_8px_left
JMP for_y
case_2:
Add_16 >D, <D, >dx_2, <dx_2;D = D + 2*dx
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
JMP for_y
case_2: ;; C =0 because LAG_16 so we can use !
Add_16 >D, <D, >dx_2, <dx_2, ! ;D = D + 2*dx
JMP for_y
end:
RTS

View file

@ -2,7 +2,7 @@
.include "macros/timer.s"
.include "STARTUP.s"
.include "routines/line/line_test_time.s"
.include "routines/line/line_test.s"
;;This is used by .s files to terminate nicely without reading includes at the end!
exit: