Skip to content

Commit f873a3b

Browse files
committed
pulled and resolved conlicts
2 parents d6b2e20 + f4755e3 commit f873a3b

File tree

3 files changed

+22
-31
lines changed

3 files changed

+22
-31
lines changed

src/drivers/main.cpp

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,38 +1260,30 @@ static volatile int gte_write = 0;
12601260
/* Quick save and turn off the console */
12611261
void quick_save_and_poweroff()
12621262
{
1263-
/* Vars */
1264-
char shell_cmd[1024];
1265-
FILE *fp;
1266-
1267-
/* Send command to kill any previously scheduled shutdown */
1268-
sprintf(shell_cmd, "pkill %s", SHELL_CMD_SCHEDULE_POWERDOWN);
1269-
fp = popen(shell_cmd, "r");
1270-
if (fp == NULL) {
1271-
printf("Failed to run command %s\n", shell_cmd);
1263+
printf("Save Instant Play file\n");
1264+
1265+
/* Send command to cancel any previously scheduled powerdown */
1266+
if (popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r") == NULL)
1267+
{
1268+
/* Countdown is still ticking, so better do nothing
1269+
than start writing and get interrupted!
1270+
*/
1271+
printf("Failed to cancel scheduled shutdown\n");
1272+
exit(0);
12721273
}
12731274

12741275
/* Quick Save */
12751276
MDFNI_SaveState(quick_save_file, NULL, NULL, NULL, NULL);
12761277

1277-
/* Write quick load file */
1278-
sprintf(shell_cmd, "%s SDL_NOMOUSE=1 \"%s\" -fs 1 -loadStateFile \"%s\" \"%s\"",
1279-
SHELL_CMD_WRITE_QUICK_LOAD_CMD, prog_name, quick_save_file, mRomName);
1280-
printf("Cmd write quick load file:\n %s\n", shell_cmd);
1281-
fp = popen(shell_cmd, "r");
1282-
if (fp == NULL) {
1283-
printf("Failed to run command %s\n", shell_cmd);
1284-
}
1278+
/* Perform Instant Play save and shutdown */
1279+
execlp(SHELL_CMD_INSTANT_PLAY, SHELL_CMD_INSTANT_PLAY,
1280+
prog_name, "-fs", "1", "--loadStateFile", quick_save_file, mRomName, NULL);
12851281

1286-
/* Clean Poweroff */
1287-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
1288-
fp = popen(shell_cmd, "r");
1289-
if (fp == NULL) {
1290-
printf("Failed to run command %s\n", shell_cmd);
1291-
}
1282+
/* Should not be reached */
1283+
printf("Failed to perform Instant Play save and shutdown\n");
12921284

12931285
/* Exit Emulator */
1294-
NeedExitNow = 1;
1286+
exit(0);
12951287
}
12961288

12971289
/* This function may also be called by the main thread if a game is not loaded. */

src/drivers/menu.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,11 +1000,9 @@ void run_menu_loop()
10001000
if(menu_confirmation){
10011001
MENU_DEBUG_PRINTF("Powerdown - confirmed\n");
10021002
/// ----- Shell cmd ----
1003-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
1004-
fp = popen(shell_cmd, "r");
1005-
if (fp == NULL) {
1006-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1007-
}
1003+
execlp(SHELL_CMD_SHUTDOWN_FUNKEY, SHELL_CMD_SHUTDOWN_FUNKEY, NULL);
1004+
MENU_ERROR_PRINTF("Failed to run command %s\n", SHELL_CMD_SHUTDOWN_FUNKEY);
1005+
exit(0);
10081006
}
10091007
else{
10101008
MENU_DEBUG_PRINTF("Powerdown - asking confirmation\n");

src/drivers/menu.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ typedef enum {RESUME_OPTIONS} ENUM_RESUME_OPTIONS;
6060
#define SHELL_CMD_VOLUME_SET "volume_set"
6161
#define SHELL_CMD_BRIGHTNESS_GET "brightness_get"
6262
#define SHELL_CMD_BRIGHTNESS_SET "brightness_set"
63-
#define SHELL_CMD_POWERDOWN "shutdown_funkey"
64-
#define SHELL_CMD_SCHEDULE_POWERDOWN "sched_shutdown"
6563
#define SHELL_CMD_NOTIF "notif_set"
6664
#define SHELL_CMD_WRITE_QUICK_LOAD_CMD "write_args_quick_load_file"
6765
#define SHELL_CMD_TURN_AMPLI_ON "start_audio_amp 1"
6866
#define SHELL_CMD_TURN_AMPLI_OFF "start_audio_amp 0"
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"
6970

7071
////------ Global variables -------
7172
extern int volume_percentage;

0 commit comments

Comments
 (0)