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
|
|
12 Timer *pMiscTimer = new Timer;
|
|
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) --------------------------------------------------------
|
783
|
76 void Timer::Update()
|
0
|
77 {
|
|
78 Timer *v1; // esi@1
|
|
79 unsigned int v2; // eax@2
|
|
80 signed int v3; // eax@3
|
|
81 char v4; // zf@5
|
|
82
|
|
83 v1 = this;
|
|
84 do
|
|
85 {
|
|
86 v2 = Time() - v1->uStartTime;
|
|
87 v1->uTimeElapsed = v2;
|
|
88 }
|
|
89 while ( (signed int)v2 <= 0 );
|
|
90 v1->uStartTime = Time();
|
|
91 v3 = v1->uTimeElapsed;
|
|
92 if ( v3 > 32 )
|
|
93 v3 = 32;
|
|
94 v4 = v1->bPaused == 0;
|
|
95 v1->uTimeElapsed = v3;
|
|
96 if ( v4 && !v1->bTackGameTime )
|
|
97 v1->uTotalGameTimeElapsed += v3;
|
783
|
98 v1->dt_in_some_format = (v3 << 16) / 128;
|
0
|
99 }
|
|
100
|
|
101 //----- (00426402) --------------------------------------------------------
|
|
102 void Timer::Initialize()
|
|
103 {
|
|
104 uTotalGameTimeElapsed = 0;
|
|
105 bReady = true;
|
|
106 }
|