uxn/examples/mouse.usm

47 lines
674 B
Plaintext

( 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
( 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
,putpixel JSR
BRK
@putpixel
SWP ,01 IOW ,01 IOW ( y )
SWP ,01 IOW ,01 IOW ( x )
,01 IOW ( color )
,01 IOW ( redraw )
RTS
@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
|d000 @ERROR BRK
|FFFA .RESET .FRAME .ERROR