commit 91fedff46d76d6e3f0f28209eb1a17353e7ef820
parent 78cd9981773a77e104c72d65ea170ad9dd604a98
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date: Sun, 11 Jul 2021 17:51:11 +0100
Extended Console to write to FD 2-8 (most useful for 2, stderr)
Diffstat:
4 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal
@@ -13,7 +13,7 @@
( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ]
-|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
+|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $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/devices/console.echo.tal b/projects/examples/devices/console.echo.tal
@@ -1,8 +1,12 @@
( dev/console )
+(
+ Copies data from stdin to both stdout and stderr.
+)
+
%RTN { JMP2r }
-|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
+|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
( init )
@@ -14,7 +18,9 @@ BRK
@on-stdin ( -> )
- .Console/read DEI .Console/write DEO
+ .Console/read DEI
+ DUP .Console/write DEO
+ .Console/error DEO
BRK
diff --git a/src/uxncli.c b/src/uxncli.c
@@ -45,8 +45,8 @@ printstack(Stack *s)
static void
console_talk(Device *d, Uint8 b0, Uint8 w)
{
- if(w && b0 == 0x8)
- write(1, (char *)&d->dat[0x8], 1);
+ if(w && b0 > 0x7)
+ write(b0 - 0x7, (char *)&d->dat[b0], 1);
}
static void
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -238,8 +238,8 @@ system_talk(Device *d, Uint8 b0, Uint8 w)
static void
console_talk(Device *d, Uint8 b0, Uint8 w)
{
- if(w && b0 == 0x8)
- write(1, (char *)&d->dat[0x8], 1);
+ if(w && b0 > 0x7)
+ write(b0 - 0x7, (char *)&d->dat[b0], 1);
}
static void