Minor cleanup for rewind.

This commit is contained in:
Themaister 2011-10-23 17:13:16 +02:00
parent 235355ffc7
commit 3739cbfc70
2 changed files with 5 additions and 9 deletions

View File

@ -22,8 +22,6 @@
#include <string.h>
#include <assert.h>
//#include <stdio.h>
struct state_manager
{
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)
{
//unsigned patch_size = 0;
bool crossed = false;
const uint32_t *old_state = state->tmp_state;
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];
// 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.
// This, if states don't really differ much, we'll save lots of space :) Hopefully this will work really well with save states.
// 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.
// 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)
{
//patch_size++;
state->buffer[state->top_ptr] = (i << 32) | xor;
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)
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)

View File

@ -1013,7 +1013,7 @@ static void init_rewind(void)
if (g_settings.rewind_enable)
{
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);
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);