archivemuh

This commit is contained in:
2025-08-20 19:18:38 -05:00
parent 1411c2e96b
commit fbfcbe9578
173 changed files with 2802 additions and 13 deletions

10
src/time/CMakeLists.txt Normal file
View File

@@ -0,0 +1,10 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
time.c
)

41
src/time/time.c Normal file
View File

@@ -0,0 +1,41 @@
/**
* 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;
}
float_t timeDeltaGet(void) {
return 0.1f;
}

52
src/time/time.h Normal file
View File

@@ -0,0 +1,52 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
typedef struct {
float_t delta;
float_t lastTick;
float_t time;
float_t realDelta;
float_t realTime;
} dusktime_t;
extern dusktime_t TIME;
#define DUSK_TIME_STEP (1.0f / 60.0f) // Default to 60FPS
#ifndef DUSK_TIME_DYNAMIC
#define DUSK_TIME_DYNAMIC 1
#endif
#if DUSK_TIME_DYNAMIC == 0
#ifndef DUSK_TIME_PLATFORM_STEP
#define DUSK_TIME_PLATFORM_STEP DUSK_TIME_STEP
#endif
#endif
/**
* Initializes the time system.
*/
void timeInit(void);
/**
* Updates the time system
*/
void timeUpdate(void);
#if DUSK_TIME_DYNAMIC == 1
/**
* Gets the time delta since the last frame, in seconds. Tied to the
* platform.
*
* This will only get called once per gameUpdate.
*/
float_t timeDeltaGet(void);
#endif