new code to collect/use more stats, some debug tools
authornotaz <notasas@gmail.com>
Fri, 4 Jul 2008 15:06:09 +0000 (15:06 +0000)
committernotaz <notasas@gmail.com>
Fri, 4 Jul 2008 15:06:09 +0000 (15:06 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@520 be3aeb3a-fb24-0410-a615-afba39da0efa

gp2x/menu.c

index c428a60..b7c926f 100644 (file)
@@ -432,8 +432,10 @@ rescan:
 // ------------ debug menu ------------\r
 \r
 char *debugString(void);\r
+void PicoDrawShowSpriteStats(unsigned short *screen);\r
+void PicoDrawShowPalette(unsigned short *screen);\r
 \r
-static void draw_debug(void)\r
+static void draw_main_debug(void)\r
 {\r
        char *p, *str = debugString();\r
        int len, line;\r
@@ -450,13 +452,47 @@ static void draw_debug(void)
                if (*p == 0) break;\r
                p++; str = p;\r
        }\r
-       menu_flip();\r
+}\r
+\r
+static void draw_frame_debug(void)\r
+{\r
+       char layer_str[48] = "layers:             ";\r
+       if (PicoDrawMask & PDRAW_LAYERB_ON)      memcpy(layer_str +  8, "B", 1);\r
+       if (PicoDrawMask & PDRAW_LAYERA_ON)      memcpy(layer_str + 10, "A", 1);\r
+       if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) memcpy(layer_str + 12, "spr_lo", 6);\r
+       if (PicoDrawMask & PDRAW_SPRITES_HI_ON)  memcpy(layer_str + 19, "spr_hi", 6);\r
+\r
+       memset(gp2x_screen, 0, 320*240*2);\r
+       emu_forcedFrame();\r
+       smalltext_out16(4, 232, layer_str, 0xffff);\r
 }\r
 \r
 static void debug_menu_loop(void)\r
 {\r
-       draw_debug();\r
-       wait_for_input(GP2X_B|GP2X_X);\r
+       int inp, mode = 0;\r
+\r
+       while (1)\r
+       {\r
+               switch (mode)\r
+               {\r
+                       case 0: draw_main_debug(); break;\r
+                       case 1: draw_frame_debug(); break;\r
+                       case 2: PicoDrawShowSpriteStats(gp2x_screen); break;\r
+                       case 3: PicoDrawShowPalette(gp2x_screen); break;\r
+               }\r
+               menu_flip();\r
+\r
+               inp = wait_for_input(GP2X_B|GP2X_X|GP2X_L|GP2X_R|GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT);\r
+               if (inp & (GP2X_B|GP2X_X)) return;\r
+               if (inp & GP2X_L) { mode--; if (mode < 0) mode = 3; }\r
+               if (inp & GP2X_R) { mode++; if (mode > 3) mode = 0; }\r
+               if (mode == 1) {\r
+                       if (inp & GP2X_LEFT)  PicoDrawMask ^= PDRAW_LAYERB_ON;\r
+                       if (inp & GP2X_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON;\r
+                       if (inp & GP2X_DOWN)  PicoDrawMask ^= PDRAW_SPRITES_LOW_ON;\r
+                       if (inp & GP2X_UP)    PicoDrawMask ^= PDRAW_SPRITES_HI_ON;\r
+               }\r
+       }\r
 }\r
 \r
 // ------------ patch/gg menu ------------\r