2021-04-21 16:48:04 +00:00
|
|
|
( dev/mouse )
|
|
|
|
|
|
|
|
%RTN { JMP2r }
|
2021-04-23 03:44:38 +00:00
|
|
|
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }.
|
2021-04-22 21:29:48 +00:00
|
|
|
|
2021-04-21 16:48:04 +00:00
|
|
|
( devices )
|
|
|
|
|
|
|
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|
|
|
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|
|
|
|
|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|
|
|
|
|
|
|
|
|0000
|
|
|
|
|
2021-04-23 02:57:47 +00: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-22 18:08:06 +00:00
|
|
|
@color $1
|
2021-04-21 16:48:04 +00:00
|
|
|
|
|
|
|
( program )
|
|
|
|
|
|
|
|
|0100 ( -> )
|
|
|
|
|
|
|
|
( theme )
|
2021-04-23 03:44:38 +00:00
|
|
|
#f0f0 .System/r DEO2
|
|
|
|
#f00f .System/g DEO2
|
|
|
|
#f000 .System/b DEO2
|
2021-04-22 22:57:40 +00:00
|
|
|
( vectors )
|
2021-04-23 03:44:38 +00:00
|
|
|
;on-mouse .Mouse/vector DEO2
|
2021-04-21 16:48:04 +00:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-mouse ( -> )
|
|
|
|
|
|
|
|
;draw-cursor JSR2
|
2021-04-22 18:08:06 +00:00
|
|
|
( on down )
|
2021-04-23 03:44:38 +00:00
|
|
|
.Mouse/state DEI #00 NEQ .pointer/state PEK #00 EQU #0101 EQU2 ,on-mouse-down JNZ
|
2021-04-22 18:08:06 +00:00
|
|
|
( on drag )
|
2021-04-23 03:44:38 +00:00
|
|
|
.Mouse/state DEI #00 NEQ ,on-mouse-drag JNZ
|
|
|
|
.Mouse/state DEI .pointer/state POK
|
2021-04-22 18:08:06 +00:00
|
|
|
|
2021-04-21 16:48:04 +00:00
|
|
|
BRK
|
|
|
|
|
2021-04-22 18:08:06 +00:00
|
|
|
@on-mouse-down ( -> )
|
|
|
|
|
2021-04-22 21:29:48 +00:00
|
|
|
( record start position )
|
2021-04-23 03:44:38 +00:00
|
|
|
.Mouse/x DEI2 DUP2 .pointer/x POK2 .pointer/lastx POK2
|
|
|
|
.Mouse/y DEI2 DUP2 .pointer/y POK2 .pointer/lasty POK2
|
|
|
|
.Mouse/state DEI .pointer/state POK
|
2021-04-22 18:08:06 +00:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-mouse-drag ( -> )
|
|
|
|
|
2021-04-22 21:29:48 +00:00
|
|
|
( draw line )
|
2021-04-23 03:44:38 +00:00
|
|
|
.pointer/lastx PEK2
|
|
|
|
.pointer/lasty PEK2
|
|
|
|
.pointer/x PEK2
|
|
|
|
.pointer/y PEK2
|
|
|
|
#01 [ .Mouse/state DEI #10 EQU #02 MUL ADD ]
|
2021-04-22 22:57:40 +00:00
|
|
|
;draw-line JSR2
|
2021-04-22 18:08:06 +00:00
|
|
|
( record last position )
|
2021-04-23 03:44:38 +00:00
|
|
|
.Mouse/x DEI2 .pointer/lastx POK2
|
|
|
|
.Mouse/y DEI2 .pointer/lasty POK2
|
|
|
|
.Mouse/state DEI .pointer/state POK
|
2021-04-22 18:08:06 +00:00
|
|
|
|
|
|
|
BRK
|
|
|
|
|
2021-04-21 16:48:04 +00:00
|
|
|
@draw-cursor ( -- )
|
|
|
|
|
|
|
|
( clear last cursor )
|
2021-04-23 03:44:38 +00:00
|
|
|
;clear .Screen/addr DEO2
|
|
|
|
.pointer/x PEK2 .Screen/x DEO2
|
|
|
|
.pointer/y PEK2 .Screen/y DEO2
|
|
|
|
#30 .Screen/color DEO
|
2021-04-21 16:48:04 +00:00
|
|
|
( record pointer positions )
|
2021-04-23 03:44:38 +00:00
|
|
|
.Mouse/x DEI2 .pointer/x POK2
|
|
|
|
.Mouse/y DEI2 .pointer/y POK2
|
2021-04-21 16:48:04 +00:00
|
|
|
( draw new cursor )
|
2021-04-23 03:44:38 +00:00
|
|
|
;cursor .Screen/addr DEO2
|
|
|
|
.pointer/x PEK2 .Screen/x DEO2
|
|
|
|
.pointer/y PEK2 .Screen/y DEO2
|
2021-04-21 16:48:04 +00:00
|
|
|
( colorize on state )
|
2021-04-23 03:44:38 +00:00
|
|
|
#31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO
|
2021-04-21 16:48:04 +00:00
|
|
|
|
|
|
|
RTN
|
|
|
|
|
2021-04-22 22:57:40 +00:00
|
|
|
@draw-line ( x1 y1 x2 y2 color -- )
|
2021-04-22 18:08:06 +00:00
|
|
|
|
2021-04-23 03:44:38 +00:00
|
|
|
( load ) .color POK .line/y0 POK2 .line/x0 POK2 .line/y POK2 .line/x POK2
|
|
|
|
.line/x0 PEK2 .line/x PEK2 SUB2 ABS2 .line/dx POK2
|
|
|
|
.line/y0 PEK2 .line/y PEK2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy POK2
|
|
|
|
#ffff #00 .line/x PEK2 .line/x0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sx POK2
|
|
|
|
#ffff #00 .line/y PEK2 .line/y0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sy POK2
|
|
|
|
.line/dx PEK2 .line/dy PEK2 ADD2 .line/e1 POK2
|
2021-04-22 18:08:06 +00:00
|
|
|
&loop
|
2021-04-22 22:57:40 +00:00
|
|
|
( draw )
|
2021-04-23 03:44:38 +00:00
|
|
|
.line/x PEK2 .Screen/x DEO2
|
|
|
|
.line/y PEK2 .Screen/y DEO2
|
|
|
|
.color PEK .Screen/color DEO
|
|
|
|
.line/x PEK2 .line/x0 PEK2 EQU2 .line/y PEK2 .line/y0 PEK2 EQU2 #0101 EQU2 ,&end JNZ
|
|
|
|
.line/e1 PEK2 #0002 MUL2 .line/e2 POK2
|
|
|
|
.line/e2 PEK2 .line/dy PEK2 LTS2 ,&skipy JNZ
|
|
|
|
.line/e1 PEK2 .line/dy PEK2 ADD2 .line/e1 POK2
|
|
|
|
.line/x PEK2 .line/sx PEK2 ADD2 .line/x POK2
|
2021-04-22 18:08:06 +00:00
|
|
|
&skipy
|
2021-04-23 03:44:38 +00:00
|
|
|
.line/e2 PEK2 .line/dx PEK2 GTS2 ,&skipx JNZ
|
|
|
|
.line/e1 PEK2 .line/dx PEK2 ADD2 .line/e1 POK2
|
|
|
|
.line/y PEK2 .line/sy PEK2 ADD2 .line/y POK2
|
2021-04-22 18:08:06 +00:00
|
|
|
&skipx
|
|
|
|
,&loop JMP
|
|
|
|
&end
|
|
|
|
|
|
|
|
RTN
|
|
|
|
|
2021-04-23 02:57:47 +00:00
|
|
|
@clear [ 0000 0000 0000 0000 ]
|
2021-04-22 22:19:09 +00:00
|
|
|
@cursor [ 80c0 e0f0 f8e0 1000 ]
|