Create two new BSV_MOVIE_CTL_* actions

This commit is contained in:
twinaphex 2016-01-30 03:25:47 +01:00
parent bd39fd252f
commit b0ec812de6
3 changed files with 28 additions and 27 deletions

View File

@ -463,7 +463,7 @@ int16_t input_state(unsigned port, unsigned device,
if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL))
{
int16_t ret;
if (bsv_movie_get_input(&ret))
if (bsv_movie_ctl(BSV_MOVIE_CTL_GET_INPUT, &ret))
return ret;
bsv_movie_ctl(BSV_MOVIE_CTL_SET_END, NULL);
@ -514,7 +514,7 @@ int16_t input_state(unsigned port, unsigned device,
}
if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_OFF, NULL))
bsv_movie_set_input(res);
bsv_movie_ctl(BSV_MOVIE_CTL_SET_INPUT, &res);
return res;
}

38
movie.c
View File

@ -198,24 +198,6 @@ void bsv_movie_free(bsv_movie_t *handle)
free(handle);
}
bool bsv_movie_get_input(int16_t *input)
{
bsv_movie_t *handle = bsv_movie_state.movie;
if (fread(input, sizeof(int16_t), 1, handle->file) != 1)
return false;
*input = swap_if_big16(*input);
return true;
}
void bsv_movie_set_input(int16_t input)
{
bsv_movie_t *handle = bsv_movie_state.movie;
input = swap_if_big16(input);
fwrite(&input, sizeof(int16_t), 1, handle->file);
}
bsv_movie_t *bsv_movie_init(const char *path, enum rarch_movie_type type)
{
bsv_movie_t *handle = (bsv_movie_t*)calloc(1, sizeof(*handle));
@ -414,6 +396,26 @@ bool bsv_movie_ctl(enum bsv_ctl_state state, void *data)
case BSV_MOVIE_CTL_FRAME_REWIND:
bsv_movie_frame_rewind(bsv_movie_state.movie);
break;
case BSV_MOVIE_CTL_GET_INPUT:
{
int16_t *bsv_data = (int16_t*)data;
bsv_movie_t *handle = bsv_movie_state.movie;
if (fread(bsv_data, sizeof(int16_t), 1, handle->file) != 1)
return false;
*bsv_data = swap_if_big16(*bsv_data);
}
break;
case BSV_MOVIE_CTL_SET_INPUT:
{
int16_t *bsv_data = (int16_t*)data;
bsv_movie_t *handle = bsv_movie_state.movie;
*bsv_data = swap_if_big16(*bsv_data);
fwrite(bsv_data, sizeof(int16_t), 1, handle->file);
}
break;
case BSV_MOVIE_CTL_NONE:
default:
return false;
}

13
movie.h
View File

@ -42,9 +42,14 @@ enum rarch_movie_type
enum bsv_ctl_state
{
BSV_MOVIE_CTL_IS_INITED = 0,
BSV_MOVIE_CTL_NONE = 0,
BSV_MOVIE_CTL_IS_INITED,
BSV_MOVIE_CTL_PLAYBACK_ON,
BSV_MOVIE_CTL_PLAYBACK_OFF,
/* Playback. */
BSV_MOVIE_CTL_GET_INPUT,
/* Recording. */
BSV_MOVIE_CTL_SET_INPUT,
BSV_MOVIE_CTL_SET_START_RECORDING,
BSV_MOVIE_CTL_UNSET_START_RECORDING,
BSV_MOVIE_CTL_START_RECORDING,
@ -72,12 +77,6 @@ void bsv_movie_set_start_path(const char *path);
bsv_movie_t *bsv_movie_init(const char *path, enum rarch_movie_type type);
/* Playback. */
bool bsv_movie_get_input(int16_t *input);
/* Recording. */
void bsv_movie_set_input(int16_t input);
/* Used for rewinding while playback/record. */
void bsv_movie_set_frame_start(bsv_movie_t *handle);