+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;
+ }
+ case SACTION_VOLUME_UP:
+ case SACTION_VOLUME_DOWN:
+ plat_step_volume(emu_action == SACTION_VOLUME_UP);
+ return;
+ 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);
+}
+
+int main(int argc, char *argv[])
+{