-
Notifications
You must be signed in to change notification settings - Fork 0
/
TIMER.C
executable file
·60 lines (45 loc) · 1.19 KB
/
TIMER.C
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "gcomm.h"
#include "majorbbs.h"
#include "timer.h"
#include "submod.h"
#include "mbbsemu.h"
#include "globals.h"
static int rtiCounter = 0;
static BOOL rtkickInstalled = FALSE;
static void timerFunction() {
int usr;
unsigned long now = hrtval();
unsigned int seconds = (unsigned int)((now >> 16) & 0xFFFF);
unsigned int fraction = (unsigned int)(now & 0xFFFF);
setmbk(mcv);
for (usr = 0; usr < nterms; ++usr) {
if (user[usr].state == moduleState) {
prfmsg(TMROUT, seconds, fraction, rtiCounter);
outprf(usr);
}
}
rstmbk();
rtkick(1, timerFunction);
}
static void rtiFunction() {
rtiCounter++;
}
static int timingEntryHandler() {
if (!rtkickInstalled) {
rtkick(1, timerFunction);
rtihdlr(rtiFunction);
prfmsg(TMRINT);
rtkickInstalled = TRUE;
}
return 1;
}
static int timingInputHandler() {
return 1;
}
void initTimerSubModule() {
SubModule subModule;
memset(&subModule, 0, sizeof(subModule));
subModule.onEnter = timingEntryHandler;
subModule.onInput = timingInputHandler;
registerSubModule(SUBMODULE_TIMING, &subModule);
};