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