mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-20 12:55:11 +00:00
184 lines
6.4 KiB
Text
184 lines
6.4 KiB
Text
( blank )
|
|
|
|
:dev/r fff8 ( std read port )
|
|
:dev/w fff9 ( std write port )
|
|
|
|
&Point2d { x 2 y 2 }
|
|
&Rect2d { x1 2 y1 2 x2 2 y2 2 }
|
|
|
|
;pos Point2d
|
|
;mouse Point2d
|
|
;rect Rect2d ;r1 Rect2d ;r2 Rect2d ;r3 Rect2d
|
|
|
|
;drag Point2d
|
|
|
|
;color 1 ;state 1 ;cursor 2
|
|
|
|
|0100 @RESET
|
|
|
|
#05 =dev/r ( set dev/read mouse )
|
|
#02 =dev/w ( set dev/write to sprite )
|
|
|
|
( create a rect )
|
|
#0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1
|
|
#0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1
|
|
#0048 #0048 #0080 #0098 =r3.y2 =r3.x2 =r3.y1 =r3.x1
|
|
|
|
BRK
|
|
|
|
|c000 @FRAME
|
|
|
|
( clear last cursor )
|
|
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR
|
|
( record mouse positions )
|
|
#00 IOR2 =mouse.x #02 IOR2 =mouse.y
|
|
( record mouse state )
|
|
#04 IOR #11 ADD =state
|
|
( detect click )
|
|
#04 IOR #01 NEQ ,no-click ROT JMP? POP2
|
|
,on-click JSR
|
|
@no-click
|
|
|
|
,cursor_icn =cursor
|
|
|
|
#02 =color
|
|
#00 IOR2 ( get x ) ~r1.x2 GTH2 ,outside0 ROT JMP? POP2
|
|
#00 IOR2 ( get x ) ~r1.x1 LTH2 ,outside0 ROT JMP? POP2
|
|
#02 IOR2 ( get y ) ~r1.y2 GTH2 ,outside0 ROT JMP? POP2
|
|
#02 IOR2 ( get y ) ~r1.y1 LTH2 ,outside0 ROT JMP? POP2
|
|
#03 =color
|
|
,hand_icn =cursor
|
|
@outside0
|
|
~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ,fill-rect JSR
|
|
,text1 ~r1.x1 ~r1.y2 #0001 ADD2 ,draw-label JSR
|
|
|
|
#02 =color
|
|
#00 IOR2 ( get x ) ~r2.x2 GTH2 ,outside1 ROT JMP? POP2
|
|
#00 IOR2 ( get x ) ~r2.x1 LTH2 ,outside1 ROT JMP? POP2
|
|
#02 IOR2 ( get y ) ~r2.y2 GTH2 ,outside1 ROT JMP? POP2
|
|
#02 IOR2 ( get y ) ~r2.y1 LTH2 ,outside1 ROT JMP? POP2
|
|
#03 =color
|
|
,hand_icn =cursor
|
|
@outside1
|
|
~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ,line-rect JSR
|
|
,text2 ~r2.x1 ~r2.y2 #0001 ADD2 ,draw-label JSR
|
|
|
|
#02 =color
|
|
#00 IOR2 ( get x ) ~r3.x2 GTH2 ,outside2 ROT JMP? POP2
|
|
#00 IOR2 ( get x ) ~r3.x1 LTH2 ,outside2 ROT JMP? POP2
|
|
#02 IOR2 ( get y ) ~r3.y2 GTH2 ,outside2 ROT JMP? POP2
|
|
#02 IOR2 ( get y ) ~r3.y1 LTH2 ,outside2 ROT JMP? POP2
|
|
#03 =color
|
|
,hand_icn =cursor
|
|
@outside2
|
|
~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ,line-rect JSR
|
|
,text3 ~r3.x1 ~r3.y2 #0001 ADD2 ,draw-label JSR
|
|
|
|
( draw mouse )
|
|
#02 =dev/w ( set dev/write to sprite )
|
|
~state ~cursor ~mouse.x ~mouse.y ,draw-sprite JSR
|
|
|
|
BRK
|
|
|
|
@on-click
|
|
|
|
#aa NOP
|
|
|
|
RTS
|
|
|
|
@draw-sprite
|
|
IOW2 ( y byte )
|
|
IOW2 ( x byte )
|
|
IOW2 ( sprite address )
|
|
IOW ( layer-color )
|
|
RTS
|
|
|
|
@fill-rect ( x1 y1 x2 y2 )
|
|
#01 =dev/w ( set dev/write to sprite )
|
|
=rect.y2 =rect.x2 ( stash x1 y1 ) =rect.y1 DUP2 WSR2 =rect.x1
|
|
@fill-rect-ver
|
|
RSW2 DUP2 =rect.x1 WSR2
|
|
@fill-rect-hor
|
|
( draw ) ~rect.x1 ~rect.y1 IOW2 IOW2 ~color IOW
|
|
( incr ) ~rect.x1 #0001 ADD2 DUP2 =rect.x1
|
|
~rect.x2 LTH2 ,fill-rect-hor ROT JMP? POP2
|
|
~rect.y1 #0001 ADD2 DUP2 =rect.y1
|
|
~rect.y2 LTH2 ,fill-rect-ver ROT JMP? POP2
|
|
RSW2 POP2
|
|
RTS
|
|
|
|
@line-rect ( x1 y1 x2 y2 )
|
|
#01 =dev/w ( set dev/write to sprite )
|
|
=rect.y2 =rect.x2 ( stash x1 y1 ) DUP2 WSR2 =rect.y1 DUP2 WSR2 =rect.x1
|
|
@line-rect-hor
|
|
( draw ) ~rect.x1 ~rect.y1 IOW2 IOW2 ~color IOW
|
|
( draw ) ~rect.x1 ~rect.y2 IOW2 IOW2 ~color IOW
|
|
( incr ) ~rect.x1 #0001 ADD2 DUP2 =rect.x1
|
|
~rect.x2 #0001 ADD2 LTH2 ,line-rect-hor ROT JMP? POP2
|
|
( restore rect.x1 rect.y1 ) RSW2 =rect.x1 RSW2 =rect.y1
|
|
@line-rect-ver
|
|
( incr ) ~rect.y1 #0001 ADD2 DUP2 =rect.y1
|
|
( draw ) ~rect.x1 ~rect.y1 IOW2 IOW2 ~color IOW
|
|
( draw ) ~rect.x2 ~rect.y1 IOW2 IOW2 ~color IOW
|
|
~rect.y2 #0001 SUB2 LTH2 ,line-rect-ver ROT JMP? POP2
|
|
RTS
|
|
|
|
@draw-label ( text x1 y1 )
|
|
#02 =dev/w ( set dev/write to sprite )
|
|
=pos.y =pos.x
|
|
@draw-label-loop
|
|
( draw ) ~pos.x ~pos.y IOW2 IOW2 DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 IOW2 ~color IOW
|
|
( incr ) #0001 ADD2
|
|
( incr ) ~pos.x #0008 ADD2 =pos.x
|
|
DUP2 LDR #00 NEQ ,draw-label-loop ROT JMP? POP2
|
|
POP2
|
|
RTS
|
|
|
|
@clear_icn [ 0000 0000 0000 0000 ]
|
|
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
|
|
@hand_icn [ 4040 4070 f8f8 f870 ]
|
|
|
|
@font ( spectrum-zx font )
|
|
[
|
|
0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
|
|
0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
|
|
007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
|
|
0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800
|
|
0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800
|
|
003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038
|
|
0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000
|
|
0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000
|
|
0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400
|
|
0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000
|
|
0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800
|
|
0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000
|
|
003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00
|
|
0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000
|
|
003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810
|
|
0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800
|
|
003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00
|
|
0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00
|
|
0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200
|
|
0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00
|
|
007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00
|
|
00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200
|
|
0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00
|
|
0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00
|
|
0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00
|
|
0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c
|
|
0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400
|
|
0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800
|
|
0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
|
|
0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
|
|
0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
|
|
0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
|
|
]
|
|
|
|
@text1 [ catapult ] <1 .00
|
|
@text2 [ helicopt ] <1 .00
|
|
@text3 [ submarin ] <1 .00
|
|
|
|
|d000 @ERROR BRK
|
|
|
|
|FFF0 [ e2af eab2 e652 ] ( palette )
|
|
|FFFA .RESET .FRAME .ERROR
|