Browse code

The console read byte is its own location

neauoire authored on 27/06/2021 23:42:47
Showing 2 changed files
... ...
@@ -19,7 +19,7 @@
19 19
 ( devices )
20 20
 
21 21
 |00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
22
-|10 @Console    [ &pad    $8 &char     $1 &byte   $1 &short $2 &string $2 ]
22
+|10 @Console    [ &vector $2 &rbyte    $1 &pad    $5 &char  $1 &wbyte  $1 &short  $2 &string $2 ]
23 23
 |20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr $2 &color $1 ]
24 24
 |30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
25 25
 |70 @Midi       [ &vector $2 &channel  $1 &note   $1 &velocity $1 ]
... ...
@@ -53,6 +53,7 @@
53 53
 	;on-frame   .Screen/vector DEO2
54 54
 	;on-control .Controller/vector DEO2
55 55
 	;on-mouse   .Mouse/vector DEO2
56
+	;on-message .Console/vector DEO2
56 57
 
57 58
 	( find center )
58 59
 	.Screen/width DEI2 2// .center/x STZ2
... ...
@@ -116,21 +117,21 @@ BRK
116 117
 
117 118
 	.Controller/key DEI
118 119
 	DUP #61 ! ,&no-c JCN
119
-		#00 .last-note STZ ;notes LDA ;play JSR2 &no-c
120
+		#30 .octave LDZ #0c * + ;play JSR2 &no-c
120 121
 	DUP #73 ! ,&no-d JCN
121
-		#01 .last-note STZ ;notes #0001 ++ LDA ;play JSR2 &no-d
122
+		#32 .octave LDZ #0c * + ;play JSR2 &no-d
122 123
 	DUP #64 ! ,&no-e JCN
123
-		#02 .last-note STZ ;notes #0002 ++ LDA ;play JSR2 &no-e
124
+		#34 .octave LDZ #0c * + ;play JSR2 &no-e
124 125
 	DUP #66 ! ,&no-f JCN
125
-		#03 .last-note STZ ;notes #0003 ++ LDA ;play JSR2 &no-f
126
+		#35 .octave LDZ #0c * + ;play JSR2 &no-f
126 127
 	DUP #67 ! ,&no-g JCN
127
-		#04 .last-note STZ ;notes #0004 ++ LDA ;play JSR2 &no-g
128
+		#37 .octave LDZ #0c * + ;play JSR2 &no-g
128 129
 	DUP #68 ! ,&no-a JCN
129
-		#05 .last-note STZ ;notes #0005 ++ LDA ;play JSR2 &no-a
130
+		#39 .octave LDZ #0c * + ;play JSR2 &no-a
130 131
 	DUP #6a ! ,&no-b JCN
131
-		#06 .last-note STZ ;notes #0006 ++ LDA ;play JSR2 &no-b
132
+		#3b .octave LDZ #0c * + ;play JSR2 &no-b
132 133
 	DUP #6b ! ,&no-c2 JCN
133
-		#07 .last-note STZ ;notes #0007 ++ LDA ;play JSR2 &no-c2
134
+		#3c .octave LDZ #0c * + ;play JSR2 &no-c2
134 135
 	POP
135 136
 
136 137
 	( release )
... ...
@@ -152,6 +153,15 @@ BRK
152 153
 
153 154
 BRK
154 155
 
156
+@on-message ( -> )
157
+	
158
+	.Console/rbyte DEI 
159
+		DUP #0c MOD .last-note STZ 
160
+	;play JSR2
161
+	;draw-octave JSR2
162
+
163
+BRK
164
+
155 165
 @on-mouse ( -> )
156 166
 
157 167
 	;draw-cursor JSR2 
... ...
@@ -190,7 +200,7 @@ BRK
190 200
 	&no-mod
191 201
 
192 202
 	.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// SWP POP #06 > ,&no-key JCN
193
-		.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// DUP2 SWP POP .last-note STZ ;notes ++ LDA ;play JSR2
203
+		.Mouse/x DEI2 .octave-view/x1 LDZ2 -- 8// ;notes ++ LDA .octave LDZ #0c * + ;play JSR2
194 204
 		( release ) #00 .Mouse/state DEO
195 205
 		;draw-octave JSR2
196 206
 	&no-key
... ...
@@ -233,8 +243,9 @@ BRK
233 243
 BRK
234 244
 
235 245
 @play ( pitch -- )
236
-	
237
-	.octave LDZ #0c * + .Audio0/pitch DEO
246
+		
247
+	DUP #0c MOD .last-note STZ 
248
+	.Audio0/pitch DEO
238 249
 
239 250
 RTN
240 251
 
... ...
@@ -246,11 +257,8 @@ RTN
246 257
 	.pointer/y LDZ2 .Screen/y DEO2 
247 258
 	#30 .Screen/color DEO
248 259
 	( record pointer positions )
249
-	.Mouse/x DEI2 .pointer/x STZ2 
250
-	.Mouse/y DEI2 .pointer/y STZ2
251
-	( draw new cursor )
252
-	.pointer/x LDZ2 .Screen/x DEO2 
253
-	.pointer/y LDZ2 .Screen/y DEO2 
260
+	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 
261
+	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2  
254 262
 	( colorize on state )
255 263
 	#31 [ .Mouse/state DEI #00 ! ] + .Screen/color DEO
256 264
 
... ...
@@ -261,12 +269,12 @@ RTN
261 269
 	.octave-view/x1 LDZ2 .octave-view/y1 LDZ2
262 270
 
263 271
 	OVR2 OVR2 ;keys-left-icns #21 .last-note LDZ #00 = + ;draw-key JSR2
264
-	OVR2 #0008 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #01 = + ;draw-key JSR2
265
-	OVR2 #0010 ++ OVR2 ;keys-right-icns #21 .last-note LDZ #02 = + ;draw-key JSR2
266
-	OVR2 #0018 ++ OVR2 ;keys-left-icns #21 .last-note LDZ #03 = + ;draw-key JSR2
267
-	OVR2 #0020 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #04 = + ;draw-key JSR2
268
-	OVR2 #0028 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #05 = + ;draw-key JSR2
269
-	SWP2 #0030 ++ SWP2 ;keys-right-icns #21 .last-note LDZ #06 = + ;draw-key JSR2
272
+	OVR2 #0008 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #02 = + ;draw-key JSR2
273
+	OVR2 #0010 ++ OVR2 ;keys-right-icns #21 .last-note LDZ #04 = + ;draw-key JSR2
274
+	OVR2 #0018 ++ OVR2 ;keys-left-icns #21 .last-note LDZ #05 = + ;draw-key JSR2
275
+	OVR2 #0020 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #07 = + ;draw-key JSR2
276
+	OVR2 #0028 ++ OVR2 ;keys-middle-icns #21 .last-note LDZ #09 = + ;draw-key JSR2
277
+	SWP2 #0030 ++ SWP2 ;keys-right-icns #21 .last-note LDZ #0b = + ;draw-key JSR2
270 278
 
271 279
 	.octave-view/x1 LDZ2 #0048 ++ .Screen/x DEO2
272 280
 
... ...
@@ -466,8 +474,8 @@ RTN
466 474
 	0010 1010 fe7c 3810 
467 475
 
468 476
 @notes 
469
-	3c 3e 40 41 43 45 47
470
-	48 4a 4c 4d 4f 51 53 
477
+	30 32 34 35
478
+	37 39 3b 3c
471 479
 
472 480
 @keys-left-icns 
473 481
 	7c7c 7c7c 7c7c 7c7c
... ...
@@ -377,7 +377,7 @@ start(Uxn *u)
377 377
 				break;
378 378
 			}
379 379
 		}
380
-		while(read(0, &devconsole->dat[0x8], 1) > 0)
380
+		while(read(0, &devconsole->dat[0x2], 1) > 0)
381 381
 			evaluxn(u, mempeek16(devconsole->dat, 0));
382 382
 		evaluxn(u, mempeek16(devscreen->dat, 0));
383 383
 		if(reqdraw)