From e24186fc1917c5e8b91924af0c3c7c55816ff5d6 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Mon, 25 Jan 2021 22:01:00 +0100 Subject: Introducing MIC --- src/app.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/app.h (limited to 'src/app.h') diff --git a/src/app.h b/src/app.h new file mode 100644 index 0000000..8edbe58 --- /dev/null +++ b/src/app.h @@ -0,0 +1,37 @@ +#ifndef MIC_APP_H +#define MIC_APP_H + +#include "shorthand.h" +#include "platform.h" + +#define LT_MEMORY_SIZE GB(2) +#define ST_MEMORY_SIZE MB(100) + +typedef struct AppState { + // Long and short term memory. + char *lt_memory; + char *st_memory; +} AppState; + +// Function pointers for the AppAPI. +typedef struct AppAPI { + // Initialization code. Meant to be called exactly once before other API + // interactions. Returns the success or failure of the initialization + // process. + bool (*init)(AppState *state, PlatformAPI platform); + + // Resource deallocation and cleanup. Meant to be called exactly once at the + // end of the app. + void (*destroy)(AppState *state, PlatformAPI platform); + + // In case of hot code reloading, these functions handle the necessary + // resource setup and reloading. + void (*reload)(AppState *state, PlatformAPI platform); + void (*unload)(AppState *state, PlatformAPI platform); + + // Main update/step function for the app. Returns if the app should keep + // running. + bool (*step)(AppState *state, PlatformAPI platform); +} AppAPI; + +#endif // MIC_APP_H -- cgit v1.2.1