mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
frontend: save autoload
This commit is contained in:
parent
b59172e3d4
commit
c7074ddb02
6 changed files with 54 additions and 17 deletions
|
@ -490,6 +490,30 @@ int emu_reload_rom(const char *rom_fname_in)
|
|||
if (currentConfig.EmuOpt & EOPT_EN_SRAM)
|
||||
emu_save_load_game(1, 1);
|
||||
|
||||
// state autoload?
|
||||
if (g_autostateld_opt) {
|
||||
int time, newest = 0, newest_slot = -1;
|
||||
int slot;
|
||||
|
||||
for (slot = 0; slot < 10; slot++) {
|
||||
if (emu_check_save_file(slot, &time)) {
|
||||
if (time > newest) {
|
||||
newest = time;
|
||||
newest_slot = slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newest_slot >= 0) {
|
||||
lprintf("autoload slot %d\n", newest_slot);
|
||||
state_slot = newest_slot;
|
||||
emu_save_load_game(1, 0);
|
||||
}
|
||||
else {
|
||||
lprintf("no save to autoload.\n");
|
||||
}
|
||||
}
|
||||
|
||||
retval = 1;
|
||||
out:
|
||||
if (menu_romload_started)
|
||||
|
@ -736,19 +760,25 @@ void update_movie(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int try_ropen_file(const char *fname)
|
||||
static int try_ropen_file(const char *fname, int *time)
|
||||
{
|
||||
struct stat st;
|
||||
FILE *f;
|
||||
|
||||
f = fopen(fname, "rb");
|
||||
if (f) {
|
||||
if (time != NULL) {
|
||||
*time = 0;
|
||||
if (fstat(fileno(f), &st) == 0)
|
||||
*time = (int)st.st_mtime;
|
||||
}
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *emu_get_save_fname(int load, int is_sram, int slot)
|
||||
char *emu_get_save_fname(int load, int is_sram, int slot, int *time)
|
||||
{
|
||||
char *saveFname = static_buff;
|
||||
char ext[16];
|
||||
|
@ -761,11 +791,11 @@ char *emu_get_save_fname(int load, int is_sram, int slot)
|
|||
if (!load)
|
||||
return saveFname;
|
||||
|
||||
if (try_ropen_file(saveFname))
|
||||
if (try_ropen_file(saveFname, time))
|
||||
return saveFname;
|
||||
|
||||
romfname_ext(saveFname, sizeof(static_buff), NULL, ext);
|
||||
if (try_ropen_file(saveFname))
|
||||
if (try_ropen_file(saveFname, time))
|
||||
return saveFname;
|
||||
}
|
||||
else
|
||||
|
@ -783,11 +813,11 @@ char *emu_get_save_fname(int load, int is_sram, int slot)
|
|||
}
|
||||
else {
|
||||
romfname_ext(saveFname, sizeof(static_buff), "mds" PATH_SEP, ext);
|
||||
if (try_ropen_file(saveFname))
|
||||
if (try_ropen_file(saveFname, time))
|
||||
return saveFname;
|
||||
|
||||
romfname_ext(saveFname, sizeof(static_buff), NULL, ext);
|
||||
if (try_ropen_file(saveFname))
|
||||
if (try_ropen_file(saveFname, time))
|
||||
return saveFname;
|
||||
|
||||
// try the other ext
|
||||
|
@ -797,7 +827,7 @@ char *emu_get_save_fname(int load, int is_sram, int slot)
|
|||
strcat(ext, ext_othr);
|
||||
|
||||
romfname_ext(saveFname, sizeof(static_buff), "mds"PATH_SEP, ext);
|
||||
if (try_ropen_file(saveFname))
|
||||
if (try_ropen_file(saveFname, time))
|
||||
return saveFname;
|
||||
}
|
||||
}
|
||||
|
@ -807,7 +837,7 @@ char *emu_get_save_fname(int load, int is_sram, int slot)
|
|||
|
||||
int emu_check_save_file(int slot, int *time)
|
||||
{
|
||||
return emu_get_save_fname(1, 0, slot) ? 1 : 0;
|
||||
return emu_get_save_fname(1, 0, slot, time) ? 1 : 0;
|
||||
}
|
||||
|
||||
int emu_save_load_game(int load, int sram)
|
||||
|
@ -816,7 +846,7 @@ int emu_save_load_game(int load, int sram)
|
|||
char *saveFname;
|
||||
|
||||
// make save filename
|
||||
saveFname = emu_get_save_fname(load, sram, state_slot);
|
||||
saveFname = emu_get_save_fname(load, sram, state_slot, NULL);
|
||||
if (saveFname == NULL) {
|
||||
if (!sram)
|
||||
emu_status_msg(load ? "LOAD FAILED (missing file)" : "SAVE FAILED");
|
||||
|
|
|
@ -121,7 +121,7 @@ void emu_set_defconfig(void);
|
|||
int emu_read_config(const char *rom_fname, int no_defaults);
|
||||
int emu_write_config(int game);
|
||||
|
||||
char *emu_get_save_fname(int load, int is_sram, int slot);
|
||||
char *emu_get_save_fname(int load, int is_sram, int slot, int *time);
|
||||
int emu_check_save_file(int slot, int *time);
|
||||
|
||||
void emu_text_out8 (int x, int y, const char *text);
|
||||
|
|
|
@ -135,7 +135,7 @@ static void draw_savestate_bg(int slot)
|
|||
const char *fname;
|
||||
void *tmp_state;
|
||||
|
||||
fname = emu_get_save_fname(1, 0, slot);
|
||||
fname = emu_get_save_fname(1, 0, slot, NULL);
|
||||
if (!fname)
|
||||
return;
|
||||
|
||||
|
@ -1166,6 +1166,7 @@ void menu_update_msg(const char *msg)
|
|||
static menu_entry e_menu_hidden[] =
|
||||
{
|
||||
mee_onoff("Accurate sprites", MA_OPT_ACC_SPRITES, PicoOpt, 0x080),
|
||||
mee_onoff("autoload savestates", MA_OPT_AUTOLOAD_SAVE, g_autostateld_opt, 1),
|
||||
mee_end,
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ typedef enum
|
|||
MA_OPT_ROTATION, /* uiq */
|
||||
MA_OPT_TEARING_FIX, /* wiz */
|
||||
MA_OPT_VOUT_MODE,
|
||||
MA_OPT_AUTOLOAD_SAVE,
|
||||
MA_OPT2_GAMMA,
|
||||
MA_OPT2_A_SN_GAMMA,
|
||||
MA_OPT2_DBLBUFF, /* giz */
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7ceadd9993ea84078e9d74d79215419e06496f90
|
||||
Subproject commit 9089665ca1260c338c4239583f59de981bc80c1c
|
|
@ -74,16 +74,21 @@ static struct in_default_bind in_evdev_defbinds[] =
|
|||
{ KEY_D, IN_BINDTYPE_PLAYER12, GBTN_C },
|
||||
{ KEY_ENTER, IN_BINDTYPE_PLAYER12, GBTN_START },
|
||||
{ KEY_F, IN_BINDTYPE_EMU, PEVB_FF },
|
||||
{ KEY_BACKSLASH, IN_BINDTYPE_EMU, PEVB_MENU },
|
||||
{ KEY_BACKSPACE,IN_BINDTYPE_EMU, PEVB_FF },
|
||||
{ KEY_BACKSLASH,IN_BINDTYPE_EMU, PEVB_MENU },
|
||||
{ KEY_SPACE, IN_BINDTYPE_EMU, PEVB_MENU },
|
||||
/* Pandora */
|
||||
{ KEY_LEFTCTRL, IN_BINDTYPE_EMU, PEVB_MENU },
|
||||
{ KEY_HOME, IN_BINDTYPE_PLAYER12, GBTN_A },
|
||||
{ KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, GBTN_B },
|
||||
{ KEY_END, IN_BINDTYPE_PLAYER12, GBTN_C },
|
||||
{ KEY_LEFTALT, IN_BINDTYPE_PLAYER12, GBTN_START },
|
||||
{ KEY_RIGHTSHIFT,IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
|
||||
{ KEY_RIGHTCTRL, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
|
||||
{ KEY_LEFTCTRL, IN_BINDTYPE_EMU, PEVB_MENU },
|
||||
{ KEY_1, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
|
||||
{ KEY_2, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
|
||||
{ KEY_3, IN_BINDTYPE_EMU, PEVB_SSLOT_PREV },
|
||||
{ KEY_4, IN_BINDTYPE_EMU, PEVB_SSLOT_NEXT },
|
||||
{ KEY_5, IN_BINDTYPE_EMU, PEVB_PICO_PPREV },
|
||||
{ KEY_6, IN_BINDTYPE_EMU, PEVB_PICO_PNEXT },
|
||||
{ KEY_7, IN_BINDTYPE_EMU, PEVB_PICO_SWINP },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue