home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 01e / more_ddj.zip / B_GETC.C next >
Text File  |  1986-09-27  |  1KB  |  35 lines

  1.    /*                 Listing 2 -- b_getc.c              */
  2.    /*---------------------------------------------------------------------*/
  3.    #include <stdio.h>
  4.    #include <dos.h>
  5.  
  6.    /*    B_GETC.C       Get a character with a direct video bios call.
  7.     *               this routine can be used to complement stderr as
  8.     *    it can be used to get characters from the keyboard, even when input
  9.     *    redirected. The typed character is returned in the low byte of the
  10.     *    returned integer, the high byte holds the auxillary byte used to
  11.     *    mark ALT keys and such. See the Technical Ref for more info.
  12.     *
  13.     *    Copyright (C) 1985 Allen I. Holub. All rights reserved.
  14.     *
  15.     *----------------------------------------------------------------------
  16.     */
  17.  
  18.   extern int int86(int, union REGS *, union REGS *);
  19.  
  20.   /*----------------------------------------------------------------------*/
  21.  
  22.   #define KB_INT  0x16      /*      Keyboard BIOS interrupt          */
  23.   #define GETC      0x00      /*      Getc is service 0              */
  24.  
  25.  
  26.   int      b_getc()
  27.   {
  28.       union REGS      Regs;
  29.  
  30.       Regs.h.ah = GETC ;
  31.       int86( KB_INT, &Regs, &Regs );
  32.       return( (int)Regs.x.ax );
  33.   }
  34.  
  35.