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