~rabbits/uxn

1

A fancy new console port

Details
Message ID
<CAE2DaSR8nb0D0ESreoBkHjLmTO9sJQKaM9SN9C6De5CfLyyHtQ@mail.gmail.com>
DKIM signature
missing
Download raw message
Hello everyone,

Here's a little something that has been requested over and over again.
A way to detect when the argument stream ends.

This is basically an implementation of zzo38's design with a little
tweak, btw you should check out their wonderful uxn(sdl1) emulator.

http://zzo38computer.org/fossil/uxn.ui/artifact/118c1b297949fdd4

So, the design goes something like this:

The console vector* is evaluated when a byte is received. The type
port holds one of 5 known types(a byte really): no-queue(0), stdin(1),
argument(2), argument-spacer(3), argument-end(4). Here are what the
types look like during the different steps of the arguments stream:

uxncli file.rom arg1 arg2
                ^   ^^   ^
                2   32   4

During the reset vector, a program should be able to query the type
port and get a null byte when there is no arguments queued. So
basically, if there's nothing following the rom filename when
launching the emulator, the byte should be 0x00, otherwise 0x01. You
won't be able to read the /read port value outside of the console
vector, but you will be able to tell if there's something coming up.

The implementation for this is pretty straight-forward, it's basically
just this one extra line, and passing the type during console_input:

https://git.sr.ht/~rabbits/uxn/tree/main/item/src/uxncli.c#L55

I've written a test file that handles the various possible type values:

https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/examples/devices/console.tal

The expected result should be something like this:

Welcome to Uxn!
(queue)
(arg)You sent: "arg1"
(arg)You sent: "arg2"
(arg)You sent: "arg3"
(argend)
hello
(std)You said: "hello"

It detects a queue of arguments, prints each argument with the arg
type, detects the end of arguments, and listens to stdin normally.

I hope you enjoy this little addition to the console device! Let me
know if you have any questions/suggestions :)

Dll
Details
Message ID
<ZD2ajO2t2S9qN8GY@vein.plastic-idolatry.com>
In-Reply-To
<CAE2DaSR8nb0D0ESreoBkHjLmTO9sJQKaM9SN9C6De5CfLyyHtQ@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
On Mon, Apr 17, 2023 at 11:44:22AM -0700, Devine Lu Linvega wrote:
> Here's a little something that has been requested over and over again.
> A way to detect when the argument stream ends.
> 
> This is basically an implementation of zzo38's design with a little
> tweak, btw you should check out their wonderful uxn(sdl1) emulator.

This is really great! I've wanted to write more command-line
tools that accept optional arguments as well as data on stdin
and this change will make that possible!

Thanks zzo38 and Devine!

-- d_m
Reply to thread Export thread (mbox)