annotate Timer.cpp @ 2080:61960bd85c6d

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