diff --git a/MiSTer.ini b/MiSTer.ini index 9d2db36..63f728e 100644 --- a/MiSTer.ini +++ b/MiSTer.ini @@ -82,6 +82,13 @@ video_info=0 ; modes as a base even for 50Hz systems. vsync_adjust=0 +; If you monitor doesn't support either very low (NTSC monitors may not support PAL) or +; very high (PAL monitors may not support NTSC) then you can set refresh_min and/or refresh_max +; parameters, so vsync_adjust won't be applied for refreshes outside specified. +; These parameters are valid only when vsync_adjust is non-zero. +refresh_min=0 +refresh_max=0 + ; These parameters have the same format as video_mode. ; You need to supply both PAL and NTSC modes if you want vsync_adjust to switch between ; predefined modes as a base. This will reduce the range of pixel clock. diff --git a/cfg.cpp b/cfg.cpp index 06fcfec..0dcd47c 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -61,6 +61,8 @@ const ini_var_t ini_vars[] = { { "GAMEPAD_DEFAULTS", (void*)(&(cfg.gamepad_defaults)), UINT8, 0, 1 }, { "RECENTS", (void*)(&(cfg.recents)), UINT8, 0, 1 }, { "CONTROLLER_INFO", (void*)(&(cfg.controller_info)), UINT8, 0, 10 }, + { "REFRESH_MIN", (void*)(&(cfg.refresh_min)), UINT8, 0, 150 }, + { "REFRESH_MAX", (void*)(&(cfg.refresh_max)), UINT8, 0, 150 }, }; // mist ini config diff --git a/cfg.h b/cfg.h index b2931c7..e4dd249 100644 --- a/cfg.h +++ b/cfg.h @@ -26,6 +26,8 @@ typedef struct { uint8_t hdmi_limited; uint8_t direct_video; uint8_t video_info; + uint8_t refresh_min; + uint8_t refresh_max; uint8_t controller_info; uint8_t vsync_adjust; uint8_t kbd_nomouse; diff --git a/video.cpp b/video.cpp index 4169533..e259636 100644 --- a/video.cpp +++ b/video.cpp @@ -737,6 +737,19 @@ void video_mode_adjust() printf("Estimated Fpix(%.4f MHz) is outside supported range. Canceling auto-adjust.\n", Fpix); Fpix = 0; } + + uint32_t hz = 100000000 / vtime; + if (cfg.refresh_min && hz < cfg.refresh_min) + { + printf("Estimated frame rate (%d Hz) is less than MONITOR_HZ_MIN(%d Hz). Canceling auto-adjust.\n", hz, cfg.refresh_min); + Fpix = 0; + } + + if (cfg.refresh_max && hz > cfg.refresh_max) + { + printf("Estimated frame rate (%d Hz) is more than MONITOR_HZ_MAX(%d Hz). Canceling auto-adjust.\n", hz, cfg.refresh_max); + Fpix = 0; + } } set_video(v, Fpix);