DXGL r810 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r809‎ | r810 | r811 >
Date:00:44, 12 May 2018
Author:admin
Status:new
Tags:
Comment:
Log last 8 mouse messages in mouse pointer test.
Fix resource leak in mouse pointer test.
Fix several compiler warnings in cfgmgr.c
Modified paths:
  • /cfgmgr/cfgmgr.c (modified) (history)
  • /dxglcfg/dxgltest.cpp (modified) (history)
  • /dxglcfg/tests.cpp (modified) (history)

Diff [purge]

Index: cfgmgr/cfgmgr.c
@@ -406,7 +406,7 @@
407407 {
408408 LPCTSTR obsolete;
409409 va_list va;
410 - int i;
 410+ unsigned int i;
411411 DWORD dwOut;
412412 DWORD sizeout = 4;
413413 DWORD regdword = REG_DWORD;
@@ -532,7 +532,7 @@
533533 {
534534 LPCTSTR obsolete;
535535 va_list va;
536 - int i;
 536+ unsigned int i;
537537 float dwOut;
538538 DWORD sizeout = 4;
539539 DWORD regdword = REG_DWORD;
@@ -699,7 +699,7 @@
700700 {
701701 LPCTSTR obsolete;
702702 va_list va;
703 - int i;
 703+ unsigned int i;
704704 va_start(va, obsolete_count);
705705 for (i = 0; i < obsolete_count; i++)
706706 {
@@ -727,7 +727,7 @@
728728 {
729729 LPCTSTR obsolete;
730730 va_list va;
731 - int i;
 731+ unsigned int i;
732732 va_start(va, obsolete_count);
733733 for (i = 0; i < obsolete_count; i++)
734734 {
@@ -833,7 +833,6 @@
834834 TCHAR sha256string[65];
835835 TCHAR regkey[MAX_PATH + 80];
836836 TCHAR filename[MAX_PATH + 1];
837 - TCHAR pathlwr[MAX_PATH + 1];
838837 HKEY hKey;
839838 LONG error;
840839 int i;
@@ -962,7 +961,7 @@
963962 float INIAspectValue(const char *value)
964963 {
965964 char *ptr;
966 - float numerator, denominator;
 965+ double numerator, denominator;
967966 if (!strcmp(value, "Default")) return 0.0f;
968967 else
969968 {
@@ -973,9 +972,9 @@
974973 *ptr = 0;
975974 numerator = atof(value);
976975 denominator = atof(ptr + 1);
977 - return numerator / denominator;
 976+ return (float)(numerator / denominator);
978977 }
979 - else return atof(value);
 978+ else return (float)atof(value);
980979 }
981980 }
982981
@@ -987,17 +986,20 @@
988987 int ReadINICallback(DXGLCFG *cfg, const char *section, const char *name,
989988 const char *value)
990989 {
991 - if (!stricmp(section, "system"))
 990+#ifdef _UNICODE
 991+ TCHAR unicode_path[MAX_PATH + 1];
 992+#endif
 993+ if (!_stricmp(section, "system"))
992994 {
993 - if (!stricmp(name, "NoWriteRegistry")) cfg->NoWriteRegistry = INIBoolValue(value);
994 - if (!stricmp(name, "OverrideDefaults")) cfg->OverrideDefaults = INIBoolValue(value);
 995+ if (!_stricmp(name, "NoWriteRegistry")) cfg->NoWriteRegistry = INIBoolValue(value);
 996+ if (!_stricmp(name, "OverrideDefaults")) cfg->OverrideDefaults = INIBoolValue(value);
995997 }
996 - if (!stricmp(section, "display"))
 998+ if (!_stricmp(section, "display"))
997999 {
998 - if (!stricmp(name, "ScalingMode")) cfg->scaler = INIIntValue(value);
999 - if (!stricmp(name, "FullscreenWindowMode")) cfg->fullmode = INIIntValue(value);
1000 - if (!stricmp(name, "ChangeColorDepth")) cfg->colormode = INIBoolValue(value);
1001 - if (!stricmp(name, "AllColorDepths"))
 1000+ if (!_stricmp(name, "ScalingMode")) cfg->scaler = INIIntValue(value);
 1001+ if (!_stricmp(name, "FullscreenWindowMode")) cfg->fullmode = INIIntValue(value);
 1002+ if (!_stricmp(name, "ChangeColorDepth")) cfg->colormode = INIBoolValue(value);
 1003+ if (!_stricmp(name, "AllColorDepths"))
10021004 {
10031005 if (!cfg->ParsedAddColorDepths)
10041006 {
@@ -1005,12 +1007,12 @@
10061008 else cfg->AddColorDepths = 0;
10071009 }
10081010 }
1009 - if (!stricmp(name, "AddColorDepths"))
 1011+ if (!_stricmp(name, "AddColorDepths"))
10101012 {
10111013 cfg->ParsedAddColorDepths = TRUE;
10121014 cfg->AddColorDepths = INIIntValue(value);
10131015 }
1014 - if (!stricmp(name, "ExtraModes"))
 1016+ if (!_stricmp(name, "ExtraModes"))
10151017 {
10161018 if (!cfg->ParsedAddModes)
10171019 {
@@ -1018,85 +1020,93 @@
10191021 else cfg->AddModes = 0;
10201022 }
10211023 }
1022 - if (!stricmp(name, "AddModes"))
 1024+ if (!_stricmp(name, "AddModes"))
10231025 {
10241026 cfg->ParsedAddModes = TRUE;
10251027 cfg->AddModes = INIIntValue(value);
10261028 }
1027 - if (!stricmp(name, "SortModes")) cfg->SortModes = INIIntValue(value);
 1029+ if (!_stricmp(name, "SortModes")) cfg->SortModes = INIIntValue(value);
10281030 }
1029 - if (!stricmp(section, "scaling"))
 1031+ if (!_stricmp(section, "scaling"))
10301032 {
1031 - if (!stricmp(name, "ScalingFilter")) cfg->scalingfilter = INIIntValue(value);
1032 - if (!stricmp(name, "BltScale")) cfg->BltScale = INIIntValue(value);
 1033+ if (!_stricmp(name, "ScalingFilter")) cfg->scalingfilter = INIIntValue(value);
 1034+ if (!_stricmp(name, "BltScale")) cfg->BltScale = INIIntValue(value);
10331035 // Removed for DXGL 0.5.13 release
1034 - // if (!stricmp(name, "BltThreshold")) cfg->BltThreshold = INIIntValue(value);
1035 - if (!stricmp(name, "AdjustPrimaryResolution")) cfg->primaryscale = INIIntValue(value);
1036 - if (!stricmp(name, "PrimaryScaleX")) cfg->primaryscalex = INIFloatValue(value);
1037 - if (!stricmp(name, "PrimaryScaleY")) cfg->primaryscaley = INIFloatValue(value);
1038 - if (!stricmp(name, "ScreenAspect")) cfg->aspect = INIAspectValue(value);
1039 - if (!stricmp(name, "DPIScale")) cfg->DPIScale = INIIntValue(value);
1040 - if (!stricmp(name, "CustomResolutionX")) cfg->CustomResolutionX = INIIntValue(value);
1041 - if (!stricmp(name, "CustomResolutionY")) cfg->CustomResolutionY = INIIntValue(value);
1042 - if (!stricmp(name, "CustomRefresh")) cfg->CustomRefresh = INIIntValue(value);
1043 - if (!stricmp(name, "DisplayMultiplierX")) cfg->DisplayMultiplierX = INIFloatValue(value);
1044 - if (!stricmp(name, "DisplayMultiplierY")) cfg->DisplayMultiplierY = INIFloatValue(value);
 1036+ // if (!_stricmp(name, "BltThreshold")) cfg->BltThreshold = INIIntValue(value);
 1037+ if (!_stricmp(name, "AdjustPrimaryResolution")) cfg->primaryscale = INIIntValue(value);
 1038+ if (!_stricmp(name, "PrimaryScaleX")) cfg->primaryscalex = INIFloatValue(value);
 1039+ if (!_stricmp(name, "PrimaryScaleY")) cfg->primaryscaley = INIFloatValue(value);
 1040+ if (!_stricmp(name, "ScreenAspect")) cfg->aspect = INIAspectValue(value);
 1041+ if (!_stricmp(name, "DPIScale")) cfg->DPIScale = INIIntValue(value);
 1042+ if (!_stricmp(name, "CustomResolutionX")) cfg->CustomResolutionX = INIIntValue(value);
 1043+ if (!_stricmp(name, "CustomResolutionY")) cfg->CustomResolutionY = INIIntValue(value);
 1044+ if (!_stricmp(name, "CustomRefresh")) cfg->CustomRefresh = INIIntValue(value);
 1045+ if (!_stricmp(name, "DisplayMultiplierX")) cfg->DisplayMultiplierX = INIFloatValue(value);
 1046+ if (!_stricmp(name, "DisplayMultiplierY")) cfg->DisplayMultiplierY = INIFloatValue(value);
10451047 }
1046 - if (!stricmp(section, "postprocess"))
 1048+ if (!_stricmp(section, "postprocess"))
10471049 {
1048 - if (!stricmp(name, "PostprocessFilter")) cfg->postfilter = INIIntValue(value);
1049 - if (!stricmp(name, "PostprocessScaleX")) cfg->postsizex = INIFloatValue(value);
1050 - if (!stricmp(name, "PostprocessScaleY")) cfg->postsizex = INIFloatValue(value);
1051 - if (!stricmp(name, "EnableShader")) cfg->EnableShader = INIBoolValue(value);
1052 - if (!stricmp(name, "ShaderFile")) strncpy(cfg->shaderfile, value, MAX_PATH);
 1050+ if (!_stricmp(name, "PostprocessFilter")) cfg->postfilter = INIIntValue(value);
 1051+ if (!_stricmp(name, "PostprocessScaleX")) cfg->postsizex = INIFloatValue(value);
 1052+ if (!_stricmp(name, "PostprocessScaleY")) cfg->postsizex = INIFloatValue(value);
 1053+ if (!_stricmp(name, "EnableShader")) cfg->EnableShader = INIBoolValue(value);
 1054+ if (!_stricmp(name, "ShaderFile"))
 1055+ {
 1056+#ifdef _UNICODE
 1057+ MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, value, strlen(value), unicode_path, MAX_PATH);
 1058+ _tcsncpy(cfg->shaderfile, unicode_path, MAX_PATH);
 1059+#else
 1060+ _tcsncpy(cfg->shaderfile, value, MAX_PATH);
 1061+#endif
 1062+ }
10531063 }
1054 - if (!stricmp(section, "d3d"))
 1064+ if (!_stricmp(section, "d3d"))
10551065 {
1056 - if (!stricmp(name, "TextureFilter")) cfg->texfilter = INIIntValue(value);
1057 - if (!stricmp(name, "AnisotropicFiltering")) cfg->anisotropic = INIIntValue(value);
1058 - if (!stricmp(name, "Antialiasing")) cfg->msaa = INIHexValue(value);
1059 - if (!stricmp(name, "D3DAspect")) cfg->aspect3d = INIIntValue(value);
1060 - if (!stricmp(name, "LowColorRendering")) cfg->LowColorRendering = INIIntValue(value);
1061 - if (!stricmp(name, "EnableDithering")) cfg->EnableDithering = INIIntValue(value);
 1066+ if (!_stricmp(name, "TextureFilter")) cfg->texfilter = INIIntValue(value);
 1067+ if (!_stricmp(name, "AnisotropicFiltering")) cfg->anisotropic = INIIntValue(value);
 1068+ if (!_stricmp(name, "Antialiasing")) cfg->msaa = INIHexValue(value);
 1069+ if (!_stricmp(name, "D3DAspect")) cfg->aspect3d = INIIntValue(value);
 1070+ if (!_stricmp(name, "LowColorRendering")) cfg->LowColorRendering = INIIntValue(value);
 1071+ if (!_stricmp(name, "EnableDithering")) cfg->EnableDithering = INIIntValue(value);
10621072 }
1063 - if (!stricmp(section, "advanced"))
 1073+ if (!_stricmp(section, "advanced"))
10641074 {
1065 - if (!stricmp(name, "VSync")) cfg->vsync = INIIntValue(value);
1066 - if (!stricmp(name, "TextureFormat")) cfg->TextureFormat = INIIntValue(value);
1067 - if (!stricmp(name, "TexUpload")) cfg->TexUpload = INIIntValue(value);
1068 - if (!stricmp(name, "SingleBufferDevice")) cfg->SingleBufferDevice = INIBoolValue(value);
1069 - if (!stricmp(name, "WindowPosition")) cfg->WindowPosition = INIIntValue(value);
1070 - if (!stricmp(name, "RememberWindowSize")) cfg->RememberWindowSize = INIBoolValue(value);
1071 - if (!stricmp(name, "RememberWindowPosition")) cfg->RememberWindowPosition = INIBoolValue(value);
1072 - if (!stricmp(name, "NoResizeWindow")) cfg->NoResizeWindow = INIBoolValue(value);
1073 - if (!stricmp(name, "WindowX")) cfg->WindowX = INIIntValue(value);
1074 - if (!stricmp(name, "WindowY")) cfg->WindowY = INIIntValue(value);
1075 - if (!stricmp(name, "WindowWidth")) cfg->WindowWidth = INIIntValue(value);
1076 - if (!stricmp(name, "WindowHeight")) cfg->WindowHeight = INIIntValue(value);
1077 - if (!stricmp(name, "WindowMaximized")) cfg->WindowMaximized = INIBoolValue(value);
 1075+ if (!_stricmp(name, "VSync")) cfg->vsync = INIIntValue(value);
 1076+ if (!_stricmp(name, "TextureFormat")) cfg->TextureFormat = INIIntValue(value);
 1077+ if (!_stricmp(name, "TexUpload")) cfg->TexUpload = INIIntValue(value);
 1078+ if (!_stricmp(name, "SingleBufferDevice")) cfg->SingleBufferDevice = INIBoolValue(value);
 1079+ if (!_stricmp(name, "WindowPosition")) cfg->WindowPosition = INIIntValue(value);
 1080+ if (!_stricmp(name, "RememberWindowSize")) cfg->RememberWindowSize = INIBoolValue(value);
 1081+ if (!_stricmp(name, "RememberWindowPosition")) cfg->RememberWindowPosition = INIBoolValue(value);
 1082+ if (!_stricmp(name, "NoResizeWindow")) cfg->NoResizeWindow = INIBoolValue(value);
 1083+ if (!_stricmp(name, "WindowX")) cfg->WindowX = INIIntValue(value);
 1084+ if (!_stricmp(name, "WindowY")) cfg->WindowY = INIIntValue(value);
 1085+ if (!_stricmp(name, "WindowWidth")) cfg->WindowWidth = INIIntValue(value);
 1086+ if (!_stricmp(name, "WindowHeight")) cfg->WindowHeight = INIIntValue(value);
 1087+ if (!_stricmp(name, "WindowMaximized")) cfg->WindowMaximized = INIBoolValue(value);
10781088 }
1079 - if (!stricmp(section, "debug"))
 1089+ if (!_stricmp(section, "debug"))
10801090 {
1081 - if (!stricmp(name, "DebugNoExtFramebuffer")) cfg->DebugNoExtFramebuffer = INIBoolValue(value);
1082 - if (!stricmp(name, "DebugNoArbFramebuffer")) cfg->DebugNoArbFramebuffer = INIBoolValue(value);
1083 - if (!stricmp(name, "DebugNoES2Compatibility")) cfg->DebugNoES2Compatibility = INIBoolValue(value);
1084 - if (!stricmp(name, "DebugNoExtDirectStateAccess")) cfg->DebugNoExtDirectStateAccess = INIBoolValue(value);
1085 - if (!stricmp(name, "DebugNoArbDirectStateAccess")) cfg->DebugNoArbDirectStateAccess = INIBoolValue(value);
1086 - if (!stricmp(name, "DebugNoSamplerObjects")) cfg->DebugNoSamplerObjects = INIBoolValue(value);
1087 - if (!stricmp(name, "DebugNoGpuShader4")) cfg->DebugNoGpuShader4 = INIBoolValue(value);
1088 - if (!stricmp(name, "DebugNoGLSL130")) cfg->DebugNoGLSL130 = INIBoolValue(value);
1089 - if (!stricmp(name, "DebugUploadAfterUnlock")) cfg->DebugUploadAfterUnlock = INIBoolValue(value);
1090 - if (!stricmp(name, "DebugBlendDestColorKey")) cfg->DebugBlendDestColorKey = INIBoolValue(value);
1091 - if (!stricmp(name, "DebugNoMouseHooks")) cfg->DebugNoMouseHooks = INIBoolValue(value);
1092 - if (!stricmp(name, "DebugMaxGLVersionMajor")) cfg->DebugMaxGLVersionMajor = INIIntValue(value);
1093 - if (!stricmp(name, "DebugMaxGLVersionMinor")) cfg->DebugMaxGLVersionMinor = INIIntValue(value);
 1091+ if (!_stricmp(name, "DebugNoExtFramebuffer")) cfg->DebugNoExtFramebuffer = INIBoolValue(value);
 1092+ if (!_stricmp(name, "DebugNoArbFramebuffer")) cfg->DebugNoArbFramebuffer = INIBoolValue(value);
 1093+ if (!_stricmp(name, "DebugNoES2Compatibility")) cfg->DebugNoES2Compatibility = INIBoolValue(value);
 1094+ if (!_stricmp(name, "DebugNoExtDirectStateAccess")) cfg->DebugNoExtDirectStateAccess = INIBoolValue(value);
 1095+ if (!_stricmp(name, "DebugNoArbDirectStateAccess")) cfg->DebugNoArbDirectStateAccess = INIBoolValue(value);
 1096+ if (!_stricmp(name, "DebugNoSamplerObjects")) cfg->DebugNoSamplerObjects = INIBoolValue(value);
 1097+ if (!_stricmp(name, "DebugNoGpuShader4")) cfg->DebugNoGpuShader4 = INIBoolValue(value);
 1098+ if (!_stricmp(name, "DebugNoGLSL130")) cfg->DebugNoGLSL130 = INIBoolValue(value);
 1099+ if (!_stricmp(name, "DebugUploadAfterUnlock")) cfg->DebugUploadAfterUnlock = INIBoolValue(value);
 1100+ if (!_stricmp(name, "DebugBlendDestColorKey")) cfg->DebugBlendDestColorKey = INIBoolValue(value);
 1101+ if (!_stricmp(name, "DebugNoMouseHooks")) cfg->DebugNoMouseHooks = INIBoolValue(value);
 1102+ if (!_stricmp(name, "DebugMaxGLVersionMajor")) cfg->DebugMaxGLVersionMajor = INIIntValue(value);
 1103+ if (!_stricmp(name, "DebugMaxGLVersionMinor")) cfg->DebugMaxGLVersionMinor = INIIntValue(value);
10941104 }
1095 - if (!stricmp(section, "hacks"))
 1105+ if (!_stricmp(section, "hacks"))
10961106 {
1097 - if (!stricmp(section, "HackCrop640480to640400")) cfg->HackCrop640480to640400 = INIBoolValue(value);
1098 - if (!stricmp(section, "HackAutoScale512448to640480")) cfg->HackAutoScale512448to640480 = INIBoolValue(value);
1099 - if (!stricmp(section, "HackNoTVRefresh")) cfg->HackNoTVRefresh = INIBoolValue(value);
1100 - if (!stricmp(section, "HackSetCursor")) cfg->HackSetCursor = INIBoolValue(value);
 1107+ if (!_stricmp(section, "HackCrop640480to640400")) cfg->HackCrop640480to640400 = INIBoolValue(value);
 1108+ if (!_stricmp(section, "HackAutoScale512448to640480")) cfg->HackAutoScale512448to640480 = INIBoolValue(value);
 1109+ if (!_stricmp(section, "HackNoTVRefresh")) cfg->HackNoTVRefresh = INIBoolValue(value);
 1110+ if (!_stricmp(section, "HackSetCursor")) cfg->HackSetCursor = INIBoolValue(value);
11011111 }
11021112 return 1;
11031113 }
@@ -1122,7 +1132,6 @@
11231133 Sha256Context sha_context;
11241134 SHA256_HASH sha256;
11251135 TCHAR sha256string[65];
1126 - FILE *file;
11271136 TCHAR filename[MAX_PATH+1];
11281137 TCHAR regkey[MAX_PATH + 80];
11291138 int i;
@@ -1244,7 +1253,7 @@
12451254 {
12461255 _SetProcessDpiAwarenessContext =
12471256 (BOOL(WINAPI*)(HANDLE))GetProcAddress(hUser32, "SetProcessDpiAwarenessContext");
1248 - if (_SetProcessDpiAwarenessContext) _SetProcessDpiAwarenessContext(-4);
 1257+ if (_SetProcessDpiAwarenessContext) _SetProcessDpiAwarenessContext((HANDLE)-4);
12491258 }
12501259 if (!_SetProcessDpiAwarenessContext)
12511260 {
@@ -1335,7 +1344,7 @@
13361345 {
13371346 HKEY hKey;
13381347 RegCreateKeyEx(HKEY_CURRENT_USER,regkeyglobal,0,NULL,0,KEY_ALL_ACCESS,NULL,&hKey,NULL);
1339 - WriteSettings(hKey,cfg,mask,TRUE);
 1348+ WriteSettings(hKey,cfg,mask);
13401349 RegCloseKey(hKey);
13411350 }
13421351
@@ -1347,7 +1356,7 @@
13481357 _tcscat(regkey, _T("Profiles\\"));
13491358 _tcsncat(regkey, name, MAX_PATH);
13501359 RegCreateKeyEx(HKEY_CURRENT_USER, regkey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
1351 - WriteSettings(hKey,cfg,mask,FALSE);
 1360+ WriteSettings(hKey,cfg,mask);
13521361 RegCloseKey(hKey);
13531362 }
13541363
Index: dxglcfg/dxgltest.cpp
@@ -221,7 +221,8 @@
222222 {7, 7, 0, 2, TRUE, 60.0, TRUE, FALSE, TRUE, _T("DrawIndexedPrimitive cube with directional light (DX7)")},
223223 {7, 7, 0, 2, TRUE, 60.0, TRUE, TRUE, TRUE, _T("DrawPrimitive textured cube (DX7)")},
224224 {7, 7, 0, 0, TRUE, 60.0, TRUE, TRUE, TRUE, _T("Texture Stage shaders (Interactive, DX7)")},
225 - {7, 7, 0, 0, TRUE, 60.0, TRUE, TRUE, TRUE, _T("Vertex shaders (Interactive, DX7)")}
 225+ {7, 7, 0, 0, TRUE, 60.0, TRUE, TRUE, TRUE, _T("Vertex shaders (Interactive, DX7)")},
 226+ {1, 7, 0, 1, TRUE, 60.0, FALSE, FALSE, FALSE, _T("SetCursorPos Test")}
226227 };
227228 const int END_TESTS = __LINE__ - 4;
228229 const int numtests = END_TESTS - START_TESTS;
Index: dxglcfg/tests.cpp
@@ -85,9 +85,9 @@
8686 static BOOL lightenable[8];
8787 static DWORD bgcolor = 0;
8888
89 -static UINT lastmousemsg = WM_NULL;
90 -static WPARAM lastmousewparam = 0;
91 -static LPARAM lastmouselparam = NULL;
 89+static UINT lastmousemsg[8] = { WM_NULL,WM_NULL,WM_NULL,WM_NULL,WM_NULL,WM_NULL,WM_NULL,WM_NULL };
 90+static WPARAM lastmousewparam[8] = { 0,0,0,0,0,0,0,0 };
 91+static LPARAM lastmouselparam[8] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
9292
9393 typedef struct
9494 {
@@ -196,6 +196,7 @@
197197 RECT srcrect,destrect;
198198 HRESULT error;
199199 PAINTSTRUCT paintstruct;
 200+ int i;
200201 switch(Msg)
201202 {
202203 case WM_CLOSE:
@@ -312,9 +313,15 @@
313314 case WM_XBUTTONUP:
314315 case WM_XBUTTONDBLCLK:
315316 case WM_MOUSEHWHEEL:
316 - lastmousemsg = Msg;
317 - lastmousewparam = wParam;
318 - lastmouselparam = lParam;
 317+ for (i = 7; i > 0; i--)
 318+ lastmousemsg[i] = lastmousemsg[i - 1];
 319+ lastmousemsg[0] = Msg;
 320+ for (i = 7; i > 0; i--)
 321+ lastmousewparam[i] = lastmousewparam[i-1];
 322+ lastmousewparam[0] = wParam;
 323+ for (i = 7; i > 0; i--)
 324+ lastmouselparam[i] = lastmouselparam[i-1];
 325+ lastmouselparam[0] = lParam;
319326 break;
320327 default:
321328 return DefWindowProc(hWnd,Msg,wParam,lParam);
@@ -1313,7 +1320,8 @@
13141321 TCHAR message[256];
13151322 TCHAR number[32];
13161323 HBRUSH brush;
1317 - BOOL out[7];
 1324+ BOOL out[9];
 1325+ int i;
13181326 bltfx.dwSize = sizeof(DDBLTFX);
13191327 ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
13201328 ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
@@ -1380,8 +1388,8 @@
13811389 destrect.bottom = height;
13821390 FillRect(hDCdest, &destrect, brush);
13831391 DeleteObject(brush);
1384 - _tcscpy(message, _T("Mouse pointer test"));
1385 - displayfonts[0] = CreateFont(9, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
 1392+ _tcscpy(message, _T("Mouse pointer test - colored pointers should follow mouse."));
 1393+ displayfonts[0] = CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
13861394 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
13871395 DEFAULT_PITCH, _T("Fixedsys"));
13881396 displayfonts[1] = (HFONT)SelectObject(hDCdest, displayfonts[0]);
@@ -1389,85 +1397,89 @@
13901398 SetBkColor(hDCdest, RGB(0,0,255));
13911399 TextOut(hDCdest, 0, 0, message, _tcslen(message));
13921400 GetTextExtentPoint(hDCdest, _T("A"), 1, &textsize);
1393 - _tcscpy(message, _T("Last mouse message: "));
1394 - switch (lastmousemsg)
 1401+ for (i = 0; i < 8; i++)
13951402 {
1396 - case WM_MOUSEMOVE:
1397 - _tcscat(message, _T("WM_MOUSEMOVE "));
1398 - break;
1399 - case WM_LBUTTONDOWN:
1400 - _tcscat(message, _T("WM_LBUTTONDOWN "));
1401 - break;
1402 - case WM_LBUTTONUP:
1403 - _tcscat(message, _T("WM_LBUTTONUP "));
1404 - break;
1405 - case WM_LBUTTONDBLCLK:
1406 - _tcscat(message, _T("WM_LBUTTONDBLCLK "));
1407 - break;
1408 - case WM_RBUTTONDOWN:
1409 - _tcscat(message, _T("WM_RBUTTONDOWN "));
1410 - break;
1411 - case WM_RBUTTONUP:
1412 - _tcscat(message, _T("WM_RBUTTONUP "));
1413 - break;
1414 - case WM_RBUTTONDBLCLK:
1415 - _tcscat(message, _T("WM_RBUTTONDBLCLK "));
1416 - break;
1417 - case WM_MBUTTONDOWN:
1418 - _tcscat(message, _T("WM_MBUTTONDOWN "));
1419 - break;
1420 - case WM_MBUTTONUP:
1421 - _tcscat(message, _T("WM_MBUTTONUP "));
1422 - break;
1423 - case WM_MBUTTONDBLCLK:
1424 - _tcscat(message, _T("WM_MBUTTONDBLCLK "));
1425 - break;
1426 - case WM_MOUSEWHEEL:
1427 - _tcscat(message, _T("WM_MOUSEWHEEL "));
1428 - break;
1429 - case WM_XBUTTONDOWN:
1430 - _tcscat(message, _T("WM_XBUTTONDOWN "));
1431 - break;
1432 - case WM_XBUTTONUP:
1433 - _tcscat(message, _T("WM_XBUTTONUP "));
1434 - break;
1435 - case WM_XBUTTONDBLCLK:
1436 - _tcscat(message, _T("WM_XBUTTONDBLCLK "));
1437 - break;
1438 - case WM_MOUSEHWHEEL:
1439 - _tcscat(message, _T("WM_MOUSEHWHEEL "));
1440 - break;
1441 - default:
1442 - _tcscat(message, _T("unknown "));
 1403+ _tcscpy(message, _T("Mouse message: "));
 1404+ switch (lastmousemsg[i])
 1405+ {
 1406+ case WM_MOUSEMOVE:
 1407+ _tcscat(message, _T("WM_MOUSEMOVE "));
 1408+ break;
 1409+ case WM_LBUTTONDOWN:
 1410+ _tcscat(message, _T("WM_LBUTTONDOWN "));
 1411+ break;
 1412+ case WM_LBUTTONUP:
 1413+ _tcscat(message, _T("WM_LBUTTONUP "));
 1414+ break;
 1415+ case WM_LBUTTONDBLCLK:
 1416+ _tcscat(message, _T("WM_LBUTTONDBLCLK "));
 1417+ break;
 1418+ case WM_RBUTTONDOWN:
 1419+ _tcscat(message, _T("WM_RBUTTONDOWN "));
 1420+ break;
 1421+ case WM_RBUTTONUP:
 1422+ _tcscat(message, _T("WM_RBUTTONUP "));
 1423+ break;
 1424+ case WM_RBUTTONDBLCLK:
 1425+ _tcscat(message, _T("WM_RBUTTONDBLCLK "));
 1426+ break;
 1427+ case WM_MBUTTONDOWN:
 1428+ _tcscat(message, _T("WM_MBUTTONDOWN "));
 1429+ break;
 1430+ case WM_MBUTTONUP:
 1431+ _tcscat(message, _T("WM_MBUTTONUP "));
 1432+ break;
 1433+ case WM_MBUTTONDBLCLK:
 1434+ _tcscat(message, _T("WM_MBUTTONDBLCLK "));
 1435+ break;
 1436+ case WM_MOUSEWHEEL:
 1437+ _tcscat(message, _T("WM_MOUSEWHEEL "));
 1438+ break;
 1439+ case WM_XBUTTONDOWN:
 1440+ _tcscat(message, _T("WM_XBUTTONDOWN "));
 1441+ break;
 1442+ case WM_XBUTTONUP:
 1443+ _tcscat(message, _T("WM_XBUTTONUP "));
 1444+ break;
 1445+ case WM_XBUTTONDBLCLK:
 1446+ _tcscat(message, _T("WM_XBUTTONDBLCLK "));
 1447+ break;
 1448+ case WM_MOUSEHWHEEL:
 1449+ _tcscat(message, _T("WM_MOUSEHWHEEL "));
 1450+ break;
 1451+ default:
 1452+ _tcscat(message, _T("unknown "));
 1453+ }
 1454+ x = GET_X_LPARAM(lastmouselparam[i]);
 1455+ y = GET_Y_LPARAM(lastmouselparam[i]);
 1456+ _tcscat(message, _T("X="));
 1457+ _itot(x, number, 10);
 1458+ _tcscat(message, number);
 1459+ _tcscat(message, _T(" "));
 1460+ _tcscat(message, _T("Y="));
 1461+ _itot(y, number, 10);
 1462+ _tcscat(message, number);
 1463+ _tcscat(message, _T(" "));
 1464+ _tcscat(message, _T("Keys: "));
 1465+ if (lastmousewparam[i] & MK_CONTROL) _tcscat(message, _T("CTRL "));
 1466+ if (lastmousewparam[i] & MK_SHIFT) _tcscat(message, _T("SHIFT "));
 1467+ _tcscat(message, _T("Buttons: "));
 1468+ if (lastmousewparam[i] & MK_LBUTTON) _tcscat(message, _T("L "));
 1469+ if (lastmousewparam[i] & MK_MBUTTON) _tcscat(message, _T("M "));
 1470+ if (lastmousewparam[i] & MK_RBUTTON) _tcscat(message, _T("R "));
 1471+ if (lastmousewparam[i] & MK_XBUTTON1) _tcscat(message, _T("X1 "));
 1472+ if (lastmousewparam[i] & MK_XBUTTON2) _tcscat(message, _T("X2 "));
 1473+ if ((x > width) || (y > height) || (x < 0) || (y < 0))
 1474+ {
 1475+ out[i] = TRUE;
 1476+ _tcscat(message, _T(" OUT OF BOUNDS"));
 1477+ }
 1478+ else out[i] = FALSE;
 1479+ if (out[i]) SetTextColor(hDCdest, RGB(255, 0, 0));
 1480+ else SetTextColor(hDCdest, RGB(255, 255, 255));
 1481+ SetBkColor(hDCdest, RGB(0, 0, 127));
 1482+ TextOut(hDCdest, 0, (i + 1)*textsize.cy, message, _tcslen(message));
14431483 }
1444 - x = GET_X_LPARAM(lastmouselparam);
1445 - y = GET_Y_LPARAM(lastmouselparam);
1446 - _tcscat(message, _T("X="));
1447 - _itot(x, number, 10);
1448 - _tcscat(message, number);
1449 - _tcscat(message, _T(" "));
1450 - _tcscat(message, _T("Y="));
1451 - _itot(y, number, 10);
1452 - _tcscat(message, number);
1453 - _tcscat(message, _T(" "));
1454 - _tcscat(message, _T("Keys: "));
1455 - if (lastmousewparam & MK_CONTROL) _tcscat(message, _T("CTRL "));
1456 - if (lastmousewparam & MK_SHIFT) _tcscat(message, _T("SHIFT "));
1457 - _tcscat(message, _T("Buttons: "));
1458 - if (lastmousewparam & MK_LBUTTON) _tcscat(message, _T("L "));
1459 - if (lastmousewparam & MK_MBUTTON) _tcscat(message, _T("M "));
1460 - if (lastmousewparam & MK_RBUTTON) _tcscat(message, _T("R "));
1461 - if (lastmousewparam & MK_XBUTTON1) _tcscat(message, _T("X1 "));
1462 - if (lastmousewparam & MK_XBUTTON2) _tcscat(message, _T("X2 "));
1463 - if ((x > width) || (y > height) || (x < 0) || (y < 0))
1464 - {
1465 - out[0] = TRUE;
1466 - _tcscat(message, _T(" OUT OF BOUNDS"));
1467 - }
1468 - else out[0] = FALSE;
1469 - if (out[0]) SetTextColor(hDCdest, RGB(255, 0, 0));
1470 - else SetTextColor(hDCdest, RGB(255, 255, 255));
1471 - TextOut(hDCdest, 0, textsize.cy, message, _tcslen(message));
14721484 GetCursorPos(&p);
14731485 _tcscpy(message, _T("GetCursorPos() position: "));
14741486 _tcscat(message, _T("X="));
@@ -1479,32 +1491,35 @@
14801492 _tcscat(message, number);
14811493 if ((p.x > width) || (p.y > height) || (p.x < 0) || (p.y < 0))
14821494 {
1483 - out[1] = TRUE;
 1495+ out[8] = TRUE;
14841496 _tcscat(message, _T(" OUT OF BOUNDS"));
14851497 }
1486 - else out[1] = FALSE;
1487 - if (out[1]) SetTextColor(hDCdest, RGB(255, 0, 0));
 1498+ else out[8] = FALSE;
 1499+ if (out[8]) SetTextColor(hDCdest, RGB(255, 0, 0));
14881500 else SetTextColor(hDCdest, RGB(255, 255, 255));
1489 - SetBkColor(hDCdest, RGB(0, 255, 0));
1490 - TextOut(hDCdest, 0, 2 * textsize.cy, message, _tcslen(message));
 1501+ SetBkColor(hDCdest, RGB(0, 127, 0));
 1502+ TextOut(hDCdest, 0, 9 * textsize.cy, message, _tcslen(message));
14911503 SelectObject(hDCdest, displayfonts[1]);
14921504 DeleteObject(displayfonts[0]);
14931505 temp1->ReleaseDC(hDCdest);
14941506 // Draw cursors
1495 - if (!out[0])
 1507+ for (i = 0; i < 8; i++)
14961508 {
1497 - destrect.left = GET_X_LPARAM(lastmouselparam);
1498 - destrect.top = GET_Y_LPARAM(lastmouselparam);
1499 - destrect.right = GET_X_LPARAM(lastmouselparam) + sprites[0].ddsd.dwWidth;
1500 - if (destrect.right > width) destrect.right = width;
1501 - destrect.bottom = GET_Y_LPARAM(lastmouselparam) + sprites[0].ddsd.dwHeight;
1502 - if (destrect.bottom > height) destrect.bottom = height;
1503 - srcrect.left = srcrect.top = 0;
1504 - srcrect.right = destrect.right - destrect.left;
1505 - srcrect.bottom = destrect.bottom - destrect.top;
1506 - temp1->Blt(&destrect, sprites[0].surface, &srcrect, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
 1509+ if (!out[i])
 1510+ {
 1511+ destrect.left = GET_X_LPARAM(lastmouselparam[i]);
 1512+ destrect.top = GET_Y_LPARAM(lastmouselparam[i]);
 1513+ destrect.right = GET_X_LPARAM(lastmouselparam[i]) + sprites[0].ddsd.dwWidth;
 1514+ if (destrect.right > width) destrect.right = width;
 1515+ destrect.bottom = GET_Y_LPARAM(lastmouselparam[i]) + sprites[0].ddsd.dwHeight;
 1516+ if (destrect.bottom > height) destrect.bottom = height;
 1517+ srcrect.left = srcrect.top = 0;
 1518+ srcrect.right = destrect.right - destrect.left;
 1519+ srcrect.bottom = destrect.bottom - destrect.top;
 1520+ temp1->Blt(&destrect, sprites[0].surface, &srcrect, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
 1521+ }
15071522 }
1508 - if (!out[1])
 1523+ if (!out[8])
15091524 {
15101525 destrect.left = p.x;
15111526 destrect.top = p.y;
@@ -1517,6 +1532,7 @@
15181533 srcrect.bottom = destrect.bottom - destrect.top;
15191534 temp1->Blt(&destrect, sprites[1].surface, &srcrect, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
15201535 }
 1536+ if (backbuffers) temp1->Release();
15211537 if (fullscreen)
15221538 {
15231539 if (backbuffers && ddsrender) ddsrender->Flip(NULL, DDFLIP_WAIT);