uxn/examples/drag.usm

119 lines
2.4 KiB
Plaintext
Raw Normal View History

2021-02-16 15:19:48 -05:00
( drag )
:dev/r fff8 ( std read port )
:dev/w fff9 ( std write port )
;drawx 2 ;drawy 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1
2021-02-16 18:34:55 -05:00
;touchx 2 ;touchy 2 ;down 1
2021-02-16 15:19:48 -05:00
|0100 @RESET
#05 =dev/r ( set dev/read mouse )
#01 =dev/w ( set dev/write to screen )
2021-02-17 00:36:51 -05:00
#02 =color ( starting color )
#0050 =w #0080 =h ( starting size )
,update JSR
2021-02-16 18:34:55 -05:00
2021-02-16 15:19:48 -05:00
BRK
|c000 @FRAME
( get touch )
2021-02-16 18:34:55 -05:00
#05 IOR #01 EQU ,on-touch ROT JMP? POP2
#05 IOR #10 EQU ,on-release ROT JMP? POP2
#01 ~down EQU ,on-drag ROT JMP? POP2
BRK
2021-02-16 15:19:48 -05:00
2021-02-16 18:34:55 -05:00
@on-touch
#01 =down
2021-02-17 00:36:51 -05:00
#03 =color
2021-02-16 18:34:55 -05:00
#00 IOR2 =touchx #02 IOR2 =touchy
,update JSR
BRK
2021-02-17 00:36:51 -05:00
2021-02-16 18:34:55 -05:00
@on-release
#00 =down
2021-02-17 00:36:51 -05:00
#01 =color
2021-02-16 18:34:55 -05:00
,update JSR
BRK
2021-02-16 20:03:24 -05:00
2021-02-17 00:36:51 -05:00
@on-drag
2021-02-16 18:34:55 -05:00
#00 IOR2 ~touchx SUBS2 ~x ADDS2 =x
#02 IOR2 ~touchy SUBS2 ~y ADDS2 =y
#00 IOR2 =touchx #02 IOR2 =touchy
,update JSR
BRK
2021-02-16 15:19:48 -05:00
2021-02-16 18:34:55 -05:00
@update
2021-02-17 00:36:51 -05:00
( draw ) ~x ~y ~w ~h ,linerect JSR
( draw ) #0000 ,rounds_chr ~x #0010 ADD2 ~y #0010 ADD2 ,drawsprite JSR
( draw ) #0100 ,eyeeye_chr ~x #0040 ADD2 ~y #0020 ADD2 ,drawsprite JSR
2021-02-16 18:34:55 -05:00
,redraw JSR
BRK
2021-02-16 15:19:48 -05:00
BRK
2021-02-16 20:03:24 -05:00
@putpixel
IOW2 ( y short )
IOW2 ( x short )
,color LDR IOW ( color byte )
#00 IOW ( redraw byte )
RTS
2021-02-16 15:19:48 -05:00
@fillrect
=h =w =y =x ( store values in variables )
~x =drawx ~y =drawy ( store draw pos in variables )
@fillrectrow
~x =drawx
@fillrectcol
( draw ) ~drawx ~drawy IOW2 IOW2 ~color IOW #00 IOW
~drawx #0001 ADD2 =drawx
~drawx ~w ~x ADD2 LTH2 ,fillrectcol ROT JMP? POP2
~drawy #0001 ADD2 =drawy
~drawy ~h ~y ADD2 LTH2 ,fillrectrow ROT JMP? POP2
RTS
2021-02-16 20:03:24 -05:00
@linerect
2021-02-17 00:36:51 -05:00
=h =w =y =x
~x =drawx ~y =drawy
2021-02-16 20:03:24 -05:00
@linerectcol
2021-02-17 00:36:51 -05:00
( draw ) ~x ~drawy ,putpixel JSR
( draw ) ~x ~w ADD2 ~drawy ,putpixel JSR
~drawy #0001 ADD2 =drawy
~drawy ~h ~y ADD2 LTH2 ,linerectcol ROT JMP? POP2
2021-02-16 20:03:24 -05:00
@linerectrow
2021-02-17 00:36:51 -05:00
( draw ) ~drawx ~y ,putpixel JSR
( draw ) ~drawx ~y ~h ADD2 ,putpixel JSR
~drawx #0001 ADD2 =drawx
~drawx ~w ~x ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2
2021-02-16 20:03:24 -05:00
RTS
2021-02-16 15:19:48 -05:00
@getmouse
#00 IOR2 ( get mouse x )
#02 IOR2 ( get mouse y )
RTS
2021-02-16 20:03:24 -05:00
@drawsprite
#02 =dev/w ( set dev/write to sprite )
IOW2 ( y short )
IOW2 ( x short )
IOW2 ( sprite address )
IOW2 ( redraw byte )
RTS
2021-02-16 15:19:48 -05:00
@redraw
2021-02-16 20:03:24 -05:00
#01 =dev/w ( set dev/write to sprite )
2021-02-16 15:19:48 -05:00
#0000 IOW2
#0000 IOW2
#00 IOW
#01 IOW
RTS
2021-02-16 20:03:24 -05:00
@rounds_chr [ 3844 92aa 9244 3800 0038 7c7c 7c38 0000 ]
@eyeeye_chr [ aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 ]
2021-02-16 15:19:48 -05:00
|d000 @ERROR BRK
2021-02-19 14:48:40 -05:00
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
2021-02-16 15:19:48 -05:00
|FFFA .RESET .FRAME .ERROR