fix tools for openwatcom

This commit is contained in:
Mario Fetka
2026-05-22 11:58:25 +02:00
parent af2f16add4
commit 6d005a1713

16
tools.c
View File

@@ -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, &regsin, &regsout);
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, &regsin, &regsout);
}
#endif
}
int ask_user(char *p, ...)