home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / BIOSKEY.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.0 KB  |  71 lines

  1. /*---------------------------------------------------------------------------
  2.  * filename - bioskey.cas
  3.  *
  4.  * function(s)
  5.  *        bioskey - keyboard interface
  6.  *--------------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18.  
  19. #pragma inline
  20. #include <asmrules.h>
  21. #include <bios.h>
  22.  
  23.  
  24. /*--------------------------------------------------------------------------*
  25.  
  26. Name        bioskey - keyboard interface
  27.  
  28. Usage        int bioskey(int cmd);
  29.  
  30. Prototype in    bios.h
  31.  
  32. Description    performs various keyboard operations using BIOS
  33.         interrupt 0x16.  The parameter cmd determines the exact
  34.         function:
  35.  
  36.             0 = Get next key
  37.             1 = Test for key
  38.             2 = Get shift status
  39.  
  40. Return value  value return to the AX register for the function specified
  41.               when cmd is 0 or 2.  
  42.               
  43.               When cmd is 1 it returns zero if no key is waiting, 0xFFFF
  44.               if control break was pressed, otherwise the keycode.
  45.  
  46. *---------------------------------------------------------------------------*/
  47.  
  48. int bioskey(int cmd)
  49. {
  50.     asm    MOV    AH, cmd
  51.     asm    INT    16h
  52.     asm    JZ    nokey
  53.  
  54. key:
  55.     asm    CMP    BYTE PTR (cmd), 1
  56.     asm    JNE    keydone
  57.     asm OR  AX, AX
  58.     asm JNZ keydone
  59.     asm MOV AX, 0FFFFh
  60.     asm JMP keydone
  61.  
  62. nokey:
  63.     asm    CMP    BYTE PTR (cmd), 1
  64.     asm    JNE    keydone
  65.     asm XOR AX, AX
  66.  
  67. keydone:
  68.     return _AX;
  69. }
  70.  
  71.