Skip to content

Commit

Permalink
Save improvements (libretro#16053)
Browse files Browse the repository at this point in the history
* Simplify autosave command function

* Simplify and split save and savestate logic

save.c contains "SRAM" saves and their logic, which uses no task/queue.
  • Loading branch information
davidgfnet authored and Sunderland93 committed Dec 26, 2024
1 parent 1acfbe7 commit 74a3a9f
Show file tree
Hide file tree
Showing 8 changed files with 610 additions and 590 deletions.
1 change: 1 addition & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ ifeq ($(HAVE_PATCH), 1)
endif

OBJ += \
save.o \
tasks/task_save.o \
tasks/task_movie.o \
tasks/task_file_transfer.o \
Expand Down
8 changes: 1 addition & 7 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,20 +1258,14 @@ bool command_event_resize_windowed_scale(settings_t *settings,
return true;
}

bool command_event_save_auto_state(
bool savestate_auto_save,
const enum rarch_core_type current_core_type)
bool command_event_save_auto_state(void)
{
size_t _len;
runloop_state_t *runloop_st = runloop_state_get_ptr();
char savestate_name_auto[PATH_MAX_LENGTH];

if (runloop_st->entry_state_slot)
return false;
if (!savestate_auto_save)
return false;
if (current_core_type == CORE_TYPE_DUMMY)
return false;
if (!core_info_current_supports_savestate())
return false;
if (string_is_empty(path_basename(path_get(RARCH_PATH_BASENAME))))
Expand Down
4 changes: 1 addition & 3 deletions command.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,7 @@ void command_event_set_mixer_volume(
bool command_event_resize_windowed_scale(settings_t *settings,
unsigned window_scale);

bool command_event_save_auto_state(
bool savestate_auto_save,
const enum rarch_core_type current_core_type);
bool command_event_save_auto_state(void);

/**
* event_set_volume:
Expand Down
6 changes: 0 additions & 6 deletions content.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ typedef struct content_ctx_info
int argc; /* Argument count. */
} content_ctx_info_t;

/* Load a RAM state from disk to memory. */
bool content_load_ram_file(unsigned slot);

/* Save a RAM state from memory to disk. */
bool content_save_ram_file(unsigned slot, bool compress);

/* Load a state from memory. */
bool content_load_state_from_ram(void);

Expand Down
1 change: 1 addition & 0 deletions griffin/griffin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ DATA RUNLOOP
#endif
#endif
#endif
#include "../save.c"
#include "../tasks/task_save.c"
#include "../tasks/task_movie.c"
#include "../tasks/task_image.c"
Expand Down
12 changes: 6 additions & 6 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -3600,9 +3600,9 @@ bool command_event(enum event_command cmd, void *data)
settings->bools.content_runtime_log_aggregate,
settings->paths.directory_runtime_log,
settings->paths.directory_playlist);
command_event_save_auto_state(
settings->bools.savestate_auto_save,
runloop_st->current_core_type);
if (settings->bools.savestate_auto_save &&
runloop_st->current_core_type != CORE_TYPE_DUMMY)
command_event_save_auto_state();

if ( (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE)
|| (runloop_st->flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE)
Expand Down Expand Up @@ -8102,9 +8102,9 @@ bool retroarch_main_quit(void)
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
#endif

command_event_save_auto_state(
settings->bools.savestate_auto_save,
runloop_st->current_core_type);
if (settings->bools.savestate_auto_save &&
runloop_st->current_core_type != CORE_TYPE_DUMMY)
command_event_save_auto_state();

/* If any save states are in progress, wait
* until all tasks are complete (otherwise
Expand Down
Loading

0 comments on commit 74a3a9f

Please sign in to comment.