From 18430c6c9f89d16cb76e3252f2003c8f3c0d6d4e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 23 Oct 2019 17:07:29 +0200 Subject: [PATCH] - refactored r_fpslimit Also removed the entire cruft related to this - the pointless offsetting value and the precalculation of the timer value (as if we could not afford a single division for something that WAITS! Unfortunately this required removal of the menu option for the time being. --- source/blood/src/blood.cpp | 4 ++-- source/blood/src/demo.cpp | 2 +- source/blood/src/menu.cpp | 25 --------------------- source/blood/src/menus.cpp | 17 +-------------- source/blood/src/osdcmd.cpp | 5 ----- source/blood/src/view.cpp | 32 --------------------------- source/blood/src/view.h | 6 ----- source/common/gamecvars.cpp | 41 +++++++++++++++++++++++++++++------ source/common/gamecvars.h | 4 +++- source/duke3d/src/game.cpp | 32 --------------------------- source/duke3d/src/game.h | 6 ----- source/duke3d/src/menus.cpp | 16 +------------- source/duke3d/src/osdcmds.cpp | 5 ----- source/rr/src/game.cpp | 29 ------------------------- source/rr/src/game.h | 6 ----- source/rr/src/menus.cpp | 15 +------------ source/rr/src/osdcmds.cpp | 5 ----- 17 files changed, 43 insertions(+), 207 deletions(-) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index ac819ae73..81e9c2f80 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -1773,7 +1773,7 @@ RESTART: g_gameUpdateAvgTime = g_gameUpdateTime; g_gameUpdateAvgTime = ((GAMEUPDATEAVGTIMENUMSAMPLES-1.f)*g_gameUpdateAvgTime+g_gameUpdateTime)/((float) GAMEUPDATEAVGTIMENUMSAMPLES); } - bDraw = viewFPSLimit() != 0; + bDraw = G_FPSLimit() != 0; if (gQuitRequest && gQuitGame) videoClearScreen(0); else @@ -1788,7 +1788,7 @@ RESTART: } else { - bDraw = viewFPSLimit() != 0; + bDraw = G_FPSLimit() != 0; if (bDraw) { videoClearScreen(0); diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index d4def4f94..ead04ce6f 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -404,7 +404,7 @@ _DEMOPLAYBACK: ProcessFrame(); ready2send = 0; } - if (viewFPSLimit()) + if (G_FPSLimit()) { viewDrawScreen(); if (gInputMode == kInputMenu && CGameMenuMgr::m_bActive) diff --git a/source/blood/src/menu.cpp b/source/blood/src/menu.cpp index af78a3c60..04461b3d4 100644 --- a/source/blood/src/menu.cpp +++ b/source/blood/src/menu.cpp @@ -76,8 +76,6 @@ void SetupVideoModeMenu(CGameMenuItemChain *); void SetVideoMode(CGameMenuItemChain *); void SetWidescreen(CGameMenuItemZBool *); void SetFOV(CGameMenuItemSlider *); -void UpdateVideoModeMenuFrameLimit(CGameMenuItemZCycle *pItem); -void UpdateVideoModeMenuFPSOffset(CGameMenuItemSlider *pItem); void UpdateVideoColorMenu(CGameMenuItemSliderFloat *); void ResetVideoColor(CGameMenuItemChain *); void SetWeaponsV10X(CGameMenuItemZBool* pItem); @@ -478,8 +476,6 @@ CGameMenuItemZCycle itemOptionsDisplayModeResolution("RESOLUTION:", 3, 66, 60, 1 CGameMenuItemZCycle itemOptionsDisplayModeRenderer("RENDERER:", 3, 66, 70, 180, 0, NULL, pzRendererStrings, 2, 0); CGameMenuItemZBool itemOptionsDisplayModeFullscreen("FULLSCREEN:", 3, 66, 80, 180, 0, NULL, NULL, NULL); CGameMenuItemZCycle itemOptionsDisplayModeVSync("VSYNC:", 3, 66, 90, 180, 0, NULL, pzVSyncStrings, 3, 0); -CGameMenuItemZCycle itemOptionsDisplayModeFrameLimit("FRAMERATE LIMIT:", 3, 66, 100, 180, 0, UpdateVideoModeMenuFrameLimit, pzFrameLimitStrings, 8, 0); -CGameMenuItemSlider itemOptionsDisplayModeFPSOffset("FPS OFFSET:", 3, 66, 110, 180, 0, -10, 10, 1, UpdateVideoModeMenuFPSOffset, -1, -1, kMenuSliderValue); CGameMenuItemChain itemOptionsDisplayModeApply("APPLY CHANGES", 3, 66, 125, 180, 0, NULL, 0, SetVideoMode, 0); void PreDrawDisplayColor(CGameMenuItem *); @@ -1625,15 +1621,6 @@ void SetupVideoModeMenu(CGameMenuItemChain *pItem) break; } } - for (int i = 0; i < 8; i++) - { - if (r_maxfps == nFrameLimitValues[i]) - { - itemOptionsDisplayModeFrameLimit.m_nFocus = i; - break; - } - } - itemOptionsDisplayModeFPSOffset.nValue = r_maxfpsoffset; } void PreDrawVideoModeMenu(CGameMenuItem *pItem) @@ -1646,18 +1633,6 @@ void PreDrawVideoModeMenu(CGameMenuItem *pItem) #endif } -void UpdateVideoModeMenuFrameLimit(CGameMenuItemZCycle *pItem) -{ - r_maxfps = nFrameLimitValues[pItem->m_nFocus]; - g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset); -} - -void UpdateVideoModeMenuFPSOffset(CGameMenuItemSlider *pItem) -{ - r_maxfpsoffset = pItem->nValue; - g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset); -} - void UpdateVideoColorMenu(CGameMenuItemSliderFloat *pItem) { UNREFERENCED_PARAMETER(pItem); diff --git a/source/blood/src/menus.cpp b/source/blood/src/menus.cpp index 0aaf889c9..6932103b8 100644 --- a/source/blood/src/menus.cpp +++ b/source/blood/src/menus.cpp @@ -536,15 +536,7 @@ static MenuEntry_t ME_VIDEOSETUP_VSYNC = MAKE_MENUENTRY("VSync:", &MF_Redfont, & -static char const *MEOSN_VIDEOSETUP_FRAMELIMIT [] = { "None", "30 fps", "60 fps", "75 fps", "100 fps", "120 fps", "144 fps", "165 fps", "240 fps" }; -static int32_t MEOSV_VIDEOSETUP_FRAMELIMIT [] = { 0, 30, 60, 75, 100, 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 char const *MEOSN_VIDEOSETUP_FRAMELIMIT [] = { "None", "30 fps", "60 fps", "75 fps", "100 fps", "120 fps", "144 fps", "165 fps", "240 fps" }; static MenuEntry_t ME_VIDEOSETUP_APPLY = MAKE_MENUENTRY( "Apply Changes", &MF_Redfont, &MEF_BigOptions_Apply, &MEO_NULL, Link ); @@ -738,8 +730,6 @@ static MenuEntry_t *MEL_VIDEOSETUP[] = { &ME_VIDEOSETUP_FULLSCREEN, &ME_VIDEOSETUP_BORDERLESS, &ME_VIDEOSETUP_VSYNC, - &ME_VIDEOSETUP_FRAMELIMIT, - &ME_VIDEOSETUP_FRAMELIMITOFFSET, &ME_Space4_Redfont, &ME_VIDEOSETUP_APPLY, }; @@ -2090,7 +2080,6 @@ static void Menu_Pre(MenuID_t cm) ) || (newrendermode != REND_CLASSIC && resolution[nr].bppmax <= 8)); MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_BORDERLESS, newfullscreen); - MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_FRAMELIMITOFFSET, !r_maxfps); break; } @@ -3363,8 +3352,6 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption) } } } - else if (entry == &ME_VIDEOSETUP_FRAMELIMIT) - g_frameDelay = calcFrameDelay(newOption + r_maxfpsoffset); switch (g_currentMenu) { @@ -3457,8 +3444,6 @@ static int32_t Menu_EntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue) joySetDeadZone(M_JOYSTICKAXES.currentEntry, newValue, *MEO_JOYSTICKAXIS_SATU.variable); else if (entry == &ME_JOYSTICKAXIS_SATU) joySetDeadZone(M_JOYSTICKAXES.currentEntry, *MEO_JOYSTICKAXIS_DEAD.variable, newValue); - else if (entry == &ME_VIDEOSETUP_FRAMELIMITOFFSET) - g_frameDelay = calcFrameDelay(r_maxfps + newValue); return 0; } diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index 17d74fa35..ae9a464c4 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -779,11 +779,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm) videoSetGameMode(fullscreen, xres, yres, bpp, gUpscaleFactor); } } - 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 = calcFrameDelay(r_maxfps + r_maxfpsoffset); - } else if (!Bstrcasecmp(parm->name, "vid_gamma")) { gBrightness = GAMMA_CALC; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index fea00a70e..e2d35947d 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -1769,9 +1769,6 @@ void viewInit(void) dword_172CE0[i][2] = mulscale16(wrand(), 2048); } gViewMap.sub_25C38(0, 0, gZoom, 0, gFollowMap); - - g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset); - bLoadScreenCrcMatch = tileCRC(kLoadScreen) == kLoadScreenCRC; } @@ -3004,35 +3001,6 @@ void viewUpdateShake(void) } } -int32_t r_maxfps = 60; -int32_t r_maxfpsoffset = 0; -double g_frameDelay = 0.0; - -int viewFPSLimit(void) -{ - if (!r_maxfps) - return 1; - - static double nextPageDelay; - static uint64_t lastFrameTicks; - - uint64_t const frameTicks = timerGetTicksU64(); - uint64_t const elapsedTime = frameTicks - lastFrameTicks; - double const dElapsedTime = elapsedTime; - - if (dElapsedTime >= floor(nextPageDelay)) - { - if (dElapsedTime <= nextPageDelay+g_frameDelay) - nextPageDelay += g_frameDelay-dElapsedTime; - - lastFrameTicks = frameTicks; - - return 1; - } - - return 0; -} - int gLastPal = 0; diff --git a/source/blood/src/view.h b/source/blood/src/view.h index 1e8e0c900..4f8f10892 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -98,14 +98,9 @@ extern int gViewX0, gViewY0, gViewX1, gViewY1; extern int gViewX0S, gViewY0S, gViewX1S, gViewY1S; extern palette_t CrosshairColors; extern bool g_isAlterDefaultCrosshair; -extern int32_t r_maxfps; -extern int32_t r_maxfpsoffset; -extern double g_frameDelay; extern int gLastPal; -static inline double calcFrameDelay(int maxFPS) { return maxFPS ? ((double)timerGetFreqU64() / (double)(maxFPS)) : 0.0; } - void viewGetFontInfo(int id, const char *unk1, int *pXSize, int *pYSize); void viewUpdatePages(void); void viewToggle(int viewMode); @@ -148,7 +143,6 @@ void viewDisplayMessage(void); void viewSetErrorMessage(const char *pMessage); void DoLensEffect(void); void UpdateDacs(int nPalette, bool bNoTint = false); -int viewFPSLimit(void); void viewDrawScreen(void); void viewLoadingScreenWide(void); void viewLoadingScreenUpdate(const char *pzText4 = NULL, int nPercent = -1); diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp index 5a331fcc8..900fff761 100644 --- a/source/common/gamecvars.cpp +++ b/source/common/gamecvars.cpp @@ -287,22 +287,49 @@ CVARD(Bool, r_shadows, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable spr CVARD(Bool, r_rotatespritenowidescreen, false, CVAR_NOSET, "pass bit 1024 to all CON rotatesprite calls") CVARD(Bool, r_precache, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable the pre-level caching routine") -CUSTOM_CVAR(Int, r_maxfps, 200, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "limit the frame rate") +CUSTOM_CVARD(Int, r_maxfps, 200, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "limit the frame rate") { - if (self < 30) self = 30; + if (self < 0) self = 0; + else if (self > 0 && self < 30) self = 30; else if (self > 1000) self = 1000; } +int G_FPSLimit(void) +{ + if (r_maxfps <= 0) + return 1; + + auto frameDelay = timerGetFreqU64()/(double)r_maxfps; + + static double nextPageDelay; + static uint64_t lastFrameTicks; + + nextPageDelay = clamp(nextPageDelay, 0.0, frameDelay); + + uint64_t const frameTicks = timerGetTicksU64(); + uint64_t const elapsedTime = frameTicks - lastFrameTicks; + double const dElapsedTime = elapsedTime; + + if (dElapsedTime >= nextPageDelay) + { + if (dElapsedTime <= nextPageDelay+frameDelay) + nextPageDelay += frameDelay-dElapsedTime; + + lastFrameTicks = frameTicks; + + return 1; + } + + return 0; +} + + #if 0 // DN3D static osdcvardata_t cvars_game[] = { - { "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 }, - { "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 }, + { "sensitivity","changes the mouse sensitivity", (void *)&CONTROL_MouseSensitivity, CVAR_FLOAT|CVAR_FUNCPTR, 0, 25 }, { "skill","changes the game skill setting", (void *)&ud.m_player_skill, CVAR_INT|CVAR_FUNCPTR|CVAR_NOSAVE/*|CVAR_NOMULTI*/, 0, 5 }, diff --git a/source/common/gamecvars.h b/source/common/gamecvars.h index d2c62614f..24e33c8cd 100644 --- a/source/common/gamecvars.h +++ b/source/common/gamecvars.h @@ -62,7 +62,8 @@ EXTERN_CVAR(Int, r_showfps) EXTERN_CVAR(Int, r_showfpsperiod) EXTERN_CVAR(Int, r_ambientlight) EXTERN_CVAR(Int, r_shadows) - +EXTERN_CVAR(Bool, r_rotatespritenowidescreen) +EXTERN_CVAR(Bool, r_precache) EXTERN_CVAR(Bool, in_joystick) EXTERN_CVAR(Bool, in_mouse) @@ -81,3 +82,4 @@ bool G_ChangeHudLayout(int direction); bool G_CheckAutorun(bool button); void G_LoadConfig(const char*); void G_SaveConfig(); +int G_FPSLimit(void); diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index f192817ab..aa4913fa9 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -107,10 +107,6 @@ GAME_STATIC GAME_INLINE int32_t G_MoveLoop(void); int32_t g_levelTextTime = 0; -int32_t r_maxfps = 60; -int32_t r_maxfpsoffset = 0; -double g_frameDelay = 0.0; - #if defined(RENDERTYPEWIN) && defined(USE_OPENGL) extern char forcegl; #endif @@ -6292,33 +6288,6 @@ void G_MaybeAllocPlayer(int32_t pnum) } -int G_FPSLimit(void) -{ - if (!r_maxfps) - return 1; - - static double nextPageDelay; - static uint64_t lastFrameTicks; - - nextPageDelay = clamp(nextPageDelay, 0.0, g_frameDelay); - - uint64_t const frameTicks = timerGetTicksU64(); - uint64_t const elapsedTime = frameTicks - lastFrameTicks; - double const dElapsedTime = elapsedTime; - - if (dElapsedTime >= nextPageDelay) - { - if (dElapsedTime <= nextPageDelay+g_frameDelay) - nextPageDelay += g_frameDelay-dElapsedTime; - - lastFrameTicks = frameTicks; - - return 1; - } - - return 0; -} - // TODO: reorder (net)actor_t to eliminate slop and update assertion EDUKE32_STATIC_ASSERT(sizeof(actor_t)%4 == 0); EDUKE32_STATIC_ASSERT(sizeof(DukePlayer_t)%4 == 0); @@ -6641,7 +6610,6 @@ int app_main(int argc, const char * const*argv) ud.setup.bpp = bpp; } - g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset); videoSetPalette(ud.brightness>>2, myplayer.palette, 0); S_MusicStartup(); S_SoundStartup(); diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index e3a172a02..f64960f8c 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -298,8 +298,6 @@ extern int32_t g_levelTextTime; extern int32_t g_quitDeadline; extern int32_t g_restorePalette; extern int32_t hud_glowingquotes; -extern int32_t r_maxfps; -extern int32_t r_maxfpsoffset; extern int32_t tempwallptr; extern int32_t ticrandomseed; extern int32_t vote_map; @@ -312,9 +310,6 @@ extern int32_t voting; extern palette_t CrosshairColors; extern palette_t DefaultCrosshairColors; -extern double g_frameDelay; -static inline double calcFrameDelay(int const maxFPS) { return maxFPS > 0 ? (timerGetFreqU64()/(double)maxFPS) : 0.0; } - int32_t A_CheckInventorySprite(spritetype *s); int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr, uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss); @@ -354,7 +349,6 @@ void G_DrawFrags(void); void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio); void G_DrawRooms(int32_t playerNum,int32_t smoothratio); void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); -int G_FPSLimit(void); void G_GameExit(const char *msg) ATTRIBUTE((noreturn)); void G_GameQuit(void); void G_GetCrosshairColor(void); diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 219b74a30..1c6b4fc89 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -535,14 +535,7 @@ static MenuEntry_t ME_VIDEOSETUP_VSYNC = MAKE_MENUENTRY("VSync:", &MF_Redfont, & -static char const *MEOSN_VIDEOSETUP_FRAMELIMIT [] = { "None", "30 fps", "60 fps", "75 fps", "100 fps", "120 fps", "144 fps", "165 fps", "240 fps" }; -static int32_t MEOSV_VIDEOSETUP_FRAMELIMIT [] = { 0, 30, 60, 75, 100, 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 char const *MEOSN_VIDEOSETUP_FRAMELIMIT [] = { "None", "30 fps", "60 fps", "75 fps", "100 fps", "120 fps", "144 fps", "165 fps", "240 fps" }; static MenuEntry_t ME_VIDEOSETUP_APPLY = MAKE_MENUENTRY( "Apply Changes", &MF_Redfont, &MEF_BigOptions_Apply, &MEO_NULL, Link ); @@ -737,8 +730,6 @@ static MenuEntry_t *MEL_VIDEOSETUP[] = { &ME_VIDEOSETUP_FULLSCREEN, &ME_VIDEOSETUP_BORDERLESS, &ME_VIDEOSETUP_VSYNC, - &ME_VIDEOSETUP_FRAMELIMIT, - &ME_VIDEOSETUP_FRAMELIMITOFFSET, &ME_Space4_Redfont, &ME_VIDEOSETUP_APPLY, }; @@ -2106,7 +2097,6 @@ static void Menu_Pre(MenuID_t cm) ) || (newrendermode != REND_CLASSIC && resolution[nr].bppmax <= 8)); MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_BORDERLESS, newfullscreen); - MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_FRAMELIMITOFFSET, !r_maxfps); break; } @@ -3379,8 +3369,6 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption) } } } - else if (entry == &ME_VIDEOSETUP_FRAMELIMIT) - g_frameDelay = calcFrameDelay(newOption + r_maxfpsoffset); switch (g_currentMenu) { @@ -3473,8 +3461,6 @@ static int32_t Menu_EntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue) joySetDeadZone(M_JOYSTICKAXES.currentEntry, newValue, *MEO_JOYSTICKAXIS_SATU.variable); else if (entry == &ME_JOYSTICKAXIS_SATU) joySetDeadZone(M_JOYSTICKAXES.currentEntry, *MEO_JOYSTICKAXIS_DEAD.variable, newValue); - else if (entry == &ME_VIDEOSETUP_FRAMELIMITOFFSET) - g_frameDelay = calcFrameDelay(r_maxfps + newValue); return 0; } diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index f08e5d220..bfbe824e3 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -1445,11 +1445,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm) videoSetGameMode(fullscreen, xres, yres, bpp, ud.detail); } } - 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 = calcFrameDelay(r_maxfps + r_maxfpsoffset); - } else if (!Bstrcasecmp(parm->name, "vid_gamma")) { ud.brightness = GAMMA_CALC; diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 1d812d9d0..b10ea0264 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -101,10 +101,6 @@ GAME_STATIC GAME_INLINE int32_t G_MoveLoop(void); int32_t g_levelTextTime = 0; -int32_t r_maxfps = 60; -int32_t r_maxfpsoffset = 0; -double g_frameDelay = 0.0; - #if defined(RENDERTYPEWIN) && defined(USE_OPENGL) extern char forcegl; #endif @@ -7655,30 +7651,6 @@ void G_MaybeAllocPlayer(int32_t pnum) } -int G_FPSLimit(void) -{ - if (!r_maxfps) - return 1; - - static double nextPageDelay; - static double lastFrameTicks; - - double const frameTicks = timerGetTicksU64(); - double const elapsedTime = frameTicks-lastFrameTicks; - - if (elapsedTime >= nextPageDelay) - { - if (elapsedTime <= nextPageDelay+g_frameDelay) - nextPageDelay += g_frameDelay-elapsedTime; - - lastFrameTicks = frameTicks; - - return 1; - } - - return 0; -} - // TODO: reorder (net)actor_t to eliminate slop and update assertion EDUKE32_STATIC_ASSERT(sizeof(actor_t)%4 == 0); @@ -8020,7 +7992,6 @@ int app_main(int argc, char const * const * argv) ud.setup.bpp = bpp; } - g_frameDelay = calcFrameDelay(r_maxfps + r_maxfpsoffset); videoSetPalette(ud.brightness>>2, g_player[myconnectindex].ps->palette, 0); S_MusicStartup(); S_SoundStartup(); diff --git a/source/rr/src/game.h b/source/rr/src/game.h index eaf6a63f3..4c5d77b0e 100644 --- a/source/rr/src/game.h +++ b/source/rr/src/game.h @@ -269,8 +269,6 @@ extern int32_t g_levelTextTime; extern int32_t g_quitDeadline; extern int32_t g_restorePalette; extern int32_t hud_glowingquotes; -extern int32_t r_maxfps; -extern int32_t r_maxfpsoffset; extern int32_t tempwallptr; extern int32_t ticrandomseed; extern int32_t vote_map; @@ -283,9 +281,6 @@ extern int32_t voting; extern palette_t CrosshairColors; extern palette_t DefaultCrosshairColors; -extern double g_frameDelay; -static inline double calcFrameDelay(int maxFPS) { return maxFPS ? ((double)timerGetFreqU64() / (double)(maxFPS)) : 0.0; } - int32_t A_CheckInventorySprite(spritetype *s); int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr, uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss); @@ -324,7 +319,6 @@ void G_DrawFrags(void); void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio); void G_DrawRooms(int32_t playerNum,int32_t smoothratio); void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); -int G_FPSLimit(void); void G_GameExit(const char *msg) ATTRIBUTE((noreturn)); void G_GameQuit(void); void G_GetCrosshairColor(void); diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index 9ca088fa7..e402000cb 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -519,14 +519,7 @@ 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 [] = { "30 fps", "60 fps", "75 fps", "100 fps", "120 fps", "144 fps", "165 fps", "240 fps" }; -static int32_t MEOSV_VIDEOSETUP_FRAMELIMIT [] = { 30, 60, 75, 100, 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 char const *MEOSN_VIDEOSETUP_FRAMELIMIT [] = { "30 fps", "60 fps", "75 fps", "100 fps", "120 fps", "144 fps", "165 fps", "240 fps" }; static MenuEntry_t ME_VIDEOSETUP_APPLY = MAKE_MENUENTRY( "Apply Changes", &MF_Redfont, &MEF_BigOptions_Apply, &MEO_NULL, Link ); @@ -705,7 +698,6 @@ static MenuEntry_t *MEL_VIDEOSETUP[] = { #endif &ME_VIDEOSETUP_FULLSCREEN, &ME_VIDEOSETUP_VSYNC, - &ME_VIDEOSETUP_FRAMELIMIT, &ME_Space6_Redfont, &ME_VIDEOSETUP_APPLY, }; @@ -2042,7 +2034,6 @@ static void Menu_Pre(MenuID_t cm) ) || (newrendermode != REND_CLASSIC && resolution[nr].bppmax <= 8)); - MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_FRAMELIMITOFFSET, !r_maxfps); break; } @@ -3776,8 +3767,6 @@ static int32_t Menu_EntryOptionModify(MenuEntry_t *entry, int32_t newOption) } } } - else if (entry == &ME_VIDEOSETUP_FRAMELIMIT) - g_frameDelay = calcFrameDelay(newOption + r_maxfpsoffset); switch (g_currentMenu) { @@ -3873,8 +3862,6 @@ static int32_t Menu_EntryRangeInt32Modify(MenuEntry_t *entry, int32_t newValue) joySetDeadZone(M_JOYSTICKAXES.currentEntry, newValue, *MEO_JOYSTICKAXIS_SATU.variable); else if (entry == &ME_JOYSTICKAXIS_SATU) joySetDeadZone(M_JOYSTICKAXES.currentEntry, *MEO_JOYSTICKAXIS_DEAD.variable, newValue); - else if (entry == &ME_VIDEOSETUP_FRAMELIMITOFFSET) - g_frameDelay = calcFrameDelay(r_maxfps + newValue); return 0; } diff --git a/source/rr/src/osdcmds.cpp b/source/rr/src/osdcmds.cpp index b9de783fd..19ad0c7b6 100644 --- a/source/rr/src/osdcmds.cpp +++ b/source/rr/src/osdcmds.cpp @@ -1232,11 +1232,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm) videoSetGameMode(fullscreen, xres, yres, bpp, ud.detail); } } - 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 = calcFrameDelay(r_maxfps + r_maxfpsoffset); - } else if (!Bstrcasecmp(parm->name, "vid_gamma")) { ud.brightness = GAMMA_CALC;