From 5ad5e16a405ab438211879299f3e78ee01453e82 Mon Sep 17 00:00:00 2001 From: retr0s4ge Date: Mon, 9 Jul 2018 01:03:35 +0200 Subject: [PATCH 1/4] (Windows Frontend) Allow screen resizing in horizontal display layout. The right hand screen is allowed to be resized in horizontal screen layout to enable the window or full screen display to better utilize the screen area. Changes: 1- Modify scaling, resizing and update functions to allow for new screen resizing ratio 2- Modify touch input scaling (incl. HUD editing) to adapt to different screen sizes 3- Add GUI menu for user to select the screen resizing ratio 4- Implement saving/loading settings from file similar to other settings --- desmume/src/frontend/windows/main.cpp | 98 +++++++++++++++++++---- desmume/src/frontend/windows/resource.h | 8 +- desmume/src/frontend/windows/resources.rc | 9 +++ 3 files changed, 100 insertions(+), 15 deletions(-) diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index db548f378..daa3f31a3 100755 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -519,6 +519,8 @@ bool continuousframeAdvancing = false; unsigned short windowSize = 0; +float screenSizeRatio = 1.0f; + /*const u32 gapColors[16] = { Color::Gray, Color::Brown, @@ -714,7 +716,10 @@ void ScaleScreen(float factor, bool user) MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor), (int)(video.rotatedheightgap() * factor)); else if (video.layout == 1) - MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor * 2), (int)(video.rotatedheightgap() * factor / 2)); + { + factor /= screenSizeRatio; + MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor * 2), (int)(video.rotatedheightgap() * factor * screenSizeRatio / 2)); + } else if (video.layout == 2) MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor), (int)(video.rotatedheightgap() * factor / 2)); @@ -868,22 +873,50 @@ void ToDSScreenRelativeCoords(s32& x, s32& y, int whichScreen) { bool topOnTop = (video.swap == 0) || (video.swap == 2 && isMainGPUFirst) || (video.swap == 3 && !isMainGPUFirst); bool bottom = (whichScreen > 0); - if(topOnTop) - x += bottom ? -GPU_FRAMEBUFFER_NATIVE_WIDTH : 0; + if (topOnTop) + { + if (bottom) + { + x += -GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio; + x /= (2 - screenSizeRatio); + y /= (2 - screenSizeRatio); + } + } else - x += (x < GPU_FRAMEBUFFER_NATIVE_WIDTH) ? (bottom ? 0 : GPU_FRAMEBUFFER_NATIVE_WIDTH) : (bottom ? 0 : -GPU_FRAMEBUFFER_NATIVE_WIDTH); + { + if (x < GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio) + { + if (bottom == 0) + x += GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio; + } + else + { + if (bottom == 0) + x += -GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio; + } + x /= screenSizeRatio; + } } else { + x /= screenSizeRatio; if(x >= GPU_FRAMEBUFFER_NATIVE_WIDTH) { x -= GPU_FRAMEBUFFER_NATIVE_WIDTH; - y += GPU_FRAMEBUFFER_NATIVE_HEIGHT; + x *= screenSizeRatio / (2 - screenSizeRatio); + y += GPU_FRAMEBUFFER_NATIVE_HEIGHT * (2 - screenSizeRatio); + y /= (2 - screenSizeRatio); + if (y < GPU_FRAMEBUFFER_NATIVE_HEIGHT) + y = GPU_FRAMEBUFFER_NATIVE_HEIGHT; } else if(x < 0) { - x += GPU_FRAMEBUFFER_NATIVE_WIDTH; - y -= GPU_FRAMEBUFFER_NATIVE_HEIGHT; + x = 0; + } + else + { + if (y > GPU_FRAMEBUFFER_NATIVE_HEIGHT) + y = GPU_FRAMEBUFFER_NATIVE_HEIGHT; } } } @@ -1161,8 +1194,8 @@ void UpdateWndRects(HWND hwnd) if (video.layout == 1) //horizontal { - rc = CalculateDisplayLayoutWrapper(rc, GPU_FRAMEBUFFER_NATIVE_WIDTH * 2, GPU_FRAMEBUFFER_NATIVE_HEIGHT, tbheight, maximized); - + rc = CalculateDisplayLayoutWrapper(rc, GPU_FRAMEBUFFER_NATIVE_WIDTH * 2, (int)((float)(GPU_FRAMEBUFFER_NATIVE_HEIGHT * screenSizeRatio)), tbheight, maximized); + wndWidth = (rc.bottom - rc.top) - tbheight; wndHeight = (rc.right - rc.left); @@ -1176,20 +1209,20 @@ void UpdateWndRects(HWND hwnd) ClientToScreen(hwnd, &ptClient); MainScreenRect.left = ptClient.x; MainScreenRect.top = ptClient.y; - ptClient.x = (rc.left + oneScreenHeight); + ptClient.x = (rc.left + oneScreenHeight * screenSizeRatio); ptClient.y = (rc.top + wndWidth); ClientToScreen(hwnd, &ptClient); MainScreenRect.right = ptClient.x; MainScreenRect.bottom = ptClient.y; // Sub screen - ptClient.x = (rc.left + oneScreenHeight); + ptClient.x = (rc.left + oneScreenHeight * screenSizeRatio); ptClient.y = rc.top; ClientToScreen(hwnd, &ptClient); SubScreenRect.left = ptClient.x; SubScreenRect.top = ptClient.y; - ptClient.x = (rc.left + oneScreenHeight + oneScreenHeight); - ptClient.y = (rc.top + wndWidth); + ptClient.x = (rc.left + oneScreenHeight * 2); + ptClient.y = (rc.top + wndWidth * (2 - screenSizeRatio)); ClientToScreen(hwnd, &ptClient); SubScreenRect.right = ptClient.x; SubScreenRect.bottom = ptClient.y; @@ -3008,6 +3041,7 @@ int _main() msgbox = &msgBoxWnd; char text[80] = {0}; + char scrRatStr[4] = "1.0"; path.ReadPathSettings(); @@ -3071,6 +3105,8 @@ int _main() GetPrivateProfileString("MicSettings", "MicSampleFile", "micsample.raw", MicSampleName, MAX_PATH, IniName); RefreshMicSettings(); + GetPrivateProfileString("Display", "Screen Size Ratio", "1.0", scrRatStr, 4, IniName); + screenSizeRatio = atof(scrRatStr); video.screengap = GetPrivateProfileInt("Display", "ScreenGap", 0, IniName); SeparationBorderDrag = GetPrivateProfileBool("Display", "Window Split Border Drag", true, IniName); ScreenGapColor = GetPrivateProfileInt("Display", "ScreenGapColor", 0xFFFFFF, IniName); @@ -4629,6 +4665,20 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM MainWindow->checkMenu(IDM_ALWAYS_ON_TOP, (GetStyle()&DWS_ALWAYSONTOP)!=0); MainWindow->checkMenu(IDM_LOCKDOWN, (GetStyle()&DWS_LOCKDOWN)!=0); + //Screen Size Ratio + MainWindow->checkMenu(IDC_SCR_RATIO_1p0, ((int)(screenSizeRatio*10)==10)); + MainWindow->checkMenu(IDC_SCR_RATIO_1p1, ((int)(screenSizeRatio*10)==11)); + MainWindow->checkMenu(IDC_SCR_RATIO_1p2, ((int)(screenSizeRatio*10)==12)); + MainWindow->checkMenu(IDC_SCR_RATIO_1p3, ((int)(screenSizeRatio*10)==13)); + MainWindow->checkMenu(IDC_SCR_RATIO_1p4, ((int)(screenSizeRatio*10)==14)); + MainWindow->checkMenu(IDC_SCR_RATIO_1p5, ((int)(screenSizeRatio*10)==15)); + DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p0, (video.layout == 1)); + DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p1, (video.layout == 1)); + DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p2, (video.layout == 1)); + DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p3, (video.layout == 1)); + DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p4, (video.layout == 1)); + DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p5, (video.layout == 1)); + //Screen Separation MainWindow->checkMenu(IDM_SCREENSEP_NONE, ((video.screengap==kGapNone))); MainWindow->checkMenu(IDM_SCREENSEP_BORDER, ((video.screengap==kGapBorder))); @@ -4920,7 +4970,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM else if (video.layout == 1) { minX = video.rotatedwidthgap() * 2; - minY = video.rotatedheightgap() / 2; + minY = video.rotatedheightgap() * screenSizeRatio / 2; } else if (video.layout == 2) { @@ -6278,6 +6328,26 @@ DOKEYDOWN: WritePrivateProfileInt("Video","Window Size",windowSize,IniName); break; + case IDC_SCR_RATIO_1p0: + case IDC_SCR_RATIO_1p1: + case IDC_SCR_RATIO_1p2: + case IDC_SCR_RATIO_1p3: + case IDC_SCR_RATIO_1p4: + case IDC_SCR_RATIO_1p5: + { + screenSizeRatio = LOWORD(wParam) - IDC_SCR_RATIO_1p0; + screenSizeRatio = screenSizeRatio * 0.1 + 1; + + RECT rc; + GetClientRect(hwnd, &rc); + MainWindow->setClientSize((int)((rc.right - rc.left + 8) / screenSizeRatio), rc.bottom - rc.top); + + char scrRatStr[4] = "1.0"; + sprintf(scrRatStr, "%.1f", screenSizeRatio); + WritePrivateProfileString("Display", "Screen Size Ratio", scrRatStr, IniName); + } + return 0; + case IDC_VIEW_PADTOINTEGER: PadToInteger = (!PadToInteger)?TRUE:FALSE; WritePrivateProfileInt("Video","Window Pad To Integer",PadToInteger,IniName); diff --git a/desmume/src/frontend/windows/resource.h b/desmume/src/frontend/windows/resource.h index 46de3140a..b2bc38c69 100644 --- a/desmume/src/frontend/windows/resource.h +++ b/desmume/src/frontend/windows/resource.h @@ -958,6 +958,12 @@ #define IDM_RENDER_3XBRZ 40123 #define IDM_RENDER_4XBRZ 40124 #define IDM_RENDER_5XBRZ 40125 +#define IDC_SCR_RATIO_1p0 40143 +#define IDC_SCR_RATIO_1p1 40144 +#define IDC_SCR_RATIO_1p2 40145 +#define IDC_SCR_RATIO_1p3 40146 +#define IDC_SCR_RATIO_1p4 40147 +#define IDC_SCR_RATIO_1p5 40148 #define ID_LABEL_HK3b 44670 #define ID_LABEL_HK3c 44671 #define ID_LABEL_HK3d 44672 @@ -1072,7 +1078,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 128 -#define _APS_NEXT_COMMAND_VALUE 40126 +#define _APS_NEXT_COMMAND_VALUE 40149 #define _APS_NEXT_CONTROL_VALUE 1065 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/desmume/src/frontend/windows/resources.rc b/desmume/src/frontend/windows/resources.rc index e2c99e650..455172ed0 100644 --- a/desmume/src/frontend/windows/resources.rc +++ b/desmume/src/frontend/windows/resources.rc @@ -1609,6 +1609,15 @@ BEGIN MENUITEM "&Always On Top", IDM_ALWAYS_ON_TOP MENUITEM "&Lockdown", IDM_LOCKDOWN END + POPUP "Screen Size Ratio (L:R)" + BEGIN + MENUITEM "1.0 : 1.0", IDC_SCR_RATIO_1p0 + MENUITEM "1.1 : 0.9", IDC_SCR_RATIO_1p1 + MENUITEM "1.2 : 0.8", IDC_SCR_RATIO_1p2 + MENUITEM "1.3 : 0.7", IDC_SCR_RATIO_1p3 + MENUITEM "1.4 : 0.6", IDC_SCR_RATIO_1p4 + MENUITEM "1.5 : 0.5", IDC_SCR_RATIO_1p5 + END POPUP "Screen &Gap" BEGIN MENUITEM "&None\t(0 px)", IDM_SCREENSEP_NONE From 9dd7e0f451edd33ba8d481f6efd761915fe1f257 Mon Sep 17 00:00:00 2001 From: retr0s4ge Date: Thu, 12 Jul 2018 00:13:43 +0200 Subject: [PATCH 2/4] Adjust the aspect ratio of the resized screen to follow the user setting, and modify input scaling accordingly. --- desmume/src/frontend/windows/main.cpp | 61 ++++++++++++--------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index daa3f31a3..297ff1025 100755 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -717,8 +717,7 @@ void ScaleScreen(float factor, bool user) else if (video.layout == 1) { - factor /= screenSizeRatio; - MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor * 2), (int)(video.rotatedheightgap() * factor * screenSizeRatio / 2)); + MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor * 2 / screenSizeRatio), (int)(video.rotatedheightgap() * factor / 2)); } else if (video.layout == 2) @@ -873,49 +872,41 @@ void ToDSScreenRelativeCoords(s32& x, s32& y, int whichScreen) { bool topOnTop = (video.swap == 0) || (video.swap == 2 && isMainGPUFirst) || (video.swap == 3 && !isMainGPUFirst); bool bottom = (whichScreen > 0); - if (topOnTop) + if(topOnTop && bottom) { - if (bottom) - { - x += -GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio; - x /= (2 - screenSizeRatio); - y /= (2 - screenSizeRatio); - } + x = (x - GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio) / (2 - screenSizeRatio); + if(ForceRatio) + y *= screenSizeRatio / (2 - screenSizeRatio); } else { - if (x < GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio) - { - if (bottom == 0) - x += GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio; - } - else - { - if (bottom == 0) - x += -GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio; - } x /= screenSizeRatio; + if(!bottom) + { + if(x < GPU_FRAMEBUFFER_NATIVE_WIDTH) + x += GPU_FRAMEBUFFER_NATIVE_WIDTH; + else + x += -GPU_FRAMEBUFFER_NATIVE_WIDTH; + } } } else { - x /= screenSizeRatio; - if(x >= GPU_FRAMEBUFFER_NATIVE_WIDTH) + if(x >= GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio) { - x -= GPU_FRAMEBUFFER_NATIVE_WIDTH; - x *= screenSizeRatio / (2 - screenSizeRatio); - y += GPU_FRAMEBUFFER_NATIVE_HEIGHT * (2 - screenSizeRatio); - y /= (2 - screenSizeRatio); - if (y < GPU_FRAMEBUFFER_NATIVE_HEIGHT) + x = (x - GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio) / (2 - screenSizeRatio); + if(ForceRatio) + y *= screenSizeRatio / (2 - screenSizeRatio); + y += GPU_FRAMEBUFFER_NATIVE_HEIGHT; + if(y < GPU_FRAMEBUFFER_NATIVE_HEIGHT) y = GPU_FRAMEBUFFER_NATIVE_HEIGHT; } - else if(x < 0) - { - x = 0; - } else { - if (y > GPU_FRAMEBUFFER_NATIVE_HEIGHT) + x /= screenSizeRatio; + if(x < 0) + x = 0; + if(y > GPU_FRAMEBUFFER_NATIVE_HEIGHT) y = GPU_FRAMEBUFFER_NATIVE_HEIGHT; } } @@ -1194,7 +1185,7 @@ void UpdateWndRects(HWND hwnd) if (video.layout == 1) //horizontal { - rc = CalculateDisplayLayoutWrapper(rc, GPU_FRAMEBUFFER_NATIVE_WIDTH * 2, (int)((float)(GPU_FRAMEBUFFER_NATIVE_HEIGHT * screenSizeRatio)), tbheight, maximized); + rc = CalculateDisplayLayoutWrapper(rc, (int)((float)GPU_FRAMEBUFFER_NATIVE_WIDTH * 2 / screenSizeRatio), GPU_FRAMEBUFFER_NATIVE_HEIGHT, tbheight, maximized); wndWidth = (rc.bottom - rc.top) - tbheight; wndHeight = (rc.right - rc.left); @@ -1222,7 +1213,10 @@ void UpdateWndRects(HWND hwnd) SubScreenRect.left = ptClient.x; SubScreenRect.top = ptClient.y; ptClient.x = (rc.left + oneScreenHeight * 2); - ptClient.y = (rc.top + wndWidth * (2 - screenSizeRatio)); + if(ForceRatio) + ptClient.y = (rc.top + oneScreenWidth * (2 - screenSizeRatio)); + else + ptClient.y = (rc.top + wndWidth); ClientToScreen(hwnd, &ptClient); SubScreenRect.right = ptClient.x; SubScreenRect.bottom = ptClient.y; @@ -6356,6 +6350,7 @@ DOKEYDOWN: case IDC_FORCERATIO: ForceRatio = (!ForceRatio)?TRUE:FALSE; + if((int)(screenSizeRatio * 10) > 10) UpdateWndRects(hwnd); if(ForceRatio) FixAspectRatio(); WritePrivateProfileInt("Video","Window Force Ratio",ForceRatio,IniName); From d17a01d0c3c3b1ce19e2f629ad39dcbb66faf257 Mon Sep 17 00:00:00 2001 From: retr0s4ge Date: Fri, 13 Jul 2018 14:43:02 +0200 Subject: [PATCH 3/4] Center the resized screen vertically by default and add a check menu setting to change that if required. --- desmume/src/frontend/windows/main.cpp | 27 +++++++++++++++++++++-- desmume/src/frontend/windows/resource.h | 3 ++- desmume/src/frontend/windows/resources.rc | 2 ++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index 297ff1025..e5aa655a3 100755 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -520,6 +520,7 @@ bool continuousframeAdvancing = false; unsigned short windowSize = 0; float screenSizeRatio = 1.0f; +bool vCenterResizedScr = true; /*const u32 gapColors[16] = { Color::Gray, @@ -876,7 +877,11 @@ void ToDSScreenRelativeCoords(s32& x, s32& y, int whichScreen) { x = (x - GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio) / (2 - screenSizeRatio); if(ForceRatio) + { y *= screenSizeRatio / (2 - screenSizeRatio); + if (vCenterResizedScr) + y += GPU_FRAMEBUFFER_NATIVE_HEIGHT * (1 - screenSizeRatio) / (2 - screenSizeRatio); + } } else { @@ -896,7 +901,11 @@ void ToDSScreenRelativeCoords(s32& x, s32& y, int whichScreen) { x = (x - GPU_FRAMEBUFFER_NATIVE_WIDTH * screenSizeRatio) / (2 - screenSizeRatio); if(ForceRatio) + { y *= screenSizeRatio / (2 - screenSizeRatio); + if (vCenterResizedScr) + y += GPU_FRAMEBUFFER_NATIVE_HEIGHT * (1 - screenSizeRatio) / (2 - screenSizeRatio); + } y += GPU_FRAMEBUFFER_NATIVE_HEIGHT; if(y < GPU_FRAMEBUFFER_NATIVE_HEIGHT) y = GPU_FRAMEBUFFER_NATIVE_HEIGHT; @@ -1193,6 +1202,7 @@ void UpdateWndRects(HWND hwnd) ratio = ((float)wndHeight / (float)512); oneScreenHeight = (int)((float)GPU_FRAMEBUFFER_NATIVE_WIDTH * ratio); int oneScreenWidth = (int)((float)GPU_FRAMEBUFFER_NATIVE_HEIGHT * ratio); + int vResizedScrOffset = 0; // Main screen ptClient.x = rc.left; @@ -1208,13 +1218,15 @@ void UpdateWndRects(HWND hwnd) // Sub screen ptClient.x = (rc.left + oneScreenHeight * screenSizeRatio); - ptClient.y = rc.top; + if(vCenterResizedScr && ForceRatio) + vResizedScrOffset = (wndWidth - oneScreenWidth * (2 - screenSizeRatio)) / 2; + ptClient.y = rc.top + vResizedScrOffset; ClientToScreen(hwnd, &ptClient); SubScreenRect.left = ptClient.x; SubScreenRect.top = ptClient.y; ptClient.x = (rc.left + oneScreenHeight * 2); if(ForceRatio) - ptClient.y = (rc.top + oneScreenWidth * (2 - screenSizeRatio)); + ptClient.y = (rc.top + vResizedScrOffset + oneScreenWidth * (2 - screenSizeRatio)); else ptClient.y = (rc.top + wndWidth); ClientToScreen(hwnd, &ptClient); @@ -3101,6 +3113,7 @@ int _main() GetPrivateProfileString("Display", "Screen Size Ratio", "1.0", scrRatStr, 4, IniName); screenSizeRatio = atof(scrRatStr); + vCenterResizedScr = GetPrivateProfileBool("Display", "Vertically Center Resized Screen", 1, IniName); video.screengap = GetPrivateProfileInt("Display", "ScreenGap", 0, IniName); SeparationBorderDrag = GetPrivateProfileBool("Display", "Window Split Border Drag", true, IniName); ScreenGapColor = GetPrivateProfileInt("Display", "ScreenGapColor", 0xFFFFFF, IniName); @@ -4666,12 +4679,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM MainWindow->checkMenu(IDC_SCR_RATIO_1p3, ((int)(screenSizeRatio*10)==13)); MainWindow->checkMenu(IDC_SCR_RATIO_1p4, ((int)(screenSizeRatio*10)==14)); MainWindow->checkMenu(IDC_SCR_RATIO_1p5, ((int)(screenSizeRatio*10)==15)); + MainWindow->checkMenu(IDC_SCR_VCENTER, (vCenterResizedScr == 1)); DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p0, (video.layout == 1)); DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p1, (video.layout == 1)); DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p2, (video.layout == 1)); DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p3, (video.layout == 1)); DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p4, (video.layout == 1)); DesEnableMenuItem(mainMenu, IDC_SCR_RATIO_1p5, (video.layout == 1)); + DesEnableMenuItem(mainMenu, IDC_SCR_VCENTER, (video.layout == 1)); //Screen Separation MainWindow->checkMenu(IDM_SCREENSEP_NONE, ((video.screengap==kGapNone))); @@ -6342,6 +6357,14 @@ DOKEYDOWN: } return 0; + case IDC_SCR_VCENTER: + { + vCenterResizedScr = (!vCenterResizedScr) ? TRUE : FALSE; + UpdateWndRects(hwnd); + WritePrivateProfileInt("Display", "Vertically Center Resized Screen", vCenterResizedScr, IniName); + } + return 0; + case IDC_VIEW_PADTOINTEGER: PadToInteger = (!PadToInteger)?TRUE:FALSE; WritePrivateProfileInt("Video","Window Pad To Integer",PadToInteger,IniName); diff --git a/desmume/src/frontend/windows/resource.h b/desmume/src/frontend/windows/resource.h index b2bc38c69..b4d6d7997 100644 --- a/desmume/src/frontend/windows/resource.h +++ b/desmume/src/frontend/windows/resource.h @@ -964,6 +964,7 @@ #define IDC_SCR_RATIO_1p3 40146 #define IDC_SCR_RATIO_1p4 40147 #define IDC_SCR_RATIO_1p5 40148 +#define IDC_SCR_VCENTER 40149 #define ID_LABEL_HK3b 44670 #define ID_LABEL_HK3c 44671 #define ID_LABEL_HK3d 44672 @@ -1078,7 +1079,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 128 -#define _APS_NEXT_COMMAND_VALUE 40149 +#define _APS_NEXT_COMMAND_VALUE 40150 #define _APS_NEXT_CONTROL_VALUE 1065 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/desmume/src/frontend/windows/resources.rc b/desmume/src/frontend/windows/resources.rc index 455172ed0..bd5b841e1 100644 --- a/desmume/src/frontend/windows/resources.rc +++ b/desmume/src/frontend/windows/resources.rc @@ -1617,6 +1617,8 @@ BEGIN MENUITEM "1.3 : 0.7", IDC_SCR_RATIO_1p3 MENUITEM "1.4 : 0.6", IDC_SCR_RATIO_1p4 MENUITEM "1.5 : 0.5", IDC_SCR_RATIO_1p5 + MENUITEM SEPARATOR + MENUITEM "Center Vertically", IDC_SCR_VCENTER END POPUP "Screen &Gap" BEGIN From 43a9734ba2cc01ad85fdc4645fe2fe1258c001e7 Mon Sep 17 00:00:00 2001 From: retr0s4ge Date: Fri, 13 Jul 2018 16:43:43 +0200 Subject: [PATCH 4/4] Fill the areas above and below the resized screen with black when using DirectDraw display method. This is needed to remove garbage from the window after resizing the screen. OpenGL display method already does this. --- desmume/src/frontend/windows/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index e5aa655a3..a92eec6c9 100755 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -1952,6 +1952,11 @@ static void DD_DoDisplay() DD_FillRect(ddraw.surface.primary,0,bottom,left,wr.bottom,RGB(0,0,128)); //bottomleft DD_FillRect(ddraw.surface.primary,left,bottom,right,wr.bottom,RGB(255,0,255)); //bottomcenter DD_FillRect(ddraw.surface.primary,right,bottom,wr.right,wr.bottom,RGB(0,255,255)); //bottomright + if (video.layout == 1) + { + DD_FillRect(ddraw.surface.primary, SubScreenRect.left, wr.top, wr.right, SubScreenRect.top, RGB(0, 0, 0)); //Top gap left when centering the resized screen + DD_FillRect(ddraw.surface.primary, SubScreenRect.left, SubScreenRect.bottom, wr.right, wr.bottom, RGB(0, 0, 0)); //Bottom gap left when centering the resized screen + } } }