Add performance optimisiation for line_up_inv.s

This commit is contained in:
hugova 2025-03-25 19:46:03 +01:00
parent d5c15bd0c2
commit 842033a014
2 changed files with 28 additions and 21 deletions

View file

@ -12,15 +12,6 @@
.proc line_up
.include "line.inc"; Defines memory positions, ex X_pos
;LDA #$20
;STA X_pos
;STA Y_pos
;LDA #$10
;STA Y_end
;LDA #$40
;STA X_end
;;We need to clear this memory
LDA #$00
STA <V
@ -62,9 +53,6 @@
Sub_16 >D, <D, dx, #$00
jsr pixel_draw
;INY ; Dont want underflow
;LDY #$09
;Sub_16 >btp_mem_pos, <btp_mem_pos, #$40, #$01 ;-320
LDX X_pos
for_x:
LDA byte_to_paint

View file

@ -44,20 +44,39 @@
STA <D
Add_16 >D, <D, #$ff, #$01
Sub_16 >D, <D, dy, #$00
for_y:
jsr pixel_draw
;;Increment Y until Y_pos = Y_end and X_pos = X_end
DEC Y_pos
LDY Y_pos
CPY Y_end
BEQ end
jsr pixel_draw
LDX Y_pos
for_y:
LDA byte_to_paint
ORA (>btp_mem_pos), Y
STA (>btp_mem_pos), Y
decrement_y_pos:
DEY
CPY #$ff
BNE decrement_y_pos_end
move_8px_up:
LDY #$07
Sub_16>btp_mem_pos, <btp_mem_pos,#$40 , #$01; ; +320 bytes
decrement_y_pos_end:
DEX
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
Sub_16 >D, <D, >V, <V, !; D = D - V
increment_pixel_x:
LDA byte_to_paint
LSR byte_to_paint
BCC for_y
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:
Add_16 >D, <D, >dx_2, <dx_2;D = D + 2*dy