Optimized line-rect routine

This commit is contained in:
neauoire 2022-02-21 10:30:55 -08:00
parent 0c819b9f59
commit f87c15c8b5
5 changed files with 107 additions and 85 deletions

View File

@ -551,23 +551,28 @@ RTN
@line-rect ( x1* y1* x2* y2* color -- ) @line-rect ( x1* y1* x2* y2* color -- )
( load ) .color STZ STH2k .rect/y2 STZ2 .rect/x2 STZ2 STH2k .rect/y1 STZ2 .rect/x1 STZ2 STH
STH2r INC2 STH2r DUP2 ,&ver-y2 STR2 ,&hor-y2 STR2
&ver DUP2 ,&ver-x2 STR2 ,&hor-x2 STR2
( save ) OVR2 .Screen/y DEO2 DUP2 ,&ver-y1 STR2 ,&hor-y1 STR2
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO DUP2 ,&ver-x1 STR2 ,&hor-x1 STR2
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/pixel DEO ( horizontal )
( incr ) SWP2 INC2 SWP2 [ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
OVR2 OVR2 LTS2 ,&ver JCN
POP2 POP2
.rect/x1 LDZ2 INC2 .rect/x2 LDZ2 #0001 --
&hor &hor
( save ) OVR2 .Screen/x DEO2 DUP2 .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
( incr ) SWP2 INC2 SWP2 INC2 GTH2k ,&hor JCN
OVR2 OVR2 INC2 LTS2 ,&hor JCN
POP2 POP2 POP2 POP2
( vertical )
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
&ver
DUP2 .Screen/y DEO2
[ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
[ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
INC2 GTH2k ,&ver JCN
POP2 POP2
POPr
RTN RTN

View File

@ -305,18 +305,28 @@ RTN
@line-rect ( x1* y1* x2* y2* color -- ) @line-rect ( x1* y1* x2* y2* color -- )
( load ) .color STZ .rect/y2 STZ2 .rect/x2 STZ2 DUP2 .Screen/y DEO2 .rect/y1 STZ2 DUP2 .Screen/x DEO2 .rect/x1 STZ2 STH
DUP2 ,&ver-y2 STR2 ,&hor-y2 STR2
DUP2 ,&ver-x2 STR2 ,&hor-x2 STR2
DUP2 ,&ver-y1 STR2 ,&hor-y1 STR2
DUP2 ,&ver-x1 STR2 ,&hor-x1 STR2
( horizontal )
[ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
&hor &hor
( incr ) .Screen/x DEI2 ++ .Screen/x DEO2 DUP2 .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
.Screen/x DEI2 .rect/x2 LDZ2 LTH2 ,&hor JCN INC2 GTH2k ,&hor JCN
.rect/y1 LDZ2 .Screen/y DEO2 POP2 POP2
( vertical )
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
&ver &ver
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ .Screen/pixel DEO DUP2 .Screen/y DEO2
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .color LDZ .Screen/pixel DEO [ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
( incr ) .Screen/y DEI2 ++ .Screen/y DEO2 [ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
.Screen/y DEI2 .rect/y2 LDZ2 ++ LTH2 ,&ver JCN INC2 GTH2k ,&ver JCN
POP2 POP2
POPr
RTN RTN

View File

@ -28,10 +28,6 @@
&w $2 &h $2 &w $2 &h $2
&x0 $2 &y0 $2 &x0 $2 &y0 $2
&x1 $2 &y1 $2 &x1 $2 &y1 $2
@color $1
@rect
&x1 $2 &y1 $2
&x2 $2 &y2 $2
( init ) ( init )
@ -57,6 +53,11 @@
( vectors ) ( vectors )
;on-button .Controller/vector DEO2 ;on-button .Controller/vector DEO2
( frame )
.frame/x0 LDZ2 .frame/y0 LDZ2
.frame/x1 LDZ2 .frame/y1 LDZ2
#03 ;line-rect JSR2
,draw-controller JSR ,draw-controller JSR
BRK BRK
@ -74,10 +75,6 @@ BRK
.Controller/button DEI STH .Controller/button DEI STH
( frame )
.frame/x0 LDZ2 .frame/y0 LDZ2
.frame/x1 LDZ2 .frame/y1 LDZ2
#01 ;line-rect JSR2
( d-pad ) ( d-pad )
.frame/x0 LDZ2 #0010 ++ .Screen/x DEO2 .frame/x0 LDZ2 #0010 ++ .Screen/x DEO2
.frame/y0 LDZ2 #0010 ++ .Screen/y DEO2 .frame/y0 LDZ2 #0010 ++ .Screen/y DEO2
@ -135,7 +132,7 @@ RTN
@draw-short ( short* color -- ) @draw-short ( short* color -- )
STH SWP STHkr ,draw-byte JSR STHr STH SWP STHkr ,draw-byte JSR STHr
@draw-byte ( byte color -- ) @draw-byte ( byte color -- )
@ -150,23 +147,28 @@ RTN
@line-rect ( x1* y1* x2* y2* color -- ) @line-rect ( x1* y1* x2* y2* color -- )
( load ) .color STZ DUP2 STH2 .rect/y2 STZ2 .rect/x2 STZ2 DUP2 STH2 .rect/y1 STZ2 .rect/x1 STZ2 STH
STH2r INC2 STH2r DUP2 ,&ver-y2 STR2 ,&hor-y2 STR2
&ver DUP2 ,&ver-x2 STR2 ,&hor-x2 STR2
( save ) OVR2 .Screen/y DEO2 DUP2 ,&ver-y1 STR2 ,&hor-y1 STR2
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO DUP2 ,&ver-x1 STR2 ,&hor-x1 STR2
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/pixel DEO ( horizontal )
( incr ) SWP2 INC2 SWP2 [ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
OVR2 OVR2 LTS2 ,&ver JCN
POP2 POP2
.rect/x1 LDZ2 INC2 .rect/x2 LDZ2 #0001 --
&hor &hor
( save ) OVR2 .Screen/x DEO2 DUP2 .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
( incr ) SWP2 INC2 SWP2 INC2 GTH2k ,&hor JCN
OVR2 OVR2 INC2 LTS2 ,&hor JCN
POP2 POP2 POP2 POP2
( vertical )
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
&ver
DUP2 .Screen/y DEO2
[ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
[ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
INC2 GTH2k ,&ver JCN
POP2 POP2
POPr
RTN RTN

View File

@ -96,25 +96,28 @@ RTN
@line-rect ( x1* y1* x2* y2* color -- ) @line-rect ( x1* y1* x2* y2* color -- )
( load ) .color STZ STH
STH2k .rect/y2 STZ2 .rect/x2 STZ2 DUP2 ,&ver-y2 STR2 ,&hor-y2 STR2
STH2k .rect/y1 STZ2 .rect/x1 STZ2 DUP2 ,&ver-x2 STR2 ,&hor-x2 STR2
STH2r STH2r SWP2 DUP2 ,&ver-y1 STR2 ,&hor-y1 STR2
&ver DUP2 ,&ver-x1 STR2 ,&hor-x1 STR2
( save ) DUP2 .Screen/y DEO2 ( horizontal )
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO [ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/pixel DEO
( incr ) INC2
OVR2 OVR2 GTS2 ,&ver JCN
POP2 POP2
.rect/x1 LDZ2 .rect/x2 LDZ2 SWP2
&hor &hor
( save ) DUP2 .Screen/x DEO2 DUP2 .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
( incr ) INC2 INC2 GTH2k ,&hor JCN
OVR2 OVR2 GTS2 ,&hor JCN
POP2 POP2 POP2 POP2
( vertical )
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
&ver
DUP2 .Screen/y DEO2
[ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
[ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
INC2 GTH2k ,&ver JCN
POP2 POP2
POPr
RTN RTN

View File

@ -93,28 +93,30 @@ RTN
@line-rect ( x1* y1* x2* y2* color -- ) @line-rect ( x1* y1* x2* y2* color -- )
( load ) STH STH
STH2k ,&y2 STR2 ,&x2 STR2 DUP2 ,&ver-y2 STR2 ,&hor-y2 STR2
STH2k ,&y1 STR2 ,&x1 STR2 DUP2 ,&ver-x2 STR2 ,&hor-x2 STR2
STH2r STH2r SWP2 DUP2 ,&ver-y1 STR2 ,&hor-y1 STR2
&ver DUP2 ,&ver-x1 STR2 ,&hor-x1 STR2
( save ) DUP2 .Screen/y DEO2 ( horizontal )
( draw ) ,&x1 LDR2 .Screen/x DEO2 STHkr .Screen/pixel DEO [ LIT2 &hor-x2 $2 ] INC2 [ LIT2 &hor-x1 $2 ]
( draw ) ,&x2 LDR2 .Screen/x DEO2 STHkr .Screen/pixel DEO
( incr ) INC2
OVR2 OVR2 GTS2 ,&ver JCN
POP2 POP2
,&x1 LDR2 ,&x2 LDR2 SWP2
&hor &hor
( save ) DUP2 .Screen/x DEO2 DUP2 .Screen/x DEO2
( draw ) ,&y1 LDR2 .Screen/y DEO2 STHkr .Screen/pixel DEO [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk
( draw ) ,&y2 LDR2 .Screen/y DEO2 STHkr .Screen/pixel DEO [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO
( incr ) INC2 INC2 GTH2k ,&hor JCN
OVR2 INC2 OVR2 GTS2 ,&hor JCN POP2 POP2
POP2 POP2 POPr ( vertical )
[ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ]
&ver
DUP2 .Screen/y DEO2
[ LIT2 &ver-x1 $2 ] .Screen/x DEO2 STHkr .Screen/pixel DEOk
[ LIT2 &ver-x2 $2 ] .Screen/x DEO2 DEO
INC2 GTH2k ,&ver JCN
POP2 POP2
POPr
RTN RTN
&x1 $2 &y1 $2 &x2 $2 &y2 $2
@fill-rect ( x1* y1* x2* y2* color -- ) @fill-rect ( x1* y1* x2* y2* color -- )