Skip to content

Commit 63fcd82

Browse files
committed
use new Instant Play system
Signed-off-by: Vincent-FK <[email protected]>
1 parent 3edf32b commit 63fcd82

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

emu.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,30 @@ rcvar_t emu_exports[] =
4444
/* Quick save and turn off the console */
4545
void quick_save_and_poweroff()
4646
{
47-
/* Vars */
48-
char shell_cmd[1024];
49-
FILE *fp;
50-
51-
/* Send command to kill any previously scheduled shutdown */
52-
sprintf(shell_cmd, "pkill %s", SHELL_CMD_SCHEDULE_POWERDOWN);
53-
fp = popen(shell_cmd, "r");
54-
if (fp == NULL)
47+
printf("Save Instant Play file\n");
48+
49+
Uint32 start = SDL_GetTicks();
50+
51+
/* Send command to cancel any previously scheduled powerdown */
52+
if (popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r") == NULL)
5553
{
56-
printf("Failed to run command %s\n", shell_cmd);
54+
/* Countdown is still ticking, so better do nothing
55+
than start writing and get interrupted!
56+
*/
57+
printf("Failed to cancel scheduled shutdown\n");
58+
exit(0);
5759
}
5860

61+
printf("============== Cancel time %d\n", SDL_GetTicks() - start);
5962
/* Save */
6063
state_file_save(quick_save_file);
6164

62-
/* Write quick load file */
63-
sprintf(shell_cmd, "%s SDL_NOMOUSE=1 \"%s\" --loadStateFile \"%s\" \"%s\"",
64-
SHELL_CMD_WRITE_QUICK_LOAD_CMD, prog_name, quick_save_file, mRomName);
65-
printf("Cmd write quick load file:\n %s\n", shell_cmd);
66-
fp = popen(shell_cmd, "r");
67-
if (fp == NULL)
68-
{
69-
printf("Failed to run command %s\n", shell_cmd);
70-
}
65+
/* Perform Instant Play save and shutdown */
66+
execlp(SHELL_CMD_INSTANT_PLAY, SHELL_CMD_INSTANT_PLAY,
67+
prog_name, "--loadStateFile", quick_save_file, mRomName, NULL);
7168

72-
/* Clean Poweroff */
73-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
74-
fp = popen(shell_cmd, "r");
75-
if (fp == NULL)
76-
{
77-
printf("Failed to run command %s\n", shell_cmd);
78-
}
69+
/* Should not be reached */
70+
printf("Failed to perform Instant Play save and shutdown\n");
7971

8072
/* Exit Emulator */
8173
exit(0);

sys.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ typedef enum {RESUME_OPTIONS} ENUM_RESUME_OPTIONS;
6363
#define SHELL_CMD_VOLUME_SET "volume_set"
6464
#define SHELL_CMD_BRIGHTNESS_GET "brightness_get"
6565
#define SHELL_CMD_BRIGHTNESS_SET "brightness_set"
66-
#define SHELL_CMD_POWERDOWN "shutdown_funkey"
67-
#define SHELL_CMD_SCHEDULE_POWERDOWN "sched_shutdown"
6866
#define SHELL_CMD_NOTIF "notif_set"
69-
#define SHELL_CMD_WRITE_QUICK_LOAD_CMD "write_args_quick_load_file"
67+
#define SHELL_CMD_CANCEL_SCHED_POWERDOWN "cancel_sched_powerdown"
68+
#define SHELL_CMD_INSTANT_PLAY "instant_play"
69+
#define SHELL_CMD_SHUTDOWN_FUNKEY "shutdown_funkey"
7070

7171
////------ Global variables -------
7272
extern int volume_percentage;

sys/sdl/sdl-menu.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -930,11 +930,9 @@ void run_menu_loop()
930930
if(menu_confirmation){
931931
MENU_DEBUG_PRINTF("Powerdown - confirmed\n");
932932
/// ----- Shell cmd ----
933-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
934-
fp = popen(shell_cmd, "r");
935-
if (fp == NULL) {
936-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
937-
}
933+
execlp(SHELL_CMD_SHUTDOWN_FUNKEY, SHELL_CMD_SHUTDOWN_FUNKEY, NULL);
934+
MENU_ERROR_PRINTF("Failed to run command %s\n", SHELL_CMD_SHUTDOWN_FUNKEY);
935+
exit(0);
938936
}
939937
else{
940938
MENU_DEBUG_PRINTF("Powerdown - asking confirmation\n");

0 commit comments

Comments
 (0)