[NTVDM]
[reactos.git] / subsystems / ntvdm / bios.c
index d21bd1e..7807e67 100644 (file)
@@ -596,13 +596,9 @@ WORD BiosPeekCharacter(VOID)
 {
     WORD CharacterData;
     
-    /* Check if there is a key available */
-    if (Bda->KeybdBufferHead == Bda->KeybdBufferTail) return 0xFFFF;
-
     /* Get the key from the queue, but don't remove it */
-    BiosKbdBufferTop(&CharacterData);
-
-    return CharacterData;
+    if (BiosKbdBufferTop(&CharacterData)) return CharacterData;
+    else return 0xFFFF;
 }
 
 WORD BiosGetCharacter(VOID)
@@ -1136,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();
@@ -1169,8 +1165,7 @@ VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack)
                     }
 
                     /* Push it onto the BIOS keyboard queue */
-                    BiosKbdBufferPush((ScanCode << 8) | (Character & 0xFF));
-
+                    BiosKbdBufferPush(MAKEWORD(Character, ScanCode));
                 }
                 else
                 {
@@ -1178,6 +1173,7 @@ VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack)
                     BiosKeyboardMap[VirtualKey] &= ~(1 << 7);
                 }
             }
+            while (KeyboardReadStatus() & 1);
 
             /* Clear the keyboard flags */
             Bda->KeybdShiftFlags = 0;