keep scores and settings in SRAM
[gbajam22] / src / gba / main.c
index 068f3d1..4ade404 100644 (file)
@@ -4,9 +4,12 @@
 #include "debug.h"
 #include "game.h"
 #include "maxmod.h"
+#include "input.h"
+#include "timer.h"
+#include "xgl.h"
+#include "scoredb.h"
 
 static void vblank(void);
-static void nopfunc(void);
 
 int main(void)
 {
@@ -28,32 +31,43 @@ int main(void)
        mmStart(MOD_POPCORN, MM_PLAY_LOOP);
 #endif
 
-       screen_vblank = nopfunc;
-
        intr_disable();
        interrupt(INTR_VBLANK, vblank);
        REG_DISPSTAT |= DISPSTAT_IEN_VBLANK;
        unmask(INTR_VBLANK);
 
+       load_scores();
+       gba_colors = scores[10].score & 1;
+
+       xgl_init();
+
+       if(init_screens() == -1) {
+               panic(get_pc(), "failed to initialize screens");
+       }
+
+       if(change_screen(find_screen("logo")) == -1) {
+               panic(get_pc(), "failed to find starting screen");
+       }
+
+       reset_msec_timer();
        intr_enable();
-       gamescr();
 
-       for(;;);
+       for(;;) {
+               curscr->frame();
+       }
        return 0;
 }
 
+ARM_IWRAM
 static void vblank(void)
 {
        vblperf_count++;
 
-       screen_vblank();
+       keyb_vblank();
+       curscr->vblank();
 
 #ifndef NOSOUND
        mmVBlank();
        mmFrame();
 #endif
 }
-
-static void nopfunc(void)
-{
-}