Unroll this

This commit is contained in:
twinaphex 2019-01-13 07:46:35 +01:00
parent cb596aec3a
commit 5b88685448
3 changed files with 38 additions and 50 deletions

45
movie.c
View File

@ -21,7 +21,6 @@
#include <rhash.h>
#include <compat/strl.h>
#include <retro_endianness.h>
#include <streams/interface_stream.h>
#include "configuration.h"
#include "movie.h"
@ -34,26 +33,6 @@
#include "command.h"
#include "file_path_special.h"
struct bsv_movie
{
intfstream_t *file;
/* A ring buffer keeping track of positions
* in the file for each frame. */
size_t *frame_pos;
size_t frame_mask;
size_t frame_ptr;
size_t min_file_pos;
size_t state_size;
uint8_t *state;
bool playback;
bool first_rewind;
bool did_rewind;
};
struct bsv_state
{
bool movie_start_recording;
@ -68,7 +47,7 @@ struct bsv_state
char movie_start_path[PATH_MAX_LENGTH];
};
static bsv_movie_t *bsv_movie_state_handle = NULL;
bsv_movie_t *bsv_movie_state_handle = NULL;
static struct bsv_state bsv_movie_state;
static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path)
@ -259,28 +238,6 @@ error:
return NULL;
}
/* Used for rewinding while playback/record. */
void bsv_movie_set_frame_start(void)
{
if (bsv_movie_state_handle)
bsv_movie_state_handle->frame_pos[bsv_movie_state_handle->frame_ptr]
= intfstream_tell(bsv_movie_state_handle->file);
}
void bsv_movie_set_frame_end(void)
{
if (!bsv_movie_state_handle)
return;
bsv_movie_state_handle->frame_ptr =
(bsv_movie_state_handle->frame_ptr + 1)
& bsv_movie_state_handle->frame_mask;
bsv_movie_state_handle->first_rewind =
!bsv_movie_state_handle->did_rewind;
bsv_movie_state_handle->did_rewind = false;
}
static void bsv_movie_frame_rewind(bsv_movie_t *handle)
{
handle->did_rewind = true;

27
movie.h
View File

@ -22,6 +22,7 @@
#include <boolean.h>
#include <retro_common_api.h>
#include <streams/interface_stream.h>
RETRO_BEGIN_DECLS
@ -56,6 +57,26 @@ enum bsv_ctl_state
BSV_MOVIE_CTL_UNSET_END
};
struct bsv_movie
{
intfstream_t *file;
/* A ring buffer keeping track of positions
* in the file for each frame. */
size_t *frame_pos;
size_t frame_mask;
size_t frame_ptr;
size_t min_file_pos;
size_t state_size;
uint8_t *state;
bool playback;
bool first_rewind;
bool did_rewind;
};
void bsv_movie_deinit(void);
bool bsv_movie_init(void);
@ -68,10 +89,6 @@ void bsv_movie_set_path(const char *path);
void bsv_movie_set_start_path(const char *path);
void bsv_movie_set_frame_start(void);
void bsv_movie_set_frame_end(void);
bool bsv_movie_get_input(int16_t *bsv_data);
bool bsv_movie_is_end_of_file(void);
@ -82,6 +99,8 @@ bool bsv_movie_check(void);
bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type);
extern bsv_movie_t *bsv_movie_state_handle;
RETRO_END_DECLS
#endif

View File

@ -3594,7 +3594,10 @@ int runloop_iterate(unsigned *sleep_ms)
if (runloop_autosave)
autosave_lock();
bsv_movie_set_frame_start();
/* Used for rewinding while playback/record. */
if (bsv_movie_state_handle)
bsv_movie_state_handle->frame_pos[bsv_movie_state_handle->frame_ptr]
= intfstream_tell(bsv_movie_state_handle->file);
camera_driver_poll();
@ -3661,7 +3664,16 @@ int runloop_iterate(unsigned *sleep_ms)
input_pop_analog_dpad(auto_binds);
}
bsv_movie_set_frame_end();
if (bsv_movie_state_handle)
{
bsv_movie_state_handle->frame_ptr =
(bsv_movie_state_handle->frame_ptr + 1)
& bsv_movie_state_handle->frame_mask;
bsv_movie_state_handle->first_rewind =
!bsv_movie_state_handle->did_rewind;
bsv_movie_state_handle->did_rewind = false;
}
if (runloop_autosave)
autosave_unlock();