Browse code

Simplified console

neauoire authored on 28/06/2021 16:40:29
Showing 15 changed files
... ...
@@ -11,7 +11,7 @@
11 11
 ( devices )
12 12
 
13 13
 |00 @System     [ &vector $2 &wst      $1 &rst    $1 &pad   $4 &r      $2 &g      $2 &b     $2 ]
14
-|10 @Console    [ &vector $2 &pad      $6 &char   $1 &byte  $1 &short  $2 &string $2 ]
14
+|10 @Console    [ &vector $2 &read     $1 &pad    $5 &write $1 ]
15 15
 |20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr  $2 &color $1 ]
16 16
 |30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
17 17
 |40 @Audio1     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
... ...
@@ -2,9 +2,6 @@
2 2
 ( an open-ended game of rocks and sand )
3 3
 ( contributed by and cc0 sejo 12021 )
4 4
 
5
-%DEBUG  { .Console/byte DEO #0a .Console/char DEO }
6
-%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
7
-
8 5
 ( parameters )
9 6
 %nrocks { #1f }
10 7
 %nrocks-1 { #1e }
... ...
@@ -37,7 +34,6 @@
37 34
 ( devices )
38 35
 
39 36
 |00 @System     [ &vector $2 &wst      $1 &rst    $1 &pad   $4 &r      $2 &g     $2 &b      $2 ]
40
-|10 @Console    [ &pad    $8 &char     $1 &byte   $1 &short $2 &string $2 ]
41 37
 |20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr  $2 &color $1 ]
42 38
 |80 @Controller [ &vector $2 &button   $1 &key    $1 ]
43 39
 
... ...
@@ -24,7 +24,6 @@
24 24
 ( devices )
25 25
 
26 26
 |00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
27
-|10 @Console    [ &pad    $8 &char     $1 &byte   $1 &short $2 &string $2 ]
28 27
 |20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y     $2 &addr   $2 &color $1 ]
29 28
 |30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
30 29
 |40 @Audio1     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
... ...
@@ -23,7 +23,6 @@
23 23
 ( devices )
24 24
 
25 25
 |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
26
-|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
27 26
 |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
28 27
 |30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ]
29 28
 |40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ]
... ...
@@ -13,7 +13,6 @@
13 13
 ( devices )
14 14
 
15 15
 |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
16
-|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
17 16
 |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
18 17
 |b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
19 18
 
... ...
@@ -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    [ &vector $2 &rbyte    $1 &pad    $5 &char  $1 &wbyte  $1 &short  $2 &string $2 ]
22
+|10 @Console    [ &vector $2 &read     $1 &pad    $5 &write $1 ]
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 ]
... ...
@@ -155,7 +155,7 @@ BRK
155 155
 
156 156
 @on-message ( -> )
157 157
 	
158
-	.Console/rbyte DEI ;play JSR2
158
+	.Console/read DEI ;play JSR2
159 159
 	;draw-octave JSR2
160 160
 
161 161
 BRK
... ...
@@ -1,14 +1,20 @@
1 1
 ( dev/console )
2 2
 
3
-|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
3
+%RTN { JMP2r }
4
+
5
+|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
4 6
 
5 7
 ( init )
6 8
 
7 9
 |0100 ( -> )
10
+
8 11
 	;on-stdin .Console/vector DEO2
12
+
9 13
 BRK
10 14
 
11 15
 @on-stdin ( -> )
12
-	.Console/char DEI .Console/byte DEO
13
-	#0a .Console/char DEO
14
-BRK
15 16
\ No newline at end of file
17
+
18
+	.Console/read DEI .Console/write DEO
19
+
20
+BRK
21
+
... ...
@@ -1,6 +1,6 @@
1 1
 ( dev/console )
2 2
 
3
-|10 @Console [ &pad $8 &char ]
3
+|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
4 4
 
5 5
 ( init )
6 6
 
... ...
@@ -9,7 +9,7 @@
9 9
 	;hello-word 
10 10
 
11 11
 	&loop
12
-		( send ) LDAk .Console/char DEO
12
+		( send ) LDAk .Console/write DEO
13 13
 		( incr ) #0001 ADD2
14 14
 		( loop ) LDAk ,&loop JCN
15 15
 	POP2
... ...
@@ -8,13 +8,9 @@
8 8
 %RTN { JMP2r }
9 9
 %TOS { #00 SWP }
10 10
 
11
-%DEBUG  { .Console/byte DEO #0a .Console/char DEO }
12
-%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
13
-
14 11
 ( devices )
15 12
 
16 13
 |00 @System     [ &vector $2 &pad    $6 &r      $2 &g     $2 &b      $2 ]
17
-|10 @Console    &vector $2 &pad      $6 &char   $1 &byte  $1 &short  $2 &string $2 ]
18 14
 |20 @Screen     [ &vector $2 &width  $2 &height $2 &pad   $2 &x      $2 &y $2 &addr $2 &color $1 ]
19 15
 |80 @Controller [ &vector $2 &button $1 &key    $1 ]
20 16
 
... ...
@@ -1,13 +1,10 @@
1 1
 ( GUI Hover )
2 2
 
3 3
 %RTN { JMP2r }
4
-%DEBUG  { .Console/byte DEO #0a .Console/char DEO }
5
-%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
6 4
 
7 5
 ( devices )
8 6
 
9 7
 |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
10
-|10 @Console    [ &vector $2 &pad     $6 &char $1 &byte $1 &short $2 &string $2 ]
11 8
 |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
12 9
 |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
13 10
 
... ...
@@ -6,7 +6,6 @@
6 6
 ( devices )
7 7
 
8 8
 |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
9
-|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
10 9
 |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
11 10
 |a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
12 11
 
... ...
@@ -17,7 +17,6 @@
17 17
 ( devices )
18 18
 
19 19
 |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
20
-|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
21 20
 |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
22 21
 
23 22
 ( variables )
24 23
new file mode 100644
... ...
@@ -0,0 +1,32 @@
1
+( hexes
2
+
3
+	A small utility that prints incoming console messages as hex values. )
4
+
5
+%RTN { JMP2r }
6
+
7
+|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
8
+
9
+( init )
10
+
11
+|0100 ( -> )
12
+	
13
+	;on-message .Console/vector DEO2
14
+
15
+BRK
16
+
17
+@on-message ( -> )
18
+	
19
+	.Console/read DEI ,print-hex JSR
20
+
21
+BRK
22
+
23
+@print-hex ( value -- )
24
+	
25
+	STHk #04 SFT ,&parse JSR .Console/write DEO
26
+	STHr #0f AND ,&parse JSR .Console/write DEO
27
+	RTN
28
+	&parse ( value -- char )
29
+		DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
30
+
31
+RTN
32
+
... ...
@@ -30,14 +30,6 @@ static Uint8 font[][8] = {
30 30
 	{0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c},
31 31
 	{0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80}};
32 32
 
33
-Uint8
34
-readpixel(Uint8 *sprite, Uint8 h, Uint8 v)
35
-{
36
-	Uint8 ch1 = ((sprite[v] >> h) & 0x1);
37
-	Uint8 ch2 = (((sprite[v + 8] >> h) & 0x1) << 1);
38
-	return ch1 + ch2;
39
-}
40
-
41 33
 void
42 34
 clear(Ppu *p)
43 35
 {
... ...
@@ -235,16 +235,8 @@ system_talk(Device *d, Uint8 b0, Uint8 w)
235 235
 void
236 236
 console_talk(Device *d, Uint8 b0, Uint8 w)
237 237
 {
238
-	char buffer[7], *p = buffer;
239
-	int len = 0;
240
-	if(!w) return;
241
-	switch(b0) {
242
-	case 0x8: len = 1, p = (char *)&d->dat[0x8]; break;
243
-	case 0x9: len = sprintf(p, "0x%02x", d->dat[0x9]); break;
244
-	case 0xb: len = sprintf(p, "0x%04x", mempeek16(d->dat, 0xa)); break;
245
-	case 0xd: len = strlen(p = (char *)&d->mem[mempeek16(d->dat, 0xc)]); break;
246
-	}
247
-	if(len) write(1, p, len);
238
+	if(w && b0 == 0x8)
239
+		write(1, (char *)&d->dat[0x8], 1);
248 240
 }
249 241
 
250 242
 void