From 85212e901401426e5dcd425c860e88cc406024b4 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 10 Apr 2023 16:48:03 +0300 Subject: [PATCH] VGA mode resolution autoswitch update --- drawing.cpp | 16 +++++++++++----- od-win32/win32_scaler.cpp | 20 ++++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 3e48f381..4909cef5 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -4138,13 +4138,19 @@ static void init_drawing_frame (void) vidinfo->gfx_vresolution_reserved = VRES_DOUBLE; graphics_reset(false); } - int newres = largest_res; - if (htotal < 190) - newres = largest_res + 1; - if (newres < RES_HIRES) + int newres = RES_HIRES; + int hres = (2 * htotal) << largest_res; + if (hres > 1000) { + newres = RES_SUPERHIRES; + } else { + newres = RES_HIRES; + } + if (newres < RES_HIRES) { newres = RES_HIRES; - if (newres > RES_MAX) + } + if (newres > RES_MAX) { newres = RES_MAX; + } if (changed_prefs.gfx_resolution != newres) { autoswitch_old_resolution = RES_HIRES; write_log(_T("Programmed mode autores = %d -> %d (%d)\n"), changed_prefs.gfx_resolution, newres, largest_res); diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index 13b5e306..574383fd 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -451,15 +451,23 @@ void getfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, int float multadd = 1.0f / (1 << currprefs.gf[idx].gfx_filter_integerscalelimit); if (cw2 > maxw || ch2 > maxh) { - while (cw2 / mult - adjw > maxw || ch2 / mult - adjh > maxh) + while (cw2 / mult - adjw > maxw || ch2 / mult - adjh > maxh) { mult += multadd; - maxw = (int)(maxw * mult); - maxh = (int)(maxh * mult); + } + float multx = mult, multy = mult; + maxw = (int)(maxw * multx); + maxh = (int)(maxh * multy); } else { - while (cw2 * (mult + multadd) - adjw <= maxw && ch2 * (mult + multadd) - adjh <= maxh) + while (cw2 * (mult + multadd) - adjw <= maxw && ch2 * (mult + multadd) - adjh <= maxh) { mult += multadd; - maxw = (int)((maxw + mult - multadd) / mult); - maxh = (int)((maxh + mult - multadd) / mult); + } + float multx = mult, multy = mult; + // if width is smaller than height, double width (programmed modes) + if (cw2 * (mult + multadd) - adjw <= maxw && cw2 < ch2) { + multx += multadd; + } + maxw = (int)((maxw + multx - multadd) / multx); + maxh = (int)((maxh + multy - multadd) / multy); } *mode = 1; -- 2.47.3