mirror of
https://github.com/libretro/RetroArch
synced 2024-12-27 15:29:23 +00:00
Undo Load State and Undo Save State both seem to be working.
This commit is contained in:
parent
051cc3fe4d
commit
8c5238c349
@ -1600,7 +1600,7 @@ static void command_event_undo_save_state(char *s, size_t len)
|
||||
if (!content_undo_save_state())
|
||||
{
|
||||
snprintf(s, len, "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_FAILED_TO_SAVE_UNDO),
|
||||
msg_hash_to_str(MSG_FAILED_TO_UNDO_SAVE_STATE),
|
||||
"from internal buffer");
|
||||
}
|
||||
}
|
||||
@ -1638,7 +1638,7 @@ static void command_event_undo_load_state(char *s, size_t len)
|
||||
if (!content_undo_load_state())
|
||||
{
|
||||
snprintf(s, len, "%s \"%s\".",
|
||||
msg_hash_to_str(MSG_FAILED_TO_LOAD_UNDO),
|
||||
msg_hash_to_str(MSG_FAILED_TO_UNDO_LOAD_STATE),
|
||||
"from internal buffer");
|
||||
}
|
||||
}
|
||||
|
BIN
internal buffer
Normal file
BIN
internal buffer
Normal file
Binary file not shown.
@ -112,13 +112,13 @@ const char *msg_hash_to_str_us(uint32_t hash)
|
||||
case MSG_RESET:
|
||||
return "Reset";
|
||||
case MSG_FAILED_TO_LOAD_STATE:
|
||||
return "Failed to load state from";
|
||||
return "Nothing to undo.";
|
||||
case MSG_FAILED_TO_SAVE_STATE_TO:
|
||||
return "Failed to save state to";
|
||||
case MSG_FAILED_TO_LOAD_UNDO:
|
||||
return "No undo state found";
|
||||
case MSG_FAILED_TO_SAVE_UNDO:
|
||||
return "Failed to save undo information";
|
||||
case MSG_FAILED_TO_UNDO_LOAD_STATE:
|
||||
return "Failed to undo load state.";
|
||||
case MSG_FAILED_TO_UNDO_SAVE_STATE:
|
||||
return "Failed to undo save state.";
|
||||
case MSG_FAILED_TO_SAVE_SRAM:
|
||||
return "Failed to save SRAM";
|
||||
case MSG_STATE_SIZE:
|
||||
|
@ -125,8 +125,8 @@
|
||||
#define MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES 0xd50adf46U
|
||||
#define MSG_FAILED_TO_LOAD_STATE 0x91f348ebU
|
||||
|
||||
#define MSG_FAILED_TO_LOAD_UNDO 0xb6e2fc55U
|
||||
#define MSG_FAILED_TO_SAVE_UNDO 0xf2e29478U
|
||||
#define MSG_FAILED_TO_UNDO_LOAD_STATE 0xb6e2fc55U
|
||||
#define MSG_FAILED_TO_UNDO_SAVE_STATE 0xf2e29478U
|
||||
|
||||
#define MSG_RESET 0x10474288U
|
||||
|
||||
|
@ -64,6 +64,9 @@ struct sram_block
|
||||
|
||||
bool content_undo_load_state()
|
||||
{
|
||||
if (old_state_buf.data == NULL)
|
||||
return false;
|
||||
|
||||
unsigned i;
|
||||
//ssize_t size;
|
||||
retro_ctx_serialize_info_t serial_info;
|
||||
@ -78,9 +81,6 @@ bool content_undo_load_state()
|
||||
msg_hash_to_str(MSG_LOADING_STATE),
|
||||
"from internal buffer");
|
||||
|
||||
if (old_state_buf.size == 0)
|
||||
return true;
|
||||
|
||||
RARCH_LOG("%s: %u %s.\n",
|
||||
msg_hash_to_str(MSG_STATE_SIZE),
|
||||
old_state_buf.size,
|
||||
@ -165,7 +165,7 @@ bool content_undo_load_state()
|
||||
|
||||
if (!ret)
|
||||
RARCH_ERR("%s \"%s\".\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE),
|
||||
msg_hash_to_str(MSG_FAILED_TO_UNDO_LOAD_STATE),
|
||||
"from internal buffer");
|
||||
|
||||
/* Wipe the old state buffer, it's meant to be one use only */
|
||||
@ -193,6 +193,11 @@ bool content_undo_save_state()
|
||||
|
||||
old_save_file.data = 0;
|
||||
|
||||
if (!ret)
|
||||
RARCH_ERR("%s \"%s\".\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_UNDO_SAVE_STATE),
|
||||
"from internal buffer");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -202,7 +207,7 @@ bool content_undo_save_state()
|
||||
/**
|
||||
* save_state:
|
||||
* @path : path of saved state that shall be written to.
|
||||
*
|
||||
* @save_to_disk: If false, saves the state onto old_state_buf.
|
||||
* Save a state from memory to disk.
|
||||
*
|
||||
* Returns: true if successful, false otherwise.
|
||||
@ -278,13 +283,15 @@ bool content_save_state_with_backup(const char *path, bool save_to_disk)
|
||||
/**
|
||||
* content_load_state:
|
||||
* @path : path that state will be loaded from.
|
||||
*
|
||||
* @load_to_backup_buffer: If true, the state will be loaded into old_save_file.
|
||||
* Load a state from disk to memory.
|
||||
*
|
||||
* Returns: true if successful, false otherwise.
|
||||
*
|
||||
*
|
||||
**/
|
||||
bool content_load_state(const char* path) { content_load_state_with_backup(path, false); }
|
||||
bool content_load_state_with_backup(const char *path, bool save_to_backup_buffer)
|
||||
bool content_load_state_with_backup(const char *path, bool load_to_backup_buffer)
|
||||
{
|
||||
unsigned i;
|
||||
ssize_t size;
|
||||
@ -310,7 +317,7 @@ bool content_load_state_with_backup(const char *path, bool save_to_backup_buffer
|
||||
|
||||
/* This means we're backing up the file in memory, so content_undo_save_state()
|
||||
can restore it */
|
||||
if (save_to_backup_buffer) {
|
||||
if (load_to_backup_buffer) {
|
||||
strcpy(old_save_file.path, path);
|
||||
|
||||
/* If we were previously backing up a file, let go of it first */
|
||||
@ -381,7 +388,7 @@ bool content_load_state_with_backup(const char *path, bool save_to_backup_buffer
|
||||
serial_info.size = size;
|
||||
|
||||
/* Backup the current state so we can undo this load */
|
||||
content_save_state_with_backup(NULL, true);
|
||||
content_save_state_with_backup("internal buffer", false);
|
||||
ret = core_unserialize(&serial_info);
|
||||
|
||||
/* Flush back. */
|
||||
|
Loading…
Reference in New Issue
Block a user