... | ... |
@@ -9,18 +9,31 @@ |
9 | 9 |
|
10 | 10 |
@line |
11 | 11 |
&x $2 &y $2 &dx $2 &dy $2 &e1 $2 |
12 |
+@length $2 |
|
13 |
+@frame $2 |
|
14 |
+@pen |
|
15 |
+ &x $2 &y $2 &x2 $2 &y2 $2 |
|
12 | 16 |
@pointer |
13 | 17 |
&x $2 &y $2 &lastx $2 &lasty $2 &state $1 |
14 | 18 |
|
15 | 19 |
|0100 ( -> ) |
16 | 20 |
|
17 | 21 |
( theme ) |
18 |
- #a0f0 .System/r DEO2 |
|
19 |
- #40ff .System/g DEO2 |
|
20 |
- #60ff .System/b DEO2 |
|
22 |
+ #4cfd .System/r DEO2 |
|
23 |
+ #4cf3 .System/g DEO2 |
|
24 |
+ #dcf2 .System/b DEO2 |
|
21 | 25 |
|
22 | 26 |
( vectors ) |
23 | 27 |
;on-mouse .Mouse/vector DEO2 |
28 |
+ ;on-frame .Screen/vector DEO2 |
|
29 |
+ |
|
30 |
+BRK |
|
31 |
+ |
|
32 |
+@on-frame ( -> ) |
|
33 |
+ |
|
34 |
+ .Mouse/state DEI ,&skip JCN |
|
35 |
+ ;run DUP2 JSR2 JSR2 |
|
36 |
+ &skip |
|
24 | 37 |
|
25 | 38 |
BRK |
26 | 39 |
|
... | ... |
@@ -34,7 +47,7 @@ BRK |
34 | 47 |
( draw new cursor ) |
35 | 48 |
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 |
36 | 49 |
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 |
37 |
- #43 .Mouse/state DEI #00 NEQ DUP ADD SUB .Screen/sprite DEO |
|
50 |
+ #42 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO |
|
38 | 51 |
( on down ) |
39 | 52 |
.Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU AND ,on-mouse-down JCN |
40 | 53 |
( on drag ) |
... | ... |
@@ -45,6 +58,8 @@ BRK |
45 | 58 |
|
46 | 59 |
@on-mouse-down ( -> ) |
47 | 60 |
|
61 |
+ #0000 DUP2 .length STZ2 .frame STZ2 |
|
62 |
+ ;clear-screen JSR2 |
|
48 | 63 |
( record start position ) |
49 | 64 |
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .pointer/lastx STZ2 |
50 | 65 |
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .pointer/lasty STZ2 |
... | ... |
@@ -53,36 +68,65 @@ BRK |
53 | 68 |
BRK |
54 | 69 |
|
55 | 70 |
@on-mouse-drag ( -> ) |
56 |
- |
|
71 |
+ |
|
72 |
+ ( record ) |
|
73 |
+ ;stroke .length LDZ2 #20 SFT2 ADD2 STH2 |
|
74 |
+ .pointer/x LDZ2 .pointer/lastx LDZ2 SUB2 STH2kr STA2 |
|
75 |
+ .pointer/y LDZ2 .pointer/lasty LDZ2 SUB2 STH2r INC2 INC2 STA2 |
|
76 |
+ ( move ptr ) |
|
77 |
+ .length LDZ2 INC2 .length STZ2 |
|
57 | 78 |
( draw line ) |
58 | 79 |
.pointer/lastx LDZ2 |
59 | 80 |
.pointer/lasty LDZ2 |
60 | 81 |
.pointer/x LDZ2 |
61 | 82 |
.pointer/y LDZ2 |
62 |
- .Mouse/state DEI INC |
|
63 |
- ;draw-line JSR2 |
|
64 |
- |
|
83 |
+ #01 |
|
84 |
+ ;draw-line JSR2 |
|
65 | 85 |
( record last position ) |
66 |
- .Mouse/x DEI2 .pointer/lastx STZ2 |
|
67 |
- .Mouse/y DEI2 .pointer/lasty STZ2 |
|
86 |
+ .Mouse/x DEI2 |
|
87 |
+ DUP2 .pointer/lastx STZ2 |
|
88 |
+ DUP2 .pen/x STZ2 |
|
89 |
+ .pen/x2 STZ2 |
|
90 |
+ .Mouse/y DEI2 |
|
91 |
+ DUP2 .pointer/lasty STZ2 |
|
92 |
+ DUP2 .pen/y STZ2 |
|
93 |
+ .pen/y2 STZ2 |
|
68 | 94 |
.Mouse/state DEI .pointer/state STZ |
69 | 95 |
|
70 | 96 |
BRK |
71 | 97 |
|
98 |
+@run ( -- ) |
|
99 |
+ |
|
100 |
+ ( read ) |
|
101 |
+ ;stroke .frame LDZ2 #20 SFT2 ADD2 STH2 |
|
102 |
+ .pen/x LDZ2 STH2kr LDA2 ADD2 .pen/x STZ2 |
|
103 |
+ .pen/y LDZ2 STH2r INC2 INC2 LDA2 ADD2 .pen/y STZ2 |
|
104 |
+ ( line ) |
|
105 |
+ .pen/x LDZ2 .pen/y LDZ2 |
|
106 |
+ .pen/x2 LDZ2 .pen/y2 LDZ2 |
|
107 |
+ .frame LDZ2 #01 SFT2 NIP #01 AND INC ;draw-line JSR2 |
|
108 |
+ ( history ) |
|
109 |
+ .pen/x LDZ2 .pen/x2 STZ2 |
|
110 |
+ .pen/y LDZ2 .pen/y2 STZ2 |
|
111 |
+ ( incr frame ) |
|
112 |
+ .frame LDZ2 INC2 .length LDZ2 INC2 ( mod2 ) DIV2k MUL2 SUB2 .frame STZ2 |
|
113 |
+ |
|
114 |
+JMP2r |
|
115 |
+ |
|
72 | 116 |
@draw-line ( x1* y1* x2* y2* color -- ) |
73 | 117 |
|
74 | 118 |
( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2 |
75 | 119 |
,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2 |
76 | 120 |
#0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2 |
77 |
- #ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 #10 SFT2 ADD2 ,&sx STR2 |
|
78 |
- #ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 #10 SFT2 ADD2 ,&sy STR2 |
|
121 |
+ #ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2 |
|
122 |
+ #ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2 |
|
79 | 123 |
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 |
80 | 124 |
&loop |
81 | 125 |
.line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2 |
82 | 126 |
.line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2 |
83 | 127 |
STHkr .Screen/pixel DEO |
84 | 128 |
AND ,&end JCN |
85 |
- .line/e1 LDZ2 #10 SFT2 DUP2 |
|
129 |
+ .line/e1 LDZ2 DUP2 ADD2 DUP2 |
|
86 | 130 |
.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN |
87 | 131 |
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 |
88 | 132 |
.line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2 |
... | ... |
@@ -101,4 +145,24 @@ JMP2r |
101 | 145 |
@lts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r |
102 | 146 |
@gts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r |
103 | 147 |
|
104 |
-@pointer-icn 80c0 e0f0 f8e0 1000 |
|
148 |
+@clear-screen ( -- ) |
|
149 |
+ |
|
150 |
+ .Screen/height DEI2 #03 SFT2 NIP #00 |
|
151 |
+ &y |
|
152 |
+ #00 OVR #30 SFT2 .Screen/y DEO2 |
|
153 |
+ .Screen/width DEI2 #03 SFT2 NIP #00 |
|
154 |
+ &x |
|
155 |
+ #00 OVR #30 SFT2 .Screen/x DEO2 |
|
156 |
+ #00 .Screen/sprite DEO |
|
157 |
+ INC GTHk ,&x JCN |
|
158 |
+ POP2 |
|
159 |
+ INC GTHk ,&y JCN |
|
160 |
+ POP2 |
|
161 |
+ |
|
162 |
+JMP2r |
|
163 |
+ |
|
164 |
+@pointer-icn |
|
165 |
+ 80c0 e0f0 f8e0 1000 |
|
166 |
+ |
|
167 |
+@stroke |
|
168 |
+ |