Skip to content

Commit 486b097

Browse files
committed
Support RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE
Add "auto" Framerate option to use the reported framerate from the frontend targeted refresh rate. It'll also be set as the new default for the Framerate option. It'll fallback to 60 FPS if not obtained.
1 parent 896549f commit 486b097

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

libretro/libretro.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,54 +244,60 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
244244
{
245245
switch(movement_smooth)
246246
{
247-
case 0:
247+
case 1:
248248
info->timing.fps = 35.0;
249249
break;
250-
case 1:
250+
case 2:
251251
info->timing.fps = 40.0;
252252
break;
253-
case 2:
253+
case 3:
254254
info->timing.fps = 50.0;
255255
break;
256-
case 3:
256+
case 4:
257257
info->timing.fps = 60.0;
258258
break;
259-
case 4:
259+
case 5:
260260
info->timing.fps = 70.0;
261261
break;
262-
case 5:
262+
case 6:
263263
info->timing.fps = 72.0;
264264
break;
265-
case 6:
265+
case 7:
266266
info->timing.fps = 75.0;
267267
break;
268-
case 7:
268+
case 8:
269269
info->timing.fps = 90.0;
270270
break;
271-
case 8:
271+
case 9:
272272
info->timing.fps = 100.0;
273273
break;
274-
case 9:
274+
case 10:
275275
info->timing.fps = 119.0;
276276
break;
277-
case 10:
277+
case 11:
278278
info->timing.fps = 120.0;
279279
break;
280-
case 11:
280+
case 12:
281281
info->timing.fps = 140.0;
282282
break;
283-
case 12:
283+
case 13:
284284
info->timing.fps = 144.0;
285285
break;
286-
case 13:
286+
case 14:
287287
info->timing.fps = 240.0;
288288
break;
289-
case 14:
289+
case 15:
290290
info->timing.fps = 244.0;
291291
break;
292+
case 0: // Auto
292293
default:
293-
info->timing.fps = TICRATE;
294+
{
295+
float target_framerate = 0.0f;
296+
if (!environ_cb(RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE, &target_framerate))
297+
target_framerate = 60.0f;
298+
info->timing.fps = target_framerate;
294299
break;
300+
}
295301
}
296302
info->timing.sample_rate = 44100.0;
297303
info->geometry.base_width = SCREENWIDTH;
@@ -1413,6 +1419,9 @@ void R_InitInterpolation(void)
14131419
tic_vars.fps = info.timing.fps;
14141420
tic_vars.frac_step = FRACUNIT * TICRATE / tic_vars.fps;
14151421
tic_vars.sample_step = info.timing.sample_rate / tic_vars.fps;
1422+
1423+
if (log_cb)
1424+
log_cb(RETRO_LOG_INFO, "[libretro]: Framerate set to %.2f FPS\n", info.timing.fps);
14161425
}
14171426
tic_vars.frac = FRACUNIT;
14181427
}

src/m_menu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,7 @@ enum {
28372837
#define G_YA3 (G_YA2 + 16)
28382838
#define GF_X 76
28392839

2840-
static const char *framerates[] = {"35fps", "40fps", "50fps", "60fps", "70fps", "72fps", "75fps", "90fps", "100fps", "119fps", "120fps", "140fps", "144fps", "240fps", "244fps", NULL};
2840+
static const char *framerates[] = {"Auto", "35fps", "40fps", "50fps", "60fps", "70fps", "72fps", "75fps", "90fps", "100fps", "119fps", "120fps", "140fps", "144fps", "240fps", "244fps", NULL};
28412841
static const char *gamma_lvls[] = {"OFF", "Lv. 1", "Lv. 2", "Lv. 3", "Lv. 4", NULL};
28422842
static const char *mus_external_opts[] = {"Never", "Always", "Only IWAD", NULL};
28432843

src/m_misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ default_t defaults[] =
295295
def_int,ss_none, NULL, NULL},
296296
{"usegamma",{&usegamma, NULL},{0, NULL},0,4, //jff 3/6/98 fix erroneous upper limit in range
297297
def_int,ss_gen, NULL, NULL}, // gamma correction level // killough 1/18/98
298-
{"uncapped_framerate", {&movement_smooth, NULL}, {3, NULL},0,14,
298+
{"uncapped_framerate", {&movement_smooth, NULL}, {0, NULL},0,15,
299299
def_int,ss_gen, NULL, NULL},
300300
{"filter_wall",{(int*)&drawvars.filterwall, NULL},{RDRAW_FILTER_POINT, NULL},
301301
RDRAW_FILTER_POINT, RDRAW_FILTER_ROUNDED, def_int,ss_gen, NULL, NULL},

0 commit comments

Comments
 (0)