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
|
||||
.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
|
||||
|
@ -19,9 +28,7 @@
|
|||
STA $FD ; for pixel_draw
|
||||
|
||||
;; V = 2*(dx -dy)
|
||||
;; where: dy = Y_pos - Y_end, dx = X_end - 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!
|
||||
;; where: dy = Y_end - Y_start, dx = OO - X_start
|
||||
LDA Y_pos
|
||||
SEC
|
||||
SBC Y_end
|
||||
|
@ -32,12 +39,18 @@
|
|||
SBC X_pos
|
||||
STA dx
|
||||
SEC
|
||||
SBC >dy_2
|
||||
SBC >V
|
||||
STA >V; <V = dx - dy
|
||||
mult_16 >V, <V; V = 2*(dx -dy)
|
||||
|
||||
;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
|
||||
;;Our D is bigger then wikipedia because D is unsigned.
|
||||
|
@ -45,25 +58,43 @@
|
|||
STA >D
|
||||
LDA <dy_2
|
||||
STA <D
|
||||
Add_16 >D, <D, #$ff, #$01
|
||||
Add_16 >D, <D, #$ff, #$01, !
|
||||
Sub_16 >D, <D, dx, #$00
|
||||
for_x:
|
||||
|
||||
jsr pixel_draw
|
||||
;;Increment X until X_pos = X_end and Y_pos = Y_end
|
||||
INC X_pos
|
||||
;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
|
||||
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
|
||||
BEQ end
|
||||
|
||||
;;If D < %00000010 00000000: case_2
|
||||
;;else case 1.
|
||||
Lag_16 >D, <D, #$00, #$02, case_2
|
||||
case_1:
|
||||
DEC Y_pos
|
||||
Sub_16 >D, <D, >V, <V; D = D - V
|
||||
JMP for_x
|
||||
Sub_16 >D, <D, >V, <V
|
||||
decrement_y_pos:
|
||||
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:
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue