mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
movie.c - move variable declarations to top of function
This commit is contained in:
parent
5bacd9ed1b
commit
8cfdd30ca0
33
movie.c
33
movie.c
@ -44,6 +44,9 @@ struct bsv_movie
|
|||||||
|
|
||||||
static bool init_playback(bsv_movie_t *handle, const char *path)
|
static bool init_playback(bsv_movie_t *handle, const char *path)
|
||||||
{
|
{
|
||||||
|
uint32_t state_size;
|
||||||
|
uint32_t header[4] = {0};
|
||||||
|
|
||||||
handle->playback = true;
|
handle->playback = true;
|
||||||
handle->file = fopen(path, "rb");
|
handle->file = fopen(path, "rb");
|
||||||
if (!handle->file)
|
if (!handle->file)
|
||||||
@ -52,7 +55,6 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t header[4] = {0};
|
|
||||||
if (fread(header, sizeof(uint32_t), 4, handle->file) != 4)
|
if (fread(header, sizeof(uint32_t), 4, handle->file) != 4)
|
||||||
{
|
{
|
||||||
RARCH_ERR("Couldn't read movie header.\n");
|
RARCH_ERR("Couldn't read movie header.\n");
|
||||||
@ -71,7 +73,7 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
|||||||
if (swap_if_big32(header[CRC_INDEX]) != g_extern.content_crc)
|
if (swap_if_big32(header[CRC_INDEX]) != g_extern.content_crc)
|
||||||
RARCH_WARN("CRC32 checksum mismatch between content file and saved content checksum in replay file header; replay highly likely to desync on playback.\n");
|
RARCH_WARN("CRC32 checksum mismatch between content file and saved content checksum in replay file header; replay highly likely to desync on playback.\n");
|
||||||
|
|
||||||
uint32_t state_size = swap_if_big32(header[STATE_SIZE_INDEX]);
|
state_size = swap_if_big32(header[STATE_SIZE_INDEX]);
|
||||||
|
|
||||||
if (state_size)
|
if (state_size)
|
||||||
{
|
{
|
||||||
@ -99,6 +101,9 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
|||||||
|
|
||||||
static bool init_record(bsv_movie_t *handle, const char *path)
|
static bool init_record(bsv_movie_t *handle, const char *path)
|
||||||
{
|
{
|
||||||
|
uint32_t state_size;
|
||||||
|
uint32_t header[4] = {0};
|
||||||
|
|
||||||
handle->file = fopen(path, "wb");
|
handle->file = fopen(path, "wb");
|
||||||
if (!handle->file)
|
if (!handle->file)
|
||||||
{
|
{
|
||||||
@ -106,7 +111,6 @@ static bool init_record(bsv_movie_t *handle, const char *path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t header[4] = {0};
|
|
||||||
|
|
||||||
/* This value is supposed to show up as
|
/* This value is supposed to show up as
|
||||||
* BSV1 in a HEX editor, big-endian. */
|
* BSV1 in a HEX editor, big-endian. */
|
||||||
@ -114,7 +118,7 @@ static bool init_record(bsv_movie_t *handle, const char *path)
|
|||||||
|
|
||||||
header[CRC_INDEX] = swap_if_big32(g_extern.content_crc);
|
header[CRC_INDEX] = swap_if_big32(g_extern.content_crc);
|
||||||
|
|
||||||
uint32_t state_size = pretro_serialize_size();
|
state_size = pretro_serialize_size();
|
||||||
|
|
||||||
header[STATE_SIZE_INDEX] = swap_if_big32(state_size);
|
header[STATE_SIZE_INDEX] = swap_if_big32(state_size);
|
||||||
fwrite(header, 4, sizeof(uint32_t), handle->file);
|
fwrite(header, 4, sizeof(uint32_t), handle->file);
|
||||||
@ -137,14 +141,14 @@ static bool init_record(bsv_movie_t *handle, const char *path)
|
|||||||
|
|
||||||
void bsv_movie_free(bsv_movie_t *handle)
|
void bsv_movie_free(bsv_movie_t *handle)
|
||||||
{
|
{
|
||||||
if (handle)
|
if (!handle)
|
||||||
{
|
return;
|
||||||
if (handle->file)
|
|
||||||
fclose(handle->file);
|
if (handle->file)
|
||||||
free(handle->state);
|
fclose(handle->file);
|
||||||
free(handle->frame_pos);
|
free(handle->state);
|
||||||
free(handle);
|
free(handle->frame_pos);
|
||||||
}
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsv_movie_get_input(bsv_movie_t *handle, int16_t *input)
|
bool bsv_movie_get_input(bsv_movie_t *handle, int16_t *input)
|
||||||
@ -193,11 +197,16 @@ error:
|
|||||||
|
|
||||||
void bsv_movie_set_frame_start(bsv_movie_t *handle)
|
void bsv_movie_set_frame_start(bsv_movie_t *handle)
|
||||||
{
|
{
|
||||||
|
if (!handle)
|
||||||
|
return;
|
||||||
handle->frame_pos[handle->frame_ptr] = ftell(handle->file);
|
handle->frame_pos[handle->frame_ptr] = ftell(handle->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bsv_movie_set_frame_end(bsv_movie_t *handle)
|
void bsv_movie_set_frame_end(bsv_movie_t *handle)
|
||||||
{
|
{
|
||||||
|
if (!handle)
|
||||||
|
return;
|
||||||
|
|
||||||
handle->frame_ptr = (handle->frame_ptr + 1) & handle->frame_mask;
|
handle->frame_ptr = (handle->frame_ptr + 1) & handle->frame_mask;
|
||||||
|
|
||||||
handle->first_rewind = !handle->did_rewind;
|
handle->first_rewind = !handle->did_rewind;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user