DXGL r567 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r566‎ | r567 | r568 >
Date:20:20, 16 November 2014
Author:admin
Status:new
Tags:
Comment:
Change primary scaling option to an enumerated DWORD, and add custom X and Y scale floats.
Replace AllColorDepths option with bitmapped AddColorDepths, deprecate old variable.
Replace ExtraModes option with bitmapped AddModes, deprecate old variable.
Remove vsync option descriptions as it is not yet implemented.
No new options are implemented yet within ddraw.dll or new DXGLCFG.
Deprecate old DXGLCFG. Will likely be removed in next release.
Modified paths:
  • /cfgmgr/ReadMe.txt (modified) (history)
  • /cfgmgr/cfgmgr.c (modified) (history)
  • /cfgmgr/cfgmgr.h (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /dxglcfg/dxglcfg.c (modified) (history)
  • /dxglcfg/dxglcfg.rc (modified) (history)

Diff [purge]

Index: cfgmgr/ReadMe.txt
——@@ -24,14 +24,31 @@
2525 0 - Nearest-neighbor stretching
2626 1 - Bilinear interpolation
2727
28 -Member highres
 28+Member primaryscale
2929 REG_DWORD HKCU\DXGL\<app>\AdjustPrimaryResolution
3030 Changes primary resolution to match desktop resolution.
3131 May cause glitches
3232 Valid settings:
33 -0 - Use native primary surface size. More compatible.
34 -1 - Adjust primary surface size.
 33+0 - Use native primary surface size. Most compatible.
 34+1 - Adjust primary surface size to match display.
 35+2 - Adjust primary surface to nearest integer multiple of native.
 36+3 - Use exact 2x scale.
 37+4 - Use exact 3x scale.
 38+5 - Use exact 4x scale.
 39+6 - Use custom scale.
3540
 41+Member primaryscalex
 42+REG_DWORD HKCU\DXGL\<app>\PrimaryScaleX
 43+Custom X scale for primary scaling.
 44+Stored as a 32-bit float encoded as a DWORD.
 45+If zero, negative, or an invalid value, set to 1.
 46+
 47+Member primaryscaley
 48+REG_DWORD HKCU\DXGL\<app>\PrimaryScaleY
 49+Custom X scale for primary scaling.
 50+Stored as a 32-bit float encoded as a DWORD.
 51+If zero, negative, or an invalid value, set to 1.
 52+
3653 Member texfilter
3754 REG_DWORD HKCU\DXGL\<app>\TextureFilter
3855 Filter for 3D textured polygons
——@@ -87,25 +104,45 @@
88105
89106 Member AllColorDepths
90107 REG_DWORD HKCU\DXGL\<app>\AllColorDepths
91 -Enable all color depths, even if unsupported by the system
 108+[DEPRECATED]Enable all color depths, even if unsupported by the system
92109 Valid settings:
93110 0 - Off
94111 1 - On
95112
96 -Member LowResModes
97 -REG_DWORD HKCU\DXGL\<app>\LowResModes
98 -Enable low resolution video modes, even if unsupported by the system
 113+Member AddColorDepths
 114+REG_DWORD HKCU\DXGL\<app>\AddColorDepths
 115+Adds color depths, even if unsupported by the system
 116+Bit-mapped variable
 117+Valid settings, OR'ed to combine settings:
 118+0 - None
 119+1 - Add 8-bit modes
 120+2 - Add 15-bit modes
 121+4 - Add 16-bit modes
 122+8 - Add 24-bit modes
 123+16 - Add 32-bit modes
 124+
 125+Member ExtraModes
 126+REG_DWORD HKCU\DXGL\<app>\ExtraModes
 127+[DEPRECATED]Enable extra video modes, even if unsupported by the system
99128 Valid settings:
100129 0 - Off
101130 1 - On
102131
 132+member AddModes
 133+REG_DWORD HKCU\DXGL\<app>\AddModes
 134+Adds additional video modes, even if unsupported by the system
 135+Bit-mapped variable
 136+Valid settings, OR'ed to combine settings:
 137+0 - None
 138+1 - Add common low-resolution modes
 139+2 - Add less common low-resolution modes
 140+4 - Add higher resolution modes
 141+
103142 Member vsync
104143 REG_DWORD HKCU\DXGL\<app>\VSync
105144 Vertical retrace control
106145 Valid settings:
107146 0 - Determined by application
108 -1 - Off
109 -2 - On
110147
111148 Member TextureFormat
112149 REG_DWORD HKCU\DXGL\<app>\TextureFormat
Index: cfgmgr/cfgmgr.c
——@@ -353,6 +353,25 @@
354354 }
355355 }
356356
 357+DWORD ReadDeprecatedBool(HKEY hKey, DWORD original, DWORD *mask, LPCTSTR value, DWORD true_value, DWORD false_value)
 358+{
 359+ DWORD dwOut;
 360+ DWORD sizeout = 4;
 361+ DWORD regdword = REG_DWORD;
 362+ LSTATUS error = RegQueryValueEx(hKey, value, NULL, &regdword, (LPBYTE)&dwOut, &sizeout);
 363+ if (error == ERROR_SUCCESS)
 364+ {
 365+ *mask = 1;
 366+ if (dwOut) return true_value;
 367+ else return false_value;
 368+ }
 369+ else
 370+ {
 371+ *mask = 0;
 372+ return original;
 373+ }
 374+}
 375+
357376 DWORD ReadDWORD(HKEY hKey, DWORD original, DWORD *mask, LPCTSTR value)
358377 {
359378 DWORD dwOut;
——@@ -418,11 +437,15 @@
419438 cfg->anisotropic = ReadDWORD(hKey,cfg->anisotropic,&cfgmask->anisotropic,_T("AnisotropicFiltering"));
420439 cfg->msaa = ReadDWORD(hKey,cfg->msaa,&cfgmask->msaa,_T("Antialiasing"));
421440 cfg->aspect3d = ReadDWORD(hKey,cfg->aspect3d,&cfgmask->aspect3d,_T("AdjustAspectRatio"));
422 - cfg->highres = ReadBool(hKey,cfg->highres,&cfgmask->highres,_T("AdjustPrimaryResolution"));
 441+ cfg->primaryscale = ReadDWORD(hKey,cfg->primaryscale,&cfgmask->primaryscale,_T("AdjustPrimaryResolution"));
 442+ cfg->primaryscalex = ReadFloat(hKey,cfg->primaryscalex,&cfgmask->primaryscalex,_T("PrimaryScaleX"));
 443+ cfg->primaryscaley = ReadFloat(hKey,cfg->primaryscaley,&cfgmask->primaryscaley,_T("PrimaryScaleY"));
423444 ReadPath(hKey,cfg->shaderfile,cfgmask->shaderfile,_T("ShaderFile"));
424445 cfg->SortModes = ReadDWORD(hKey,cfg->SortModes,&cfgmask->SortModes,_T("SortModes"));
425 - cfg->AllColorDepths = ReadBool(hKey,cfg->AllColorDepths,&cfgmask->AllColorDepths,_T("AllColorDepths"));
426 - cfg->ExtraModes = ReadBool(hKey,cfg->ExtraModes,&cfgmask->ExtraModes,_T("ExtraModes"));
 446+ cfg->AddColorDepths = ReadDeprecatedBool(hKey, cfg->AddColorDepths, &cfgmask->AddColorDepths, _T("AddColorDepths"), 1 | 4 | 16, 0);
 447+ cfg->AddColorDepths = ReadDWORD(hKey,cfg->AddColorDepths,&cfgmask->AddColorDepths,_T("AddColorDepths"));
 448+ cfg->AddModes = ReadDeprecatedBool(hKey, cfg->AddModes, &cfgmask->AddModes, _T("ExtraModes"),7,0);
 449+ cfg->AddModes = ReadDWORD(hKey, cfg->AddModes, &cfgmask->AddModes, _T("AddModes"));
427450 cfg->vsync = ReadDWORD(hKey,cfg->vsync,&cfgmask->vsync,_T("VSync"));
428451 cfg->TextureFormat = ReadDWORD(hKey,cfg->TextureFormat,&cfgmask->TextureFormat,_T("TextureFormat"));
429452 cfg->TexUpload = ReadDWORD(hKey,cfg->TexUpload,&cfgmask->TexUpload,_T("TexUpload"));
——@@ -506,11 +529,13 @@
507530 WriteDWORD(hKey,cfg->anisotropic,cfgmask->anisotropic,_T("AnisotropicFiltering"));
508531 WriteDWORD(hKey,cfg->msaa,cfgmask->msaa,_T("Antialiasing"));
509532 WriteDWORD(hKey,cfg->aspect3d,cfgmask->aspect3d,_T("AdjustAspectRatio"));
510 - WriteBool(hKey,cfg->highres,cfgmask->highres,_T("AdjustPrimaryResolution"));
 533+ WriteBool(hKey,cfg->primaryscale,cfgmask->primaryscale,_T("AdjustPrimaryResolution"));
 534+ WriteFloat(hKey,cfg->primaryscalex,cfgmask->primaryscalex,_T("PrimaryScaleX"));
 535+ WriteFloat(hKey,cfg->primaryscaley,cfgmask->primaryscaley,_T("PrimaryScaleY"));
511536 WritePath(hKey,cfg->shaderfile,cfgmask->shaderfile,_T("ShaderFile"));
512537 WriteDWORD(hKey,cfg->SortModes,cfgmask->SortModes,_T("SortModes"));
513 - WriteBool(hKey,cfg->AllColorDepths,cfgmask->AllColorDepths,_T("AllColorDepths"));
514 - WriteBool(hKey,cfg->ExtraModes,cfgmask->ExtraModes,_T("ExtraModes"));
 538+ WriteBool(hKey,cfg->AddColorDepths,cfgmask->AddColorDepths,_T("AddColorDepths"));
 539+ WriteBool(hKey,cfg->AddModes,cfgmask->AddModes,_T("AddModes"));
515540 WriteDWORD(hKey,cfg->vsync,cfgmask->vsync,_T("VSync"));
516541 WriteDWORD(hKey,cfg->TextureFormat,cfgmask->TextureFormat,_T("TextureFormat"));
517542 WriteDWORD(hKey,cfg->TexUpload,cfgmask->TexUpload,_T("TexUpload"));
——@@ -666,7 +691,7 @@
667692 GetVersionEx(&osver);
668693 if (osver.dwMajorVersion > 6) cfg->Windows8Detected = TRUE;
669694 if ((osver.dwMajorVersion == 6) && (osver.dwMinorVersion >= 2)) cfg->Windows8Detected = TRUE;
670 - if (cfg->Windows8Detected) cfg->AllColorDepths = TRUE;
 695+ if (cfg->Windows8Detected) cfg->AddColorDepths = 1 | 4 | 16;
671696 }
672697 RegCloseKey(hKey);
673698 }
Index: cfgmgr/cfgmgr.h
——@@ -32,12 +32,14 @@
3333 DWORD anisotropic;
3434 DWORD msaa;
3535 DWORD aspect3d;
36 - BOOL highres;
 36+ DWORD primaryscale;
 37+ float primaryscalex;
 38+ float primaryscaley;
3739 DWORD vsync;
3840 TCHAR shaderfile[MAX_PATH+1];
3941 DWORD SortModes;
40 - BOOL AllColorDepths;
41 - BOOL ExtraModes;
 42+ DWORD AddColorDepths;
 43+ DWORD AddModes;
4244 DWORD TextureFormat;
4345 DWORD TexUpload;
4446 DWORD DPIScale;
Index: ddraw/glDirectDraw.cpp
——@@ -377,9 +377,9 @@
378378 }
379379 }
380380 DiscardDuplicateModes(&modes,&modenum);
381 - if(dxglcfg.AllColorDepths) AddExtraColorModes(&modes,&modenum);
 381+ if(dxglcfg.AddColorDepths) AddExtraColorModes(&modes,&modenum); // FIXME: Add color depths by bitmask
382382 DiscardDuplicateModes(&modes,&modenum);
383 - if(dxglcfg.ExtraModes && (dxglcfg.scaler != 0)) AddExtraResolutions(&modes,&modenum);
 383+ if(dxglcfg.AddModes && (dxglcfg.scaler != 0)) AddExtraResolutions(&modes,&modenum); // FIXME: Add modes by bitmask
384384 modenum--;
385385 switch(dxglcfg.SortModes)
386386 {
——@@ -488,8 +488,8 @@
489489 }
490490 }
491491 DiscardDuplicateModes(&modes,&modenum);
492 - if(dxglcfg.AllColorDepths) AddExtraColorModes(&modes,&modenum);
493 - if(dxglcfg.ExtraModes && (dxglcfg.scaler != 0)) AddExtraResolutions(&modes,&modenum);
 492+ if(dxglcfg.AddColorDepths) AddExtraColorModes(&modes,&modenum); // FIXME: Add color depths by bitmask
 493+ if(dxglcfg.AddModes && (dxglcfg.scaler != 0)) AddExtraResolutions(&modes,&modenum); // FIXME: Add modes by bitmask
494494 modenum--;
495495 switch(dxglcfg.SortModes)
496496 {
Index: ddraw/glDirectDrawSurface.cpp
——@@ -99,7 +99,7 @@
100100 {
101101 ddsd.dwWidth = sizes[2];
102102 ddsd.dwHeight = sizes[3];
103 - if(dxglcfg.highres)
 103+ if(dxglcfg.primaryscale) // FIXME: Support new scaling modes
104104 {
105105 fakex = sizes[0];
106106 fakey = sizes[1];
——@@ -1338,7 +1338,7 @@
13391339 {
13401340 ddsd.dwWidth = sizes[2];
13411341 ddsd.dwHeight = sizes[3];
1342 - if(dxglcfg.highres)
 1342+ if(dxglcfg.primaryscale) // FIXME: Support new scaling modes
13431343 {
13441344 fakex = sizes[0];
13451345 fakey = sizes[1];
——@@ -1378,7 +1378,7 @@
13791379 {
13801380 ddsd.dwWidth = sizes[2];
13811381 ddsd.dwHeight = sizes[3];
1382 - if(dxglcfg.highres)
 1382+ if(dxglcfg.primaryscale) // FIXME: Support new scaling modes
13831383 {
13841384 fakex = sizes[0];
13851385 fakey = sizes[1];
Index: dxglcfg/dxglcfg.c
——@@ -348,6 +348,24 @@
349349 }
350350 }
351351
 352+DWORD GetCheckWithSpecificValue(HWND hWnd, int DlgItem, DWORD *mask, DWORD true_value, DWORD false_value)
 353+{
 354+ int check = SendDlgItemMessage(hWnd, DlgItem, BM_GETCHECK, 0, 0);
 355+ switch (check)
 356+ {
 357+ case BST_CHECKED:
 358+ *mask = 1;
 359+ return true_value;
 360+ case BST_UNCHECKED:
 361+ *mask = 1;
 362+ return false_value;
 363+ case BST_INDETERMINATE:
 364+ default:
 365+ *mask = 0;
 366+ return false_value;
 367+ }
 368+}
 369+
352370 DWORD GetCombo(HWND hWnd, int DlgItem, DWORD *mask)
353371 {
354372 int value = SendDlgItemMessage(hWnd,DlgItem,CB_GETCURSEL,0,0);
——@@ -557,7 +575,7 @@
558576 SetAspectCombo(hWnd, IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
559577
560578 // highres
561 - if(cfg->highres) SendDlgItemMessage(hWnd,IDC_HIGHRES,BM_SETCHECK,BST_CHECKED,0);
 579+ if(cfg->primaryscale) SendDlgItemMessage(hWnd,IDC_HIGHRES,BM_SETCHECK,BST_CHECKED,0);
562580 else SendDlgItemMessage(hWnd,IDC_HIGHRES,BM_SETCHECK,BST_UNCHECKED,0);
563581 // texfilter
564582 _tcscpy(buffer,_T("Application default"));
——@@ -689,10 +707,10 @@
690708 SendDlgItemMessage(hWnd,IDC_SORTMODES,CB_ADDSTRING,2,(LPARAM)buffer);
691709 SendDlgItemMessage(hWnd,IDC_SORTMODES,CB_SETCURSEL,cfg->SortModes,0);
692710 // color depths
693 - if(cfg->AllColorDepths) SendDlgItemMessage(hWnd,IDC_UNCOMMONCOLOR,BM_SETCHECK,BST_CHECKED,0);
 711+ if(cfg->AddColorDepths) SendDlgItemMessage(hWnd,IDC_UNCOMMONCOLOR,BM_SETCHECK,BST_CHECKED,0);
694712 else SendDlgItemMessage(hWnd,IDC_UNCOMMONCOLOR,BM_SETCHECK,BST_UNCHECKED,0);
695713 // extra modes
696 - if(cfg->ExtraModes) SendDlgItemMessage(hWnd,IDC_EXTRAMODES,BM_SETCHECK,BST_CHECKED,0);
 714+ if(cfg->AddModes) SendDlgItemMessage(hWnd,IDC_EXTRAMODES,BM_SETCHECK,BST_CHECKED,0);
697715 else SendDlgItemMessage(hWnd,IDC_EXTRAMODES,BM_SETCHECK,BST_UNCHECKED,0);
698716 // shader path
699717 SetText(hWnd,IDC_SHADER,cfg->shaderfile,cfgmask->shaderfile,FALSE);
——@@ -995,11 +1013,11 @@
9961014 SetCombo(hWnd,IDC_TEXFILTER,cfg->texfilter,cfgmask->texfilter,tristate);
9971015 SetCombo(hWnd,IDC_ASPECT3D,cfg->aspect3d,cfgmask->aspect3d,tristate);
9981016 SetCheck(hWnd,IDC_COLOR,cfg->colormode,cfgmask->colormode,tristate);
999 - SetCheck(hWnd,IDC_HIGHRES,cfg->highres,cfgmask->highres,tristate);
1000 - SetCheck(hWnd,IDC_UNCOMMONCOLOR,cfg->AllColorDepths,cfgmask->AllColorDepths,tristate);
 1017+ SetCheck(hWnd,IDC_HIGHRES,cfg->primaryscale,cfgmask->primaryscale,tristate);
 1018+ SetCheck(hWnd,IDC_UNCOMMONCOLOR,cfg->AddColorDepths,cfgmask->AddColorDepths,tristate);
10011019 SetCombo(hWnd,IDC_TEXTUREFORMAT,cfg->TextureFormat,cfgmask->TextureFormat,tristate);
10021020 SetCombo(hWnd,IDC_TEXUPLOAD,cfg->TexUpload,cfgmask->TexUpload,tristate);
1003 - SetCheck(hWnd,IDC_EXTRAMODES,cfg->ExtraModes,cfgmask->ExtraModes,tristate);
 1021+ SetCheck(hWnd,IDC_EXTRAMODES,cfg->AddModes,cfgmask->AddModes,tristate);
10041022 SetText(hWnd,IDC_SHADER,cfg->shaderfile,cfgmask->shaderfile,tristate);
10051023 SetCombo(hWnd, IDC_DPISCALE, cfg->DPIScale, cfgmask->DPIScale, tristate);
10061024 SetAspectCombo(hWnd, IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
——@@ -1051,17 +1069,17 @@
10521070 *dirty = TRUE;
10531071 break;
10541072 case IDC_HIGHRES:
1055 - cfg->highres = GetCheck(hWnd,IDC_HIGHRES,&cfgmask->highres);
 1073+ cfg->primaryscale = GetCheck(hWnd,IDC_HIGHRES,&cfgmask->primaryscale);
10561074 EnableWindow(GetDlgItem(hWnd,IDC_APPLY),TRUE);
10571075 *dirty = TRUE;
10581076 break;
10591077 case IDC_UNCOMMONCOLOR:
1060 - cfg->AllColorDepths = GetCheck(hWnd,IDC_UNCOMMONCOLOR,&cfgmask->AllColorDepths);
 1078+ cfg->AddColorDepths = GetCheckWithSpecificValue(hWnd, IDC_UNCOMMONCOLOR, &cfgmask->AddColorDepths, 1 | 4 | 16, 0);
10611079 EnableWindow(GetDlgItem(hWnd,IDC_APPLY),TRUE);
10621080 *dirty = TRUE;
10631081 break;
10641082 case IDC_EXTRAMODES:
1065 - cfg->ExtraModes = GetCheck(hWnd,IDC_EXTRAMODES,&cfgmask->ExtraModes);
 1083+ cfg->AddModes = GetCheckWithSpecificValue(hWnd,IDC_EXTRAMODES,&cfgmask->AddModes, 7, 0);
10661084 EnableWindow(GetDlgItem(hWnd,IDC_APPLY),TRUE);
10671085 *dirty = TRUE;
10681086 break;
——@@ -1300,6 +1318,8 @@
13011319 GetModuleFileName(NULL,hlppath,MAX_PATH);
13021320 GetDirFromPath(hlppath);
13031321 _tcscat(hlppath,_T("\\dxgl.chm"));
 1322+ MessageBox(NULL, _T("This version of DXGL Config is deprecated and no longer supported. Some options may no longer work correctly."),
 1323+ _T("Notice"), MB_OK | MB_ICONWARNING);
13041324 DialogBox(hInstance,MAKEINTRESOURCE(IDD_DXGLCFG),0,(DLGPROC)DXGLCfgCallback);
13051325 #ifdef _DEBUG
13061326 _CrtDumpMemoryLeaks();
Index: dxglcfg/dxglcfg.rc
——@@ -30,7 +30,7 @@
3131 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
3232 IDD_DXGLCFG DIALOG 0, 0, 405, 265
3333 STYLE DS_3DLOOK | DS_CONTEXTHELP | DS_SETFONT | WS_CAPTION | WS_SYSMENU
34 -CAPTION "DXGL Config"
 34+CAPTION "DXGL Config (DEPRECATED)"
3535 FONT 8, "Ms Shell Dlg 2"
3636 {
3737 DEFPUSHBUTTON "OK", IDOK, 247, 247, 50, 14
——@@ -110,7 +110,7 @@
111111 {
112112 BLOCK "08000352"
113113 {
114 - VALUE "FileDescription", "DXGL Configuration Program"
 114+ VALUE "FileDescription", "DXGL Configuration Program (DEPRECATED VERSION)"
115115 VALUE "FileVersion", DXGLVERSTRING
116116 VALUE "InternalName", "DXGL"
117117 VALUE "LegalCopyright", "Copyright © 2011-2014 William Feely"