From 25604512f4bf7cdf370115a32548de0ae251d6ed Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Mon, 19 Dec 2022 00:13:08 +0000 Subject: [PATCH] The model 3 (actually model 1,2 and 3) all used some crazy refresh rate of 57.524hz. If your screen refresh rate is 60hz, supermodel will work fine, but really run too fast. Anyway if you create a custom refresh rate, supermodel will automatically pick this, and set it when the emulator is in fullscreen mode. Apparently this works with most monitors, even cheapo low end ones. To active set your command line to: -res=1920,1080 -vsync -fullscreen -true-hz Replace the resolution with whatever your monitor's native resolution is. --- Src/OSD/SDL/Main.cpp | 41 +++++++++++++++++++++++++++++- Src/OSD/Windows/FileSystemPath.cpp | 2 ++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Src/OSD/SDL/Main.cpp b/Src/OSD/SDL/Main.cpp index 5562543..4a07187 100644 --- a/Src/OSD/SDL/Main.cpp +++ b/Src/OSD/SDL/Main.cpp @@ -119,7 +119,7 @@ static bool SetGLGeometry(unsigned *xOffsetPtr, unsigned *yOffsetPtr, unsigned * float yRes = float(*yResPtr); if (keepAspectRatio) { - float model3Ratio = 496.0/384.0; + float model3Ratio = float(496.0/384.0); if (yRes < (xRes/model3Ratio)) xRes = yRes*model3Ratio; if (xRes < (yRes*model3Ratio)) @@ -176,6 +176,42 @@ static void GLAPIENTRY DebugCallback(GLenum source, GLenum type, GLuint id, GLen printf("OGLDebug:: 0x%X: %s\n", id, message); } +// In windows with an nvidia card (sorry not tested anything else) you can customise the resolution. +// This also allows you to set a totally custom refresh rate. Apparently you can drive most monitors at +// 57.5fps with no issues. Anyway this code will automatically pick up your custom refresh rate, and set it if it exists +// It it doesn't exist, then it'll probably just default to 60 or whatever your refresh rate is. +static void SetFullScreenRefreshRate() +{ + float refreshRateHz = std::abs(s_runtime_config["RefreshRate"].ValueAs()); + + if (refreshRateHz > 57.f && refreshRateHz < 58.f) { + + int display_in_use = 0; /* Only using first display */ + + int display_mode_count = SDL_GetNumDisplayModes(display_in_use); + if (display_mode_count < 1) { + return; + } + + for (int i = 0; i < display_mode_count; ++i) { + + SDL_DisplayMode mode; + + if (SDL_GetDisplayMode(display_in_use, i, &mode) != 0) { + return; + } + + if (SDL_BITSPERPIXEL(mode.format) >= 24 && mode.refresh_rate == 58 && mode.w == totalXRes && mode.h == totalYRes) { + int result = SDL_SetWindowDisplayMode(s_window, &mode); + if (result == 0) { + printf("Custom fullscreen mode set: %ix%i@57.524 Hz\n", mode.w, mode.h); + } + break; + } + } + } +} + /* * CreateGLScreen(): * @@ -1049,6 +1085,9 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In SDL_SetWindowTitle(s_window, baseTitleStr); SDL_SetWindowSize(s_window, totalXRes, totalYRes); SDL_SetWindowPosition(s_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + + SetFullScreenRefreshRate(); + bool stretch = s_runtime_config["Stretch"].ValueAs(); bool fullscreen = s_runtime_config["FullScreen"].ValueAs(); if (OKAY != ResizeGLScreen(&xOffset, &yOffset ,&xRes, &yRes, &totalXRes, &totalYRes, !stretch, fullscreen)) diff --git a/Src/OSD/Windows/FileSystemPath.cpp b/Src/OSD/Windows/FileSystemPath.cpp index 9536d27..b0ca737 100644 --- a/Src/OSD/Windows/FileSystemPath.cpp +++ b/Src/OSD/Windows/FileSystemPath.cpp @@ -42,5 +42,7 @@ namespace FileSystemPath case Screenshots: return ""; } + + return ""; } }