| Index: cfgmgr/cfgmgr.cpp |
| — | — | @@ -430,6 +430,7 @@ |
| 431 | 431 | cfg->TexUpload = ReadDWORD(hKey,cfg->TexUpload,cfgmask->TexUpload,_T("TexUpload"));
|
| 432 | 432 | cfg->Windows8Detected = ReadBool(hKey,cfg->Windows8Detected,cfgmask->Windows8Detected,_T("Windows8Detected"));
|
| 433 | 433 | cfg->DPIScale = ReadDWORD(hKey,cfg->DPIScale,cfgmask->DPIScale,_T("DPIScale"));
|
| | 434 | + cfg->aspect = ReadFloat(hKey, cfg->aspect, cfgmask->aspect, _T("ScreenAspect"));
|
| 434 | 435 | if(!global && dll)
|
| 435 | 436 | {
|
| 436 | 437 | LPTSTR paths;
|
| — | — | @@ -487,6 +488,11 @@ |
| 488 | 489 | if(mask[0]) RegSetValueEx(hKey,name,0,REG_SZ,(BYTE*)path,(_tcslen(path)+1)*sizeof(TCHAR));
|
| 489 | 490 | else RegDeleteValue(hKey,name);
|
| 490 | 491 | }
|
| | 492 | +void WriteFloat(HKEY hKey, float value, float mask, LPCTSTR name)
|
| | 493 | +{
|
| | 494 | + if (abs(mask) > 0.5f) RegSetValueEx(hKey, name, 0, REG_DWORD, (BYTE*)&value, 4);
|
| | 495 | + else RegDeleteValue(hKey, name);
|
| | 496 | +}
|
| 491 | 497 |
|
| 492 | 498 | void WriteSettings(HKEY hKey, const DXGLCFG *cfg, const DXGLCFG *mask, bool global)
|
| 493 | 499 | {
|
| — | — | @@ -494,6 +500,7 @@ |
| 495 | 501 | if(mask) cfgmask = mask;
|
| 496 | 502 | else cfgmask = &defaultmask;
|
| 497 | 503 | memset(&defaultmask,1,sizeof(DXGLCFG));
|
| | 504 | + defaultmask.aspect = 1.0f;
|
| 498 | 505 | WriteDWORD(hKey,cfg->scaler,cfgmask->scaler,_T("ScalingMode"));
|
| 499 | 506 | WriteBool(hKey,cfg->colormode,cfgmask->colormode,_T("ChangeColorDepth"));
|
| 500 | 507 | WriteDWORD(hKey,cfg->scalingfilter,cfgmask->scalingfilter,_T("ScalingFilter"));
|
| — | — | @@ -511,6 +518,7 @@ |
| 512 | 519 | WriteDWORD(hKey,cfg->TexUpload,cfgmask->TexUpload,_T("TexUpload"));
|
| 513 | 520 | WriteBool(hKey,cfg->Windows8Detected,cfgmask->Windows8Detected,_T("Windows8Detected"));
|
| 514 | 521 | WriteDWORD(hKey,cfg->DPIScale,cfgmask->DPIScale,_T("DPIScale"));
|
| | 522 | + WriteFloat(hKey, cfg->aspect, cfgmask->aspect, _T("ScreenAspect"));
|
| 515 | 523 | }
|
| 516 | 524 |
|
| 517 | 525 | tstring newregname;
|
| Index: ddraw/glDirectDraw.cpp |
| — | — | @@ -1433,15 +1433,15 @@ |
| 1434 | 1434 | else
|
| 1435 | 1435 | {
|
| 1436 | 1436 | aspect = dxglcfg.aspect;
|
| 1437 | | - if (screenx*aspect > screeny)
|
| | 1437 | + if (screenx/aspect > screeny)
|
| 1438 | 1438 | {
|
| 1439 | | - internalx = (DWORD)((float)screeny / (float)aspect);
|
| | 1439 | + internalx = (DWORD)((float)screeny * (float)aspect);
|
| 1440 | 1440 | internaly = screeny;
|
| 1441 | 1441 | }
|
| 1442 | 1442 | else
|
| 1443 | 1443 | {
|
| 1444 | 1444 | internalx = screenx;
|
| 1445 | | - internaly = (DWORD)((float)screenx * (float)aspect);
|
| | 1445 | + internaly = (DWORD)((float)screenx / (float)aspect);
|
| 1446 | 1446 | }
|
| 1447 | 1447 | }
|
| 1448 | 1448 | if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
| — | — | @@ -1531,15 +1531,15 @@ |
| 1532 | 1532 | else
|
| 1533 | 1533 | {
|
| 1534 | 1534 | aspect = dxglcfg.aspect;
|
| 1535 | | - if (screenx*aspect > screeny)
|
| | 1535 | + if (screenx / aspect > screeny)
|
| 1536 | 1536 | {
|
| 1537 | | - internalx = (DWORD)((float)screeny / (float)aspect);
|
| | 1537 | + internalx = (DWORD)((float)screeny * (float)aspect);
|
| 1538 | 1538 | internaly = screeny;
|
| 1539 | 1539 | }
|
| 1540 | 1540 | else
|
| 1541 | 1541 | {
|
| 1542 | 1542 | internalx = screenx;
|
| 1543 | | - internaly = (DWORD)((float)screenx * (float)aspect);
|
| | 1543 | + internaly = (DWORD)((float)screenx / (float)aspect);
|
| 1544 | 1544 | }
|
| 1545 | 1545 | }
|
| 1546 | 1546 | if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
| Index: dxglcfg/dxglcfg.cpp |
| — | — | @@ -217,6 +217,69 @@ |
| 218 | 218 | EnableWindow(GetDlgItem(hWnd,IDC_APPLY),FALSE);
|
| 219 | 219 | }
|
| 220 | 220 |
|
| | 221 | +void FloatToAspect(float f, LPTSTR aspect)
|
| | 222 | +{
|
| | 223 | + float integer;
|
| | 224 | + float dummy;
|
| | 225 | + TCHAR denominator[5];
|
| | 226 | + if (f >= 1000.0f) // Clamp ridiculously wide aspects
|
| | 227 | + {
|
| | 228 | + _tcscpy(aspect, _T("1000:1"));
|
| | 229 | + return;
|
| | 230 | + }
|
| | 231 | + if (f < 0.001f) // Exclude ridiculously tall aspects, zero, and negative
|
| | 232 | + {
|
| | 233 | + _tcscpy(aspect, _T("Default"));
|
| | 234 | + return;
|
| | 235 | + }
|
| | 236 | + // Handle common aspects
|
| | 237 | + if (abs(f - 1.25f) < 0.0001f)
|
| | 238 | + {
|
| | 239 | + _tcscpy(aspect, _T("5:4"));
|
| | 240 | + return;
|
| | 241 | + }
|
| | 242 | + if (abs(f - 1.3333333f) < 0.0001f)
|
| | 243 | + {
|
| | 244 | + _tcscpy(aspect, _T("4:3"));
|
| | 245 | + return;
|
| | 246 | + }
|
| | 247 | + if (abs(f - 1.6f) < 0.0001f)
|
| | 248 | + {
|
| | 249 | + _tcscpy(aspect, _T("16:10"));
|
| | 250 | + return;
|
| | 251 | + }
|
| | 252 | + if (abs(f - 1.7777777) < 0.0001f)
|
| | 253 | + {
|
| | 254 | + _tcscpy(aspect, _T("16:9"));
|
| | 255 | + return;
|
| | 256 | + }
|
| | 257 | + if (abs(f - 1.9333333) < 0.0001f)
|
| | 258 | + {
|
| | 259 | + _tcscpy(aspect, _T("256:135"));
|
| | 260 | + return;
|
| | 261 | + }
|
| | 262 | + float fract = modf(f, &integer);
|
| | 263 | + if (fract < 0.0001f) //Handle integer aspects
|
| | 264 | + {
|
| | 265 | + _itot(integer, aspect, 10);
|
| | 266 | + _tcscat(aspect, _T(":1"));
|
| | 267 | + }
|
| | 268 | + // Finally try from 2 to 1000
|
| | 269 | + for (int i = 2; i < 1000; i++)
|
| | 270 | + {
|
| | 271 | + if (abs(modf(fract*i, &dummy)) < 0.0001f)
|
| | 272 | + {
|
| | 273 | + _itot((f*i) + .5f, aspect, 10);
|
| | 274 | + _itot(i, denominator, 10);
|
| | 275 | + _tcscat(aspect, _T(":"));
|
| | 276 | + _tcscat(aspect, denominator);
|
| | 277 | + return;
|
| | 278 | + }
|
| | 279 | + }
|
| | 280 | + // Cannot find a reasonable fractional aspect, so display as decimal.
|
| | 281 | + _stprintf(aspect, _T("%.6f"), f);
|
| | 282 | +}
|
| | 283 | +
|
| 221 | 284 | void SetCheck(HWND hWnd, int DlgItem, bool value, bool mask, bool tristate)
|
| 222 | 285 | {
|
| 223 | 286 | if(tristate && !mask)
|
| — | — | @@ -237,6 +300,22 @@ |
| 238 | 301 | SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,value,0);
|
| 239 | 302 | }
|
| 240 | 303 |
|
| | 304 | +void SetAspectCombo(HWND hWnd, int DlgItem, float value, DWORD mask, bool tristate)
|
| | 305 | +{
|
| | 306 | + TCHAR buffer[32];
|
| | 307 | + if (tristate && !mask)
|
| | 308 | + SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| | 309 | + SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 310 | + else
|
| | 311 | + {
|
| | 312 | + FloatToAspect(value, buffer);
|
| | 313 | + SetDlgItemText(hWnd, DlgItem, buffer);
|
| | 314 | + SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,
|
| | 315 | + SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)buffer), 0);
|
| | 316 | + }
|
| | 317 | +
|
| | 318 | +}
|
| | 319 | +
|
| 241 | 320 | void SetText(HWND hWnd, int DlgItem, TCHAR *value, TCHAR *mask, bool tristate)
|
| 242 | 321 | {
|
| 243 | 322 | if(tristate && (mask[0] == 0))
|
| — | — | @@ -277,6 +356,37 @@ |
| 278 | 357 | }
|
| 279 | 358 | }
|
| 280 | 359 |
|
| | 360 | +float GetAspectCombo(HWND hWnd, int DlgItem, float &mask)
|
| | 361 | +{
|
| | 362 | + TCHAR buffer[32];
|
| | 363 | + TCHAR *ptr;
|
| | 364 | + float numerator, denominator;
|
| | 365 | + GetDlgItemText(hWnd, DlgItem, buffer, 31);
|
| | 366 | + if (!_tcscmp(buffer, strdefault))
|
| | 367 | + {
|
| | 368 | + mask = 0.0f;
|
| | 369 | + return 0;
|
| | 370 | + }
|
| | 371 | + else
|
| | 372 | + {
|
| | 373 | + mask = 1.0f;
|
| | 374 | + if (!_tcscmp(buffer, _T("Default"))) return 0.0f;
|
| | 375 | + else
|
| | 376 | + {
|
| | 377 | + // Check for colon
|
| | 378 | + ptr = _tcsstr(buffer, _T(":"));
|
| | 379 | + if (ptr)
|
| | 380 | + {
|
| | 381 | + *ptr = 0;
|
| | 382 | + numerator = _ttof(buffer);
|
| | 383 | + denominator = _ttof(ptr + 1);
|
| | 384 | + return numerator / denominator;
|
| | 385 | + }
|
| | 386 | + else return _ttof(buffer);
|
| | 387 | + }
|
| | 388 | + }
|
| | 389 | +}
|
| | 390 | +
|
| 281 | 391 | void GetText(HWND hWnd, int DlgItem, TCHAR *str, TCHAR *mask)
|
| 282 | 392 | {
|
| 283 | 393 | GetDlgItemText(hWnd,DlgItem,str,MAX_PATH+1);
|
| — | — | @@ -284,10 +394,6 @@ |
| 285 | 395 | else mask[0] = 0xff;
|
| 286 | 396 | }
|
| 287 | 397 |
|
| 288 | | -void SetAspectCombo(int item, float value)
|
| 289 | | -{
|
| 290 | | -}
|
| 291 | | -
|
| 292 | 398 | LRESULT CALLBACK DXGLCfgCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 293 | 399 | {
|
| 294 | 400 | PIXELFORMATDESCRIPTOR pfd =
|
| — | — | @@ -435,6 +541,7 @@ |
| 436 | 542 | SendDlgItemMessage(hWnd,IDC_ASPECT,CB_ADDSTRING,0,(LPARAM)buffer);
|
| 437 | 543 | _tcscpy(buffer,_T("5:4"));
|
| 438 | 544 | SendDlgItemMessage(hWnd,IDC_ASPECT,CB_ADDSTRING,0,(LPARAM)buffer);
|
| | 545 | + SendDlgItemMessage(hWnd, IDC_ASPECT, CB_SETCURSEL, cfg->aspect, 0);
|
| 439 | 546 |
|
| 440 | 547 | // highres
|
| 441 | 548 | if(cfg->highres) SendDlgItemMessage(hWnd,IDC_HIGHRES,BM_SETCHECK,BST_CHECKED,0);
|
| — | — | @@ -816,6 +923,7 @@ |
| 817 | 924 | SendDlgItemMessage(hWnd,IDC_TEXTUREFORMAT,CB_ADDSTRING,0,(LPARAM)strdefault);
|
| 818 | 925 | SendDlgItemMessage(hWnd,IDC_TEXUPLOAD,CB_ADDSTRING,0,(LPARAM)strdefault);
|
| 819 | 926 | SendDlgItemMessage(hWnd, IDC_DPISCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 927 | + SendDlgItemMessage(hWnd, IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 820 | 928 | }
|
| 821 | 929 | else if(!current_app && tristate)
|
| 822 | 930 | {
|
| — | — | @@ -845,7 +953,9 @@ |
| 846 | 954 | SendDlgItemMessage(hWnd,IDC_TEXUPLOAD,CB_DELETESTRING,
|
| 847 | 955 | SendDlgItemMessage(hWnd,IDC_ASPECT3D,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
|
| 848 | 956 | SendDlgItemMessage(hWnd, IDC_DPISCALE, CB_DELETESTRING,
|
| 849 | | - SendDlgItemMessage(hWnd, IDC_ASPECT3D, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 957 | + SendDlgItemMessage(hWnd, IDC_DPISCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 958 | + SendDlgItemMessage(hWnd, IDC_ASPECT, CB_DELETESTRING,
|
| | 959 | + SendDlgItemMessage(hWnd, IDC_ASPECT, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 850 | 960 | }
|
| 851 | 961 | // Read settings into controls
|
| 852 | 962 | SetCombo(hWnd,IDC_VIDMODE,cfg->scaler,cfgmask->scaler,tristate);
|
| — | — | @@ -864,6 +974,7 @@ |
| 865 | 975 | SetCheck(hWnd,IDC_EXTRAMODES,cfg->ExtraModes,cfgmask->ExtraModes,tristate);
|
| 866 | 976 | SetText(hWnd,IDC_SHADER,cfg->shaderfile,cfgmask->shaderfile,tristate);
|
| 867 | 977 | SetCombo(hWnd, IDC_DPISCALE, cfg->DPIScale, cfgmask->DPIScale, tristate);
|
| | 978 | + SetAspectCombo(hWnd, IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
|
| 868 | 979 | }
|
| 869 | 980 | case IDC_VIDMODE:
|
| 870 | 981 | cfg->scaler = GetCombo(hWnd,IDC_VIDMODE,cfgmask->scaler);
|
| — | — | @@ -948,6 +1059,21 @@ |
| 949 | 1060 | *dirty = true;
|
| 950 | 1061 | }
|
| 951 | 1062 | break;
|
| | 1063 | + case IDC_ASPECT:
|
| | 1064 | + if (HIWORD(wParam) == CBN_KILLFOCUS)
|
| | 1065 | + {
|
| | 1066 | + cfg->aspect = GetAspectCombo(hWnd, IDC_ASPECT, cfgmask->aspect);
|
| | 1067 | + SetAspectCombo(hWnd, IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
|
| | 1068 | + EnableWindow(GetDlgItem(hWnd, IDC_APPLY), true);
|
| | 1069 | + *dirty = true;
|
| | 1070 | + }
|
| | 1071 | + else if (HIWORD(wParam) == CBN_SELCHANGE)
|
| | 1072 | + {
|
| | 1073 | + cfg->aspect = GetAspectCombo(hWnd, IDC_ASPECT, cfgmask->aspect);
|
| | 1074 | + EnableWindow(GetDlgItem(hWnd, IDC_APPLY), true);
|
| | 1075 | + *dirty = true;
|
| | 1076 | + }
|
| | 1077 | + break;
|
| 952 | 1078 | case IDC_ADD:
|
| 953 | 1079 | OPENFILENAME filename;
|
| 954 | 1080 | TCHAR selectedfile[MAX_PATH+1];
|