From f42ee1e7f8d5abd1b23f6683fb6c28036afe2c58 Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Thu, 10 Feb 2022 21:27:45 +0100 Subject: [PATCH 1/3] Added `gfx_force_43` to switch the aspect ratio to 4:3 on the fly. I had to add a new method `forceResizeWindow` for this. Also added NO_LOAD_PROGRESS_DISPLAY. --- src/DisplayLoadProgress.cpp | 2 ++ src/DisplayWindow.h | 1 + src/native/Native.cpp | 24 ++++++++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/DisplayLoadProgress.cpp b/src/DisplayLoadProgress.cpp index 647ca326..d47b9f50 100644 --- a/src/DisplayLoadProgress.cpp +++ b/src/DisplayLoadProgress.cpp @@ -11,6 +11,7 @@ void displayLoadProgress(const wchar_t *format, ...) { +#ifndef NO_LOAD_PROGRESS_DISPLAY va_list args; wchar_t wbuf[INFO_BUF]; char buf[INFO_BUF]; @@ -46,4 +47,5 @@ void displayLoadProgress(const wchar_t *format, ...) if (pBuffer != nullptr) gfxContext.bindFramebuffer(graphics::bufferTarget::DRAW_FRAMEBUFFER, pBuffer->m_FBO); +#endif } diff --git a/src/DisplayWindow.h b/src/DisplayWindow.h index a1cf83d4..6b6a53d2 100644 --- a/src/DisplayWindow.h +++ b/src/DisplayWindow.h @@ -38,6 +38,7 @@ public: bool isFullscreen() const { return m_bFullscreen; } bool isAdjustScreen() const { return m_bAdjustScreen; } bool isResizeWindow() const { return m_bResizeWindow; } + void forceResizeWindow() { _resizeWindow(); } GraphicsDrawer & getDrawer() { return m_drawer; } diff --git a/src/native/Native.cpp b/src/native/Native.cpp index acc8f191..4412f1d4 100644 --- a/src/native/Native.cpp +++ b/src/native/Native.cpp @@ -15,7 +15,8 @@ #define START_WIDTH 1280 #define START_HEIGHT 720 -static u64 g_width = START_WIDTH; +static u64 g_originalWidth = START_WIDTH;//Size set by the end-user +static u64 g_width = START_WIDTH;//Current size static u64 g_height = START_HEIGHT; extern "C" { @@ -92,9 +93,11 @@ N64Regs::~N64Regs() { extern "C" { + //Called when the end-user changes the window size void gfx_resize(long width, long height) { - g_width = width; + g_originalWidth = width; + g_width = width; g_height = height; config.video.windowedWidth = g_width; config.video.windowedHeight = g_height; @@ -133,6 +136,23 @@ extern "C" { api().RomOpen(romName); } + void gfx_force_43(bool enable) { + const u32 newAspectRatio = enable ? 1 : 3; + + if (config.frameBufferEmulation.aspect == newAspectRatio) + return;//Already set + + config.frameBufferEmulation.aspect = enable ? 1 : 3; + dwnd().forceResizeWindow();//Inform GLideN64 about the change + + //Calculate new width + auto newWidth = g_originalWidth; + if (enable) + newWidth = (g_height * 4) / 3; + + g_width = newWidth; + } + void gfx_shutdown() { RDRAMSize = 0; api().RomClosed(); From 455310da1c6ba992253eb6212fecc2f33d5f623e Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Thu, 10 Feb 2022 22:07:23 +0100 Subject: [PATCH 2/3] Fixed a tiny but important mistake. --- src/DisplayWindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DisplayWindow.h b/src/DisplayWindow.h index 6b6a53d2..92383eb4 100644 --- a/src/DisplayWindow.h +++ b/src/DisplayWindow.h @@ -38,7 +38,7 @@ public: bool isFullscreen() const { return m_bFullscreen; } bool isAdjustScreen() const { return m_bAdjustScreen; } bool isResizeWindow() const { return m_bResizeWindow; } - void forceResizeWindow() { _resizeWindow(); } + void forceResizeWindow() { m_bResizeWindow = true; resizeWindow(); } GraphicsDrawer & getDrawer() { return m_drawer; } From fb108abab7fae407987854d932245a5f715ae626 Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Thu, 10 Feb 2022 22:14:38 +0100 Subject: [PATCH 3/3] Fixed an issue when the user is resizing the window while in 4:3 mode. --- src/native/Native.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/native/Native.cpp b/src/native/Native.cpp index 4412f1d4..3ee314dd 100644 --- a/src/native/Native.cpp +++ b/src/native/Native.cpp @@ -97,11 +97,16 @@ extern "C" void gfx_resize(long width, long height) { g_originalWidth = width; - g_width = width; + + if (config.frameBufferEmulation.aspect == 1)//Running in 4:3 mode? + g_width = (height*4)/3; + else + g_width = width; g_height = height; - config.video.windowedWidth = g_width; - config.video.windowedHeight = g_height; - dwnd().setWindowSize(g_width, g_height); + + config.video.windowedWidth = width; + config.video.windowedHeight = height; + dwnd().setWindowSize(width, height); } }