Create bsv_movie_get_input

This commit is contained in:
twinaphex 2017-01-22 17:03:42 +01:00
parent b04056db11
commit 12c5cc51c5
3 changed files with 16 additions and 16 deletions

View File

@ -342,9 +342,9 @@ int16_t input_state(unsigned port, unsigned device,
if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL))
{
int16_t ret;
if (bsv_movie_ctl(BSV_MOVIE_CTL_GET_INPUT, &ret))
return ret;
int16_t bsv_result;
if (bsv_movie_get_input(&bsv_result))
return bsv_result;
bsv_movie_ctl(BSV_MOVIE_CTL_SET_END, NULL);
}

21
movie.c
View File

@ -354,6 +354,17 @@ static void bsv_movie_init_state(void)
}
}
bool bsv_movie_get_input(int16_t *bsv_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);
return true;
}
bool bsv_movie_ctl(enum bsv_ctl_state state, void *data)
{
switch (state)
@ -405,16 +416,6 @@ 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;

View File

@ -46,9 +46,6 @@ enum bsv_ctl_state
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,
@ -76,6 +73,8 @@ 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_ctl(enum bsv_ctl_state state, void *data);
bool bsv_movie_check(void);