0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-01 03:52:39 +00:00
uxn/projects/examples/dev.controller.usm
2021-04-01 21:53:41 -07:00

83 lines
1.7 KiB
Text

( Dev/Controller )
%++ { #0001 ADD2 }
%-- { #0001 SUB2 }
%2/ { #0002 DIV2 }
( variables )
;slime { color 1 }
( devices )
|0100 ;Console { pad 8 char 1 byte 1 short 2 }
|0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|0130 ;Controller { p1 1 }
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|0200 ^RESET JMP
|0204 ,ERROR JMP2
|0208 ,FRAME JMP2
@RESET
( theme ) #0daf =System.r #02ff =System.g #035f =System.b
( set origin )
~Screen.width 2/ =Sprite.x
~Screen.height 2/ =Sprite.y
,default_icn =Sprite.addr
#11 =Sprite.color
#0a =slime
BRK
@FRAME
~Controller.p1 ,on-ctrl-arrows JNZ2
BRK
@on-ctrl-arrows
#0a =slime
,default_icn =Sprite.addr
( hold ctrl key to change slime color )
~Controller.p1 #0f AND
DUP #01 NEQ ^$no-ctrl JNZ #05 =slime $no-ctrl
DUP #02 NEQ ^$no-alt JNZ #0f =slime $no-alt
POP
( clear ) #10 =Sprite.color
( detect movement )
~Controller.p1 #f0 AND
DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ
( move ) ~Sprite.y -- =Sprite.y ,up_icn =Sprite.addr $no-up
DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ
( move ) ~Sprite.y ++ =Sprite.y ,down_icn =Sprite.addr $no-down
DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ
( move ) ~Sprite.x -- =Sprite.x ,left_icn =Sprite.addr $no-left
DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ
( move ) ~Sprite.x ++ =Sprite.x ,right_icn =Sprite.addr $no-right
POP
( draw face )
#11 =Sprite.color
( draw slime )
,slime_icn =Sprite.addr
~slime =Sprite.color
BRK
@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 ]
@ERROR BRK