Imports the current Win32 source for the pod-racing game 'Red Planet', built on the MUNGA engine and its L4 (Win32/DirectX) platform layer: - MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend - RP / RP_L4: Red Planet game logic and Win32 application - DivLoader, Setup1: asset loader and installer project - lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies Removed stale Subversion metadata and added .gitignore/.gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
118 lines
2.9 KiB
C++
118 lines
2.9 KiB
C++
#include "munga.h"
|
|
#pragma hdrstop
|
|
|
|
#include "time.h"
|
|
|
|
//#############################################################################
|
|
//########################### System Clock ##############################
|
|
//#############################################################################
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void SystemClock::TogglePause()
|
|
{
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// If the clock is currently paused, figure out how long it was paused
|
|
// and add that to the pause delay
|
|
//--------------------------------------------------------------------
|
|
//
|
|
if (timer.pauseStart)
|
|
{
|
|
timer.pauseTime += GetRTC() - timer.pauseStart;
|
|
timer.pauseStart = 0;
|
|
}
|
|
else
|
|
{
|
|
//--------------------------------------------------------
|
|
// Otherwise, start pausing by marking what time it is now
|
|
//--------------------------------------------------------
|
|
timer.pauseStart = GetRTC();
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
volatile Time& Now()
|
|
{
|
|
static Time result;
|
|
|
|
//
|
|
//-------------------------------------------------
|
|
// If we are in pause mode, return the paused clock
|
|
//-------------------------------------------------
|
|
//
|
|
if (SystemClock::timer.pauseStart)
|
|
{
|
|
result = SystemClock::timer.pauseStart;
|
|
}
|
|
else
|
|
{
|
|
//----------------------------------------------------------------
|
|
// Otherwise, return the timer minus the amount of pause time lost
|
|
//----------------------------------------------------------------
|
|
result = SystemClock::GetRTC() - SystemClock::timer.pauseTime;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
double HiResNow()
|
|
{
|
|
return SystemClock::GetHiRes();
|
|
}
|
|
|
|
__int64 HiResNowTicks()
|
|
{
|
|
return SystemClock::GetHiResTicks();
|
|
}
|
|
|
|
__int64 HiResCounterFreq()
|
|
{
|
|
return SystemClock::perfCounterFreq;
|
|
}
|
|
//#############################################################################
|
|
//############################### Time ##################################
|
|
//#############################################################################
|
|
|
|
Time Time::Null(SystemClock::timer);
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
int Is_Signature_Bad(const volatile Time *)
|
|
{
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Logical Time::TestInstance() const volatile
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Time functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
void Convert_From_Ascii(const char *str, Time *time)
|
|
{
|
|
Check_Pointer(str);
|
|
Check_Signature(time);
|
|
|
|
Scalar seconds;
|
|
|
|
seconds = atof(str);
|
|
*time = seconds;
|
|
Check(time);
|
|
}
|
|
|
|
#if defined(TEST_CLASS)
|
|
#include "time.tcp"
|
|
#endif
|