DXGL r418 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r417‎ | r418 | r419 >
Date:00:19, 4 April 2014
Author:admin
Status:new
Tags:
Comment:
Custom aspect correction for scaler mode 5. Note that this will only work properly if the display is set to a mode that has square pixels on the screen, and no match is found when changing modes.
Modified paths:
  • /cfgmgr/ReadMe.txt (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: cfgmgr/ReadMe.txt
@@ -133,7 +133,7 @@
134134
135135 Member aspect
136136 REG_DWORD HKCU\DXGL\<app>\ScreenAspect
137 -Screen aspect ratio to simulate, if the scaler is 1 or 4.
 137+Screen aspect ratio to simulate, if the scaler is 1 or 5.
138138 Stored as a 32-bit float encoded as a DWORD.
139139 If zero, negative, or an invalid value, use automatic ratio based on square pixels.
140140 Positive values indicate a specific screen aspect ratio.
Index: ddraw/glDirectDraw.cpp
@@ -1512,20 +1512,37 @@
15131513 screenx = newmode2.dmPelsWidth;
15141514 primaryy = dwHeight;
15151515 screeny = newmode2.dmPelsHeight;
1516 - aspect = (float)dwWidth / (float)dwHeight;
1517 - xmul = (float)screenx / (float)dwWidth;
1518 - ymul = (float)screeny / (float)dwHeight;
1519 - if((float)dwWidth*(float)ymul > (float)screenx)
 1516+ if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
15201517 {
1521 - internalx = (DWORD)((float)dwWidth * (float)xmul);
1522 - internaly = (DWORD)((float)dwHeight * (float)xmul);
 1518+ aspect = (float)dwWidth / (float)dwHeight;
 1519+ xmul = (float)screenx / (float)dwWidth;
 1520+ ymul = (float)screeny / (float)dwHeight;
 1521+ if ((float)dwWidth*(float)ymul > (float)screenx)
 1522+ {
 1523+ internalx = (DWORD)((float)dwWidth * (float)xmul);
 1524+ internaly = (DWORD)((float)dwHeight * (float)xmul);
 1525+ }
 1526+ else
 1527+ {
 1528+ internalx = (DWORD)((float)dwWidth * (float)ymul);
 1529+ internaly = (DWORD)((float)dwHeight * (float)ymul);
 1530+ }
15231531 }
15241532 else
15251533 {
1526 - internalx = (DWORD)((float)dwWidth * (float)ymul);
1527 - internaly = (DWORD)((float)dwHeight * (float)ymul);
 1534+ aspect = dxglcfg.aspect;
 1535+ if (screenx*aspect > screeny)
 1536+ {
 1537+ internalx = (DWORD)((float)screeny / (float)aspect);
 1538+ internaly = screeny;
 1539+ }
 1540+ else
 1541+ {
 1542+ internalx = screenx;
 1543+ internaly = (DWORD)((float)screenx * (float)aspect);
 1544+ }
15281545 }
1529 - if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
 1546+ if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
15301547 else internalbpp = screenbpp = newmode2.dmBitsPerPel;
15311548 if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
15321549 else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;