[NTVDM]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 3 Nov 2014 21:27:20 +0000 (21:27 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 3 Nov 2014 21:27:20 +0000 (21:27 +0000)
- Fix the BIOS32 Wait hack (Sleep takes a duration in milliseconds, whereas the BIOS function takes the duration in microseconds).
- Initialize the PIT channels with realistic values (realistic == found on real BIOSes).
- Remove unneeded commented code.

svn path=/trunk/; revision=65237

reactos/subsystems/ntvdm/bios/bios32/bios32.c
reactos/subsystems/ntvdm/dos/mouse32.c
reactos/subsystems/ntvdm/hardware/keyboard.c
reactos/subsystems/ntvdm/hardware/mouse.c

index ba07df8..19725a0 100644 (file)
@@ -166,7 +166,9 @@ static VOID WINAPI BiosMiscService(LPWORD Stack)
              * See Ralf Brown: http://www.ctyme.com/intr/rb-1525.htm
              * for more information.
              */
-            Sleep(MAKELONG(getDX(), getCX()));
+
+            // HACK: For now, use the Win32 API (that takes time in milliseconds).
+            Sleep(MAKELONG(getDX(), getCX()) / 1000);
 
             /* Clear CF */
             Stack[STACK_FLAGS] &= ~EMULATOR_FLAG_CF;
@@ -471,20 +473,23 @@ static VOID BiosHwSetup(VOID)
     IOWriteB(PIC_SLAVE_DATA , 0xFF);
 
 
-    /* Initialize PIT Counter 0 */
+    /* Initialize PIT Counter 0 - Mode 2, 16bit binary count */
+    // NOTE: Some BIOSes set it to Mode 3 instead.
     IOWriteB(PIT_COMMAND_PORT, 0x34);
+    // 18.2Hz refresh rate
     IOWriteB(PIT_DATA_PORT(0), 0x00);
     IOWriteB(PIT_DATA_PORT(0), 0x00);
 
-    /* Initialize PIT Counter 1 */
-    IOWriteB(PIT_COMMAND_PORT, 0x74);
-    IOWriteB(PIT_DATA_PORT(1), 0x00);
-    IOWriteB(PIT_DATA_PORT(1), 0x00);
+    /* Initialize PIT Counter 1 - Mode 2, 8bit binary count */
+    IOWriteB(PIT_COMMAND_PORT, 0x54);
+    // DRAM refresh every 15ms: http://www.cs.dartmouth.edu/~spl/Academic/Organization/docs/PC%20Timer%208253.html
+    IOWriteB(PIT_DATA_PORT(1),   18);
 
-    /* Initialize PIT Counter 2 */
-    IOWriteB(PIT_COMMAND_PORT, 0xB4);
-    IOWriteB(PIT_DATA_PORT(2), 0x00);
-    IOWriteB(PIT_DATA_PORT(2), 0x00);
+    /* Initialize PIT Counter 2 - Mode 3, 16bit binary count */
+    IOWriteB(PIT_COMMAND_PORT, 0xB6);
+    // Count for 440Hz
+    IOWriteB(PIT_DATA_PORT(2), 0x97);
+    IOWriteB(PIT_DATA_PORT(2), 0x0A);
 
     EnableHwIRQ(0, BiosTimerIrq);
 }
index acf3f83..08ad22d 100644 (file)
@@ -327,11 +327,11 @@ static VOID WINAPI BiosMouseService(LPWORD Stack)
             DriverState.GraphicsCursor.HotSpot.X = getBX();
             DriverState.GraphicsCursor.HotSpot.Y = getCX();
 
-            RtlMoveMemory(DriverState.GraphicsCursor.ScreenMask,
+            RtlCopyMemory(DriverState.GraphicsCursor.ScreenMask,
                           MaskBitmap,
                           sizeof(DriverState.GraphicsCursor.ScreenMask));
 
-            RtlMoveMemory(DriverState.GraphicsCursor.CursorMask,
+            RtlCopyMemory(DriverState.GraphicsCursor.CursorMask,
                           &MaskBitmap[16],
                           sizeof(DriverState.GraphicsCursor.CursorMask));
 
index fbd1d7a..520d503 100644 (file)
@@ -41,8 +41,6 @@ VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
     }
 
     DPRINT("Press 0x%X\n", ScanCode);
-
-    // PicInterruptRequest(1);
 }
 
 BOOLEAN KeyboardInit(BYTE PS2Connector)
index f480d5b..7ddb5c4 100644 (file)
@@ -317,7 +317,6 @@ VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent)
     MouseBiosUpdateButtons(LOWORD(MouseEvent->dwButtonState));
 
     // PS2QueuePush(PS2Port, Data);
-    // PicInterruptRequest(12);
 }
 
 BOOLEAN MouseInit(BYTE PS2Connector)