Author: hbelusca
Date: Tue Nov 11 01:40:23 2014
New Revision: 65374

URL: http://svn.reactos.org/svn/reactos?rev=65374&view=rev
Log:
[NTVDM]
- 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.

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

Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] Tue Nov 11 
01:40:23 2014
@@ -264,7 +264,7 @@
         /* 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;
         }
 
@@ -442,8 +442,8 @@
      * because some programs may hook only BIOS_SYS_TIMER_INTERRUPT
      * for their purpose...
      */
-    /** EmulatorInterrupt(BIOS_SYS_TIMER_INTERRUPT); **/
     Int32Call(&BiosContext, BIOS_SYS_TIMER_INTERRUPT);
+    // BiosSystemTimerInterrupt(Stack);
     PicIRQComplete(Stack);
 }
 
@@ -581,9 +581,11 @@
 VOID
 Bios32Post(VOID)
 {
+#if 0
     BOOLEAN Success;
-
-    DPRINT1("Bios32Post\n");
+#endif
+
+    DPRINT("Bios32Post\n");
 
     /* Initialize the stack */
     // That's what says IBM... (stack at 30:00FF going downwards)
@@ -631,9 +633,11 @@
 
     ///////////// 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());
+#endif
 
     SearchAndInitRoms(&BiosContext);
 
@@ -646,7 +650,7 @@
 
 static VOID WINAPI Bios32ResetBop(LPWORD Stack)
 {
-    DPRINT1("Bios32ResetBop\n");
+    DPRINT("Bios32ResetBop\n");
 
     /* Disable interrupts */
     setIF(0);

Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c      [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c      [iso-8859-1] 
Tue Nov 11 01:40:23 2014
@@ -302,15 +302,16 @@
     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');
-
-    /* Register the BIOS 32-bit Interrupts */
-
-    /* Initialize software vector handlers */
+    // 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:
+     * - Software vector handler
+     * - HW vector interrupt
+     */
     RegisterBiosInt32(BIOS_KBD_INTERRUPT, BiosKeyboardService);
-
-    /* Set up the HW vector interrupts */
     EnableHwIRQ(1, BiosKeyboardIrq);
 
     return TRUE;

Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c      [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c      [iso-8859-1] 
Tue Nov 11 01:40:23 2014
@@ -18,6 +18,9 @@
 #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 
**********************************************************/
@@ -25,7 +28,88 @@
 // 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);
+}
+
+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 
***********************************************************/
@@ -34,7 +118,6 @@
 {
     /* Set up the HW vector interrupts */
     EnableHwIRQ(12, BiosMouseIrq);
-
     return TRUE;
 }
 

Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.h?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.h      [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.h      [iso-8859-1] 
Tue Nov 11 01:40:23 2014
@@ -15,7 +15,7 @@
 
 /* DEFINES 
********************************************************************/
 
-#define BIOS_MOUSE_INTERRUPT 0x33
+#if 0 // This code is for the MOUSE.COM driver
 
 enum
 {
@@ -70,10 +70,12 @@
     } GraphicsCursor;
 } MOUSE_DRIVER_STATE, *PMOUSE_DRIVER_STATE;
 
+#endif
+
 /* FUNCTIONS 
******************************************************************/
 
-VOID MouseBiosUpdatePosition(PCOORD NewPosition);
-VOID MouseBiosUpdateButtons(WORD ButtonStatus);
+VOID BiosMousePs2Interface(LPWORD Stack);
+
 BOOLEAN MouseBios32Initialize(VOID);
 VOID MouseBios32Cleanup(VOID);
 

Modified: trunk/reactos/subsystems/ntvdm/dos/dem.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dem.c?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/dem.c    [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/dem.c    [iso-8859-1] Tue Nov 11 
01:40:23 2014
@@ -246,7 +246,7 @@
         }
 
         /* 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)
         {

Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c  [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c  [iso-8859-1] Tue Nov 11 
01:40:23 2014
@@ -916,7 +916,7 @@
     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,

Modified: trunk/reactos/subsystems/ntvdm/dos/mouse32.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/mouse32.c?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/mouse32.c        [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/mouse32.c        [iso-8859-1] Tue Nov 11 
01:40:23 2014
@@ -25,6 +25,11 @@
 static BOOLEAN DriverEnabled = TRUE;
 static MOUSE_DRIVER_STATE DriverState;
 
+/**/
+COORD DosNewPosition;
+WORD  DosButtonState;
+/**/
+
 /* PRIVATE FUNCTIONS 
**********************************************************/
 
 static VOID PaintMouseCursor(VOID)
@@ -81,7 +86,6 @@
 
 static VOID CallMouseUserHandlers(USHORT CallMask)
 {
-#if 0
     USHORT i;
     USHORT AX, BX, CX, DX, SI, DI;
 
@@ -109,10 +113,10 @@
         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);
@@ -168,12 +172,11 @@
             setDI(DI);
         }
     }
-#endif
-}
-
-static VOID WINAPI BiosMouseService(LPWORD Stack)
-{
-    switch (getAX())
+}
+
+static VOID WINAPI DosMouseService(LPWORD Stack)
+{
+    switch (getAL())
     {
         /* Reset Driver */
         case 0x00:
@@ -598,14 +601,14 @@
 
         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 
***********************************************************/
 
-VOID MouseBiosUpdatePosition(PCOORD NewPosition)
+VOID DosMouseUpdatePosition(PCOORD NewPosition)
 {
     SHORT DeltaX = NewPosition->X - DriverState.Position.X;
     SHORT DeltaY = NewPosition->Y - DriverState.Position.Y;
@@ -615,18 +618,16 @@
     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 */
+    // if (DeltaX || DeltaY)
     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
@@ -668,7 +669,7 @@
     RtlZeroMemory(&DriverState, sizeof(DriverState));
 
     /* Initialize the interrupt handler */
-    RegisterDosInt32(BIOS_MOUSE_INTERRUPT, BiosMouseService);
+    RegisterDosInt32(DOS_MOUSE_INTERRUPT, DosMouseService);
 
     return TRUE;
 }

Modified: trunk/reactos/subsystems/ntvdm/dos/mouse32.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/mouse32.h?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/mouse32.h        [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/mouse32.h        [iso-8859-1] Tue Nov 11 
01:40:23 2014
@@ -15,7 +15,7 @@
 
 /* DEFINES 
********************************************************************/
 
-#define BIOS_MOUSE_INTERRUPT 0x33
+#define DOS_MOUSE_INTERRUPT 0x33
 
 enum
 {
@@ -72,8 +72,8 @@
 
 /* FUNCTIONS 
******************************************************************/
 
-VOID MouseBiosUpdatePosition(PCOORD NewPosition);
-VOID MouseBiosUpdateButtons(WORD ButtonStatus);
+VOID DosMouseUpdatePosition(PCOORD NewPosition);
+VOID DosMouseUpdateButtons(WORD ButtonStatus);
 
 BOOLEAN DosMouseInitialize(VOID);
 VOID DosMouseCleanup(VOID);

Modified: trunk/reactos/subsystems/ntvdm/hardware/mouse.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/mouse.c?rev=65374&r1=65373&r2=65374&view=diff
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/mouse.c     [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/mouse.c     [iso-8859-1] Tue Nov 11 
01:40:23 2014
@@ -13,9 +13,6 @@
 #include "mouse.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 
**********************************************************/
 
@@ -310,11 +307,16 @@
 
 VOID MouseEventHandler(PMOUSE_EVENT_RECORD MouseEvent)
 {
+extern COORD DosNewPosition;
+extern WORD  DosButtonState;
+
     // FIXME: Sync our private data
+    MouseUpdatePosition(&MouseEvent->dwMousePosition);
+    MouseUpdateButtons(MouseEvent->dwButtonState);
 
     // 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);
 }


Reply via email to