37 lines
809 B
C
37 lines
809 B
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "time.h"
|
|
#include "util/memory.h"
|
|
#include "assert/assert.h"
|
|
|
|
dusktime_t TIME;
|
|
|
|
void timeInit(void) {
|
|
memoryZero(&TIME, sizeof(TIME));
|
|
|
|
// Set these to something non-zero.
|
|
TIME.lastTick = TIME_STEP;
|
|
TIME.delta = TIME.realDelta = TIME_STEP;
|
|
TIME.realTime = TIME.time = TIME_STEP * 2;
|
|
}
|
|
|
|
void timeUpdate(void) {
|
|
TIME.realDelta = timeDeltaGet();
|
|
|
|
#if TIME_DYNAMIC
|
|
TIME.delta = TIME.realDelta;
|
|
#else
|
|
TIME.delta = TIME_PLATFORM_STEP;
|
|
#endif
|
|
|
|
assertTrue(TIME.delta >= 0.0f, "Time delta is negative");
|
|
assertTrue(TIME.realDelta >= 0.0f, "Real time delta is negative");
|
|
|
|
TIME.time += TIME.delta;
|
|
TIME.realTime += TIME.realDelta;
|
|
} |