- Switch to C++11 steady clock

- Move the C++11 implementation to d_main
- Remove the platform specific timer implementations
This commit is contained in:
Magnus Norddahl 2017-11-12 03:12:22 +01:00
parent 090943eaa4
commit 307d8931d8
22 changed files with 174 additions and 560 deletions

View file

@ -47,6 +47,7 @@
#include "templates.h"
#include "dobject.h"
#include "vm.h"
#include "d_main.h"
#include <math.h>
#include <stdlib.h>

View file

@ -69,6 +69,7 @@
#include "c_consolebuffer.h"
#include "g_levellocals.h"
#include "vm.h"
#include "d_main.h"
FString FStringFormat(VM_ARGS); // extern from thingdef_data.cpp
@ -528,7 +529,7 @@ static void maybedrawnow (bool tick, bool force)
|| gamestate == GS_STARTUP))
{
static size_t lastprinttime = 0;
size_t nowtime = I_GetTime(false);
size_t nowtime = I_GetTime();
if (nowtime - lastprinttime > 1 || force)
{

View file

@ -117,6 +117,8 @@
#include "vm.h"
#include "types.h"
#include "r_data/r_vanillatrans.h"
#include <chrono>
#include <thread>
EXTERN_CVAR(Bool, hud_althud)
void DrawHUD();
@ -280,7 +282,7 @@ void D_ProcessEvents (void)
{
M_SetDefaultMode ();
}
else if (testingmode <= I_GetTime(false))
else if (testingmode <= I_GetTime())
{
M_RestoreMode ();
}
@ -1080,6 +1082,127 @@ void D_DoomLoop ()
}
}
//==========================================================================
//
// Tick time functions
//
//==========================================================================
static unsigned int FirstFrameStartTime;
static unsigned int CurrentFrameStartTime;
static unsigned int FreezeTime;
static uint32_t performanceGetTime()
{
using namespace std::chrono;
return (uint32_t)duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count();
}
void I_SetFrameTime()
{
// Must only be called once per frame/swapbuffers.
//
// Caches all timing information for the current rendered frame so that any
// calls to I_FPSTime, I_MSTime, I_GetTime or I_GetTimeFrac will return
// the same time.
if (FreezeTime == 0)
{
CurrentFrameStartTime = performanceGetTime();
if (FirstFrameStartTime == 0)
FirstFrameStartTime = CurrentFrameStartTime;
}
}
void I_WaitVBL(int count)
{
// I_WaitVBL is never used to actually synchronize to the vertical blank.
// Instead, it's used for delay purposes. Doom used a 70 Hz display mode,
// so that's what we use to determine how long to wait for.
std::this_thread::sleep_for(std::chrono::milliseconds(1000 * count / 70));
I_SetFrameTime();
}
int I_WaitForTic(int prevtic)
{
// Waits until the current tic is greater than prevtic. Time must not be frozen.
int time;
assert(TicFrozen == 0);
while ((time = I_GetTime()) <= prevtic)
{
// The minimum amount of time a thread can sleep is controlled by timeBeginPeriod.
// We set this to 1 ms in DoMain.
int sleepTime = prevtic - time;
if (sleepTime > 2)
std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime - 2));
I_SetFrameTime();
}
return time;
}
unsigned int I_FPSTime()
{
if (FreezeTime == 0)
return CurrentFrameStartTime;
else
return performanceGetTime();
}
unsigned int I_MSTime()
{
if (FreezeTime == 0)
{
return CurrentFrameStartTime - FirstFrameStartTime;
}
else
{
if (FirstFrameStartTime == 0)
{
FirstFrameStartTime = performanceGetTime();
return 0;
}
else
{
return performanceGetTime() - FirstFrameStartTime;
}
}
}
int I_GetTime()
{
return (CurrentFrameStartTime - FirstFrameStartTime) * TICRATE / 1000 + 1;
}
double I_GetTimeFrac(uint32_t *ms)
{
unsigned int currentTic = (CurrentFrameStartTime - FirstFrameStartTime) * TICRATE / 1000;
unsigned int ticStartTime = FirstFrameStartTime + currentTic * 1000 / TICRATE;
unsigned int ticNextTime = FirstFrameStartTime + (currentTic + 1) * 1000 / TICRATE;
if (ms)
*ms = currentTic + 1;
return (CurrentFrameStartTime - ticStartTime) / (double)(ticNextTime - ticStartTime);
}
void I_FreezeTime(bool frozen)
{
if (frozen)
{
FreezeTime = performanceGetTime();
}
else
{
FirstFrameStartTime += performanceGetTime() - FreezeTime;
FreezeTime = 0;
I_SetFrameTime();
}
}
//==========================================================================
//
// D_PageTicker

View file

@ -162,5 +162,25 @@ public:
};
// Called by D_DoomLoop, sets the time for the current frame
void I_SetFrameTime();
// Called by D_DoomLoop, returns current time in tics.
int I_GetTime();
double I_GetTimeFrac(uint32_t *ms);
// like I_GetTime, except it waits for a new tic before returning
int I_WaitForTic(int);
// Freezes tic counting temporarily. While frozen, calls to I_GetTime()
// will always return the same value. This does not affect I_MSTime().
// You must also not call I_WaitForTic() while freezing time, since the
// tic will never arrive (unless it's the current one).
void I_FreezeTime(bool frozen);
// [RH] Returns millisecond-accurate time
unsigned int I_MSTime();
unsigned int I_FPSTime();
#endif

View file

@ -68,6 +68,7 @@
#include "intermission/intermission.h"
#include "g_levellocals.h"
#include "events.h"
#include "d_main.h"
EXTERN_CVAR (Int, disableautosave)
EXTERN_CVAR (Int, autosavecount)
@ -956,7 +957,7 @@ void NetUpdate (void)
}
// check time
nowtime = I_GetTime (false);
nowtime = I_GetTime ();
newtics = nowtime - gametime;
gametime = nowtime;
@ -1830,7 +1831,7 @@ void TryRunTics (void)
}
else
{
entertic = I_GetTime (false);
entertic = I_GetTime ();
}
realtics = entertic - oldentertics;
oldentertics = entertic;
@ -1913,7 +1914,7 @@ void TryRunTics (void)
Net_CheckLastReceived (counts);
// don't stay in here forever -- give the menu a chance to work
if (I_GetTime (false) - entertic >= 1)
if (I_GetTime () - entertic >= 1)
{
C_Ticker ();
M_Ticker ();
@ -1928,7 +1929,7 @@ void TryRunTics (void)
hadlate = false;
for (i = 0; i < MAXPLAYERS; i++)
players[i].waiting = false;
lastglobalrecvtime = I_GetTime (false); //Update the last time the game tic'd over
lastglobalrecvtime = I_GetTime (); //Update the last time the game tic'd over
// run the count tics
if (counts > 0)
@ -1961,9 +1962,9 @@ void Net_CheckLastReceived (int counts)
{
// [Ed850] Check to see the last time a packet was received.
// If it's longer then 3 seconds, a node has likely stalled.
if (I_GetTime(false) - lastglobalrecvtime >= TICRATE * 3)
if (I_GetTime() - lastglobalrecvtime >= TICRATE * 3)
{
lastglobalrecvtime = I_GetTime(false); //Bump the count
lastglobalrecvtime = I_GetTime(); //Bump the count
if (NetMode == NET_PeerToPeer || consoleplayer == Net_Arbitrator)
{

View file

@ -51,6 +51,7 @@
#include "vm.h"
#include "g_levellocals.h"
#include "types.h"
#include "d_main.h"
//==========================================================================
//

View file

@ -92,6 +92,7 @@
#include "g_hub.h"
#include "g_levellocals.h"
#include "events.h"
#include "d_main.h"
static FRandom pr_dmspawn ("DMSpawn");
@ -2887,7 +2888,7 @@ bool G_CheckDemoStatus (void)
int endtime = 0;
if (timingdemo)
endtime = I_GetTime (false) - starttime;
endtime = I_GetTime () - starttime;
C_RestoreCVars (); // [RH] Restore cvars demo might have changed
M_Free (demobuffer);

View file

@ -94,6 +94,7 @@
#include "g_levellocals.h"
#include "actorinlines.h"
#include "vm.h"
#include "d_main.h"
#include <string.h>
@ -1020,7 +1021,7 @@ void G_DoLoadLevel (int position, bool autosave)
if (firstTime)
{
starttime = I_GetTime (false);
starttime = I_GetTime ();
firstTime = false;
}
}

View file

@ -39,6 +39,7 @@
#include "d_player.h"
#include "g_levellocals.h"
#include "r_utility.h"
#include "d_main.h"
//#include "resources/voxels.h"
//#include "gl/gl_intern.h"

View file

@ -45,6 +45,7 @@
#include "serializer.h"
#include "g_levellocals.h"
#include "events.h"
#include "d_main.h"
#include "gl/dynlights/gl_lightbuffer.h"
#include "gl/system/gl_interface.h"

View file

@ -52,7 +52,7 @@
#include "g_levellocals.h"
#include "gl/utility/gl_clock.h"
#include "gl/utility/gl_convert.h"
#include "d_main.h"
glcycle_t RenderWall,SetupWall,ClipWall;
glcycle_t RenderFlat,SetupFlat;

View file

@ -55,6 +55,7 @@
#include "hardware.h"
#include "vm.h"
#include "r_videoscale.h"
#include "d_main.h"
/*=======================================
*
@ -312,7 +313,7 @@ DEFINE_ACTION_FUNCTION(DVideoModeMenu, SetSelectedSize)
OldBits = DisplayBits;
NewBits = BitTranslate[DummyDepthCvar];
setmodeneeded = true;
testingmode = I_GetTime(false) + 5 * TICRATE;
testingmode = I_GetTime() + 5 * TICRATE;
SetModesMenu (NewWidth, NewHeight, NewBits);
ACTION_RETURN_BOOL(true);
}

View file

@ -68,6 +68,7 @@
#include "r_utility.h"
#include "cmdlib.h"
#include "g_levellocals.h"
#include "d_main.h"
void P_GetPolySpots (MapData * lump, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors);

View file

@ -115,6 +115,7 @@
#endif
#include "events.h"
#include "types.h"
#include "d_main.h"
#include "fragglescript/t_fs.h"

View file

@ -40,202 +40,12 @@
#include "i_system.h"
#include "templates.h"
namespace
{
timeval s_gameStartTicks;
timeval s_systemBootTicks;
unsigned int GetMillisecondsSince(const timeval& time)
{
timeval now;
gettimeofday(&now, NULL);
return static_cast<unsigned int>(
(now.tv_sec - time.tv_sec ) * 1000
+ (now.tv_usec - time.tv_usec) / 1000);
}
bool s_isTicFrozen;
timespec GetNextTickTime()
{
static const long MILLISECONDS_IN_SECOND = 1000;
static const long MICROSECONDS_IN_SECOND = 1000 * MILLISECONDS_IN_SECOND;
static const long NANOSECONDS_IN_SECOND = 1000 * MICROSECONDS_IN_SECOND;
static timespec ts = {};
if (__builtin_expect((0 == ts.tv_sec), 0))
{
timeval tv;
gettimeofday(&tv, NULL);
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = (tv.tv_usec + MICROSECONDS_IN_SECOND / TICRATE) * MILLISECONDS_IN_SECOND;
}
else
{
ts.tv_nsec += (MICROSECONDS_IN_SECOND / TICRATE) * MILLISECONDS_IN_SECOND;
}
if (ts.tv_nsec >= NANOSECONDS_IN_SECOND)
{
ts.tv_sec++;
ts.tv_nsec -= NANOSECONDS_IN_SECOND;
}
return ts;
}
pthread_cond_t s_timerEvent;
pthread_mutex_t s_timerMutex;
pthread_t s_timerThread;
bool s_timerInitialized;
bool s_timerExitRequested;
uint32_t s_ticStart;
uint32_t s_timerStart;
int s_tics;
void* TimerThreadFunc(void*)
{
assert(s_timerInitialized);
assert(!s_timerExitRequested);
while (true)
{
if (s_timerExitRequested)
{
break;
}
const timespec timeToNextTick = GetNextTickTime();
pthread_mutex_lock(&s_timerMutex);
pthread_cond_timedwait(&s_timerEvent, &s_timerMutex, &timeToNextTick);
if (!s_isTicFrozen)
{
__sync_add_and_fetch(&s_tics, 1);
}
s_timerStart = I_MSTime();
pthread_cond_broadcast(&s_timerEvent);
pthread_mutex_unlock(&s_timerMutex);
}
return NULL;
}
int GetTimeThreaded(bool saveMS)
{
if (saveMS)
{
s_ticStart = s_timerStart;
}
return s_tics;
}
int WaitForTicThreaded(int prevTic)
{
assert(!s_isTicFrozen);
while (s_tics <= prevTic)
{
pthread_mutex_lock(&s_timerMutex);
pthread_cond_wait(&s_timerEvent, &s_timerMutex);
pthread_mutex_unlock(&s_timerMutex);
}
return s_tics;
}
void FreezeTimeThreaded(bool frozen)
{
s_isTicFrozen = frozen;
}
} // unnamed namespace
unsigned int I_MSTime()
{
return GetMillisecondsSince(s_gameStartTicks);
}
unsigned int I_FPSTime()
{
return GetMillisecondsSince(s_systemBootTicks);
}
static uint32_t FrameTime;
void I_SetFrameTime()
{
FrameTime = I_MSTime();
}
double I_GetTimeFrac(uint32_t* ms)
{
const uint32_t now = FrameTime;
if (NULL != ms)
{
*ms = s_ticStart + 1000 / TICRATE;
}
return 0 == s_ticStart
? 1.
: clamp<double>( (now - s_ticStart) * TICRATE / 1000., 0, 1);
}
// To do: this file is obviously not needed anymore. It needs to be removed.
void I_InitTimer()
{
assert(!s_timerInitialized);
s_timerInitialized = true;
gettimeofday(&s_gameStartTicks, NULL);
int mib[2] = { CTL_KERN, KERN_BOOTTIME };
size_t len = sizeof s_systemBootTicks;
sysctl(mib, 2, &s_systemBootTicks, &len, NULL, 0);
pthread_cond_init (&s_timerEvent, NULL);
pthread_mutex_init(&s_timerMutex, NULL);
pthread_create(&s_timerThread, NULL, TimerThreadFunc, NULL);
I_GetTime = GetTimeThreaded;
I_WaitForTic = WaitForTicThreaded;
I_FreezeTime = FreezeTimeThreaded;
}
void I_ShutdownTimer()
{
if (!s_timerInitialized)
{
// This might happen if Cancel button was pressed
// in the IWAD selector window
return;
}
s_timerExitRequested = true;
pthread_join(s_timerThread, NULL);
pthread_mutex_destroy(&s_timerMutex);
pthread_cond_destroy (&s_timerEvent);
}

View file

@ -140,10 +140,6 @@ TArray<FString> I_GetGogPaths();
// The ini could not be saved at exit
bool I_WriteIniFailed ();
// [RH] Returns millisecond-accurate time
unsigned int I_MSTime (void);
unsigned int I_FPSTime();
class FTexture;
bool I_SetCursor(FTexture *);

View file

@ -44,201 +44,13 @@
#include "i_system.h"
#include "templates.h"
static uint32_t TicStart;
static uint32_t BaseTime;
static int TicFrozen;
// Signal based timer.
static Semaphore timerWait;
static int tics;
static uint32_t sig_start;
void I_SelectTimer();
// [RH] Returns time in milliseconds
unsigned int I_MSTime (void)
{
unsigned int time = SDL_GetTicks ();
return time - BaseTime;
}
// Exactly the same thing, but based does no modification to the time.
unsigned int I_FPSTime()
{
return SDL_GetTicks();
}
//
// I_GetTime
// returns time in 1/35th second tics
//
int I_GetTimeSelect (bool saveMS)
{
I_SelectTimer();
return I_GetTime (saveMS);
}
int I_GetTimePolled (bool saveMS)
{
if (TicFrozen != 0)
{
return TicFrozen;
}
uint32_t tm = SDL_GetTicks();
if (saveMS)
{
TicStart = tm;
}
return Scale(tm - BaseTime, TICRATE, 1000);
}
int I_GetTimeSignaled (bool saveMS)
{
if (saveMS)
{
TicStart = sig_start;
}
return tics;
}
int I_WaitForTicPolled (int prevtic)
{
int time;
assert (TicFrozen == 0);
while ((time = I_GetTimePolled(false)) <= prevtic)
;
return time;
}
int I_WaitForTicSignaled (int prevtic)
{
assert (TicFrozen == 0);
while(tics <= prevtic)
{
SEMAPHORE_WAIT(timerWait)
}
return tics;
}
void I_FreezeTimeSelect (bool frozen)
{
I_SelectTimer();
return I_FreezeTime (frozen);
}
void I_FreezeTimePolled (bool frozen)
{
if (frozen)
{
assert(TicFrozen == 0);
TicFrozen = I_GetTimePolled(false);
}
else
{
assert(TicFrozen != 0);
int froze = TicFrozen;
TicFrozen = 0;
int now = I_GetTimePolled(false);
BaseTime += (now - froze) * 1000 / TICRATE;
}
}
void I_FreezeTimeSignaled (bool frozen)
{
TicFrozen = frozen;
}
int I_WaitForTicSelect (int prevtic)
{
I_SelectTimer();
return I_WaitForTic (prevtic);
}
//
// I_HandleAlarm
// Should be called every time there is an alarm.
//
void I_HandleAlarm (int sig)
{
if(!TicFrozen)
tics++;
sig_start = SDL_GetTicks();
SEMAPHORE_SIGNAL(timerWait)
}
//
// I_SelectTimer
// Sets up the timer function based on if we can use signals for efficent CPU
// usage.
//
void I_SelectTimer()
{
SEMAPHORE_INIT(timerWait, 0, 0)
#ifndef __sun
signal(SIGALRM, I_HandleAlarm);
#else
struct sigaction alrmaction;
sigaction(SIGALRM, NULL, &alrmaction);
alrmaction.sa_handler = I_HandleAlarm;
sigaction(SIGALRM, &alrmaction, NULL);
#endif
struct itimerval itv;
itv.it_interval.tv_sec = itv.it_value.tv_sec = 0;
itv.it_interval.tv_usec = itv.it_value.tv_usec = 1000000/TICRATE;
if (setitimer(ITIMER_REAL, &itv, NULL) != 0)
{
I_GetTime = I_GetTimePolled;
I_FreezeTime = I_FreezeTimePolled;
I_WaitForTic = I_WaitForTicPolled;
}
else
{
I_GetTime = I_GetTimeSignaled;
I_FreezeTime = I_FreezeTimeSignaled;
I_WaitForTic = I_WaitForTicSignaled;
}
}
static uint32_t FrameTime;
void I_SetFrameTime()
{
FrameTime = SDL_GetTicks();
}
// Returns the fractional amount of a tic passed since the most recent tic
double I_GetTimeFrac (uint32_t *ms)
{
uint32_t now = FrameTime;
if (ms) *ms = TicStart + (1000 / TICRATE);
if (TicStart == 0)
{
return 1;
}
else
{
return clamp<double>((now - TicStart) * TICRATE / 1000., 0, 1);
}
}
void I_InitTimer ()
{
if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0)
I_FatalError("Could not initialize SDL timers:\n%s\n", SDL_GetError());
I_GetTime = I_GetTimeSelect;
I_WaitForTic = I_WaitForTicSelect;
I_FreezeTime = I_FreezeTimeSelect;
// Maybe this file isn't needed at all anymore.
// Someone with Linux should test if the timer subsystem is used elsewhere..
}
void I_ShutdownTimer ()

View file

@ -66,6 +66,7 @@
#include "sbar.h"
#include "math/cmath.h"
#include "vm.h"
#include "d_main.h"
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
@ -136,8 +137,6 @@ FRenderViewpoint::FRenderViewpoint()
FRenderViewpoint r_viewpoint;
FViewWindow r_viewwindow;
int otic;
bool r_NoInterpolate;
angle_t LocalViewAngle;
@ -784,7 +783,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
iview = FindPastViewer (viewpoint.camera);
int nowtic = I_GetTime (false);
int nowtic = I_GetTime ();
if (iview->otic != -1 && nowtic > iview->otic)
{
iview->otic = nowtic;

View file

@ -40,6 +40,7 @@
#include "r_data/voxels.h"
#include "r_data/sprites.h"
#include "d_net.h"
#include "d_main.h"
#include "po_man.h"
#include "r_utility.h"
#include "swrenderer/drawers/r_draw.h"

View file

@ -84,6 +84,7 @@
#include "r_data/voxels.h"
#include "vm.h"
#include "r_videoscale.h"
#include "d_main.h"
EXTERN_CVAR(Bool, r_blendmethod)
@ -902,7 +903,7 @@ void DFrameBuffer::DrawRateStuff ()
// draws little dots on the bottom of the screen
if (ticker)
{
int i = I_GetTime(false);
int i = I_GetTime();
int tics = i - LastTic;
uint8_t *buffer = GetBuffer();

View file

@ -122,10 +122,6 @@ static void CalculateCPUSpeed();
static int I_GetTimePolled(bool saveMS);
static int I_WaitForTicPolled(int prevtic);
static void I_FreezeTimePolled(bool frozen);
static int I_GetTimeEventDriven(bool saveMS);
static int I_WaitForTicEvent(int prevtic);
static void I_FreezeTimeEventDriven(bool frozen);
static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2);
static HCURSOR CreateCompatibleCursor(FTexture *cursorpic);
static HCURSOR CreateAlphaCursor(FTexture *cursorpic);
@ -174,140 +170,6 @@ static int DefaultWad;
static HCURSOR CustomCursor;
//==========================================================================
//
// Tick time functions
//
//==========================================================================
static LARGE_INTEGER frequency;
static uint32_t performanceGetTime()
{
if (frequency.QuadPart != 0)
{
LARGE_INTEGER current;
QueryPerformanceCounter(&current);
return current.QuadPart * 1000 / frequency.QuadPart;
}
else
{
return timeGetTime();
}
}
static unsigned int FirstFrameStartTime;
static unsigned int CurrentFrameStartTime;
static unsigned int FreezeTime;
void I_SetFrameTime()
{
// It is critical that all timing is calculated only once at a start of a frame.
//
// performanceGetTime() must only ever be called once or otherwise the playsim
// processing time will affect the interpolation done by the renderer.
if (FreezeTime == 0)
{
CurrentFrameStartTime = performanceGetTime();
if (FirstFrameStartTime == 0)
FirstFrameStartTime = CurrentFrameStartTime;
}
}
void I_WaitVBL(int count)
{
// I_WaitVBL is never used to actually synchronize to the vertical blank.
// Instead, it's used for delay purposes. Doom used a 70 Hz display mode,
// so that's what we use to determine how long to wait for.
Sleep(1000 * count / 70);
I_SetFrameTime();
}
static int I_WaitForTicWin32(int prevtic)
{
// Waits until the current tic is greater than prevtic. Time must not be frozen.
int time;
assert(TicFrozen == 0);
while ((time = I_GetTime(false)) <= prevtic)
{
// The minimum amount of time a thread can sleep is controlled by timeBeginPeriod.
// We set this to 1 ms in DoMain.
int sleepTime = prevtic - time;
if (sleepTime > 2)
Sleep(sleepTime - 2);
I_SetFrameTime();
}
return time;
}
unsigned int I_FPSTime()
{
if (FreezeTime == 0)
return CurrentFrameStartTime;
else
return performanceGetTime();
}
unsigned int I_MSTime()
{
if (FreezeTime == 0)
{
return CurrentFrameStartTime - FirstFrameStartTime;
}
else
{
if (FirstFrameStartTime == 0)
{
FirstFrameStartTime = performanceGetTime();
return 0;
}
else
{
return performanceGetTime() - FirstFrameStartTime;
}
}
}
int I_GetTimeWin32(bool saveMS)
{
return (CurrentFrameStartTime - FirstFrameStartTime) * TICRATE / 1000 + 1;
}
double I_GetTimeFrac(uint32_t *ms)
{
unsigned int currentTic = (CurrentFrameStartTime - FirstFrameStartTime) * TICRATE / 1000;
unsigned int ticStartTime = FirstFrameStartTime + currentTic * 1000 / TICRATE;
unsigned int ticNextTime = FirstFrameStartTime + (currentTic + 1) * 1000 / TICRATE;
if (ms)
*ms = currentTic + 1;
return (CurrentFrameStartTime - ticStartTime) / (double)(ticNextTime - ticStartTime);
}
void I_FreezeTimeWin32(bool frozen)
{
if (frozen)
{
FreezeTime = performanceGetTime();
}
else
{
FirstFrameStartTime += performanceGetTime() - FreezeTime;
FreezeTime = 0;
I_SetFrameTime();
}
}
int(*I_GetTime)(bool saveMS) = I_GetTimeWin32;
int(*I_WaitForTic)(int) = I_WaitForTicWin32;
void(*I_FreezeTime)(bool frozen) = I_FreezeTimeWin32;
//==========================================================================
//
// I_Tactile
@ -543,8 +405,6 @@ void I_Init()
CalculateCPUSpeed();
DumpCPUInfo(&CPU);
QueryPerformanceFrequency(&frequency);
atterm (I_ShutdownSound);
I_InitSound ();
}

View file

@ -50,21 +50,6 @@ void I_DetectOS (void);
// Called by DoomMain.
void I_Init (void);
// Called by D_DoomLoop, returns current time in tics.
extern int (*I_GetTime) (bool saveMS);
// like I_GetTime, except it waits for a new tic before returning
extern int (*I_WaitForTic) (int);
// Freezes tic counting temporarily. While frozen, calls to I_GetTime()
// will always return the same value. This does not affect I_MSTime().
// You must also not call I_WaitForTic() while freezing time, since the
// tic will never arrive (unless it's the current one).
extern void (*I_FreezeTime) (bool frozen);
double I_GetTimeFrac (uint32_t *ms);
void I_SetFrameTime();
// Return a seed value for the RNG.
unsigned int I_MakeRNGSeed();
@ -132,10 +117,6 @@ int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad);
// The ini could not be saved at exit
bool I_WriteIniFailed ();
// [RH] Returns millisecond-accurate time
unsigned int I_MSTime (void);
unsigned int I_FPSTime();
// [RH] Used by the display code to set the normal window procedure
void I_SetWndProc();