uxn/projects/examples/dev.mouse.usm

64 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-04-21 16:48:04 +00:00
( dev/mouse )
%RTN { JMP2r }
%8+ { #0008 ADD2 }
%++ { #0001 ADD2 }
%-- { #0001 SUB2 }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &pad $8 &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 ]
|40 @Controller [ &vector $2 &button $1 &key $1 ]
|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|0000
@pointer [ &x $2 &y $2 ]
( program )
|0100 ( -> )
( theme )
#03fd .System/r DEO2
#0ef3 .System/g DEO2
#0bf2 .System/b DEO2
2021-04-21 16:48:04 +00:00
( vectors ) ;on-mouse .Mouse/vector DEO2
2021-04-21 16:48:04 +00:00
BRK
@on-mouse ( -> )
;draw-cursor JSR2
BRK
@draw-cursor ( -- )
( clear last cursor )
;clear .Screen/addr DEO2
.pointer/x PEK2 .Screen/x DEO2
.pointer/y PEK2 .Screen/y DEO2
#30 .Screen/color DEO
2021-04-21 16:48:04 +00:00
( record pointer positions )
.Mouse/x DEI2 .pointer/x POK2
.Mouse/y DEI2 .pointer/y POK2
2021-04-21 16:48:04 +00:00
( draw new cursor )
;cursor .Screen/addr DEO2
.pointer/x PEK2 .Screen/x DEO2
.pointer/y PEK2 .Screen/y DEO2
2021-04-21 16:48:04 +00:00
( colorize on state )
.Mouse/state DEI #00 NEQ
#31 ADD .Screen/color DEO
2021-04-21 16:48:04 +00:00
RTN
@clear [ 0000 0000 0000 0000 ]
@cursor [ 80c0 e0f0 f8e0 1000 ]