home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name kbready -- Return a character and scan code if one is
- * ready in the keyboard buffer.
- * (Formerly called UTRDYKEY.)
- *
- * Synopsis isrdy = kbready(pch,pscan);
- *
- * int isrdy 1 if a character is in the buffer,
- * 0 if not.
- * char *pch If a character is ready, the character
- * is returned.
- * int *pscan If a character is ready, its scan code
- * is returned.
- *
- * Description This function returns the character and scan code of the
- * next character in the BIOS type-ahead buffer if one is
- * ready. If the buffer is empty, the values of *pch and
- * *pscan are both undefined.
- *
- * KBREADY is similar to KBIN, but the latter suspends
- * execution until the buffer has an available character.
- * Moreover, KBIN removes the waiting character from the
- * buffer, while KBREADY leaves the character waiting to be
- * read again.
- *
- * Returns isrdy Character ready flag: 1 if ready, 0 if not.
- * *pch Next character in buffer.
- * *pscan Next scan code in the buffer.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1984, 1985, 1986
- *
- **/
-
- #include <bkeybd.h>
- #include <butility.h>
-
- int kbready(pch,pscan)
- int *pscan;
- char *pch;
- {
- int ax,bx,cx,dx,flags; /* General registers */
-
- /* The BIOS function 22 to query the status of the keyboard buffer.*/
-
- flags = 0;
- ax = 0x0100;
- bios(22,&ax,&bx,&cx,&dx,&flags);
- if ((flags & 0x40) == 0) /* ZF = 0 */
- {
- *pscan = uthibyte(ax); /* The scan code */
- *pch = (char)utlobyte(ax);
- return(1);
- }
- return(0);
- }