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