aboutsummaryrefslogtreecommitdiff
path: root/hftrss.c
diff options
context:
space:
mode:
Diffstat (limited to 'hftrss.c')
-rw-r--r--hftrss.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/hftrss.c b/hftrss.c
index 1b903c1..b52fcd6 100644
--- a/hftrss.c
+++ b/hftrss.c
@@ -6,14 +6,13 @@
#include "plat.h"
#include "render.h"
-int entrypoint(int argc, const char** argv, Arena* m) {
- Heap h;
- App* a;
- FPS f;
- Renderer r;
- Game* game;
- (void)argc;
- (void)argv;
+static Heap h;
+static App* a;
+static FPS f;
+static Renderer r;
+static Game* game;
+
+int prog_init(Arena* m) {
init_maths();
init_heap(
&h,
@@ -25,21 +24,27 @@ int entrypoint(int argc, const char** argv, Arena* m) {
init_fps(&f, default_mpf);
game = arena_alloc(m, sizeof *game);
init_game(game, game_state_menu);
- while (a->o) {
- fps_begin(&f);
- while (f.now >= f.next && a->o) {
- app_begin(a);
- update_game(game, a);
- ren_begin(&r, a->fb, viewport_w, viewport_h);
- ren_clear(&r);
- ren_game(game, &r);
- ren_end(&r);
- app_end(a);
- fps_update(&f);
- }
- fps_end(&f);
+ return 0;
+}
+
+int prog_update(void) {
+ fps_begin(&f);
+ while (f.now >= f.next && a->o) {
+ app_begin(a);
+ update_game(game, a);
+ ren_begin(&r, a->fb, viewport_w, viewport_h);
+ ren_clear(&r);
+ ren_game(game, &r);
+ ren_end(&r);
+ app_end(a);
+ fps_update(&f);
}
+ fps_end(&f);
+ return a->o;
+}
+
+void prog_deinit(void) {
deinit_audio();
deinit_app(a);
- return error_none;
}
+