diff --git a/tools.c b/tools.c index 35a86ed..4a68ae0 100755 --- a/tools.c +++ b/tools.c @@ -7,19 +7,35 @@ int key_pressed(void) { +#ifdef __WATCOMC__ + /* + * Open Watcom's WORDREGS does not expose x.flags. The old Borland + * code checked the BIOS INT 16h ZF bit after AH=01h. Open Watcom's + * bios.h provides _bios_keybrd(), which wraps the same BIOS keyboard + * service and returns 0 when no key is waiting. + */ + return(_bios_keybrd(_KEYBRD_READY) != 0); +#else REGS regsin, regsout; regsin.h.ah = 0x01; /* read key-press */ int86(0x16, ®sin, ®sout); return((regsout.x.flags & 0x40) ? 0 : 1); /* zeroflag != 0 */ +#endif } void clear_kb(void) { +#ifdef __WATCOMC__ + while (key_pressed()) { + (void)_bios_keybrd(_KEYBRD_READ); + } +#else REGS regsin, regsout; while (key_pressed()) { /* zeroflag != 0 */ regsin.h.ah = 0x00; /* read key-press */ int86(0x16, ®sin, ®sout); } +#endif } int ask_user(char *p, ...)