uxn/examples/dev.ctrl.usm

68 lines
1.3 KiB
Plaintext

( controller )
&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 }
&Point2d { x 2 y 2 }
;pos Point2d
;sprite 2
|0100 @RESET
( set origin )
~dev/screen.width #0002 DIV2 =pos.x
~dev/screen.height #0002 DIV2 =pos.y
#12 ,up_icn ~pos.y ~pos.x ,draw-sprite JSR
BRK
|c000 @FRAME
,default_icn =sprite
~dev/ctrl.buttons #10 NEQ ,next1 ROT JMP? POP2
,up_icn =sprite
~pos.y #0001 SUB2 =pos.y
@next1
~dev/ctrl.buttons #20 NEQ ,next2 ROT JMP? POP2
,down_icn =sprite
~pos.y #0001 ADD2 =pos.y
@next2
~dev/ctrl.buttons #40 NEQ ,next3 ROT JMP? POP2
,left_icn =sprite
~pos.x #0001 SUB2 =pos.x
@next3
~dev/ctrl.buttons #80 NEQ ,end ROT JMP? POP2
,right_icn =sprite
~pos.x #0001 ADD2 =pos.x
@end
( redraw )
#13 ~sprite ~pos.y ~pos.x ,draw-sprite JSR
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 ]
@draw-sprite
=dev/sprite.x
=dev/sprite.y
=dev/sprite.addr
=dev/sprite.color
RTS
|d000 @ERROR BRK
|FF10 ;dev/screen Screen
|FF20 ;dev/sprite Sprite
|FF30 ;dev/ctrl Controller
|FFF0 [ 02ac 05bb 0b53 ] ( palette )
|FFFA .RESET .FRAME .ERROR