uxn/projects/examples/dev.controller.buttons.usm

87 lines
1.9 KiB
Plaintext
Raw Normal View History

2021-04-02 04:53:41 +00:00
( Dev/Controller )
2021-03-14 01:34:08 +00:00
2021-04-20 04:33:52 +00:00
%++ { #0001 ADD2 } %-- { #0001 SUB2 }
2021-03-16 18:25:26 +00:00
%2/ { #0002 DIV2 }
2021-03-15 00:32:40 +00:00
2021-04-20 17:48:55 +00:00
%=>SC/ADDR { .Screen/addr IOW2 }
%->SC/COLR { .Screen/color IOW }
2021-03-21 21:16:19 +00:00
( variables )
2021-04-20 04:33:52 +00:00
@slime $1
2021-03-14 01:34:08 +00:00
2021-03-21 21:16:19 +00:00
( devices )
2021-04-20 17:31:50 +00:00
|0100 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|0110 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
|0120 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|0140 @Controller [ &vector $2 &button $1 &key $1 ]
2021-04-06 17:45:53 +00:00
|0200
2021-04-20 04:00:14 +00:00
( theme )
2021-04-20 17:31:50 +00:00
#0daf .System/r IOW2
#02ff .System/g IOW2
#035f .System/b IOW2
2021-03-28 18:20:36 +00:00
2021-04-20 04:00:14 +00:00
( vectors )
2021-04-20 17:31:50 +00:00
;on-frame .Screen/vector IOW2
2021-03-14 01:34:08 +00:00
( set origin )
2021-04-20 17:31:50 +00:00
.Screen/width IOR2 2/ .Screen/x IOW2
.Screen/height IOR2 2/ .Screen/y IOW2
2021-04-20 17:48:55 +00:00
;default_icn =>SC/ADDR
#31 ->SC/COLR
2021-04-20 04:33:52 +00:00
#2a .slime POK
2021-03-14 01:34:08 +00:00
BRK
2021-04-20 00:23:30 +00:00
@on-frame
2021-03-15 00:32:40 +00:00
2021-04-20 04:33:52 +00:00
#2a .slime POK
2021-04-20 17:48:55 +00:00
;default_icn =>SC/ADDR
2021-03-15 00:32:40 +00:00
2021-03-14 01:34:08 +00:00
( hold ctrl key to change slime color )
2021-04-20 17:31:50 +00:00
.Controller/button IOR #0f AND
2021-04-20 04:33:52 +00:00
DUP #01 NEQ ,&no-ctrl JNZ #25 .slime POK &no-ctrl
DUP #02 NEQ ,&no-alt JNZ #2f .slime POK &no-alt
2021-03-15 00:32:40 +00:00
POP
2021-04-20 17:48:55 +00:00
( clear ) #30 ->SC/COLR
2021-03-15 00:32:40 +00:00
( detect movement )
2021-04-20 17:31:50 +00:00
.Controller/button IOR #f0 AND
2021-04-20 04:33:52 +00:00
DUP #04 SFT #01 AND #01 NEQ ,&no-up JNZ
2021-04-20 04:00:14 +00:00
( move )
2021-04-20 17:31:50 +00:00
.Screen/y IOR2 -- .Screen/y IOW2
2021-04-20 17:48:55 +00:00
;up_icn =>SC/ADDR &no-up
2021-04-20 04:33:52 +00:00
DUP #05 SFT #01 AND #01 NEQ ,&no-down JNZ
2021-04-20 04:00:14 +00:00
( move )
2021-04-20 17:31:50 +00:00
.Screen/y IOR2 ++ .Screen/y IOW2
2021-04-20 17:48:55 +00:00
;down_icn =>SC/ADDR &no-down
2021-04-20 04:33:52 +00:00
DUP #06 SFT #01 AND #01 NEQ ,&no-left JNZ
2021-04-20 04:00:14 +00:00
( move )
2021-04-20 17:31:50 +00:00
.Screen/x IOR2 -- .Screen/x IOW2
2021-04-20 17:48:55 +00:00
;left_icn =>SC/ADDR &no-left
2021-04-20 04:33:52 +00:00
DUP #07 SFT #01 AND #01 NEQ ,&no-right JNZ
2021-04-20 04:00:14 +00:00
( move )
2021-04-20 17:31:50 +00:00
.Screen/x IOR2 ++ .Screen/x IOW2
2021-04-20 17:48:55 +00:00
;right_icn =>SC/ADDR &no-right
2021-03-15 00:32:40 +00:00
POP
2021-03-14 01:34:08 +00:00
( draw face )
2021-04-20 17:48:55 +00:00
#31 ->SC/COLR
2021-03-15 00:32:40 +00:00
2021-03-14 01:34:08 +00:00
( draw slime )
2021-04-20 17:48:55 +00:00
;slime_icn =>SC/ADDR
.slime PEK ->SC/COLR
2021-03-14 01:34:08 +00:00
2021-03-15 00:32:40 +00:00
BRK
2021-03-14 01:34:08 +00:00
@default_icn [ 3c7e ffdb ffe7 7e3c ]
@up_icn [ 2466 e7db ffff 7e3c ]
@down_icn [ 3c7e ffff dbe7 6624 ]
@left_icn [ 3c7e ef1f 1fef 7e3c ]
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
@slime_icn [ 0000 183c 3c18 0000 ]