mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-04 17:06:48 +00:00
Refactor BSV movie code
This commit is contained in:
parent
e09358c712
commit
7dca09d6f8
14
command.c
14
command.c
@ -1208,7 +1208,7 @@ static void command_event_deinit_core(bool reinit)
|
||||
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
|
||||
}
|
||||
|
||||
static void command_event_init_cheats(void)
|
||||
static bool command_event_init_cheats(void)
|
||||
{
|
||||
bool allow_cheats = true;
|
||||
#ifdef HAVE_NETWORKING
|
||||
@ -1218,9 +1218,11 @@ static void command_event_init_cheats(void)
|
||||
allow_cheats &= !bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL);
|
||||
|
||||
if (!allow_cheats)
|
||||
return;
|
||||
return false;
|
||||
|
||||
/* TODO/FIXME - add some stuff here. */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void command_event_load_auto_state(void)
|
||||
@ -2016,8 +2018,7 @@ bool command_event(enum event_command cmd, void *data)
|
||||
break;
|
||||
case CMD_EVENT_CHEATS_INIT:
|
||||
command_event(CMD_EVENT_CHEATS_DEINIT, NULL);
|
||||
command_event_init_cheats();
|
||||
break;
|
||||
return command_event_init_cheats();
|
||||
case CMD_EVENT_CHEATS_APPLY:
|
||||
cheat_manager_apply_cheats();
|
||||
break;
|
||||
@ -2430,7 +2431,10 @@ bool command_event(enum event_command cmd, void *data)
|
||||
break;
|
||||
case CMD_EVENT_BSV_MOVIE_INIT:
|
||||
command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL);
|
||||
bsv_movie_init();
|
||||
if (bsv_movie_init())
|
||||
runloop_set(RUNLOOP_ACTION_BSV_MOVIE);
|
||||
else
|
||||
runloop_unset(RUNLOOP_ACTION_BSV_MOVIE);
|
||||
break;
|
||||
#ifdef HAVE_NETWORKING
|
||||
case CMD_EVENT_NETPLAY_DEINIT:
|
||||
|
19
movie.c
19
movie.c
@ -248,6 +248,7 @@ error:
|
||||
/* Used for rewinding while playback/record. */
|
||||
void bsv_movie_set_frame_start(void)
|
||||
{
|
||||
RARCH_LOG("movie state: %d\n", bsv_movie_state_handle);
|
||||
if (bsv_movie_state_handle)
|
||||
bsv_movie_state_handle->frame_pos[bsv_movie_state_handle->frame_ptr]
|
||||
= filestream_tell(bsv_movie_state_handle->file);
|
||||
@ -315,6 +316,15 @@ static void bsv_movie_frame_rewind(bsv_movie_t *handle)
|
||||
}
|
||||
}
|
||||
|
||||
static bool bsv_movie_init_handle(const char *path,
|
||||
enum rarch_movie_type type)
|
||||
{
|
||||
bsv_movie_state_handle = bsv_movie_init_internal(path, type);
|
||||
if (!bsv_movie_state_handle)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bsv_movie_init(void)
|
||||
{
|
||||
bool set_granularity = false;
|
||||
@ -461,15 +471,6 @@ void bsv_movie_set_start_path(const char *path)
|
||||
sizeof(bsv_movie_state.movie_start_path));
|
||||
}
|
||||
|
||||
bool bsv_movie_init_handle(const char *path,
|
||||
enum rarch_movie_type type)
|
||||
{
|
||||
bsv_movie_state_handle = bsv_movie_init_internal(path, type);
|
||||
if (!bsv_movie_state_handle)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void bsv_movie_deinit(void)
|
||||
{
|
||||
if (!bsv_movie_state_handle)
|
||||
|
2
movie.h
2
movie.h
@ -80,8 +80,6 @@ bool bsv_movie_ctl(enum bsv_ctl_state state, void *data);
|
||||
|
||||
bool bsv_movie_check(void);
|
||||
|
||||
bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
23
runloop.c
23
runloop.c
@ -132,6 +132,7 @@ static bool runloop_perfcnt_enable = false;
|
||||
static bool runloop_overrides_active = false;
|
||||
static bool runloop_game_options_active = false;
|
||||
static bool runloop_missing_bios = false;
|
||||
static bool runloop_bsv_movie = false;
|
||||
static bool runloop_autosave = false;
|
||||
static retro_time_t frame_limit_minimum_time = 0.0;
|
||||
static retro_time_t frame_limit_last_time = 0.0;
|
||||
@ -393,6 +394,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
runloop_paused = false;
|
||||
runloop_slowmotion = false;
|
||||
runloop_overrides_active = false;
|
||||
runloop_bsv_movie = false;
|
||||
runloop_autosave = false;
|
||||
runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL);
|
||||
break;
|
||||
@ -674,7 +676,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
* d) Video driver no longer alive.
|
||||
* e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better)
|
||||
*/
|
||||
#define time_to_exit(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !is_alive || bsv_movie_is_end_of_file() || (runloop_max_frames && (frame_count >= runloop_max_frames)) || runloop_exec)
|
||||
#define time_to_exit(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !is_alive || (runloop_bsv_movie && bsv_movie_is_end_of_file()) || (runloop_max_frames && (frame_count >= runloop_max_frames)) || runloop_exec)
|
||||
|
||||
#define runloop_check_cheevos() (settings->bools.cheevos_enable && cheevos_loaded && (!cheats_are_enabled && !cheats_were_enabled))
|
||||
|
||||
@ -1009,7 +1011,12 @@ static enum runloop_state runloop_check_state(
|
||||
}
|
||||
|
||||
if (runloop_cmd_triggered(trigger_input, RARCH_MOVIE_RECORD_TOGGLE))
|
||||
bsv_movie_check();
|
||||
{
|
||||
if (bsv_movie_check())
|
||||
runloop_set(RUNLOOP_ACTION_BSV_MOVIE);
|
||||
else
|
||||
runloop_unset(RUNLOOP_ACTION_BSV_MOVIE);
|
||||
}
|
||||
|
||||
if (runloop_cmd_triggered(trigger_input, RARCH_SHADER_NEXT) ||
|
||||
runloop_cmd_triggered(trigger_input, RARCH_SHADER_PREV))
|
||||
@ -1046,6 +1053,9 @@ void runloop_set(enum runloop_action action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case RUNLOOP_ACTION_BSV_MOVIE:
|
||||
runloop_bsv_movie = true;
|
||||
break;
|
||||
case RUNLOOP_ACTION_AUTOSAVE:
|
||||
runloop_autosave = true;
|
||||
break;
|
||||
@ -1058,6 +1068,9 @@ void runloop_unset(enum runloop_action action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case RUNLOOP_ACTION_BSV_MOVIE:
|
||||
runloop_bsv_movie = false;
|
||||
break;
|
||||
case RUNLOOP_ACTION_AUTOSAVE:
|
||||
runloop_autosave = false;
|
||||
break;
|
||||
@ -1162,7 +1175,8 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
if (runloop_autosave)
|
||||
autosave_lock();
|
||||
|
||||
bsv_movie_set_frame_start();
|
||||
if (runloop_bsv_movie)
|
||||
bsv_movie_set_frame_start();
|
||||
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_POLL, NULL);
|
||||
|
||||
@ -1203,7 +1217,8 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
input_pop_analog_dpad(auto_binds);
|
||||
}
|
||||
|
||||
bsv_movie_set_frame_end();
|
||||
if (runloop_bsv_movie)
|
||||
bsv_movie_set_frame_end();
|
||||
|
||||
if (runloop_autosave)
|
||||
autosave_unlock();
|
||||
|
Loading…
Reference in New Issue
Block a user