home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------
- * filename - bioskey.cas
- *
- * function(s)
- * bioskey - keyboard interface
- *--------------------------------------------------------------------------*/
-
- /*[]------------------------------------------------------------[]*/
- /*| |*/
- /*| Turbo C Run Time Library - Version 3.0 |*/
- /*| |*/
- /*| |*/
- /*| Copyright (c) 1987,1988,1990 by Borland International |*/
- /*| All Rights Reserved. |*/
- /*| |*/
- /*[]------------------------------------------------------------[]*/
-
-
- #pragma inline
- #include <asmrules.h>
- #include <bios.h>
-
-
- /*--------------------------------------------------------------------------*
-
- Name bioskey - keyboard interface
-
- Usage int bioskey(int cmd);
-
- Prototype in bios.h
-
- Description performs various keyboard operations using BIOS
- interrupt 0x16. The parameter cmd determines the exact
- function:
-
- 0 = Get next key
- 1 = Test for key
- 2 = Get shift status
-
- Return value value return to the AX register for the function specified
- when cmd is 0 or 2.
-
- When cmd is 1 it returns zero if no key is waiting, 0xFFFF
- if control break was pressed, otherwise the keycode.
-
- *---------------------------------------------------------------------------*/
-
- int bioskey(int cmd)
- {
- asm MOV AH, cmd
- asm INT 16h
- asm JZ nokey
-
- key:
- asm CMP BYTE PTR (cmd), 1
- asm JNE keydone
- asm OR AX, AX
- asm JNZ keydone
- asm MOV AX, 0FFFFh
- asm JMP keydone
-
- nokey:
- asm CMP BYTE PTR (cmd), 1
- asm JNE keydone
- asm XOR AX, AX
-
- keydone:
- return _AX;
- }
-
-