home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name kbin -- Return a character or scan code from the
- * keyboard.
- * (Formerly called UTINKEY.)
- *
- * Synopsis isch = kbin(pscan);
- *
- * int isch 1 if a character is entered,
- * 0 if an extended key sequence is
- * entered.
- * int *pscan For a character (ASCII code 0 - 255),
- * the ASCII code is returned; for an
- * extended key sequence, the scan code
- * is returned.
- *
- * Description This function waits for a key sequence to be pressed
- * (unless one is already waiting in the BIOS typeahead
- * buffer) and then returns either the ASCII code for the
- * character or the scan code for the extended character
- * sequence. If an ASCII character is entered, the value
- * of the function is 1; otherwise it is 0. See also the
- * function KBREADY.
- *
- * Returns isch Flag: 1 if a character is entered,
- * 0 if an extended key sequence is
- * entered.
- * pscan Pointer to either the ASCII code or
- * scan code
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- **/
-
- #include <bkeybd.h>
- #include <butility.h>
-
- int kbin(pscan)
- int *pscan;
- {
- int ax,bx,cx,dx,flags; /* General registers */
-
- /* The BIOS function 22 is called because getch() does not trap */
- /* Ctrl/Break or return scan codes. DOS functions 1 or 8 are not */
- /* used because those functions trap Ctrl/Q, Ctrl/P and some */
- /* others. */
-
- ax = 0;
- bios(22,&ax,&bx,&cx,&dx,&flags);
- *pscan = uthibyte(ax); /* The scan code */
- if (utlobyte(ax) == 0) /* Extended sequence typed */
- return(0);
-
- *pscan = utlobyte(ax); /* Character typed */
- return(1);
- }