DXGL r791 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r790‎ | r791 | r792 >
Date:15:02, 10 March 2018
Author:admin
Status:new
Tags:
Comment:
Add support for selections for extra modes. Common low-resolution modes enables pixel-doubled modes.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -95,44 +95,6 @@
9696 return false;
9797 }
9898
99 -const int START_EXTRAMODESCOUNT = __LINE__;
100 -const int ExtraModes[] [3] =
101 -{
102 - {320,175,70},
103 - {320,200,70},
104 - {320,240,60},
105 - {320,400,70},
106 - {320,480,60},
107 - {360,200,70},
108 - {360,240,60},
109 - {360,400,70},
110 - {360,480,60},
111 - {400,300,60},
112 - {416,312,75},
113 - {512,384,60},
114 - {576,432,60},
115 - {640,200,70},
116 - {640,350,70},
117 - {640,400,70},
118 - {640,512,60},
119 - {680,384,60},
120 - {700,525,60},
121 - {720,350,70},
122 - {720,400,70},
123 - {720,450,60},
124 - {720,480,60},
125 - {800,512,60},
126 - {832,624,75},
127 - {840,525,60},
128 - {896,672,60},
129 - {928,696,60},
130 - {960,540,60},
131 - {960,600,60},
132 - {960,720,60}
133 -};
134 -const int END_EXTRAMODESCOUNT = __LINE__ - 4;
135 -const int numextramodes = END_EXTRAMODESCOUNT - START_EXTRAMODESCOUNT;
136 -
13799 const int START_LOWRESMODES = __LINE__;
138100 const int LowResModes[][3] =
139101 {
@@ -155,7 +117,7 @@
156118 { 400,300,60 }
157119 };
158120 const int END_UNCOMMONLOWRESMODES = __LINE__ - 4;
159 -const int NumUncommonLowResModes = END_LOWRESMODES - START_LOWRESMODES;
 121+const int NumUncommonLowResModes = END_UNCOMMONLOWRESMODES - START_UNCOMMONLOWRESMODES;
160122
161123 const int START_UNCOMMONSDMODES = __LINE__;
162124 const int UncommonSDModes[][3] =
@@ -223,7 +185,7 @@
224186 { 8192,4608,60 }
225187 };
226188 const int END_UHD2MODES = __LINE__ - 4;
227 -const int NumUHD2Modes = END_UHDMODES - START_UHDMODES;
 189+const int NumUHD2Modes = END_UHD2MODES - START_UHD2MODES;
228190
229191 const int START_UNCOMMONMODES = __LINE__;
230192 const int UncommonModes[][3] =
@@ -265,6 +227,7 @@
266228 {360,240,60,720,480},
267229 {360,400,70,720,400},
268230 {360,480,60,720,480},
 231+ {400,300,56,800,600},
269232 {400,300,60,800,600}
270233 };
271234 const int END_DOUBLEDMODESCOUNT = __LINE__ - 4;
@@ -290,21 +253,21 @@
291254 return false;
292255 }
293256
294 -void AddExtraResolutions(DEVMODE **array, DWORD *count)
 257+void AddExtraResolutions(DEVMODE **array, DWORD *count, const int (*modelist)[3], const int nummodes)
295258 {
296 - DEVMODE *array2 = (DEVMODE *)malloc(sizeof(DEVMODE)*5*numextramodes);
 259+ DEVMODE *array2 = (DEVMODE *)malloc(sizeof(DEVMODE) * 5 * nummodes);
297260 DEVMODE compmode = *array[0];
298261 DWORD newcount = 0;
299262 int i;
300 - if(ScanColorMode(*array,*count,8))
 263+ if (ScanColorMode(*array, *count, 8))
301264 {
302265 compmode.dmBitsPerPel = 8;
303 - for(i = 0; i < numextramodes; i++)
 266+ for (i = 0; i < nummodes; i++)
304267 {
305 - compmode.dmPelsWidth = ExtraModes[i][0];
306 - compmode.dmPelsHeight = ExtraModes[i][1];
307 - compmode.dmDisplayFrequency = ExtraModes[i][2];
308 - if(!ScanModeListNoRefresh(*array,compmode,*count))
 268+ compmode.dmPelsWidth = modelist[i][0];
 269+ compmode.dmPelsHeight = modelist[i][1];
 270+ compmode.dmDisplayFrequency = modelist[i][2];
 271+ if (!ScanModeListNoRefresh(*array, compmode, *count))
309272 {
310273 array2[newcount] = compmode;
311274 newcount++;
@@ -311,15 +274,15 @@
312275 }
313276 }
314277 }
315 - if(ScanColorMode(*array,*count,15))
 278+ if (ScanColorMode(*array, *count, 15))
316279 {
317280 compmode.dmBitsPerPel = 15;
318 - for(i = 0; i < numextramodes; i++)
 281+ for (i = 0; i < nummodes; i++)
319282 {
320 - compmode.dmPelsWidth = ExtraModes[i][0];
321 - compmode.dmPelsHeight = ExtraModes[i][1];
322 - compmode.dmDisplayFrequency = ExtraModes[i][2];
323 - if(!ScanModeListNoRefresh(*array,compmode,*count))
 283+ compmode.dmPelsWidth = modelist[i][0];
 284+ compmode.dmPelsHeight = modelist[i][1];
 285+ compmode.dmDisplayFrequency = modelist[i][2];
 286+ if (!ScanModeListNoRefresh(*array, compmode, *count))
324287 {
325288 array2[newcount] = compmode;
326289 newcount++;
@@ -326,15 +289,15 @@
327290 }
328291 }
329292 }
330 - if(ScanColorMode(*array,*count,16))
 293+ if (ScanColorMode(*array, *count, 16))
331294 {
332295 compmode.dmBitsPerPel = 16;
333 - for(i = 0; i < numextramodes; i++)
 296+ for (i = 0; i < nummodes; i++)
334297 {
335 - compmode.dmPelsWidth = ExtraModes[i][0];
336 - compmode.dmPelsHeight = ExtraModes[i][1];
337 - compmode.dmDisplayFrequency = ExtraModes[i][2];
338 - if(!ScanModeListNoRefresh(*array,compmode,*count))
 298+ compmode.dmPelsWidth = modelist[i][0];
 299+ compmode.dmPelsHeight = modelist[i][1];
 300+ compmode.dmDisplayFrequency = modelist[i][2];
 301+ if (!ScanModeListNoRefresh(*array, compmode, *count))
339302 {
340303 array2[newcount] = compmode;
341304 newcount++;
@@ -341,15 +304,15 @@
342305 }
343306 }
344307 }
345 - if(ScanColorMode(*array,*count,24))
 308+ if (ScanColorMode(*array, *count, 24))
346309 {
347310 compmode.dmBitsPerPel = 24;
348 - for(i = 0; i < numextramodes; i++)
 311+ for (i = 0; i < nummodes; i++)
349312 {
350 - compmode.dmPelsWidth = ExtraModes[i][0];
351 - compmode.dmPelsHeight = ExtraModes[i][1];
352 - compmode.dmDisplayFrequency = ExtraModes[i][2];
353 - if(!ScanModeListNoRefresh(*array,compmode,*count))
 313+ compmode.dmPelsWidth = modelist[i][0];
 314+ compmode.dmPelsHeight = modelist[i][1];
 315+ compmode.dmDisplayFrequency = modelist[i][2];
 316+ if (!ScanModeListNoRefresh(*array, compmode, *count))
354317 {
355318 array2[newcount] = compmode;
356319 newcount++;
@@ -356,15 +319,15 @@
357320 }
358321 }
359322 }
360 - if(ScanColorMode(*array,*count,32))
 323+ if (ScanColorMode(*array, *count, 32))
361324 {
362325 compmode.dmBitsPerPel = 32;
363 - for(i = 0; i < numextramodes; i++)
 326+ for (i = 0; i < nummodes; i++)
364327 {
365 - compmode.dmPelsWidth = ExtraModes[i][0];
366 - compmode.dmPelsHeight = ExtraModes[i][1];
367 - compmode.dmDisplayFrequency = ExtraModes[i][2];
368 - if(!ScanModeListNoRefresh(*array,compmode,*count))
 328+ compmode.dmPelsWidth = modelist[i][0];
 329+ compmode.dmPelsHeight = modelist[i][1];
 330+ compmode.dmDisplayFrequency = modelist[i][2];
 331+ if (!ScanModeListNoRefresh(*array, compmode, *count))
369332 {
370333 array2[newcount] = compmode;
371334 newcount++;
@@ -371,8 +334,8 @@
372335 }
373336 }
374337 }
375 - *array = (DEVMODE *)realloc(*array,(*count+newcount)*sizeof(DEVMODE));
376 - memcpy(&(*array)[*count-1],array2,newcount*sizeof(DEVMODE));
 338+ *array = (DEVMODE *)realloc(*array, (*count + newcount) * sizeof(DEVMODE));
 339+ memcpy(&(*array)[*count - 1], array2, newcount * sizeof(DEVMODE));
377340 free(array2);
378341 *count += newcount;
379342 }
@@ -636,12 +599,31 @@
637600 DiscardDuplicateModes(&modes,&modenum);
638601 if(dxglcfg.AddColorDepths) AddExtraColorModes(&modes,&modenum); // FIXME: Add color depths by bitmask
639602 DiscardDuplicateModes(&modes,&modenum);
640 - if(dxglcfg.AddModes && (dxglcfg.scaler != 0)) AddExtraResolutions(&modes,&modenum); // FIXME: Add modes by bitmask
 603+ if (dxglcfg.scaler != 0)
 604+ {
 605+ if (dxglcfg.AddModes & 1) //Common low resolutions and doubled modes
 606+ AddExtraResolutions(&modes, &modenum, LowResModes, NumLowResModes);
 607+ if (dxglcfg.AddModes & 2) //Uncommon low resolutions
 608+ AddExtraResolutions(&modes, &modenum, UncommonLowResModes, NumUncommonLowResModes);
 609+ if (dxglcfg.AddModes & 4) //Uncommon SD reosolutions
 610+ AddExtraResolutions(&modes, &modenum, UncommonSDModes, NumUncommonSDModes);
 611+ if (dxglcfg.AddModes & 8) //High definition resolutions
 612+ AddExtraResolutions(&modes, &modenum, HDModes, NumHDModes);
 613+ if (dxglcfg.AddModes & 16) //Ultra-HD resolutions
 614+ AddExtraResolutions(&modes, &modenum, UHDModes, NumUHDModes);
 615+ if (dxglcfg.AddModes & 32) //Ultra-HD resolutions above 4k
 616+ AddExtraResolutions(&modes, &modenum, UHD2Modes, NumUHD2Modes);
 617+ if (dxglcfg.AddModes & 64) //Very uncommon resolutions
 618+ AddExtraResolutions(&modes, &modenum, UncommonModes, NumUncommonModes);
 619+ }
641620 if (dxglcfg.AddModes && (_isnan(dxglcfg.postsizex) || _isnan(dxglcfg.postsizey) ||
642621 (dxglcfg.postsizex < 0.25f) || (dxglcfg.postsizey < 0.25f)))
643622 {
644 - AddDoubledResolutions(&modes, &modenum);
645 - DiscardDuplicateModes(&modes, &modenum);
 623+ if (dxglcfg.AddModes & 1)
 624+ {
 625+ AddDoubledResolutions(&modes, &modenum);
 626+ DiscardDuplicateModes(&modes, &modenum);
 627+ }
646628 }
647629 modenum--;
648630 switch(dxglcfg.SortModes)
@@ -752,7 +734,32 @@
753735 }
754736 DiscardDuplicateModes(&modes,&modenum);
755737 if(dxglcfg.AddColorDepths) AddExtraColorModes(&modes,&modenum); // FIXME: Add color depths by bitmask
756 - if(dxglcfg.AddModes && (dxglcfg.scaler != 0)) AddExtraResolutions(&modes,&modenum); // FIXME: Add modes by bitmask
 738+ if (dxglcfg.scaler != 0)
 739+ {
 740+ if (dxglcfg.AddModes & 1) //Common low resolutions and doubled modes
 741+ AddExtraResolutions(&modes, &modenum, LowResModes, NumLowResModes);
 742+ if (dxglcfg.AddModes & 2) //Uncommon low resolutions
 743+ AddExtraResolutions(&modes, &modenum, UncommonLowResModes, NumUncommonLowResModes);
 744+ if (dxglcfg.AddModes & 4) //Uncommon SD reosolutions
 745+ AddExtraResolutions(&modes, &modenum, UncommonSDModes, NumUncommonSDModes);
 746+ if (dxglcfg.AddModes & 8) //High definition resolutions
 747+ AddExtraResolutions(&modes, &modenum, HDModes, NumHDModes);
 748+ if (dxglcfg.AddModes & 16) //Ultra-HD resolutions
 749+ AddExtraResolutions(&modes, &modenum, UHDModes, NumUHDModes);
 750+ if (dxglcfg.AddModes & 32) //Ultra-HD resolutions above 4k
 751+ AddExtraResolutions(&modes, &modenum, UHD2Modes, NumUHD2Modes);
 752+ if (dxglcfg.AddModes & 64) //Very uncommon resolutions
 753+ AddExtraResolutions(&modes, &modenum, UncommonModes, NumUncommonModes);
 754+ }
 755+ if (dxglcfg.AddModes && (_isnan(dxglcfg.postsizex) || _isnan(dxglcfg.postsizey) ||
 756+ (dxglcfg.postsizex < 0.25f) || (dxglcfg.postsizey < 0.25f)))
 757+ {
 758+ if (dxglcfg.AddModes & 1)
 759+ {
 760+ AddDoubledResolutions(&modes, &modenum);
 761+ DiscardDuplicateModes(&modes, &modenum);
 762+ }
 763+ }
757764 modenum--;
758765 switch(dxglcfg.SortModes)
759766 {