X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgame.c;fp=src%2Fgame.c;h=38136aa7a0e9fe52f1b81764e6ff931244ad4928;hb=b0f9c6ecc15c2d4b5df77a7a963b742a6352ee1a;hp=0000000000000000000000000000000000000000;hpb=bb895563088da093a90f42fc6a532688adc36cf2;p=gbajam22 diff --git a/src/game.c b/src/game.c new file mode 100644 index 0000000..38136aa --- /dev/null +++ b/src/game.c @@ -0,0 +1,52 @@ +#include +#include "gba.h" +#include "game.h" + +struct screen *init_menu_screen(void); +struct screen *init_game_screen(void); + +struct screen *curscr; + +#define MAX_SCR 4 +static struct screen *scrlist[MAX_SCR]; +static int num_scr; + +int init_screens(void) +{ + if(!(scrlist[num_scr++] = init_menu_screen())) { + return -1; + } + if(!(scrlist[num_scr++] = init_game_screen())) { + return -1; + } + return 0; +} + +int change_screen(struct screen *scr) +{ + if(!scr) return -1; + + mask(INTR_VBLANK); + + if(scr->start && scr->start() == -1) { + return -1; + } + if(curscr && curscr->stop) { + curscr->stop(); + } + curscr = scr; + + unmask(INTR_VBLANK); + return 0; +} + +struct screen *find_screen(const char *name) +{ + int i; + for(i=0; iname, name) == 0) { + return scrlist[i]; + } + } + return 0; +}