0
|
1 #include "OSAPI.h"
|
|
2
|
|
3 #include "Time.h"
|
|
4 #include "Keyboard.h"
|
816
|
5 #include "Log.h"
|
0
|
6
|
|
7 #include "mm7_data.h"
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13 Timer *pMiscTimer = new Timer;
|
|
14 Timer *pEventTimer;
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21 //----- (00426317) --------------------------------------------------------
|
|
22 unsigned __int64 Timer::Time()
|
|
23 {
|
1194
|
24 unsigned __int64 v2 = TimeQuant * timeGetTime() / 1000;
|
0
|
25 if (v2 < uStartTime)
|
|
26 uStartTime = 0;
|
|
27 return v2;
|
|
28 }
|
|
29
|
|
30
|
|
31
|
|
32 //----- (00426349) --------------------------------------------------------
|
|
33 void Timer::Pause()
|
|
34 {
|
|
35 if (!bPaused)
|
|
36 {
|
|
37 uStopTime = Time();
|
|
38 bPaused = true;
|
|
39 }
|
|
40 }
|
|
41
|
|
42
|
|
43 //----- (00426363) --------------------------------------------------------
|
|
44 void Timer::Resume()
|
|
45 {
|
|
46 if (bPaused)
|
|
47 {
|
|
48 pKeyActionMap->ResetKeys();
|
|
49 bPaused = 0;
|
|
50 uStartTime = Time();
|
|
51 }
|
|
52 }
|
|
53
|
|
54 //----- (00426386) --------------------------------------------------------
|
|
55 void Timer::TrackGameTime()
|
|
56 {
|
|
57 if (!bTackGameTime)
|
|
58 {
|
|
59 uGameTimeStart = Time();
|
|
60 bTackGameTime = true;
|
|
61 }
|
|
62 }
|
|
63
|
|
64
|
|
65
|
|
66 //----- (004263A0) --------------------------------------------------------
|
|
67 void Timer::StopGameTime()
|
|
68 {
|
|
69 if (bTackGameTime)
|
|
70 {
|
|
71 bTackGameTime = 0;
|
|
72 uStartTime = Time();
|
|
73 }
|
|
74 }
|
|
75
|
|
76 //----- (004263B7) --------------------------------------------------------
|
783
|
77 void Timer::Update()
|
0
|
78 {
|
816
|
79 //Timer *v1; // esi@1
|
|
80 //unsigned int v2; // eax@2
|
|
81 //signed int v3; // eax@3
|
|
82 //char v4; // zf@5
|
|
83
|
|
84
|
|
85 unsigned __int64 new_time = Time();
|
|
86 while (new_time <= uStartTime)
|
|
87 new_time = Time();
|
0
|
88
|
816
|
89 uTimeElapsed = new_time - uStartTime;
|
|
90 uStartTime = new_time;
|
|
91
|
|
92 if (uTimeElapsed > 32)
|
|
93 uTimeElapsed = 32;
|
|
94
|
|
95 if (!bPaused && !bTackGameTime)
|
|
96 uTotalGameTimeElapsed += uTimeElapsed;
|
|
97 dt_in_some_format = (uTimeElapsed << 16) / 128;
|
0
|
98 }
|
|
99
|
|
100 //----- (00426402) --------------------------------------------------------
|
|
101 void Timer::Initialize()
|
|
102 {
|
|
103 uTotalGameTimeElapsed = 0;
|
|
104 bReady = true;
|
|
105 }
|