add missing tools/pngdump to the repo
[gbajam22] / src / debug.c
index 42d1343..e36ed1f 100644 (file)
@@ -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);
 
@@ -84,24 +87,28 @@ void panic(void *pc, const char *fmt, ...)
 
 #endif
 
+int glyphcolor = 0xff;
+int glyphbg = 0;
+void *glyphfb = (void*)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 : 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;
        }
 }