0
|
1 #include "OSAPI.h"
|
|
2
|
|
3 #include "Mouse.h"
|
|
4 #include "Items.h"
|
|
5 #include "Party.h"
|
|
6 #include "LOD.h"
|
|
7 #include "Game.h"
|
|
8 #include "Texture.h"
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16 Mouse *pMouse;
|
|
17 AsyncMouse *pAsyncMouse;
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23 //----- (00469860) --------------------------------------------------------
|
|
24 void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY)
|
|
25 {
|
|
26 unsigned int v3; // eax@2
|
|
27
|
|
28 if (pAsyncMouse)
|
|
29 {
|
|
30 *pX = *((int *)pAsyncMouse + 6);
|
|
31 v3 = *((int *)pAsyncMouse + 7);
|
|
32 }
|
|
33 else
|
|
34 {
|
|
35 *pX = this->uMouseClickX;
|
|
36 v3 = this->uMouseClickY;
|
|
37 }
|
|
38 *pY = v3;
|
|
39 }
|
|
40
|
|
41 //----- (004698A6) --------------------------------------------------------
|
|
42 void Mouse::RemoveHoldingItem()
|
|
43 {
|
|
44 pParty->pPickedItem.Reset();
|
|
45 if (strcmpi(pCurrentCursorName, "MICON2"))
|
|
46 SetCursorBitmap("MICON1");
|
|
47 }
|
|
48
|
|
49 //----- (004698D8) --------------------------------------------------------
|
|
50 void Mouse::SetCursorBitmapFromItemID(unsigned int uItemID)
|
|
51 {
|
|
52 pMouse->SetCursorBitmap(pItemsTable->pItems[uItemID].pIconName);
|
|
53 }
|
|
54
|
|
55 //----- (004698F6) --------------------------------------------------------
|
|
56 void Mouse::SetCurrentCursorBitmap()
|
|
57 {
|
|
58 SetCursorBitmap(pCurrentCursorName);
|
|
59 }
|
|
60
|
|
61 //----- (00469903) --------------------------------------------------------
|
|
62 void Mouse::SetCursorBitmap(const char *pName)
|
|
63 {
|
|
64 Mouse *v2; // esi@1
|
|
65 HCURSOR v3; // eax@10
|
|
66 int v4; // ecx@10
|
|
67 double v5; // st7@11
|
|
68 float v6; // ST04_4@12
|
|
69 LONG v7; // eax@14
|
|
70 LONG v8; // eax@17
|
|
71 unsigned int v9; // eax@21
|
|
72 float v10; // [sp+4h] [bp-18h]@11
|
|
73 struct tagPOINT Point; // [sp+14h] [bp-8h]@20
|
|
74
|
|
75 v2 = this;
|
|
76 if ( !this->bInitialized || !pName )
|
|
77 return;
|
|
78 if ( _strcmpi("MICON2", pName) )
|
|
79 pGame->uFlags2 &= 0xFFFFFFEFu;
|
|
80 else
|
|
81 pGame->uFlags2 |= 0x10u;
|
|
82 if ( _strcmpi(v2->pCurrentCursorName, pName) )
|
|
83 strcpy(v2->pCurrentCursorName, pName);
|
|
84 ClearCursor();
|
|
85 if ( _strnicmp(pName, "MICON1", 5u) )
|
|
86 {
|
|
87 v9 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
|
|
88 v2->uCursorTextureID = v9;
|
|
89 v2->uCursorTextureID_2 = v9;
|
|
90 v2->AllocCursorSystemMem();
|
|
91 v2->field_C = 0;
|
|
92 v2->field_14 = 1;
|
|
93 v2->bActive = 1;
|
|
94 if ( !areWeLoadingTexture )
|
|
95 {
|
|
96 if (uCursorTextureID != -1)
|
|
97 pIcons_LOD->pTextures[uCursorTextureID].Release();
|
|
98 pIcons_LOD->_40F9C5();
|
|
99 }
|
|
100 return;
|
|
101 }
|
|
102 v2->bActive = 0;
|
|
103 v2->field_C = 1;
|
|
104 if ( !strcmp(pName, "MICON1") )
|
|
105 {
|
|
106 v3 = LoadCursorA(GetModuleHandleW(nullptr), "Arrow");
|
|
107 SetClassLongA(hWnd, GCL_HCURSOR, (LONG)v3);
|
|
108 v4 = (int)pAsyncMouse;
|
|
109 if (pAsyncMouse)
|
|
110 {
|
|
111 v10 = 0.0;
|
|
112 v5 = 0.0;
|
779
|
113 //LABEL_12:
|
0
|
114 v6 = v5;
|
|
115 pAsyncMouse->SetHotspot(v6, v10);
|
779
|
116 if ( !pAsyncMouse || (pAsyncMouse->LoadCursor(pName), !pAsyncMouse) )
|
|
117 {
|
|
118 GetCursorPos(&Point);
|
|
119 SetCursorPos(Point.x, Point.y);
|
|
120 }
|
|
121 return;
|
0
|
122 }
|
779
|
123 GetCursorPos(&Point);
|
|
124 ClientToScreen(hWnd,&Point);
|
|
125 SetCursorPos(Point.x, Point.y);
|
|
126 return;
|
0
|
127 }
|
|
128 if ( !strcmp(pName, "MICON2") )
|
|
129 {
|
|
130 v7 = (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target");
|
|
131 SetClassLongA(hWnd, -12, v7);
|
|
132 v4 = (int)pAsyncMouse;
|
|
133 if (pAsyncMouse)
|
|
134 {
|
|
135 v10 = 14.0;
|
|
136 v5 = 14.0;
|
779
|
137 v6 = v5;
|
|
138 pAsyncMouse->SetHotspot(v6, v10);
|
|
139 if ( !pAsyncMouse || (pAsyncMouse->LoadCursor(pName), !pAsyncMouse) )
|
|
140 {
|
|
141 GetCursorPos(&Point);
|
|
142 SetCursorPos(Point.x, Point.y);
|
|
143 }
|
|
144 return;
|
0
|
145 }
|
779
|
146 //LABEL_20:
|
0
|
147 GetCursorPos(&Point);
|
|
148 SetCursorPos(Point.x, Point.y);
|
|
149 return;
|
|
150 }
|
|
151 if ( !strcmp(pName, "MICON3") )
|
|
152 {
|
|
153 v8 = (LONG)LoadCursorA(0, (LPCSTR)IDC_WAIT);
|
|
154 SetClassLongA(hWnd, -12, v8);
|
|
155 }
|
779
|
156 //LABEL_18:
|
0
|
157 if ( !pAsyncMouse || (pAsyncMouse->LoadCursor(pName), !pAsyncMouse) )
|
779
|
158 {
|
|
159 GetCursorPos(&Point);
|
|
160 SetCursorPos(Point.x, Point.y);
|
|
161 }
|
0
|
162 }
|
|
163 // 506128: using guessed type int areWeLoadingTexture;
|
|
164
|
|
165 //----- (00469AE4) --------------------------------------------------------
|
|
166 LONG Mouse::_469AE4()
|
|
167 {
|
|
168 Mouse *v1; // esi@1
|
|
169 LONG v2; // ecx@2
|
|
170 LONG result; // eax@2
|
|
171 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2
|
|
172
|
|
173 v1 = this;
|
|
174 this->field_8 = 1;
|
|
175 if (pAsyncMouse)
|
|
176 {
|
|
177 v2 = *((int *)pAsyncMouse + 6);
|
|
178 Point.x = *((int *)pAsyncMouse + 6);
|
|
179 result = *((int *)pAsyncMouse + 7);
|
|
180 }
|
|
181 else
|
|
182 {
|
|
183 GetCursorPos(&Point);
|
|
184 if ( pRenderer->bWindowMode )
|
|
185 ScreenToClient(hWnd, &Point);
|
|
186 result = Point.y;
|
|
187 v2 = Point.x;
|
|
188 }
|
|
189 v1->uMouseClickX = v2;
|
|
190 v1->uMouseClickY = result;
|
|
191 if ( pRenderer->bWindowMode )
|
|
192 goto LABEL_16;
|
|
193 if (pAsyncMouse)
|
|
194 goto LABEL_24;
|
|
195 if ( v2 < 0 )
|
|
196 v2 = 0;
|
|
197 if ( result < 0 )
|
|
198 result = 0;
|
|
199 if ( v2 > 639 )
|
|
200 v2 = 639;
|
|
201 if ( result > 479 )
|
|
202 {
|
|
203 result = 479;
|
|
204 LABEL_16:
|
|
205 if (pAsyncMouse)
|
|
206 goto LABEL_24;
|
|
207 if ( pRenderer->bWindowMode && (v2 < 0 || result < 0 || v2 > 639 || result > 479) )
|
|
208 goto LABEL_23;
|
|
209 }
|
|
210 if ( v1->field_C )
|
|
211 LABEL_23:
|
|
212 v1->bActive = 0;
|
|
213 LABEL_24:
|
|
214 v1->field_8 = 0;
|
|
215 return result;
|
|
216 }
|
|
217
|
|
218 //----- (00469BA3) --------------------------------------------------------
|
|
219 void Mouse::ClearCursor()
|
|
220 {
|
|
221 Mouse *v1; // esi@1
|
|
222 void *v2; // eax@1
|
|
223 void **v3; // esi@5
|
|
224
|
|
225 v1 = this;
|
|
226 v2 = this->pCursorBitmap_sysmem;
|
|
227 this->bActive = 0;
|
|
228 if ( v2 )
|
|
229 {
|
|
230 free(v2);
|
|
231 v1->pCursorBitmap_sysmem = 0;
|
|
232 }
|
|
233 if ( v1->pCursorBitmap2_sysmem )
|
|
234 {
|
|
235 free(v1->pCursorBitmap2_sysmem);
|
|
236 v1->pCursorBitmap2_sysmem = 0;
|
|
237 }
|
|
238 v3 = &v1->ptr_90;
|
|
239 if ( *v3 )
|
|
240 free(*v3);
|
|
241 *v3 = 0;
|
|
242 }
|
|
243
|
|
244 //----- (00469BE6) --------------------------------------------------------
|
|
245 void Mouse::AllocCursorSystemMem()
|
|
246 {
|
|
247 bActive = 0;
|
|
248 if (!pCursorBitmap_sysmem)
|
|
249 pCursorBitmap_sysmem = (unsigned __int16 *)DoAllocCursorMem();
|
|
250 if (!pCursorBitmap2_sysmem)
|
|
251 pCursorBitmap2_sysmem = (unsigned __int8 *)DoAllocCursorMem();
|
|
252 }
|
|
253
|
|
254 //----- (00469C0D) --------------------------------------------------------
|
|
255 void *Mouse::DoAllocCursorMem()
|
|
256 {
|
|
257 return malloc(4 * (this->uCursorTextureID != -1 ? pIcons_LOD->pTextures[this->uCursorTextureID].uTextureWidth : 24)
|
|
258 * (this->uCursorTextureID != -1 ? pIcons_LOD->pTextures[this->uCursorTextureID].uTextureHeight : 26));
|
|
259 }
|
|
260
|
|
261 //----- (00469C39) --------------------------------------------------------
|
|
262 POINT *Mouse::GetCursorPos(POINT *a2)
|
|
263 {
|
|
264 void *v2; // edx@1
|
|
265 POINT *result; // eax@1
|
|
266 unsigned int v4; // ecx@2
|
|
267 unsigned int v5; // edx@3
|
|
268
|
|
269 v2 = pAsyncMouse;
|
|
270 result = a2;
|
|
271 if (pAsyncMouse)
|
|
272 {
|
|
273 a2->x = *((int *)pAsyncMouse + 6);
|
|
274 v4 = *((int *)v2 + 7);
|
|
275 }
|
|
276 else
|
|
277 {
|
|
278 v5 = this->uMouseClickX;
|
|
279 v4 = this->uMouseClickY;
|
|
280 a2->x = v5;
|
|
281 }
|
|
282 a2->y = v4;
|
|
283 return result;
|
|
284 }
|
|
285
|
|
286 //----- (00469C65) --------------------------------------------------------
|
|
287 void Mouse::Initialize(HWND hWnd)
|
|
288 {
|
|
289 this->hWnd = hWnd;
|
|
290 this->bActive = 0;
|
|
291 this->bInitialized = 1;
|
|
292 this->pCursorBitmapPos.x = 0;
|
|
293 this->pCursorBitmapPos.y = 0;
|
|
294 this->uMouseClickX = 0;
|
|
295 this->uMouseClickY = 0;
|
|
296 this->pCursorBitmap_sysmem = 0;
|
|
297 this->field_34 = 0;
|
|
298 this->pCursorBitmap2_sysmem = 0;
|
|
299
|
|
300 SetCursorBitmap("MICON3");
|
|
301 SetCursorBitmap("MICON2");
|
|
302 SetCursorBitmap("MICON1");
|
|
303 }
|
|
304
|
762
|
305 // inlined
|
|
306 //----- (0045FE00) mm6 chinese --------------------------------------------
|
|
307 void Mouse::SetActive(bool active)
|
|
308 {
|
|
309 bActive = active;
|
|
310 }
|
|
311
|
0
|
312 //----- (00469CC2) --------------------------------------------------------
|
|
313 void Mouse::Deactivate()
|
|
314 {
|
|
315 if (bInitialized)
|
762
|
316 SetActive(false);
|
0
|
317 }
|
|
318
|
|
319 //----- (00469CCD) --------------------------------------------------------
|
|
320 void Mouse::DrawCursor()
|
|
321 {
|
|
322 Mouse *v1; // esi@1
|
|
323 char v11; // zf@6
|
|
324 signed int v3; // eax@6
|
|
325 signed int v4; // ecx@6
|
|
326 Vec4_int_ *v5; // edx@21
|
|
327 int v6; // edi@21
|
|
328 int v7; // ebx@21
|
|
329 int v8; // eax@29
|
|
330 unsigned int v9; // eax@31
|
|
331
|
|
332 v1 = this;
|
|
333 if ( this->bInitialized )
|
|
334 {
|
|
335 if ( !this->field_8 && this->bActive && !this->field_C )
|
|
336 pMouse->_469AE4();
|
|
337 v11 = v1->field_C == 0;
|
|
338 v3 = v1->uMouseClickX;
|
|
339 v4 = v1->uMouseClickY;
|
|
340 v1->field_F4 = 1;
|
|
341 if ( !v11 )
|
|
342 goto LABEL_12;
|
|
343 if ( pRenderer->bWindowMode )
|
|
344 {
|
|
345 if ( v3 < 0 || v4 < 0 || v3 > 639 || v4 > 479 )
|
|
346 {
|
|
347 LABEL_12:
|
|
348 v1->field_F4 = 0;
|
|
349 return;
|
|
350 }
|
|
351 }
|
|
352 else
|
|
353 {
|
|
354 if ( v3 < 0 )
|
|
355 v3 = 0;
|
|
356 if ( v4 < 0 )
|
|
357 v4 = 0;
|
|
358 if ( v3 > 639 )
|
|
359 v3 = 639;
|
|
360 if ( v4 > 479 )
|
|
361 v4 = 479;
|
|
362 }
|
|
363 v5 = &v1->pCursorBitmapRect;
|
|
364 v6 = v3 + v1->uCursorBitmapPitch;
|
|
365 v7 = v4 + v1->field_5C[0];
|
|
366 v1->pCursorBitmapRect.y = v4;
|
|
367 v1->pCursorBitmapRect.x = v3;
|
|
368 v1->pCursorBitmapRect.z = v6;
|
|
369 v1->pCursorBitmapRect.w = v7;
|
|
370 if ( v3 < 0 )
|
|
371 v5->x = 0;
|
|
372 if ( v4 < 0 )
|
|
373 v1->pCursorBitmapRect.y = 0;
|
|
374 if ( v6 > 640 )
|
|
375 v1->pCursorBitmapRect.z = 640;
|
|
376 if ( v7 > 480 )
|
|
377 v1->pCursorBitmapRect.w = 480;
|
|
378 v8 = v1->pCursorBitmapRect.z;
|
|
379 v1->bActive = 0;
|
|
380 v1->uCursorBitmapWidth = v8 - v5->x;
|
|
381 v11 = v1->field_14 == 0;
|
|
382 v1->uCursorBitmapHeight = v1->pCursorBitmapRect.w - v1->pCursorBitmapRect.y;
|
|
383 if ( !v11 )
|
|
384 {
|
|
385 if ( pMouse->ptr_90 )
|
|
386 v9 = 2 * pMouse->uCursorBitmapPitch;
|
|
387 else
|
|
388 v9 = 0;
|
|
389 pRenderer->_4A6DF5(
|
|
390 v1->pCursorBitmap_sysmem,
|
|
391 v9,
|
|
392 &v1->pCursorBitmapPos,
|
|
393 pRenderer->pTargetSurface,
|
|
394 pRenderer->uTargetSurfacePitch,
|
|
395 &v1->pCursorBitmapRect);
|
|
396 v1->field_14 = 0;
|
|
397 }
|
|
398 }
|
|
399 }
|
|
400
|
|
401 //----- (00469E1C) --------------------------------------------------------
|
|
402 void Mouse::_469E1C()
|
|
403 {
|
|
404 bActive = true;
|
|
405 }
|
|
406
|
|
407 //----- (00469E24) --------------------------------------------------------
|
|
408 void Mouse::_469E24()
|
|
409 {
|
|
410 if (pCursorBitmap3_sysmembits_16bit)
|
|
411 {
|
|
412 free(pCursorBitmap3_sysmembits_16bit);
|
|
413 pCursorBitmap3_sysmembits_16bit = 0;
|
|
414 }
|
|
415 }
|
|
416
|
|
417 //----- (00469E3B) --------------------------------------------------------
|
|
418 void Mouse::DrawCursorToTarget()
|
|
419 {
|
|
420 if (!pCursorBitmap3_sysmembits_16bit)
|
|
421 return;
|
|
422
|
|
423 auto pSrc = pCursorBitmap3_sysmembits_16bit;
|
|
424 for (uint y = field_44; y < field_4C; ++y)
|
|
425 for (uint x = field_40; x < field_48; ++x)
|
|
426 pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
|
|
427 }
|
|
428
|
|
429 //----- (00469EA4) --------------------------------------------------------
|
|
430 void Mouse::_469EA4()
|
|
431 {
|
|
432 Mouse *v1; // esi@1
|
|
433 unsigned int v2; // eax@2
|
|
434 Texture *v3; // edi@2
|
|
435 unsigned int v4; // ecx@3
|
|
436 unsigned int v5; // eax@3
|
|
437 unsigned int v6; // ebx@5
|
|
438 int v7; // ecx@15
|
|
439 int v8; // ecx@25
|
|
440 int v9; // ebx@26
|
|
441 unsigned int v10; // eax@26
|
|
442 int v11; // edx@27
|
|
443 unsigned __int16 *v12; // edx@29
|
|
444 unsigned __int16 *v13; // ebx@29
|
|
445 unsigned int a2; // [sp+Ch] [bp-1Ch]@5
|
|
446 unsigned int v15; // [sp+10h] [bp-18h]@5
|
|
447 unsigned int v16; // [sp+14h] [bp-14h]@25
|
|
448 unsigned __int16 *v17; // [sp+18h] [bp-10h]@25
|
|
449 int v18; // [sp+1Ch] [bp-Ch]@27
|
|
450 int v19; // [sp+20h] [bp-8h]@15
|
|
451 unsigned __int16 *v20; // [sp+20h] [bp-8h]@28
|
|
452 int v21; // [sp+24h] [bp-4h]@12
|
|
453 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25
|
|
454
|
|
455 v1 = this;
|
|
456 if ( pParty->pPickedItem.uItemID )
|
|
457 {
|
|
458 v2 = pIcons_LOD->LoadTexture(
|
|
459 pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
|
|
460 TEXTURE_16BIT_PALETTE);
|
|
461 v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
|
|
462 if (pAsyncMouse)
|
|
463 {
|
|
464 v4 = *((int *)pAsyncMouse + 6);
|
|
465 v5 = *((int *)pAsyncMouse + 7);
|
|
466 }
|
|
467 else
|
|
468 {
|
|
469 v4 = pMouse->uMouseClickX;
|
|
470 v5 = pMouse->uMouseClickY;
|
|
471 }
|
|
472 v6 = v5;
|
|
473 a2 = v4;
|
|
474 v15 = v5;
|
|
475 if ( (signed int)v4 <= 639 && (signed int)v5 <= 479 )
|
|
476 {
|
|
477 if ( (v4 & 0x80000000u) != 0 )
|
|
478 a2 = 0;
|
|
479 if ( (v5 & 0x80000000u) != 0 )
|
|
480 {
|
|
481 v6 = 0;
|
|
482 v15 = 0;
|
|
483 }
|
|
484 if ( (signed int)(v3->uTextureWidth + a2) <= 640 )
|
|
485 v21 = v3->uTextureWidth;
|
|
486 else
|
|
487 v21 = 640 - a2;
|
|
488 if ( (signed int)(v3->uTextureHeight + v6) <= 480 )
|
|
489 {
|
|
490 v19 = v3->uTextureHeight;
|
|
491 v7 = v3->uTextureHeight;
|
|
492 }
|
|
493 else
|
|
494 {
|
|
495 v7 = 480 - v6;
|
|
496 v19 = 480 - v6;
|
|
497 }
|
|
498 if ( !v1->pCursorBitmap3_sysmembits_16bit
|
|
499 || a2 != v1->field_40
|
|
500 || v6 != v1->field_44
|
|
501 || a2 + v21 != v1->field_48
|
|
502 || v6 + v7 != v1->field_4C )
|
|
503 {
|
|
504 if ( v1->pCursorBitmap3_sysmembits_16bit )
|
|
505 free(v1->pCursorBitmap3_sysmembits_16bit);
|
|
506 v1->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)operator new(2 * v3->uTextureHeight
|
|
507 * v3->uTextureWidth);
|
|
508 v1->field_40 = a2;
|
|
509 v1->field_48 = a2 + v21;
|
|
510 v1->field_44 = v6;
|
|
511 v1->field_4C = v6 + v19;
|
|
512 }
|
|
513 v8 = v1->field_44;
|
|
514 v22 = v1->pCursorBitmap3_sysmembits_16bit;
|
|
515 v17 = pRenderer->pTargetSurface;
|
|
516 v16 = pRenderer->uTargetSurfacePitch;
|
|
517 if ( v8 < v1->field_4C )
|
|
518 {
|
|
519 v9 = v1->field_48;
|
|
520 v10 = pRenderer->uTargetSurfacePitch * v8;
|
|
521 do
|
|
522 {
|
|
523 v11 = v1->field_40;
|
|
524 v18 = v1->field_40;
|
|
525 if ( v11 < v9 )
|
|
526 {
|
|
527 v20 = &v17[v10 + v11];
|
|
528 do
|
|
529 {
|
|
530 v12 = v20;
|
|
531 v13 = v22;
|
|
532 ++v18;
|
|
533 ++v20;
|
|
534 ++v22;
|
|
535 *v13 = *v12;
|
|
536 v9 = v1->field_48;
|
|
537 }
|
|
538 while ( v18 < v9 );
|
|
539 }
|
|
540 v10 += v16;
|
|
541 ++v8;
|
|
542 }
|
|
543 while ( v8 < v1->field_4C );
|
|
544 v6 = v15;
|
|
545 }
|
315
|
546 if (pParty->pPickedItem.Broken())
|
|
547 pRenderer->DrawTransparentRedShade(a2, v6, v3);
|
|
548 else if (!pParty->pPickedItem.Identified())
|
|
549 pRenderer->DrawTransparentGreenShade(a2, v6, v3);
|
0
|
550 else
|
315
|
551 pRenderer->DrawTextureTransparent(a2, v6, v3);
|
0
|
552 }
|
|
553 }
|
|
554 else
|
|
555 {
|
|
556 if ( this->pCursorBitmap3_sysmembits_16bit )
|
|
557 {
|
|
558 free(this->pCursorBitmap3_sysmembits_16bit);
|
|
559 v1->pCursorBitmap3_sysmembits_16bit = 0;
|
|
560 }
|
|
561 }
|
|
562 }
|
|
563
|
|
564 //----- (0046A080) --------------------------------------------------------
|
|
565 void Mouse::Activate(int bActive)
|
|
566 {
|
|
567 bActive = bActive;
|
|
568 }
|
|
569
|
|
570 //----- (0046A08A) --------------------------------------------------------
|
|
571 void Mouse::SetMouseClick(int x, int y)
|
|
572 {
|
|
573 uMouseClickX = x;
|
|
574 uMouseClickY = y;
|
|
575 }
|
|
576
|
|
577
|
|
578 //----- (00409E3D) --------------------------------------------------------
|
|
579 void AsyncMouse::_409E3D(char a2)
|
|
580 {
|
|
581 if ( *((unsigned char *)this + 128) & 1 )
|
|
582 *((unsigned char *)this + 103) = 1;
|
|
583 else
|
|
584 *((unsigned char *)this + 103) = 0;
|
|
585 if ( a2 )
|
|
586 *((unsigned int *)this + 32) |= 1u;
|
|
587 else
|
|
588 *((unsigned int *)this + 32) &= 0xFFFFFFFEu;
|
|
589 }
|
|
590
|
|
591 //----- (00465C2C) --------------------------------------------------------
|
|
592 void AsyncMouse::Release()
|
|
593 {
|
|
594 if (pAsyncMouse)
|
|
595 {
|
|
596 pAsyncMouse->Suspend();
|
|
597 if (pAsyncMouse)
|
|
598 (**(void (__stdcall ***)(int))pAsyncMouse)(1);
|
|
599 }
|
|
600 pAsyncMouse = 0;
|
|
601 }
|
|
602
|
|
603
|
|
604
|
|
605
|
|
606 //----- (0046ACA9) --------------------------------------------------------
|
|
607 AsyncMouse::AsyncMouse(IDirectDrawSurface *a2)
|
|
608 {
|
|
609 IDirectDrawSurface *v2; // eax@1
|
|
610 void *v3; // esi@1
|
|
611 char *v4; // edi@1
|
|
612 double v5; // ST14_8@3
|
|
613 double v6; // ST14_8@3
|
|
614
|
|
615 v2 = a2;
|
|
616 v3 = this;
|
|
617 *((int *)this + 16) = -1;
|
|
618 *((int *)this + 3) = (int)v2;
|
|
619 LOBYTE(v2) = BYTE3(a2);
|
|
620 v4 = (char *)this + 104;
|
|
621 *((int *)this + 1) = 0;
|
|
622 *((char *)this + 20) = 0;
|
|
623 *((int *)this + 17) = 0;
|
|
624 *((int *)this + 18) = 0;
|
|
625 *((char *)this + 88) = 1;
|
|
626 *((char *)this + 91) = 0;
|
|
627 *((char *)this + 93) = 0;
|
|
628 *((char *)this + 94) = 0;
|
|
629 *((char *)this + 95) = 0;
|
|
630 *((char *)this + 96) = 0;
|
|
631 *((char *)this + 97) = 0;
|
|
632 *((char *)this + 98) = 0;
|
|
633 *((char *)this + 99) = 0;
|
|
634 *((char *)this + 100) = 0;
|
|
635 *((char *)this + 101) = 0;
|
|
636 *((char *)this + 102) = 0;
|
|
637 *((char *)this + 104) = (char)v2;
|
|
638 *((int *)this + 27) = (int)AsyncMouse::unk_46BD09(0, 0);
|
|
639 *((int *)v4 + 2) = 0;
|
|
640 *((char *)v3 + 116) = BYTE3(a2);
|
|
641 *((int *)v3 + 30) = (int)AsyncMouse::unk_46BD09(0, 0);
|
|
642 *((int *)v3 + 31) = 0;
|
|
643 *((int *)v3 + 32) = 0;
|
|
644 *((int *)v3 + 33) = 0;
|
|
645 *(int *)v3 = 5080880;
|
|
646 if ( !Initialize(this) )
|
|
647 {
|
|
648 MessageBoxW(nullptr, L"Could not initialize CMouseAsync object", nullptr, 0);
|
|
649 }
|
|
650 *((int *)v3 + 12) = 0;
|
|
651 *((int *)v3 + 13) = 0;
|
|
652 *((int *)v3 + 14) = 0;
|
|
653 *((int *)v3 + 15) = 0;
|
|
654 v5 = (float)0.0 + 6.7553994e15;
|
|
655 *((int *)v3 + 10) = LODWORD(v5);
|
|
656 v6 = (float)0.0 + 6.7553994e15;
|
|
657 a2 = (IDirectDrawSurface *)LODWORD(v6);
|
|
658 *((int *)v3 + 32) |= 1u;
|
|
659 *((int *)v3 + 11) = LODWORD(v6);
|
|
660 *((char *)v3 + 103) = 1;
|
|
661 }
|
|
662 // 4DBD94: using guessed type int dword_4DBD94;
|
|
663
|
|
664
|
|
665
|
|
666 //----- (0046ADE2) --------------------------------------------------------
|
|
667 AsyncMouse::~AsyncMouse()
|
|
668 {
|
|
669 void *v1; // esi@1
|
|
670 char *v2; // edi@1
|
|
671 int v3; // ecx@1
|
|
672
|
|
673 v1 = this;
|
|
674 //*(int *)this = AsyncMouse_pvdtor;
|
|
675 v2 = (char *)this + 132;
|
|
676 v3 = *((int *)this + 33);
|
|
677 if ( v3 )
|
|
678 (**(void (__stdcall ***)(int))v3)(1);
|
|
679 *(int *)v2 = 0;
|
|
680 TerminateThread(*((HANDLE *)v1 + 4), 0xFAu);
|
|
681 SetWindowPos(hWnd, (HWND)0xFFFFFFFE, uWindowX, uWindowY, 640, 480, 0);
|
|
682 //AsyncMouse::dtor_sub_46BC73((int)((char *)v1 + 116));
|
|
683 //AsyncMouse::dtor_sub_46BC73((int)((char *)v1 + 104));
|
|
684 }
|
|
685 // 4D8730: using guessed type int (__stdcall *AsyncMouse_pvdtor[2])(char);
|
|
686
|
|
687
|
|
688
|
|
689
|
|
690
|
|
691
|
|
692
|
|
693
|
|
694
|
|
695
|
|
696
|
|
697
|
|
698
|
|
699 //----- (0046AE6E) --------------------------------------------------------
|
|
700 char AsyncMouse::Initialize(LPVOID lpParameter)
|
|
701 {
|
|
702 void *v1; // esi@1
|
|
703 char result; // al@2
|
|
704
|
|
705 v1 = lpParameter;
|
|
706 if ( LoadCursorImage() && _46B072() )
|
|
707 result = CreateDisrectInputMouse() != 0;
|
|
708 else
|
|
709 result = 0;
|
|
710 return result;
|
|
711 }
|
|
712
|
|
713 //----- (0046AE97) --------------------------------------------------------
|
|
714 char AsyncMouse::LoadCursor(const char *pContainer)
|
|
715 {
|
|
716 __debugbreak();
|
|
717 return 0;
|
|
718 /*
|
|
719 void *v2; // esi@1
|
|
720 int v3; // eax@1
|
|
721 HRESULT v4; // eax@1
|
|
722 char result; // al@3
|
|
723 HRESULT a2; // [sp+8h] [bp-B0h]@1
|
|
724 int v7; // [sp+58h] [bp-60h]@1
|
|
725 char v9; // [sp+B4h] [bp-4h]@1
|
|
726
|
|
727 v2 = this;
|
|
728 EnterCriticalSection(&pGame->pThreadWardInstance->cs2);
|
|
729 v3 = *((int *)v2 + 1);
|
|
730 a2 = 100;
|
|
731 v7 = 0;
|
|
732 v4 = (*(int (__stdcall **)(int, int, int, int, signed int, HRESULT *))(*(int *)v3 + 20))(
|
|
733 v3,
|
|
734 0,
|
|
735 0,
|
|
736 0,
|
|
737 1024,
|
|
738 &a2);
|
|
739 ErrHR(v4, "DirectInput", __FUNCTION__, __FILE__, __LINE__);
|
|
740
|
|
741 Texture thisa; // [sp+6Ch] [bp-4Ch]@1
|
|
742 //Texture::Texture(&thisa);
|
|
743
|
|
744 if ( pIcons_LOD->LoadTextureFromLOD(&thisa, pContainer, TEXTURE_16BIT_PALETTE) != -1
|
|
745 && DrawCursor(&thisa, *((IDirectDrawSurface4 **)v2 + 1), 0) )
|
|
746 {
|
|
747 thisa.Release();
|
|
748 LeaveCriticalSection(&pGame->pThreadWardInstance->cs2);
|
|
749 result = 1;
|
|
750 }
|
|
751 else
|
|
752 {
|
|
753 result = 0;
|
|
754 }
|
|
755 return result;*/
|
|
756 }
|
|
757
|
|
758 //----- (0046AF50) --------------------------------------------------------
|
|
759 char AsyncMouse::LoadCursorImage()
|
|
760 {
|
|
761 void *v1; // ebx@1
|
|
762 int v2; // eax@2
|
|
763 int v3; // esi@4
|
|
764 char result; // al@5
|
|
765 //const char *v5; // eax@6
|
|
766 //std::string v6; // [sp-18h] [bp-12Ch]@9
|
|
767 const char *v7; // [sp-8h] [bp-11Ch]@9
|
|
768 int v8; // [sp-4h] [bp-118h]@9
|
|
769 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-108h]@1
|
|
770 int v10; // [sp+88h] [bp-8Ch]@2
|
|
771 int v11; // [sp+8Ch] [bp-88h]@2
|
|
772 int v12; // [sp+90h] [bp-84h]@2
|
|
773 int v13; // [sp+94h] [bp-80h]@2
|
|
774 char v14; // [sp+D0h] [bp-44h]@2
|
|
775 int v15; // [sp+F0h] [bp-24h]@2
|
|
776 int v16; // [sp+104h] [bp-10h]@4
|
|
777 int v17; // [sp+108h] [bp-Ch]@4
|
|
778 std::string *v18; // [sp+10Ch] [bp-8h]@9
|
|
779 int a3; // [sp+113h] [bp-1h]@9
|
|
780
|
|
781 v1 = this;
|
|
782 memset(&Dst, 0, 0x7Cu);
|
|
783 Dst.dwSize = 124;
|
|
784 if ( pRenderer->pDirectDraw4->GetDisplayMode(&Dst)
|
|
785 || (memset(&v10, 0, 0x7Cu),
|
|
786 v10 = 124,
|
|
787 v11 = 4103,
|
|
788 v15 = 2112,
|
|
789 v12 = 32,
|
|
790 v13 = 32,
|
|
791 v2 = *((int *)v1 + 3),
|
|
792 memcpy(&v14, &Dst.ddpfPixelFormat, 0x20u),
|
|
793 (*(int (__stdcall **)(int, int *, char *, int))(**(int **)v2 + 24))(
|
|
794 *(int *)v2,
|
|
795 &v10,
|
|
796 (char *)v1 + 4,
|
|
797 0))
|
|
798 || (*(int (__stdcall **)(int, int *, char *, int))(***((int ***)v1 + 3) + 24))(
|
|
799 **((int **)v1 + 3),
|
|
800 &v10,
|
|
801 (char *)v1 + 8,
|
|
802 0)
|
|
803 || (v3 = *((int *)v1 + 1),
|
|
804 v16 = 0,
|
|
805 v17 = 0,
|
|
806 (*(int (__stdcall **)(int, signed int, int *))(*(int *)v3 + 116))(v3, 8, &v16)) )
|
|
807 {
|
|
808 result = 0;
|
|
809 return false;
|
|
810 }
|
|
811 else
|
|
812 {
|
|
813 if ( !LoadCursor("micon1") )
|
|
814 {
|
|
815 MessageBoxW(nullptr, L"Could not load async mouse cursor image", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:182", 0);
|
|
816 }
|
|
817 result = 1;
|
|
818 return true;
|
|
819 }
|
|
820 return result;
|
|
821 }
|
|
822 // 4D86F0: using guessed type int dword_4D86F0;
|
|
823
|
|
824 //----- (0046B072) --------------------------------------------------------
|
|
825 char AsyncMouse::_46B072()
|
|
826 {
|
|
827 DWORD v1; // esi@1
|
|
828 HANDLE v2; // eax@1
|
|
829 char result; // al@2
|
|
830 DWORD ThreadId; // [sp+0h] [bp-4h]@1
|
|
831
|
|
832 ThreadId = (DWORD)this;
|
|
833 v1 = (DWORD)this;
|
|
834 v2 = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)AsyncMouseThread, this, 4u, &ThreadId);
|
|
835 *(int *)(v1 + 16) = (int)v2;
|
|
836 if ( v2 )
|
|
837 result = SetThreadPriority(v2, 15) != 0;
|
|
838 else
|
|
839 result = 0;
|
|
840 return result;
|
|
841 }
|
|
842
|
|
843 //----- (0046B0A9) --------------------------------------------------------
|
|
844 char AsyncMouse::CreateDisrectInputMouse()
|
|
845 {
|
|
846 __debugbreak();
|
|
847 /*
|
|
848 void *v1; // esi@1
|
|
849 DirectInputMouse *v2; // ecx@1
|
|
850 DirectInputMouse *v3; // eax@2
|
|
851
|
|
852 v1 = this;
|
|
853 v2 = (DirectInputMouse *)operator new(0x2Cu);
|
|
854 if ( v2 )
|
|
855 v3 = DirectInputMouse::DirectInputMouse(v2);
|
|
856 else
|
|
857 v3 = 0;
|
|
858 *((int *)v1 + 33) = v3;
|
|
859 return v3 != 0;*/
|
|
860 return 0;
|
|
861 }
|
|
862
|
|
863 //----- (0046B0ED) --------------------------------------------------------
|
|
864 int AsyncMouse::_46B0ED()
|
|
865 {
|
|
866 __debugbreak();
|
|
867 /*
|
|
868 int v1; // esi@1
|
|
869 int v2; // ecx@1
|
|
870 int result; // eax@2
|
|
871
|
|
872 v1 = this + 132;
|
|
873 v2 = *(int *)(this + 132);
|
|
874 if ( v2 )
|
|
875 result = (**(int (__stdcall ***)(int))v2)(1);
|
|
876 *(int *)v1 = 0;
|
|
877 return result;*/
|
|
878 return 0;
|
|
879 }
|
|
880 // 46B0ED: using guessed type int __thiscall AsyncMouse__46B0ED(int);
|
|
881
|
|
882 //----- (0046B105) --------------------------------------------------------
|
|
883 void AsyncMouse::Resume()
|
|
884 {
|
|
885 __debugbreak();
|
|
886 /*
|
|
887 void *v1; // esi@1
|
|
888
|
|
889 v1 = this;
|
|
890 EnterCriticalSection(&pGame->pThreadWardInstance->cs3);
|
|
891 AsyncMouse::CreateDisrectInputMouse(v1);
|
|
892 AsyncMouse::Clip();
|
|
893 ResumeThread(*((HANDLE *)v1 + 4));
|
|
894 *((char *)v1 + 88) = 0;
|
|
895 LeaveCriticalSection(&pGame->pThreadWardInstance->cs3);*/
|
|
896 }
|
|
897
|
|
898 //----- (0046B14F) --------------------------------------------------------
|
|
899 void AsyncMouse::Suspend()
|
|
900 {
|
|
901 void *v1; // esi@1
|
194
|
902 //Vis *v2; // eax@3
|
0
|
903 std::string v3; // [sp-18h] [bp-24h]@2
|
|
904 const char *v4; // [sp-8h] [bp-14h]@2
|
|
905 int v5; // [sp-4h] [bp-10h]@2
|
|
906 std::string *v6; // [sp+4h] [bp-8h]@2
|
|
907 int a3; // [sp+Bh] [bp-1h]@2
|
|
908
|
|
909 v1 = this;
|
|
910 if ( *((int *)this + 33) )
|
|
911 {
|
194
|
912 //v2 = pGame->pVisInstance;
|
|
913 if (pGame->pVisInstance)
|
|
914 pGame->pVisInstance->default_list.uNumPointers = 0;
|
|
915
|
0
|
916 EnterCriticalSection(&pGame->pThreadWardInstance->cs3);
|
|
917 SuspendThread(*((HANDLE *)v1 + 4));
|
|
918 _46B0ED();
|
|
919 LeaveCriticalSection(&pGame->pThreadWardInstance->cs3);
|
|
920 }
|
|
921 else
|
|
922 {
|
|
923 MessageBoxW(nullptr, L"DI_Mouse pointer invalid; bailing out from suspend()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:233", 0);
|
|
924 }
|
|
925 }
|
|
926 // 46B0ED: using guessed type int __thiscall AsyncMouse__46B0ED(int);
|
|
927
|
|
928 //----- (0046B1DD) --------------------------------------------------------
|
|
929 char AsyncMouse::_46B1DD()
|
|
930 {
|
|
931 *((char *)this + 20) = 1;
|
|
932 Sleep(118);
|
|
933 return 1;
|
|
934 }
|
|
935
|
|
936 //----- (0046B1EC) --------------------------------------------------------
|
|
937 bool AsyncMouse::DrawCursor(Texture *a1, IDirectDrawSurface4 *a2, int a3)
|
|
938 {
|
|
939 __debugbreak();
|
|
940 /*
|
|
941 bool result; // eax@1
|
|
942 unsigned __int16 *v5; // ebx@2
|
|
943 unsigned __int8 *v6; // edx@2
|
|
944 int v7; // esi@2
|
|
945 int v8; // ecx@2
|
|
946 LPVOID v9; // edi@2
|
|
947 int v10; // ecx@5
|
|
948 DDSURFACEDESC2 Dst; // [sp+0h] [bp-84h]@1
|
|
949 __int32 v12; // [sp+7Ch] [bp-8h]@3
|
|
950 int v13; // [sp+80h] [bp-4h]@3
|
|
951
|
|
952 Dst.dwSize = 124;
|
168
|
953 result = pRenderer->LockSurface_DDraw4(a2, &Dst, DDLOCK_WAIT);
|
0
|
954 if ( result )
|
|
955 {
|
|
956 v5 = a1->pPalette16;
|
710
|
957 v6 = a1->pLevelOfDetail0_prolly_alpha_mask;
|
0
|
958 v7 = a1->uTextureWidth;
|
|
959 v8 = a1->uTextureHeight;
|
|
960 v9 = Dst.lpSurface;
|
|
961 if ( v8 > 0 )
|
|
962 {
|
|
963 v12 = 2 * (Dst.lPitch / 2 - v7);
|
|
964 v13 = v8;
|
|
965 do
|
|
966 {
|
|
967 if ( v7 > 0 )
|
|
968 {
|
|
969 v10 = v7;
|
|
970 do
|
|
971 {
|
|
972 if ( v5[*v6] )
|
|
973 *(short *)v9 = v5[*v6];
|
|
974 v9 = (char *)v9 + 2;
|
|
975 ++v6;
|
|
976 --v10;
|
|
977 }
|
|
978 while ( v10 );
|
|
979 }
|
|
980 v9 = (char *)v9 + v12;
|
|
981 --v13;
|
|
982 }
|
|
983 while ( v13 );
|
|
984 }
|
|
985 result = a2->Unlock(
|
|
986 v6,
|
|
987 a2,
|
|
988 a3);
|
|
989 }
|
|
990 LOBYTE(result) = 1;
|
|
991 return result;*/
|
|
992 return 0;
|
|
993 }
|
|
994
|
|
995 //----- (0046B289) --------------------------------------------------------
|
|
996 bool AsyncMouse::_46B289(int a2, char a3)
|
|
997 {
|
|
998 char v3; // dl@1
|
|
999 bool result; // eax@33
|
|
1000 char v5; // [sp+2h] [bp-2h]@1
|
|
1001 char v6; // [sp+3h] [bp-1h]@1
|
|
1002
|
|
1003 v3 = *((char *)this + 93);
|
|
1004 v6 = *((char *)this + 94);
|
|
1005 v5 = *((char *)this + 95);
|
|
1006 if ( a3 & 1 )
|
|
1007 {
|
|
1008 *((char *)this + 93) = 1;
|
|
1009 }
|
|
1010 else
|
|
1011 {
|
|
1012 if ( v3 )
|
|
1013 *((char *)this + 99) = 1;
|
|
1014 else
|
|
1015 *((char *)this + 99) = 0;
|
|
1016 *((char *)this + 93) = 0;
|
|
1017 }
|
|
1018 if ( a3 & 2 )
|
|
1019 {
|
|
1020 *((char *)this + 94) = 1;
|
|
1021 }
|
|
1022 else
|
|
1023 {
|
|
1024 if ( v6 )
|
|
1025 *((char *)this + 100) = 1;
|
|
1026 else
|
|
1027 *((char *)this + 100) = 0;
|
|
1028 *((char *)this + 94) = 0;
|
|
1029 }
|
|
1030 if ( a3 & 4 )
|
|
1031 {
|
|
1032 *((char *)this + 95) = 1;
|
|
1033 }
|
|
1034 else
|
|
1035 {
|
|
1036 if ( v5 )
|
|
1037 *((char *)this + 101) = 1;
|
|
1038 else
|
|
1039 *((char *)this + 101) = 0;
|
|
1040 *((char *)this + 95) = 0;
|
|
1041 }
|
|
1042 *((char *)this + 96) = v3 != *((char *)this + 93);
|
|
1043 *((char *)this + 97) = v6 != *((char *)this + 94);
|
|
1044 *((char *)this + 98) = v5 != *((char *)this + 95);
|
|
1045 if ( *((char *)this + 99) && *((char *)this + 96) || *((char *)this + 100) && *((char *)this + 97) )
|
|
1046 *((char *)this + 102) = 1;
|
|
1047 LOBYTE(result) = 1;
|
|
1048 return result;
|
|
1049 }
|
|
1050
|
|
1051 //----- (0046B342) --------------------------------------------------------
|
|
1052 void AsyncMouse::SetHotspot(float hotspotx, float hotspoty)
|
|
1053 {
|
|
1054 double v3; // ST00_8@1
|
|
1055 double v4; // ST00_8@1
|
|
1056
|
|
1057 v3 = hotspotx + 6.7553994e15;
|
|
1058 *(int *)(this + 40) = LODWORD(v3);
|
|
1059 v4 = hotspoty + 6.7553994e15;
|
|
1060 *(int *)(this + 44) = LODWORD(v4);
|
|
1061 }
|
|
1062
|
|
1063 //----- (0046B37C) --------------------------------------------------------
|
|
1064 int AsyncMouse::UpdateData(int a2)
|
|
1065 {
|
|
1066 __debugbreak();
|
|
1067 /*
|
|
1068 void *v2; // edi@1
|
|
1069 int result; // eax@2
|
|
1070 int v4; // eax@3
|
|
1071 int v5; // esi@3
|
|
1072 std::string v6; // [sp-18h] [bp-28h]@2
|
|
1073 const char *v7; // [sp-8h] [bp-18h]@2
|
|
1074 int v8; // [sp-4h] [bp-14h]@2
|
|
1075 std::string *v9; // [sp+8h] [bp-8h]@2
|
|
1076 int a3; // [sp+Fh] [bp-1h]@2
|
|
1077
|
|
1078 v2 = this;
|
|
1079 if ( *((int *)this + 33) )
|
|
1080 {
|
|
1081 EnterCriticalSection(&pGame->pThreadWardInstance->cs3);
|
|
1082 DirectInputMouse::_43BB89(*((DirectInputMouse **)v2 + 33));
|
|
1083 v4 = *((int *)v2 + 33);
|
|
1084 v5 = v4 + 32;
|
|
1085 _46B289(v4 + 32, *(int *)(v4 + 40));
|
|
1086 LeaveCriticalSection(&pGame->pThreadWardInstance->cs3);
|
|
1087 result = a2;
|
|
1088 *(int *)a2 = *(int *)v5;
|
|
1089 *(int *)(a2 + 4) = *(int *)(v5 + 4);
|
|
1090 }
|
|
1091 else
|
|
1092 {
|
|
1093 MessageBoxW(nullptr, L"DI_Mouse pointer invalid bailing out from update_mouse_data()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:446", 0);
|
|
1094 result = a2;
|
|
1095 *(int *)a2 = 0;
|
|
1096 *(int *)(a2 + 4) = 0;
|
|
1097 }
|
|
1098 return result;*/
|
|
1099 return 0;
|
|
1100 }
|
|
1101
|
|
1102 //----- (0046B420) --------------------------------------------------------
|
|
1103 char AsyncMouse::Thread()
|
|
1104 {
|
|
1105 void *v1; // esi@1
|
|
1106 char result; // al@2
|
|
1107 int v3; // eax@3
|
|
1108 int v4; // ecx@3
|
|
1109 int v5; // eax@3
|
|
1110 int v6; // ecx@3
|
|
1111 int v7; // [sp+4h] [bp-8h]@3
|
|
1112 int v8; // [sp+8h] [bp-4h]@3
|
|
1113
|
|
1114 v1 = this;
|
|
1115 if ( *((char *)this + 20) )
|
|
1116 {
|
|
1117 result = 0;
|
|
1118 }
|
|
1119 else
|
|
1120 {
|
|
1121 UpdateData((int)&v7);
|
|
1122 _46BA8D(v7, v8);
|
|
1123 _46B958(v7 - *((int *)v1 + 10), v8 - *((int *)v1 + 11));
|
|
1124 _46B492((int)&v7);
|
|
1125 _46B5D5((int)&v7);
|
|
1126 v3 = v7;
|
|
1127 v4 = v8;
|
|
1128 *((int *)v1 + 6) = v7;
|
|
1129 v5 = v3 - *((int *)v1 + 10);
|
|
1130 *((int *)v1 + 7) = v4;
|
|
1131 v6 = v4 - *((int *)v1 + 11);
|
|
1132 *((int *)v1 + 8) = v5;
|
|
1133 result = 1;
|
|
1134 *((int *)v1 + 9) = v6;
|
|
1135 }
|
|
1136 return result;
|
|
1137 }
|
|
1138
|
|
1139 //----- (0046B492) --------------------------------------------------------
|
|
1140 void AsyncMouse::_46B492(int a2)
|
|
1141 {
|
|
1142 __debugbreak();
|
|
1143 /*
|
|
1144 void *v2; // edi@1
|
|
1145 int v3; // esi@3
|
|
1146 int v4; // eax@5
|
|
1147 int v5; // ecx@5
|
|
1148 int v6; // eax@8
|
|
1149 int v7; // ecx@8
|
|
1150 int v8; // eax@11
|
|
1151 int v9; // esi@11
|
|
1152 int v10; // [sp+Ch] [bp-1Ch]@5
|
|
1153 int v11; // [sp+10h] [bp-18h]@5
|
|
1154 int v12; // [sp+14h] [bp-14h]@5
|
|
1155 int v13; // [sp+18h] [bp-10h]@5
|
|
1156 int v14; // [sp+24h] [bp-4h]@5
|
|
1157
|
|
1158 v2 = this;
|
|
1159 EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);
|
|
1160 if ( *((int *)v2 + 28) > 0x80u )
|
|
1161 _46BCAB((char *)v2 + 104);
|
|
1162 v3 = a2;
|
|
1163 if ( *((char *)v2 + 93) && *((char *)v2 + 96) )
|
|
1164 {
|
|
1165 v4 = *(int *)a2;
|
|
1166 v5 = *(int *)(a2 + 4);
|
|
1167 v13 = 1;
|
|
1168 v10 = 5080884;
|
|
1169 v11 = v4;
|
|
1170 v12 = v5;
|
|
1171 v14 = 0;
|
|
1172 AsyncMouse::unk_46BCD2((char *)v2 + 104, (int)&a2, *((int *)v2 + 27), (int)&v10);
|
|
1173 v14 = -1;
|
|
1174 }
|
|
1175 if ( *((char *)v2 + 94) && *((char *)v2 + 97) )
|
|
1176 {
|
|
1177 v6 = *(int *)v3;
|
|
1178 v7 = *(int *)(v3 + 4);
|
|
1179 v13 = 2;
|
|
1180 v10 = 5080884;
|
|
1181 v11 = v6;
|
|
1182 v12 = v7;
|
|
1183 v14 = 1;
|
|
1184 AsyncMouse::unk_46BCD2((char *)v2 + 104, (int)&a2, *((int *)v2 + 27), (int)&v10);
|
|
1185 v14 = -1;
|
|
1186 }
|
|
1187 if ( *((char *)v2 + 95) && *((char *)v2 + 98) )
|
|
1188 {
|
|
1189 v8 = *(int *)v3;
|
|
1190 v9 = *(int *)(v3 + 4);
|
|
1191 v13 = 4;
|
|
1192 v10 = 5080884;
|
|
1193 v11 = v8;
|
|
1194 v12 = v9;
|
|
1195 v14 = 2;
|
|
1196 AsyncMouse::unk_46BCD2((char *)v2 + 104, (int)&a2, *((int *)v2 + 27), (int)&v10);
|
|
1197 }
|
|
1198 LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);*/
|
|
1199 }
|
|
1200
|
|
1201 //----- (0046B5D5) --------------------------------------------------------
|
|
1202 void AsyncMouse::_46B5D5(int a2)
|
|
1203 {
|
|
1204 __debugbreak();
|
|
1205 /*
|
|
1206 void *v2; // esi@1
|
|
1207 DWORD v3; // eax@3
|
|
1208 char v4; // zf@3
|
|
1209 int v5; // edi@3
|
|
1210 int v6; // eax@6
|
|
1211 int v7; // ecx@6
|
|
1212 int v8; // eax@11
|
|
1213 int v9; // ecx@11
|
|
1214 int v10; // eax@16
|
|
1215 int v11; // edi@16
|
|
1216 int (__stdcall **v12)(char); // [sp+Ch] [bp-20h]@6
|
|
1217 int v13; // [sp+10h] [bp-1Ch]@6
|
|
1218 int v14; // [sp+14h] [bp-18h]@6
|
|
1219 int v15; // [sp+18h] [bp-14h]@6
|
|
1220 DWORD v16; // [sp+1Ch] [bp-10h]@3
|
|
1221 int v17; // [sp+28h] [bp-4h]@6
|
|
1222
|
|
1223 v2 = this;
|
|
1224 EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);
|
|
1225 if ( *((int *)v2 + 31) > 0x80u )
|
|
1226 _46BCAB((char *)v2 + 116);
|
|
1227 v3 = timeGetTime();
|
|
1228 v4 = *((char *)v2 + 93) == 0;
|
|
1229 v5 = a2;
|
|
1230 v16 = v3;
|
|
1231 if ( !v4 && *((char *)v2 + 96) )
|
|
1232 {
|
|
1233 if ( v3 - *((int *)v2 + 19) < 0xFA )
|
|
1234 {
|
|
1235 v6 = *(int *)a2;
|
|
1236 v7 = *(int *)(a2 + 4);
|
|
1237 v15 = 1;
|
|
1238 v12 = &AsyncMouse::unk::vdtor_ptr;
|
|
1239 v13 = v6;
|
|
1240 v14 = v7;
|
|
1241 v17 = 0;
|
|
1242 AsyncMouse::unk_46BCD2((char *)v2 + 116, (int)&a2, *((int *)v2 + 30), (int)&v12);
|
|
1243 v17 = -1;
|
|
1244 v3 = v16;
|
|
1245 }
|
|
1246 *((int *)v2 + 19) = v3;
|
|
1247 }
|
|
1248 if ( *((char *)v2 + 94) && *((char *)v2 + 97) )
|
|
1249 {
|
|
1250 if ( v3 - *((int *)v2 + 20) < 0xFA )
|
|
1251 {
|
|
1252 v8 = *(int *)v5;
|
|
1253 v9 = *(int *)(v5 + 4);
|
|
1254 v15 = 2;
|
|
1255 //v12 = &AsyncMouse::unk::vdtor_ptr;
|
|
1256 v13 = v8;
|
|
1257 v14 = v9;
|
|
1258 v17 = 1;
|
|
1259 AsyncMouse::unk_46BCD2((char *)v2 + 116, (int)&a2, *((int *)v2 + 30), (int)&v12);
|
|
1260 v17 = -1;
|
|
1261 v3 = v16;
|
|
1262 }
|
|
1263 *((int *)v2 + 20) = v3;
|
|
1264 }
|
|
1265 if ( *((char *)v2 + 95) && *((char *)v2 + 98) )
|
|
1266 {
|
|
1267 if ( v3 - *((int *)v2 + 21) < 0xFA )
|
|
1268 {
|
|
1269 v10 = *(int *)v5;
|
|
1270 v11 = *(int *)(v5 + 4);
|
|
1271 v15 = 4;
|
|
1272 //v12 = &AsyncMouse::unk::vdtor_ptr;
|
|
1273 v13 = v10;
|
|
1274 v14 = v11;
|
|
1275 v17 = 2;
|
|
1276 AsyncMouse::unk_46BCD2((char *)v2 + 116, (int)&a2, *((int *)v2 + 30), (int)&v12);
|
|
1277 v3 = v16;
|
|
1278 }
|
|
1279 *((int *)v2 + 21) = v3;
|
|
1280 }
|
|
1281 LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);*/
|
|
1282 }
|
|
1283
|
|
1284 //----- (0046B736) --------------------------------------------------------
|
|
1285 void AsyncMouse::_46B736_consume_click_lists(char a2)
|
|
1286 {
|
|
1287 __debugbreak();
|
|
1288 /*
|
|
1289 void *v2; // esi@1
|
|
1290
|
|
1291 v2 = this;
|
|
1292 _46B76F();
|
|
1293 _46B879();
|
|
1294 if ( a2 )
|
|
1295 {
|
|
1296 _46BCAB((char *)v2 + 104);
|
|
1297 _46BCAB((char *)v2 + 116);
|
|
1298 }
|
|
1299 if ( *((char *)v2 + 102) )
|
|
1300 {
|
|
1301 back_to_game();
|
|
1302 *((char *)v2 + 102) = 0;
|
|
1303 }*/
|
|
1304 }
|
|
1305
|
|
1306 //----- (0046B76F) --------------------------------------------------------
|
|
1307 void AsyncMouse::_46B76F()
|
|
1308 {
|
|
1309 __debugbreak();
|
|
1310 /*
|
|
1311 char *v0; // ebx@1
|
|
1312 int v1; // eax@1
|
|
1313 int v2; // edi@1
|
|
1314 int v3; // eax@2
|
|
1315 unsigned int *v4; // esi@2
|
|
1316 unsigned int v5; // ST08_4@7
|
|
1317 unsigned int v6; // ST04_4@7
|
|
1318 float v7; // ST00_4@7
|
|
1319 unsigned int v8; // ST08_4@9
|
|
1320 unsigned int v9; // ST04_4@9
|
|
1321 float v10; // ST00_4@9
|
|
1322
|
|
1323 EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);
|
|
1324 v0 = (char *)pAsyncMouse + 108;
|
|
1325 v1 = *((int *)pAsyncMouse + 27);
|
|
1326 v2 = *(int *)v1;
|
|
1327 if ( *(int *)v1 != v1 )
|
|
1328 {
|
|
1329 do
|
|
1330 {
|
|
1331 v3 = *(int *)(v2 + 20);
|
|
1332 v4 = (unsigned int *)(v2 + 12);
|
|
1333 if ( v3 & 1 )
|
|
1334 {
|
|
1335 pGame->PickMouse(512.0, *v4, *(int *)(v2 + 16), 0, &a3, &a4);
|
|
1336 if ( GetCurrentMenuID() == 6 )
|
|
1337 sub_41CD4F(0x29u);
|
|
1338 UI_OnMouseLeftClick((int *)(v2 + 12));
|
|
1339 }
|
|
1340 else
|
|
1341 {
|
|
1342 if ( v3 & 2 )
|
|
1343 {
|
|
1344 v5 = *(int *)(v2 + 16);
|
|
1345 v6 = *v4;
|
|
1346 v7 = GetPickDepth();
|
|
1347 pGame->PickMouse(v7, v6, v5, 0, &stru_F93E30, &a5);
|
|
1348 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62((Vec2_int_ *)(v2 + 12));
|
|
1349 }
|
|
1350 else
|
|
1351 {
|
|
1352 if ( v3 & 4 )
|
|
1353 {
|
|
1354 v8 = *(int *)(v2 + 16);
|
|
1355 v9 = *v4;
|
|
1356 v10 = GetPickDepth();
|
|
1357 pGame->PickMouse(v10, v9, v8, 1, &a3, &a5);
|
|
1358 }
|
|
1359 }
|
|
1360 }
|
|
1361 v2 = *(int *)v2;
|
|
1362 }
|
|
1363 while ( v2 != *(int *)v0 );
|
|
1364 }
|
|
1365 LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);*/
|
|
1366 }
|
|
1367
|
|
1368 //----- (0046B879) --------------------------------------------------------
|
|
1369 void AsyncMouse::_46B879()
|
|
1370 {
|
|
1371 __debugbreak();
|
|
1372 /*
|
|
1373 char *v0; // ebx@1
|
|
1374 int v1; // eax@1
|
|
1375 int v2; // edi@1
|
|
1376 int v3; // eax@2
|
|
1377 unsigned int *v4; // esi@2
|
|
1378 unsigned int v5; // ST08_4@5
|
|
1379 unsigned int v6; // ST04_4@5
|
|
1380 float v7; // ST00_4@5
|
|
1381
|
|
1382 EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);
|
|
1383 v0 = (char *)pAsyncMouse + 120;
|
|
1384 v1 = *((int *)pAsyncMouse + 30);
|
|
1385 v2 = *(int *)v1;
|
|
1386 if ( *(int *)v1 != v1 )
|
|
1387 {
|
|
1388 do
|
|
1389 {
|
|
1390 v3 = *(int *)(v2 + 20);
|
|
1391 v4 = (unsigned int *)(v2 + 12);
|
|
1392 if ( v3 & 1 )
|
|
1393 {
|
|
1394 pGame->PickMouse(512.0, *v4, *(int *)(v2 + 16), 0, &a3, &a4);
|
|
1395 sub_4178C4();
|
|
1396 }
|
|
1397 else
|
|
1398 {
|
|
1399 if ( v3 & 2 )
|
|
1400 {
|
|
1401 v5 = *(int *)(v2 + 16);
|
|
1402 v6 = *v4;
|
|
1403 v7 = GetPickDepth();
|
|
1404 pGame->PickMouse(v7, v6, v5, 0, &stru_F93E30, &a4);
|
|
1405 sub_4178E1();
|
|
1406 }
|
|
1407 else
|
|
1408 {
|
|
1409 if ( v3 & 4 )
|
|
1410 nullsub_1();
|
|
1411 }
|
|
1412 }
|
|
1413 v2 = *(int *)v2;
|
|
1414 }
|
|
1415 while ( v2 != *(int *)v0 );
|
|
1416 }
|
|
1417 LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);*/
|
|
1418 }
|
|
1419
|
|
1420 //----- (0046B944) --------------------------------------------------------
|
|
1421 int AsyncMouse::_46B944()
|
|
1422 {
|
|
1423 __debugbreak();
|
|
1424 /*
|
|
1425 void *v1; // esi@1
|
|
1426
|
|
1427 v1 = this;
|
|
1428 _46BCAB((char *)this + 104);
|
|
1429 return _46BCAB((char *)v1 + 116);*/
|
|
1430 return 0;
|
|
1431 }
|
|
1432 // 46BCAB: using guessed type int __thiscall AsyncMouse__46BCAB(int);
|
|
1433
|
|
1434 //----- (0046B958) --------------------------------------------------------
|
|
1435 char AsyncMouse::_46B958(int a2, int a3)
|
|
1436 {
|
|
1437 __debugbreak();
|
|
1438 /*
|
|
1439 void *v3; // esi@1
|
|
1440 char result; // al@3
|
|
1441 int v5; // edx@6
|
|
1442 int v6; // eax@6
|
|
1443 int v7; // eax@12
|
|
1444 int v8; // edi@13
|
|
1445 int v9; // eax@19
|
|
1446 struct IDirectDrawSurface4 *v10; // ST08_4@21
|
|
1447 DDBLTFX v11; // [sp+4h] [bp-74h]@21
|
|
1448 RECT v12; // [sp+68h] [bp-10h]@19
|
|
1449
|
|
1450 v3 = this;
|
|
1451 if ( pRenderer->pFrontBuffer4 && !pRenderer->pFrontBuffer4->IsLost() )
|
|
1452 {
|
|
1453 EnterCriticalSection(&pGame->pThreadWardInstance->cs2);
|
|
1454 if ( *((char *)v3 + 88) )
|
|
1455 pRenderer->pFrontBuffer4->BltFast(
|
|
1456 *((int *)v3 + 8),
|
|
1457 *((int *)v3 + 9),
|
|
1458 (LPDIRECTDRAWSURFACE4)*((int *)v3 + 2),
|
|
1459 (LPRECT)((char *)v3 + 48),
|
|
1460 16u);
|
|
1461 v5 = 640 - a2;
|
|
1462 v6 = 640 - a2;
|
|
1463 if ( 640 - a2 >= 31 )
|
|
1464 v6 = 31;
|
|
1465 if ( v6 >= 0 )
|
|
1466 {
|
|
1467 if ( v5 >= 31 )
|
|
1468 v5 = 31;
|
|
1469 }
|
|
1470 else
|
|
1471 {
|
|
1472 v5 = 0;
|
|
1473 }
|
|
1474 v7 = 480 - a3;
|
|
1475 if ( 480 - a3 >= 31 )
|
|
1476 v8 = 31;
|
|
1477 else
|
|
1478 v8 = 480 - a3;
|
|
1479 if ( v8 >= 0 )
|
|
1480 {
|
|
1481 if ( v7 >= 31 )
|
|
1482 v7 = 31;
|
|
1483 }
|
|
1484 else
|
|
1485 {
|
|
1486 v7 = 0;
|
|
1487 }
|
|
1488 *((int *)v3 + 13) = 0;
|
|
1489 *((int *)v3 + 14) = v5;
|
|
1490 v12.right = a2 + v5;
|
|
1491 *((int *)v3 + 12) = 0;
|
|
1492 *((int *)v3 + 15) = v7;
|
|
1493 v12.left = a2;
|
|
1494 v12.bottom = a3 + v7;
|
|
1495 v9 = *((int *)v3 + 2);
|
|
1496 v12.top = a3;
|
|
1497 (*(void (__stdcall **)(int, int, int, IDirectDrawSurface4 *, RECT *, signed int))(*(int *)v9 + 28))(
|
|
1498 v9,
|
|
1499 0,
|
|
1500 0,
|
|
1501 pRenderer->pFrontBuffer4,
|
|
1502 &v12,
|
|
1503 16);
|
|
1504 if ( !*((char *)v3 + 90) || *((char *)v3 + 128) & 1 )
|
|
1505 {
|
|
1506 v10 = (struct IDirectDrawSurface4 *)*((int *)v3 + 1);
|
|
1507 v11.dwSize = 100;
|
|
1508 v11.dwDDFX = 8;
|
|
1509 pRenderer->pFrontBuffer4->Blt(
|
|
1510 &v12,
|
|
1511 v10,
|
|
1512 (LPRECT)((char *)v3 + 48),
|
|
1513 16812032u,
|
|
1514 &v11);
|
|
1515 }
|
|
1516 *((char *)v3 + 88) = 1;
|
|
1517 LeaveCriticalSection(&pGame->pThreadWardInstance->cs2);
|
|
1518 result = 1;
|
|
1519 }
|
|
1520 else
|
|
1521 {
|
|
1522 result = 0;
|
|
1523 }
|
|
1524 return result;*/
|
|
1525 return 0;
|
|
1526 }
|
|
1527
|
|
1528 //----- (0046BA8D) --------------------------------------------------------
|
|
1529 char AsyncMouse::_46BA8D(int a2, int a3)
|
|
1530 {
|
|
1531 __debugbreak();
|
|
1532 /*
|
|
1533 void *v3; // esi@1
|
|
1534 DWORD v4; // eax@1
|
|
1535
|
|
1536 v3 = this;
|
|
1537 v4 = timeGetTime();
|
|
1538 if ( v4 - *((int *)v3 + 16) <= 0x32 )
|
|
1539 {
|
|
1540 *((char *)v3 + 91) = *((char *)v3 + 90) == 1;
|
|
1541 *((char *)v3 + 90) = 0;
|
|
1542 }
|
|
1543 else
|
|
1544 {
|
|
1545 if ( *((char *)v3 + 90) )
|
|
1546 *((char *)v3 + 91) = 0;
|
|
1547 else
|
|
1548 *((char *)v3 + 91) = 1;
|
|
1549 *((char *)v3 + 90) = 1;
|
|
1550 }
|
|
1551 if ( a2 != *((int *)v3 + 17) || a3 != *((int *)v3 + 18) )
|
|
1552 {
|
|
1553 *((int *)v3 + 16) = v4;
|
|
1554 *((int *)v3 + 17) = a2;
|
|
1555 *((int *)v3 + 18) = a3;
|
|
1556 }
|
|
1557 return *((char *)v3 + 90);*/
|
|
1558 return 0;
|
|
1559 }
|
|
1560
|
|
1561 //----- (0046BAEC) --------------------------------------------------------
|
|
1562 void AsyncMouse::_46BAEC()
|
|
1563 {
|
|
1564 void *v1; // esi@1
|
|
1565
|
|
1566 v1 = this;
|
|
1567 EnterCriticalSection(&pGame->pThreadWardInstance->cs2);
|
|
1568 *((char *)v1 + 88) = 0;
|
|
1569 }
|
|
1570
|
|
1571 //----- (0046BB0A) --------------------------------------------------------
|
|
1572 void AsyncMouse::_46BB0A()
|
|
1573 {
|
|
1574 __debugbreak();
|
|
1575 /*
|
|
1576 void *v1; // esi@1
|
|
1577 int v2; // eax@1
|
|
1578 int v3; // edx@1
|
|
1579 int v4; // ecx@1
|
|
1580 int v5; // edx@1
|
|
1581 int v6; // eax@1
|
|
1582 char v7; // zf@1
|
|
1583 struct IDirectDrawSurface4 *v8; // ST08_4@8
|
|
1584 int v9; // [sp+8h] [bp-74h]@8
|
|
1585 int v10; // [sp+Ch] [bp-70h]@8
|
|
1586 int v11; // [sp+6Ch] [bp-10h]@1
|
|
1587 int v12; // [sp+70h] [bp-Ch]@1
|
|
1588 int v13; // [sp+74h] [bp-8h]@1
|
|
1589 int v14; // [sp+78h] [bp-4h]@1
|
|
1590
|
|
1591 v1 = this;
|
|
1592 v2 = *((int *)this + 17) - *((int *)this + 10);
|
|
1593 v3 = *((int *)this + 14);
|
|
1594 v4 = *((int *)this + 18) - *((int *)this + 11);
|
|
1595 v11 = v2;
|
|
1596 v5 = v2 + v3;
|
|
1597 v6 = *((int *)v1 + 15);
|
|
1598 v12 = v4;
|
|
1599 v7 = *((char *)v1 + 90) == 0;
|
|
1600 v13 = v5;
|
|
1601 v14 = v4 + v6;
|
|
1602 if ( v7 || *((char *)v1 + 128) & 1 )
|
|
1603 {
|
|
1604 if ( *((char *)v1 + 88) )
|
|
1605 pRenderer->pFrontBuffer4->BltFast(
|
|
1606 *((int *)v1 + 8),
|
|
1607 *((int *)v1 + 9),
|
|
1608 (LPDIRECTDRAWSURFACE4)*((int *)v1 + 2),
|
|
1609 (LPRECT)((char *)v1 + 48),
|
|
1610 16u);
|
|
1611 (*(void (__stdcall **)(int, int, int, IDirectDrawSurface4 *, int *, signed int))(**((int **)v1 + 2) + 28))(
|
|
1612 *((int *)v1 + 2),
|
|
1613 0,
|
|
1614 0,
|
|
1615 pRenderer->pFrontBuffer4,
|
|
1616 &v11,
|
|
1617 16);
|
|
1618 }
|
|
1619 if ( *((char *)v1 + 90) && !(*((char *)v1 + 128) & 1) )
|
|
1620 {
|
|
1621 v8 = (struct IDirectDrawSurface4 *)*((int *)v1 + 1);
|
|
1622 v9 = 100;
|
|
1623 v10 = 8;
|
|
1624 pRenderer->pFrontBuffer4->Blt(
|
|
1625 (LPRECT)&v11,
|
|
1626 v8,
|
|
1627 (LPRECT)((char *)v1 + 48),
|
|
1628 16812032u,
|
|
1629 (LPDDBLTFX)&v9);
|
|
1630 }
|
|
1631 LeaveCriticalSection(&pGame->pThreadWardInstance->cs2);*/
|
|
1632 }
|
|
1633
|
|
1634 //----- (0046BBD0) --------------------------------------------------------
|
|
1635 void *AsyncMouse::Clip()
|
|
1636 {
|
|
1637 __debugbreak();
|
|
1638 /*
|
|
1639 void *result; // eax@1
|
|
1640 std::string v1; // [sp-18h] [bp-30h]@2
|
|
1641 const char *v2; // [sp-8h] [bp-20h]@2
|
|
1642 int v3; // [sp-4h] [bp-1Ch]@2
|
|
1643 RECT Rect; // [sp+0h] [bp-18h]@1
|
|
1644 std::string *v5; // [sp+10h] [bp-8h]@2
|
|
1645 int a3; // [sp+17h] [bp-1h]@2
|
|
1646
|
|
1647 SetWindowPos(hWnd, HWND_MESSAGE|0x2, 320, 240, 640, 480, 0);
|
|
1648 Rect.left = 325;
|
|
1649 Rect.top = 245;
|
|
1650 Rect.right = 326;
|
|
1651 Rect.bottom = 246;
|
|
1652 result = (void *)ClipCursor(&Rect);
|
|
1653 if ( !result )
|
|
1654 {
|
|
1655 MessageBoxW(nullptr, L"Could not clip cursor to screen!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:827", 0);
|
|
1656 }
|
|
1657 return result;*/
|
|
1658 return 0;
|
|
1659 }
|
|
1660
|
|
1661 //----- (0046BC4E) --------------------------------------------------------
|
|
1662 void __stdcall AsyncMouse::AsyncMouseThread(int a1)
|
|
1663 {
|
|
1664 __debugbreak();
|
|
1665 /*
|
|
1666 while ( 1 )
|
|
1667 {
|
|
1668 while ( !pAsyncMouse )
|
|
1669 Sleep(1);
|
|
1670 if ( !AsyncMouse::Thread(pAsyncMouse) )
|
|
1671 ExitThread(0);
|
|
1672 Sleep(18);
|
|
1673 }*/
|
|
1674 }
|
|
1675
|
|
1676 //----- (0046BC73) --------------------------------------------------------
|
|
1677 void AsyncMouse::dtor_sub_46BC73()
|
|
1678 {
|
|
1679 __debugbreak();
|
|
1680 /*
|
|
1681 int v1; // edi@1
|
|
1682 void **v2; // ebx@1
|
|
1683 void *v3; // esi@1
|
|
1684 void *v4; // eax@2
|
|
1685 int v5; // [sp+0h] [bp-4h]@1
|
|
1686
|
|
1687 v5 = this;
|
|
1688 v1 = this;
|
|
1689 v2 = *(void ***)(this + 4);
|
|
1690 v3 = *v2;
|
|
1691 while ( v3 != v2 )
|
|
1692 {
|
|
1693 v4 = v3;
|
|
1694 v3 = *(void **)v3;
|
|
1695 AsyncMouse::unk_46BD2D((void *)v1, (int)&v5, v4);
|
|
1696 }
|
|
1697 free(*(void **)(v1 + 4));
|
|
1698 *(int *)(v1 + 4) = 0;
|
|
1699 *(int *)(v1 + 8) = 0;*/
|
|
1700 }
|
|
1701
|
|
1702 //----- (0046BCAB) --------------------------------------------------------
|
|
1703 int AsyncMouse::_46BCAB()
|
|
1704 {
|
|
1705 __debugbreak();
|
|
1706 /*
|
|
1707 void *v1; // ebx@1
|
|
1708 void **v2; // edi@1
|
|
1709 void *v3; // esi@1
|
|
1710 void *v4; // eax@2
|
|
1711 int result; // eax@2
|
|
1712 int v6; // [sp+0h] [bp-4h]@1
|
|
1713
|
|
1714 v6 = this;
|
|
1715 v1 = (void *)this;
|
|
1716 v2 = *(void ***)(this + 4);
|
|
1717 v3 = *v2;
|
|
1718 while ( v3 != v2 )
|
|
1719 {
|
|
1720 v4 = v3;
|
|
1721 v3 = *(void **)v3;
|
|
1722 result = AsyncMouse::unk_46BD2D(v1, (int)&v6, v4);
|
|
1723 }
|
|
1724 return result;*/
|
|
1725 return 0;
|
|
1726 }
|
|
1727 // 46BCAB: using guessed type int __thiscall AsyncMouse__46BCAB(int);
|
|
1728
|
|
1729 //----- (0046BCD2) --------------------------------------------------------
|
|
1730 int AsyncMouse::unk_46BCD2(int a2, int a3, int a4)
|
|
1731 {
|
|
1732 __debugbreak();
|
|
1733 /*
|
|
1734 void *v4; // edi@1
|
|
1735 void *v5; // eax@1
|
|
1736 void *v6; // esi@1
|
|
1737 int result; // eax@1
|
|
1738
|
|
1739 v4 = this;
|
|
1740 v5 = AsyncMouse::unk_46BD09((void *)a3, *(void **)(a3 + 4));
|
|
1741 v6 = v5;
|
|
1742 *(int *)(a3 + 4) = v5;
|
|
1743 **((int **)v5 + 1) = v5;
|
|
1744 AsyncMouse::unk_46BD66((char *)v5 + 8, a4);
|
|
1745 result = a2;
|
|
1746 ++*((int *)v4 + 2);
|
|
1747 *(int *)a2 = v6;
|
|
1748 return result;*/
|
|
1749 return 0;
|
|
1750 }
|
|
1751 // 46BD66: using guessed type int __fastcall AsyncMouse__unk__46BD66(int, int);
|
|
1752
|
|
1753 //----- (0046BD09) --------------------------------------------------------
|
|
1754 void *AsyncMouse::unk_46BD09(void *a1, void *a2)
|
|
1755 {
|
|
1756 __debugbreak();
|
|
1757 /*
|
|
1758 void *result; // eax@1
|
|
1759 void *v3; // ecx@1
|
|
1760 void *v4; // ecx@3
|
|
1761
|
|
1762 result = operator new(0x18u);
|
|
1763 v3 = a1;
|
|
1764 if ( !a1 )
|
|
1765 v3 = result;
|
|
1766 *(int *)result = v3;
|
|
1767 v4 = a2;
|
|
1768 if ( !a2 )
|
|
1769 v4 = result;
|
|
1770 *((int *)result + 1) = v4;
|
|
1771 return result;*/
|
|
1772 return 0;
|
|
1773 }
|
|
1774
|
|
1775 //----- (0046BD2D) --------------------------------------------------------
|
|
1776 int AsyncMouse::unk_46BD2D(int a2, void *a3)
|
|
1777 {
|
|
1778 __debugbreak();
|
|
1779 /*
|
|
1780 void *v3; // edi@1
|
|
1781 int v4; // ebx@1
|
|
1782 int result; // eax@1
|
|
1783
|
|
1784 v3 = this;
|
|
1785 v4 = *(int *)a3;
|
|
1786 **((int **)a3 + 1) = *(int *)a3;
|
|
1787 *(int *)(*(int *)a3 + 4) = *((int *)a3 + 1);
|
|
1788 (**((void (__stdcall ***)(int))a3 + 2))(0);
|
|
1789 free(a3);
|
|
1790 result = a2;
|
|
1791 --*((int *)v3 + 2);
|
|
1792 *(int *)a2 = v4;
|
|
1793 return result;*/
|
|
1794 return 0;
|
|
1795 }
|
|
1796
|
|
1797 //----- (0046BD66) --------------------------------------------------------
|
|
1798 int AsyncMouse::unk_46BD66(int a1, int a2)
|
|
1799 {
|
|
1800 int result; // eax@2
|
|
1801
|
|
1802 if ( a1 )
|
|
1803 {
|
|
1804 *(int *)(a1 + 4) = *(int *)(a2 + 4);
|
|
1805 *(int *)(a1 + 8) = *(int *)(a2 + 8);
|
|
1806 result = *(int *)(a2 + 12);
|
|
1807 *(int *)(a1 + 12) = result;
|
|
1808 //*(int *)a1 = &AsyncMouse::unk::vdtor_ptr;
|
|
1809 }
|
|
1810 return result;
|
|
1811 }
|
|
1812 // 46BD66: using guessed type int __fastcall AsyncMouse__unk__46BD66(int, int);
|
|
1813 // 4D8734: using guessed type int (__stdcall *AsyncMouse__unk__vdtor_ptr)(char);
|
|
1814
|
|
1815
|
|
1816
|
|
1817
|
|
1818
|
|
1819
|
|
1820
|
|
1821
|
|
1822
|
|
1823
|
|
1824
|
|
1825
|
|
1826
|
|
1827
|
|
1828
|
|
1829
|
|
1830
|
|
1831
|
|
1832
|
|
1833 /*
|
|
1834 //----- (0043B9FF) --------------------------------------------------------
|
|
1835 DirectInputMouse *__thiscall DirectInputMouse::DirectInputMouse(DirectInputMouse *this)
|
|
1836 {
|
|
1837 DirectInputMouse *v1; // esi@1
|
|
1838 HRESULT v2; // eax@5
|
|
1839 signed int v4; // [sp-18h] [bp-24h]@3
|
|
1840 char *v5; // [sp-14h] [bp-20h]@3
|
|
1841 int v6; // [sp-10h] [bp-1Ch]@3
|
|
1842 const char *v7; // [sp-Ch] [bp-18h]@3
|
|
1843 int v8; // [sp-8h] [bp-14h]@3
|
|
1844 unsigned int v9; // [sp-4h] [bp-10h]@3
|
|
1845 CheckHRESULT_stru0 v10; // [sp+8h] [bp-4h]@5
|
|
1846
|
|
1847 v1 = this;
|
|
1848 this->field_8 = 0;
|
|
1849 LOBYTE(this->field_1C) = 0;
|
|
1850 this->field_28 = 0;
|
|
1851 this->vdestructor_ptr = (int)&DirectInputMouse_pvdtor;
|
|
1852 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
|
|
1853 {
|
|
1854 v9 = 1;
|
|
1855 v8 = 30;
|
|
1856 v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp";
|
|
1857 v6 = 0;
|
|
1858 v5 = (char *)&this->pDirectInput;
|
|
1859 v4 = 1280;
|
|
1860 }
|
|
1861 else
|
|
1862 {
|
|
1863 v9 = 1;
|
|
1864 v8 = 28;
|
|
1865 v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp";
|
|
1866 v6 = 0;
|
|
1867 v5 = (char *)&this->pDirectInput;
|
|
1868 v4 = 768;
|
|
1869 }
|
|
1870 v2 = DirectInputCreateA(hInstance, v4, v5, v6);
|
|
1871 CheckHRESULT(&v10, v2, v7, v8, v9);
|
|
1872 DirectInputMouse::CreateDevice(v1);
|
|
1873 DirectInputMouse::43BB18(v1);
|
|
1874 v1->field_20 = 0;
|
|
1875 v1->field_24 = 0;
|
|
1876 return v1;
|
|
1877 }
|
|
1878 // 4C8880: using guessed type int __stdcall DirectInputCreateA(int, int, int, int);
|
|
1879 // 4D8608: using guessed type int (__stdcall *DirectInputMouse_pvdtor)(char);
|
|
1880
|
|
1881 //----- (0043BA80) --------------------------------------------------------
|
|
1882 void *__thiscall DirectInputMouse::vdtor(void *this, bool a2)
|
|
1883 {
|
|
1884 void *v2; // esi@1
|
|
1885
|
|
1886 v2 = this;
|
|
1887 DirectInputMouse::dtor(this);
|
|
1888 if ( a2 & 1 )
|
|
1889 free(v2);
|
|
1890 return v2;
|
|
1891 }
|
|
1892
|
|
1893 //----- (0043BA9C) --------------------------------------------------------
|
|
1894 int __thiscall DirectInputMouse::dtor(void *this)
|
|
1895 {
|
|
1896 void *v1; // esi@1
|
|
1897 int v2; // eax@1
|
|
1898 int result; // eax@3
|
|
1899
|
|
1900 v1 = this;
|
|
1901 v2 = *((int *)this + 2);
|
|
1902 *(int *)this = &DirectInputMouse_pvdtor;
|
|
1903 if ( v2 )
|
|
1904 {
|
|
1905 (*(void (__stdcall **)(int))(*(int *)v2 + 32))(v2);
|
|
1906 (*(void (__stdcall **)(int))(**((int **)v1 + 2) + 8))(*((int *)v1 + 2));
|
|
1907 *((int *)v1 + 2) = 0;
|
|
1908 }
|
|
1909 result = (*(int (__stdcall **)(int))(**((int **)v1 + 1) + 8))(*((int *)v1 + 1));
|
|
1910 *((int *)v1 + 1) = 0;
|
|
1911 return result;
|
|
1912 }
|
|
1913 // 4D8608: using guessed type int (__stdcall *DirectInputMouse_pvdtor)(char);
|
|
1914
|
|
1915 //----- (0043BACE) --------------------------------------------------------
|
|
1916 void __thiscall DirectInputMouse::CreateDevice(DirectInputMouse *this)
|
|
1917 {
|
|
1918 DirectInputMouse *v1; // esi@1
|
|
1919 HRESULT v2; // eax@1
|
|
1920 CheckHRESULT_stru0 v3; // [sp+4h] [bp-4h]@1
|
|
1921
|
|
1922 v1 = this;
|
|
1923 v2 = ((int (__stdcall *)(int, int, int, int, int))this->pDirectInput->lpVtbl->field_10)(
|
|
1924 this->pDirectInput,
|
|
1925 2,
|
|
1926 DirectInputMouse_enumerator,
|
|
1927 this,
|
|
1928 1);
|
|
1929 CheckHRESULT(&v3, v2, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp", 57, 1u);
|
|
1930 if ( !LOBYTE(v1->field_1C) )
|
|
1931 {
|
|
1932 v3.vdestructor_ptr = (void (__thiscall ***)(CheckHRESULT_stru0 *, bool))"Error: No mouse found";
|
|
1933 _CxxThrowException((int)&v3, (int)&dword_4DBD94);
|
|
1934 }
|
|
1935 }
|
|
1936 // 43BC61: using guessed type int __stdcall DirectInputMouse_enumerator(int, int);
|
|
1937 // 4DBD94: using guessed type int dword_4DBD94;
|
|
1938
|
|
1939 //----- (0043BB18) --------------------------------------------------------
|
|
1940 int __thiscall DirectInputMouse::43BB18(DirectInputMouse *this)
|
|
1941 {
|
|
1942 char *v1; // esi@1
|
|
1943 HRESULT v2; // eax@1
|
|
1944 HRESULT v3; // eax@1
|
|
1945 HRESULT v4; // eax@1
|
|
1946 unsigned int v6; // [sp+0h] [bp-Ch]@0
|
|
1947 CheckHRESULT_stru0 v7; // [sp+8h] [bp-4h]@1
|
|
1948
|
|
1949 v1 = (char *)&this->field_8;
|
|
1950 v2 = ((int (__stdcall *)(int, int, int, int, int))this->pDirectInput->lpVtbl->field_C)(
|
|
1951 this->pDirectInput,
|
|
1952 &this->field_C,
|
|
1953 &this->field_8,
|
|
1954 0,
|
|
1955 "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp");
|
|
1956 CheckHRESULT(&v7, v2, (const char *)0x40, 1, v6);
|
|
1957 v3 = (*(int (__stdcall **)(int, int))(**(int **)v1 + 44))(*(int *)v1, dword_4C9920);
|
|
1958 CheckHRESULT(&v7, v3, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp", 65, 1u);
|
|
1959 v4 = (*(int (__stdcall **)(int, int, int))(**(int **)v1 + 52))(*(int *)v1, hWnd, 6);
|
|
1960 CheckHRESULT(&v7, v4, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp", 66, 1u);
|
|
1961 return (*(int (__cdecl **)(int))(**(int **)v1 + 28))(*(int *)v1);
|
|
1962 }
|
|
1963 // 4C9920: using guessed type int dword_4C9920[16];
|
|
1964
|
|
1965 //----- (0043BB89) --------------------------------------------------------
|
|
1966 bool __thiscall DirectInputMouse::43BB89(DirectInputMouse *this)
|
|
1967 {
|
|
1968 DirectInputMouse *v1; // esi@1
|
|
1969 bool result; // eax@1
|
|
1970 HRESULT v3; // eax@5
|
|
1971 __int32 v4; // ecx@6
|
|
1972 __int32 v5; // eax@6
|
|
1973 __int32 v6; // edx@6
|
|
1974 int v7; // ecx@12
|
|
1975 bool v8; // ecx@12
|
|
1976 signed int v9; // edx@12
|
|
1977 HRESULT a2; // [sp+4h] [bp-14h]@3
|
|
1978 int v11; // [sp+8h] [bp-10h]@12
|
|
1979 char v12; // [sp+10h] [bp-8h]@18
|
|
1980 char v13; // [sp+11h] [bp-7h]@20
|
|
1981 char v14; // [sp+12h] [bp-6h]@22
|
|
1982 char v15; // [sp+13h] [bp-5h]@24
|
|
1983 char v18; // [sp+14h] [bp-4h]@5
|
|
1984
|
|
1985 v1 = this;
|
|
1986 result = this->field_8;
|
|
1987 if ( result )
|
|
1988 {
|
|
1989 if ( (*(int (__stdcall **)(bool, signed int, HRESULT *))(*(int *)result + 36))(result, 16, &a2) == -2147024866
|
|
1990 && !(*(int (__stdcall **)(int))(*(int *)v1->field_8 + 28))(v1->field_8) )
|
|
1991 {
|
|
1992 v3 = (*(int (__stdcall **)(int, signed int, HRESULT *))(*(int *)v1->field_8 + 36))(v1->field_8, 16, &a2);
|
|
1993 CheckHRESULT((CheckHRESULT_stru0 *)&v18, v3, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\DirectInputMouse.cpp", 80, 1u);
|
|
1994 }
|
|
1995 v4 = v1->field_20 + a2;
|
|
1996 v5 = 640;
|
|
1997 v6 = v1->field_20 + a2;
|
|
1998 if ( v4 >= 640 )
|
|
1999 v6 = 640;
|
|
2000 if ( v6 >= 0 )
|
|
2001 {
|
|
2002 if ( v4 < 640 )
|
|
2003 v5 = v1->field_20 + a2;
|
|
2004 }
|
|
2005 else
|
|
2006 {
|
|
2007 v5 = 0;
|
|
2008 }
|
|
2009 v7 = v11;
|
|
2010 v1->field_20 = v5;
|
|
2011 v8 = v1->field_24 + v7;
|
|
2012 result = 480;
|
|
2013 v9 = v8;
|
|
2014 if ( v8 >= 480 )
|
|
2015 v9 = 480;
|
|
2016 if ( v9 >= 0 )
|
|
2017 {
|
|
2018 if ( v8 < 480 )
|
|
2019 result = v8;
|
|
2020 }
|
|
2021 else
|
|
2022 {
|
|
2023 result = 0;
|
|
2024 }
|
|
2025 v1->field_28 = 0;
|
|
2026 v1->field_24 = result;
|
|
2027 if ( v12 & 0x80 )
|
|
2028 v1->field_28 = 1;
|
|
2029 if ( v13 & 0x80 )
|
|
2030 v1->field_28 |= 2u;
|
|
2031 if ( v14 & 0x80 )
|
|
2032 v1->field_28 |= 4u;
|
|
2033 if ( v15 & 0x80 )
|
|
2034 v1->field_28 |= 8u;
|
|
2035 LOBYTE(result) = 1;
|
|
2036 }
|
|
2037 else
|
|
2038 {
|
|
2039 LOBYTE(result) = 0;
|
|
2040 }
|
|
2041 return result;
|
|
2042 }
|
|
2043
|
|
2044 //----- (0043BC61) --------------------------------------------------------
|
|
2045 signed int __stdcall DirectInputMouse_enumerator(int a1, int a2)
|
|
2046 {
|
|
2047 signed int result; // eax@2
|
|
2048
|
|
2049 if ( *(char *)(a1 + 36) & 2 )
|
|
2050 {
|
|
2051 *(int *)(a2 + 12) = *(int *)(a1 + 4);
|
|
2052 *(int *)(a2 + 16) = *(int *)(a1 + 8);
|
|
2053 *(int *)(a2 + 20) = *(int *)(a1 + 12);
|
|
2054 *(int *)(a2 + 24) = *(int *)(a1 + 16);
|
|
2055 *(char *)(a2 + 28) = 1;
|
|
2056 result = 0;
|
|
2057 }
|
|
2058 else
|
|
2059 {
|
|
2060 result = 1;
|
|
2061 }
|
|
2062 return result;
|
|
2063 }
|
|
2064 // 43BC61: using guessed type int __stdcall DirectInputMouse_enumerator(int, int);
|
|
2065 */ |