@@ -106,6 +106,8 @@ static bool alt_grab;
106106static bool ctrl_grab ;
107107static int gui_saved_grab ;
108108static int gui_fullscreen ;
109+ static int fps_selection = 3 ;
110+ static float frame_deadline = (NANOSECONDS_PER_SECOND / 60 );
109111static int gui_grab_code = KMOD_LALT | KMOD_LCTRL ;
110112static SDL_Cursor * sdl_cursor_normal ;
111113static SDL_Cursor * sdl_cursor_hidden ;
@@ -132,6 +134,26 @@ void xemu_toggle_fullscreen(void)
132134 toggle_full_screen (& sdl2_console [0 ]);
133135}
134136
137+ int xemu_get_frame_rate_cap (void )
138+ {
139+ return fps_selection ;
140+ }
141+
142+ void xemu_set_frame_rate_cap (int selection )
143+ {
144+ // FIXME: Remove redundent selection
145+ fps_selection = selection ;
146+
147+ // No framerate cap
148+ if (!selection ) {
149+ frame_deadline = 0 ;
150+ }
151+
152+ const int framerates [6 ] = { 60 , 15 , 30 , 60 , 120 , 144 };
153+ int frame_rate = framerates [selection ];
154+ frame_deadline = (float )NANOSECONDS_PER_SECOND / frame_rate ;
155+ }
156+
135157#define SDL2_REFRESH_INTERVAL_BUSY 16
136158#define SDL2_MAX_IDLE_COUNT (2 * GUI_REFRESH_INTERVAL_DEFAULT \
137159 / SDL2_REFRESH_INTERVAL_BUSY + 1)
@@ -1084,7 +1106,7 @@ void sdl2_gl_refresh(DisplayChangeListener *dcl)
10841106 * Throttle to make sure swaps happen at 60Hz
10851107 */
10861108 static int64_t last_update = 0 ;
1087- int64_t deadline = last_update + 16666666 ;
1109+ int64_t deadline = last_update + frame_deadline ;
10881110
10891111#ifdef DEBUG_XEMU_C
10901112 int64_t sleep_acc = 0 ;
0 commit comments