some fixes and adjustments
[libpicofe.git] / common / menu.c
index d2957c2..16d4342 100644 (file)
  #define SCREEN_WIDTH 321\r
  #define SCREEN_BUFFER menu_screen\r
  extern unsigned char *menu_screen;\r
+#elif defined(PSP)\r
+ #include "../psp/psp.h"\r
+ #define SCREEN_WIDTH 512\r
+ #define SCREEN_BUFFER psp_screen\r
 #endif\r
 \r
 char menuErrorMsg[64] = { 0, };\r
@@ -160,7 +164,12 @@ static int parse_hex_color(char *buff)
 {\r
        char *endp = buff;\r
        int t = (int) strtoul(buff, &endp, 16);\r
-       if (endp != buff) return ((t>>8)&0xf800) | ((t>>5)&0x07e0) | ((t>>3)&0x1f);\r
+       if (endp != buff)\r
+#ifdef PSP\r
+               return ((t<<8)&0xf800) | ((t>>5)&0x07e0) | ((t>>19)&0x1f);\r
+#else\r
+               return ((t>>8)&0xf800) | ((t>>5)&0x07e0) | ((t>>3)&0x1f);\r
+#endif\r
        return -1;\r
 }\r
 \r
@@ -313,5 +322,25 @@ int me_process(menu_entry *entries, int count, menu_id id, int is_next)
        }\r
 }\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