Browse code

Cleaned a few examples

neauoire authored on 29/04/2021 04:00:39
Showing 12 changed files
... ...
@@ -38,7 +38,7 @@ Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html).
38 38
 	
39 39
 BRK
40 40
 
41
-@print ( addr -- )
41
+@print ( addr* -- )
42 42
 	
43 43
 	&loop
44 44
 		( send ) DUP2 GET .Console/char DEO
... ...
@@ -14,7 +14,7 @@
14 14
 
15 15
 |00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
16 16
 |20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr $2 &color $1 ]
17
-|90 @Mouse      [ &vector $2 &x        $2 &y      $2 &state $1 &chord $1 ]
17
+|90 @Mouse      [ &vector $2 &x        $2 &y      $2 &state $1 &chord  $1 ]
18 18
 |b0 @DateTime   [ &year   $2 &month    $1 &day    $1 &hour  $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
19 19
 
20 20
 ( variables )
... ...
@@ -54,6 +54,7 @@ BRK
54 54
 
55 55
 	( only draw once per second )
56 56
 	.DateTime/second DEI .last PEK NEQ #01 JNZ [ BRK ]
57
+
57 58
 	.DateTime/second DEI .last POK
58 59
 
59 60
 	;redraw JSR2
... ...
@@ -144,7 +145,7 @@ RTN
144 145
 @draw-cursor ( -- )
145 146
 	
146 147
 	( clear last cursor )
147
-	;clear .Screen/addr DEO2 
148
+	#fff8 .Screen/addr DEO2 
148 149
 	.pointer/x PEK2 .Screen/x DEO2 
149 150
 	.pointer/y PEK2 .Screen/y DEO2 
150 151
 	#30 .Screen/color DEO
... ...
@@ -160,13 +161,14 @@ RTN
160 161
 
161 162
 RTN
162 163
 
163
-@clear  [ 
164
-	0000 0000 0000 0000 ]
165 164
 @cursor [ 
166 165
 	80c0 e0f0 f8e0 1000 ]
166
+
167 167
 @digits [
168
-	7b6f 2492 73e7 73cf 5bc9 
169
-	79cf 49ef 7249 7bef 7bc9 ]
168
+	7b6f 2492 73e7 73cf 
169
+	5bc9 79cf 49ef 7249 
170
+	7bef 7bc9 ]
171
+
170 172
 @tiles [
171 173
 	0102 0408 1020 4080
172 174
 	8040 2010 0804 0201 
... ...
@@ -5,27 +5,26 @@
5 5
 %2/  { #0001 SFT2 }
6 6
 %8+  { #0008 ADD2 }
7 7
 %STEP8 { #0033 SFT2 }
8
-%S2B { SWP POP }
9 8
 
10 9
 ( devices )
11 10
 
12
-|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
13
-|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
14
-|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
11
+|00 @System [ &vector $2 &pad   $6 &r      $2 &g     $2 &b     $2 ]
12
+|20 @Screen [ &vector $2 &width $2 &height $2 &pad   $2 &x     $2 &y $2 &addr $2 &color $1 ]
13
+|90 @Mouse  [ &vector $2 &x     $2 &y      $2 &state $1 &chord $1 ]
15 14
 
16 15
 ( variables )
17 16
 
18 17
 |0000
19 18
 
20
-@center [ &x $2 &y $2 ]
21
-@color [ &byte $1 ]
22
-@pointer [ &x $2 &y $2 &sprite $2 ]
23
-@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
24
-@window [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &w $2 &h $2 ]
25
-@label [ &x $2 &y $2 &addr $2 ]
26
-@slider [ &x1 $2 &y $2 &x2 $2 &pos $2 ]
27
-@selection [ &byte $1 ]
28
-@addr [ &byte $1 ]
19
+@color     $1
20
+@selection $1
21
+
22
+@center  [ &x $2 &y $2 ]
23
+@pointer [ &x $2 &y $2 ]
24
+@rect    [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
25
+@window  [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &w $2 &h $2 ]
26
+@slider  [ &x1 $2 &y $2 &x2 $2 &pos $2 ]
27
+
29 28
 @theme [
30 29
 	&r1 $1 &r2 $1 &r3 $1 &r4 $1
31 30
 	&g1 $1 &g2 $1 &g3 $1 &g4 $1
... ...
@@ -34,18 +33,23 @@
34 33
 
35 34
 ( program )
36 35
 
37
-|0100
36
+|0100 ( -> )
37
+
38
+	( theme ) 
39
+	#027f .System/r DEO2 
40
+	#04e7 .System/g DEO2 
41
+	#06c4 .System/b DEO2
38 42
 
39
-	( theme ) #127f .System/r DEO2 #34e7 .System/g DEO2 #56c4 .System/b DEO2
40
-	( vectors ) ;on-mouse .Mouse/vector DEO2
43
+	( vectors ) 
44
+	;on-mouse .Mouse/vector DEO2
41 45
 	
46
+	( size window )
42 47
 	#00b0 .window/w POK2
43 48
 	#0050 .window/h POK2
44 49
 
45 50
 	( center window )
46
-
47
-	.Screen/width DEI2 #0002 DIV2 .window/w PEK2 #0002 DIV2 SUB2 .window/x1 POK2
48
-	.Screen/height DEI2 #0002 DIV2 .window/h PEK2 #0002 DIV2 SUB2 .window/y1 POK2
51
+	.Screen/width DEI2 2/ .window/w PEK2 2/ SUB2 .window/x1 POK2
52
+	.Screen/height DEI2 2/ .window/h PEK2 2/ SUB2 .window/y1 POK2
49 53
 
50 54
 	#01 .theme/r1 POK #02 .theme/g1 POK #03 .theme/b1 POK
51 55
 	#04 .theme/r2 POK #06 .theme/g2 POK #07 .theme/b2 POK
... ...
@@ -53,8 +57,8 @@
53 57
 	#0c .theme/r4 POK #0b .theme/g4 POK #0d .theme/b4 POK
54 58
 
55 59
 	( find screen center )
56
-	.Screen/width DEI2 #0002 DIV2 .center/x POK2
57
-	.Screen/height DEI2 #0002 DIV2 .center/y POK2
60
+	.Screen/width DEI2 2/ .center/x POK2
61
+	.Screen/height DEI2 2/ .center/y POK2
58 62
 
59 63
 	;update-theme JSR2
60 64
 	;draw-background JSR2
... ...
@@ -62,35 +66,33 @@
62 66
 
63 67
 BRK
64 68
 
65
-@on-mouse
69
+@on-mouse ( -> )
66 70
 	
67 71
 	;draw-cursor JSR2
68 72
 
69
-	.Mouse/state DEI #00 NEQ ;&no-skip JNZ2 BRK &no-skip
73
+	.Mouse/state DEI #00 NEQ #01 JNZ [ BRK ]
70 74
 
71 75
 	.Mouse/y DEI2 .window/y1 PEK2 SUB2 STEP8
72
-
73 76
 	DUP2 #0010 NEQ2 ,&no-touch-red JNZ
74 77
 		.Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-red JNZ
75 78
 		.Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-red JNZ
76
-		( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/r1 #00 .selection PEK ADD2 PUT
79
+		( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 SWP POP ;theme/r1 #00 .selection PEK ADD2 PUT
77 80
 	&no-touch-red
78 81
 	DUP2 #0020 NEQ2 ,&no-touch-green JNZ
79 82
 		.Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-green JNZ
80 83
 		.Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-green JNZ
81
-		( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/g1 #00 .selection PEK ADD2 PUT
84
+		( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 SWP POP ;theme/g1 #00 .selection PEK ADD2 PUT
82 85
 	&no-touch-green
83 86
 	DUP2 #0030 NEQ2 ,&no-touch-blue JNZ
84 87
 		.Mouse/x DEI2 .window/x1 PEK2 #0060 ADD2 LTH2 ,&no-touch-blue JNZ
85 88
 		.Mouse/x DEI2 .window/x1 PEK2 #009c ADD2 GTH2 ,&no-touch-blue JNZ
86
-		( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 S2B ;theme/b1 #00 .selection PEK ADD2 PUT
89
+		( get new value ) .Mouse/x DEI2 .window/x1 PEK2 SUB2 #0060 SUB2 #0004 DIV2 SWP POP ;theme/b1 #00 .selection PEK ADD2 PUT
87 90
 	&no-touch-blue
88 91
 	DUP2 #0040 NEQ2 ,&no-touch-radio JNZ
89 92
 		.Mouse/x DEI2 .window/x1 PEK2 #0050 ADD2 LTH2 ,&no-touch-radio JNZ
90 93
 		.Mouse/x DEI2 .window/x1 PEK2 #008c ADD2 GTH2 ,&no-touch-radio JNZ
91
-		.Mouse/x DEI2 .window/x1 PEK2 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 S2B .selection POK
94
+		.Mouse/x DEI2 .window/x1 PEK2 SUB2 #0050 SUB2 STEP8 2/ #0008 DIV2 SWP POP .selection POK
92 95
 	&no-touch-radio
93
-
94 96
 	POP2
95 97
 
96 98
 	;update-theme JSR2
... ...
@@ -98,7 +100,7 @@ BRK
98 100
 
99 101
 BRK
100 102
 
101
-@update-theme
103
+@update-theme ( -- )
102 104
 
103 105
 	#08 DEI #0f AND .theme/r1 PEK #40 SFT ADD #08 DEO
104 106
 	#0a DEI #0f AND .theme/g1 PEK #40 SFT ADD #0a DEO
... ...
@@ -115,7 +117,7 @@ BRK
115 117
 
116 118
 RTN
117 119
 
118
-@draw-background
120
+@draw-background ( -- )
119 121
 	
120 122
 	( draw hor line )
121 123
 	#0000 .Screen/x DEO2 .center/y PEK2 .Screen/y DEO2
... ...
@@ -140,7 +142,7 @@ RTN
140 142
 	#0010 .Screen/y DEO2
141 143
 	#00 #08
142 144
 	&draw-pixel1
143
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
145
+		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
144 146
 		( draw ) OVR .Screen/color DEO
145 147
 		( incr ) SWP #01 ADD SWP
146 148
 		DUP2 LTH ,&draw-pixel1 JNZ
... ...
@@ -148,7 +150,7 @@ RTN
148 150
 	#0018 .Screen/y DEO2
149 151
 	#00 #08
150 152
 	&draw-pixel2
151
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
153
+		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
152 154
 		( draw ) OVR #08 ADD .Screen/color DEO
153 155
 		( incr ) SWP #01 ADD SWP
154 156
 		DUP2 LTH ,&draw-pixel2 JNZ
... ...
@@ -156,7 +158,7 @@ RTN
156 158
 	#0020 .Screen/y DEO2
157 159
 	#00 #08
158 160
 	&draw-icn1
159
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
161
+		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
160 162
 		( draw ) OVR #20 ADD .Screen/color DEO
161 163
 		( incr ) SWP #01 ADD SWP
162 164
 		DUP2 LTH ,&draw-icn1 JNZ
... ...
@@ -164,7 +166,7 @@ RTN
164 166
 	#0028 .Screen/y DEO2
165 167
 	#00 #08
166 168
 	&draw-icn2
167
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
169
+		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
168 170
 		( draw ) OVR #28 ADD .Screen/color DEO
169 171
 		( incr ) SWP #01 ADD SWP
170 172
 		DUP2 LTH ,&draw-icn2 JNZ
... ...
@@ -172,7 +174,7 @@ RTN
172 174
 	#0030 .Screen/y DEO2
173 175
 	#00 #08
174 176
 	&draw-chr1
175
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
177
+		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
176 178
 		( draw ) OVR #40 ADD .Screen/color DEO
177 179
 		( incr ) SWP #01 ADD SWP
178 180
 		DUP2 LTH ,&draw-chr1 JNZ
... ...
@@ -180,7 +182,7 @@ RTN
180 182
 	#0038 .Screen/y DEO2
181 183
 	#00 #08
182 184
 	&draw-chr2
183
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
185
+		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
184 186
 		( draw ) OVR #48 ADD .Screen/color DEO
185 187
 		( incr ) SWP #01 ADD SWP
186 188
 		DUP2 LTH ,&draw-chr2 JNZ
... ...
@@ -188,7 +190,7 @@ RTN
188 190
 
189 191
 RTN
190 192
 
191
-@draw-window
193
+@draw-window ( -- )
192 194
 	
193 195
 	.window/x1 PEK2 .window/w PEK2 ADD2 .window/x2 POK2
194 196
 	.window/y1 PEK2 .window/h PEK2 ADD2 .window/y2 POK2
... ...
@@ -196,17 +198,17 @@ RTN
196 198
 	.window/x1 PEK2 .window/y1 PEK2 .window/x2 PEK2 .window/y2 PEK2 #01 ;line-rect JSR2
197 199
 	.window/x1 PEK2 #0002 SUB2 .window/y1 PEK2 #0002 SUB2 .window/x2 PEK2 #0002 ADD2 .window/y2 PEK2 #0002 ADD2 #01 ;line-rect JSR2
198 200
 
199
-	.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0010 ADD2 #25 ;red_txt ;draw-label JSR2
200
-	.window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0010 ADD2 #28 .System/r ;draw-byte JSR2
201
-	.window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0010 ADD2 #28 .System/r #01 ADD ;draw-byte JSR2
201
+	.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0010 ADD2 ;red_txt #25 ;draw-label JSR2
202
+	.window/x1 PEK2 #0038 ADD2 .Screen/x DEO2 
203
+	.System/r DEI2 #28 ;draw-short JSR2
202 204
 
203
-	.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0020 ADD2 #25 ;green_txt ;draw-label JSR2
204
-	.window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0020 ADD2 #28 .System/g ;draw-byte JSR2
205
-	.window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0020 ADD2 #28 .System/g #01 ADD ;draw-byte JSR2
205
+	.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0020 ADD2 ;green_txt #25 ;draw-label JSR2
206
+	.window/x1 PEK2 #0038 ADD2 .Screen/x DEO2 
207
+	.System/g DEI2 #28 ;draw-short JSR2
206 208
 
207
-	.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0030 ADD2 #25 ;blue_txt ;draw-label JSR2
208
-	.window/x1 PEK2 #0038 ADD2 .window/y1 PEK2 #0030 ADD2 #28 .System/b ;draw-byte JSR2
209
-	.window/x1 PEK2 #0048 ADD2 .window/y1 PEK2 #0030 ADD2 #28 .System/b #01 ADD ;draw-byte JSR2
209
+	.window/x1 PEK2 #0008 ADD2 .window/y1 PEK2 #0030 ADD2 ;blue_txt #25 ;draw-label JSR2
210
+	.window/x1 PEK2 #0038 ADD2 .Screen/x DEO2 
211
+	.System/b DEI2 #28 ;draw-short JSR2
210 212
 
211 213
 	.window/x1 PEK2 #0060 ADD2 .window/y1 PEK2 #0010 ADD2 .window/x1 PEK2 #0090 ADD2 #00 ;theme/r1 .selection PEK ADD GET #0004 MUL2 #01 ;draw-slider JSR2
212 214
 	.window/x1 PEK2 #0060 ADD2 .window/y1 PEK2 #0020 ADD2 .window/x1 PEK2 #0090 ADD2 #00 ;theme/g1 .selection PEK ADD GET #0004 MUL2 #01 ;draw-slider JSR2
... ...
@@ -235,15 +237,16 @@ RTN
235 237
 RTN
236 238
 
237 239
 @draw-cursor ( -- )
238
-
240
+	
239 241
 	( clear last cursor )
240
-	;clear_icn .Screen/addr DEO2
242
+	#fff8 .Screen/addr DEO2
241 243
 	.pointer/x PEK2 .Screen/x DEO2
242 244
 	.pointer/y PEK2 .Screen/y DEO2
243 245
 	#30 .Screen/color DEO
244 246
 
245 247
 	( record pointer positions )
246
-	.Mouse/x DEI2 .pointer/x POK2 .Mouse/y DEI2 .pointer/y POK2
248
+	.Mouse/x DEI2 .pointer/x POK2 
249
+	.Mouse/y DEI2 .pointer/y POK2
247 250
 
248 251
 	( draw new cursor )
249 252
 	;pointer_icn .Screen/addr DEO2
... ...
@@ -253,7 +256,7 @@ RTN
253 256
 
254 257
 RTN
255 258
 
256
-@draw-slider ( x1 y x2 pos color -- )
259
+@draw-slider ( x1* y* x2* pos* color -- )
257 260
 	
258 261
 	( load ) .color POK .slider/pos POK2 .slider/x2 POK2 .slider/y POK2 .slider/x1 POK2
259 262
 
... ...
@@ -280,7 +283,7 @@ RTN
280 283
 
281 284
 RTN
282 285
 
283
-@fill-rect ( x1 y1 x2 y2 color )
286
+@fill-rect ( x1* y1* x2* y2* color -- )
284 287
 	
285 288
 	.color POK
286 289
 	( x1 x2 y1 y2 ) ROT2 SWP2
... ...
@@ -299,7 +302,7 @@ RTN
299 302
 
300 303
 RTN
301 304
 
302
-@line-rect ( x1 y1 x2 y2 color -- )
305
+@line-rect ( x1* y1* x2* y2* color -- )
303 306
 
304 307
 	( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2
305 308
 	&hor
... ...
@@ -316,49 +319,58 @@ RTN
316 319
 
317 320
 RTN
318 321
 
319
-@draw-label ( x y color addr -- )
322
+@draw-label ( x* y* addr* color  -- )
320 323
 	
321
-	( load ) .label/addr POK2 .color POK .Screen/y DEO2 .Screen/x DEO2 .label/addr PEK2
324
+	STH STH2 
325
+	.Screen/y DEO2 
326
+	.Screen/x DEO2 
327
+	STH2r
322 328
 	&loop
323
-		( draw ) DUP2 GET #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 .color PEK .Screen/color DEO
329
+		DUP2 GET #00 SWP #0008 MUL2 
330
+		;font ADD2 .Screen/addr DEO2 
331
+		( draw ) DUPr STHr .Screen/color DEO
324 332
 		( incr ) ++
325 333
 		( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
326 334
 		DUP2 GET #00 NEQ ,&loop JNZ
327
-	POP2
335
+	POP2 POPr
328 336
 
329 337
 RTN
330 338
 
331
-@draw-byte ( x y color addr -- )
339
+@draw-short ( short* color -- )
332 340
 
333
-	.addr POK STH
334
-	.Screen/y DEO2
335
-	.Screen/x DEO2
336
-	;font_hex #00 .addr PEK DEI #04 SFT #0008 MUL2 ADD2 .Screen/addr DEO2
337
-	STHr DUP STH .Screen/color DEO
338
-	;font_hex #00 .addr PEK DEI #0f AND #0008 MUL2 ADD2 .Screen/addr DEO2
341
+	STH SWP 
342
+	DUP #04 SFT #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
343
+	( draw ) DUPr STHr .Screen/color DEO
344
+	#0f AND #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
339 345
 	.Screen/x DEI2 8+ .Screen/x DEO2
340
-	STHr .Screen/color DEO
346
+	( draw ) DUPr STHr .Screen/color DEO
347
+	DUP #04 SFT #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
348
+	.Screen/x DEI2 8+ .Screen/x DEO2
349
+	( draw ) DUPr STHr .Screen/color DEO
350
+	#0f AND #00 SWP #0008 MUL2 ;font-hex ADD2 .Screen/addr DEO2
351
+	.Screen/x DEI2 8+ .Screen/x DEO2
352
+	( draw ) STHr .Screen/color DEO
341 353
 
342 354
 RTN
343 355
 
344
-@clear_icn    [ 0000 0000 0000 0000 ]
356
+@red_txt      [ "Red 00 ]
357
+@green_txt    [ "Green 00 ]
358
+@blue_txt     [ "Blue 00 ]
359
+
345 360
 @pointer_icn  [ 80c0 e0f0 f8e0 1000 ]
346 361
 @halftone_icn [ aa55 aa55 aa55 aa55 ]
347 362
 @slidera_icn  [ 3f7f ffff ffff 7f3f ]
348 363
 @sliderb_icn  [ ffff ffff ffff ffff ]
349 364
 @sliderc_icn  [ fcfe ffff ffff fefc ]
350 365
 @sliderd_icn  [ 003c 7e7e 7e7e 3c00 ]
351
-@preview_icn  [ 183c 66db db66 3c18 0000 183c 3c18 0000 ]
366
+
367
+@preview_icn  [ 
368
+	183c 66db db66 3c18 
369
+	0000 183c 3c18 0000 ]
352 370
 @radio_icns
353 371
 	[ 3c42 8181 8181 423c ]
354 372
 	[ 3c42 99bd bd99 423c ]
355
-
356
-@red_txt   [ "Red 00 ]
357
-@green_txt [ "Green 00 ]
358
-@blue_txt  [ "Blue 00 ]
359
-
360
-@font_hex ( 0-F TODO: should pull from @font instead.. )
361
-[
373
+@font-hex [
362 374
 	003c 464a 5262 3c00 0018 0808 0808 1c00
363 375
 	003c 4202 3c40 7e00 003c 421c 0242 3c00
364 376
 	000c 1424 447e 0400 007e 407c 0242 3c00
... ...
@@ -366,11 +378,9 @@ RTN
366 378
 	003c 423c 4242 3c00 003c 4242 3e02 3c00
367 379
 	003c 4242 7e42 4200 007c 427c 4242 7c00
368 380
 	003c 4240 4042 3c00 007c 4242 4242 7c00
369
-	007e 4078 4040 7e00 007e 4078 4040 4000
370
-]
381
+	007e 4078 4040 7e00 007e 4078 4040 4000 ]
371 382
 
372
-@font ( spectrum-zx font )
373
-[
383
+@font ( spectrum-zx font ) [
374 384
 	0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
375 385
 	0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
376 386
 	007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
... ...
@@ -402,5 +412,4 @@ RTN
402 412
 	0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
403 413
 	0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
404 414
 	0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
405
-	0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
406
-]
415
+	0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c ]
... ...
@@ -7,35 +7,38 @@
7 7
 
8 8
 ( devices )
9 9
 
10
-|00 @System     [ &vector $2 &pad    $6 &r      $2 &g     $2 &b      $2 ]
11
-|20 @Screen     [ &vector $2 &width  $2 &height $2 &pad   $2 &x      $2 &y    $2 &addr  $2 &color $1 ]
12
-|30 @Audio      [ &pad $8 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ]
10
+|00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
11
+|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y    $2 &addr  $2 &color $1 ]
12
+|30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
13 13
 
14 14
 |0100 ( -> )
15 15
 	
16
-	( set color pallete )
16
+	( theme )
17 17
 	#00ff .System/r DEO2 
18 18
 	#0f0f .System/g DEO2 
19 19
 	#0ff0 .System/b DEO2 
20 20
 
21
-	;on-frame .Screen/vector DEO2 ( run on-frame every 1/60th of a second )
22
-	#ff .Audio/volume DEO         ( set volume to max )
23
-	;saw .Audio/addr DEO2         ( set waveform to saw for audio engine )
24
-	;saw/end ;saw SUB2 .Audio/len DEO2
25
-	#1202 .Audio/adsr DEO2        ( set envelope for audio engine )
21
+	( vectors )
22
+	;on-frame .Screen/vector DEO2
23
+
24
+	( setup synth )
25
+	#1202 .Audio0/adsr DEO2
26
+	;saw .Audio0/addr DEO2
27
+	#0100 .Audio0/length DEO2
28
+	#ff .Audio0/volume DEO
26 29
 
27 30
 BRK
28 31
 
29 32
 @on-frame ( -> )
30 33
 
31 34
 	( incr ) .timer PEK #01 ADD .timer POK 
32
-	( skip ) .timer PEK #10 EQU ,&play-note JNZ BRK &play-note
35
+	( skip ) .timer PEK #10 EQU #01 JNZ [ BRK ]
33 36
 
34 37
 	( get note )
35 38
 	;melody #00 .progress PEK ADD2 GET 
36 39
 
37 40
 	( play note )
38
-	DUP .Audio/pitch DEO
41
+	DUP .Audio0/pitch DEO
39 42
 
40 43
 	( erase last note )
41 44
 	#20  .Screen/color DEO
... ...
@@ -52,42 +55,28 @@ BRK
52 55
 
53 56
 BRK
54 57
 
55
-@silence ( -> )
56
-
57
-BRK
58
-
59
-( defines a sawtooth wave. )
60
-
61
-@saw ( -> )
62
-	5f5f 5e5e 5e5d 5d5d 5c5c 5b5b 5b5a 5a5a
63
-	5959 5858 5857 5757 5656 5555 5554 5454
64
-	5353 5252 5251 5151 5050 4f4f 4f4e 4e4e
65
-	4d4d 4c4c 4c4b 4b4b 4a4a 4949 4948 4848
66
-	4747 4646 4645 4545 4444 4343 4342 4242
67
-	4141 4040 403f 3f3f 3e3e 3d3d 3d3c 3c3c
68
-	3b3b 3a3a 3a39 3939 3838 3737 3736 3636
69
-	3535 3434 3433 3333 3232 3131 3130 3030
70
-	2f2f 2e2e 2e2d 2d2d 2c2c 2b2b 2b2a 2a2a
71
-	2929 2828 2827 2727 2626 2525 2524 2424
72
-	2323 2222 2221 2121 2020 1f1f 1f1e 1e1e
73
-	1d1d 1c1c 1c1b 1b1b 1a1a 1919 1918 1818
74
-	1717 1616 1615 1515 1414 1313 1312 1212
75
-	1111 1010 100f 0f0f 0e0e 0d0d 0d0c 0c0c
76
-	0b0b 0a0a 0a09 0909 0808 0707 0706 0606
77
-	0505 0404 0403 0303 0202 0101 0100 0000
78
-	&end
79
-
80
-BRK
58
+@dot [ 003c 7eff 7e3c 0000 ] 
81 59
 
82
-( song data, #ff is used for a rest )
60
+@saw [
61
+	0003 0609 0c0f 1215 181b 1e21 2427 2a2d
62
+	3033 3639 3b3e 4143 4649 4b4e 5052 5557
63
+	595b 5e60 6264 6667 696b 6c6e 7071 7274
64
+	7576 7778 797a 7b7b 7c7d 7d7e 7e7e 7e7e
65
+	7f7e 7e7e 7e7e 7d7d 7c7b 7b7a 7978 7776
66
+	7574 7271 706e 6c6b 6967 6664 6260 5e5b
67
+	5957 5552 504e 4b49 4643 413e 3b39 3633
68
+	302d 2a27 2421 1e1b 1815 120f 0c09 0603
69
+	00fd faf7 f4f1 eeeb e8e5 e2df dcd9 d6d3
70
+	d0cd cac7 c5c2 bfbd bab7 b5b2 b0ae aba9
71
+	a7a5 a2a0 9e9c 9a99 9795 9492 908f 8e8c
72
+	8b8a 8988 8786 8585 8483 8382 8282 8282
73
+	8182 8282 8282 8383 8485 8586 8788 898a
74
+	8b8c 8e8f 9092 9495 9799 9a9c 9ea0 a2a5
75
+	a7a9 abae b0b2 b5b7 babd bfc2 c5c7 cacd
76
+	d0d3 d6d9 dcdf e2e5 e8eb eef1 f4f7 fafd ]
83 77
 
84 78
 @melody [ 
85 79
 	54 52 54 4f 4b 4f 48 ff
86 80
 	54 52 54 4f 4b 4f 48 ff
87 81
 	54 56 57 56 57 54 56 54 
88
-	56 52 54 52 54 50 54 ff
89
-] 
90
-
91
-( dot sprite )
92
-	 
93
-@dot [ 003c 7eff 7e3c 0000 ] 
82
+	56 52 54 52 54 50 54 ff ] 
... ...
@@ -14,7 +14,7 @@
14 14
 	
15 15
 BRK
16 16
 
17
-@print ( addr -- )
17
+@print ( addr* -- )
18 18
 	
19 19
 	&loop
20 20
 		( send ) DUP2 GET .Console/char DEO
... ...
@@ -18,6 +18,7 @@
18 18
 	#0f73 .System/r DEO2 
19 19
 	#0fe3 .System/g DEO2 
20 20
 	#0fc3 .System/b DEO2
21
+
21 22
 	( vectors ) 
22 23
 	;on-button .Controller/vector DEO2
23 24
 	;draw-cursor JSR2
... ...
@@ -26,7 +27,8 @@ BRK
26 27
 
27 28
 @on-button ( -> )
28 29
 	
29
-	.Controller/key DEI #00 NEQ ,&skip JNZ BRK &skip  
30
+	( skip ) .Controller/key DEI #00 NEQ #01 JNZ [ BRK ] 
31
+
30 32
 	.Controller/key DEI #0d NEQ ,&no-return JNZ 
31 33
 		( draw ) #20 .Screen/color DEO
32 34
 		( reset ) #0000 .Screen/x DEO2
... ...
@@ -34,9 +36,11 @@ BRK
34 36
 		;draw-cursor JSR2
35 37
 		BRK
36 38
 	&no-return
39
+
37 40
 	;font #00 .Controller/key DEI 8* ADD2 .Screen/addr DEO2
38 41
 	( draw ) #21 .Screen/color DEO
39 42
 	( incr ) .Screen/x DEI2 8+ .Screen/x DEO2
43
+	
40 44
 	;draw-cursor JSR2
41 45
 
42 46
 BRK
... ...
@@ -24,21 +24,23 @@
24 24
 
25 25
 ( program )
26 26
 
27
-|0100
27
+|0100 ( -> )
28 28
 	
29 29
 	( theme ) 
30 30
 	#0ff8 .System/r DEO2 
31 31
 	#0f08 .System/g DEO2 
32 32
 	#0f08 .System/b DEO2
33
+
33 34
 	( vectors ) 
34 35
 	;on-frame .Screen/vector DEO2
35 36
 
36 37
 BRK
37 38
 
38
-@on-frame
39
+@on-frame ( -> )
39 40
 
40 41
 	( only draw once per second )
41
-	.DateTime/second DEI .current PEK NEQ #01 JNZ [ BRK ]
42
+	( skip ) .DateTime/second DEI .current PEK NEQ #01 JNZ [ BRK ]
43
+
42 44
 	.DateTime/second DEI .current POK
43 45
 
44 46
 	( clear )
... ...
@@ -62,8 +62,8 @@ BRK
62 62
 
63 63
 BRK
64 64
 
65
-@successtxt "Success! $1
66
-@failedtxt "Failed. $1
65
+@successtxt "Success! 09 $1
66
+@failedtxt  "Failed. 09 $1
67 67
 
68 68
 @srcpath    "projects/pictures/ako10x10.chr $1
69 69
 @dstpath    "bin/image-copy.chr $1
... ...
@@ -11,18 +11,19 @@
11 11
 
12 12
 |0000
13 13
 
14
+@color $1
14 15
 @line    [ &x0 $2 &y0 $2 &x     $2 &y     $2 &sx    $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ]
15 16
 @pointer [ &x  $2 &y  $2 &lastx $2 &lasty $2 &state $1 ]
16
-@color $1
17 17
 
18 18
 ( program )
19 19
 
20 20
 |0100 ( -> )
21 21
 
22 22
 	( theme ) 
23
-	#f0f0 .System/r DEO2 
24
-	#f00f .System/g DEO2 
25
-	#f000 .System/b DEO2
23
+	#f030 .System/r DEO2 
24
+	#f04f .System/g DEO2 
25
+	#f050 .System/b DEO2
26
+
26 27
 	( vectors ) 
27 28
 	;on-mouse .Mouse/vector DEO2
28 29
 
... ...
@@ -31,8 +32,10 @@ BRK
31 32
 @on-mouse ( -> )
32 33
 
33 34
 	;draw-cursor JSR2
35
+
34 36
 	( on down )
35 37
 	.Mouse/state DEI #00 NEQ .pointer/state PEK #00 EQU #0101 EQU2 ,on-mouse-down JNZ
38
+
36 39
 	( on drag )
37 40
 	.Mouse/state DEI #00 NEQ ,on-mouse-drag JNZ
38 41
 	.Mouse/state DEI .pointer/state POK
... ...
@@ -57,6 +60,7 @@ BRK
57 60
 	.pointer/y PEK2 
58 61
 	#01 [ .Mouse/state DEI #10 EQU #02 MUL ADD ] 
59 62
 	;draw-line JSR2
63
+
60 64
 	( record last position )
61 65
 	.Mouse/x DEI2 .pointer/lastx POK2 
62 66
 	.Mouse/y DEI2 .pointer/lasty POK2
... ...
@@ -67,19 +71,20 @@ BRK
67 71
 @draw-cursor ( -- )
68 72
 	
69 73
 	( clear last cursor )
70
-	;clear .Screen/addr DEO2 
71
-	.pointer/x PEK2 .Screen/x DEO2 
72
-	.pointer/y PEK2 .Screen/y DEO2 
74
+	#fff8 .Screen/addr DEO2
75
+	.pointer/x PEK2 .Screen/x DEO2
76
+	.pointer/y PEK2 .Screen/y DEO2
73 77
 	#30 .Screen/color DEO
78
+
74 79
 	( record pointer positions )
75 80
 	.Mouse/x DEI2 .pointer/x POK2 
76 81
 	.Mouse/y DEI2 .pointer/y POK2
82
+
77 83
 	( draw new cursor )
78
-	;cursor .Screen/addr DEO2 
79
-	.pointer/x PEK2 .Screen/x DEO2 
80
-	.pointer/y PEK2 .Screen/y DEO2 
81
-	( colorize on state )
82
-	#31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO
84
+	;pointer_icn .Screen/addr DEO2
85
+	.pointer/x PEK2 .Screen/x DEO2
86
+	.pointer/y PEK2 .Screen/y DEO2
87
+	#33 .Mouse/state DEI #00 NEQ #02 MUL SUB .Screen/color DEO
83 88
 
84 89
 RTN
85 90
 
... ...
@@ -111,5 +116,4 @@ RTN
111 116
 
112 117
 RTN
113 118
 
114
-@clear  [ 0000 0000 0000 0000 ]
115
-@cursor [ 80c0 e0f0 f8e0 1000 ]
119
+@pointer_icn [ 80c0 e0f0 f8e0 1000 ]
... ...
@@ -1,6 +1,7 @@
1 1
 ( dev/screen )
2 2
 
3 3
 %RTN { JMP2r }
4
+%MOD { DUP2 DIV MUL SUB }
4 5
 
5 6
 ( devices )
6 7
 
... ...
@@ -18,95 +19,34 @@
18 19
 |0100 ( -> )
19 20
 	
20 21
 	( theme ) 
21
-	#530f .System/r DEO2
22
-	#f20f .System/g DEO2 
23
-	#ad0f .System/b DEO2 
22
+	#0c5f .System/r DEO2
23
+	#022f .System/g DEO2 
24
+	#0da4 .System/b DEO2 
24 25
 
25 26
 	( find screen center )
26 27
 	.Screen/width DEI2 #0002 DIV2 .center/x POK2
27 28
 	.Screen/height DEI2 #0002 DIV2 .center/y POK2
28 29
 
29 30
 	( draw )
30
-	;draw-background JSR2
31 31
 	;draw-sprites JSR2
32 32
 	
33 33
 BRK
34 34
 
35
-@draw-background ( -- )
36
-	
37
-	( draw hor line )
38
-	#0000 .Screen/x DEO2 .center/y PEK2 .Screen/y DEO2
39
-	#0000 .Screen/width DEI2 ( from/to )
40
-	&draw-hor
41
-		( draw ) #01 .Screen/color DEO
42
-		( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2
43
-		OVR2 OVR2 LTH2 ,&draw-hor JNZ
44
-	POP2 POP2
45
-
46
-	( draw ver line )
47
-	.center/x PEK2 .Screen/x DEO2 #0000 .Screen/y DEO2
48
-	#0000 .Screen/height DEI2 ( from/to )
49
-	&draw-ver
50
-		( draw ) #02 .Screen/color DEO
51
-		( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2
52
-		OVR2 OVR2 LTH2 ,&draw-ver JNZ
53
-	POP2 POP2
54
-
55
-RTN
56
-
57 35
 @draw-sprites ( -- )
58 36
 	
59
-	( draw blending modes )
60 37
 	;preview_icn .Screen/addr DEO2
61
-	#0010 .Screen/y DEO2
62
-	#00 #08
63
-	&draw-pixel1
64
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
38
+
39
+	#00 #ff
40
+	&loop
41
+		( move ) OVR #0f AND #40 SFT #02 DIV #00 SWP 
42
+			.center/x PEK2 #0040 SUB2 ADD2 .Screen/x DEO2
43
+		( move ) OVR #f0 AND #02 DIV #00 SWP 
44
+			.center/y PEK2 #0018 SUB2 ADD2 .Screen/y DEO2
65 45
 		( draw ) OVR .Screen/color DEO
66 46
 		( incr ) SWP #01 ADD SWP
67
-		DUP2 LTH ,&draw-pixel1 JNZ
68
-	POP POP
69
-	#0018 .Screen/y DEO2
70
-	#00 #08
71
-	&draw-pixel2
72
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
73
-		( draw ) OVR #08 ADD .Screen/color DEO
74
-		( incr ) SWP #01 ADD SWP
75
-		DUP2 LTH ,&draw-pixel2 JNZ
76
-	POP POP
77
-	#0020 .Screen/y DEO2
78
-	#00 #08
79
-	&draw-icn1
80
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
81
-		( draw ) OVR #20 ADD .Screen/color DEO
82
-		( incr ) SWP #01 ADD SWP
83
-		DUP2 LTH ,&draw-icn1 JNZ
84
-	POP POP
85
-	#0028 .Screen/y DEO2
86
-	#00 #08
87
-	&draw-icn2
88
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
89
-		( draw ) OVR #28 ADD .Screen/color DEO
90
-		( incr ) SWP #01 ADD SWP
91
-		DUP2 LTH ,&draw-icn2 JNZ
92
-	POP POP
93
-	#0030 .Screen/y DEO2
94
-	#00 #08
95
-	&draw-chr1
96
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
97
-		( draw ) OVR #40 ADD .Screen/color DEO
98
-		( incr ) SWP #01 ADD SWP
99
-		DUP2 LTH ,&draw-chr1 JNZ
100
-	POP POP
101
-	#0038 .Screen/y DEO2
102
-	#00 #08
103
-	&draw-chr2
104
-		( move ) OVR #00 SWP #0008 MUL2 #0010 ADD2 .Screen/x DEO2
105
-		( draw ) OVR #48 ADD .Screen/color DEO
106
-		( incr ) SWP #01 ADD SWP
107
-		DUP2 LTH ,&draw-chr2 JNZ
108
-	POP POP
109
-
47
+		DUP2 LTH ,&loop JNZ
48
+	POP2
49
+	
110 50
 RTN
111 51
 
112 52
 @preview_icn  [ 183c 66db db66 3c18 0000 183c 3c18 0000 ]
113 53
\ No newline at end of file
... ...
@@ -15,11 +15,14 @@
15 15
 	#4cfd .System/r DEO2 
16 16
 	#4cf3 .System/g DEO2 
17 17
 	#dcf2 .System/b DEO2
18
+
18 19
 	( vectors )
19 20
 	;on-frame .Screen/vector DEO2
21
+
20 22
 	( starting position )
21 23
 	.Screen/width DEI2 #0002 DIV2 .dvd/x POK2
22 24
 	.Screen/height DEI2 #0002 DIV2 .dvd/y POK2
25
+	
23 26
 	#21 ;draw-dvd JSR2
24 27
 	
25 28
 BRK
... ...
@@ -82,7 +82,7 @@ BRK
82 82
 
83 83
 RTN
84 84
 
85
-@line-rect ( x1 y1 x2 y2 color )
85
+@line-rect ( x1* y1* x2* y2* color -- )
86 86
 
87 87
 	( load ) .color POK .rect/y2 POK2 .rect/x2 POK2 DUP2 .Screen/y DEO2 .rect/y1 POK2 DUP2 .Screen/x DEO2 .rect/x1 POK2
88 88
 	&hor