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