mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-17 23:21:22 +00:00
Remove win32 specific timer
This commit is contained in:
parent
4ca994a05b
commit
425b56c288
1 changed files with 0 additions and 98 deletions
|
@ -54,11 +54,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
|
|||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32)
|
||||
DWORD TimeFunction(int requested_frequency);
|
||||
#else
|
||||
int TimeFunction(int requested_frequency);
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
|
@ -2044,80 +2040,6 @@ ticcmd_t *I_BaseTiccmd2(void)
|
|||
return &emptycmd2;
|
||||
}
|
||||
|
||||
#if defined (_WIN32)
|
||||
static HMODULE winmm = NULL;
|
||||
static DWORD starttickcount = 0; // hack for win2k time bug
|
||||
static p_timeGetTime pfntimeGetTime = NULL;
|
||||
|
||||
// ---------
|
||||
// I_GetTime
|
||||
// Use the High Resolution Timer if available,
|
||||
// else use the multimedia timer which has 1 millisecond precision on Windowz 95,
|
||||
// but lower precision on Windows NT
|
||||
// ---------
|
||||
|
||||
DWORD TimeFunction(int requested_frequency)
|
||||
{
|
||||
DWORD newtics = 0;
|
||||
// this var acts as a multiplier if sub-millisecond precision is asked but is not available
|
||||
int excess_frequency = requested_frequency / 1000;
|
||||
|
||||
if (!starttickcount) // high precision timer
|
||||
{
|
||||
LARGE_INTEGER currtime; // use only LowPart if high resolution counter is not available
|
||||
static LARGE_INTEGER basetime = {{0, 0}};
|
||||
|
||||
// use this if High Resolution timer is found
|
||||
static LARGE_INTEGER frequency;
|
||||
|
||||
if (!basetime.LowPart)
|
||||
{
|
||||
if (!QueryPerformanceFrequency(&frequency))
|
||||
frequency.QuadPart = 0;
|
||||
else
|
||||
QueryPerformanceCounter(&basetime);
|
||||
}
|
||||
|
||||
if (frequency.LowPart && QueryPerformanceCounter(&currtime))
|
||||
{
|
||||
newtics = (INT32)((currtime.QuadPart - basetime.QuadPart) * requested_frequency
|
||||
/ frequency.QuadPart);
|
||||
}
|
||||
else if (pfntimeGetTime)
|
||||
{
|
||||
currtime.LowPart = pfntimeGetTime();
|
||||
if (!basetime.LowPart)
|
||||
basetime.LowPart = currtime.LowPart;
|
||||
if (requested_frequency > 1000)
|
||||
newtics = currtime.LowPart - basetime.LowPart * excess_frequency;
|
||||
else
|
||||
newtics = (currtime.LowPart - basetime.LowPart)/(1000/requested_frequency);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (requested_frequency > 1000)
|
||||
newtics = (GetTickCount() - starttickcount) * excess_frequency;
|
||||
else
|
||||
newtics = (GetTickCount() - starttickcount)/(1000/requested_frequency);
|
||||
}
|
||||
|
||||
return newtics;
|
||||
}
|
||||
|
||||
static void I_ShutdownTimer(void)
|
||||
{
|
||||
pfntimeGetTime = NULL;
|
||||
if (winmm)
|
||||
{
|
||||
p_timeEndPeriod pfntimeEndPeriod = (p_timeEndPeriod)(LPVOID)GetProcAddress(winmm, "timeEndPeriod");
|
||||
if (pfntimeEndPeriod)
|
||||
pfntimeEndPeriod(1);
|
||||
FreeLibrary(winmm);
|
||||
winmm = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
//
|
||||
// I_GetTime
|
||||
// returns time in 1/TICRATE second tics
|
||||
|
@ -2140,7 +2062,6 @@ int TimeFunction(int requested_frequency)
|
|||
|
||||
return ticks;
|
||||
}
|
||||
#endif
|
||||
|
||||
tic_t I_GetTime(void)
|
||||
{
|
||||
|
@ -2157,27 +2078,8 @@ int I_GetTimeMicros(void)
|
|||
//
|
||||
void I_StartupTimer(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// for win2k time bug
|
||||
if (M_CheckParm("-gettickcount"))
|
||||
{
|
||||
starttickcount = GetTickCount();
|
||||
CONS_Printf("%s", M_GetText("Using GetTickCount()\n"));
|
||||
}
|
||||
winmm = LoadLibraryA("winmm.dll");
|
||||
if (winmm)
|
||||
{
|
||||
p_timeEndPeriod pfntimeBeginPeriod = (p_timeEndPeriod)(LPVOID)GetProcAddress(winmm, "timeBeginPeriod");
|
||||
if (pfntimeBeginPeriod)
|
||||
pfntimeBeginPeriod(1);
|
||||
pfntimeGetTime = (p_timeGetTime)(LPVOID)GetProcAddress(winmm, "timeGetTime");
|
||||
}
|
||||
I_AddExitFunc(I_ShutdownTimer);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void I_Sleep(void)
|
||||
{
|
||||
if (cv_sleep.value != -1)
|
||||
|
|
Loading…
Reference in a new issue