annotate Timer.cpp @ 2475:acac52e9e36a

remove DirectX11.cpp/.h for VS2010, MatrixMultiply and other
author Ritor1
date Thu, 21 Aug 2014 11:24:51 +0600
parents b054ea5daf45
children
rev   line source
2415
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2253
diff changeset
1 #define _CRTDBG_MAP_ALLOC
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2253
diff changeset
2 #include <stdlib.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2253
diff changeset
3 #include <crtdbg.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2253
diff changeset
4
2253
aff7a7b072b7 adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents: 2044
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
2044
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
6
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
7 #include "Timer.h"
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
8 #include "Keyboard.h"
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
9
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
10 #include "OSAPI.h"
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
11
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
12
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
13
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 Timer *pMiscTimer = new Timer;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
17 Timer *pEventTimer;
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
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
21
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
22
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
23
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
24 //----- (00426317) --------------------------------------------------------
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
25 unsigned __int64 Timer::Time()
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
26 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
27 unsigned __int64 v2 = TimeQuant * timeGetTime() / 1000;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
28 if (v2 < uStartTime)
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
29 uStartTime = 0;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
30 return v2;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
31 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
32
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
33
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
34
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
35 //----- (00426349) --------------------------------------------------------
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
36 void Timer::Pause()
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
37 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
38 if (!bPaused)
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
39 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
40 uStopTime = Time();
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
41 bPaused = true;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
42 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
43 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
44
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
45 //----- (00426363) --------------------------------------------------------
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
46 void Timer::Resume()
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
47 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
48 if (bPaused)
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
49 {
2425
d922225a6081 Hot key for mm7 main menu
Ritor1
parents: 2415
diff changeset
50 pKeyActionMap->ResetKeys();//Unhandled application exception
d922225a6081 Hot key for mm7 main menu
Ritor1
parents: 2415
diff changeset
51
2044
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
52 bPaused = 0;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
53 uStartTime = Time();
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
54 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
55 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
56
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
57 //----- (00426386) --------------------------------------------------------
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
58 void Timer::TrackGameTime()
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
59 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
60 if (!bTackGameTime)
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
61 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
62 uGameTimeStart = Time();
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
63 bTackGameTime = true;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
64 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
65 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
66
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
67
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
68
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
69 //----- (004263A0) --------------------------------------------------------
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
70 void Timer::StopGameTime()
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
71 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
72 if (bTackGameTime)
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
73 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
74 bTackGameTime = 0;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
75 uStartTime = Time();
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
76 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
77 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
78
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
79 //----- (004263B7) --------------------------------------------------------
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
80 void Timer::Update()
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
81 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
82 //Timer *v1; // esi@1
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
83 //unsigned int v2; // eax@2
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
84 //signed int v3; // eax@3
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
85 //char v4; // zf@5
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
86
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
87
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
88 unsigned __int64 new_time = Time();
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
89 while (new_time <= uStartTime)
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
90 new_time = Time();
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
91
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
92 uTimeElapsed = new_time - uStartTime;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
93 uStartTime = new_time;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
94
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
95 if (uTimeElapsed > 32)
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
96 uTimeElapsed = 32;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
97
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
98 if (!bPaused && !bTackGameTime)
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
99 uTotalGameTimeElapsed += uTimeElapsed;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
100 dt_in_some_format = (uTimeElapsed << 16) / 128;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
101 }
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
102
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
103 //----- (00426402) --------------------------------------------------------
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
104 void Timer::Initialize()
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
105 {
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
106 uTotalGameTimeElapsed = 0;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
107 bReady = true;
28cb79ae2f6f Time.h rename
Ritor1
parents:
diff changeset
108 }