sprite limit
[libpicofe.git] / psp / menu.c
index c2df05f..ca40cfe 100644 (file)
@@ -699,8 +699,6 @@ static int count_bound_keys(int action, int pl_idx)
        return keys;
 }
 
-typedef struct { char *name; int mask; } bind_action_t;
-
 static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_idx, int sel)
 {
        int x, y, tl_y = 16+40, i;
@@ -789,33 +787,17 @@ static void draw_kc_sel(int menu_sel)
 }
 
 
-// PicoPad[] format: MXYZ SACB RLDU
-static bind_action_t ctrl_actions[] =
-{
-       { "UP     ", 0x001 },
-       { "DOWN   ", 0x002 },
-       { "LEFT   ", 0x004 },
-       { "RIGHT  ", 0x008 },
-       { "A      ", 0x040 },
-       { "B      ", 0x010 },
-       { "C      ", 0x020 },
-       { "START  ", 0x080 },
-       { "MODE   ", 0x800 },
-       { "X      ", 0x400 },
-       { "Y      ", 0x200 },
-       { "Z      ", 0x100 },
-};
-
 // player2_flag, ?, ?, ?, ?, ?, ?, menu
 // "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE",
 // "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE"
-static bind_action_t emuctrl_actions[] =
+me_bind_action emuctrl_actions[] =
 {
        { "Load State     ", 1<<28 },
        { "Save State     ", 1<<27 },
        { "Prev Save Slot ", 1<<25 },
        { "Next Save Slot ", 1<<24 },
        { "Switch Renderer", 1<<26 },
+       { NULL,              0     }
 };
 
 static void kc_sel_loop(void)
@@ -832,10 +814,10 @@ static void kc_sel_loop(void)
                if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
                if (inp & BTN_CIRCLE) {
                        switch (menu_sel) {
-                               case 0: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 0); return;
-                               case 1: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 1); return;
+                               case 0: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 0); return;
+                               case 1: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 1); return;
                                case 2: key_config_loop(emuctrl_actions,
-                                               sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return;
+                                               sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return;
                                case 3: if (!rom_loaded) emu_WriteConfig(0); return;
                                default: return;
                        }
@@ -954,9 +936,9 @@ static void cd_menu_loop_options(void)
                            selected_id == MA_CDOPT_READAHEAD) {
                                if (inp & BTN_LEFT) {
                                        PicoCDBuffers >>= 1;
-                                       if (PicoCDBuffers < 64) PicoCDBuffers = 0;
+                                       if (PicoCDBuffers < 2) PicoCDBuffers = 0;
                                } else {
-                                       if (PicoCDBuffers < 64) PicoCDBuffers = 64;
+                                       if (PicoCDBuffers < 2) PicoCDBuffers = 2;
                                        else PicoCDBuffers <<= 1;
                                        if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M
                                }
@@ -1261,29 +1243,6 @@ menu_entry opt_entries[] =
 #define OPT_ENTRY_COUNT (sizeof(opt_entries) / sizeof(opt_entries[0]))
 
 
-static const char *region_name(unsigned int code)
-{
-       static const char *names[] = { "Auto", "      Japan NTSC", "      Japan PAL", "      USA", "      Europe" };
-       static const char *names_short[] = { "", " JP", " JP", " US", " EU" };
-       int u, i = 0;
-       if (code) {
-               code <<= 1;
-               while((code >>= 1)) i++;
-               if (i > 4) return "unknown";
-               return names[i];
-       } else {
-               static char name[24];
-               strcpy(name, "Auto:");
-               for (u = 0; u < 3; u++) {
-                       i = 0; code = ((PicoAutoRgnOrder >> u*4) & 0xf) << 1;
-                       while((code >>= 1)) i++;
-                       strcat(name, names_short[i]);
-               }
-               return name;
-       }
-}
-
-
 static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *param)
 {
        char *str, str24[24];
@@ -1310,7 +1269,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para
                        text_out16(x, y, "Sound Quality:     %5iHz %s", currentConfig.PsndRate, str);
                        break;
                case MA_OPT_REGION:
-                       text_out16(x, y, "Region:              %s", region_name(currentConfig.PicoRegion));
+                       text_out16(x, y, "Region:              %s", me_region_name(PicoRegionOverride, PicoAutoRgnOrder));
                        break;
                case MA_OPT_CONFIRM_STATES:
                        switch ((currentConfig.EmuOpt >> 9) & 5) {
@@ -1371,21 +1330,21 @@ static void region_prevnext(int right)
        static int rgn_orders[] = { 0x148, 0x184, 0x814, 0x418, 0x841, 0x481 };
        int i;
        if (right) {
-               if (!currentConfig.PicoRegion) {
+               if (!PicoRegionOverride) {
                        for (i = 0; i < 6; i++)
                                if (rgn_orders[i] == PicoAutoRgnOrder) break;
                        if (i < 5) PicoAutoRgnOrder = rgn_orders[i+1];
-                       else currentConfig.PicoRegion=1;
+                       else PicoRegionOverride=1;
                }
-               else currentConfig.PicoRegion<<=1;
-               if (currentConfig.PicoRegion > 8) currentConfig.PicoRegion = 8;
+               else PicoRegionOverride<<=1;
+               if (PicoRegionOverride > 8) PicoRegionOverride = 8;
        } else {
-               if (!currentConfig.PicoRegion) {
+               if (!PicoRegionOverride) {
                        for (i = 0; i < 6; i++)
                                if (rgn_orders[i] == PicoAutoRgnOrder) break;
                        if (i > 0) PicoAutoRgnOrder = rgn_orders[i-1];
                }
-               else currentConfig.PicoRegion>>=1;
+               else PicoRegionOverride>>=1;
        }
 }
 
@@ -1393,7 +1352,6 @@ static void menu_options_save(void)
 {
        PicoOpt = currentConfig.PicoOpt;
        PsndRate = currentConfig.PsndRate;
-       PicoRegionOverride = currentConfig.PicoRegion;
        if (PicoRegionOverride) {
                // force setting possibly changed..
                Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;
@@ -1413,7 +1371,6 @@ static int menu_loop_options(void)
 
        currentConfig.PicoOpt = PicoOpt;
        currentConfig.PsndRate = PsndRate;
-       currentConfig.PicoRegion = PicoRegionOverride;
 
        me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_loaded);
        me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);