uxn/examples/mouse.usm

47 lines
674 B
Plaintext
Raw Normal View History

2021-02-09 20:22:52 -05:00
( draw pixel )
|0100 @RESET
( draw 3 pixels )
,00 ,01 ,0000 ,0000 ,putpixel JSR
,00 ,02 ,0001 ,0001 ,putpixel JSR
,01 ,03 ,0002 ,0002 ,putpixel JSR
BRK
|c000 @FRAME
2021-02-09 20:43:53 -05:00
( get mouse button, or break )
,02 ,02 IOR
,01 NEQ
BRK?
( print A to console on click )
,02 ,02 IOR
,41 ADD
,putbyte JSR
( paint a white pixel )
,01 ,01
,getmouse JSR
2021-02-09 20:22:52 -05:00
,putpixel JSR
BRK
@putpixel
SWP ,01 IOW ,01 IOW ( y )
SWP ,01 IOW ,01 IOW ( x )
,01 IOW ( color )
,01 IOW ( redraw )
RTS
2021-02-09 20:43:53 -05:00
@getmouse ( push y,x to stack )
,00 ,01 ,02 IOR ( grab y )
,00 ,00 ,02 IOR ( grab x )
RTS
@putbyte ( print to console )
,00 IOW RTS
2021-02-09 20:22:52 -05:00
|d000 @ERROR BRK
|FFFA .RESET .FRAME .ERROR