Mercurial > mm7
comparison _deleted.cpp @ 741:cd9ae9a2c99c
Слияние
author | Ritor1 |
---|---|
date | Fri, 22 Mar 2013 19:59:03 +0600 |
parents | 93287fb98441 |
children | cc9a3a24d61d |
comparison
equal
deleted
inserted
replaced
740:14cf77af15de | 741:cd9ae9a2c99c |
---|---|
1 | |
2 /* | |
3 //----- (004AC1C9) -------------------------------------------------------- | |
4 int __thiscall _4AC1C9_get_cpu_speed(unsigned int _this, Vec4_int_ *a2) | |
5 { | |
6 unsigned int v2; // esi@1 | |
7 __int16 v3; // di@1 | |
8 signed int v4; // ebx@1 | |
9 int v5; // ecx@3 | |
10 Vec4_int_ *v6; // eax@10 | |
11 Vec4_int_ *v7; // esi@14 | |
12 int result; // eax@16 | |
13 char *v9; // esi@16 | |
14 Vec4_int_ a1; // [sp+Ch] [bp-34h]@10 | |
15 Vec4_int_ v11; // [sp+1Ch] [bp-24h]@14 | |
16 Vec4_int_ Dst; // [sp+2Ch] [bp-14h]@1 | |
17 int v13; // [sp+3Ch] [bp-4h]@1 | |
18 | |
19 v2 = _this; | |
20 v3 = _4382BC_get_cpu_speed_sub0(_this); | |
21 v13 = _4383ED_get_cpu_speed_sub2(); | |
22 v4 = 0; | |
23 memset(&Dst, 0, 0x10u); | |
24 if ( v3 < 0 ) | |
25 goto LABEL_19; | |
26 if ( (signed int)v2 > 0 ) | |
27 { | |
28 if ( (signed int)v2 > 150 ) | |
29 { | |
30 v5 = (int)a2; | |
31 } | |
32 else | |
33 { | |
34 v5 = 4000 * v2; | |
35 v4 = 1; | |
36 } | |
37 } | |
38 else | |
39 { | |
40 v5 = 4000 * dword_4F031C[(unsigned __int16)v3]; | |
41 } | |
42 if ( v13 & 0x10 && !v4 ) | |
43 { | |
44 if ( v2 ) | |
45 v6 = _4AC4FD_get_cpu_clocks_rdtsc(v5, &a1); | |
46 else | |
47 v6 = _4AC33A_get_cpu_clocks_QPC(v5, &a1); | |
48 goto LABEL_14; | |
49 } | |
50 if ( (unsigned __int16)v3 < 3u ) | |
51 { | |
52 LABEL_19: | |
53 v7 = &Dst; | |
54 goto LABEL_16; | |
55 } | |
56 v6 = _4AC277_get_cpu_speed_sub3(v5, &a1); | |
57 LABEL_14: | |
58 v11.x = v6->x; | |
59 v11.y = v6->y; | |
60 v11.z = v6->z; | |
61 v11.w = v6->w; | |
62 v7 = &v11; | |
63 LABEL_16: | |
64 result = (int)a2; | |
65 a2->x = v7->x; | |
66 v9 = (char *)&v7->y; | |
67 a2->y = *(int *)v9; | |
68 v9 += 4; | |
69 a2->z = *(int *)v9; | |
70 a2->w = *((int *)v9 + 1); | |
71 return result; | |
72 } | |
73 // 4F031C: using guessed type int dword_4F031C[]; | |
74 | |
75 | |
76 | |
77 //----- (004382BC) -------------------------------------------------------- | |
78 __int16 __thiscall _4382BC_get_cpu_speed_sub0(int _this) | |
79 { | |
80 __int16 result; // ax@4 | |
81 __int16 v14; // sp@11 | |
82 int v15; // [sp-4h] [bp-Ch]@0 | |
83 signed __int16 v16; // [sp+4h] [bp-4h]@1 | |
84 __int16 v17; // [sp+4h] [bp-4h]@8 | |
85 __int16 v18; // [sp+4h] [bp-4h]@11 | |
86 | |
87 v16 = 1; | |
88 __asm { pushf } | |
89 if ( v15 == (v15 ^ 0x200000) ) | |
90 v16 = 0; | |
91 if ( v16 ) | |
92 { | |
93 result = _43847A_get_cpu_speed_sub1(); | |
94 } | |
95 else | |
96 { | |
97 //UNDEF(_ZF); | |
98 //UNDEF(_SF); | |
99 //UNDEF(_OF); | |
100 _CF = 0; | |
101 if ( !_ZF ) | |
102 _CF = 1; | |
103 __asm { pushfw } | |
104 bProcessorIsNotIntel = (BYTE2(v15) & 1 ^ 1) & 1; | |
105 _CF = 0; | |
106 _OF = 0; | |
107 _ZF = 0; | |
108 _SF = 1; | |
109 __asm { pushfw } | |
110 v17 = 2; | |
111 if ( (HIWORD(v15) | 0xF000) & 0xF000 ) | |
112 v17 = -1; | |
113 __asm { popfw } | |
114 result = v17; | |
115 if ( v17 != 2 ) | |
116 { | |
117 _CF = 0; | |
118 _OF = 0; | |
119 _ZF = v14 == 0; | |
120 _SF = v14 < 0; | |
121 __asm { pushf } | |
122 v18 = 3; | |
123 if ( v15 != (v15 ^ 0x40000) ) | |
124 v18 = -1; | |
125 __asm { popf } | |
126 result = v18; | |
127 if ( v18 != 3 ) | |
128 result = 4; | |
129 } | |
130 } | |
131 if ( bProcessorIsNotIntel ) | |
132 HIBYTE(result) |= 0x80u; | |
133 return result; | |
134 } | |
135 | |
136 | |
137 | |
138 //----- (0043847A) -------------------------------------------------------- | |
139 __int16 __cdecl _43847A_get_cpu_speed_sub1() | |
140 { | |
141 signed int v5; // eax@1 | |
142 char v12[12]; // [sp+Ch] [bp-28h]@1 | |
143 char v13; // [sp+18h] [bp-1Ch]@1 | |
144 char v14; // [sp+19h] [bp-1Bh]@1 | |
145 int v15[4]; // [sp+1Ch] [bp-18h]@1 | |
146 int v16; // [sp+2Eh] [bp-6h]@1 | |
147 char v17; // [sp+32h] [bp-2h]@6 | |
148 char v18; // [sp+33h] [bp-1h]@1 | |
149 | |
150 *(int *)v12 = *(int *)"------------"; | |
151 *(int *)&v12[4] = *(int *)"--------"; | |
152 *(int *)&v12[8] = *(int *)"----"; | |
153 v13 = asc_4E4938[12]; | |
154 v14 = 0; | |
155 v18 = 0; | |
156 v15[0] = *(int *)"GenuineIntel"; | |
157 v15[1] = *(int *)"ineIntel"; | |
158 v15[2] = *(int *)"ntel"; | |
159 v16 = 65535; | |
160 LOBYTE(v15[3]) = aGenuineintel[12]; | |
161 _EAX = 0; | |
162 __asm { cpuid } | |
163 *(int *)v12 = _EBX; | |
164 *(int *)&v12[4] = _EDX; | |
165 *(int *)&v12[8] = _ECX; | |
166 v5 = 0; | |
167 do | |
168 { | |
169 if ( v12[v5] != *((char *)v15 + v5) ) | |
170 bProcessorIsNotIntel = 1; | |
171 ++v5; | |
172 } | |
173 while ( v5 < 12 ); | |
174 if ( v5 >= 1 ) | |
175 { | |
176 _EAX = 1; | |
177 __asm { cpuid } | |
178 v18 = _EAX & 0xF; | |
179 LOBYTE(_EAX) = (unsigned __int8)(_EAX & 0xF0) >> 4; | |
180 v17 = _EAX; | |
181 LOWORD(v16) = ((_EAX & 0xF00u) >> 8) & 0xF; | |
182 } | |
183 return v16; | |
184 } | |
185 | |
186 | |
187 | |
188 //----- (004383ED) -------------------------------------------------------- | |
189 int __cdecl _4383ED_get_cpu_speed_sub2() | |
190 { | |
191 signed int v9; // eax@4 | |
192 int v16; // [sp-4h] [bp-38h]@0 | |
193 int v17[3]; // [sp+Ch] [bp-28h]@1 | |
194 char v18; // [sp+18h] [bp-1Ch]@1 | |
195 char v19; // [sp+19h] [bp-1Bh]@1 | |
196 int v20[4]; // [sp+1Ch] [bp-18h]@1 | |
197 int v21; // [sp+2Ch] [bp-8h]@1 | |
198 int v22; // [sp+30h] [bp-4h]@1 | |
199 | |
200 v17[0] = *(int *)"------------"; | |
201 v17[1] = *(int *)"--------"; | |
202 v17[2] = *(int *)"----"; | |
203 v18 = asc_4E4938[12]; | |
204 v19 = 0; | |
205 v22 = 0; | |
206 v20[0] = *(int *)"GenuineIntel"; | |
207 v20[1] = *(int *)"ineIntel"; | |
208 v20[2] = *(int *)"ntel"; | |
209 LOBYTE(v20[3]) = aGenuineintel[12]; | |
210 _CF = 0; | |
211 _OF = 0; | |
212 _ZF = 0; | |
213 _SF = 0; | |
214 v21 = 1; | |
215 __asm { pushf } | |
216 if ( v16 == (v16 ^ 0x200000) ) | |
217 v21 = 0; | |
218 if ( (short)v21 ) | |
219 { | |
220 _EAX = 0; | |
221 __asm { cpuid } | |
222 v17[0] = _EBX; | |
223 v17[1] = _EDX; | |
224 v17[2] = _ECX; | |
225 v9 = 0; | |
226 do | |
227 { | |
228 if ( *((char *)v17 + v9) != *((char *)v20 + v9) ) | |
229 bProcessorIsNotIntel = 1; | |
230 ++v9; | |
231 } | |
232 while ( v9 < 12 ); | |
233 if ( v9 >= 1 ) | |
234 { | |
235 _EAX = 1; | |
236 __asm { cpuid } | |
237 v22 = _EDX; | |
238 } | |
239 } | |
240 return v22; | |
241 } | |
242 | |
243 | |
244 | |
245 //----- (004AC4FD) -------------------------------------------------------- | |
246 Vec4_int_ *__thiscall _4AC4FD_get_cpu_clocks_rdtsc(int _this, Vec4_int_ *a1) | |
247 { | |
248 int v2; // eax@1 | |
249 int v3; // eax@4 | |
250 bool v4; // eax@5 | |
251 unsigned __int64 v5; // kr00_8@8 | |
252 int v6; // edi@9 | |
253 int v7; // eax@9 | |
254 bool v8; // eax@10 | |
255 unsigned __int64 v9; // kr08_8@13 | |
256 unsigned int v10; // eax@15 | |
257 Vec4_int_ *result; // eax@17 | |
258 int Dst; // [sp+Ch] [bp-2Ch]@1 | |
259 int v13; // [sp+10h] [bp-28h]@17 | |
260 int v14; // [sp+14h] [bp-24h]@15 | |
261 int v15; // [sp+18h] [bp-20h]@17 | |
262 unsigned int v16; // [sp+1Ch] [bp-1Ch]@8 | |
263 unsigned int v17; // [sp+20h] [bp-18h]@8 | |
264 unsigned int v18; // [sp+24h] [bp-14h]@13 | |
265 int nPriority; // [sp+28h] [bp-10h]@1 | |
266 __int64 v20; // [sp+2Ch] [bp-Ch]@1 | |
267 int v21; // [sp+34h] [bp-4h]@3 | |
268 | |
269 HIDWORD(v20) = GetCurrentThread(); | |
270 memset(&Dst, 0, 0x10u); | |
271 v2 = GetThreadPriority(HIDWORD(v20)); | |
272 nPriority = v2; | |
273 if ( v2 != 0x7FFFFFFF ) | |
274 SetThreadPriority(HIDWORD(v20), v2 + 1); | |
275 __outbyte(0x70u, 0); | |
276 v21 = __inbyte(0x71u); | |
277 do | |
278 { | |
279 __outbyte(0x70u, 0); | |
280 LODWORD(v20) = __inbyte(0x71u); | |
281 v3 = v20 - v21; | |
282 if ( (signed int)v20 >= v21 ) | |
283 v4 = v3 > 0; | |
284 else | |
285 v4 = v3 + 10; | |
286 } | |
287 while ( !v4 ); | |
288 v5 = __rdtsc(); | |
289 v16 = HIDWORD(v5); | |
290 v17 = v5; | |
291 do | |
292 { | |
293 __outbyte(0x70u, 0); | |
294 v21 = __inbyte(0x71u); | |
295 v6 = v21; | |
296 v7 = v21 - v20; | |
297 if ( v21 >= (signed int)v20 ) | |
298 v8 = v7 > 0; | |
299 else | |
300 v8 = v7 + 10; | |
301 } | |
302 while ( !v8 ); | |
303 v9 = __rdtsc(); | |
304 v18 = HIDWORD(v9); | |
305 v21 = v9; | |
306 if ( nPriority != 0x7FFFFFFF ) | |
307 SetThreadPriority(HIDWORD(v20), nPriority); | |
308 nPriority = v21; | |
309 *(__int64 *)((char *)&v20 + 4) = __PAIR__(v18, v21) - __PAIR__(v16, v17); | |
310 Dst = HIDWORD(v20); | |
311 v10 = HIDWORD(v20) / 0xF4240; | |
312 v14 = HIDWORD(v20) / 0xF4240; | |
313 if ( HIDWORD(v20) / 0x186A0 - 10 * HIDWORD(v20) / 0xF4240 >= 6 ) | |
314 ++v10; | |
315 v15 = v10; | |
316 result = a1; | |
317 v13 = 1000000 * v6 - 1000000 * v20; | |
318 a1->x = Dst; | |
319 a1->y = v13; | |
320 a1->z = v14; | |
321 a1->w = v15; | |
322 return result; | |
323 } | |
324 | |
325 | |
326 | |
327 | |
328 //----- (004AC33A) -------------------------------------------------------- | |
329 Vec4_int_ *__thiscall _4AC33A_get_cpu_clocks_QPC(int _this, Vec4_int_ *a1) | |
330 { | |
331 int v2; // esi@1 | |
332 int v3; // ebx@1 | |
333 unsigned __int64 v4; // qax@4 | |
334 unsigned __int64 v5; // qax@7 | |
335 DWORD v6; // edi@7 | |
336 DWORD v7; // eax@7 | |
337 unsigned int v8; // ecx@10 | |
338 unsigned __int64 v9; // qax@10 | |
339 unsigned int v10; // edi@10 | |
340 int v11; // eax@14 | |
341 unsigned int v12; // ecx@19 | |
342 Vec4_int_ *result; // eax@24 | |
343 int Dst; // [sp+Ch] [bp-4Ch]@1 | |
344 int v15; // [sp+10h] [bp-48h]@23 | |
345 int v16; // [sp+14h] [bp-44h]@21 | |
346 int v17; // [sp+18h] [bp-40h]@21 | |
347 LARGE_INTEGER Frequency; // [sp+1Ch] [bp-3Ch]@1 | |
348 LARGE_INTEGER PerformanceCount; // [sp+24h] [bp-34h]@2 | |
349 LARGE_INTEGER v20; // [sp+2Ch] [bp-2Ch]@2 | |
350 int v21; // [sp+34h] [bp-24h]@2 | |
351 int v22; // [sp+38h] [bp-20h]@2 | |
352 int v23; // [sp+3Ch] [bp-1Ch]@4 | |
353 int v24; // [sp+40h] [bp-18h]@7 | |
354 int nPriority; // [sp+44h] [bp-14h]@2 | |
355 unsigned int v26; // [sp+48h] [bp-10h]@1 | |
356 unsigned int v27; // [sp+4Ch] [bp-Ch]@1 | |
357 HANDLE hThread; // [sp+50h] [bp-8h]@1 | |
358 int v29; // [sp+54h] [bp-4h]@1 | |
359 | |
360 v2 = 0; | |
361 v3 = 0; | |
362 v29 = 0; | |
363 v27 = 0; | |
364 v26 = 0; | |
365 hThread = GetCurrentThread(); | |
366 memset(&Dst, 0, 0x10u); | |
367 if ( QueryPerformanceFrequency(&Frequency) ) | |
368 { | |
369 do | |
370 { | |
371 ++v29; | |
372 v22 = v2; | |
373 v21 = v3; | |
374 QueryPerformanceCounter(&PerformanceCount); | |
375 v20 = PerformanceCount; | |
376 nPriority = GetThreadPriority(hThread); | |
377 if ( nPriority != 2147483647 ) | |
378 SetThreadPriority(hThread, 15); | |
379 while ( v20.s.LowPart - PerformanceCount.s.LowPart < 0x32 ) | |
380 { | |
381 QueryPerformanceCounter(&v20); | |
382 v4 = __rdtsc(); | |
383 v23 = v4; | |
384 } | |
385 PerformanceCount = v20; | |
386 do | |
387 { | |
388 QueryPerformanceCounter(&v20); | |
389 v5 = __rdtsc(); | |
390 v24 = v5; | |
391 v6 = v20.s.LowPart; | |
392 v7 = PerformanceCount.s.LowPart; | |
393 } | |
394 while ( v20.s.LowPart - PerformanceCount.s.LowPart < 0x3E8 ); | |
395 if ( nPriority != 2147483647 ) | |
396 { | |
397 SetThreadPriority(hThread, nPriority); | |
398 v7 = PerformanceCount.s.LowPart; | |
399 v6 = v20.s.LowPart; | |
400 } | |
401 v8 = v24 - v23; | |
402 v27 += v24 - v23; | |
403 v9 = (100000 * v6 - 100000 * v7) / (Frequency.s.LowPart / 0xA); | |
404 v10 = v9; | |
405 v26 += v9; | |
406 if ( v9 % Frequency.s.LowPart > Frequency.s.LowPart >> 1 ) | |
407 v10 = v9 + 1; | |
408 v3 = v8 / v10; | |
409 if ( v8 % v10 > v10 >> 1 ) | |
410 v3 = v8 / v10 + 1; | |
411 v2 = v21; | |
412 v11 = v3 + v22 + v21; | |
413 } | |
414 while ( v29 < 3 | |
415 || v29 < 20 | |
416 && ((unsigned int)(3 * v3 - v11) > 3 || (unsigned int)(3 * v21 - v11) > 3 || (unsigned int)(3 * v22 - v11) > 3) ); | |
417 v12 = 10 * v27 / v26; | |
418 if ( 100 * v27 / v26 - 10 * v12 >= 6 ) | |
419 ++v12; | |
420 v16 = v27 / v26; | |
421 v17 = v27 / v26; | |
422 if ( v12 - 10 * v27 / v26 >= 6 ) | |
423 v17 = v27 / v26 + 1; | |
424 v15 = v26; | |
425 Dst = v27; | |
426 } | |
427 result = a1; | |
428 a1->x = Dst; | |
429 a1->y = v15; | |
430 a1->z = v16; | |
431 a1->w = v17; | |
432 return result; | |
433 } | |
434 | |
435 | |
436 | |
437 | |
438 | |
439 //----- (004AC277) -------------------------------------------------------- | |
440 Vec4_int_ *__thiscall _4AC277_get_cpu_speed_sub3(unsigned int _this, Vec4_int_ *a2) | |
441 { | |
442 signed int v2; // esi@1 | |
443 signed __int16 v4; // bx@3 | |
444 int v10; // esi@8 | |
445 int v11; // eax@10 | |
446 Vec4_int_ *result; // eax@13 | |
447 Vec4_int_ Dst; // [sp+8h] [bp-30h]@1 | |
448 LARGE_INTEGER Frequency; // [sp+18h] [bp-20h]@1 | |
449 LARGE_INTEGER PerformanceCount; // [sp+20h] [bp-18h]@3 | |
450 LARGE_INTEGER v16; // [sp+28h] [bp-10h]@5 | |
451 int v17; // [sp+30h] [bp-8h]@1 | |
452 int v18; // [sp+34h] [bp-4h]@2 | |
453 | |
454 v17 = _this; | |
455 v2 = -1; | |
456 memset(&Dst, 0, 0x10u); | |
457 if ( QueryPerformanceFrequency(&Frequency) ) | |
458 { | |
459 v18 = 10; | |
460 do | |
461 { | |
462 QueryPerformanceCounter(&PerformanceCount); | |
463 _EAX = -2147483648; | |
464 v4 = 4000; | |
465 do | |
466 { | |
467 __asm { bsf ecx, eax } | |
468 --v4; | |
469 } | |
470 while ( v4 ); | |
471 QueryPerformanceCounter(&v16); | |
472 if ( (signed int)v16.s.LowPart - (signed int)PerformanceCount.s.LowPart < (unsigned int)v2 ) | |
473 v2 = v16.s.LowPart - PerformanceCount.s.LowPart; | |
474 --v18; | |
475 } | |
476 while ( v18 ); | |
477 v10 = 100000 * v2 / (Frequency.s.LowPart / 0xA); | |
478 if ( v10 % Frequency.s.LowPart > Frequency.s.LowPart >> 1 ) | |
479 ++v10; | |
480 v11 = v17 / (unsigned int)v10; | |
481 Dst.z = v17 / (unsigned int)v10; | |
482 if ( v17 % (unsigned int)v10 > (unsigned int)v10 >> 1 ) | |
483 ++v11; | |
484 Dst.x = v17; | |
485 Dst.y = v10; | |
486 Dst.w = v11; | |
487 } | |
488 result = a2; | |
489 a2->x = Dst.x; | |
490 a2->y = Dst.y; | |
491 a2->z = Dst.z; | |
492 a2->w = Dst.w; | |
493 return result; | |
494 }*/ |