archivemuh
This commit is contained in:
37
archive/dusk/time.c
Normal file
37
archive/dusk/time.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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 = DUSK_TIME_STEP;
|
||||
TIME.delta = TIME.realDelta = DUSK_TIME_STEP;
|
||||
TIME.realTime = TIME.time = DUSK_TIME_STEP * 2;
|
||||
}
|
||||
|
||||
void timeUpdate(void) {
|
||||
TIME.realDelta = timeDeltaGet();
|
||||
|
||||
#if DUSK_TIME_DYNAMIC
|
||||
TIME.delta = TIME.realDelta;
|
||||
#else
|
||||
TIME.delta = DUSK_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;
|
||||
}
|
Reference in New Issue
Block a user