summaryrefslogtreecommitdiff
path: root/plat.h
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-06-30 18:24:01 +1000
committerquou <quou@disroot.org>2024-06-30 18:27:11 +1000
commit39100e7292d3ee12d387fddfa0f0d7b712e31e1c (patch)
tree28f26b19de857868aeb9ecf23a7fecfc170addf9 /plat.h
initial commit.
Diffstat (limited to 'plat.h')
-rw-r--r--plat.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/plat.h b/plat.h
new file mode 100644
index 0000000..7e4f445
--- /dev/null
+++ b/plat.h
@@ -0,0 +1,58 @@
+#ifndef plat_h
+#define plat_h
+
+#include "error.h"
+#include "memory.h"
+#include "render.h"
+
+#ifdef assert
+#undef assert
+#endif
+
+#define assert(expr) \
+ imp_assert( \
+ expr, \
+ #expr, \
+ __FILE__, \
+ __LINE__ \
+ )
+
+int imp_assert(
+ int val,
+ const char* expr,
+ const char* file,
+ int line
+);
+
+void print(const char* fmt, ...);
+void print_err(const char* fmt, ...);
+void print_war(const char* fmt, ...);
+void pbreak(Error code);
+
+typedef struct {
+ int mpf;
+ int fps;
+ unsigned long pt, ct;
+ unsigned long now, next;
+} FPS;
+
+void init_fps(FPS* f, int mpf);
+void fps_begin(FPS* f);
+void fps_end(FPS* f);
+void fps_update(FPS* f);
+
+typedef struct {
+ int w, h, s, o, mpf;
+ int fps;
+ int mx, my;
+ Error err;
+ Colour* fb;
+ Heap* heap;
+} App;
+
+App* new_app(Heap* mem, int w, int h, const char* n);
+void deinit_app(App* a);
+void app_begin(App* a);
+void app_end(App* a);
+
+#endif