In process of migrating to ANSI C.

This commit is contained in:
2026-03-21 17:08:46 -07:00
parent a9573a440e
commit 8af1c59bb6
6 changed files with 222 additions and 133 deletions
+25 -26
View File
@@ -1,16 +1,13 @@
#ifndef HANDMADE_H
#define HANDMADE_H
#ifndef HANDMADE_H_SENTRY
#define HANDMADE_H_SENTRY
#include "sdl_handmade.h"
#include "core.h"
///////////////////////////////////////////////////////////////////////////////
// NOTE: Servcies that the platform layer provides to the game. //
///////////////////////////////////////////////////////////////////////////////
/* --------------------------------------------------------------------- */
/* NOTE: Servcies that the platform layer provides to the game. */
/* --------------------------------------------------------------------- */
#if BUILD_INTERNAL
// NOTE: WARNING: Not for the shipping game.
typedef struct debug_read_file_result {
U32 ContentsSize;
void *Contents;
@@ -21,12 +18,12 @@ B32 DEBUGPlatformWriteEntireFile(const char *Filename, U32 MemorySize, void *Mem
void DEBUGPlatformFreeFileMemory(void *Memory);
#endif
///////////////////////////////////////////////////////////////////////////////
// NOTE: Servcies that the game provides to the platform layer. //
///////////////////////////////////////////////////////////////////////////////
/* --------------------------------------------------------------------- */
/* NOTE: Servcies that the game provides to the platform layer. */
/* --------------------------------------------------------------------- */
typedef struct game_offscreen_buffer {
// Pixels are always 32-bit and have the bytes in BGRX (little-endian).
/* Pixels are always 32-bit and have the bytes in BGRX (little-endian). */
void *Memory;
S32 Width;
S32 Height;
@@ -70,7 +67,7 @@ typedef struct game_controller_input {
game_button_state Start;
game_button_state Back;
// NOTE: All buttons must be added above this line.
/* NOTE: All buttons must be added above this line. */
game_button_state Terminator;
};
@@ -78,11 +75,11 @@ typedef struct game_controller_input {
} game_controller_input;
typedef struct game_input {
// TODO: Insert clock value here . . .
/* TODO: Insert clock value here . . . */
game_controller_input Controllers[5];
} game_input;
inline game_controller_input *GetController(game_input *Input, S32 ControllerIndex)
game_controller_input *GetController(game_input *Input, S32 ControllerIndex)
{
Assert((U32)ControllerIndex < ARRAY_SIZE(Input->Controllers));
game_controller_input *Result = &(Input->Controllers[ControllerIndex]);
@@ -93,26 +90,28 @@ typedef struct game_memory {
B32 IsInitialized;
U64 PermanentStorageSize;
void *PermanentStorage; // WARNING: This memory is REQUIRED to be zero initialized!!! (Done by the OS layer.)
void *PermanentStorage; /* WARNING: This memory is REQUIRED to be zero initialized!!! (Done by the OS layer.) */
U64 TransientStorageSize;
void *TransientStorage; // WARNING: This memory is REQUIRED to be zero initialized!!! (Done by the OS layer.)
void *TransientStorage; /* WARNING: This memory is REQUIRED to be zero initialized!!! (Done by the OS layer.) */
#if BUILD_INTERNAL
debug_read_file_result (*DEBUGPlatformReadEntireFile)(const char *);
B32 (*DEBUGPlatformWriteEntireFile)(const char *, U32, void *);
void (*DEBUGPlatformFreeFileMemory)(void *);
#endif
} game_memory;
// typedef struct game_clocks {
// U64 Ticks;
// F32 SecondsElapsed;
// } game_clocks;
/*typedef struct game_clocks {
U64 Ticks;
F32 SecondsElapsed;
} game_clocks;*/
extern "C" void UpdateAndRender(game_memory *Memory, game_input *Input, game_offscreen_buffer *Buffer, game_sound_output_buffer *SoundBuffer);
void UpdateAndRender(game_memory *Memory, game_input *Input, game_offscreen_buffer *Buffer, game_sound_output_buffer *SoundBuffer);
//
//
//
/**/
/**/
/**/
typedef struct game_state {
S32 ToneHz;
@@ -122,4 +121,4 @@ typedef struct game_state {
F32 tSine;
} game_state;
#endif // HANDMADE_H
#endif