annotate Time.cpp @ 212:9f349addbe00

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