annotate Time.cpp @ 190:d7bd52a35e52

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