Created within-rect routine
This commit is contained in:
parent
0d20b4309a
commit
3b9519d945
2
build.sh
2
build.sh
|
@ -42,7 +42,7 @@ then
|
|||
fi
|
||||
|
||||
echo "Assembling.."
|
||||
./bin/uxnasm projects/demos/life.usm bin/boot.rom
|
||||
./bin/uxnasm projects/demos/piano.usm bin/boot.rom
|
||||
|
||||
echo "Running.."
|
||||
if [ "${2}" = '--cli' ];
|
||||
|
|
|
@ -169,19 +169,15 @@ BRK
|
|||
@on-mouse ( -> )
|
||||
|
||||
;draw-cursor JSR2
|
||||
|
||||
.Mouse/state DEI #00 ! #01 JCN [ BRK ]
|
||||
( wave-view )
|
||||
.Mouse/x DEI2 DUP2 .wave-view/x1 LDZ2 >> ROT ROT .wave-view/x2 LDZ2 #0001 ++ << #0101 ==
|
||||
.Mouse/y DEI2 DUP2 .wave-view/y1 LDZ2 >> ROT ROT .wave-view/y2 LDZ2 << #0101 ==
|
||||
#0101 == ;on-touch-wave-view JCN2
|
||||
( adsr-view )
|
||||
.Mouse/x DEI2 DUP2 .adsr-view/x1 LDZ2 >> ROT ROT .adsr-view/x2 LDZ2 << #0101 ==
|
||||
.Mouse/y DEI2 DUP2 .adsr-view/y1 LDZ2 >> ROT ROT .adsr-view/y2 LDZ2 << #0101 ==
|
||||
#0101 == ;on-touch-adsr-view JCN2
|
||||
( octave-view )
|
||||
.Mouse/x DEI2 DUP2 .octave-view/x1 LDZ2 >> ROT ROT .octave-view/x2 LDZ2 << #0101 ==
|
||||
.Mouse/y DEI2 DUP2 .octave-view/y1 LDZ2 >> ROT ROT .octave-view/y2 LDZ2 << #0101 ==
|
||||
#0101 == ;on-touch-octave-view JCN2
|
||||
|
||||
.Mouse/x DEI2 .Mouse/y DEI2 .wave-view ;within-rect JSR2
|
||||
;on-touch-wave-view JCN2
|
||||
.Mouse/x DEI2 .Mouse/y DEI2 .adsr-view ;within-rect JSR2
|
||||
;on-touch-adsr-view JCN2
|
||||
.Mouse/x DEI2 .Mouse/y DEI2 .octave-view ;within-rect JSR2
|
||||
;on-touch-octave-view JCN2
|
||||
|
||||
BRK
|
||||
|
||||
|
@ -459,6 +455,23 @@ RTN
|
|||
|
||||
RTN
|
||||
|
||||
@within-rect ( x* y* rect -- flag )
|
||||
|
||||
STH
|
||||
( y < rect.y1 ) DUP2 STHkr #02 ADD LDZ2 LTH2 ,&skip JCN
|
||||
( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN
|
||||
SWP2
|
||||
( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN
|
||||
( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
|
||||
POP2 POP2 POPr
|
||||
#01
|
||||
RTN
|
||||
&skip
|
||||
POP2 POP2 POPr
|
||||
#00
|
||||
|
||||
RTN
|
||||
|
||||
@cursor
|
||||
80c0 e0f0 f8e0 1000
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
( GUI Hover )
|
||||
|
||||
%RTN { JMP2r }
|
||||
%DEBUG { .Console/byte DEO #0a .Console/char DEO }
|
||||
%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
|
||||
|
||||
( devices )
|
||||
|
||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
|
||||
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|
||||
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|
||||
|
||||
|
@ -34,39 +37,37 @@
|
|||
|
||||
@on-mouse
|
||||
|
||||
( defaults )
|
||||
;pointer_icn .pointer/sprite STZ2
|
||||
|
||||
#01 .color STZ
|
||||
( matrix comparison )
|
||||
.Mouse/x DEI2 .r1/x1 LDZ2 GTH2 .Mouse/x DEI2 .r1/x2 LDZ2 LTH2 #0101 EQU2
|
||||
.Mouse/y DEI2 .r1/y1 LDZ2 GTH2 .Mouse/y DEI2 .r1/y2 LDZ2 LTH2 #0101 EQU2
|
||||
#0101 NEQ2 ,&draw1 JCN #02 .color STZ ;hand_icn .pointer/sprite STZ2
|
||||
&draw1 .r1/x1 LDZ2 .r1/y1 LDZ2 .r1/x2 LDZ2 .r1/y2 LDZ2 .color LDZ ;line-rect JSR2
|
||||
.Mouse/x DEI2 .Mouse/y DEI2 .r1 ;within-rect JSR2 #00 EQU ,&draw1 JCN
|
||||
#02 .color STZ
|
||||
;hand_icn .pointer/sprite STZ2
|
||||
&draw1
|
||||
.r1/x1 LDZ2 .r1/y1 LDZ2 .r1/x2 LDZ2 .r1/y2 LDZ2 .color LDZ ;line-rect JSR2
|
||||
|
||||
#01 .color STZ
|
||||
( 2-step comparison )
|
||||
.Mouse/x DEI2 .r2/x1 LDZ2 GTH2 .Mouse/x DEI2 .r2/x2 LDZ2 LTH2 #0101 NEQ2 ,&draw2 JCN
|
||||
.Mouse/y DEI2 .r2/y1 LDZ2 GTH2 .Mouse/y DEI2 .r2/y2 LDZ2 LTH2 #0101 NEQ2 ,&draw2 JCN
|
||||
#03 .color STZ ;hand_icn .pointer/sprite STZ2
|
||||
&draw2 .r2/x1 LDZ2 .r2/y1 LDZ2 .r2/x2 LDZ2 .r2/y2 LDZ2 .color LDZ ;line-rect JSR2
|
||||
.Mouse/x DEI2 .Mouse/y DEI2 .r2 ;within-rect JSR2 #00 EQU ,&draw2 JCN
|
||||
#03 .color STZ
|
||||
;hand_icn .pointer/sprite STZ2
|
||||
&draw2
|
||||
.r2/x1 LDZ2 .r2/y1 LDZ2 .r2/x2 LDZ2 .r2/y2 LDZ2 .color LDZ ;line-rect JSR2
|
||||
|
||||
#01 .color STZ
|
||||
( 4-step comparison )
|
||||
.Mouse/x DEI2 .r3/x1 LDZ2 LTH2 ,&draw3 JCN
|
||||
.Mouse/x DEI2 .r3/x2 LDZ2 GTH2 ,&draw3 JCN
|
||||
.Mouse/y DEI2 .r3/y1 LDZ2 LTH2 ,&draw3 JCN
|
||||
.Mouse/y DEI2 .r3/y2 LDZ2 GTH2 ,&draw3 JCN
|
||||
#02 .color STZ ;hand_icn .pointer/sprite STZ2
|
||||
&draw3 .r3/x1 LDZ2 .r3/y1 LDZ2 .r3/x2 LDZ2 .r3/y2 LDZ2 .color LDZ ;line-rect JSR2
|
||||
.Mouse/x DEI2 .Mouse/y DEI2 .r3 ;within-rect JSR2 #00 EQU ,&draw3 JCN
|
||||
#02 .color STZ
|
||||
;hand_icn .pointer/sprite STZ2
|
||||
&draw3
|
||||
.r3/x1 LDZ2 .r3/y1 LDZ2 .r3/x2 LDZ2 .r3/y2 LDZ2 .color LDZ ;line-rect JSR2
|
||||
|
||||
;draw-cursor JSR2
|
||||
|
||||
BRK
|
||||
|
||||
@draw-cursor
|
||||
@draw-cursor ( -- )
|
||||
|
||||
( clear last cursor )
|
||||
;clear_icn .Screen/addr DEO2
|
||||
.pointer/x LDZ2 .Screen/x DEO2
|
||||
.pointer/y LDZ2 .Screen/y DEO2
|
||||
#30 .Screen/color DEO
|
||||
|
@ -82,6 +83,23 @@ BRK
|
|||
|
||||
RTN
|
||||
|
||||
@within-rect ( x* y* rect -- flag )
|
||||
|
||||
STH
|
||||
( y < rect.y1 ) DUP2 STHkr #02 ADD LDZ2 LTH2 ,&skip JCN
|
||||
( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN
|
||||
SWP2
|
||||
( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN
|
||||
( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
|
||||
POP2 POP2 POPr
|
||||
#01
|
||||
RTN
|
||||
&skip
|
||||
POP2 POP2 POPr
|
||||
#00
|
||||
|
||||
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
|
||||
|
@ -99,6 +117,5 @@ RTN
|
|||
|
||||
RTN
|
||||
|
||||
@clear_icn [ 0000 0000 0000 0000 ]
|
||||
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
|
||||
@hand_icn [ 4040 4070 f8f8 f870 ]
|
||||
|
|
Loading…
Reference in New Issue