From: Aleksandar Andrejevic Date: Sat, 13 Sep 2014 21:50:23 +0000 (+0000) Subject: [NTVDM] X-Git-Tag: backups/0.3.17@66124~589 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=75c869d7b5ad3b8bbebfde5b8555080852553195 [NTVDM] Implement motion counters in the mouse BIOS. svn path=/trunk/; revision=64136 --- diff --git a/reactos/subsystems/ntvdm/bios/bios32/moubios32.c b/reactos/subsystems/ntvdm/bios/bios32/moubios32.c index ca744a6edab..10ec89bfef2 100644 --- a/reactos/subsystems/ntvdm/bios/bios32/moubios32.c +++ b/reactos/subsystems/ntvdm/bios/bios32/moubios32.c @@ -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; diff --git a/reactos/subsystems/ntvdm/bios/bios32/moubios32.h b/reactos/subsystems/ntvdm/bios/bios32/moubios32.h index 89a943da4c1..4530b6374d2 100644 --- a/reactos/subsystems/ntvdm/bios/bios32/moubios32.h +++ b/reactos/subsystems/ntvdm/bios/bios32/moubios32.h @@ -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 {