Commit 7160d8c7 authored by Peter Dons Tychsen's avatar Peter Dons Tychsen Committed by Alexandre Julliard

winedos: Fixed a problem with timer values that are below 50ms.

parent cb7a0da5
...@@ -58,6 +58,8 @@ static UINT TIMER_ticks = 0; ...@@ -58,6 +58,8 @@ static UINT TIMER_ticks = 0;
/* Number of pending timer IRQs. */ /* Number of pending timer IRQs. */
static LONG TIMER_pending = 0; static LONG TIMER_pending = 0;
/* Number of milliseconds between IRQs. */
static DWORD TIMER_millis = 0;
/*********************************************************************** /***********************************************************************
* TIMER_Relay * TIMER_Relay
...@@ -81,11 +83,11 @@ static void CALLBACK TIMER_TimerProc( HWND hwnd, ...@@ -81,11 +83,11 @@ static void CALLBACK TIMER_TimerProc( HWND hwnd,
DWORD dwTime ) DWORD dwTime )
{ {
LONG pending = InterlockedIncrement( &TIMER_pending ); LONG pending = InterlockedIncrement( &TIMER_pending );
DWORD delta = (dwTime >= TIMER_stamp) ?
(dwTime - TIMER_stamp) : (0xffffffff - (TIMER_stamp - dwTime));
if (pending >= TIMER_MAX_PENDING) if (pending >= TIMER_MAX_PENDING)
{ {
DWORD delta = (dwTime >= TIMER_stamp) ?
(dwTime - TIMER_stamp) : (0xffffffff - (TIMER_stamp - dwTime));
if (delta >= 60000) if (delta >= 60000)
{ {
...@@ -97,8 +99,19 @@ static void CALLBACK TIMER_TimerProc( HWND hwnd, ...@@ -97,8 +99,19 @@ static void CALLBACK TIMER_TimerProc( HWND hwnd,
} }
else else
{ {
TIMER_stamp = dwTime; int i;
DOSVM_QueueEvent( 0, DOS_PRIORITY_REALTIME, TIMER_Relay, NULL );
/* Calculate the number of valid timer interrupts we can generate */
DWORD count = delta / TIMER_millis;
/* Forward the timestamp with the time used */
TIMER_stamp += (count * TIMER_millis);
/* Generate interrupts */
for(i=0;i<count;i++)
{
DOSVM_QueueEvent( 0, DOS_PRIORITY_REALTIME, TIMER_Relay, NULL );
}
} }
} }
...@@ -122,6 +135,9 @@ static void WINAPI TIMER_DoSetTimer( ULONG_PTR arg ) ...@@ -122,6 +135,9 @@ static void WINAPI TIMER_DoSetTimer( ULONG_PTR arg )
TIMER_id = SetTimer( NULL, 0, millis, TIMER_TimerProc ); TIMER_id = SetTimer( NULL, 0, millis, TIMER_TimerProc );
TIMER_stamp = GetTickCount(); TIMER_stamp = GetTickCount();
TIMER_ticks = arg; TIMER_ticks = arg;
/* Remember number of milliseconds to wait */
TIMER_millis = millis;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment