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

John Collyer johncollyer at zoominternet.net
Sun Dec 7 18:52:05 EST 2003


Get the cgfx library located at RTSI you'll find lots of useful stuff

/*
More multi-vue functions for the CGFX library
by Mike Sweet 10/10/89
*/

#include <lowio.h>
#include <mouse.h>
#include <sgstat.h>

static MSRET mp; /* mouse data packet */
static struct sgbuf oldopts,newopts;

/*
int MouseKey(path)
int path;

  Returns a keypress from path if one is available, or returns -1 or -2 if
one of the mouse buttons has been pressed (-1=left button, -2=right button.)
If neither a keypress is ready nor a button is pressed, then it returns a 0.
*/

int MouseKey(path)
register int path;
{
 char ch; /* character variable used to read a character from the window */

 _gs_opt(path,&oldopts);
 _gs_opt(path,&newopts);
 newopts.sg_echo=newopts.sg_kbich=newopts.sg_kbach=0;
 _ss_opt(path,&newopts);

 while (TRUE)
  {
   if (_gs_rdy(path)>0) /* chars ready? */
    {
     read(path,&ch,1); /* get the waiting character */
     _ss_opt(path,&oldopts);
     return(ch); /* and give it to the caller */
    }
   else
    {
     _gs_mous(path,&mp);
     if (!mp.pt_valid)
      continue;

     if (mp.pt_cbsa) /* if the left button has been pressed...*/
      {
       _ss_opt(path,&oldopts);
       tsleep(15);
       return(-1); /* return a -1 for left button */
      }
     else if (mp.pt_cctb) /* else if the right button has been pressed...*/
      {
       _ss_opt(path,&oldopts);
       tsleep(15);
       return(-2); /* return -2 for the right button */
      };
    };
  };
}

John Collyer

----- Original Message ----- 
From: "Mannequin*" <mannequin at primary.net>
To: "cocolist" <ColorComputer at yahoogroups.com>
Sent: Sunday, December 07, 2003 6:08 PM
Subject: [Coco] Re: [Color Computer] Inkey for Microware C Compiler


> On Sat, 6 Dec 2003 22:52:20 EST
> KnudsenMJ-YDxpq3io04c at public.gmane.org wrote:
>
> > In a message dated 12/6/03 6:54:27 PM Eastern Standard Time,
> > mannequin-n6Ta2snkUAvR7s880joybQ at public.gmane.org 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.
>
> Sounds good. I need something to look at, so I can take a good learning
> step.
>
> > 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.
> > 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.
> >
> > 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.
> > --Mike K.
>
> Yeah, I've had experience with such a beast under Linux. Garbage code is
> a very appropriate name for it. :)
>
> Thanks for your help!
> - Mannequin*
>
> ------------------------ Yahoo! Groups Sponsor ---------------------~-->
> Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
> Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
> http://www.c1tracking.com/l.asp?cid=5511
> http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/CFFolB/TM
> ---------------------------------------------------------------------~->
>
> Brought to you by the 6809, the 6803 and their cousins!
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
>




More information about the Coco mailing list