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