Propergate optimisations from line_down.s to the other line_*.s files
This commit is contained in:
parent
be3e9582ba
commit
46a52661b8
6 changed files with 66 additions and 72 deletions
|
@ -5,10 +5,10 @@
|
||||||
Y_end = $05
|
Y_end = $05
|
||||||
X_pos = $FC
|
X_pos = $FC
|
||||||
Y_pos = $FB
|
Y_pos = $FB
|
||||||
dy= $0c
|
dx = $0c
|
||||||
dx = dy
|
dy = $06
|
||||||
dy_2 = $0607
|
dy_2 = $0607
|
||||||
dx_2 = dy_2
|
dx_2 = $0cF3
|
||||||
V = $0809
|
V = $0809
|
||||||
D = $0a0b
|
D = $0a0b
|
||||||
;;These are also used in pixel_draw. Look there to find out more
|
;;These are also used in pixel_draw. Look there to find out more
|
||||||
|
|
|
@ -35,6 +35,8 @@ down:
|
||||||
CMP dx
|
CMP dx
|
||||||
BCC shallow_; dy < dx
|
BCC shallow_; dy < dx
|
||||||
steep_:
|
steep_:
|
||||||
|
;LDA dx
|
||||||
|
|
||||||
jsr line_down_inv
|
jsr line_down_inv
|
||||||
RTS
|
RTS
|
||||||
shallow_: ;dy < dx
|
shallow_: ;dy < dx
|
||||||
|
|
|
@ -10,24 +10,7 @@
|
||||||
|
|
||||||
.proc line_down
|
.proc line_down
|
||||||
|
|
||||||
;; TEMPORARY
|
.include "line.inc"; Defines memory positions, ex X_pos
|
||||||
;; Hack because changing dx and dy makes other line draws bugg and idk why
|
|
||||||
;; This is offcorse temporary
|
|
||||||
;.include "line.inc"; Defines memory positions, ex X_pos
|
|
||||||
X_end = $04
|
|
||||||
Y_end = $05
|
|
||||||
X_pos = $FC
|
|
||||||
Y_pos = $FB
|
|
||||||
dx = $0c
|
|
||||||
dy = $06
|
|
||||||
dy_2 = $0607
|
|
||||||
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
|
|
||||||
;;END TEMPORARY
|
|
||||||
|
|
||||||
;;We need to clear this memory
|
;;We need to clear this memory
|
||||||
LDA #$00
|
LDA #$00
|
||||||
|
@ -63,7 +46,7 @@
|
||||||
jsr pixel_draw ;;only used first pixel. after this relative position is abused
|
jsr pixel_draw ;;only used first pixel. after this relative position is abused
|
||||||
LDX X_pos
|
LDX X_pos
|
||||||
|
|
||||||
selfmod:
|
selfmod:
|
||||||
;; Self modifying code. Makes LDA and SBC instructions each take 1 cycle less.
|
;; Self modifying code. Makes LDA and SBC instructions each take 1 cycle less.
|
||||||
;; You can remove this if you run the loop without # at dy_2 and V.
|
;; You can remove this if you run the loop without # at dy_2 and V.
|
||||||
;;Note: The offsets like +2 etc is because there are instructions betwean the label and the
|
;;Note: The offsets like +2 etc is because there are instructions betwean the label and the
|
||||||
|
@ -82,7 +65,7 @@
|
||||||
;; Modifies SBC <V
|
;; Modifies SBC <V
|
||||||
LDA <V
|
LDA <V
|
||||||
STA case_1 +9
|
STA case_1 +9
|
||||||
end_selfmod:
|
end_selfmod:
|
||||||
|
|
||||||
for_x:
|
for_x:
|
||||||
;; Paints A to address in |btp_mem_pos* + Y|
|
;; Paints A to address in |btp_mem_pos* + Y|
|
||||||
|
|
|
@ -8,35 +8,38 @@
|
||||||
;;# (X_end, Y_end) #
|
;;# (X_end, Y_end) #
|
||||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Min 45deg!
|
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Min 45deg!
|
||||||
.proc line_down_inv
|
.proc line_down_inv
|
||||||
;; Look at line_down for referense
|
;; Look at line_down for referense
|
||||||
.include "line.inc"
|
.include "line.inc"; Defines memory positions, ex X_pos
|
||||||
|
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA <V
|
STA <V
|
||||||
STA <dx_2
|
STA <dx_2
|
||||||
STA $FD
|
STA $FD
|
||||||
|
|
||||||
LDA dx
|
|
||||||
STA >V
|
|
||||||
STA >dx_2
|
|
||||||
LDA Y_end
|
|
||||||
SEC
|
SEC
|
||||||
SBC Y_pos
|
LDA dy
|
||||||
STA dy
|
SBC dx
|
||||||
|
|
||||||
SEC
|
|
||||||
SBC >V
|
|
||||||
STA >V
|
STA >V
|
||||||
Mult_16 >V, <V
|
Mult_16 >V, <V
|
||||||
|
|
||||||
Mult_16 >dx_2, <dx_2
|
Mult_16 >dx_2, <dx_2
|
||||||
|
|
||||||
LDA >dx_2
|
Mov_16 >D, <D, >dx_2, <dx_2
|
||||||
STA >D
|
Add_16 >D, <D, #$ff, #$01, !
|
||||||
LDA <dx_2
|
|
||||||
STA <D
|
|
||||||
Add_16 >D, <D, #$ff, #$01
|
|
||||||
Sub_16 >D, <D, dy, #$00
|
Sub_16 >D, <D, dy, #$00
|
||||||
|
|
||||||
|
|
||||||
|
selfmod:
|
||||||
|
LDA >dx_2
|
||||||
|
STA case_2 +1
|
||||||
|
LDA <dx_2
|
||||||
|
STA case_2 +7
|
||||||
|
LDA >V
|
||||||
|
STA case_1 +3
|
||||||
|
LDA <V
|
||||||
|
STA case_1 +9
|
||||||
|
end_selfmod:
|
||||||
|
|
||||||
jsr pixel_draw
|
jsr pixel_draw
|
||||||
LDX Y_pos
|
LDX Y_pos
|
||||||
for_y:
|
for_y:
|
||||||
|
@ -49,14 +52,14 @@ increment_y_pos:
|
||||||
BNE increment_y_pos_end
|
BNE increment_y_pos_end
|
||||||
move_8px_down:
|
move_8px_down:
|
||||||
LDY #$00
|
LDY #$00
|
||||||
Add_16 >btp_mem_pos, <btp_mem_pos,#$40 , #$01;
|
Add_16 >btp_mem_pos, <btp_mem_pos, #$40 ,#$01
|
||||||
increment_y_pos_end:
|
increment_y_pos_end:
|
||||||
INX
|
INX
|
||||||
CPX Y_end
|
CPX Y_end
|
||||||
BEQ end
|
BEQ end
|
||||||
Lag_16 >D, <D, #$00, #$02, case_2
|
Lag_16 >D, <D, #$00, #$02, case_2
|
||||||
case_1:
|
case_1:
|
||||||
Sub_16 >D, <D, >V, <V, !
|
Sub_16 >D, <D, #>V, #<V, !
|
||||||
increment_pixel_x:
|
increment_pixel_x:
|
||||||
LDA byte_to_paint
|
LDA byte_to_paint
|
||||||
LSR byte_to_paint
|
LSR byte_to_paint
|
||||||
|
@ -67,7 +70,7 @@ move_8px_left:
|
||||||
STA byte_to_paint
|
STA byte_to_paint
|
||||||
JMP for_y
|
JMP for_y
|
||||||
case_2:
|
case_2:
|
||||||
Add_16 >D, <D, >dx_2, <dx_2, ! ;D = D + 2*dx
|
Add_16 >D, <D, #>dx_2, #<dx_2, ! ;D = D + 2*dx
|
||||||
JMP for_y
|
JMP for_y
|
||||||
end:
|
end:
|
||||||
RTS
|
RTS
|
||||||
|
|
|
@ -11,32 +11,36 @@
|
||||||
|
|
||||||
.proc line_up
|
.proc line_up
|
||||||
;; Look at line_down for referense
|
;; Look at line_down for referense
|
||||||
.include "line.inc"
|
.include "line.inc"; Defines memory positions, ex X_pos
|
||||||
|
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA <V
|
STA <V
|
||||||
STA <dy_2
|
STA <dy_2
|
||||||
STA $FD
|
STA $FD
|
||||||
|
|
||||||
LDA Y_pos
|
|
||||||
SEC
|
SEC
|
||||||
SBC Y_end
|
|
||||||
STA >V
|
|
||||||
STA >dy_2
|
|
||||||
LDA dx
|
LDA dx
|
||||||
SEC
|
SBC dy
|
||||||
SBC >V
|
|
||||||
STA >V
|
STA >V
|
||||||
Mult_16 >V, <V
|
Mult_16 >V, <V
|
||||||
|
|
||||||
Mult_16 >dy_2, <dy_2, !
|
Mult_16 >dy_2, <dy_2
|
||||||
|
|
||||||
LDA >dy_2
|
Mov_16 >D, <D, >dy_2, <dy_2
|
||||||
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
|
Sub_16 >D, <D, dx, #$00
|
||||||
|
|
||||||
|
selfmod:
|
||||||
|
LDA >dy_2
|
||||||
|
STA case_2 +1
|
||||||
|
LDA <dy_2
|
||||||
|
STA case_2 +7
|
||||||
|
LDA >V
|
||||||
|
STA case_1 +3
|
||||||
|
LDA <V
|
||||||
|
STA case_1 +9
|
||||||
|
end_selfmod:
|
||||||
|
|
||||||
jsr pixel_draw
|
jsr pixel_draw
|
||||||
LDX X_pos
|
LDX X_pos
|
||||||
for_x:
|
for_x:
|
||||||
|
@ -56,7 +60,7 @@ increment_pixel_x_end:
|
||||||
BEQ end
|
BEQ end
|
||||||
Lag_16 >D, <D, #$00, #$02, case_2
|
Lag_16 >D, <D, #$00, #$02, case_2
|
||||||
case_1:
|
case_1:
|
||||||
Sub_16 >D, <D, >V, <V, !
|
Sub_16 >D, <D, #>V, #<V, !
|
||||||
decrement_y_pos:
|
decrement_y_pos:
|
||||||
DEY
|
DEY
|
||||||
CPY #$ff
|
CPY #$ff
|
||||||
|
@ -67,7 +71,7 @@ move_8px_up:
|
||||||
jmp for_x
|
jmp for_x
|
||||||
decrement_y_pos_end:
|
decrement_y_pos_end:
|
||||||
case_2:
|
case_2:
|
||||||
Add_16 >D, <D, >dy_2, <dy_2, !
|
Add_16 >D, <D, #>dy_2, #<dy_2, !
|
||||||
JMP for_x
|
JMP for_x
|
||||||
end:
|
end:
|
||||||
RTS
|
RTS
|
||||||
|
|
|
@ -10,34 +10,36 @@
|
||||||
|
|
||||||
.proc line_up_inv
|
.proc line_up_inv
|
||||||
;; Look at line_down for referense
|
;; Look at line_down for referense
|
||||||
.include "line.inc"
|
.include "line.inc"; Defines memory positions, ex X_pos
|
||||||
|
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA <V
|
STA <V
|
||||||
STA <dx_2
|
STA <dx_2
|
||||||
STA $FD
|
STA $FD
|
||||||
|
|
||||||
LDA dx
|
|
||||||
STA >V
|
|
||||||
STA >dx_2
|
|
||||||
LDA Y_pos
|
|
||||||
SEC
|
SEC
|
||||||
SBC Y_end
|
LDA dy
|
||||||
STA dy
|
SBC dx
|
||||||
SEC
|
|
||||||
SBC >V
|
|
||||||
STA >V
|
STA >V
|
||||||
Mult_16 >V, <V
|
Mult_16 >V, <V
|
||||||
|
|
||||||
Mult_16 >dx_2, <dx_2
|
Mult_16 >dx_2, <dx_2
|
||||||
|
|
||||||
LDA >dx_2
|
Mov_16 >D, <D, >dx_2, <dx_2
|
||||||
STA >D
|
Add_16 >D, <D, #$ff, #$01, !
|
||||||
LDA <dx_2
|
|
||||||
STA <D
|
|
||||||
Add_16 >D, <D, #$ff, #$01
|
|
||||||
Sub_16 >D, <D, dy, #$00
|
Sub_16 >D, <D, dy, #$00
|
||||||
|
|
||||||
|
selfmod:
|
||||||
|
LDA >dx_2
|
||||||
|
STA case_2 +1
|
||||||
|
LDA <dx_2
|
||||||
|
STA case_2 +7
|
||||||
|
LDA >V
|
||||||
|
STA case_1 +3
|
||||||
|
LDA <V
|
||||||
|
STA case_1 +9
|
||||||
|
end_selfmod:
|
||||||
|
|
||||||
jsr pixel_draw
|
jsr pixel_draw
|
||||||
LDX Y_pos
|
LDX Y_pos
|
||||||
for_y:
|
for_y:
|
||||||
|
@ -57,7 +59,7 @@ decrement_y_pos_end:
|
||||||
BEQ end
|
BEQ end
|
||||||
Lag_16 >D, <D, #$00, #$02, case_2
|
Lag_16 >D, <D, #$00, #$02, case_2
|
||||||
case_1:
|
case_1:
|
||||||
Sub_16 >D, <D, >V, <V, !
|
Sub_16 >D, <D, #>V, #<V, !
|
||||||
increment_pixel_x:
|
increment_pixel_x:
|
||||||
LDA byte_to_paint
|
LDA byte_to_paint
|
||||||
LSR byte_to_paint
|
LSR byte_to_paint
|
||||||
|
@ -68,7 +70,7 @@ move_8px_left:
|
||||||
STA byte_to_paint
|
STA byte_to_paint
|
||||||
JMP for_y
|
JMP for_y
|
||||||
case_2:
|
case_2:
|
||||||
Add_16 >D, <D, >dx_2, <dx_2,!
|
Add_16 >D, <D, #>dx_2, #<dx_2, !
|
||||||
JMP for_y
|
JMP for_y
|
||||||
end:
|
end:
|
||||||
RTS
|
RTS
|
||||||
|
|
Loading…
Add table
Reference in a new issue