Skip to content

Commit

Permalink
Vita: - some fixes to savestates now they work even with no disk inse…
Browse files Browse the repository at this point in the history
…rted in df0. Savestate file name is now the first available among df0, boot-hd, hdf2, hdf3, hdf4, df1, df2, df3.
  • Loading branch information
rsn8887 committed Jan 3, 2017
1 parent d0d0063 commit ceba505
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 117 deletions.
2 changes: 1 addition & 1 deletion src/gp2x/menu/menu_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void SetDefaultMenuSettings(int general)
}

if(general > 0) {
// hdf0
//reset floppies
uae4all_image_file0[0] = '\0';
uae4all_image_file1[0] = '\0';
uae4all_image_file2[0] = '\0';
Expand Down
2 changes: 0 additions & 2 deletions src/gp2x/menu/menu_memory_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ static int key_memDiskMenu(int *c)
if (run_menuLoad(currentDir, MENU_LOAD_HD_DIR)) {
make_hard_dir_cfg_line(uae4all_hard_dir);
reset_hdConf();
mainMenu_bootHD = 1;
loadconfig(2);
}
} else if (del) {
Expand All @@ -509,7 +508,6 @@ static int key_memDiskMenu(int *c)
else if (current_hdf==3)
make_hard_file_cfg_line(uae4all_hard_file3);
reset_hdConf();
mainMenu_bootHD = 2;
loadconfig(2);
}
} else if (del) {
Expand Down
96 changes: 84 additions & 12 deletions src/gp2x/menu/menu_savestates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static const char *text_str_exit="Back to Main Menu";
extern int emulating;
extern int saveMenu_n_savestate;
extern int quit_pressed_in_submenu;
extern int mainMenu_bootHD;

int saveMenu_case=-1;

Expand Down Expand Up @@ -246,6 +247,88 @@ void show_error(const char *str)
}


void make_savestate_filenames(char *save, char *thumb)
{
save[0]='\0';
if (thumb!=NULL)
thumb[0]='\0';
int i=0;
char *hd_name=NULL;
// savestate is named by boot unit
// use first floppy as filename, if empty, use boot hdf/hd dir
if (uae4all_image_file0[0]!='\0')
{
strcpy(save,uae4all_image_file0);
}
else
{
if (mainMenu_bootHD == 2)
{
if (uae4all_hard_file0[0]!='\0')
hd_name=uae4all_hard_file0;
else if (uae4all_hard_file1[0]!='\0')
hd_name=uae4all_hard_file1;
else if (uae4all_hard_file2[0]!='\0')
hd_name=uae4all_hard_file2;
else if (uae4all_hard_file3[0]!='\0')
hd_name=uae4all_hard_file3;
} else if (mainMenu_bootHD == 1 && uae4all_hard_dir[0]!='\0')
hd_name=uae4all_hard_dir;
if (hd_name!=NULL && hd_name[0]!='\0')
{
int oneColonFound=0;
for (i = strlen(hd_name); i > 0; i--)
if (hd_name[i] == ':' && !oneColonFound)
oneColonFound=1;
else if (hd_name[i] == ':' && oneColonFound)
break;
if (i > 0)
{
strcpy(save, &hd_name[i+1]);
if (strlen(save) > 255 - 2)
save[255 - 2] = '\0';
}
else
{
save[0]='\0';
}
}
} //Still nothing? Use floppy numbers 2,3,4
if (save[0]=='\0')
{
if (uae4all_image_file1[0]!='\0')
strcpy(save,uae4all_image_file1);
else if (uae4all_image_file2[0]!='\0')
strcpy(save,uae4all_image_file2);
else if (uae4all_image_file3[0]!='\0')
strcpy(save,uae4all_image_file3);
}
if (thumb!=NULL)
strcpy(thumb, save);
switch(saveMenu_n_savestate)
{
case 1:
strcat(save,"-1.asf");
if (thumb!=NULL)
strcat(thumb,"-1.png");
break;
case 2:
strcat(save,"-2.asf");
if (thumb!=NULL)
strcat(thumb,"-2.png");
break;
case 3:
strcat(save,"-3.asf");
if (thumb!=NULL)
strcat(thumb,"-3.png");
break;
default:
strcat(save,".asf");
if (thumb!=NULL)
strcat(thumb,".png");
}
}

int run_menuSavestates()
{
static int c=0;
Expand All @@ -272,18 +355,7 @@ int run_menuSavestates()
{
case SAVE_MENU_CASE_LOAD_MEM:
{
strcpy(savestate_filename,uae4all_image_file0);
switch(saveMenu_n_savestate)
{
case 1:
strcat(savestate_filename,"-1.asf"); break;
case 2:
strcat(savestate_filename,"-2.asf"); break;
case 3:
strcat(savestate_filename,"-3.asf"); break;
default:
strcat(savestate_filename,".asf");
}
make_savestate_filenames(savestate_filename,NULL);
FILE *f=fopen(savestate_filename,"rb");
if (f)
{
Expand Down
97 changes: 9 additions & 88 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,41 +267,14 @@ int gui_update (void)
extern char *savestate_filename;
#ifdef USE_GUICHAN
extern char *screenshot_filename;
#else
char *screenshot_filename=NULL;
#endif
strcpy(changed_df[0],uae4all_image_file0);
strcpy(changed_df[1],uae4all_image_file1);
strcpy(changed_df[2],uae4all_image_file2);
strcpy(changed_df[3],uae4all_image_file3);
strcpy(savestate_filename,uae4all_image_file0);
#ifdef USE_GUICHAN
strcpy(screenshot_filename,uae4all_image_file0);
#endif
switch(saveMenu_n_savestate)
{
case 1:
strcat(savestate_filename,"-1.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-1.png");
#endif
break;
case 2:
strcat(savestate_filename,"-2.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-2.png");
#endif
break;
case 3:
strcat(savestate_filename,"-3.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-3.png");
#endif
break;
default:
strcat(savestate_filename,".asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,".png");
#endif
}
make_savestate_filenames(savestate_filename, screenshot_filename);
real_changed_df[0]=1;
real_changed_df[1]=1;
real_changed_df[2]=1;
Expand Down Expand Up @@ -355,6 +328,8 @@ static void goMenu(void)
extern char *savestate_filename;
#ifdef USE_GUICHAN
extern char *screenshot_filename;
#else
char *screenshot_filename = NULL;
#endif
extern int saveMenu_n_savestate;
for(int i=0;i<mainMenu_drives;i++)
Expand All @@ -376,44 +351,16 @@ static void goMenu(void)
real_changed_df[3]=1;
}
}
strcpy(savestate_filename,uae4all_image_file0);
#ifdef USE_GUICHAN
strcpy(screenshot_filename,uae4all_image_file0);
#endif
switch(saveMenu_n_savestate)
{
case 1:
strcat(savestate_filename,"-1.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-1.png");
#endif
break;
case 2:
strcat(savestate_filename,"-2.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-2.png");
#endif
break;
case 3:
strcat(savestate_filename,"-3.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-3.png");
#endif
break;
default:
strcat(savestate_filename,".asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,".png");
#endif
}
make_savestate_filenames(savestate_filename, screenshot_filename);
}
if (exitmode==3)
{
extern char *savestate_filename;
#ifdef USE_GUICHAN
extern char *screenshot_filename;
#else
char *screenshot_filename = NULL;
#endif
extern int saveMenu_n_savestate;
for(int i=0;i<mainMenu_drives;i++)
{
changed_df[i][0]=0;
Expand Down Expand Up @@ -451,36 +398,10 @@ static void goMenu(void)
}
disk_eject(i);
}
strcpy(savestate_filename,uae4all_image_file0);
make_savestate_filenames(savestate_filename, screenshot_filename);
#ifdef USE_GUICHAN
strcpy(screenshot_filename,uae4all_image_file0);
#endif
switch(saveMenu_n_savestate)
{
case 1:
strcat(savestate_filename,"-1.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-1.png");
#endif
break;
case 2:
strcat(savestate_filename,"-2.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-2.png");
#endif
break;
case 3:
strcat(savestate_filename,"-3.asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,"-3.png");
#endif
break;
default:
strcat(savestate_filename,".asf");
#ifdef USE_GUICHAN
strcat(screenshot_filename,".png");
#endif
}
}
if (exitmode==2)
{
Expand Down
3 changes: 3 additions & 0 deletions src/include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ extern void uae4all_show_time(void);
/* Function to update the custom key config to one of three presets on Vita */
extern void remap_custom_controls();

/* Function to create savestate filename
and screenshot filename if USE_GUICHAN is defined */
extern void make_savestate_filenames(char *save, char *thumb);
16 changes: 2 additions & 14 deletions src/menu_guichan/menuTabSavestates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,8 @@ class LoadStateActionListener : public gcn::ActionListener
void action(const gcn::ActionEvent& actionEvent) {
if(emulating) {
mainMenu_case = MAIN_MENU_CASE_SAVESTATES;
strcpy(savestate_filename,uae4all_image_file0);
switch(saveMenu_n_savestate) {
case 1:
strcat(savestate_filename,"-1.asf");
break;
case 2:
strcat(savestate_filename,"-2.asf");
break;
case 3:
strcat(savestate_filename,"-3.asf");
break;
default:
strcat(savestate_filename,".asf");
}
make_savestate_filenames(savestate_filename, NULL);

FILE *f = fopen(savestate_filename,"rb");
if (f) {
fclose(f);
Expand Down

0 comments on commit ceba505

Please sign in to comment.