Movie rewind still very broken :(

This commit is contained in:
Themaister 2011-02-25 12:37:05 +01:00
parent e8865060ca
commit 42c68e21a2
2 changed files with 10 additions and 3 deletions

View File

@ -269,9 +269,12 @@ error:
void bsv_movie_set_frame_end(bsv_movie_t *handle)
{
fprintf(stderr, "Current frame count: %u\n", handle->current_frame_count);
handle->frame_state[handle->frame_ptr] = handle->current_frame_count;
handle->current_frame_count = 0;
handle->frame_ptr = (handle->frame_ptr + 1) & handle->frame_mask;
fprintf(stderr, "Frame end: Current pos: %ld\n", ftell(handle->file) - handle->min_file_pos);
}
void bsv_movie_frame_rewind(bsv_movie_t *handle)
@ -290,4 +293,5 @@ void bsv_movie_frame_rewind(bsv_movie_t *handle)
handle->frame_ptr = (handle->frame_ptr - 1) & handle->frame_mask;
fseek(handle->file, -((long)handle->frame_state[handle->frame_ptr] * sizeof(int16_t)), SEEK_CUR);
}
fprintf(stderr, "Rewind: Current pos: %ld\n", ftell(handle->file) - handle->min_file_pos);
}

View File

@ -1042,8 +1042,6 @@ static void check_rewind(void)
if (driver.input->key_pressed(driver.input_data, SSNES_REWIND))
{
if (g_extern.bsv_movie)
bsv_movie_frame_rewind(g_extern.bsv_movie);
msg_queue_clear(g_extern.msg_queue);
void *buf;
@ -1052,6 +1050,11 @@ static void check_rewind(void)
msg_queue_push(g_extern.msg_queue, "Rewinding!", 0, 30);
psnes_unserialize(buf, psnes_serialize_size());
g_extern.frame_is_reverse = true;
if (g_extern.bsv_movie)
{
for (unsigned i = 0; i < (g_settings.rewind_granularity ? g_settings.rewind_granularity : 1); i++)
bsv_movie_frame_rewind(g_extern.bsv_movie);
}
}
else
msg_queue_push(g_extern.msg_queue, "Reached end of rewind buffer!", 0, 30);
@ -1254,7 +1257,7 @@ int main(int argc, char *argv[])
psnes_run();
if (g_extern.bsv_movie)
if (g_extern.bsv_movie && !g_extern.frame_is_reverse)
bsv_movie_set_frame_end(g_extern.bsv_movie);
if (g_extern.netplay)
netplay_post_frame(g_extern.netplay);