[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sun, 27 Oct 2013 16:34:27 +0000 (16:34 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sun, 27 Oct 2013 16:34:27 +0000 (16:34 +0000)
Simplify BiosPeekCharacter.
Implement DOS direct console I/O functions.

svn path=/branches/ntvdm/; revision=60772

subsystems/ntvdm/bios.c
subsystems/ntvdm/dos.c

index d21bd1e..efb3718 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)
@@ -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
                 {
index 9528a67..f52f94a 100644 (file)
@@ -1411,6 +1411,36 @@ VOID DosInt21h(LPWORD Stack)
             break;
         }
 
+        /* Direct Console I/O */
+        case 0x06:
+        {
+            BYTE Character = LOBYTE(Edx);
+
+            if (Character != 0xFF)
+            {
+                /* Output */
+                DosPrintCharacter(Character);
+            }
+            else
+            {
+                /* Input */
+                Eax &= 0xFFFFFF00;
+
+                if (DosCheckInput())
+                {
+                    Eax |= DosReadCharacter();
+                    Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_ZF;
+                }
+                else
+                {
+                    /* No character available */
+                    Stack[STACK_FLAGS] |= EMULATOR_FLAG_ZF;
+                }
+            }
+
+            break;
+        }
+
         /* Read Character Without Echo */
         case 0x07:
         case 0x08: