2021-04-21 12:48:04 -04:00
|
|
|
( dev/mouse )
|
|
|
|
|
2021-05-01 12:59:57 -04:00
|
|
|
%RTN { JMP2r }
|
2021-08-17 15:16:39 -04:00
|
|
|
%ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 }
|
2021-05-01 12:59:57 -04:00
|
|
|
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
|
|
|
|
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
|
2021-05-24 17:52:11 -04:00
|
|
|
%2** { #10 SFT2 }
|
2021-04-22 17:29:48 -04:00
|
|
|
|
2021-04-21 12:48:04 -04:00
|
|
|
( devices )
|
|
|
|
|
|
|
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
2021-07-31 16:58:33 -04:00
|
|
|
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|
2021-05-31 18:08:34 -04:00
|
|
|
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
|
2021-04-21 12:48:04 -04:00
|
|
|
|
|
|
|
|0000
|
|
|
|
|
2021-04-29 00:00:39 -04:00
|
|
|
@color $1
|
2021-04-22 22:57:47 -04:00
|
|
|
@line [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ]
|
|
|
|
@pointer [ &x $2 &y $2 &lastx $2 &lasty $2 &state $1 ]
|
2021-04-21 12:48:04 -04:00
|
|
|
|
|
|
|
( program )
|
|
|
|
|
|
|
|
|0100 ( -> )
|
|
|
|
|
|
|
|
( theme )
|
2021-04-29 00:00:39 -04:00
|
|
|
#f030 .System/r DEO2
|
|
|
|
#f04f .System/g DEO2
|
|
|
|
#f050 .System/b DEO2
|
|
|
|
|
2021-04-22 18:57:40 -04:00
|
|
|
( vectors )
|
2021-04-22 23:44:38 -04:00
|
|
|
;on-mouse .Mouse/vector DEO2
|
2021-04-21 12:48:04 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-mouse ( -> )
|
|
|
|
|
|
|
|
;draw-cursor JSR2
|
2021-04-29 00:00:39 -04:00
|
|
|
|
2021-04-22 14:08:06 -04:00
|
|
|
( on down )
|
2021-05-11 14:14:52 -04:00
|
|
|
.Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU #0101 EQU2 ,on-mouse-down JCN
|
2021-04-29 00:00:39 -04:00
|
|
|
|
2021-04-22 14:08:06 -04:00
|
|
|
( on drag )
|
2021-05-13 02:31:42 -04:00
|
|
|
.Mouse/state DEI ,on-mouse-drag JCN
|
2021-05-11 14:14:52 -04:00
|
|
|
.Mouse/state DEI .pointer/state STZ
|
2021-04-22 14:08:06 -04:00
|
|
|
|
2021-04-21 12:48:04 -04:00
|
|
|
BRK
|
|
|
|
|
2021-04-22 14:08:06 -04:00
|
|
|
@on-mouse-down ( -> )
|
|
|
|
|
2021-04-22 17:29:48 -04:00
|
|
|
( record start position )
|
2021-05-11 14:14:52 -04:00
|
|
|
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .pointer/lastx STZ2
|
|
|
|
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .pointer/lasty STZ2
|
|
|
|
.Mouse/state DEI .pointer/state STZ
|
2021-04-22 14:08:06 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-mouse-drag ( -> )
|
|
|
|
|
2021-04-22 17:29:48 -04:00
|
|
|
( draw line )
|
2021-05-11 14:14:52 -04:00
|
|
|
.pointer/lastx LDZ2
|
|
|
|
.pointer/lasty LDZ2
|
|
|
|
.pointer/x LDZ2
|
|
|
|
.pointer/y LDZ2
|
2021-08-17 15:16:39 -04:00
|
|
|
#01 [ .Mouse/state DEI #10 EQU DUP ADD ADD ]
|
2021-04-22 18:57:40 -04:00
|
|
|
;draw-line JSR2
|
2021-04-29 00:00:39 -04:00
|
|
|
|
2021-04-22 14:08:06 -04:00
|
|
|
( record last position )
|
2021-05-11 14:14:52 -04:00
|
|
|
.Mouse/x DEI2 .pointer/lastx STZ2
|
|
|
|
.Mouse/y DEI2 .pointer/lasty STZ2
|
|
|
|
.Mouse/state DEI .pointer/state STZ
|
2021-04-22 14:08:06 -04:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2021-04-21 12:48:04 -04:00
|
|
|
@draw-cursor ( -- )
|
|
|
|
|
2021-05-12 21:28:45 -04:00
|
|
|
;pointer_icn .Screen/addr DEO2
|
2021-04-21 12:48:04 -04:00
|
|
|
( clear last cursor )
|
2021-05-11 14:14:52 -04:00
|
|
|
.pointer/x LDZ2 .Screen/x DEO2
|
|
|
|
.pointer/y LDZ2 .Screen/y DEO2
|
2021-07-31 16:58:33 -04:00
|
|
|
#40 .Screen/sprite DEO
|
2021-04-29 00:00:39 -04:00
|
|
|
|
2021-04-21 12:48:04 -04:00
|
|
|
( record pointer positions )
|
2021-05-11 14:14:52 -04:00
|
|
|
.Mouse/x DEI2 .pointer/x STZ2
|
|
|
|
.Mouse/y DEI2 .pointer/y STZ2
|
2021-04-29 00:00:39 -04:00
|
|
|
|
2021-04-21 12:48:04 -04:00
|
|
|
( draw new cursor )
|
2021-05-11 14:14:52 -04:00
|
|
|
.pointer/x LDZ2 .Screen/x DEO2
|
|
|
|
.pointer/y LDZ2 .Screen/y DEO2
|
2021-08-17 15:16:39 -04:00
|
|
|
#43 .Mouse/state DEI #00 NEQ DUP ADD SUB .Screen/sprite DEO
|
2021-04-21 12:48:04 -04:00
|
|
|
|
|
|
|
RTN
|
|
|
|
|
2021-04-22 18:57:40 -04:00
|
|
|
@draw-line ( x1 y1 x2 y2 color -- )
|
2021-04-22 14:08:06 -04:00
|
|
|
|
2021-05-11 14:14:52 -04:00
|
|
|
( load ) .color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2
|
|
|
|
.line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2
|
|
|
|
.line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2
|
2021-05-24 17:52:11 -04:00
|
|
|
#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ADD2 .line/sx STZ2
|
|
|
|
#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ADD2 .line/sy STZ2
|
2021-05-11 14:14:52 -04:00
|
|
|
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
|
2021-04-22 14:08:06 -04:00
|
|
|
&loop
|
2021-05-11 14:14:52 -04:00
|
|
|
.line/x LDZ2 .Screen/x DEO2
|
|
|
|
.line/y LDZ2 .Screen/y DEO2
|
2021-07-31 16:58:33 -04:00
|
|
|
.color LDZ .Screen/pixel DEO
|
2021-05-11 14:14:52 -04:00
|
|
|
[ .line/x LDZ2 .line/x0 LDZ2 EQU2 ]
|
|
|
|
[ .line/y LDZ2 .line/y0 LDZ2 EQU2 ] #0101 EQU2 ,&end JCN
|
2021-05-24 17:52:11 -04:00
|
|
|
.line/e1 LDZ2 2** .line/e2 STZ2
|
2021-05-11 14:14:52 -04:00
|
|
|
.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
|
|
|
|
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
|
|
|
|
.line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2
|
2021-04-22 14:08:06 -04:00
|
|
|
&skipy
|
2021-05-11 14:14:52 -04:00
|
|
|
.line/e2 LDZ2 .line/dx LDZ2 GTS2 ,&skipx JCN
|
|
|
|
.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
|
|
|
|
.line/y LDZ2 .line/sy LDZ2 ADD2 .line/y STZ2
|
2021-04-22 14:08:06 -04:00
|
|
|
&skipx
|
2021-05-01 12:59:57 -04:00
|
|
|
;&loop JMP2
|
2021-04-22 14:08:06 -04:00
|
|
|
&end
|
|
|
|
|
|
|
|
RTN
|
|
|
|
|
2021-04-29 00:00:39 -04:00
|
|
|
@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
|