Simplify runloop

This commit is contained in:
twinaphex 2019-01-14 04:39:58 +01:00
parent fab4834b82
commit 7cb84245b7
3 changed files with 21 additions and 23 deletions

21
movie.c
View File

@ -33,22 +33,8 @@
#include "command.h"
#include "file_path_special.h"
struct bsv_state
{
bool movie_start_recording;
bool movie_start_playback;
bool movie_playback;
bool eof_exit;
bool movie_end;
/* Movie playback/recording support. */
char movie_path[PATH_MAX_LENGTH];
/* Immediate playback/recording. */
char movie_start_path[PATH_MAX_LENGTH];
};
bsv_movie_t *bsv_movie_state_handle = NULL;
static struct bsv_state bsv_movie_state;
struct bsv_state bsv_movie_state;
static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path)
{
@ -370,11 +356,6 @@ bool bsv_movie_is_playback_off(void)
return bsv_movie_state_handle && !bsv_movie_state.movie_playback;
}
bool bsv_movie_is_end_of_file(void)
{
return bsv_movie_state.movie_end && bsv_movie_state.eof_exit;
}
bool bsv_movie_ctl(enum bsv_ctl_state state, void *data)
{
switch (state)

19
movie.h
View File

@ -23,6 +23,7 @@
#include <boolean.h>
#include <retro_common_api.h>
#include <streams/interface_stream.h>
#include <retro_miscellaneous.h>
RETRO_BEGIN_DECLS
@ -57,6 +58,20 @@ enum bsv_ctl_state
BSV_MOVIE_CTL_UNSET_END
};
struct bsv_state
{
bool movie_start_recording;
bool movie_start_playback;
bool movie_playback;
bool eof_exit;
bool movie_end;
/* Movie playback/recording support. */
char movie_path[PATH_MAX_LENGTH];
/* Immediate playback/recording. */
char movie_start_path[PATH_MAX_LENGTH];
};
struct bsv_movie
{
intfstream_t *file;
@ -91,8 +106,6 @@ void bsv_movie_set_start_path(const char *path);
bool bsv_movie_get_input(int16_t *bsv_data);
bool bsv_movie_is_end_of_file(void);
bool bsv_movie_ctl(enum bsv_ctl_state state, void *data);
bool bsv_movie_check(void);
@ -101,6 +114,8 @@ bool bsv_movie_init_handle(const char *path, enum rarch_movie_type type);
extern bsv_movie_t *bsv_movie_state_handle;
extern struct bsv_state bsv_movie_state;
RETRO_END_DECLS
#endif

View File

@ -2461,6 +2461,8 @@ bool runloop_msg_queue_pull(const char **ret)
return true;
}
#define bsv_movie_is_end_of_file() (bsv_movie_state.movie_end && bsv_movie_state.eof_exit)
/* Time to exit out of the main loop?
* Reasons for exiting:
* a) Shutdown environment callback was invoked.
@ -2469,7 +2471,7 @@ bool runloop_msg_queue_pull(const char **ret)
* 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) (rarch_ctl(RARCH_CTL_IS_SHUTDOWN, NULL) || quit_key_pressed || !is_alive || bsv_movie_is_end_of_file() || ((runloop_max_frames != 0) && (frame_count >= runloop_max_frames)) || runloop_exec)
#define time_to_exit(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !is_alive || bsv_movie_is_end_of_file() || ((runloop_max_frames != 0) && (frame_count >= runloop_max_frames)) || runloop_exec)
#define runloop_check_cheevos() (settings->bools.cheevos_enable && cheevos_loaded && (!cheats_are_enabled && !cheats_were_enabled))