Skip to content

Commit

Permalink
Use SDL for all timing, no more scaling at this level
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 8, 2004
1 parent 61a9aca commit f31c23c
Showing 1 changed file with 21 additions and 49 deletions.
70 changes: 21 additions & 49 deletions doomsday/Src/sys_timer.c
Expand Up @@ -18,20 +18,12 @@
/*
* sys_timer.c: Timing Subsystem
*
* Uses Win32 multimedia timing routines.
* Uses the SDL timing routines.
*/

// HEADER FILES ------------------------------------------------------------

#include "de_platform.h"

#ifdef WIN32
# include <mmsystem.h>
#endif

#ifdef UNIX
# include <SDL.h>
#endif
#include <SDL.h>

#include "de_base.h"
#include "de_console.h"
Expand All @@ -56,41 +48,23 @@ float ticsPerSecond = TICSPERSEC;

// CODE --------------------------------------------------------------------

//==========================================================================
// Sys_ShutdownTimer
//==========================================================================
void Sys_ShutdownTimer(void)
{
#ifdef WIN32
timeEndPeriod(1);
#endif
}

//==========================================================================
// Sys_InitTimer
//==========================================================================
void Sys_InitTimer(void)
{
Con_Message("Sys_InitTimer.\n");
#ifdef WIN32
timeBeginPeriod(1);
#endif
/*Con_Message("Sys_InitTimer.\n");*/
}

//===========================================================================
// Sys_GetRealTime
// Returns the time in milliseconds.
//===========================================================================
/*
* Returns the time in milliseconds.
*/
unsigned int Sys_GetRealTime (void)
{
static boolean first = true;
static DWORD start;
#ifdef WIN32
DWORD now = timeGetTime();
#endif
#ifdef UNIX
static Uint32 start = 0;
Uint32 now = SDL_GetTicks();
#endif

if(first)
{
Expand All @@ -105,39 +79,37 @@ unsigned int Sys_GetRealTime (void)
return now - start;
}

//===========================================================================
// Sys_GetSeconds
// Returns the timer value in seconds.
//===========================================================================
/*
* Returns the timer value in seconds.
*/
double Sys_GetSeconds (void)
{
return (double) Sys_GetRealTime() / 1000.0;
}

//===========================================================================
// Sys_GetTimef
// Returns time in 35 Hz floating point tics.
//===========================================================================
/*
* Returns time in 35 Hz floating point tics.
*/
double Sys_GetTimef(void)
{
return (Sys_GetRealTime() / 1000.0 * ticsPerSecond);
}

//==========================================================================
// Sys_GetTime
// Returns time in 35 Hz tics.
//==========================================================================
/*
* Returns time in 35 Hz tics.
*/
int Sys_GetTime (void)
{
return (int) Sys_GetTimef();
}

//==========================================================================
// Sys_TicksPerSecond
// Set the number of game tics per second.
//==========================================================================
#if 0
/*
* Set the number of game tics per second.
*/
void Sys_TicksPerSecond(float num)
{
if(num <= 0) num = TICSPERSEC;
ticsPerSecond = num;
}
#endif

0 comments on commit f31c23c

Please sign in to comment.