comparison Mouse.cpp @ 1048:d36681a9e4f8

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