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

126 lines
2.1 KiB
Plaintext
Raw Normal View History

2021-04-02 00:53:41 -04:00
( Dev/Controller )
2021-03-13 20:34:08 -05:00
2021-03-16 14:25:26 -04:00
%++ { #0001 ADD2 }
%-- { #0001 SUB2 }
%2/ { #0002 DIV2 }
2021-03-14 20:32:40 -04:00
2021-03-21 17:16:19 -04:00
( variables )
2021-04-19 20:23:30 -04:00
@slime [
&color 00
&end
]
2021-03-13 20:34:08 -05:00
2021-03-21 17:16:19 -04:00
( devices )
2021-04-19 20:23:30 -04:00
|0100 @System [
&vector 0000
&pad 0000
0000
0000
2021-04-20 00:00:14 -04:00
&r 0daf
&g 02ff
&b 035f
2021-04-19 20:23:30 -04:00
&end
]
2021-04-20 00:00:14 -04:00
|0110 @Console [
&pad 0000
0000
0000
0000
&char 00
&byte 00
&short 0000
&string 0000
&end
]
2021-04-19 20:23:30 -04:00
|0120 @Screen [
&vector 0000
&width 0000
&height 0000
&pad 0000
&x 0000
&y 0000
&addr 0000
&color 00
&end
]
2021-04-20 00:00:14 -04:00
2021-04-19 20:23:30 -04:00
|0140 @Controller [
&vector 0000
&button 00
&key 00
&end
]
2021-04-06 13:45:53 -04:00
|0200
2021-04-20 00:00:14 -04:00
( theme )
#0daf ,System/r STR2
#02ff ,System/g STR2
#035f ,System/b STR2
2021-03-28 14:20:36 -04:00
2021-04-20 00:00:14 -04:00
( vectors )
,on-frame ,Screen/vector STR2
2021-03-13 20:34:08 -05:00
( set origin )
2021-04-20 00:00:14 -04:00
,Screen/width LDR2 2/ ,Screen/x STR2
,Screen/height LDR2 2/ ,Screen/y STR2
,default_icn ,Screen/addr STR2
#31 ,Screen/color POK2
#2a ,slime/color POK2
2021-03-13 20:34:08 -05:00
BRK
2021-04-19 20:23:30 -04:00
@on-frame
2021-03-14 20:32:40 -04:00
2021-04-20 00:00:14 -04:00
#2a ,slime/color POK2
,default_icn ,Screen/addr STR2
2021-03-14 20:32:40 -04:00
2021-03-13 20:34:08 -05:00
( hold ctrl key to change slime color )
2021-04-20 00:00:14 -04:00
,Controller/button PEK2 #0f AND
DUP #01 NEQ ^&no-ctrl JNZ #25 ,slime/color POK2 &no-ctrl
DUP #02 NEQ ^&no-alt JNZ #2f ,slime/color POK2 &no-alt
2021-03-14 20:32:40 -04:00
POP
2021-04-20 00:00:14 -04:00
( clear ) #30 ,Screen/color POK2
2021-03-14 20:32:40 -04:00
( detect movement )
2021-04-20 00:00:14 -04:00
,Controller/button PEK2 #f0 AND
DUP #04 SFT #01 AND #01 NEQ ^&no-up JNZ
( move )
,Screen/y LDR2 -- ,Screen/y STR2
,up_icn ,Screen/addr STR2 &no-up
DUP #05 SFT #01 AND #01 NEQ ^&no-down JNZ
( move )
,Screen/y LDR2 ++ ,Screen/y STR2
,down_icn ,Screen/addr STR2 &no-down
DUP #06 SFT #01 AND #01 NEQ ^&no-left JNZ
( move )
,Screen/x LDR2 -- ,Screen/x STR2
,left_icn ,Screen/addr STR2 &no-left
DUP #07 SFT #01 AND #01 NEQ ^&no-right JNZ
( move )
,Screen/x LDR2 ++ ,Screen/x STR2
,right_icn ,Screen/addr STR2 &no-right
2021-03-14 20:32:40 -04:00
POP
2021-03-13 20:34:08 -05:00
( draw face )
2021-04-20 00:00:14 -04:00
#31 ,Screen/color POK2
2021-03-14 20:32:40 -04:00
2021-03-13 20:34:08 -05:00
( draw slime )
2021-04-20 00:00:14 -04:00
,slime_icn ,Screen/addr STR2
,slime/color PEK2 ,Screen/color POK2
2021-03-13 20:34:08 -05:00
2021-03-14 20:32:40 -04:00
BRK
2021-03-13 20:34:08 -05: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 ]