debug bgm player, sound code refactoring
[libpicofe.git] / common / menu.c
index 00afc34..241af9f 100644 (file)
@@ -39,6 +39,8 @@ me_bind_action me_ctrl_actions[15] =
 };\r
 \r
 \r
+#ifndef UIQ3\r
+\r
 static unsigned char menu_font_data[10240];\r
 static int menu_text_color = 0xffff; // default to white\r
 static int menu_sel_color = -1; // disabled\r
@@ -331,38 +333,30 @@ int me_process(menu_entry *entries, int count, menu_id id, int is_next)
        }\r
 }\r
 \r
-const char *me_region_name(unsigned int code, int auto_order)\r
-{\r
-       static const char *names[] = { "Auto", "      Japan NTSC", "      Japan PAL", "      USA", "      Europe" };\r
-       static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
-       int u, i = 0;\r
-       if (code) {\r
-               code <<= 1;\r
-               while((code >>= 1)) i++;\r
-               if (i > 4) return "unknown";\r
-               return names[i];\r
-       } else {\r
-               static char name[24];\r
-               strcpy(name, "Auto:");\r
-               for (u = 0; u < 3; u++) {\r
-                       i = 0; code = ((auto_order >> u*4) & 0xf) << 1;\r
-                       while((code >>= 1)) i++;\r
-                       strcat(name, names_short[i]);\r
-               }\r
-               return name;\r
-       }\r
-}\r
-\r
 // ------------ debug menu ------------\r
 \r
 #include <sys/stat.h>\r
 #include <sys/types.h>\r
 \r
-#include <Pico/Pico.h>\r
-#include <Pico/Debug.h>\r
+#include <pico/pico.h>\r
+#include <pico/debug.h>\r
 \r
 void SekStepM68k(void);\r
 \r
+static void mplayer_loop(void)\r
+{\r
+       emu_startSound();\r
+\r
+       while (1)\r
+       {\r
+               PDebugZ80Frame();\r
+               if (read_buttons_async(BTN_NORTH)) break;\r
+               emu_waitSound();\r
+       }\r
+\r
+       emu_endSound();\r
+}\r
+\r
 static void draw_text_debug(const char *str, int skip, int from)\r
 {\r
        const char *p;\r
@@ -405,13 +399,16 @@ void debug_menu_loop(void)
 {\r
        int inp, mode = 0;\r
        int spr_offs = 0, dumped = 0;\r
+       char *tmp;\r
 \r
        while (1)\r
        {\r
                switch (mode)\r
                {\r
                        case 0: menu_draw_begin();\r
-                               draw_text_debug(PDebugMain(), 0, 0);\r
+                               tmp = PDebugMain();\r
+                               emu_platformDebugCat(tmp);\r
+                               draw_text_debug(tmp, 0, 0);\r
                                if (dumped) {\r
                                        smalltext_out16(SCREEN_WIDTH-6*10, SCREEN_HEIGHT-8, "dumped", 0xffff);\r
                                        dumped = 0;\r
@@ -432,7 +429,7 @@ void debug_menu_loop(void)
                }\r
                menu_draw_end();\r
 \r
-               inp = read_buttons(BTN_EAST|BTN_SOUTH|BTN_WEST|BTN_L|BTN_R|BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT);\r
+               inp = read_buttons(BTN_EAST|BTN_SOUTH|BTN_WEST|BTN_NORTH|BTN_L|BTN_R|BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT);\r
                if (inp & BTN_SOUTH) return;\r
                if (inp & BTN_L) { mode--; if (mode < 0) mode = 3; }\r
                if (inp & BTN_R) { mode++; if (mode > 3) mode = 0; }\r
@@ -440,6 +437,10 @@ void debug_menu_loop(void)
                {\r
                        case 0:\r
                                if (inp & BTN_EAST) SekStepM68k();\r
+                               if (inp & BTN_NORTH) {\r
+                                       while (inp & BTN_NORTH) inp = read_buttons_async(BTN_NORTH);\r
+                                       mplayer_loop();\r
+                               }\r
                                if ((inp & (BTN_WEST|BTN_LEFT)) == (BTN_WEST|BTN_LEFT)) {\r
                                        mkdir("dumps", 0777);\r
                                        PDebugDumpMem();\r
@@ -469,4 +470,30 @@ void debug_menu_loop(void)
        }\r
 }\r
 \r
+#endif // !UIQ3\r
+\r
+// ------------ util ------------\r
+\r
+const char *me_region_name(unsigned int code, int auto_order)\r
+{\r
+       static const char *names[] = { "Auto", "      Japan NTSC", "      Japan PAL", "      USA", "      Europe" };\r
+       static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
+       int u, i = 0;\r
+       if (code) {\r
+               code <<= 1;\r
+               while((code >>= 1)) i++;\r
+               if (i > 4) return "unknown";\r
+               return names[i];\r
+       } else {\r
+               static char name[24];\r
+               strcpy(name, "Auto:");\r
+               for (u = 0; u < 3; u++) {\r
+                       i = 0; code = ((auto_order >> u*4) & 0xf) << 1;\r
+                       while((code >>= 1)) i++;\r
+                       strcat(name, names_short[i]);\r
+               }\r
+               return name;\r
+       }\r
+}\r
+\r
 \r