X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmain.c;h=e1c3af09595e0e3472c81c2bd166f491fa9ff152;hb=ff74cf463fa44906add9344891096cada0970205;hp=d7a3308b5d0c281bacc8298b480e6bda8965df98;hpb=ffae5f4e018d05dac4b986497169039bbba46acf;p=gbajam21 diff --git a/src/main.c b/src/main.c index d7a3308..e1c3af0 100644 --- a/src/main.c +++ b/src/main.c @@ -2,35 +2,50 @@ #include "gbaregs.h" #include "intr.h" #include "debug.h" +#include "game.h" +#include "data.h" +#include "maxmod.h" -#define RGB15(r, g, b) \ - (((uint16_t)(r) & 0x1f) | \ - (((uint16_t)(g) & 0x1f) << 5) | \ - (((uint16_t)(b) & 0x1f) << 10)) +static void vblank(void); +static void nopfunc(void); int main(void) { - int i, j; - uint16_t *vptr; + intr_init(); - emuprint("\nStarting GBAJAM21\n-----------------\n"); + REG_WAITCNT = WAITCNT_PREFETCH | WAITCNT_ROM_2_1; - intr_init(); +#ifndef NOSOUND + mmInitDefault(sound_data, 8); + mmStart(MOD_POPCORN, MM_PLAY_LOOP); +#endif - REG_DISPCNT = 3 | DISPCNT_BG2; + screen_vblank = nopfunc; - vptr = (uint16_t*)VRAM_START_ADDR; - for(i=0; i<160; i++) { - for(j=0; j<240; j++) { - int xor = i ^ j; - int r = xor >> 2; - int g = xor >> 1; - int b = xor; + intr_disable(); + interrupt(INTR_VBLANK, vblank); + REG_DISPSTAT |= DISPSTAT_IEN_VBLANK; + unmask(INTR_VBLANK); - *vptr++ = RGB15(r, g, b); - } - } + intr_enable(); + gamescr(); for(;;); return 0; } + +static void vblank(void) +{ + vblperf_count++; + + screen_vblank(); + +#ifndef NOSOUND + mmVBlank(); + mmFrame(); +#endif +} + +static void nopfunc(void) +{ +}