Starting mouse-picking

This commit is contained in:
Devine Lu Linvega 2024-02-10 20:56:26 -08:00
parent efaa0a927e
commit de35b9908f
1 changed files with 36 additions and 8 deletions

View File

@ -5,6 +5,10 @@
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1 |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
|0000
@hover $2
|0100 |0100
@on-reset ( -> ) @on-reset ( -> )
@ -19,8 +23,29 @@
@on-mouse ( -> ) @on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #42 ADD ;pointer-icn <update-pointer> [ LIT2 00 -Mouse/state ] DEI NEQ #42 ADD ;pointer-icn <update-pointer>
.Mouse/state DEI ?on-mouse-down
( | hover )
get-mouse-key <set-hover>
BRK BRK
@on-mouse-down ( -> )
BRK
(
@|core )
@<set-hover> ( id* -- )
DUP2 .hover LDZ2 EQU2 ?{ .hover STZ2
JMP2r }
POP2 JMP2r
@get-mouse-key ( -- id* )
( x ) .Mouse/x DEI2 #0008 SUB2 #05 SFT2
( y ) .Mouse/y DEI2 #0008 SUB2 #0030 DIV2 #0009 MUL2 ADD2
( last2 ) DUP #22 LTH ?{ #0004 SUB2 JMP2r }
( space ) DUP #1d SUB #04 GTH ?{ POP2 #001d }
JMP2r
@<set-position> ( id* -- ) @<set-position> ( id* -- )
DUP2 #0009 DIV2 #0030 MUL2 #0008 ADD2 .Screen/y DEO2 DUP2 #0009 DIV2 #0030 MUL2 #0008 ADD2 .Screen/y DEO2
DUP #1e NEQ ?{ POP2 #0007 } DUP #1e NEQ ?{ POP2 #0007 }
@ -31,15 +56,18 @@
@<draw-keyboard> ( -- ) @<draw-keyboard> ( -- )
#0020 #0000 #0020 #0000
&l ( -- ) &l ( -- )
DUP2 <set-position> DUP2 #00 <draw-key-id>
DUP #1d NEQ ?{ <draw-key-space> ( ) INC2 GTH2k ?&l
INC2 !&l } POP2 POP2 JMP2r
DUP2 #0006 MUL2 ;layout ADD2
@<draw-key-id> ( id* state -- )
POP DUP2 <set-position>
DUP #1d EQU ?<draw-key-space>
#0006 MUL2 ;layout ADD2
( ) STH2k #0004 ADD2 LDA2 ( ) STH2k #0004 ADD2 LDA2
( ) STH2kr #0002 ADD2 LDA2 ( ) STH2kr #0002 ADD2 LDA2
( ) STH2r LDA2 <draw-key> ( ) STH2r LDA2 <draw-key>
( ) INC2 GTH2k ?&l JMP2r
POP2 POP2 JMP2r
@<draw-glyph> ( addr* -- ) @<draw-glyph> ( addr* -- )
.Screen/addr DEO2 .Screen/addr DEO2
@ -65,8 +93,8 @@
.Screen/y DEI2k #001c SUB2 ROT DEO2 .Screen/y DEI2k #001c SUB2 ROT DEO2
JMP2r JMP2r
@<draw-key-space> ( -- ) @<draw-key-space> ( id* -- )
[ LIT2 35 -Screen/auto ] DEO POP2 [ LIT2 35 -Screen/auto ] DEO
;button-wide-icn/left .Screen/addr DEO2 ;button-wide-icn/left .Screen/addr DEO2
[ LIT2 81 -Screen/sprite ] DEOk DEOk #ef [ LIT2 81 -Screen/sprite ] DEOk DEOk #ef
&l ( -- ) &l ( -- )