Reorginisation of line-drawing code. Also added a macro to benchmark line drawing logic. Addition of line_test_time to benchmark line drawing time (Do not work yet)
This commit is contained in:
parent
494e9dc5f9
commit
89c2b42bfe
10 changed files with 202 additions and 112 deletions
18
wip-hugo/macros/timer.s
Normal file
18
wip-hugo/macros/timer.s
Normal file
|
@ -0,0 +1,18 @@
|
|||
;; Max 1.5s
|
||||
.macro time_start
|
||||
PHA
|
||||
LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1
|
||||
AND #%00001111
|
||||
STA $f1
|
||||
PLA
|
||||
.endmacro
|
||||
|
||||
.macro time_stop
|
||||
PHA
|
||||
LDA $DC08 ; Bit 0..3: Tenth seconds in BCD-format, others may be 0 or 1
|
||||
AND #%00001111
|
||||
SEC
|
||||
SBC $f1
|
||||
STA $f1
|
||||
PLA
|
||||
.endmacro
|
11
wip-hugo/routines/line/line.inc
Normal file
11
wip-hugo/routines/line/line.inc
Normal file
|
@ -0,0 +1,11 @@
|
|||
;;Not values but register position in memory
|
||||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
dy= $0c
|
||||
dx = dy
|
||||
dy_2 = $0607
|
||||
dx_2 = dy_2
|
||||
V = $0809
|
||||
D = $0a0b
|
|
@ -1,11 +1,16 @@
|
|||
.proc line; X_pos =< X_end skall alltid gälla
|
||||
dx = $fe
|
||||
dy = $69
|
||||
;; note that these have same adresses as stuff in line.inc
|
||||
;; This should be used as a optimisation in the future
|
||||
dx = $0c
|
||||
dy = $06
|
||||
;;dx
|
||||
SEC
|
||||
LDA X_end
|
||||
SBC X_pos
|
||||
STA dx
|
||||
BCC dx_no_underflow;; X_end >= X_pos
|
||||
EOR #$ff ; Fix bit underflow
|
||||
dx_no_underflow:
|
||||
|
||||
SEC
|
||||
LDA Y_pos
|
||||
|
@ -20,6 +25,7 @@ steep:
|
|||
jsr line_up_inv
|
||||
RTS
|
||||
shallow: ;dy =< dx
|
||||
lda dx
|
||||
jsr line_up
|
||||
RTS
|
||||
down:
|
||||
|
@ -34,7 +40,6 @@ shallow_: ;dy < dx
|
|||
jsr line_down
|
||||
RTS
|
||||
.endproc
|
||||
|
||||
.include "line_down.s"
|
||||
.include "line_down_inv.s"
|
||||
.include "line_up.s"
|
|
@ -6,16 +6,7 @@
|
|||
;;# * #
|
||||
;;# (X_end, Y_end) #
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Max 45deg!
|
||||
|
||||
;;Not values but register position in memory
|
||||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
dx = $0c
|
||||
dy_2 = $0607
|
||||
V = $0809
|
||||
D = $0a0b
|
||||
.include "line.inc"; Defines memory positions, ex X_pos
|
||||
|
||||
;;We need to clear this memory
|
||||
LDA #$00
|
|
@ -6,16 +6,7 @@
|
|||
;;# * #
|
||||
;;# (X_end, Y_end) #
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos <= Y_end. Min 45deg!
|
||||
|
||||
;;Not values but register position in memory
|
||||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
dy = $0c
|
||||
dx_2 = $0607
|
||||
V = $0809
|
||||
D = $0a0b
|
||||
.include "line.inc"; Defines memory positions, ex X_pos
|
||||
|
||||
;example values ~~~~~ SHOULD BE PRECOMPILED
|
||||
;LDA #$00
|
90
wip-hugo/routines/line/line_test.s
Normal file
90
wip-hugo/routines/line/line_test.s
Normal file
|
@ -0,0 +1,90 @@
|
|||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
;;for testing stuff
|
||||
Y_pos_ = $0D
|
||||
X_pos_ = $0E
|
||||
Y_end_ = $10
|
||||
X_end_ = $11
|
||||
LDA #$d0
|
||||
STA X_pos_
|
||||
LDA #$60
|
||||
STA Y_pos_
|
||||
LDA #$ff
|
||||
STA X_end
|
||||
LDA #$0
|
||||
STA Y_end
|
||||
|
||||
;; Short test for timing
|
||||
@loop:
|
||||
LDA Y_pos_
|
||||
STA Y_pos
|
||||
LDA X_pos_
|
||||
STA X_pos
|
||||
|
||||
jsr line
|
||||
INC Y_end
|
||||
LDA Y_end
|
||||
CMP #$bb
|
||||
BEQ end__
|
||||
jmp @loop
|
||||
end__:
|
||||
|
||||
|
||||
|
||||
;; Full anfle test
|
||||
@loop:
|
||||
LDA Y_pos_
|
||||
STA Y_pos
|
||||
LDA X_pos_
|
||||
STA X_pos
|
||||
|
||||
jsr line
|
||||
INC Y_end
|
||||
LDA Y_end
|
||||
CMP #$bb
|
||||
BEQ end
|
||||
jmp @loop
|
||||
end:
|
||||
;;Long lines
|
||||
|
||||
;;Lets cleer bitmap
|
||||
LDA #>VIC_bank
|
||||
STA $FC
|
||||
LDA #<VIC_bank
|
||||
STA $FB
|
||||
|
||||
LDA #>$5f3f
|
||||
STA $FE
|
||||
LDA #<$5f3f
|
||||
STA $FD
|
||||
|
||||
LDA #$0
|
||||
jsr memory_rec
|
||||
|
||||
LDA #$00
|
||||
STA X_pos_
|
||||
LDA #$60
|
||||
STA Y_pos_
|
||||
LDA #$ff
|
||||
STA X_end
|
||||
LDA #$0
|
||||
STA Y_end
|
||||
@loop:
|
||||
LDA Y_pos_
|
||||
STA Y_pos
|
||||
LDA X_pos_
|
||||
STA X_pos
|
||||
|
||||
jsr line
|
||||
INC Y_end
|
||||
LDA Y_end
|
||||
CMP #$bb
|
||||
BEQ end_
|
||||
jmp @loop
|
||||
end_:
|
||||
jmp exit
|
||||
|
||||
.include "line.s"
|
||||
.include "macros/"
|
38
wip-hugo/routines/line/line_test_time.s
Normal file
38
wip-hugo/routines/line/line_test_time.s
Normal file
|
@ -0,0 +1,38 @@
|
|||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
;;for testing stuff
|
||||
Y_pos_ = $0D
|
||||
X_pos_ = $0E
|
||||
Y_end_ = $10
|
||||
X_end_ = $11
|
||||
LDA #$d0
|
||||
STA X_pos_
|
||||
LDA #$60
|
||||
STA Y_pos_
|
||||
LDA #$ff
|
||||
STA X_end
|
||||
LDA #$0
|
||||
STA Y_end
|
||||
|
||||
;; Short test for timing
|
||||
time_start
|
||||
|
||||
@loop:
|
||||
LDA Y_pos_
|
||||
STA Y_pos
|
||||
LDA X_pos_
|
||||
STA X_pos
|
||||
|
||||
jsr line
|
||||
INC Y_end
|
||||
LDA Y_end
|
||||
CMP #$30
|
||||
BEQ end__
|
||||
jmp @loop
|
||||
end__:
|
||||
time_stop
|
||||
jmp exit
|
||||
|
||||
.include "line.s"
|
|
@ -7,16 +7,7 @@
|
|||
;;# (X_pos, Y_pos) #
|
||||
;;
|
||||
;;NOTE THAT X_pos <= X_end, Y_pos >= Y_end. Max 45deg!
|
||||
|
||||
;;Not values but register position in memory
|
||||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
dy_2 = $0607
|
||||
dx = $0c
|
||||
V = $0809
|
||||
D = $0a0b
|
||||
.include "line.inc"; Defines memory positions, ex X_pos
|
||||
|
||||
;;example values ~~~~~ SHOULD BE PRECOMPILED
|
||||
;LDA #$90
|
||||
|
@ -36,6 +27,8 @@
|
|||
|
||||
;; 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!
|
||||
LDA Y_pos
|
||||
SEC
|
||||
SBC Y_end
|
||||
|
@ -46,7 +39,7 @@
|
|||
SBC X_pos
|
||||
STA dx
|
||||
SEC
|
||||
SBC >V
|
||||
SBC >dy_2
|
||||
STA >V; <V = dx - dy
|
||||
mult_16 >V, <V; V = 2*(dx -dy)
|
||||
|
|
@ -6,18 +6,9 @@
|
|||
;;# * #
|
||||
;;# (X_pos, Y_pos) #
|
||||
;;NOTE THAT Y_pos >) Y_end, X_pos <= X_end. Min 45deg!
|
||||
.include "line.inc"
|
||||
|
||||
;;Not values but register position in memory
|
||||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
dx_2 = $0607
|
||||
dy = $0c
|
||||
V = $0809
|
||||
D = $0a0b
|
||||
|
||||
;We need to clear this memory
|
||||
;;We need to clear this memory
|
||||
LDA #$00
|
||||
STA <V
|
||||
STA <dx_2
|
|
@ -1,50 +1,12 @@
|
|||
.include "STARTUP.s"
|
||||
.include "macros/16aritmatic.s"
|
||||
.include "macros/timer.s"
|
||||
|
||||
X_end = $04
|
||||
Y_end = $05
|
||||
X_pos = $FC
|
||||
Y_pos = $FB
|
||||
.include "STARTUP.s"
|
||||
.include "routines/line/line_test_time.s"
|
||||
|
||||
;;for testing stuff
|
||||
Y_pos_ = $0D
|
||||
X_pos_ = $0E
|
||||
Y_end_ = $10
|
||||
X_end_ = $11
|
||||
;;This is used by .s files to terminate nicely without reading includes at the end!
|
||||
exit:
|
||||
jmp exit
|
||||
|
||||
LDA #$d0
|
||||
STA X_pos_
|
||||
LDA #$60
|
||||
STA Y_pos_
|
||||
LDA #$ff
|
||||
STA X_end_
|
||||
LDA #$0
|
||||
STA Y_end_
|
||||
|
||||
@loop:
|
||||
LDA Y_pos_
|
||||
STA Y_pos
|
||||
LDA X_pos_
|
||||
STA X_pos
|
||||
LDA Y_end_
|
||||
STA Y_end
|
||||
LDA X_end_
|
||||
STA X_end
|
||||
|
||||
jsr line
|
||||
INC Y_end_
|
||||
LDA Y_end_
|
||||
CMP #$bb
|
||||
BEQ loop
|
||||
jmp @loop
|
||||
loop:
|
||||
jmp loop
|
||||
|
||||
|
||||
|
||||
|
||||
loop_:
|
||||
jmp loop_
|
||||
.include "routines/memory/memory_rec.s"
|
||||
.include "routines/memory/pixel_draw.s"
|
||||
.include "routines/memory/line/line.s"
|
||||
|
|
Loading…
Add table
Reference in a new issue