Article View: comp.sys.ibm.pc.programmer
Article #1380Re: Slow kbhit() fix
From: Jeff Pipkins
Date: Mon, 19 Feb 1990 22:47
Date: Mon, 19 Feb 1990 22:47
32 lines
2059 bytes
2059 bytes
In article <22242@pasteur.Berkeley.EDU> c60b-hk@buddy.Berkeley.EDU.UUCP (Geoffrey Broadwell) writes:
>I just caught an article referring to the fact that kbhit() is annoyingly
>slow. I have noticed this myself, and came up with the following function
>that responds quite a bit faster (I'm sure someone will one-up its speed,
>but what the hell -- it's simple! :-) ).
>
>char keypress(void)
>{
> _AH=0x01;
> geninterrupt(0x16);
> return(~_FLAGS&0x40);
>}
>
>I wrote it using TurboC 2.0, so if your compiler is different, the syntax
>is probably somewhat different, though it should be easily translatable.
>Good luck.
>BTW, I would be interested in being one-upped, if anyone is willing. :-)
I haven't heard complaints of kbhit() being slow, but I rewrote kbhit()
and several other related functions (including getch(), getche(), ungetch(),
and putch() ) because of several deficiencies in the ones that come with
the MSC compiler. These are written in assembly, callable from MSC or
Turdo C. The commented source code, along with documentation in similar
format to that of the MSC lib. ref, has apparently been uploaded to SIMTEL,
it is in PD:<MSDOS.C>CONIO.ARC. The C User's Journal also has it on file.
If none of these are accessible, I will be glad to e-mail a copy to anyone
sending a request to pipkins@imagen.com. Please include an '@'-style
return address, as '!' (bang) addresses are often uni-directional. Also,
I can't send to *.UUCP addresses.
-Jeff Pipkins
pipkins@imagen.com
Technical Details
Message-ID:
<114@qmsseq.imagen.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!helios.ee.lbl.gov!pasteur!ames!amdcad!sun!imagen!qmsseq!pipkinsReferences:
<I3S1182xds13@ficc.uu.net> <29@demott.COM> <22242@pasteur.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!helios.ee.lbl.gov!pasteur!ames!amdcad!sun!imagen!qmsseq!pipkins From: pipkins@qmsseq.imagen.com (Jeff Pipkins) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: Slow kbhit() fix Keywords: kbhit() Message-ID: <114@qmsseq.imagen.com> Date: 19 Feb 90 22:47:31 GMT References: <I3S1182xds13@ficc.uu.net> <29@demott.COM> <22242@pasteur.Berkeley.EDU> Reply-To: pipkins@qmsseq.UUCP (Jeff Pipkins) Distribution: usa Organization: QMS Inc., Mobile, Alabama Lines: 32