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

95 lines
1.9 KiB
Plaintext
Raw Normal View History

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