diff --git a/subsystems/ntvdm/bios.c b/subsystems/ntvdm/bios.c index efb37182d91..7807e67c75d 100644 --- a/subsystems/ntvdm/bios.c +++ b/subsystems/ntvdm/bios.c @@ -1132,9 +1132,9 @@ VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack) { BYTE ScanCode, VirtualKey; WORD Character; - + /* Loop while there is a scancode available */ - while (KeyboardReadStatus() & 1) + do { /* Get the scan code and virtual key code */ ScanCode = KeyboardReadData(); @@ -1173,6 +1173,7 @@ VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack) BiosKeyboardMap[VirtualKey] &= ~(1 << 7); } } + while (KeyboardReadStatus() & 1); /* Clear the keyboard flags */ Bda->KeybdShiftFlags = 0; diff --git a/subsystems/ntvdm/ps2.c b/subsystems/ntvdm/ps2.c index 034d81129f7..e17c3d2156b 100644 --- a/subsystems/ntvdm/ps2.c +++ b/subsystems/ntvdm/ps2.c @@ -20,7 +20,7 @@ static BYTE KeyboardQueue[KEYBOARD_BUFFER_SIZE]; static BOOLEAN KeyboardQueueEmpty = TRUE; static UINT KeyboardQueueStart = 0; static UINT KeyboardQueueEnd = 0; -static BYTE KeyboardResponse = 0; +static BYTE KeyboardData = 0, KeyboardResponse = 0; static BOOLEAN KeyboardReadResponse = FALSE, KeyboardWriteResponse = FALSE; static BYTE KeyboardConfig = PS2_DEFAULT_CONFIG; @@ -190,19 +190,19 @@ VOID KeyboardWriteCommand(BYTE Command) BYTE KeyboardReadData() { - BYTE Value = 0; - /* If there was a response byte from the controller, return it */ if (KeyboardReadResponse) { KeyboardReadResponse = FALSE; - return KeyboardResponse; + KeyboardData = KeyboardResponse; + } + else + { + /* Otherwise, read the data from the queue */ + KeyboardQueuePop(&KeyboardData); } - - /* Otherwise, read the data from the queue */ - KeyboardQueuePop(&Value); - return Value; + return KeyboardData; } VOID KeyboardWriteData(BYTE Data)