Implement earlier perfromance improvments to line_up.s
This commit is contained in:
parent
4497026d95
commit
0df0e666ad
1 changed files with 47 additions and 16 deletions
|
@ -12,6 +12,15 @@
|
||||||
.proc line_up
|
.proc line_up
|
||||||
.include "line.inc"; Defines memory positions, ex X_pos
|
.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
|
;;We need to clear this memory
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA <V
|
STA <V
|
||||||
|
@ -19,9 +28,7 @@
|
||||||
STA $FD ; for pixel_draw
|
STA $FD ; for pixel_draw
|
||||||
|
|
||||||
;; V = 2*(dx -dy)
|
;; V = 2*(dx -dy)
|
||||||
;; where: dy = Y_pos - Y_end, dx = X_end - X_start
|
;; where: dy = Y_end - Y_start, dx = OO - X_start
|
||||||
;; This logic is comented out because line.s does it woithout any
|
|
||||||
;;extra cost. May be needed in the future so it will stay as coments!
|
|
||||||
LDA Y_pos
|
LDA Y_pos
|
||||||
SEC
|
SEC
|
||||||
SBC Y_end
|
SBC Y_end
|
||||||
|
@ -32,12 +39,18 @@
|
||||||
SBC X_pos
|
SBC X_pos
|
||||||
STA dx
|
STA dx
|
||||||
SEC
|
SEC
|
||||||
SBC >dy_2
|
SBC >V
|
||||||
STA >V; <V = dx - dy
|
STA >V; <V = dx - dy
|
||||||
mult_16 >V, <V; V = 2*(dx -dy)
|
mult_16 >V, <V; V = 2*(dx -dy)
|
||||||
|
|
||||||
;dy_2 = dy*2
|
;dy_2 = dy*2
|
||||||
mult_16 >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.
|
||||||
|
;; V_max = 00000001 11111111
|
||||||
|
;; For us to work with unsigned numbers we add 00000001 11111111
|
||||||
|
;; to V and the branch logic to V!
|
||||||
|
|
||||||
;;D = 2*dy - dx + 2*255
|
;;D = 2*dy - dx + 2*255
|
||||||
;;Our D is bigger then wikipedia because D is unsigned.
|
;;Our D is bigger then wikipedia because D is unsigned.
|
||||||
|
@ -45,25 +58,43 @@
|
||||||
STA >D
|
STA >D
|
||||||
LDA <dy_2
|
LDA <dy_2
|
||||||
STA <D
|
STA <D
|
||||||
Add_16 >D, <D, #$ff, #$01
|
Add_16 >D, <D, #$ff, #$01, !
|
||||||
Sub_16 >D, <D, dx, #$00
|
Sub_16 >D, <D, dx, #$00
|
||||||
for_x:
|
|
||||||
jsr pixel_draw
|
jsr pixel_draw
|
||||||
;;Increment X until X_pos = X_end and Y_pos = Y_end
|
;INY ; Dont want underflow
|
||||||
INC X_pos
|
;LDY #$09
|
||||||
|
;Sub_16 >btp_mem_pos, <btp_mem_pos, #$40, #$01 ;-320
|
||||||
LDX X_pos
|
LDX X_pos
|
||||||
|
for_x:
|
||||||
|
LDA byte_to_paint
|
||||||
|
ORA (>btp_mem_pos), Y
|
||||||
|
STA (>btp_mem_pos), Y
|
||||||
|
increment_pixel_x:
|
||||||
|
LSR byte_to_paint
|
||||||
|
BCC increment_pixel_x_end
|
||||||
|
move_8px_left:
|
||||||
|
Add_16 >btp_mem_pos, <btp_mem_pos, #$08, #$00
|
||||||
|
LDA #%10000000
|
||||||
|
STA byte_to_paint
|
||||||
|
increment_pixel_x_end:
|
||||||
|
INX
|
||||||
CPX X_end
|
CPX X_end
|
||||||
BEQ end
|
BEQ end
|
||||||
|
|
||||||
;;If D < %00000010 00000000: case_2
|
|
||||||
;;else case 1.
|
|
||||||
Lag_16 >D, <D, #$00, #$02, case_2
|
Lag_16 >D, <D, #$00, #$02, case_2
|
||||||
case_1:
|
case_1:
|
||||||
DEC Y_pos
|
Sub_16 >D, <D, >V, <V
|
||||||
Sub_16 >D, <D, >V, <V; D = D - V
|
decrement_y_pos:
|
||||||
JMP for_x
|
DEY
|
||||||
|
CPY #$ff
|
||||||
|
BNE for_x
|
||||||
|
move_8px_up:
|
||||||
|
LDY #$07
|
||||||
|
Sub_16 >btp_mem_pos, <btp_mem_pos, #$40, #$01 ;-320
|
||||||
|
jmp for_x
|
||||||
|
decrement_y_pos_end:
|
||||||
case_2:
|
case_2:
|
||||||
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
|
JMP for_x
|
||||||
end:
|
end:
|
||||||
RTS
|
RTS
|
||||||
|
|
Loading…
Add table
Reference in a new issue