aboutsummaryrefslogtreecommitdiff
path: root/windows.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-05-03 09:43:08 +0000
committerSimon Tatham <anakin@pobox.com>2004-05-03 09:43:08 +0000
commitccbf3ca6f1950fb1e39df40b2d44fe99ab9de0d1 (patch)
treecb04a0da087247f6e7d846c15c8157a9c012e192 /windows.c
parent2d1d54b96ba5b7edf4765230ddf00436eb924a52 (diff)
downloadpuzzles-ccbf3ca6f1950fb1e39df40b2d44fe99ab9de0d1.zip
puzzles-ccbf3ca6f1950fb1e39df40b2d44fe99ab9de0d1.tar.gz
puzzles-ccbf3ca6f1950fb1e39df40b2d44fe99ab9de0d1.tar.bz2
puzzles-ccbf3ca6f1950fb1e39df40b2d44fe99ab9de0d1.tar.xz
GTK and Windows appear to handle timers very differently:
specifically, the elapsed time between calls varies much more with GTK than it does under Windows. Therefore, I now take my own time readings on every timer call, and this appears to have made the animations run at closer to the same speed between platforms. Having done that, I decided some of them were at the _wrong_ speed, and fiddled with each game's timings as well. [originally from svn r4189]
Diffstat (limited to 'windows.c')
-rw-r--r--windows.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/windows.c b/windows.c
index 87f4284..90d96d2 100644
--- a/windows.c
+++ b/windows.c
@@ -88,6 +88,7 @@ struct frontend {
HPEN *pens;
HRGN clip;
UINT timer;
+ DWORD timer_last_tickcount;
int npresets;
game_params **presets;
struct font *fonts;
@@ -302,7 +303,10 @@ void deactivate_timer(frontend *fe)
void activate_timer(frontend *fe)
{
- fe->timer = SetTimer(fe->hwnd, fe->timer, 20, NULL);
+ if (!fe->timer) {
+ fe->timer = SetTimer(fe->hwnd, fe->timer, 20, NULL);
+ fe->timer_last_tickcount = GetTickCount();
+ }
}
static frontend *new_window(HINSTANCE inst)
@@ -942,8 +946,12 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
PostQuitMessage(0);
return 0;
case WM_TIMER:
- if (fe->timer)
- midend_timer(fe->me, (float)0.02);
+ if (fe->timer) {
+ DWORD now = GetTickCount();
+ float elapsed = (float) (now - fe->timer_last_tickcount) * 0.001F;
+ midend_timer(fe->me, elapsed);
+ fe->timer_last_tickcount = now;
+ }
return 0;
}