Skip to content

Commit 2d5e38d

Browse files
committed
use new Instant Play system
Signed-off-by: Vincent-FK <[email protected]>
1 parent 4c48411 commit 2d5e38d

File tree

3 files changed

+26
-39
lines changed

3 files changed

+26
-39
lines changed

menu/main.cpp

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -591,16 +591,16 @@ void S9xLoadSRAM (void)
591591
/* Quick save and turn off the console */
592592
void quick_save_and_poweroff()
593593
{
594-
/* Vars */
595-
char shell_cmd[200+SAL_MAX_PATH];
596-
FILE *fp;
597-
598-
/* Send command to kill any previously scheduled shutdown */
599-
sprintf(shell_cmd, "pkill %s", SHELL_CMD_SCHEDULE_POWERDOWN);
600-
fp = popen(shell_cmd, "r");
601-
if (fp == NULL)
594+
printf("Save Instant Play file\n");
595+
596+
/* Send command to cancel any previously scheduled powerdown */
597+
if (popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r") == NULL)
602598
{
603-
printf("Failed to run command %s\n", shell_cmd);
599+
/* Countdown is still ticking, so better do nothing
600+
than start writing and get interrupted!
601+
*/
602+
printf("Failed to cancel scheduled shutdown\n");
603+
exit(0);
604604
}
605605

606606
/* Save */
@@ -610,26 +610,15 @@ void quick_save_and_poweroff()
610610
return;
611611
}
612612

613-
/* Write quick load file */
614-
sprintf(shell_cmd, "%s SDL_NOMOUSE=1 \"%s\" -loadStateFile \"%s\" \"%s\"",
615-
SHELL_CMD_WRITE_QUICK_LOAD_CMD, prog_name, quick_save_file, mRomName);
616-
printf("Cmd write quick load file:\n %s\n", shell_cmd);
617-
fp = popen(shell_cmd, "r");
618-
if (fp == NULL)
619-
{
620-
printf("Failed to run command %s\n", shell_cmd);
621-
}
613+
/* Perform Instant Play save and shutdown */
614+
execlp(SHELL_CMD_INSTANT_PLAY, SHELL_CMD_INSTANT_PLAY,
615+
prog_name, "-loadStateFile", quick_save_file, mRomName, NULL);
622616

623-
/* Clean Poweroff */
624-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
625-
fp = popen(shell_cmd, "r");
626-
if (fp == NULL)
627-
{
628-
printf("Failed to run command %s\n", shell_cmd);
629-
}
617+
/* Should not be reached */
618+
printf("Failed to perform Instant Play save and shutdown\n");
630619

631620
/* Exit Emulator */
632-
mExit = 1;
621+
exit(0);
633622
}
634623

635624
static u32 LastAudioRate = 0;

menu/menu.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,9 @@ void run_menu_loop()
953953
if(menu_confirmation){
954954
MENU_DEBUG_PRINTF("Powerdown - confirmed\n");
955955
/// ----- Shell cmd ----
956-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
957-
fp = popen(shell_cmd, "r");
958-
if (fp == NULL) {
959-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
960-
}
956+
execlp(SHELL_CMD_SHUTDOWN_FUNKEY, SHELL_CMD_SHUTDOWN_FUNKEY, NULL);
957+
MENU_ERROR_PRINTF("Failed to run command %s\n", SHELL_CMD_SHUTDOWN_FUNKEY);
958+
exit(0);
961959
}
962960
else{
963961
MENU_DEBUG_PRINTF("Powerdown - asking confirmation\n");

menu/menu.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ typedef enum {RESUME_OPTIONS} ENUM_RESUME_OPTIONS;
184184
#define NOTIF_SECONDS_DISP 2
185185

186186
////------ Menu commands -------
187-
#define SHELL_CMD_VOLUME_GET "volume_get"
188-
#define SHELL_CMD_VOLUME_SET "volume_set"
189-
#define SHELL_CMD_BRIGHTNESS_GET "brightness_get"
190-
#define SHELL_CMD_BRIGHTNESS_SET "brightness_set"
191-
#define SHELL_CMD_POWERDOWN "shutdown_funkey"
192-
#define SHELL_CMD_SCHEDULE_POWERDOWN "sched_shutdown"
193-
#define SHELL_CMD_NOTIF "notif_set"
194-
#define SHELL_CMD_WRITE_QUICK_LOAD_CMD "write_args_quick_load_file"
187+
#define SHELL_CMD_VOLUME_GET "volume_get"
188+
#define SHELL_CMD_VOLUME_SET "volume_set"
189+
#define SHELL_CMD_BRIGHTNESS_GET "brightness_get"
190+
#define SHELL_CMD_BRIGHTNESS_SET "brightness_set"
191+
#define SHELL_CMD_NOTIF "notif_set"
192+
#define SHELL_CMD_CANCEL_SCHED_POWERDOWN "cancel_sched_powerdown"
193+
#define SHELL_CMD_INSTANT_PLAY "instant_play"
194+
#define SHELL_CMD_SHUTDOWN_FUNKEY "shutdown_funkey"
195195

196196
////------ Global variables -------
197197
extern int volume_percentage;

0 commit comments

Comments
 (0)