mirror of
https://github.com/TheOnlyZac/sly1.git
synced 2024-11-27 15:40:51 +00:00
84 lines
1.6 KiB
C
84 lines
1.6 KiB
C
/**
|
|
* @file clock.h
|
|
*
|
|
* @brief Engine clock
|
|
*/
|
|
#ifndef CLOCK_H
|
|
#define CLOCK_H
|
|
|
|
#include "common.h"
|
|
|
|
typedef unsigned long long TICK;
|
|
|
|
/**
|
|
* @brief Engine clock.
|
|
*/
|
|
struct CLOCK
|
|
{
|
|
int fEnabled; // clock enabled flag
|
|
float t;
|
|
float dt; // time since last frame
|
|
float dtPrev; // dt from previous frame
|
|
float tReal; // t factoring in EE clock cyclerate
|
|
float dtReal; // dt factoring in EE clock cyclerate
|
|
TICK tickFrame;
|
|
};
|
|
|
|
/**
|
|
* @brief Sets the rate of the global clock.
|
|
*
|
|
* @param rt The new tick rate.
|
|
*/
|
|
void SetClockRate(float rt);
|
|
|
|
/**
|
|
* @brief Updates clock values based to time elapsed.
|
|
*
|
|
* @param pclock Pointer to the clock.
|
|
*/
|
|
void MarkClockTick(CLOCK *pclock);
|
|
|
|
/**
|
|
* @brief Updates clock values based to time elapsed.
|
|
*
|
|
* Only updates the real clock values (those determined by the EE clock cyclerate).
|
|
*
|
|
* @param pclock Pointer to the clock.
|
|
*/
|
|
void MarkClockTickRealOnly(CLOCK *pClock);
|
|
|
|
/**
|
|
* @brief Resets the clock to the given time t.
|
|
*
|
|
* @param pclock Pointer to the clock.
|
|
* @param t Time to set.
|
|
*/
|
|
void ResetClock(CLOCK *pclock, float t);
|
|
|
|
/**
|
|
* @brief Sets the fEnabled flag on the clock to the given value.
|
|
*
|
|
* @param pclock Pointer to the clock.
|
|
* @param fEnabled 1 to enable, 0 to disable.
|
|
*/
|
|
void SetClockEnabled(CLOCK *pclock, int fEnabled);
|
|
|
|
/**
|
|
* @brief Initializes and enables the global clock.
|
|
*/
|
|
void StartupClock();
|
|
|
|
/**
|
|
* @brief Gets the current tick.
|
|
*
|
|
* @return The current tick.
|
|
*/
|
|
const TICK TickNow();
|
|
|
|
extern float g_rtClock;
|
|
extern float g_rtClockPowerUp;
|
|
extern struct CLOCK g_clock;
|
|
extern TICK s_tickLastRaw;
|
|
|
|
#endif // CLOCK_H
|