annotate src/timer/wince/SDL_systimer.c @ 1180:bdcb8bb4c831

From: Tyler Montbriand <tsm@accesscomm.ca> To: sdl@libsdl.org Date: Fri, 30 Sep 2005 02:24:50 -0600 Subject: [SDL] WinCE timers, continued Here's a strange timer for Windows CE that doesn't ignore time across suspends. It uses GetSystemTime to keep the time continuous, and GetTicks to get finer-grained readings than 1 second. It detects the difference between the GetTicks time and GetSystemTime time on power-on to keep the error within one second max. It's not a patch on the current win32 timer code -- took one look at that and figured it had more than enough #ifdefs already. It's windows-ce specific. Another thing I've noticed is that the Windows CE 4.0 and newer API has functions warn processes about suspends. This is something SDL REALLY needs for audio in particular, because turning it off while it's playing causes anything that uses audio to hardlock the system on power-on. Unfortunately I don't have 4.0 to play with. :(
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 22 Nov 2005 07:10:07 +0000
parents
children c9b51268668f
rev   line source
1180
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 Library General Public License for more details.
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 Sam Lantinga
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 slouken@libsdl.org
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 */
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23 #ifdef SAVE_RCSID
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 static char rcsid =
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 "@(#) $Id$";
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 #endif
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 #include <windows.h>
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 #include <mmsystem.h>
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 #include "SDL_timer.h"
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 #include "SDL_timer_c.h"
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 #include "SDL_error.h"
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 static Uint64 start_date;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 static Uint64 start_ticks;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 static Uint64 wce_ticks(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 return((Uint64)GetTickCount());
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43 static Uint64 wce_date(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 union
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47 FILETIME ftime;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48 Uint64 itime;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 } ftime;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 SYSTEMTIME stime;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
52 GetSystemTime(&stime);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 SystemTimeToFileTime(&stime,&ftime.ftime);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 ftime.itime/=10000; // Convert 100ns intervals to 1ms intervals
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55 // Remove ms portion, which can't be relied on
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 ftime.itime -= (ftime.itime % 1000);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57 return(ftime.itime);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 static Sint32 wce_rel_ticks(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 return((Sint32)(wce_ticks()-start_ticks));
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65 static Sint32 wce_rel_date(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67 return((Sint32)(wce_date()-start_date));
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 /* Return time in ms relative to when SDL was started */
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 Uint32 SDL_GetTicks()
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 Sint32 offset=wce_rel_date()-wce_rel_ticks();
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 if((offset < -1000) || (offset > 1000))
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76 // fprintf(stderr,"Time desync(%+d), resyncing\n",offset/1000);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 start_ticks-=offset;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80 return((Uint32)wce_rel_ticks());
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
82
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
83 /* Give up approx. givem milliseconds to the OS. */
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 void SDL_Delay(Uint32 ms)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 Sleep(ms);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
89 /* Recard start-time of application for reference */
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
90 void SDL_StartTicks(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
91 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
92 start_date=wce_date();
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
93 start_ticks=wce_ticks();
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
94 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
95
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96 static UINT WIN_timer;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 int SDL_SYS_TimerInit(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100 return(0);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
103 void SDL_SYS_TimerQuit(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 return;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108 /* Forward declaration because this is called by the timer callback */
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109 int SDL_SYS_StartTimer(void);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 static VOID CALLBACK TimerCallbackProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113 Uint32 ms;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 ms = SDL_alarm_callback(SDL_alarm_interval);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
116 if ( ms != SDL_alarm_interval ) {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 KillTimer(NULL, idEvent);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118 if ( ms ) {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
119 SDL_alarm_interval = ROUND_RESOLUTION(ms);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 SDL_SYS_StartTimer();
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 } else {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
122 SDL_alarm_interval = 0;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
125 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
126
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
127 int SDL_SYS_StartTimer(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
128 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 int retval;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 WIN_timer = SetTimer(NULL, 0, SDL_alarm_interval, TimerCallbackProc);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 if ( WIN_timer ) {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133 retval = 0;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 } else {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 retval = -1;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 return retval;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
139
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140 void SDL_SYS_StopTimer(void)
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141 {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 if ( WIN_timer ) {
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
143 KillTimer(NULL, WIN_timer);
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144 WIN_timer = 0;
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146 }
bdcb8bb4c831 From: Tyler Montbriand <tsm@accesscomm.ca>
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
147