home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / KBHIT.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.4 KB  |  52 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - kbhit.cas
  3.  *
  4.  * function(s)
  5.  *        kbhit - checks for recent keystrokes
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma inline
  18. #include <conio.h>
  19.  
  20. /* The following variables are used in getch.cas */
  21.  
  22. unsigned char _cFlag = 0;       /* Flag presence of un-gotten char */
  23. unsigned char _cChar = 0;       /* The ungotten char               */
  24.  
  25. /*-----------------------------------------------------------------------*
  26.  
  27. Name            kbhit - checks for recent keystrokes
  28.  
  29. Usage           int kbhit(void);
  30.  
  31. Prototype in    conio.h
  32.  
  33. Description     kbhit checks to see if a keystroke is currently
  34.                 available. Any available keystrokes can be retrieved with
  35.                 getch or getche.
  36.  
  37. Return value    If a keystroke is available, kbhit returns a
  38.                 non-zero integer. If not, it returns 0.
  39.  
  40. *------------------------------------------------------------------------*/
  41. int kbhit( void )
  42. {
  43.         if (_cFlag)             /* has a character been ungetch'd? */
  44.                 return (1);
  45.  
  46. asm     mov     ah, 0Bh
  47. asm     int     21h
  48. asm     cbw
  49.  
  50.         return( _AX );
  51. }
  52.