+ menu_darken_bg(g_menubg_ptr, g_menuscreen_ptr, g_menuscreen_w * g_menuscreen_h, 0);
+
+ menu_draw_end();
+out:
+ free(blocks1);
+ free(blocks2);
+}
+
+static void handle_memcard_sel(void)
+{
+ Config.Mcd1[0] = 0;
+ if (memcard1_sel != 0)
+ snprintf(Config.Mcd1, sizeof(Config.Mcd1), ".%s%s", MEMCARD_DIR, memcards[memcard1_sel]);
+ Config.Mcd2[0] = 0;
+ if (memcard2_sel != 0)
+ snprintf(Config.Mcd2, sizeof(Config.Mcd2), ".%s%s", MEMCARD_DIR, memcards[memcard2_sel]);
+ LoadMcds(Config.Mcd1, Config.Mcd2);
+ draw_mc_bg();
+}
+
+static menu_entry e_memcard_options[] =
+{
+ mee_enum("Memory card 1", 0, memcard1_sel, memcards),
+ mee_enum("Memory card 2", 0, memcard2_sel, memcards),
+ mee_end,
+};
+
+static int menu_loop_memcards(int id, int keys)
+{
+ static int sel = 0;
+ char *p;
+ int i;
+
+ memcard1_sel = memcard2_sel = 0;
+ p = strrchr(Config.Mcd1, '/');
+ if (p != NULL)
+ for (i = 0; memcards[i] != NULL; i++)
+ if (strcmp(p + 1, memcards[i]) == 0)
+ { memcard1_sel = i; break; }
+ p = strrchr(Config.Mcd2, '/');
+ if (p != NULL)
+ for (i = 0; memcards[i] != NULL; i++)
+ if (strcmp(p + 1, memcards[i]) == 0)
+ { memcard2_sel = i; break; }
+
+ me_loop_d(e_memcard_options, &sel, handle_memcard_sel, NULL);
+
+ memcpy(g_menubg_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h * 2);
+
+ return 0;
+}
+
+// --------- main menu help ----------
+
+static void menu_bios_warn(void)
+{
+ int inp;
+ static const char msg[] =
+ "You don't seem to have copied any BIOS\n"
+ "files to\n"
+#ifdef __ARM_ARCH_7A__ // XXX
+ "<SD card>/pandora/appdata/pcsx_rearmed/bios/\n\n"
+#else
+ "pcsx_rearmed/bios/\n\n"
+#endif
+ "While many games work fine with fake\n"
+ "(HLE) BIOS, others (like MGS and FF8)\n"
+ "require BIOS to work.\n"
+ "After copying the file, you'll also need\n"
+ "to select it in the emu's menu:\n"
+ "options->[BIOS/Plugins]\n\n"
+ "The file is usually named SCPH1001.BIN,\n"
+ "but other not compressed files can be\n"
+ "used too.\n\n"
+ "Press (B) or (X) to continue";
+
+ while (1)
+ {
+ draw_menu_message(msg, NULL);
+
+ inp = in_menu_wait(PBTN_MOK|PBTN_MBACK, 70);
+ if (inp & (PBTN_MBACK|PBTN_MOK))
+ return;
+ }
+}
+
+// ------------ main menu ------------
+
+void OnFile_Exit();
+
+static void draw_frame_main(void)
+{
+ struct tm *tmp;
+ time_t ltime;
+ char ltime_s[16];
+ char buff[64];
+
+ if (CdromId[0] != 0) {
+ snprintf(buff, sizeof(buff), "%.32s/%.9s (running as %s, with %s)",
+ get_cd_label(), CdromId, Config.PsxType ? "PAL" : "NTSC",
+ Config.HLE ? "HLE" : "BIOS");
+ smalltext_out16(4, 1, buff, 0x105f);
+ }
+
+ if (ready_to_go) {
+ ltime = time(NULL);
+ tmp = localtime(<ime);
+ strftime(ltime_s, sizeof(ltime_s), "%H:%M", tmp);
+ snprintf(buff, sizeof(buff), "%s %3d%%", ltime_s, plat_get_bat_capacity());
+ smalltext_out16(4, 1 + me_sfont_h, buff, 0x105f);
+ }
+}
+
+static void draw_frame_credits(void)
+{
+ smalltext_out16(4, 1, "build: "__DATE__ " " __TIME__ " " REV, 0xe7fc);
+}
+
+static const char credits_text[] =
+ "PCSX-ReARMed\n\n"
+ "(C) 1999-2003 PCSX Team\n"
+ "(C) 2005-2009 PCSX-df Team\n"
+ "(C) 2009-2011 PCSX-Reloaded Team\n\n"
+ "GPU and SPU code by Pete Bernert\n"
+ " and the P.E.Op.S. team\n"
+ "ARM recompiler (C) 2009-2011 Ari64\n"
+ "PCSX4ALL plugins by PCSX4ALL team\n"
+ " Chui, Franxis, Unai\n\n"
+ "integration, optimization and\n"
+ " frontend (C) 2010-2011 notaz\n";
+
+static int reset_game(void)
+{
+ // sanity check
+ if (bios_sel == 0 && !Config.HLE)
+ return -1;
+
+ ClosePlugins();
+ OpenPlugins();
+ SysReset();
+ if (CheckCdrom() != -1) {
+ LoadCdrom();
+ }
+ return 0;
+}
+
+static int reload_plugins(const char *cdimg)
+{
+ pl_vout_buf = NULL;
+
+ ClosePlugins();
+
+ set_cd_image(cdimg);
+ LoadPlugins();
+ pcnt_hook_plugins();
+ NetOpened = 0;
+ if (OpenPlugins() == -1) {
+ me_update_msg("failed to open plugins");
+ return -1;
+ }
+ plugin_call_rearmed_cbs();
+
+ CdromId[0] = '\0';
+ CdromLabel[0] = '\0';
+
+ return 0;
+}
+
+static int run_bios(void)
+{
+ if (bios_sel == 0)
+ return -1;
+
+ ready_to_go = 0;
+ if (reload_plugins(NULL) != 0)
+ return -1;
+ SysReset();