| ... | ... |
@@ -7,14 +7,11 @@ |
| 7 | 7 |
|
| 8 | 8 |
|0000 |
| 9 | 9 |
|
| 10 |
-@line |
|
| 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 |
|
| 16 |
-@pointer |
|
| 17 |
- &x $2 &y $2 &lastx $2 &lasty $2 &state $1 |
|
| 10 |
+ @line &x2 $2 &y2 $2 |
|
| 11 |
+ @length $2 |
|
| 12 |
+ @frame $2 |
|
| 13 |
+ @pen &x $2 &y $2 &x2 $2 &y2 $2 |
|
| 14 |
+ @pointer &x $2 &y $2 &lastx $2 &lasty $2 &state $1 |
|
| 18 | 15 |
|
| 19 | 16 |
|0100 ( -> ) |
| 20 | 17 |
|
| ... | ... |
@@ -27,8 +24,13 @@ |
| 27 | 24 |
;on-mouse .Mouse/vector DEO2 |
| 28 | 25 |
;on-frame .Screen/vector DEO2 |
| 29 | 26 |
|
| 27 |
+ draw-mouse |
|
| 28 |
+ |
|
| 30 | 29 |
BRK |
| 31 | 30 |
|
| 31 |
+( |
|
| 32 |
+@|vectors ) |
|
| 33 |
+ |
|
| 32 | 34 |
@on-frame ( -> ) |
| 33 | 35 |
|
| 34 | 36 |
.Mouse/state DEI ?&skip |
| ... | ... |
@@ -39,15 +41,17 @@ BRK |
| 39 | 41 |
|
| 40 | 42 |
@on-mouse ( -> ) |
| 41 | 43 |
|
| 42 |
- ;pointer-icn .Screen/addr DEO2 |
|
| 43 | 44 |
( clear last cursor ) |
| 44 | 45 |
.pointer/x LDZ2 .Screen/x DEO2 |
| 45 | 46 |
.pointer/y LDZ2 .Screen/y DEO2 |
| 46 | 47 |
[ LIT2 40 -Screen/sprite ] DEO |
| 48 |
+ draw-mouse |
|
| 47 | 49 |
( draw new cursor ) |
| 50 |
+ ;pointer-icn .Screen/addr DEO2 |
|
| 51 |
+ #00 .Screen/auto DEO |
|
| 48 | 52 |
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 |
| 49 | 53 |
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 |
| 50 |
- #42 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO |
|
| 54 |
+ #45 .Mouse/state DEI #00 NEQ #05 MUL ADD .Screen/sprite DEO |
|
| 51 | 55 |
( on down ) |
| 52 | 56 |
.Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU AND ?on-mouse-down |
| 53 | 57 |
( on drag ) |
| ... | ... |
@@ -74,7 +78,7 @@ BRK |
| 74 | 78 |
.pointer/x LDZ2 .pointer/lastx LDZ2 SUB2 STH2kr STA2 |
| 75 | 79 |
.pointer/y LDZ2 .pointer/lasty LDZ2 SUB2 STH2r INC2 INC2 STA2 |
| 76 | 80 |
( move ptr ) |
| 77 |
- .length LDZ2 INC2 .length STZ2 |
|
| 81 |
+ .length LDZ2 INC2 .length STZ2 |
|
| 78 | 82 |
( draw line ) |
| 79 | 83 |
.pointer/lastx LDZ2 |
| 80 | 84 |
.pointer/lasty LDZ2 |
| ... | ... |
@@ -82,18 +86,23 @@ BRK |
| 82 | 86 |
.pointer/y LDZ2 |
| 83 | 87 |
#01 draw-line |
| 84 | 88 |
( record last position ) |
| 85 |
- .Mouse/x DEI2 |
|
| 86 |
- DUP2 .pointer/lastx STZ2 |
|
| 89 |
+ .Mouse/x DEI2 |
|
| 90 |
+ DUP2 .pointer/lastx STZ2 |
|
| 87 | 91 |
DUP2 .pen/x STZ2 |
| 88 | 92 |
.pen/x2 STZ2 |
| 89 |
- .Mouse/y DEI2 |
|
| 90 |
- DUP2 .pointer/lasty STZ2 |
|
| 93 |
+ .Mouse/y DEI2 |
|
| 94 |
+ DUP2 .pointer/lasty STZ2 |
|
| 91 | 95 |
DUP2 .pen/y STZ2 |
| 92 | 96 |
.pen/y2 STZ2 |
| 93 |
- .Mouse/state DEI .pointer/state STZ |
|
| 97 |
+ .Mouse/state DEI |
|
| 98 |
+ DUP #01 NEQ INC ;run/color STA |
|
| 99 |
+ .pointer/state STZ |
|
| 94 | 100 |
|
| 95 | 101 |
BRK |
| 96 | 102 |
|
| 103 |
+( |
|
| 104 |
+@|main ) |
|
| 105 |
+ |
|
| 97 | 106 |
@run ( -- ) |
| 98 | 107 |
|
| 99 | 108 |
( read ) |
| ... | ... |
@@ -103,7 +112,7 @@ BRK |
| 103 | 112 |
( line ) |
| 104 | 113 |
.pen/x LDZ2 .pen/y LDZ2 |
| 105 | 114 |
.pen/x2 LDZ2 .pen/y2 LDZ2 |
| 106 |
- .frame LDZ2 #01 SFT2 NIP #01 AND INC draw-line |
|
| 115 |
+ .frame LDZ2 #01 SFT2 NIP #01 AND [ LIT &color $1 ] ADD INC draw-line |
|
| 107 | 116 |
( history ) |
| 108 | 117 |
.pen/x LDZ2 .pen/x2 STZ2 |
| 109 | 118 |
.pen/y LDZ2 .pen/y2 STZ2 |
| ... | ... |
@@ -112,31 +121,65 @@ BRK |
| 112 | 121 |
|
| 113 | 122 |
JMP2r |
| 114 | 123 |
|
| 124 |
+@draw-mouse ( -- ) |
|
| 125 |
+ |
|
| 126 |
+ ( clear ) |
|
| 127 |
+ #0010 |
|
| 128 |
+ DUP2 .Screen/x DEO2 |
|
| 129 |
+ .Screen/y DEO2 |
|
| 130 |
+ #16 .Screen/auto DEO |
|
| 131 |
+ #40 .Screen/sprite DEOk DEO |
|
| 132 |
+ ( buttons ) |
|
| 133 |
+ #0300 |
|
| 134 |
+ &l |
|
| 135 |
+ #01 OVR #40 SFT SFT .Mouse/state DEI AND #00 EQU ?&no-draw |
|
| 136 |
+ #0010 .Screen/y DEO2 |
|
| 137 |
+ #00 OVR #40 SFT2 ;button-icn ADD2 .Screen/addr DEO2 |
|
| 138 |
+ #45 .Screen/sprite DEO |
|
| 139 |
+ &no-draw |
|
| 140 |
+ INC GTHk ?&l |
|
| 141 |
+ POP2 |
|
| 142 |
+ ( outline ) |
|
| 143 |
+ #0010 .Screen/y DEO2 |
|
| 144 |
+ ;mouse-icn .Screen/addr DEO2 |
|
| 145 |
+ #16 .Screen/auto DEO |
|
| 146 |
+ #4a .Screen/sprite DEOk DEO |
|
| 147 |
+ |
|
| 148 |
+JMP2r |
|
| 149 |
+ |
|
| 115 | 150 |
@draw-line ( x1* y1* x2* y2* color -- ) |
| 116 | 151 |
|
| 117 |
- ( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2 |
|
| 118 |
- ,&x LDR2 .line/x LDZ2 SUB2 abs2 .line/dx STZ2 |
|
| 119 |
- #0000 ,&y LDR2 .line/y LDZ2 SUB2 abs2 SUB2 .line/dy STZ2 |
|
| 120 |
- #ffff #00 .line/x LDZ2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2 |
|
| 121 |
- #ffff #00 .line/y LDZ2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2 |
|
| 122 |
- .line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 |
|
| 152 |
+ ( load ) |
|
| 153 |
+ ,&color STR |
|
| 154 |
+ ,&y STR2 |
|
| 155 |
+ ,&x STR2 |
|
| 156 |
+ .line/y2 STZ2 |
|
| 157 |
+ .line/x2 STZ2 |
|
| 158 |
+ |
|
| 159 |
+ ,&x LDR2 .line/x2 LDZ2 SUB2 abs2 ,&dx STR2 |
|
| 160 |
+ #0000 ,&y LDR2 .line/y2 LDZ2 SUB2 abs2 SUB2 ,&dy STR2 |
|
| 161 |
+ |
|
| 162 |
+ #ffff #00 .line/x2 LDZ2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2 |
|
| 163 |
+ #ffff #00 .line/y2 LDZ2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2 |
|
| 164 |
+ |
|
| 165 |
+ [ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 ,&e1 STR2 |
|
| 166 |
+ |
|
| 123 | 167 |
&loop |
| 124 |
- .line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2 |
|
| 125 |
- .line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2 |
|
| 126 |
- STHkr .Screen/pixel DEO |
|
| 168 |
+ .line/x2 LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2 |
|
| 169 |
+ .line/y2 LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2 |
|
| 170 |
+ [ LIT2 &color $1 -Screen/pixel ] DEO |
|
| 127 | 171 |
AND ?&end |
| 128 |
- .line/e1 LDZ2 DUP2 ADD2 DUP2 |
|
| 129 |
- .line/dy LDZ2 lts2 ?&skipy |
|
| 130 |
- .line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 |
|
| 131 |
- .line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2 |
|
| 172 |
+ [ LIT2 &e1 $2 ] DUP2 ADD2 DUP2 |
|
| 173 |
+ ,&dy LDR2 lts2 ?&skipy |
|
| 174 |
+ ,&e1 LDR2 ,&dy LDR2 ADD2 ,&e1 STR2 |
|
| 175 |
+ .line/x2 LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x2 STZ2 |
|
| 132 | 176 |
&skipy |
| 133 |
- .line/dx LDZ2 gts2 ?&skipx |
|
| 134 |
- .line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2 |
|
| 135 |
- .line/y LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y STZ2 |
|
| 177 |
+ ,&dx LDR2 gts2 ?&skipx |
|
| 178 |
+ ,&e1 LDR2 ,&dx LDR2 ADD2 ,&e1 STR2 |
|
| 179 |
+ .line/y2 LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y2 STZ2 |
|
| 136 | 180 |
&skipx |
| 137 | 181 |
!&loop |
| 138 | 182 |
&end |
| 139 |
- POPr |
|
| 140 | 183 |
|
| 141 | 184 |
JMP2r |
| 142 | 185 |
|
| ... | ... |
@@ -146,6 +189,8 @@ JMP2r |
| 146 | 189 |
|
| 147 | 190 |
@clear-screen ( -- ) |
| 148 | 191 |
|
| 192 |
+ #00 .Screen/auto DEO |
|
| 193 |
+ |
|
| 149 | 194 |
.Screen/height DEI2 #03 SFT2 NIP #00 |
| 150 | 195 |
&y |
| 151 | 196 |
#00 OVR #30 SFT2 .Screen/y DEO2 |
| ... | ... |
@@ -160,8 +205,23 @@ JMP2r |
| 160 | 205 |
|
| 161 | 206 |
JMP2r |
| 162 | 207 |
|
| 163 |
-@pointer-icn |
|
| 164 |
- 80c0 e0f0 f8e0 1000 |
|
| 208 |
+@pointer-icn [ |
|
| 209 |
+ 80c0 e0f0 f8e0 1000 ] |
|
| 210 |
+@mouse-icn [ |
|
| 211 |
+ 000d 1212 1212 121d |
|
| 212 |
+ 00b0 4848 4848 48b8 |
|
| 213 |
+ 1010 1010 1008 0700 |
|
| 214 |
+ 0808 0808 0810 e000 ] |
|
| 215 |
+@button-icn [ |
|
| 216 |
+ 000c 1e1e 1e1e 1e0c |
|
| 217 |
+ 0000 0000 0000 0000 |
|
| 218 |
+ 0001 0303 0303 0301 |
|
| 219 |
+ 0080 c0c0 c0c0 c080 |
|
| 220 |
+ 0000 0000 0000 0000 |
|
| 221 |
+ 0030 7878 7878 7830 ] |
|
| 222 |
+ |
|
| 223 |
+( |
|
| 224 |
+@|memory ) |
|
| 165 | 225 |
|
| 166 | 226 |
@stroke |
| 167 | 227 |
|