mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 18:35:22 +00:00
Minor cleanup for rewind.
This commit is contained in:
parent
235355ffc7
commit
3739cbfc70
12
rewind.c
12
rewind.c
@ -22,8 +22,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
//#include <stdio.h>
|
|
||||||
|
|
||||||
struct state_manager
|
struct state_manager
|
||||||
{
|
{
|
||||||
uint64_t *buffer;
|
uint64_t *buffer;
|
||||||
@ -125,7 +123,6 @@ static void reassign_bottom(state_manager_t *state)
|
|||||||
|
|
||||||
static void generate_delta(state_manager_t *state, const void *data)
|
static void generate_delta(state_manager_t *state, const void *data)
|
||||||
{
|
{
|
||||||
//unsigned patch_size = 0;
|
|
||||||
bool crossed = false;
|
bool crossed = false;
|
||||||
const uint32_t *old_state = state->tmp_state;
|
const uint32_t *old_state = state->tmp_state;
|
||||||
const uint32_t *new_state = data;
|
const uint32_t *new_state = data;
|
||||||
@ -138,11 +135,12 @@ static void generate_delta(state_manager_t *state, const void *data)
|
|||||||
{
|
{
|
||||||
uint64_t xor = old_state[i] ^ new_state[i];
|
uint64_t xor = old_state[i] ^ new_state[i];
|
||||||
|
|
||||||
// If the data differs (xor != 0), we push that xor on the stack with index and xor. This can be reversed by reapplying the xor.
|
// If the data differs (xor != 0), we push that xor on the stack with index and xor.
|
||||||
// This, if states don't really differ much, we'll save lots of space :) Hopefully this will work really well with save states.
|
// This can be reversed by reapplying the xor.
|
||||||
|
// This, if states don't really differ much, we'll save lots of space :)
|
||||||
|
// Hopefully this will work really well with save states.
|
||||||
if (xor)
|
if (xor)
|
||||||
{
|
{
|
||||||
//patch_size++;
|
|
||||||
state->buffer[state->top_ptr] = (i << 32) | xor;
|
state->buffer[state->top_ptr] = (i << 32) | xor;
|
||||||
state->top_ptr = (state->top_ptr + 1) % state->buf_size;
|
state->top_ptr = (state->top_ptr + 1) % state->buf_size;
|
||||||
|
|
||||||
@ -153,8 +151,6 @@ static void generate_delta(state_manager_t *state, const void *data)
|
|||||||
|
|
||||||
if (crossed)
|
if (crossed)
|
||||||
reassign_bottom(state);
|
reassign_bottom(state);
|
||||||
|
|
||||||
//fprintf(stderr, "DELTA SIZE: %u, ORIG SIZE: %u\n", (unsigned)patch_size << 3, (unsigned)state->state_size << 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool state_manager_push(state_manager_t *state, const void *data)
|
bool state_manager_push(state_manager_t *state, const void *data)
|
||||||
|
2
ssnes.c
2
ssnes.c
@ -1013,7 +1013,7 @@ static void init_rewind(void)
|
|||||||
if (g_settings.rewind_enable)
|
if (g_settings.rewind_enable)
|
||||||
{
|
{
|
||||||
size_t serial_size = psnes_serialize_size();
|
size_t serial_size = psnes_serialize_size();
|
||||||
g_extern.state_buf = malloc((serial_size + 3) & ~3); // Make sure we allocate at least 4-byte multiple.
|
g_extern.state_buf = calloc(1, (serial_size + 3) & ~3); // Make sure we allocate at least 4-byte multiple.
|
||||||
psnes_serialize(g_extern.state_buf, serial_size);
|
psnes_serialize(g_extern.state_buf, serial_size);
|
||||||
SSNES_LOG("Initing rewind buffer with size: %u MB\n", (unsigned)g_settings.rewind_buffer_size / 1000000);
|
SSNES_LOG("Initing rewind buffer with size: %u MB\n", (unsigned)g_settings.rewind_buffer_size / 1000000);
|
||||||
g_extern.state_manager = state_manager_new((serial_size + 3) & ~3, g_settings.rewind_buffer_size, g_extern.state_buf);
|
g_extern.state_manager = state_manager_new((serial_size + 3) & ~3, g_settings.rewind_buffer_size, g_extern.state_buf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user