@@ -1260,38 +1260,30 @@ static volatile int gte_write = 0;
12601260/* Quick save and turn off the console */
12611261void 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. */
0 commit comments