+static void set_default_paths(void)
+{
+ MAKE_PATH(Config.Mcd1, MEMCARD_DIR, "card1.mcd");
+ MAKE_PATH(Config.Mcd2, MEMCARD_DIR, "card2.mcd");
+ strcpy(Config.BiosDir, "bios");
+
+ strcpy(Config.PluginsDir, "plugins");
+ strcpy(Config.Gpu, "builtin_gpu");
+ strcpy(Config.Spu, "builtin_spu");
+ strcpy(Config.Cdr, "builtin_cdr");
+ strcpy(Config.Pad1, "builtin_pad");
+ strcpy(Config.Pad2, "builtin_pad");
+ strcpy(Config.Net, "Disabled");
+ Config.PsxAuto = 1;
+
+ snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "." PATCHES_DIR);
+}
+
+static void check_memcards(void)
+{
+ char buf[MAXPATHLEN];
+ FILE *f;
+ int i;
+
+ for (i = 1; i <= 9; i++) {
+ snprintf(buf, sizeof(buf), ".%scard%d.mcd", MEMCARD_DIR, i);
+
+ f = fopen(buf, "rb");
+ if (f == NULL) {
+ printf("Creating memcard: %s\n", buf);
+ CreateMcd(buf);
+ }
+ else
+ fclose(f);
+ }
+}
+
+void do_emu_action(void)
+{
+ char buf[MAXPATHLEN];
+ int ret;
+
+ emu_action_old = emu_action;
+
+ switch (emu_action) {
+ case SACTION_ENTER_MENU:
+ menu_loop();
+ return;
+ case SACTION_LOAD_STATE:
+ ret = emu_load_state(state_slot);
+ snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "LOADED" : "FAIL!");
+ break;
+ case SACTION_SAVE_STATE:
+ ret = emu_save_state(state_slot);
+ snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "SAVED" : "FAIL!");
+ break;
+ case SACTION_NEXT_SSLOT:
+ state_slot++;
+ if (state_slot > 9)
+ state_slot = 0;
+ goto do_state_slot;
+ case SACTION_PREV_SSLOT:
+ state_slot--;
+ if (state_slot < 0)
+ state_slot = 9;
+ goto do_state_slot;
+ case SACTION_TOGGLE_FSKIP:
+ pl_rearmed_cbs.fskip_advice = 0;
+ pl_rearmed_cbs.frameskip++;
+ if (pl_rearmed_cbs.frameskip > 1)
+ pl_rearmed_cbs.frameskip = -1;
+ snprintf(hud_msg, sizeof(hud_msg), "FRAMESKIP: %s",
+ pl_rearmed_cbs.frameskip == -1 ? "AUTO" :
+ pl_rearmed_cbs.frameskip == 0 ? "OFF" : "1" );
+ plugin_call_rearmed_cbs();
+ break;
+ case SACTION_SCREENSHOT:
+ {
+ void *scrbuf;
+ int w, h, bpp;
+ time_t t = time(NULL);
+ struct tm *tb = localtime(&t);
+ int ti = tb->tm_yday * 1000000 + tb->tm_hour * 10000 +
+ tb->tm_min * 100 + tb->tm_sec;
+
+ scrbuf = pl_prepare_screenshot(&w, &h, &bpp);
+ get_gameid_filename(buf, sizeof(buf),
+ "screenshots/%.32s-%.9s.%d.png", ti);
+ ret = -1;
+ if (scrbuf != 0 && bpp == 16)
+ ret = writepng(buf, scrbuf, w, h);
+ if (ret == 0)
+ snprintf(hud_msg, sizeof(hud_msg), "SCREENSHOT TAKEN");
+ break;
+ }
+ default:
+ return;
+ }
+ hud_new_msg = 3;
+ return;
+
+do_state_slot:
+ snprintf(hud_msg, sizeof(hud_msg), "STATE SLOT %d [%s]", state_slot,
+ emu_check_state(state_slot) == 0 ? "USED" : "FREE");
+ hud_new_msg = 3;
+ printf("* %s\n", hud_msg);
+}
+