[Coco] [Color Computer] Inkey for Microware C Compiler

David dbree at duo-county.com
Sun Dec 7 22:58:08 EST 2003


On Sat, Dec 06, 2003 at 10:52:20PM -0500, KnudsenMJ at aol.com wrote:
> In a message dated 12/6/03 6:54:27 PM Eastern Standard Time, 
> mannequin at primary.net writes:
> 
> > Does anyone know of a way to use Inkey (or make one) that can be used
> >  with Microware's C Compiler v1.00.00?
> 
> It's very simple, no asm needed, and I can post the code tomorrow.
> 1. Call getstt() to read the number of chars in the input buffer (channel 0). 
>  You can find the proper args in the manual.  You can do it all in C, using a 
> defined struct that represents the 6809's registers.  See the _os9() function.

If you have the Level 2 Development system (I believe it's from there),
you also have the _gs_rdy() function that returns the status of whether
a character is available.

> 2. If 0, return 0 or whatever code you choose for null char.
> 3. Otherwise, read one character with read(0, 1, &charvar) and return 
> charvar.  This read() call won't block, since you've pre-tested for at least one char 
> present.

Actually, though, for normal usage of the inkey() function, you'd
probably want it to block, wouldn't you?  In most cases, you'd be
expecting a single keystroke for a menu choice or the like.

> BTW, the existence of the stat call in step (1) is a major superiority of 
> OS-9 over UNIX or Linux in this regard, where a paragraph of garbage
> code is required to do a non-blocking read.  That's probably why the
> standard C I/O lib lacks such a call.

I guess there are ways around all this in unix/linux.  Remember some
time ago when you(?) and I were complaining about the lack of the
capability of a single-key input in linux?  Someone pointed out a very
simple solution to the problem.  I've thought about writing a library
inkey() function for linux, but haven't done so yet.




More information about the Coco mailing list