comparison Timer.cpp @ 2044:28cb79ae2f6f

Time.h rename
author Ritor1
date Thu, 28 Nov 2013 17:12:50 +0600
parents
children aff7a7b072b7
comparison
equal deleted inserted replaced
2043:2ccf638342d6 2044:28cb79ae2f6f
1
2 #include "Timer.h"
3 #include "Keyboard.h"
4 #include "Log.h"
5
6 #include "OSAPI.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 unsigned __int64 v2 = TimeQuant * timeGetTime() / 1000;
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 void 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
83
84 unsigned __int64 new_time = Time();
85 while (new_time <= uStartTime)
86 new_time = Time();
87
88 uTimeElapsed = new_time - uStartTime;
89 uStartTime = new_time;
90
91 if (uTimeElapsed > 32)
92 uTimeElapsed = 32;
93
94 if (!bPaused && !bTackGameTime)
95 uTotalGameTimeElapsed += uTimeElapsed;
96 dt_in_some_format = (uTimeElapsed << 16) / 128;
97 }
98
99 //----- (00426402) --------------------------------------------------------
100 void Timer::Initialize()
101 {
102 uTotalGameTimeElapsed = 0;
103 bReady = true;
104 }