mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 03:12:00 -04:00
working DRS in capped mode, remove newsync uncapped hack (#1341)
This commit is contained in:
parent
ba70ba460c
commit
80145d6e6c
13
src/d_loop.c
13
src/d_loop.c
@ -755,20 +755,7 @@ void TryRunTics (void)
|
|||||||
|
|
||||||
if (new_sync)
|
if (new_sync)
|
||||||
{
|
{
|
||||||
if (uncapped)
|
|
||||||
{
|
|
||||||
// decide how many tics to run
|
|
||||||
if (realtics < availabletics-1)
|
|
||||||
counts = realtics+1;
|
|
||||||
else if (realtics < availabletics)
|
|
||||||
counts = realtics;
|
|
||||||
else
|
|
||||||
counts = availabletics;
|
counts = availabletics;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
counts = availabletics;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [AM] If we've uncapped the framerate and there are no tics
|
// [AM] If we've uncapped the framerate and there are no tics
|
||||||
// to run, return early instead of waiting around.
|
// to run, return early instead of waiting around.
|
||||||
|
@ -89,7 +89,7 @@ static int actualheight;
|
|||||||
static int native_width;
|
static int native_width;
|
||||||
static int native_height;
|
static int native_height;
|
||||||
static int native_height_adjusted;
|
static int native_height_adjusted;
|
||||||
static int refresh_rate;
|
static int native_refresh_rate;
|
||||||
|
|
||||||
static boolean need_resize;
|
static boolean need_resize;
|
||||||
|
|
||||||
@ -477,6 +477,7 @@ static void UpdateRender(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t frametime_withoutpresent;
|
static uint64_t frametime_withoutpresent;
|
||||||
|
static int targetrefresh;
|
||||||
|
|
||||||
static void ResetResolution(int height);
|
static void ResetResolution(int height);
|
||||||
static void ResetLogicalSize(void);
|
static void ResetLogicalSize(void);
|
||||||
@ -495,7 +496,7 @@ static void DynamicResolution(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1.25 milliseconds for SDL render present
|
// 1.25 milliseconds for SDL render present
|
||||||
double target = (1.0 / refresh_rate) - 0.00125;
|
double target = (1.0 / targetrefresh) - 0.00125;
|
||||||
double actual = frametime_withoutpresent / 1000000.0;
|
double actual = frametime_withoutpresent / 1000000.0;
|
||||||
|
|
||||||
double actualpercent = actual / target;
|
double actualpercent = actual / target;
|
||||||
@ -609,22 +610,19 @@ void I_FinishUpdate(void)
|
|||||||
need_resize = false;
|
need_resize = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uncapped)
|
if (uncapped && fpslimit >= TICRATE)
|
||||||
{
|
{
|
||||||
if (fpslimit >= TICRATE)
|
uint64_t target_time = 1000000ull / targetrefresh;
|
||||||
{
|
|
||||||
uint64_t target_time = 1000000ull / fpslimit;
|
|
||||||
static uint64_t start_time;
|
|
||||||
|
|
||||||
while (1)
|
while (true)
|
||||||
{
|
{
|
||||||
uint64_t current_time = I_GetTimeUS();
|
uint64_t current_time = I_GetTimeUS();
|
||||||
uint64_t elapsed_time = current_time - start_time;
|
uint64_t elapsed_time = current_time - frametime_start;
|
||||||
uint64_t remaining_time = 0;
|
uint64_t remaining_time = 0;
|
||||||
|
|
||||||
if (elapsed_time >= target_time)
|
if (elapsed_time >= target_time)
|
||||||
{
|
{
|
||||||
start_time = current_time;
|
frametime_start = current_time;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,10 +632,11 @@ void I_FinishUpdate(void)
|
|||||||
I_Sleep((remaining_time - 1000) / 1000);
|
I_Sleep((remaining_time - 1000) / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
frametime_start = I_GetTimeUS();
|
frametime_start = I_GetTimeUS();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// I_ReadScreen
|
// I_ReadScreen
|
||||||
@ -1149,6 +1148,18 @@ static void ResetLogicalSize(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void I_ResetTargetRefresh(void)
|
||||||
|
{
|
||||||
|
if (uncapped)
|
||||||
|
{
|
||||||
|
targetrefresh = (fpslimit >= TICRATE) ? fpslimit : native_refresh_rate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetrefresh = TICRATE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// killough 11/98: New routine, for setting hires and page flipping
|
// killough 11/98: New routine, for setting hires and page flipping
|
||||||
//
|
//
|
||||||
@ -1161,6 +1172,7 @@ static void I_InitVideoParms(void)
|
|||||||
resolution_mode = default_resolution_mode;
|
resolution_mode = default_resolution_mode;
|
||||||
uncapped = default_uncapped;
|
uncapped = default_uncapped;
|
||||||
grabmouse = default_grabmouse;
|
grabmouse = default_grabmouse;
|
||||||
|
I_ResetTargetRefresh();
|
||||||
|
|
||||||
//!
|
//!
|
||||||
// @category video
|
// @category video
|
||||||
@ -1359,7 +1371,7 @@ static void CreateSurfaces(void)
|
|||||||
|
|
||||||
native_width = mode.w;
|
native_width = mode.w;
|
||||||
native_height = mode.h;
|
native_height = mode.h;
|
||||||
refresh_rate = mode.refresh_rate;
|
native_refresh_rate = mode.refresh_rate;
|
||||||
|
|
||||||
w = native_width;
|
w = native_width;
|
||||||
h = use_aspect ? (int)(native_height / 1.2) : native_height;
|
h = use_aspect ? (int)(native_height / 1.2) : native_height;
|
||||||
|
@ -62,6 +62,7 @@ void I_FinishUpdate (void);
|
|||||||
void I_ReadScreen (byte* scr);
|
void I_ReadScreen (byte* scr);
|
||||||
|
|
||||||
void I_ResetScreen(void); // killough 10/98
|
void I_ResetScreen(void); // killough 10/98
|
||||||
|
void I_ResetTargetRefresh(void);
|
||||||
void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle
|
void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle
|
||||||
|
|
||||||
extern boolean use_vsync; // killough 2/8/98: controls whether vsync is called
|
extern boolean use_vsync; // killough 2/8/98: controls whether vsync is called
|
||||||
|
@ -3773,9 +3773,10 @@ static void M_SetMidiPlayer(void)
|
|||||||
S_RestartMusic();
|
S_RestartMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_EnableDisableFPSLimit(void)
|
static void M_ToggleUncapped(void)
|
||||||
{
|
{
|
||||||
DISABLE_ITEM(!uncapped, gen_settings1[gen1_fpslimit]);
|
DISABLE_ITEM(!uncapped, gen_settings1[gen1_fpslimit]);
|
||||||
|
I_ResetTargetRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_ToggleFullScreen(void)
|
static void M_ToggleFullScreen(void)
|
||||||
@ -3792,6 +3793,7 @@ static void M_CoerceFPSLimit(void)
|
|||||||
{
|
{
|
||||||
if (fpslimit < TICRATE)
|
if (fpslimit < TICRATE)
|
||||||
fpslimit = 0;
|
fpslimit = 0;
|
||||||
|
I_ResetTargetRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_ResetScreen(void)
|
static void M_ResetScreen(void)
|
||||||
@ -3820,7 +3822,7 @@ setup_menu_t gen_settings1[] = { // General Settings screen1
|
|||||||
{"", S_SKIP, m_null, M_X, M_Y + gen1_gap2*M_SPC},
|
{"", S_SKIP, m_null, M_X, M_Y + gen1_gap2*M_SPC},
|
||||||
|
|
||||||
{"Uncapped Frame Rate", S_YESNO, m_null, M_X, M_Y+ gen1_uncapped*M_SPC,
|
{"Uncapped Frame Rate", S_YESNO, m_null, M_X, M_Y+ gen1_uncapped*M_SPC,
|
||||||
{"uncapped"}, 0, M_EnableDisableFPSLimit},
|
{"uncapped"}, 0, M_ToggleUncapped},
|
||||||
|
|
||||||
{"Frame Rate Limit", S_NUM, m_null, M_X,
|
{"Frame Rate Limit", S_NUM, m_null, M_X,
|
||||||
M_Y + gen1_fpslimit*M_SPC, {"fpslimit"}, 0, M_CoerceFPSLimit},
|
M_Y + gen1_fpslimit*M_SPC, {"fpslimit"}, 0, M_CoerceFPSLimit},
|
||||||
@ -6864,7 +6866,7 @@ void M_ResetSetupMenu(void)
|
|||||||
|
|
||||||
void M_ResetSetupMenuVideo(void)
|
void M_ResetSetupMenuVideo(void)
|
||||||
{
|
{
|
||||||
M_EnableDisableFPSLimit();
|
M_ToggleUncapped();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user