uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit f87c15c8b5274546a2198c35f5a6e30094f8f004
parent 0c819b9f5959678402eb6002a136ada0dbee815a
Author: neauoire <aliceffekt@gmail.com>
Date:   Mon, 21 Feb 2022 10:30:55 -0800

Optimized line-rect routine

Diffstat:
Mprojects/examples/demos/drum-rack.tal | 35++++++++++++++++++++---------------
Mprojects/examples/demos/theme.tal | 30++++++++++++++++++++----------
Mprojects/examples/devices/controller.tal | 50++++++++++++++++++++++++++------------------------
Mprojects/examples/gui/hover.tal | 37++++++++++++++++++++-----------------
Mprojects/examples/gui/shapes.tal | 38++++++++++++++++++++------------------
5 files changed, 106 insertions(+), 84 deletions(-)

diff --git a/projects/examples/demos/drum-rack.tal b/projects/examples/demos/drum-rack.tal @@ -551,23 +551,28 @@ RTN @line-rect ( x1* y1* x2* y2* color -- ) - ( load ) .color STZ STH2k .rect/y2 STZ2 .rect/x2 STZ2 STH2k .rect/y1 STZ2 .rect/x1 STZ2 - STH2r INC2 STH2r - &ver - ( save ) OVR2 .Screen/y DEO2 - ( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO - ( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/pixel DEO - ( incr ) SWP2 INC2 SWP2 - OVR2 OVR2 LTS2 ,&ver JCN - POP2 POP2 - .rect/x1 LDZ2 INC2 .rect/x2 LDZ2 #0001 -- + 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 - ( save ) OVR2 .Screen/x DEO2 - ( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO - ( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO - ( incr ) SWP2 INC2 SWP2 - OVR2 OVR2 INC2 LTS2 ,&hor JCN + DUP2 .Screen/x DEO2 + [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk + [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO + INC2 GTH2k ,&hor JCN 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 diff --git a/projects/examples/demos/theme.tal b/projects/examples/demos/theme.tal @@ -305,18 +305,28 @@ RTN @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 - ( incr ) .Screen/x DEI2 ++ .Screen/x DEO2 - ( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO - ( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO - .Screen/x DEI2 .rect/x2 LDZ2 LTH2 ,&hor JCN - .rect/y1 LDZ2 .Screen/y DEO2 + DUP2 .Screen/x DEO2 + [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk + [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO + INC2 GTH2k ,&hor JCN + POP2 POP2 + ( vertical ) + [ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ] &ver - ( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ .Screen/pixel DEO - ( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .color LDZ .Screen/pixel DEO - ( incr ) .Screen/y DEI2 ++ .Screen/y DEO2 - .Screen/y DEI2 .rect/y2 LDZ2 ++ LTH2 ,&ver JCN + 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 diff --git a/projects/examples/devices/controller.tal b/projects/examples/devices/controller.tal @@ -28,10 +28,6 @@ &w $2 &h $2 &x0 $2 &y0 $2 &x1 $2 &y1 $2 -@color $1 -@rect - &x1 $2 &y1 $2 - &x2 $2 &y2 $2 ( init ) @@ -57,6 +53,11 @@ ( vectors ) ;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 BRK @@ -74,10 +75,6 @@ BRK .Controller/button DEI STH - ( frame ) - .frame/x0 LDZ2 .frame/y0 LDZ2 - .frame/x1 LDZ2 .frame/y1 LDZ2 - #01 ;line-rect JSR2 ( d-pad ) .frame/x0 LDZ2 #0010 ++ .Screen/x DEO2 .frame/y0 LDZ2 #0010 ++ .Screen/y DEO2 @@ -135,7 +132,7 @@ RTN @draw-short ( short* color -- ) - STH SWP STHkr ,draw-byte JSR STHr + STH SWP STHkr ,draw-byte JSR STHr @draw-byte ( byte color -- ) @@ -150,23 +147,28 @@ RTN @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 - STH2r INC2 STH2r - &ver - ( save ) OVR2 .Screen/y DEO2 - ( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO - ( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/pixel DEO - ( incr ) SWP2 INC2 SWP2 - OVR2 OVR2 LTS2 ,&ver JCN - POP2 POP2 - .rect/x1 LDZ2 INC2 .rect/x2 LDZ2 #0001 -- + 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 - ( save ) OVR2 .Screen/x DEO2 - ( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO - ( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO - ( incr ) SWP2 INC2 SWP2 - OVR2 OVR2 INC2 LTS2 ,&hor JCN + DUP2 .Screen/x DEO2 + [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk + [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO + INC2 GTH2k ,&hor JCN + 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 diff --git a/projects/examples/gui/hover.tal b/projects/examples/gui/hover.tal @@ -96,25 +96,28 @@ RTN @line-rect ( x1* y1* x2* y2* color -- ) - ( load ) .color STZ - STH2k .rect/y2 STZ2 .rect/x2 STZ2 - STH2k .rect/y1 STZ2 .rect/x1 STZ2 - STH2r STH2r SWP2 - &ver - ( save ) DUP2 .Screen/y DEO2 - ( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/pixel DEO - ( 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 + 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 - ( save ) DUP2 .Screen/x DEO2 - ( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/pixel DEO - ( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/pixel DEO - ( incr ) INC2 - OVR2 OVR2 GTS2 ,&hor JCN + DUP2 .Screen/x DEO2 + [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk + [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO + INC2 GTH2k ,&hor JCN + 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 diff --git a/projects/examples/gui/shapes.tal b/projects/examples/gui/shapes.tal @@ -93,28 +93,30 @@ RTN @line-rect ( x1* y1* x2* y2* color -- ) - ( load ) STH - STH2k ,&y2 STR2 ,&x2 STR2 - STH2k ,&y1 STR2 ,&x1 STR2 - STH2r STH2r SWP2 + 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 + DUP2 .Screen/x DEO2 + [ LIT2 &hor-y1 $2 ] .Screen/y DEO2 STHkr .Screen/pixel DEOk + [ LIT2 &hor-y2 $2 ] .Screen/y DEO2 DEO + INC2 GTH2k ,&hor JCN + POP2 POP2 + ( vertical ) + [ LIT2 &ver-y2 $2 ] [ LIT2 &ver-y1 $2 ] &ver - ( save ) DUP2 .Screen/y DEO2 - ( draw ) ,&x1 LDR2 .Screen/x DEO2 STHkr .Screen/pixel DEO - ( draw ) ,&x2 LDR2 .Screen/x DEO2 STHkr .Screen/pixel DEO - ( incr ) INC2 - OVR2 OVR2 GTS2 ,&ver JCN + 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 - ,&x1 LDR2 ,&x2 LDR2 SWP2 - &hor - ( save ) DUP2 .Screen/x DEO2 - ( draw ) ,&y1 LDR2 .Screen/y DEO2 STHkr .Screen/pixel DEO - ( draw ) ,&y2 LDR2 .Screen/y DEO2 STHkr .Screen/pixel DEO - ( incr ) INC2 - OVR2 INC2 OVR2 GTS2 ,&hor JCN - POP2 POP2 POPr + POPr RTN - &x1 $2 &y1 $2 &x2 $2 &y2 $2 @fill-rect ( x1* y1* x2* y2* color -- )