[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 13 Sep 2014 21:50:23 +0000 (21:50 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 13 Sep 2014 21:50:23 +0000 (21:50 +0000)
Implement motion counters in the mouse BIOS.

svn path=/trunk/; revision=64136

reactos/subsystems/ntvdm/bios/bios32/moubios32.c
reactos/subsystems/ntvdm/bios/bios32/moubios32.h

index ca744a6..10ec89b 100644 (file)
@@ -85,8 +85,11 @@ static VOID WINAPI BiosMouseService(LPWORD Stack)
         /* Reset Driver */
         case 0x00:
         {
+            SHORT i;
+
             DriverEnabled = TRUE;
             DriverState.ShowCount = 0;
+            DriverState.ButtonState = 0;
 
             /* Set the default text cursor */
             DriverState.TextCursor.ScreenMask = 0xFFFF; /* Display everything */
@@ -130,6 +133,18 @@ static VOID WINAPI BiosMouseService(LPWORD Stack)
             DriverState.GraphicsCursor.CursorMask[14] = 0x0030; // 0000000000110000
             DriverState.GraphicsCursor.CursorMask[15] = 0x0000; // 0000000000000000
 
+            /* Initialize the counters */
+            DriverState.HorizCount = DriverState.VertCount = 0;
+
+            for (i = 0; i < NUM_MOUSE_BUTTONS; i++)
+            {
+                DriverState.PressCount[i] = DriverState.ReleaseCount[i] = 0;
+            }
+
+            /* Initialize the resolution */
+            DriverState.MickeysPerCellHoriz = 8;
+            DriverState.MickeysPerCellVert = 16;
+
             /* Return mouse information */
             setAX(0xFFFF);  // Hardware & driver installed
             setBX(NUM_MOUSE_BUTTONS);
@@ -240,6 +255,27 @@ static VOID WINAPI BiosMouseService(LPWORD Stack)
             break;
         }
 
+        /* Read Motion Counters */
+        case 0x0B:
+        {
+            setCX(DriverState.HorizCount);
+            setDX(DriverState.VertCount);
+
+            /* Reset the counters */
+            DriverState.HorizCount = DriverState.VertCount = 0;
+
+            break;
+        }
+
+        /* Define Mickey/Pixel Ratio */
+        case 0x0F:
+        {
+            DriverState.MickeysPerCellHoriz = getCX();
+            DriverState.MickeysPerCellVert = getDX();
+
+            break;
+        }
+
         /* Return Driver Storage Requirements */
         case 0x15:
         {
@@ -289,7 +325,15 @@ static VOID WINAPI BiosMouseService(LPWORD Stack)
 
 VOID MouseBiosUpdatePosition(PCOORD NewPosition)
 {
-    if (DriverEnabled && (DriverState.ShowCount > 0))
+    SHORT DeltaX = NewPosition->X - DriverState.Position.X;
+    SHORT DeltaY = NewPosition->Y - DriverState.Position.Y;
+
+    if (!DriverEnabled) return;
+
+    DriverState.HorizCount += (DeltaX * (SHORT)DriverState.MickeysPerCellHoriz) / 8;
+    DriverState.VertCount += (DeltaY * (SHORT)DriverState.MickeysPerCellVert) / 8;
+    
+    if (DriverState.ShowCount > 0)
     {
         EraseMouseCursor();
         DriverState.Position = *NewPosition;
index 89a943d..4530b63 100644 (file)
@@ -35,6 +35,10 @@ typedef struct _MOUSE_DRIVER_STATE
     COORD LastPress[NUM_MOUSE_BUTTONS];
     WORD ReleaseCount[NUM_MOUSE_BUTTONS];
     COORD LastRelease[NUM_MOUSE_BUTTONS];
+    SHORT HorizCount;
+    SHORT VertCount;
+    WORD MickeysPerCellHoriz;
+    WORD MickeysPerCellVert;
 
     struct
     {