2023-09-15 18:35:27 -07:00
|
|
|
/*
|
|
|
|
Services the engine provides to the platform layer
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-10-06 23:33:39 -07:00
|
|
|
#if INTELLISENSE_DIRECTIVES
|
2023-09-23 18:52:38 -07:00
|
|
|
#include "platform/platform.hpp"
|
2023-10-11 14:52:13 -07:00
|
|
|
#include "engine_module.hpp"
|
|
|
|
#include "tile_map.hpp"
|
2023-10-10 10:08:08 -07:00
|
|
|
#endif
|
|
|
|
|
2023-09-15 18:35:27 -07:00
|
|
|
NS_ENGINE_BEGIN
|
|
|
|
|
2023-09-18 17:16:40 -07:00
|
|
|
struct Clocks
|
|
|
|
{
|
|
|
|
// TODO(Ed) : Clock values...
|
2023-09-30 07:05:37 -07:00
|
|
|
f32 seconds_elapsed;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ThreadContext
|
|
|
|
{
|
|
|
|
u32 placeholder;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MemorySnapshot
|
|
|
|
{
|
2023-09-30 12:40:27 -07:00
|
|
|
StrPath file_path;
|
|
|
|
void* opaque_handle;
|
|
|
|
void* opaque_handle_2;
|
|
|
|
void* memory;
|
2023-10-01 17:17:14 -07:00
|
|
|
u64 age;
|
2023-09-18 17:16:40 -07:00
|
|
|
};
|
|
|
|
|
2023-10-11 14:52:13 -07:00
|
|
|
|
|
|
|
enum ReplayMode : s32
|
|
|
|
{
|
|
|
|
ReplayMode_Off,
|
|
|
|
ReplayMode_Record,
|
|
|
|
ReplayMode_Playback
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ReplayData
|
|
|
|
{
|
|
|
|
static constexpr
|
|
|
|
s32 Num_Snapshot_Slots = 3;
|
|
|
|
// Abuse RAM to store snapshots of the Engine or Game state.
|
|
|
|
MemorySnapshot snapshots[ Num_Snapshot_Slots ];
|
|
|
|
s32 active_snapshot_slot;
|
|
|
|
|
|
|
|
// Recording and playback info is the same for either engine or game.
|
|
|
|
|
|
|
|
ReplayMode replay_mode;
|
|
|
|
platform::File active_input_replay_file;
|
|
|
|
|
|
|
|
// Engine-wide recording & playback loop.
|
|
|
|
s32 engine_loop_active;
|
|
|
|
s32 game_loop_active;
|
|
|
|
};
|
|
|
|
|
2023-09-18 17:16:40 -07:00
|
|
|
struct Memory
|
|
|
|
{
|
|
|
|
// All memory for the engine is required to be zero initialized.
|
|
|
|
|
|
|
|
// Wiped on shutdown
|
2023-10-11 14:52:13 -07:00
|
|
|
Byte* persistent;
|
|
|
|
ssize persistent_size;
|
2023-09-18 17:16:40 -07:00
|
|
|
|
|
|
|
// Wiped on a per-frame basis
|
|
|
|
// void* Frame;
|
|
|
|
// u64 FrameSize;
|
|
|
|
|
|
|
|
// Wiped whenever the engine wants to?
|
2023-10-11 14:52:13 -07:00
|
|
|
Byte* transient;
|
|
|
|
ssize transient_size;
|
2023-09-30 07:05:37 -07:00
|
|
|
|
2023-10-11 14:52:13 -07:00
|
|
|
// TODO(Ed) : Move this to state & replay archive definitions?
|
2023-09-30 12:40:27 -07:00
|
|
|
#if Build_Development
|
2023-09-30 07:05:37 -07:00
|
|
|
static constexpr
|
2023-10-01 17:17:14 -07:00
|
|
|
s32 Num_Snapshot_Slots = 3;
|
2023-09-30 07:05:37 -07:00
|
|
|
// Abuse RAM to store snapshots of the Engine or Game state.
|
|
|
|
MemorySnapshot snapshots[ Num_Snapshot_Slots ];
|
|
|
|
s32 active_snapshot_slot;
|
|
|
|
|
|
|
|
// Recording and playback info is the same for either engine or game.
|
|
|
|
|
2023-09-30 12:40:27 -07:00
|
|
|
ReplayMode replay_mode;
|
|
|
|
platform::File active_input_replay_file;
|
2023-09-30 07:05:37 -07:00
|
|
|
|
|
|
|
// Engine-wide recording & playback loop.
|
|
|
|
s32 engine_loop_active;
|
|
|
|
s32 game_loop_active;
|
2023-10-11 14:52:13 -07:00
|
|
|
|
|
|
|
//ReplayData replay;
|
2023-09-30 12:40:27 -07:00
|
|
|
#endif
|
2023-10-11 14:52:13 -07:00
|
|
|
|
|
|
|
// The game will have 1/4 of persistent's memory available ot it.
|
|
|
|
static constexpr
|
|
|
|
ssize game_memory_factor = 4;
|
|
|
|
|
|
|
|
ssize engine_persistent_size()
|
|
|
|
{
|
|
|
|
return persistent_size - persistent_size / game_memory_factor;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssize total_size()
|
2023-09-30 07:05:37 -07:00
|
|
|
{
|
|
|
|
return persistent_size + transient_size;
|
|
|
|
}
|
2023-09-18 17:16:40 -07:00
|
|
|
};
|
|
|
|
|
2023-10-11 14:52:13 -07:00
|
|
|
struct MemoryArena
|
|
|
|
{
|
|
|
|
Byte* storage;
|
|
|
|
ssize size;
|
|
|
|
ssize used;
|
|
|
|
};
|
|
|
|
|
2023-09-15 18:35:27 -07:00
|
|
|
struct OffscreenBuffer
|
|
|
|
{
|
2023-09-30 07:05:37 -07:00
|
|
|
void* memory; // Lets use directly mess with the "pixel's memory buffer"
|
|
|
|
u32 width;
|
|
|
|
u32 height;
|
|
|
|
u32 pitch;
|
|
|
|
u32 bytes_per_pixel;
|
2023-09-15 18:35:27 -07:00
|
|
|
};
|
|
|
|
|
2023-09-17 18:20:11 -07:00
|
|
|
// TODO : Will be gutting this once we have other stuff lifted.
|
2023-09-24 19:37:05 -07:00
|
|
|
struct AudioBuffer
|
2023-09-16 15:41:07 -07:00
|
|
|
{
|
2023-09-30 07:05:37 -07:00
|
|
|
s16* samples;
|
|
|
|
u32 running_sample_index;
|
|
|
|
s32 samples_per_second;
|
|
|
|
s32 num_samples;
|
2023-09-16 15:41:07 -07:00
|
|
|
};
|
|
|
|
|
2023-10-04 10:55:15 -07:00
|
|
|
struct World
|
|
|
|
{
|
2023-10-10 21:56:16 -07:00
|
|
|
// TODO(Ed) : Remove
|
|
|
|
f32 tile_lower_left_x;
|
|
|
|
f32 tile_lower_left_y;
|
|
|
|
|
2023-10-11 14:52:13 -07:00
|
|
|
TileMap* tile_map;
|
2023-10-06 10:06:40 -07:00
|
|
|
};
|
|
|
|
|
2023-09-15 18:35:27 -07:00
|
|
|
NS_ENGINE_END
|