[NTVDM]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 11 Nov 2014 01:40:23 +0000 (01:40 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 11 Nov 2014 01:40:23 +0000 (01:40 +0000)
- Disable some DPRINTs and reenable some others (those concerning programs loading).
- INT 15h, AH=C2h calls a dedicated mouse bios function, which is stubplemented.
- Move part of the HW mouse / driver hack from the HW mouse module into the BIOS mouse.
- INT 33h: s/BiosMouseService/DosMouseService/, in this interrupt we need to check for function numbers in AL (not in AX :) fixes few apps).
- Reenable mouse user handler callbacks calls in CallMouseUserHandlers.
- Some apps (e.g. the demo from http://www.brackeen.com/vga/mouse.html ) draw by themselves the cursor and do not bother to call the INT 33h "Show cursor" function, but expects that moving the mouse we report its correct position. Fix DosMouseUpdatePosition so that it always updates the stored mouse position, but redraws it only when the cursor is shown.

svn path=/trunk/; revision=65374

reactos/subsystems/ntvdm/bios/bios32/bios32.c
reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c
reactos/subsystems/ntvdm/bios/bios32/moubios32.c
reactos/subsystems/ntvdm/bios/bios32/moubios32.h
reactos/subsystems/ntvdm/dos/dem.c
reactos/subsystems/ntvdm/dos/dos32krnl/dos.c
reactos/subsystems/ntvdm/dos/mouse32.c
reactos/subsystems/ntvdm/dos/mouse32.h
reactos/subsystems/ntvdm/hardware/mouse.c

index bc8095a..bff238b 100644 (file)
@@ -264,7 +264,7 @@ static VOID WINAPI BiosMiscService(LPWORD Stack)
         /* Pointing Device BIOS Interface (PS) */
         case 0xC2:
         {
         /* Pointing Device BIOS Interface (PS) */
         case 0xC2:
         {
-            DPRINT1("INT 15h, AH = C2h must be implemented in order to support vendor mouse drivers\n");
+            BiosMousePs2Interface(Stack);
             break;
         }
 
             break;
         }
 
@@ -442,8 +442,8 @@ static VOID WINAPI BiosTimerIrq(LPWORD Stack)
      * because some programs may hook only BIOS_SYS_TIMER_INTERRUPT
      * for their purpose...
      */
      * because some programs may hook only BIOS_SYS_TIMER_INTERRUPT
      * for their purpose...
      */
-    /** EmulatorInterrupt(BIOS_SYS_TIMER_INTERRUPT); **/
     Int32Call(&BiosContext, BIOS_SYS_TIMER_INTERRUPT);
     Int32Call(&BiosContext, BIOS_SYS_TIMER_INTERRUPT);
+    // BiosSystemTimerInterrupt(Stack);
     PicIRQComplete(Stack);
 }
 
     PicIRQComplete(Stack);
 }
 
@@ -581,9 +581,11 @@ static VOID InitializeBiosInfo(VOID)
 VOID
 Bios32Post(VOID)
 {
 VOID
 Bios32Post(VOID)
 {
+#if 0
     BOOLEAN Success;
     BOOLEAN Success;
+#endif
 
 
-    DPRINT1("Bios32Post\n");
+    DPRINT("Bios32Post\n");
 
     /* Initialize the stack */
     // That's what says IBM... (stack at 30:00FF going downwards)
 
     /* Initialize the stack */
     // That's what says IBM... (stack at 30:00FF going downwards)
@@ -631,9 +633,11 @@ Bios32Post(VOID)
 
     ///////////// MUST BE DONE AFTER IVT INITIALIZATION !! /////////////////////
 
 
     ///////////// MUST BE DONE AFTER IVT INITIALIZATION !! /////////////////////
 
+#if 0
     /* Load some ROMs */
     Success = LoadRom("boot.bin", (PVOID)0xE0000, NULL);
     DPRINT1("Test ROM loading %s ; GetLastError() = %u\n", Success ? "succeeded" : "failed", GetLastError());
     /* Load some ROMs */
     Success = LoadRom("boot.bin", (PVOID)0xE0000, NULL);
     DPRINT1("Test ROM loading %s ; GetLastError() = %u\n", Success ? "succeeded" : "failed", GetLastError());
+#endif
 
     SearchAndInitRoms(&BiosContext);
 
 
     SearchAndInitRoms(&BiosContext);
 
@@ -646,7 +650,7 @@ Bios32Post(VOID)
 
 static VOID WINAPI Bios32ResetBop(LPWORD Stack)
 {
 
 static VOID WINAPI Bios32ResetBop(LPWORD Stack)
 {
-    DPRINT1("Bios32ResetBop\n");
+    DPRINT("Bios32ResetBop\n");
 
     /* Disable interrupts */
     setIF(0);
 
     /* Disable interrupts */
     setIF(0);
index 16ec165..476296a 100644 (file)
@@ -302,15 +302,16 @@ BOOLEAN KbdBios32Initialize(VOID)
     Bda->KeybdBufferEnd   = Bda->KeybdBufferStart + BIOS_KBD_BUFFER_SIZE * sizeof(WORD);
     Bda->KeybdBufferHead  = Bda->KeybdBufferTail = Bda->KeybdBufferStart;
 
     Bda->KeybdBufferEnd   = Bda->KeybdBufferStart + BIOS_KBD_BUFFER_SIZE * sizeof(WORD);
     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');
 
 
-    /* Register the BIOS 32-bit Interrupts */
-
-    /* Initialize software vector handlers */
+    /*
+     * Register the BIOS 32-bit Interrupts:
+     * - Software vector handler
+     * - HW vector interrupt
+     */
     RegisterBiosInt32(BIOS_KBD_INTERRUPT, BiosKeyboardService);
     RegisterBiosInt32(BIOS_KBD_INTERRUPT, BiosKeyboardService);
-
-    /* Set up the HW vector interrupts */
     EnableHwIRQ(1, BiosKeyboardIrq);
 
     return TRUE;
     EnableHwIRQ(1, BiosKeyboardIrq);
 
     return TRUE;
index 235709e..e4e119f 100644 (file)
@@ -18,6 +18,9 @@
 #include "io.h"
 #include "hardware/mouse.h"
 
 #include "io.h"
 #include "hardware/mouse.h"
 
+// HACK: For the PS/2 bypass and MOUSE.COM driver direct call
+#include "dos/mouse32.h"
+
 /* PRIVATE VARIABLES **********************************************************/
 
 /* PRIVATE FUNCTIONS **********************************************************/
 /* PRIVATE VARIABLES **********************************************************/
 
 /* PRIVATE FUNCTIONS **********************************************************/
 // Mouse IRQ 12
 static VOID WINAPI BiosMouseIrq(LPWORD Stack)
 {
 // Mouse IRQ 12
 static VOID WINAPI BiosMouseIrq(LPWORD Stack)
 {
+    // HACK!! Call directly the MOUSE.COM driver instead of going
+    // through the regular interfaces!!
+    extern COORD DosNewPosition;
+    extern WORD  DosButtonState;
+    DosMouseUpdatePosition(&DosNewPosition);
+    DosMouseUpdateButtons(DosButtonState);
+
     PicIRQComplete(Stack);
 }
 
     PicIRQComplete(Stack);
 }
 
+VOID BiosMousePs2Interface(LPWORD Stack)
+{
+    DPRINT1("INT 15h, AH = C2h must be implemented in order to support vendor mouse drivers\n");
+
+    switch (getAL())
+    {
+        /* Enable / Disable */
+        case 0x00:
+        {
+            break;
+        }
+
+        /* Reset */
+        case 0x01:
+        {
+            break;
+        }
+
+        /* Set Sampling Rate */
+        case 0x02:
+        {
+            break;
+        }
+
+        /* Set Resolution */
+        case 0x03:
+        {
+            break;
+        }
+
+        /* Get Type */
+        case 0x04:
+        {
+            break;
+        }
+
+        /* Initialize */
+        case 0x05:
+        {
+            break;
+        }
+
+        /* Extended Commands */
+        case 0x06:
+        {
+            break;
+        }
+
+        /* Set Device Handler Address */
+        case 0x07:
+        {
+            break;
+        }
+
+        /* Write to Pointer Port */
+        case 0x08:
+        {
+            break;
+        }
+
+        /* Read from Pointer Port */
+        case 0x09:
+        {
+            break;
+        }
+
+        default:
+        {
+            DPRINT1("INT 15h, AH = C2h, AL = 0x%02X NOT IMPLEMENTED\n",
+                    getAL());
+        }
+    }
+}
+
 /* PUBLIC FUNCTIONS ***********************************************************/
 
 BOOLEAN MouseBios32Initialize(VOID)
 {
     /* Set up the HW vector interrupts */
     EnableHwIRQ(12, BiosMouseIrq);
 /* PUBLIC FUNCTIONS ***********************************************************/
 
 BOOLEAN MouseBios32Initialize(VOID)
 {
     /* Set up the HW vector interrupts */
     EnableHwIRQ(12, BiosMouseIrq);
-
     return TRUE;
 }
 
     return TRUE;
 }
 
index de2586a..0656c30 100644 (file)
@@ -15,7 +15,7 @@
 
 /* DEFINES ********************************************************************/
 
 
 /* DEFINES ********************************************************************/
 
-#define BIOS_MOUSE_INTERRUPT 0x33
+#if 0 // This code is for the MOUSE.COM driver
 
 enum
 {
 
 enum
 {
@@ -70,10 +70,12 @@ typedef struct _MOUSE_DRIVER_STATE
     } GraphicsCursor;
 } MOUSE_DRIVER_STATE, *PMOUSE_DRIVER_STATE;
 
     } GraphicsCursor;
 } MOUSE_DRIVER_STATE, *PMOUSE_DRIVER_STATE;
 
+#endif
+
 /* FUNCTIONS ******************************************************************/
 
 /* FUNCTIONS ******************************************************************/
 
-VOID MouseBiosUpdatePosition(PCOORD NewPosition);
-VOID MouseBiosUpdateButtons(WORD ButtonStatus);
+VOID BiosMousePs2Interface(LPWORD Stack);
+
 BOOLEAN MouseBios32Initialize(VOID);
 VOID MouseBios32Cleanup(VOID);
 
 BOOLEAN MouseBios32Initialize(VOID);
 VOID MouseBios32Cleanup(VOID);
 
index da2cb34..9e1078f 100644 (file)
@@ -246,7 +246,7 @@ Command:
         }
 
         /* Start the process from the command line */
         }
 
         /* Start the process from the command line */
-        DPRINT("Starting '%s' ('%s')...\n", AppName, CmdLine);
+        DPRINT1("Starting '%s' ('%s')...\n", AppName, CmdLine);
         Result = DosStartProcess(AppName, CmdLine, Env);
         if (Result != ERROR_SUCCESS)
         {
         Result = DosStartProcess(AppName, CmdLine, Env);
         if (Result != ERROR_SUCCESS)
         {
index 2a48c6f..743b4b6 100644 (file)
@@ -916,7 +916,7 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType,
     PWORD RelocWord;
     LPSTR CmdLinePtr = (LPSTR)CommandLine;
 
     PWORD RelocWord;
     LPSTR CmdLinePtr = (LPSTR)CommandLine;
 
-    DPRINT("DosLoadExecutable(%d, %s, %s, %s, 0x%08X, 0x%08X)\n",
+    DPRINT1("DosLoadExecutable(%d, %s, %s, %s, 0x%08X, 0x%08X)\n",
             LoadType,
             ExecutablePath,
             CommandLine,
             LoadType,
             ExecutablePath,
             CommandLine,
index 08ad22d..51d0621 100644 (file)
 static BOOLEAN DriverEnabled = TRUE;
 static MOUSE_DRIVER_STATE DriverState;
 
 static BOOLEAN DriverEnabled = TRUE;
 static MOUSE_DRIVER_STATE DriverState;
 
+/**/
+COORD DosNewPosition;
+WORD  DosButtonState;
+/**/
+
 /* PRIVATE FUNCTIONS **********************************************************/
 
 static VOID PaintMouseCursor(VOID)
 /* PRIVATE FUNCTIONS **********************************************************/
 
 static VOID PaintMouseCursor(VOID)
@@ -81,7 +86,6 @@ static VOID EraseMouseCursor(VOID)
 
 static VOID CallMouseUserHandlers(USHORT CallMask)
 {
 
 static VOID CallMouseUserHandlers(USHORT CallMask)
 {
-#if 0
     USHORT i;
     USHORT AX, BX, CX, DX, SI, DI;
 
     USHORT i;
     USHORT AX, BX, CX, DX, SI, DI;
 
@@ -109,10 +113,10 @@ static VOID CallMouseUserHandlers(USHORT CallMask)
         setSI(DriverState.MickeysPerCellHoriz);
         setDI(DriverState.MickeysPerCellVert);
 
         setSI(DriverState.MickeysPerCellHoriz);
         setDI(DriverState.MickeysPerCellVert);
 
-        DPRINT1("Calling Handler0 %04X:%04X with CallMask 0x%04X\n",
-                HIWORD(DriverState.Handler0.Callback),
-                LOWORD(DriverState.Handler0.Callback),
-                CallMask);
+        DPRINT("Calling Handler0 %04X:%04X with CallMask 0x%04X\n",
+               HIWORD(DriverState.Handler0.Callback),
+               LOWORD(DriverState.Handler0.Callback),
+               CallMask);
 
         /* Call the callback */
         RunCallback16(&DosContext, DriverState.Handler0.Callback);
 
         /* Call the callback */
         RunCallback16(&DosContext, DriverState.Handler0.Callback);
@@ -168,12 +172,11 @@ static VOID CallMouseUserHandlers(USHORT CallMask)
             setDI(DI);
         }
     }
             setDI(DI);
         }
     }
-#endif
 }
 
 }
 
-static VOID WINAPI BiosMouseService(LPWORD Stack)
+static VOID WINAPI DosMouseService(LPWORD Stack)
 {
 {
-    switch (getAX())
+    switch (getAL())
     {
         /* Reset Driver */
         case 0x00:
     {
         /* Reset Driver */
         case 0x00:
@@ -598,14 +601,14 @@ static VOID WINAPI BiosMouseService(LPWORD Stack)
 
         default:
         {
 
         default:
         {
-            DPRINT1("BIOS Function INT 33h, AX = 0x%04X NOT IMPLEMENTED\n", getAX());
+            DPRINT1("BIOS Function INT 33h, AL = 0x%02X NOT IMPLEMENTED\n", getAL());
         }
     }
 }
 
 /* PUBLIC FUNCTIONS ***********************************************************/
 
         }
     }
 }
 
 /* PUBLIC FUNCTIONS ***********************************************************/
 
-VOID MouseBiosUpdatePosition(PCOORD NewPosition)
+VOID DosMouseUpdatePosition(PCOORD NewPosition)
 {
     SHORT DeltaX = NewPosition->X - DriverState.Position.X;
     SHORT DeltaY = NewPosition->Y - DriverState.Position.Y;
 {
     SHORT DeltaX = NewPosition->X - DriverState.Position.X;
     SHORT DeltaY = NewPosition->Y - DriverState.Position.Y;
@@ -615,18 +618,16 @@ VOID MouseBiosUpdatePosition(PCOORD NewPosition)
     DriverState.HorizCount += (DeltaX * (SHORT)DriverState.MickeysPerCellHoriz) / 8;
     DriverState.VertCount  += (DeltaY * (SHORT)DriverState.MickeysPerCellVert ) / 8;
 
     DriverState.HorizCount += (DeltaX * (SHORT)DriverState.MickeysPerCellHoriz) / 8;
     DriverState.VertCount  += (DeltaY * (SHORT)DriverState.MickeysPerCellVert ) / 8;
 
-    if (DriverState.ShowCount > 0)
-    {
-        EraseMouseCursor();
-        DriverState.Position = *NewPosition;
-        PaintMouseCursor();
-    }
+    if (DriverState.ShowCount > 0) EraseMouseCursor();
+    DriverState.Position = *NewPosition;
+    if (DriverState.ShowCount > 0) PaintMouseCursor();
 
     /* Call the mouse handlers */
 
     /* Call the mouse handlers */
+    // if (DeltaX || DeltaY)
     CallMouseUserHandlers(0x0001); // We use MS MOUSE v1.0+ format
 }
 
     CallMouseUserHandlers(0x0001); // We use MS MOUSE v1.0+ format
 }
 
-VOID MouseBiosUpdateButtons(WORD ButtonState)
+VOID DosMouseUpdateButtons(WORD ButtonState)
 {
     USHORT i;
     USHORT CallMask = 0x0000; // We use MS MOUSE v1.0+ format
 {
     USHORT i;
     USHORT CallMask = 0x0000; // We use MS MOUSE v1.0+ format
@@ -668,7 +669,7 @@ BOOLEAN DosMouseInitialize(VOID)
     RtlZeroMemory(&DriverState, sizeof(DriverState));
 
     /* Initialize the interrupt handler */
     RtlZeroMemory(&DriverState, sizeof(DriverState));
 
     /* Initialize the interrupt handler */
-    RegisterDosInt32(BIOS_MOUSE_INTERRUPT, BiosMouseService);
+    RegisterDosInt32(DOS_MOUSE_INTERRUPT, DosMouseService);
 
     return TRUE;
 }
 
     return TRUE;
 }
index 1bbf31a..899dfc8 100644 (file)
@@ -15,7 +15,7 @@
 
 /* DEFINES ********************************************************************/
 
 
 /* DEFINES ********************************************************************/
 
-#define BIOS_MOUSE_INTERRUPT 0x33
+#define DOS_MOUSE_INTERRUPT 0x33
 
 enum
 {
 
 enum
 {
@@ -72,8 +72,8 @@ typedef struct _MOUSE_DRIVER_STATE
 
 /* FUNCTIONS ******************************************************************/
 
 
 /* FUNCTIONS ******************************************************************/
 
-VOID MouseBiosUpdatePosition(PCOORD NewPosition);
-VOID MouseBiosUpdateButtons(WORD ButtonStatus);
+VOID DosMouseUpdatePosition(PCOORD NewPosition);
+VOID DosMouseUpdateButtons(WORD ButtonStatus);
 
 BOOLEAN DosMouseInitialize(VOID);
 VOID DosMouseCleanup(VOID);
 
 BOOLEAN DosMouseInitialize(VOID);
 VOID DosMouseCleanup(VOID);
index 7ddb5c4..faa176a 100644 (file)
@@ -14,9 +14,6 @@
 #include "ps2.h"
 // #include "pic.h"
 
 #include "ps2.h"
 // #include "pic.h"
 
-// HACK: For the PS/2 bypass and MOUSE.COM driver direct call
-#include "dos/mouse32.h"
-
 /* PRIVATE VARIABLES **********************************************************/
 
 static MOUSE_MODE Mode, PreviousMode;
 /* PRIVATE VARIABLES **********************************************************/
 
 static MOUSE_MODE Mode, PreviousMode;
@@ -310,11 +307,16 @@ static VOID WINAPI MouseCommand(LPVOID Param, BYTE Command)
 
 VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent)
 {
 
 VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent)
 {
+extern COORD DosNewPosition;
+extern WORD  DosButtonState;
+
     // FIXME: Sync our private data
     // FIXME: Sync our private data
+    MouseUpdatePosition(&MouseEvent->dwMousePosition);
+    MouseUpdateButtons(MouseEvent->dwButtonState);
 
     // HACK: Bypass PS/2 and instead, notify the MOUSE.COM driver directly
 
     // HACK: Bypass PS/2 and instead, notify the MOUSE.COM driver directly
-    MouseBiosUpdatePosition(&MouseEvent->dwMousePosition);
-    MouseBiosUpdateButtons(LOWORD(MouseEvent->dwButtonState));
+    DosNewPosition = MouseEvent->dwMousePosition;
+    DosButtonState = LOWORD(MouseEvent->dwButtonState);
 
     // PS2QueuePush(PS2Port, Data);
 }
 
     // PS2QueuePush(PS2Port, Data);
 }