summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..91075f1
--- /dev/null
+++ b/main.c
@@ -0,0 +1,67 @@
+#include "memory.h"
+#include "plat.h"
+#include "rcache.h"
+#include "ui.h"
+#include "library.h"
+
+UI* ui;
+Library* lib;
+
+Font* ffont;
+void prog_init(void* memory) {
+ Heap* fh;
+ unsigned char* bin;
+ int bin_size;
+ int fhs = 1024 * 1024 * 4;
+ Font* font;
+ memory_init(memory);
+ rc_init();
+ fh = galloc(sizeof *fh);
+ init_heap(fh, galloc(fhs), fhs);
+ bin = load_binary(default_font_location, &bin_size);
+ font = new_font(fh, bin, default_font_size);
+ ui = stack_alloc(sizeof *ui);
+ init_ui(ui, font);
+ lib = stack_alloc(sizeof *lib);
+ init_library(lib);
+ build_library(lib, library_folder);
+}
+
+void prog_update(void) {
+ Rectangle l, r, lc, list;
+ int h, i, c;
+ rc_begin();
+ ui_begin(ui, &l);
+ rc_add_cmd_rect(&l, theme_background_colour);
+
+ r = rectcut_right(&l, l.w / 2);
+ h = font_height(ui->font) + theme_padding * 2;
+ c = lib->song_count;
+ lc.x = 0;
+ lc.y = 0;
+ lc.w = r.w - theme_padding * 2;
+ lc.h = h * c + theme_padding * (c - 1);
+ ui_container(
+ ui,
+ &r,
+ &lc,
+ &lc
+ );
+ list = lc;
+ list.h = h;
+ for (i = 0; i < max_songs; i++) {
+ Song* song = &lib->songs[i];
+ if (song->file[0]) {
+ ui_button(ui, &list, song->name);
+ list.y += list.h + theme_padding;
+ }
+ }
+ rc_add_cmd_reset_clip();
+
+ ui_end(ui);
+ rc_flush();
+}
+
+void prog_deinit(void) {
+
+}