home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 5.ddi / CLIBSRC2.ZIP / BIOSKEY.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  2.2 KB  |  83 lines

  1. /*---------------------------------------------------------------------------
  2.  * filename - bioskey.cas
  3.  *
  4.  * function(s)
  5.  *        bioskey - keyboard interface
  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 <asmrules.h>
  19. #include <bios.h>
  20.  
  21.  
  22. /*--------------------------------------------------------------------------*
  23.  
  24. Name            bioskey - keyboard interface
  25.  
  26. Usage           int bioskey(int cmd);
  27.  
  28. Prototype in    bios.h
  29.  
  30. Description     performs various keyboard operations using BIOS
  31.                 interrupt 0x16.  The parameter cmd determines the exact
  32.                 function:
  33.  
  34.                 0x00 = Get next key
  35.                 0x01 = Test for key
  36.                 0x02 = Get shift status
  37.  
  38.                 0x10 = Get next key for enhanced keyboard
  39.                 0x11 = Test for key for enhanced keyboard
  40.                 0x12 = Get shift status for enhanced keyboard
  41.  
  42. Return value    value returned to the AX register for the function specified
  43.                 when cmd is 0x00, 0x10, 0x02, or 0x12.
  44.  
  45.                 When cmd is 0x01 or 0x11 it returns zero if no key is waiting,
  46.                 0xFFFF if control break was pressed, otherwise the keycode.
  47.  
  48. *---------------------------------------------------------------------------*/
  49.  
  50. int bioskey(int cmd)
  51. {
  52. //  Clear zero flag
  53.     asm xor  al, al
  54.  
  55.     asm mov  ah, cmd
  56.     asm int  16h
  57.  
  58. //  If zero flag set then no key is waiting
  59.     asm jz   nokey
  60.  
  61. //  If we aren't checking status, just return key
  62.     asm test byte ptr (cmd), 1
  63.     asm jz   keydone
  64.  
  65. //  Here we have status command and key waiting
  66. //  If keycode is zero (control-break) then signal with 0FFFFh
  67.     asm or   ax, ax
  68.     asm jnz  keydone
  69.     asm mov  ax, 0FFFFh
  70.     asm jmp  keydone
  71.  
  72. nokey:
  73. //  Zero flag wasn't set, if not checking status just return key
  74.     asm test byte ptr (cmd), 1
  75.     asm jz   keydone
  76.  
  77. //  Here we have status command and no key waiting
  78.     asm xor  ax, ax
  79.  
  80. keydone:
  81.     return _AX;
  82. }
  83.