[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Wed, 14 May 2014 20:56:21 +0000 (20:56 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Wed, 14 May 2014 20:56:21 +0000 (20:56 +0000)
Don't calculate NextElement twice.
Properly initialize the keyboard buffer head and tail.

svn path=/trunk/; revision=63302

reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c

index fdc5b40..d3a4ad8 100644 (file)
@@ -39,14 +39,7 @@ static BOOLEAN BiosKbdBufferPush(WORD Data)
 
     /* Put the value in the queue */
     *((LPWORD)((ULONG_PTR)Bda + Bda->KeybdBufferTail)) = Data;
 
     /* Put the value in the queue */
     *((LPWORD)((ULONG_PTR)Bda + Bda->KeybdBufferTail)) = Data;
-    Bda->KeybdBufferTail += sizeof(WORD);
-
-    /* Check if we are at, or have passed, the end of the buffer */
-    if (Bda->KeybdBufferTail >= Bda->KeybdBufferEnd)
-    {
-        /* Return it to the beginning */
-        Bda->KeybdBufferTail = Bda->KeybdBufferStart;
-    }
+    Bda->KeybdBufferTail = NextElement;
 
     /* Return success */
     return TRUE;
 
     /* Return success */
     return TRUE;
@@ -271,7 +264,7 @@ BOOLEAN KbdBios32Initialize(VOID)
     /* Initialize the BDA */
     Bda->KeybdBufferStart = FIELD_OFFSET(BIOS_DATA_AREA, KeybdBuffer);
     Bda->KeybdBufferEnd   = Bda->KeybdBufferStart + BIOS_KBD_BUFFER_SIZE * sizeof(WORD);
     /* Initialize the BDA */
     Bda->KeybdBufferStart = FIELD_OFFSET(BIOS_DATA_AREA, KeybdBuffer);
     Bda->KeybdBufferEnd   = Bda->KeybdBufferStart + BIOS_KBD_BUFFER_SIZE * sizeof(WORD);
-    Bda->KeybdBufferHead  = Bda->KeybdBufferTail = 0;
+    Bda->KeybdBufferHead  = Bda->KeybdBufferTail = Bda->KeybdBufferStart;
 
     // FIXME: Fill the keyboard buffer with invalid values, for diagnostic purposes...
     RtlFillMemory(((LPVOID)((ULONG_PTR)Bda + Bda->KeybdBufferStart)), BIOS_KBD_BUFFER_SIZE * sizeof(WORD), 'A');
 
     // FIXME: Fill the keyboard buffer with invalid values, for diagnostic purposes...
     RtlFillMemory(((LPVOID)((ULONG_PTR)Bda + Bda->KeybdBufferStart)), BIOS_KBD_BUFFER_SIZE * sizeof(WORD), 'A');