#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