From 274edad29da18a28a1e5e81031b4492a44a596e3 Mon Sep 17 00:00:00 2001 From: neauoire Date: Mon, 28 Jun 2021 09:40:29 -0700 Subject: [PATCH] Simplified console --- projects/examples/blank.tal | 2 +- projects/examples/demos/darena.tal | 4 --- projects/examples/demos/drum-rack.tal | 1 - projects/examples/demos/musictracker.tal | 1 - projects/examples/demos/neralie.tal | 1 - projects/examples/demos/piano.tal | 4 +-- projects/examples/devices/console.echo.tal | 14 +++++--- projects/examples/devices/console.tal | 4 +-- projects/examples/devices/controller.keys.tal | 4 --- projects/examples/gui/hover.tal | 3 -- projects/examples/gui/picture.tal | 1 - projects/examples/gui/shapes.tal | 1 - projects/software/hexes.tal | 32 +++++++++++++++++++ src/devices/ppu.c | 8 ----- src/uxnemu.c | 12 ++----- 15 files changed, 49 insertions(+), 43 deletions(-) create mode 100644 projects/software/hexes.tal diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal index 4bed974..3ec6666 100644 --- a/projects/examples/blank.tal +++ b/projects/examples/blank.tal @@ -11,7 +11,7 @@ ( devices ) |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 ] |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 ] diff --git a/projects/examples/demos/darena.tal b/projects/examples/demos/darena.tal index 0ef08b0..df22e95 100644 --- a/projects/examples/demos/darena.tal +++ b/projects/examples/demos/darena.tal @@ -2,9 +2,6 @@ ( an open-ended game of rocks and sand ) ( contributed by and cc0 sejo 12021 ) -%DEBUG { .Console/byte DEO #0a .Console/char DEO } -%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO } - ( parameters ) %nrocks { #1f } %nrocks-1 { #1e } @@ -37,7 +34,6 @@ ( devices ) |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 ] |80 @Controller [ &vector $2 &button $1 &key $1 ] diff --git a/projects/examples/demos/drum-rack.tal b/projects/examples/demos/drum-rack.tal index 69c45ad..1c6d540 100644 --- a/projects/examples/demos/drum-rack.tal +++ b/projects/examples/demos/drum-rack.tal @@ -24,7 +24,6 @@ ( devices ) |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 ] |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 ] diff --git a/projects/examples/demos/musictracker.tal b/projects/examples/demos/musictracker.tal index a32d06c..346de5a 100644 --- a/projects/examples/demos/musictracker.tal +++ b/projects/examples/demos/musictracker.tal @@ -23,7 +23,6 @@ ( devices ) |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 ] |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 ] diff --git a/projects/examples/demos/neralie.tal b/projects/examples/demos/neralie.tal index 77dad59..deaefa8 100644 --- a/projects/examples/demos/neralie.tal +++ b/projects/examples/demos/neralie.tal @@ -13,7 +13,6 @@ ( devices ) |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 ] |b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] diff --git a/projects/examples/demos/piano.tal b/projects/examples/demos/piano.tal index 463c47c..c962058 100644 --- a/projects/examples/demos/piano.tal +++ b/projects/examples/demos/piano.tal @@ -19,7 +19,7 @@ ( devices ) |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 ] |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 ¬e $1 &velocity $1 ] @@ -155,7 +155,7 @@ BRK @on-message ( -> ) - .Console/rbyte DEI ;play JSR2 + .Console/read DEI ;play JSR2 ;draw-octave JSR2 BRK diff --git a/projects/examples/devices/console.echo.tal b/projects/examples/devices/console.echo.tal index 0ff1348..8d35833 100644 --- a/projects/examples/devices/console.echo.tal +++ b/projects/examples/devices/console.echo.tal @@ -1,14 +1,20 @@ ( 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 ) |0100 ( -> ) + ;on-stdin .Console/vector DEO2 + BRK @on-stdin ( -> ) - .Console/char DEI .Console/byte DEO - #0a .Console/char DEO -BRK \ No newline at end of file + + .Console/read DEI .Console/write DEO + +BRK + diff --git a/projects/examples/devices/console.tal b/projects/examples/devices/console.tal index 1c91fb9..b3275c9 100644 --- a/projects/examples/devices/console.tal +++ b/projects/examples/devices/console.tal @@ -1,6 +1,6 @@ ( dev/console ) -|10 @Console [ &pad $8 &char ] +|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ] ( init ) @@ -9,7 +9,7 @@ ;hello-word &loop - ( send ) LDAk .Console/char DEO + ( send ) LDAk .Console/write DEO ( incr ) #0001 ADD2 ( loop ) LDAk ,&loop JCN POP2 diff --git a/projects/examples/devices/controller.keys.tal b/projects/examples/devices/controller.keys.tal index ba095ec..4b74906 100644 --- a/projects/examples/devices/controller.keys.tal +++ b/projects/examples/devices/controller.keys.tal @@ -8,13 +8,9 @@ %RTN { JMP2r } %TOS { #00 SWP } -%DEBUG { .Console/byte DEO #0a .Console/char DEO } -%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO } - ( devices ) |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 ] |80 @Controller [ &vector $2 &button $1 &key $1 ] diff --git a/projects/examples/gui/hover.tal b/projects/examples/gui/hover.tal index 37efcba..a08564d 100644 --- a/projects/examples/gui/hover.tal +++ b/projects/examples/gui/hover.tal @@ -1,13 +1,10 @@ ( GUI Hover ) %RTN { JMP2r } -%DEBUG { .Console/byte DEO #0a .Console/char DEO } -%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO } ( devices ) |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 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] diff --git a/projects/examples/gui/picture.tal b/projects/examples/gui/picture.tal index 2c935ad..6f833c3 100644 --- a/projects/examples/gui/picture.tal +++ b/projects/examples/gui/picture.tal @@ -6,7 +6,6 @@ ( devices ) |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 ] |a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] diff --git a/projects/examples/gui/shapes.tal b/projects/examples/gui/shapes.tal index a812440..b93be85 100644 --- a/projects/examples/gui/shapes.tal +++ b/projects/examples/gui/shapes.tal @@ -17,7 +17,6 @@ ( devices ) |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 ] ( variables ) diff --git a/projects/software/hexes.tal b/projects/software/hexes.tal new file mode 100644 index 0000000..d549932 --- /dev/null +++ b/projects/software/hexes.tal @@ -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 + diff --git a/src/devices/ppu.c b/src/devices/ppu.c index 014ea0e..add2a46 100644 --- a/src/devices/ppu.c +++ b/src/devices/ppu.c @@ -30,14 +30,6 @@ static Uint8 font[][8] = { {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c}, {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 clear(Ppu *p) { diff --git a/src/uxnemu.c b/src/uxnemu.c index f532c91..d618520 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -235,16 +235,8 @@ system_talk(Device *d, Uint8 b0, Uint8 w) void console_talk(Device *d, Uint8 b0, Uint8 w) { - char buffer[7], *p = buffer; - int len = 0; - 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); + if(w && b0 == 0x8) + write(1, (char *)&d->dat[0x8], 1); } void