#ifndef HANDMADE_H #define HANDMADE_H #include "sdl_handmade.h" #include "core.h" /////////////////////////////////////////////////////////////////////////////// // 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; } debug_read_file_result; debug_read_file_result DEBUGPlatformReadEntireFile(const char *Filename); B32 DEBUGPlatformWriteEntireFile(const char *Filename, U32 MemorySize, void *Memory); void DEBUGPlatformFreeFileMemory(void *Memory); #endif /////////////////////////////////////////////////////////////////////////////// // 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). void *Memory; S32 Width; S32 Height; S32 Pitch; } game_offscreen_buffer; typedef struct game_sound_output_buffer { S32 SamplesPerSecond; S32 SampleCount; S16 *Samples; } game_sound_output_buffer; typedef struct game_button_state { S32 HalfTransitionCount; B32 EndedDown; } game_button_state; typedef struct game_controller_input { B32 IsConnected; B32 IsAnalog; F32 StickAverageX; F32 StickAverageY; union { game_button_state Buttons[12]; struct { game_button_state MoveUp; game_button_state MoveDown; game_button_state MoveLeft; game_button_state MoveRight; game_button_state ActionUp; game_button_state ActionDown; game_button_state ActionLeft; game_button_state ActionRight; game_button_state LeftShoulder; game_button_state RightShoulder; game_button_state Start; game_button_state Back; // NOTE: All buttons must be added above this line. game_button_state Terminator; }; }; } game_controller_input; typedef struct game_input { // TODO: Insert clock value here . . . game_controller_input Controllers[5]; } game_input; inline game_controller_input *GetController(game_input *Input, S32 ControllerIndex) { Assert((U32)ControllerIndex < ARRAY_SIZE(Input->Controllers)); game_controller_input *Result = &(Input->Controllers[ControllerIndex]); return Result; } typedef struct game_memory { B32 IsInitialized; U64 PermanentStorageSize; 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.) debug_read_file_result (*DEBUGPlatformReadEntireFile)(const char *); B32 (*DEBUGPlatformWriteEntireFile)(const char *, U32, void *); void (*DEBUGPlatformFreeFileMemory)(void *); } game_memory; // 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); // // // typedef struct game_state { S32 ToneHz; S32 GreenOffset; S32 BlueOffset; } game_state; #endif // HANDMADE_H