From: John Tsiombikas Date: Sun, 30 Oct 2022 23:00:17 +0000 (+0200) Subject: score display, and hit frame re-init X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=gbajam22;a=commitdiff_plain;h=695487a7a2c44e73c758c50cdbf84b9ef370651b score display, and hit frame re-init --- diff --git a/src/debug.c b/src/debug.c index ee94699..e36ed1f 100644 --- a/src/debug.c +++ b/src/debug.c @@ -37,6 +37,9 @@ void panic(void *pc, const char *fmt, ...) intr_disable(); REG_DISPCNT = 4 | DISPCNT_BG2; + glyphcolor = 0xff; + glyphfb = (void*)VRAM_LFB_FB0_ADDR; + set_bg_color(0, 31, 0, 0); set_bg_color(0xff, 31, 31, 31); @@ -73,9 +76,6 @@ void panic(void *pc, const char *fmt, ...) { va_list ap; - glyphcolor = 0xff; - glyphfb = VRAM_LFB_FB0_ADDR; - fputs("~~~ PANIC ~~~\n", stderr); va_start(ap, fmt); vfprintf(stderr, fmt, ap); @@ -88,7 +88,8 @@ void panic(void *pc, const char *fmt, ...) #endif int glyphcolor = 0xff; -void *glyphfb = VRAM_LFB_FB0_ADDR; +int glyphbg = 0; +void *glyphfb = (void*)VRAM_LFB_FB0_ADDR; void dbg_drawglyph(int x, int y, int c) { @@ -100,14 +101,14 @@ void dbg_drawglyph(int x, int y, int c) for(i=0; i<8; i++) { row = *fnt++; - pp = row & 0x80 ? glyphcolor : 0; - *ptr++ = pp | (row & 0x40 ? (glyphcolor << 8) : 0); - pp = row & 0x20 ? glyphcolor : 0; - *ptr++ = pp | (row & 0x10 ? (glyphcolor << 8) : 0); - pp = row & 0x08 ? glyphcolor : 0; - *ptr++ = pp | (row & 0x04 ? (glyphcolor << 8) : 0); - pp = row & 0x02 ? glyphcolor : 0; - *ptr++ = pp | (row & 0x01 ? (glyphcolor << 8) : 0); + pp = row & 0x80 ? glyphcolor : glyphbg; + *ptr++ = pp | ((row & 0x40 ? glyphcolor : glyphbg) << 8); + pp = row & 0x20 ? glyphcolor : glyphbg; + *ptr++ = pp | ((row & 0x10 ? glyphcolor : glyphbg) << 8); + pp = row & 0x08 ? glyphcolor : glyphbg; + *ptr++ = pp | ((row & 0x04 ? glyphcolor : glyphbg) << 8); + pp = row & 0x02 ? glyphcolor : glyphbg; + *ptr++ = pp | ((row & 0x01 ? glyphcolor : glyphbg) << 8); ptr += 120 - 4; } } diff --git a/src/debug.h b/src/debug.h index 0d52110..4afad76 100644 --- a/src/debug.h +++ b/src/debug.h @@ -28,7 +28,7 @@ void vblperf_setcolor(int palidx); #define vblperf_end() #endif -extern int glyphcolor; +extern int glyphcolor, glyphbg; extern void *glyphfb; void panic(void *pc, const char *fmt, ...) __attribute__((noreturn)); diff --git a/src/gamescr.c b/src/gamescr.c index 896af07..b7e35d2 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -59,7 +59,7 @@ static int hit_px, hit_py; #define COLOR_HORIZON 192 #define COLOR_ZENITH 255 -#define MAX_SPR 32 +#define MAX_SPR 40 static uint16_t oam[4 * MAX_SPR]; static int dynspr_base, dynspr_count; @@ -74,6 +74,7 @@ static int energy; static int score; static unsigned long total_time, start_time; +static int running; #define XFORM_PIXEL_X(x, y) (xform_ca * (x) - xform_sa * (y) + (120 << 8)) #define XFORM_PIXEL_Y(x, y) (xform_sa * (x) + xform_ca * (y) + (80 << 8)) @@ -202,13 +203,19 @@ endspawn: total_time = 0; start_time = timer_msec; + hitfrm = 0; + vblcount = 0; nframes = 0; + + running = 1; return 0; } static void gamescr_stop(void) { + running = 0; + iwram_brk(prev_iwram_top); wait_vblank(); @@ -439,11 +446,19 @@ static void draw(void) //vox_sky_solid(COLOR_ZENITH); if(score >= 0) { - glyphcolor = 200; + int sec = total_time / 1000; + + fillblock_16byte(framebuf + 8 * 240 / 2, 199 | (199 << 8) | (199 << 16) | (199 << 24), 40 * 240 / 16); + glyphfb = framebuf; + glyphbg = 199; + glyphcolor = 197; dbg_drawstr(80, 10, "Victory!"); - dbg_drawstr(60, 20, "Score: %d", score); - dbg_drawstr(59, 30, "Completed in: %lus", total_time); + glyphcolor = 200; + dbg_drawstr(30, 20, " Score: %d", score); + dbg_drawstr(30, 28, "Completed in: %lum.%lus", sec / 60, sec % 60); + glyphcolor = 198; + dbg_drawstr(85, 40, "Press start to exit"); } } @@ -476,6 +491,8 @@ static void gamescr_vblank(void) static int bank, bankdir, theta; int32_t sa, ca; + if(!running) return; + vblcount++; /* TODO: pre-arrange sprite tiles in gba-native format, so that I can just