uxn/projects/examples/devices/controller.buttons.tal

90 lines
1.9 KiB
Tal
Raw Normal View History

2021-04-21 16:09:18 +00:00
( dev/controller/buttons )
2021-03-14 01:34:08 +00:00
2021-04-21 16:09:18 +00:00
%++ { #0001 ADD2 }
%-- { #0001 SUB2 }
2021-05-24 21:36:15 +00:00
%2// { #01 SFT2 }
2021-04-20 17:48:55 +00:00
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
2021-04-26 17:52:46 +00:00
|80 @Controller [ &vector $2 &button $1 &key $1 ]
2021-03-21 21:16:19 +00:00
( variables )
|0000
2021-04-20 04:33:52 +00:00
@slime $1
2021-03-14 01:34:08 +00:00
2021-04-21 16:48:04 +00:00
( init )
|0100 ( -> )
2021-04-20 04:00:14 +00:00
( theme )
#0daf .System/r DEO2
#02ff .System/g DEO2
#035f .System/b DEO2
2021-03-28 18:20:36 +00:00
2021-04-20 04:00:14 +00:00
( vectors )
;on-frame .Screen/vector DEO2
2021-03-14 01:34:08 +00:00
( set origin )
2021-05-24 21:36:15 +00:00
.Screen/width DEI2 2// .Screen/x DEO2
.Screen/height DEI2 2// .Screen/y DEO2
2021-04-21 16:09:18 +00:00
;default_icn .Screen/addr DEO2
#31 .Screen/color DEO
2021-05-11 18:14:52 +00:00
#2a .slime STZ
2021-03-14 01:34:08 +00:00
BRK
2021-04-21 16:48:04 +00:00
@on-frame ( -> )
2021-03-15 00:32:40 +00:00
2021-05-11 18:14:52 +00:00
#2a .slime STZ
;default_icn .Screen/addr DEO2
2021-03-15 00:32:40 +00:00
2021-03-14 01:34:08 +00:00
( hold ctrl key to change slime color )
.Controller/button DEI #0f AND
2021-05-11 18:14:52 +00:00
DUP #01 NEQ ,&no-ctrl JCN #25 .slime STZ &no-ctrl
DUP #02 NEQ ,&no-alt JCN #2f .slime STZ &no-alt
2021-03-15 00:32:40 +00:00
POP
( clear ) #30 .Screen/color DEO
2021-03-15 00:32:40 +00:00
( detect movement )
.Controller/button DEI #f0 AND
2021-05-11 18:12:07 +00:00
DUP #04 SFT #01 AND #01 NEQ ,&no-up JCN
2021-04-20 04:00:14 +00:00
( move )
.Screen/y DEI2 -- .Screen/y DEO2
;up_icn .Screen/addr DEO2 &no-up
2021-05-11 18:12:07 +00:00
DUP #05 SFT #01 AND #01 NEQ ,&no-down JCN
2021-04-20 04:00:14 +00:00
( move )
.Screen/y DEI2 ++ .Screen/y DEO2
;down_icn .Screen/addr DEO2 &no-down
2021-05-11 18:12:07 +00:00
DUP #06 SFT #01 AND #01 NEQ ,&no-left JCN
2021-04-20 04:00:14 +00:00
( move )
.Screen/x DEI2 -- .Screen/x DEO2
;left_icn .Screen/addr DEO2 &no-left
2021-05-11 18:12:07 +00:00
DUP #07 SFT #01 AND #01 NEQ ,&no-right JCN
2021-04-20 04:00:14 +00:00
( move )
.Screen/x DEI2 ++ .Screen/x DEO2
;right_icn .Screen/addr DEO2 &no-right
2021-03-15 00:32:40 +00:00
POP
2021-03-14 01:34:08 +00:00
( draw face )
#31 .Screen/color DEO
2021-03-15 00:32:40 +00:00
2021-03-14 01:34:08 +00:00
( draw slime )
;slime_icn .Screen/addr DEO2
2021-05-11 18:14:52 +00:00
.slime LDZ .Screen/color DEO
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 ]
2021-04-20 21:30:26 +00:00