uxn/examples/devmousedrag.usm

113 lines
2.9 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 )
2021-02-19 23:21:37 -05:00
;dragx 2 ;dragy 2
;mousex 2 ;mousey 2
;lastx 2 ;lasty 2
;originx 2 ;originy 2
;down 1 ;state 1
2021-02-16 15:19:48 -05:00
|0100 @RESET
#05 =dev/r ( set dev/read mouse )
2021-02-19 23:21:37 -05:00
#02 =dev/w ( set dev/write to sprite )
,draw-picture JSR
2021-02-16 18:34:55 -05:00
2021-02-16 15:19:48 -05:00
BRK
|c000 @FRAME
2021-02-19 23:21:37 -05:00
( clear last cursor )
#10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR
( record mouse values )
#00 IOR2 =mousex #02 IOR2 =mousey
#04 IOR #11 ADD =state
( draw mouse )
~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR
( update last pos )
~mousex =lastx ~mousey =lasty
2021-02-16 15:19:48 -05:00
( 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
2021-02-19 23:21:37 -05:00
2021-02-16 18:34:55 -05:00
BRK
2021-02-16 15:19:48 -05:00
2021-02-16 18:34:55 -05:00
@on-touch
#01 =down
2021-02-19 23:21:37 -05:00
#00 IOR2 =originx #02 IOR2 =originy
2021-02-16 18:34:55 -05:00
,update JSR
BRK
2021-02-17 00:36:51 -05:00
2021-02-16 18:34:55 -05:00
@on-release
#00 =down
,update JSR
BRK
2021-02-16 20:03:24 -05:00
2021-02-17 00:36:51 -05:00
@on-drag
2021-02-19 23:21:37 -05:00
#00 IOR2 ~originx SUBS2 ~dragx ADDS2 =dragx
#02 IOR2 ~originy SUBS2 ~dragy ADDS2 =dragy
#00 IOR2 =originx #02 IOR2 =originy
2021-02-16 18:34:55 -05:00
,update JSR
BRK
2021-02-16 15:19:48 -05:00
2021-02-16 18:34:55 -05:00
@update
2021-02-19 23:21:37 -05:00
,draw-picture JSR
2021-02-16 15:19:48 -05:00
BRK
2021-02-19 23:21:37 -05:00
@draw-picture
#01 ,graphic #0040 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0008 ADD2 #0048 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0010 ADD2 #0050 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0018 ADD2 #0058 ~dragx ADD2 #0040 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0020 ADD2 #0040 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0028 ADD2 #0048 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0030 ADD2 #0050 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0038 ADD2 #0058 ~dragx ADD2 #0048 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0040 ADD2 #0040 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0048 ADD2 #0048 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0050 ADD2 #0050 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0058 ADD2 #0058 ~dragx ADD2 #0050 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0060 ADD2 #0040 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0068 ADD2 #0048 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0070 ADD2 #0050 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR
#01 ,graphic #0078 ADD2 #0058 ~dragx ADD2 #0058 ~dragy ADD2 ,draw-sprite JSR
2021-02-16 20:03:24 -05:00
RTS
2021-02-19 23:21:37 -05:00
@draw-sprite
IOW2 ( y byte )
IOW2 ( x byte )
2021-02-16 20:03:24 -05:00
IOW2 ( sprite address )
2021-02-19 23:21:37 -05:00
IOW ( layer-color )
2021-02-16 15:19:48 -05:00
RTS
2021-02-19 23:21:37 -05:00
@clear_icn [ 0000 0000 0000 0000 ]
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
@graphic [
ff80 8080 8080 8088
ffff fffc f8f9 f1f4
ffff 0010 c721 2120
ffff 3f0f 0717 c343
8888 8080 8080 8080
f0f1 f2f5 f2f1 f0f4
1208 804c 9212 4c00
7303 0343 1b1b fbfb
8080 8f83 8383 8393
f0f3 f1f0 e4c0 80ff
00c7 c7c6 4606 00ff
c3d3 c307 870f 3fff
8f83 8383 8383 83ff
fff7 fdff c0e2 f1ff
7fef bfff 07af 5fff
ffff ffff ffff ffff
]
2021-02-16 20:03:24 -05:00
2021-02-16 15:19:48 -05:00
|d000 @ERROR BRK
2021-02-19 23:21:37 -05:00
|FFF0 [ f0ac f0bb f053 ] ( palette )
|FFFA .RESET .FRAME .ERROR ( vectors )