Simplified console

This commit is contained in:
neauoire 2021-06-28 09:40:29 -07:00
parent e309ebf6e8
commit 274edad29d
15 changed files with 49 additions and 43 deletions

View File

@ -11,7 +11,7 @@
( devices ) ( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] |10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]

View File

@ -2,9 +2,6 @@
( an open-ended game of rocks and sand ) ( an open-ended game of rocks and sand )
( contributed by and cc0 sejo 12021 ) ( contributed by and cc0 sejo 12021 )
%DEBUG { .Console/byte DEO #0a .Console/char DEO }
%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
( parameters ) ( parameters )
%nrocks { #1f } %nrocks { #1f }
%nrocks-1 { #1e } %nrocks-1 { #1e }
@ -37,7 +34,6 @@
( devices ) ( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ]
|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ] |80 @Controller [ &vector $2 &button $1 &key $1 ]

View File

@ -24,7 +24,6 @@
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]

View File

@ -23,7 +23,6 @@
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ] |30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ]
|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ] |40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ]

View File

@ -13,7 +13,6 @@
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] |b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]

View File

@ -19,7 +19,7 @@
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &rbyte $1 &pad $5 &char $1 &wbyte $1 &short $2 &string $2 ] |10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|70 @Midi [ &vector $2 &channel $1 &note $1 &velocity $1 ] |70 @Midi [ &vector $2 &channel $1 &note $1 &velocity $1 ]
@ -155,7 +155,7 @@ BRK
@on-message ( -> ) @on-message ( -> )
.Console/rbyte DEI ;play JSR2 .Console/read DEI ;play JSR2
;draw-octave JSR2 ;draw-octave JSR2
BRK BRK

View File

@ -1,14 +1,20 @@
( dev/console ) ( dev/console )
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] %RTN { JMP2r }
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
( init ) ( init )
|0100 ( -> ) |0100 ( -> )
;on-stdin .Console/vector DEO2 ;on-stdin .Console/vector DEO2
BRK BRK
@on-stdin ( -> ) @on-stdin ( -> )
.Console/char DEI .Console/byte DEO
#0a .Console/char DEO .Console/read DEI .Console/write DEO
BRK
BRK

View File

@ -1,6 +1,6 @@
( dev/console ) ( dev/console )
|10 @Console [ &pad $8 &char ] |10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
( init ) ( init )
@ -9,7 +9,7 @@
;hello-word ;hello-word
&loop &loop
( send ) LDAk .Console/char DEO ( send ) LDAk .Console/write DEO
( incr ) #0001 ADD2 ( incr ) #0001 ADD2
( loop ) LDAk ,&loop JCN ( loop ) LDAk ,&loop JCN
POP2 POP2

View File

@ -8,13 +8,9 @@
%RTN { JMP2r } %RTN { JMP2r }
%TOS { #00 SWP } %TOS { #00 SWP }
%DEBUG { .Console/byte DEO #0a .Console/char DEO }
%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ] |80 @Controller [ &vector $2 &button $1 &key $1 ]

View File

@ -1,13 +1,10 @@
( GUI Hover ) ( GUI Hover )
%RTN { JMP2r } %RTN { JMP2r }
%DEBUG { .Console/byte DEO #0a .Console/char DEO }
%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]

View File

@ -6,7 +6,6 @@
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] |a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]

View File

@ -17,7 +17,6 @@
( devices ) ( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
( variables ) ( variables )

View File

@ -0,0 +1,32 @@
( hexes
A small utility that prints incoming console messages as hex values. )
%RTN { JMP2r }
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
( init )
|0100 ( -> )
;on-message .Console/vector DEO2
BRK
@on-message ( -> )
.Console/read DEI ,print-hex JSR
BRK
@print-hex ( value -- )
STHk #04 SFT ,&parse JSR .Console/write DEO
STHr #0f AND ,&parse JSR .Console/write DEO
RTN
&parse ( value -- char )
DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
RTN

View File

@ -30,14 +30,6 @@ static Uint8 font[][8] = {
{0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c}, {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c},
{0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80}}; {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80}};
Uint8
readpixel(Uint8 *sprite, Uint8 h, Uint8 v)
{
Uint8 ch1 = ((sprite[v] >> h) & 0x1);
Uint8 ch2 = (((sprite[v + 8] >> h) & 0x1) << 1);
return ch1 + ch2;
}
void void
clear(Ppu *p) clear(Ppu *p)
{ {

View File

@ -235,16 +235,8 @@ system_talk(Device *d, Uint8 b0, Uint8 w)
void void
console_talk(Device *d, Uint8 b0, Uint8 w) console_talk(Device *d, Uint8 b0, Uint8 w)
{ {
char buffer[7], *p = buffer; if(w && b0 == 0x8)
int len = 0; write(1, (char *)&d->dat[0x8], 1);
if(!w) return;
switch(b0) {
case 0x8: len = 1, p = (char *)&d->dat[0x8]; break;
case 0x9: len = sprintf(p, "0x%02x", d->dat[0x9]); break;
case 0xb: len = sprintf(p, "0x%04x", mempeek16(d->dat, 0xa)); break;
case 0xd: len = strlen(p = (char *)&d->mem[mempeek16(d->dat, 0xc)]); break;
}
if(len) write(1, p, len);
} }
void void