Skip to content

Commit e37c0fa

Browse files
committed
use new Instant Play system
Signed-off-by: Vincent-FK <[email protected]>
1 parent 6d3149e commit e37c0fa

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
lines changed

platform/common/emu.c

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,38 +1417,30 @@ void emu_cmn_forced_frame(int no_scale, int do_emu)
14171417
/* Quick save and turn off the console */
14181418
void quick_save_and_poweroff()
14191419
{
1420-
/* Vars */
1421-
char shell_cmd[1024];
1422-
FILE *fp;
1423-
1424-
/* Send command to kill any previously scheduled shutdown */
1425-
sprintf(shell_cmd, "pkill %s", SHELL_CMD_SCHEDULE_POWERDOWN);
1426-
fp = popen(shell_cmd, "r");
1427-
if (fp == NULL) {
1428-
printf("Failed to run command %s\n", shell_cmd);
1420+
printf("Save Instant Play file\n");
1421+
1422+
/* Send command to cancel any previously scheduled powerdown */
1423+
if (popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r") == NULL)
1424+
{
1425+
/* Countdown is still ticking, so better do nothing
1426+
than start writing and get interrupted!
1427+
*/
1428+
printf("Failed to cancel scheduled shutdown\n");
1429+
exit(0);
14291430
}
14301431

14311432
/* Save */
14321433
emu_save_load_game_from_file(0, quick_save_file);
14331434

1434-
/* Write quick load file */
1435-
sprintf(shell_cmd, "%s SDL_NOMOUSE=1 \"%s\" -loadStateFile \"%s\" \"%s\"",
1436-
SHELL_CMD_WRITE_QUICK_LOAD_CMD, prog_name, quick_save_file, mRomName);
1437-
printf("Cmd write quick load file:\n %s\n", shell_cmd);
1438-
fp = popen(shell_cmd, "r");
1439-
if (fp == NULL) {
1440-
printf("Failed to run command %s\n", shell_cmd);
1441-
}
1435+
/* Perform Instant Play save and shutdown */
1436+
execlp(SHELL_CMD_INSTANT_PLAY, SHELL_CMD_INSTANT_PLAY,
1437+
prog_name, "-loadStateFile", quick_save_file, mRomName, NULL);
14421438

1443-
/* Clean Poweroff */
1444-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
1445-
fp = popen(shell_cmd, "r");
1446-
if (fp == NULL) {
1447-
printf("Failed to run command %s\n", shell_cmd);
1448-
}
1439+
/* Should not be reached */
1440+
printf("Failed to perform Instant Play save and shutdown\n");
14491441

14501442
/* Exit Emulator */
1451-
engineState = PGS_Quit;
1443+
exit(0);
14521444
}
14531445

14541446

platform/common/menu_pico.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,11 +1016,9 @@ void run_menu_loop()
10161016
if(menu_confirmation){
10171017
MENU_DEBUG_PRINTF("Powerdown - confirmed\n");
10181018
/// ----- Shell cmd ----
1019-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
1020-
fp = popen(shell_cmd, "r");
1021-
if (fp == NULL) {
1022-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1023-
}
1019+
execlp(SHELL_CMD_SHUTDOWN_FUNKEY, SHELL_CMD_SHUTDOWN_FUNKEY, NULL);
1020+
MENU_ERROR_PRINTF("Failed to run command %s\n", SHELL_CMD_SHUTDOWN_FUNKEY);
1021+
exit(0);
10241022
}
10251023
else{
10261024
MENU_DEBUG_PRINTF("Powerdown - asking confirmation\n");

platform/common/menu_pico.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ typedef enum {RESUME_OPTIONS} ENUM_RESUME_OPTIONS;
5050
#define SHELL_CMD_VOLUME_SET "volume_set"
5151
#define SHELL_CMD_BRIGHTNESS_GET "brightness_get"
5252
#define SHELL_CMD_BRIGHTNESS_SET "brightness_set"
53-
#define SHELL_CMD_POWERDOWN "shutdown_funkey"
54-
#define SHELL_CMD_SCHEDULE_POWERDOWN "sched_shutdown"
5553
#define SHELL_CMD_NOTIF "notif_set"
56-
#define SHELL_CMD_WRITE_QUICK_LOAD_CMD "write_args_quick_load_file"
54+
#define SHELL_CMD_CANCEL_SCHED_POWERDOWN "cancel_sched_powerdown"
55+
#define SHELL_CMD_INSTANT_PLAY "instant_play"
56+
#define SHELL_CMD_SHUTDOWN_FUNKEY "shutdown_funkey"
5757

5858
#define MAXPATHLEN 512
5959

0 commit comments

Comments
 (0)