diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp index a90bcf11c4aab..e3b0b75a9c97b 100644 --- a/src/emu/screen.cpp +++ b/src/emu/screen.cpp @@ -847,6 +847,10 @@ void screen_device::device_start() if ((m_video_attributes & VIDEO_UPDATE_SCANLINE) != 0 || !m_scanline_cb.isunset()) m_scanline_timer = timer_alloc(FUNC(screen_device::scanline_tick), this); +#ifdef __LIBRETRO__ + screen_configured = 0; +#endif + // configure the screen with the default parameters configure(m_width, m_height, m_visarea, m_refresh); @@ -975,6 +979,14 @@ TIMER_CALLBACK_MEMBER(screen_device::scanline_tick) void screen_device::configure(int width, int height, const rectangle &visarea, attoseconds_t frame_period) { +#ifdef __LIBRETRO__ + if (screen_configured + && width == m_width + && height == m_height + && floorf(ATTOSECONDS_TO_HZ(frame_period)) == floorf(ATTOSECONDS_TO_HZ(m_frame_period))) + return; +#endif + // validate arguments assert(width > 0); assert(height > 0); @@ -1029,7 +1041,14 @@ void screen_device::configure(int width, int height, const rectangle &visarea, a machine().video().update_refresh_speed(); #ifdef __LIBRETRO__ - retro_fps = ATTOSECONDS_TO_HZ(frame_period); + float retro_fps_new = ATTOSECONDS_TO_HZ(m_frame_period); + if (!screen_configured + && retro_fps_new != retro_fps + && retro_fps_new <= 120.0f + && retro_fps_new >= 30.0f) + retro_fps = retro_fps_new; + + screen_configured++; #endif } diff --git a/src/osd/libretro/libretro-internal/libretro.cpp b/src/osd/libretro/libretro-internal/libretro.cpp index ee2292424841f..1d9520cb78d9a 100755 --- a/src/osd/libretro/libretro-internal/libretro.cpp +++ b/src/osd/libretro/libretro-internal/libretro.cpp @@ -41,6 +41,7 @@ float view_aspect = 1.0f; float retro_fps = 60.0f; float sound_timer = 50.0f; /* default STREAMS_UPDATE_ATTOTIME, changed later to `retro_fps` */ int video_changed = 0; +int screen_configured = 0; static bool draw_this_frame; static int cpu_overclock = 100; diff --git a/src/osd/libretro/libretro-internal/libretro_shared.h b/src/osd/libretro/libretro-internal/libretro_shared.h index 16076ddb85bc1..0e513777cf081 100644 --- a/src/osd/libretro/libretro-internal/libretro_shared.h +++ b/src/osd/libretro/libretro-internal/libretro_shared.h @@ -55,6 +55,7 @@ enum RETRO_SETTING_LIGHTGUN_MODE_LIGHTGUN }; +extern bool retro_load_ok; extern int video_changed; extern int retro_pause; extern int mame_reset; @@ -105,6 +106,9 @@ extern float retro_fps; extern float view_aspect; extern int rotation_mode; extern int thread_mode; +extern float sound_timer; +extern int screen_configured; + static const char core[] = "mame"; /* libretro callbacks */ diff --git a/src/osd/libretro/osdretro.h b/src/osd/libretro/osdretro.h index a89d46a3022e2..e8292b55eb607 100644 --- a/src/osd/libretro/osdretro.h +++ b/src/osd/libretro/osdretro.h @@ -7,10 +7,6 @@ #include "libretro-internal/libretro_shared.h" -extern float sound_timer; -extern float retro_fps; -extern int video_changed; - //============================================================ // Defines //============================================================ diff --git a/src/osd/libretro/window.cpp b/src/osd/libretro/window.cpp index d2f59ad7e5b0f..6ded475dc457f 100644 --- a/src/osd/libretro/window.cpp +++ b/src/osd/libretro/window.cpp @@ -36,12 +36,13 @@ #include "modules/render/drawretro.h" #include "modules/monitor/monitor_common.h" +#include "libretro-internal/libretro_shared.h" + extern int max_width; extern int max_height; extern int libretro_rotation_allow; extern int internal_rotation_allow; extern int norotate; -extern bool retro_load_ok; //============================================================ // PARAMETERS @@ -293,6 +294,9 @@ int retro_window_info::window_init() // reset sound timer (set in `sound_manager::update` to `retro_fps`) sound_timer = 0; + // reset screen configuration + screen_configured = 0; + // reset machine aspect (set in `retro_window_info::update()`) view_aspect = 1; @@ -481,11 +485,13 @@ void retro_window_info::update() /* Update retro_fps */ if (screen) { - float current_screen_refresh = screen->frame_period().as_hz(); + float screen_refresh = screen->frame_period().as_hz(); - if (current_screen_refresh != retro_fps) + if (screen_refresh != retro_fps + && screen_refresh <= 120.0f + && screen_refresh >= 30.0f) { - retro_fps = current_screen_refresh; + retro_fps = screen_refresh; video_changed = 1; } }