mirror of
https://github.com/libretro/RetroArch
synced 2025-02-19 21:40:49 +00:00
Add rewind granularity. (Faster, but less accurate rewind.)
This commit is contained in:
parent
ae395f05e1
commit
9034e82298
@ -153,6 +153,9 @@ static const bool rewind_enable = false;
|
||||
// The buffer size for the rewind buffer. This needs to be about 15-20MB per minute. Very game dependant.
|
||||
static const unsigned rewind_buffer_size = 20 << 20; // 20MiB
|
||||
|
||||
// How many frames to rewind at a time.
|
||||
static const unsigned rewind_granularity = 1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -88,6 +88,7 @@ struct settings
|
||||
|
||||
bool rewind_enable;
|
||||
unsigned rewind_buffer_size;
|
||||
unsigned rewind_granularity;
|
||||
};
|
||||
|
||||
enum ssnes_game_type
|
||||
|
@ -126,6 +126,7 @@ static void set_defaults(void)
|
||||
|
||||
g_settings.rewind_enable = rewind_enable;
|
||||
g_settings.rewind_buffer_size = rewind_buffer_size;
|
||||
g_settings.rewind_granularity = rewind_granularity;
|
||||
|
||||
assert(sizeof(g_settings.input.binds[0]) >= sizeof(snes_keybinds_1));
|
||||
assert(sizeof(g_settings.input.binds[1]) >= sizeof(snes_keybinds_2));
|
||||
@ -314,6 +315,7 @@ static void parse_config_file(void)
|
||||
|
||||
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
|
||||
CONFIG_GET_INT(rewind_buffer_size, "rewind_buffer_size");
|
||||
CONFIG_GET_INT(rewind_granularity, "rewind_granularity");
|
||||
|
||||
read_keybinds(conf);
|
||||
|
||||
|
11
ssnes.c
11
ssnes.c
@ -826,14 +826,17 @@ static void check_rewind(void)
|
||||
g_extern.frame_is_reverse = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_queue_push(g_extern.msg_queue, "Reached end of rewind buffer!", 0, 30);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snes_serialize(g_extern.state_buf, snes_serialize_size());
|
||||
state_manager_push(g_extern.state_manager, g_extern.state_buf);
|
||||
static unsigned cnt = 0;
|
||||
cnt = (cnt + 1) % (g_settings.rewind_granularity ? g_settings.rewind_granularity : 1); // Avoid possible SIGFPE.
|
||||
if (cnt == 0)
|
||||
{
|
||||
snes_serialize(g_extern.state_buf, snes_serialize_size());
|
||||
state_manager_push(g_extern.state_manager, g_extern.state_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,6 +199,9 @@
|
||||
# The buffer should be approx. 20MB per minute of buffer time.
|
||||
# rewind_buffer_size = 20
|
||||
|
||||
# Rewind granularity. When rewinding defined number of frames, you can rewind several frames at a time, increasing the rewinding speed.
|
||||
# rewind_granularity = 1
|
||||
|
||||
# Hold button down to rewind. Rewinding must be enabled.
|
||||
# input_rewind = r
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user