0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-10 16:25:05 +00:00
uxn/examples/dev.ctrl.usm

79 lines
1.9 KiB
Text

( dev/ctrl )
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
&Controller { buttons 1 }
;slime-color 1
|0100 @RESET
( set origin )
~dev/screen.width #0002 DIV2 =dev/sprite.x
~dev/screen.height #0002 DIV2 =dev/sprite.y
,default_icn =dev/sprite.addr
#11 =dev/sprite.color
#0a =slime-color
BRK
|c000 @FRAME
#0a =slime-color
( hold ctrl key to change slime color )
,no-ctrl ~dev/ctrl.buttons #0f AND #01 NEQ JMP? POP2
#05 =slime-color
@no-ctrl
( hold alt key to change slime color )
,no-alt ~dev/ctrl.buttons #0f AND #02 NEQ JMP? POP2
#0f =slime-color
@no-alt
( detect movement )
,no-up ~dev/ctrl.buttons #f0 AND #10 NEQ JMP? POP2
( clear ) #10 =dev/sprite.color
( move ) ~dev/sprite.y #0001 SUB2 =dev/sprite.y ,up_icn =dev/sprite.addr
( draw ) ,redraw JSR BRK
@no-up
,no-down ~dev/ctrl.buttons #f0 AND #20 NEQ JMP? POP2
( clear ) #10 =dev/sprite.color
( move ) ~dev/sprite.y #0001 ADD2 =dev/sprite.y ,down_icn =dev/sprite.addr
( draw ) ,redraw JSR BRK
@no-down
,no-left ~dev/ctrl.buttons #f0 AND #40 NEQ JMP? POP2
( clear ) #10 =dev/sprite.color
( move ) ~dev/sprite.x #0001 SUB2 =dev/sprite.x ,left_icn =dev/sprite.addr
( draw ) ,redraw JSR BRK
@no-left
,no-right ~dev/ctrl.buttons #f0 AND #80 NEQ JMP? POP2
( clear ) #10 =dev/sprite.color
( move ) ~dev/sprite.x #0001 ADD2 =dev/sprite.x ,right_icn =dev/sprite.addr
( draw ) ,redraw JSR BRK
@no-right
BRK
@redraw
( draw face )
#11 =dev/sprite.color
( draw slime )
,slime_icn =dev/sprite.addr
~slime-color =dev/sprite.color
RTS
@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 ]
|d000 @ERROR BRK
|FF10 ;dev/screen Screen
|FF20 ;dev/sprite Sprite
|FF30 ;dev/ctrl Controller
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 0daf 02ff 035f ] ( palette )