-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin_timer.cpp
43 lines (34 loc) · 974 Bytes
/
win_timer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/****************************************************************
xerxes engine
win_timer.cpp
****************************************************************/
#include "xerxes.h"
/***************************** data *****************************/
quad systemtime = 0, timer = 0, vctimer = 0;
quad key_timer, key_repeater, repeatedkey;
/***************************** code *****************************/
void CALLBACK DefaultTimer(UINT uID,UINT uMsg,DWORD dwUser,DWORD dw1,DWORD dw2)
{
UpdateSound();
systemtime++;
timer++;
vctimer++;
HookTimer();
}
void timer_Init(int hz)
{
static xTimer *systimer;
systimer = new xTimer(hz, DefaultTimer);
}
/****************************************************************/
xTimer::xTimer(int hz, LPTIMECALLBACK TimeProc)
{
if (currtimer)
timeKillEvent(currtimer);
currtimer = timeSetEvent(1000/hz,0,(LPTIMECALLBACK)TimeProc,0,TIME_PERIODIC);
}
xTimer::~xTimer()
{
timeKillEvent(currtimer);
currtimer=0;
}