@@ -1417,38 +1417,30 @@ void emu_cmn_forced_frame(int no_scale, int do_emu)
14171417/* Quick save and turn off the console */
14181418void 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
0 commit comments