From bf4c35d5afd97b7a681177810f1fb26eea84044f Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sun, 30 Oct 2022 21:42:28 +0200 Subject: [PATCH] janky victory screen --- src/debug.c | 24 +++++++++++++++--------- src/debug.h | 3 +++ src/gamescr.c | 9 +++++++++ src/gba/main.c | 2 +- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/debug.c b/src/debug.c index 42d1343..ee94699 100644 --- a/src/debug.c +++ b/src/debug.c @@ -73,6 +73,9 @@ 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); @@ -84,24 +87,27 @@ void panic(void *pc, const char *fmt, ...) #endif +int glyphcolor = 0xff; +void *glyphfb = VRAM_LFB_FB0_ADDR; + void dbg_drawglyph(int x, int y, int c) { int i; uint16_t pp; unsigned char row; - uint16_t *ptr = (uint16_t*)VRAM_LFB_FB0_ADDR + (y << 7) - (y << 3) + (x >> 1); + uint16_t *ptr = (uint16_t*)glyphfb + (y << 7) - (y << 3) + (x >> 1); unsigned char *fnt = font_8x8 + ((c & 0xff) << 3); for(i=0; i<8; i++) { row = *fnt++; - pp = row & 0x80 ? 0xff : 0; - *ptr++ = pp | (row & 0x40 ? 0xff00 : 0); - pp = row & 0x20 ? 0xff : 0; - *ptr++ = pp | (row & 0x10 ? 0xff00 : 0); - pp = row & 0x08 ? 0xff : 0; - *ptr++ = pp | (row & 0x04 ? 0xff00 : 0); - pp = row & 0x02 ? 0xff : 0; - *ptr++ = pp | (row & 0x01 ? 0xff00 : 0); + 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); ptr += 120 - 4; } } diff --git a/src/debug.h b/src/debug.h index 80a7826..0d52110 100644 --- a/src/debug.h +++ b/src/debug.h @@ -28,6 +28,9 @@ void vblperf_setcolor(int palidx); #define vblperf_end() #endif +extern int glyphcolor; +extern void *glyphfb; + void panic(void *pc, const char *fmt, ...) __attribute__((noreturn)); void dbg_drawglyph(int x, int y, int c); diff --git a/src/gamescr.c b/src/gamescr.c index 18ef9e5..896af07 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -182,6 +182,7 @@ static int gamescr_start(void) } } endspawn: + total_enemies = 1; /* XXX DBG */ /* check continuity */ for(i=0; i= 0) { + glyphcolor = 200; + glyphfb = framebuf; + dbg_drawstr(80, 10, "Victory!"); + dbg_drawstr(60, 20, "Score: %d", score); + dbg_drawstr(59, 30, "Completed in: %lus", total_time); + } } static void victory(void) diff --git a/src/gba/main.c b/src/gba/main.c index 4ade404..478b8f6 100644 --- a/src/gba/main.c +++ b/src/gba/main.c @@ -45,7 +45,7 @@ int main(void) panic(get_pc(), "failed to initialize screens"); } - if(change_screen(find_screen("logo")) == -1) { + if(change_screen(find_screen("game")) == -1) { panic(get_pc(), "failed to find starting screen"); } -- 1.7.10.4