Archival snapshot of the Virtual World Entertainment Tesla cockpit software, 1994-1996: MUNGA engine and L4 pod layer source (Borland C++ 5.0), BT/RP game code, and game content (models, audio, maps, gauges, Division renderer data). Includes third-party libraries: Division dVS/DPL graphics, HMI SOS audio, WATTCP networking. Files are preserved byte-for-byte (.gitattributes disables all line-ending conversion). README.md documents the layout, target hardware, and toolchain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
138 lines
4.1 KiB
C++
138 lines
4.1 KiB
C++
//===========================================================================//
|
|
// File: time.cc //
|
|
// Project: MUNGA Brick: Time Manager //
|
|
// Contents: Implementation details of the Time Manager //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 10/19/94 JMA Initial coding. //
|
|
// 10/24/94 JMA Added Lester's IBM RTC code in as SystemClock class //
|
|
// 10/28/94 JMA Made compatible with SGI CC //
|
|
// 11/03/94 ECH Made compatible with BC4.0 //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
|
|
// PROPRIETARY AND CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#include <munga.hpp>
|
|
#pragma hdrstop
|
|
|
|
#if !defined(TIME_HPP)
|
|
#include <time.hpp>
|
|
#endif
|
|
|
|
//#############################################################################
|
|
//########################### 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 = 0L;
|
|
}
|
|
|
|
//
|
|
//--------------------------------------------------------
|
|
// Otherwise, start pausing by marking what time it is now
|
|
//--------------------------------------------------------
|
|
//
|
|
else
|
|
{
|
|
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;
|
|
}
|
|
|
|
//
|
|
//----------------------------------------------------------------
|
|
// Otherwise, return the timer minus the amount of pause time lost
|
|
//----------------------------------------------------------------
|
|
//
|
|
else
|
|
{
|
|
result = SystemClock::GetRTC() - SystemClock::timer.pauseTime;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
//#############################################################################
|
|
//############################### 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
|
|
|