diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 21c769393..cc8fad38d 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -116,6 +116,7 @@ int32_t hud_showmapname = 1; int32_t g_levelTextTime = 0; int32_t r_maxfps = 60; +int32_t r_maxfpsoffset = 0; uint64_t g_frameDelay = 17; #if defined(RENDERTYPEWIN) && defined(USE_OPENGL) diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 5ebffda3b..f1dfc252e 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -324,6 +324,7 @@ extern int32_t g_restorePalette; extern int32_t hud_glowingquotes; extern int32_t hud_showmapname; extern int32_t r_maxfps; +extern int32_t r_maxfpsoffset; extern int32_t tempwallptr; extern int32_t ticrandomseed; extern int32_t vote_map; diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 06dd08484..2265fdd94 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -522,12 +522,14 @@ static MenuOptionSet_t MEOS_VIDEOSETUP_VSYNC = MAKE_MENUOPTIONSET(MEOSN_VIDEOSET static MenuOption_t MEO_VIDEOSETUP_VSYNC = MAKE_MENUOPTION(&MF_Redfont, &MEOS_VIDEOSETUP_VSYNC, &newvsync); static MenuEntry_t ME_VIDEOSETUP_VSYNC = MAKE_MENUENTRY("VSync:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_VIDEOSETUP_VSYNC, Option); -static char const *MEOSN_VIDEOSETUP_FRAMELIMIT [] = { "None", "30 fps", "60 fps", "120 fps", }; -static int32_t MEOSV_VIDEOSETUP_FRAMELIMIT [] = { 0, 30, 60, 120 }; -static MenuOptionSet_t MEOS_VIDEOSETUP_FRAMELIMIT = MAKE_MENUOPTIONSET(MEOSN_VIDEOSETUP_FRAMELIMIT, MEOSV_VIDEOSETUP_FRAMELIMIT, 0x2); +static char const *MEOSN_VIDEOSETUP_FRAMELIMIT [] = { "None", "30 fps", "60 fps", "120 fps", "144 fps", "165 fps", "240 fps" }; +static int32_t MEOSV_VIDEOSETUP_FRAMELIMIT [] = { 0, 30, 60, 120, 144, 165, 240 }; +static MenuOptionSet_t MEOS_VIDEOSETUP_FRAMELIMIT = MAKE_MENUOPTIONSET(MEOSN_VIDEOSETUP_FRAMELIMIT, MEOSV_VIDEOSETUP_FRAMELIMIT, 0x0); static MenuOption_t MEO_VIDEOSETUP_FRAMELIMIT= MAKE_MENUOPTION(&MF_Redfont, &MEOS_VIDEOSETUP_FRAMELIMIT, &r_maxfps); static MenuEntry_t ME_VIDEOSETUP_FRAMELIMIT = MAKE_MENUENTRY("Framerate limit:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_VIDEOSETUP_FRAMELIMIT, Option); +static MenuRangeInt32_t MEO_VIDEOSETUP_FRAMELIMITOFFSET = MAKE_MENURANGE( &r_maxfpsoffset, &MF_Redfont, -10, 10, 0, 21, 1 ); +static MenuEntry_t ME_VIDEOSETUP_FRAMELIMITOFFSET = MAKE_MENUENTRY( "FPS offset:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_VIDEOSETUP_FRAMELIMITOFFSET, RangeInt32 ); static MenuEntry_t ME_VIDEOSETUP_APPLY = MAKE_MENUENTRY( "Apply Changes", &MF_Redfont, &MEF_BigOptions_Apply, &MEO_NULL, Link ); @@ -536,8 +538,8 @@ static MenuLink_t MEO_DISPLAYSETUP_COLORCORR = { MENU_COLCORR, MA_Advance, }; static MenuEntry_t ME_DISPLAYSETUP_COLORCORR = MAKE_MENUENTRY( "Color Correction", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_COLORCORR, Link ); -static char const *MEOSN_DISPLAYSETUP_UPSCALING[] = { "None", "2x", "4x" }; -static int32_t MEOSV_DISPLAYSETUP_UPSCALING[] = { 1, 2, 4 }; +static char const *MEOSN_DISPLAYSETUP_UPSCALING[] = { "None", "2x" }; +static int32_t MEOSV_DISPLAYSETUP_UPSCALING[] = { 1, 2 }; static MenuOptionSet_t MEOS_DISPLAYSETUP_UPSCALING = MAKE_MENUOPTIONSET( MEOSN_DISPLAYSETUP_UPSCALING, MEOSV_DISPLAYSETUP_UPSCALING, 0x0 ); static MenuOption_t MEO_DISPLAYSETUP_UPSCALING = MAKE_MENUOPTION( &MF_Redfont, &MEOS_DISPLAYSETUP_UPSCALING, &ud.detail ); static MenuEntry_t ME_DISPLAYSETUP_UPSCALING = MAKE_MENUENTRY( "Upscaling:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_UPSCALING, Option ); @@ -711,6 +713,7 @@ static MenuEntry_t *MEL_VIDEOSETUP[] = { &ME_VIDEOSETUP_FULLSCREEN, &ME_VIDEOSETUP_VSYNC, &ME_VIDEOSETUP_FRAMELIMIT, + &ME_VIDEOSETUP_FRAMELIMITOFFSET, &ME_Space6_Redfont, &ME_VIDEOSETUP_APPLY, }; @@ -1989,6 +1992,8 @@ static void Menu_Pre(MenuID_t cm) && vsync == newvsync ) || (newrendermode != REND_CLASSIC && resolution[nr].bppmax <= 8)); + + MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_FRAMELIMITOFFSET, !r_maxfps); break; } @@ -3216,7 +3221,11 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption) } else if (entry == &ME_VIDEOSETUP_FRAMELIMIT) { - g_frameDelay = newOption ? (timerGetFreqU64()/newOption) : 0; + g_frameDelay = newOption ? (timerGetFreqU64()/(newOption + r_maxfpsoffset)) : 0; + } + else if (entry == &ME_VIDEOSETUP_FRAMELIMITOFFSET) + { + g_frameDelay = r_maxfps ? (timerGetFreqU64()/(r_maxfps + newOption)) : 0; } switch (g_currentMenu) diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index e4b417b6e..00d22d1f3 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -1390,10 +1390,10 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm) ud.statusbarmode = (ud.screen_size < 8); G_UpdateScreenArea(); } - else if (!Bstrcasecmp(parm->name, "r_maxfps")) + else if (!Bstrcasecmp(parm->name, "r_maxfps") || !Bstrcasecmp(parm->name, "r_maxfpsoffset")) { if (r_maxfps != 0) r_maxfps = clamp(r_maxfps, 30, 1000); - g_frameDelay = r_maxfps ? (timerGetFreqU64()/r_maxfps) : 0; + g_frameDelay = r_maxfps ? (timerGetFreqU64()/(r_maxfps + r_maxfpsoffset)) : 0; } else if (!Bstrcasecmp(parm->name, "r_ambientlight")) { @@ -1642,6 +1642,7 @@ int32_t registerosdcommands(void) { "r_ambientlight", "sets the global map light level",(void *)&r_ambientlight, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, { "r_maxfps", "limit the frame rate",(void *)&r_maxfps, CVAR_INT|CVAR_FUNCPTR, 0, 1000 }, + { "r_maxfpsoffset", "menu-controlled offset for r_maxfps",(void *)&r_maxfpsoffset, CVAR_INT|CVAR_FUNCPTR, -10, 10 }, { "sensitivity","changes the mouse sensitivity", (void *)&CONTROL_MouseSensitivity, CVAR_FLOAT|CVAR_FUNCPTR, 0, 25 },