0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-05 22:05:04 +00:00
uxn/examples/dev.mouse.usm

134 lines
3.7 KiB
Text
Raw Normal View History

2021-02-20 22:07:20 +00:00
( mouse )
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
2021-02-27 00:53:09 +00:00
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
&Mouse { x 2 y 2 state 1 chord 1 }
2021-02-20 22:07:20 +00:00
2021-02-24 01:57:57 +00:00
&Point2d { x 2 y 2 }
;cat Point2d ;mouse Point2d
2021-02-24 01:57:57 +00:00
;timer 1
2021-02-20 22:07:20 +00:00
|0100 @RESET
2021-02-24 01:57:57 +00:00
( position cat )
~dev/screen.width #0002 DIV2 =cat.x
~dev/screen.height #0038 SUB2 =cat.y
2021-02-20 22:07:20 +00:00
( draw polycat )
,draw-polycat JSR
BRK
|c000 @FRAME
2021-02-20 22:07:20 +00:00
( clear last cursor )
2021-02-24 01:57:57 +00:00
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR
2021-02-20 22:07:20 +00:00
( record mouse positions )
~dev/mouse.x =mouse.x ~dev/mouse.y =mouse.y
2021-02-21 01:14:36 +00:00
( detect click )
~dev/mouse.state #01 NEQ ,no-click ROT JMP? POP2
2021-02-20 22:07:20 +00:00
#50 =timer
@no-click
( draw mouse )
~dev/mouse.state #11 ADD ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR
2021-02-20 22:07:20 +00:00
( animate )
,animate-polycat JSR
( update last pos )
~timer #01 ADD =timer
BRK
@draw-polycat
( ears )
2021-02-24 01:57:57 +00:00
,polycat ~cat.x ~cat.y ,draw-sprite-chr JSR
,polycat #0010 ADD2 ~cat.x #0008 ADD2 ~cat.y ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
( eye )
2021-02-24 01:57:57 +00:00
,polycat #0020 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
( body )
2021-02-24 01:57:57 +00:00
,polycat #00a0 ADD2 ~cat.x ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
RTS
@animate-polycat
( tail )
~timer #50 NEQ ,animate-polycat-tail-next0 ROT JMP? POP2
2021-02-24 01:57:57 +00:00
,polycat #00c0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
@animate-polycat-tail-next0
~timer #58 NEQ ,animate-polycat-tail-next1 ROT JMP? POP2
2021-02-24 01:57:57 +00:00
,polycat #00d0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
@animate-polycat-tail-next1
~timer #60 NEQ ,animate-polycat-tail-next2 ROT JMP? POP2
2021-02-24 01:57:57 +00:00
,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
@animate-polycat-tail-next2
( look-at )
2021-02-24 01:57:57 +00:00
~mouse.x ~cat.x #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP? POP2
2021-02-20 22:07:20 +00:00
@animate-polycat-left
2021-02-24 01:57:57 +00:00
~mouse.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP? POP2
2021-02-20 22:07:20 +00:00
@animate-polycat-left-up
2021-02-24 01:57:57 +00:00
,polycat #0040 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0050 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
RTS
@animate-polycat-left-down
2021-02-24 01:57:57 +00:00
,polycat #0020 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
RTS
@animate-polycat-right
2021-02-24 01:57:57 +00:00
~mouse.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP? POP2
2021-02-20 22:07:20 +00:00
@animate-polycat-right-up
2021-02-24 01:57:57 +00:00
,polycat #0060 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0070 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
RTS
@animate-polycat-right-down
2021-02-24 01:57:57 +00:00
,polycat #0080 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
,polycat #0090 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR
2021-02-20 22:07:20 +00:00
RTS
RTS
@draw-sprite
=dev/sprite.y
2021-02-27 00:53:09 +00:00
=dev/sprite.x
=dev/sprite.addr
=dev/sprite.color
2021-02-20 22:07:20 +00:00
RTS
@draw-sprite-chr
=dev/sprite.y
2021-02-27 00:53:09 +00:00
=dev/sprite.x
=dev/sprite.addr
#20 =dev/sprite.color
2021-02-20 22:07:20 +00:00
RTS
@clear_icn [ 0000 0000 0000 0000 ]
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
@polycat [
2021-02-20 23:00:34 +00:00
081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc
2021-02-20 22:07:20 +00:00
081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f
ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f
ffff ffff fffe fcf0 0783 c1c3 871e fcf0
ffff ffff ff7f 3f0f f7ef cfe7 f07c 3f0f
ffff ffff fffe fcf0 87c3 c183 071e fcf0
ffff ffff ff7f 3f0f f0e1 c1e0 f07c 3f0f
ffff ffff fffe fcf0 f7fb f9f3 071e fcf0
ffff ffff ff7f 3f0f f0e0 c1e1 f07c 3f0f
ffff ffff fffe fcf0 07f3 f9fb f71e fcf0
0307 0707 0302 0200 0307 0707 0300 0000
c0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
c0f0 f0e0 e080 8000 c0f2 faf9 fef8 b000
c0f0 f0e0 e080 8000 c0f1 faf9 fef8 b000
]
|FF10 ;dev/screen Screen
|FF20 ;dev/sprite Sprite
|FF50 ;dev/mouse Mouse
2021-02-20 22:07:20 +00:00
|d000 @ERROR BRK
|FFF0 [ 0f85 0fd5 0fb5 ] ( palette )
|FFFA .RESET .FRAME .ERROR