corrected quick loads for Sega CD, fix for now

This commit is contained in:
Vincent-FK 2021-04-17 20:22:29 +02:00
parent 484383a502
commit b1a23f037d
3 changed files with 71 additions and 19 deletions

View File

@ -1504,8 +1504,9 @@ void emu_cmn_forced_frame(int no_scale, int do_emu, void *buf)
PicoIn.opt = po_old;
}
int emu_is_segaCD(){
return (PicoIn.AHW & PAHW_MCD);
}
/* Quick save and turn off the console */
void quick_save_and_poweroff()
@ -1669,6 +1670,7 @@ static void emu_loop_prep(void)
void emu_loop(void)
{
int frames_done, frames_shown; /* actual frames for fps counter */
int frame_nb = 0;
int target_frametime_x3;
unsigned int timestamp_x3 = 0;
unsigned int timestamp_aim_x3 = 0;
@ -1679,6 +1681,8 @@ void emu_loop(void)
fpsbuff[0] = 0;
printf("%s ------------------ \n", __func__);
PicoLoopPrepare();
plat_video_loop_prepare();
@ -1797,8 +1801,8 @@ void emu_loop(void)
/* Quick save and poweroff */
if(mQuickSaveAndPoweroff){
quick_save_and_poweroff();
mQuickSaveAndPoweroff = 0;
quick_save_and_poweroff();
mQuickSaveAndPoweroff = 0;
}
emu_update_input();
@ -1842,6 +1846,36 @@ void emu_loop(void)
if (!skip && flip_after_sync)
plat_video_flip();
/* FOR SEGA CD */
/* Leave some time for the bios to load before starting a quick load at boot */
/* (Sega CD doesn't quick load at boot otherwise) */
/* Should have a much cleaner implementation thant this fix */
if((PicoIn.AHW & PAHW_MCD) && frame_nb >= 100){
/* Load slot */
if(load_state_slot != -1){
printf("LOADING FROM SLOT (SEGA CD) %d...\n", load_state_slot+1);
char fname[1024];
emu_save_load_game(1, 0);
printf("LOADED FROM SLOT (SEGA CD) %d\n", load_state_slot+1);
load_state_slot = -1;
}
if(need_quick_load != -1){
load_state_file = quick_save_file;
need_quick_load = -1;
}
/* Load file */
if(load_state_file != NULL){
printf("LOADING FROM FILE (SEGA CD) %s...\n", load_state_file);
emu_save_load_game_from_file(1, load_state_file);
printf("LOADED FROM SLOT (SEGA CD) %s\n", load_state_file);
load_state_file = NULL;
}
}
frame_nb++;
pprof_end(main);
}

View File

@ -90,6 +90,9 @@ extern int flip_after_sync;
extern int show_fps_bypass;
extern int need_screen_cleared;
extern int mQuickSaveAndPoweroff;
extern char *load_state_file;
extern int load_state_slot;
extern int need_quick_load;
extern char *prog_name;
extern char *mRomName;
@ -150,6 +153,7 @@ void emu_update_input(void);
void emu_get_game_name(char *str150);
void emu_set_fastforward(int set_on);
void emu_status_msg(const char *format, ...);
int emu_is_segaCD();
/* default sound code */
void emu_sound_start(void);

View File

@ -30,12 +30,13 @@
char **g_argv;
char *prog_name;
static char *load_state_file = NULL;
static int load_state_slot = -1;
char *load_state_file = NULL;
int load_state_slot = -1;
static char *quick_save_file_extension = "quicksave";
char *mRomName = NULL;
char *mRomPath = NULL;
char *quick_save_file = NULL;
int need_quick_load = -1;
char *cfg_file_default = NULL;
char *cfg_file_rom = NULL;
static char *cfg_file_default_name = "default_config";
@ -204,29 +205,42 @@ int main(int argc, char *argv[])
if (emu_reload_rom(rom_fname_reload)) {
engineState = PGS_Running;
/* Load slot */
/* Load slot (if NOT sega CD) */
if(load_state_slot != -1){
printf("LOADING FROM SLOT %d...\n", load_state_slot+1);
char fname[1024];
emu_save_load_game(1, 0);
printf("LOADED FROM SLOT %d\n", load_state_slot+1);
load_state_slot = -1;
/* DO NOT put this if in the previous one, we need this here not to enter the next else */
if(!emu_is_segaCD()){
printf("LOADING FROM SLOT %d...\n", load_state_slot+1);
char fname[1024];
emu_save_load_game(1, 0);
printf("LOADED FROM SLOT %d\n", load_state_slot+1);
load_state_slot = -1;
}
}
/* Load file */
/* Load file (if NOT sega CD) */
else if(load_state_file != NULL){
printf("LOADING FROM FILE %s...\n", load_state_file);
emu_save_load_game_from_file(1, load_state_file);
printf("LOADED FROM SLOT %s\n", load_state_file);
load_state_file = NULL;
/* DO NOT put this if in the previous one, we need this here not to enter the next else */
if(!emu_is_segaCD()){
printf("LOADING FROM FILE %s...\n", load_state_file);
emu_save_load_game_from_file(1, load_state_file);
printf("LOADED FROM SLOT %s\n", load_state_file);
load_state_file = NULL;
}
}
/* Load quick save file */
/* Load quick save file (if NOT sega CD) */
else if(access( quick_save_file, F_OK ) != -1){
printf("Found quick save file: %s\n", quick_save_file);
int resume = launch_resume_menu_loop();
if(resume == RESUME_YES){
printf("Resume game from quick save file: %s\n", quick_save_file);
emu_save_load_game_from_file(1, quick_save_file);
if(emu_is_segaCD()){
need_quick_load = 1;
}
else{
emu_save_load_game_from_file(1, quick_save_file);
}
}
else{
printf("Reset game\n");