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