0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-08 07:15:04 +00:00
uxn/examples/devmousedrag.usm
2021-02-20 14:07:20 -08:00

112 lines
2.9 KiB
Text

( drag )
:dev/r fff8 ( std read port )
:dev/w fff9 ( std write port )
;dragx 2 ;dragy 2
;mousex 2 ;mousey 2
;lastx 2 ;lasty 2
;originx 2 ;originy 2
;down 1 ;state 1
|0100 @RESET
#05 =dev/r ( set dev/read mouse )
#02 =dev/w ( set dev/write to sprite )
,draw-picture JSR
BRK
|c000 @FRAME
( 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
( get touch )
#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
@on-touch
#01 =down
#00 IOR2 =originx #02 IOR2 =originy
,update JSR
BRK
@on-release
#00 =down
,update JSR
BRK
@on-drag
#00 IOR2 ~originx SUBS2 ~dragx ADDS2 =dragx
#02 IOR2 ~originy SUBS2 ~dragy ADDS2 =dragy
#00 IOR2 =originx #02 IOR2 =originy
,update JSR
BRK
@update
,draw-picture JSR
BRK
@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
RTS
@draw-sprite
IOW2 ( y byte )
IOW2 ( x byte )
IOW2 ( sprite address )
IOW ( layer-color )
RTS
@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
]
|d000 @ERROR BRK
|FFF0 [ f0ac f0bb f053 ] ( palette )
|FFFA .RESET .FRAME .ERROR ( vectors )