It does work, somewhat! :D

This commit is contained in:
Themaister 2011-02-26 00:59:17 +01:00
parent f135972a6b
commit f24653768f
3 changed files with 21 additions and 26 deletions

35
movie.c
View File

@ -96,6 +96,7 @@ struct bsv_movie
bool playback;
unsigned min_file_pos;
bool first_rewind;
};
#define BSV_MAGIC 0x42535631
@ -229,25 +230,16 @@ void bsv_movie_free(bsv_movie_t *handle)
bool bsv_movie_get_input(bsv_movie_t *handle, int16_t *input)
{
if (g_extern.frame_is_reverse)
{
*input = 0;
return true;
}
else
{
if (fread(input, sizeof(int16_t), 1, handle->file) != 1)
return false;
if (fread(input, sizeof(int16_t), 1, handle->file) != 1)
return false;
*input = swap_if_big16(*input);
return true;
}
*input = swap_if_big16(*input);
return true;
}
void bsv_movie_set_input(bsv_movie_t *handle, int16_t input)
{
if (!g_extern.frame_is_reverse)
fwrite(&input, sizeof(int16_t), 1, handle->file);
fwrite(&input, sizeof(int16_t), 1, handle->file);
}
bsv_movie_t *bsv_movie_init(const char *path, enum ssnes_movie_type type)
@ -289,6 +281,15 @@ void bsv_movie_set_frame_end(bsv_movie_t *handle)
void bsv_movie_frame_rewind(bsv_movie_t *handle)
{
fprintf(stderr, "Frame--\n");
if (handle->frame_ptr <= 1)
handle->frame_ptr = 0;
else
{
handle->frame_ptr = (handle->frame_ptr - 2) & handle->frame_mask;
fseek(handle->file, handle->frame_pos[handle->frame_ptr], SEEK_SET);
}
if (ftell(handle->file) <= (long)handle->min_file_pos)
{
if (!handle->playback)
@ -300,10 +301,4 @@ void bsv_movie_frame_rewind(bsv_movie_t *handle)
else
fseek(handle->file, handle->min_file_pos, SEEK_SET);
}
else
{
fprintf(stderr, "Frame--\n");
handle->frame_ptr = (handle->frame_ptr - 1) & handle->frame_mask;
fseek(handle->file, handle->frame_pos[handle->frame_ptr], SEEK_SET);
}
}

View File

@ -78,11 +78,11 @@ void state_manager_free(state_manager_t *state)
bool state_manager_pop(state_manager_t *state, void **data)
{
*data = state->tmp_state;
if (state->first_pop)
{
state->first_pop = false;
return true;
}
//if (state->first_pop)
//{
// state->first_pop = false;
// return true;
//}
if (state->top_ptr == 0)
state->top_ptr = state->buf_size - 1;

View File

@ -1266,7 +1266,7 @@ int main(int argc, char *argv[])
psnes_run();
if (g_extern.bsv_movie && !g_extern.frame_is_reverse)
if (g_extern.bsv_movie)
bsv_movie_set_frame_end(g_extern.bsv_movie);
if (g_extern.netplay)
netplay_post_frame(g_extern.netplay);