2021-09-21 16:38:53 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2021 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RUNLOOP_H
|
|
|
|
#define __RUNLOOP_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <boolean.h>
|
|
|
|
#include <retro_inline.h>
|
|
|
|
#include <retro_common_api.h>
|
2021-10-14 19:15:11 +00:00
|
|
|
#include <dynamic/dylib.h>
|
2021-09-21 16:38:53 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
#include <rthreads/rthreads.h>
|
|
|
|
#endif
|
|
|
|
|
2021-10-14 19:15:11 +00:00
|
|
|
#include "dynamic.h"
|
2021-09-21 16:38:53 +00:00
|
|
|
#include "core_option_manager.h"
|
|
|
|
|
2021-10-11 16:01:37 +00:00
|
|
|
enum runloop_state_enum
|
2021-09-21 16:38:53 +00:00
|
|
|
{
|
|
|
|
RUNLOOP_STATE_ITERATE = 0,
|
|
|
|
RUNLOOP_STATE_POLLED_AND_SLEEP,
|
|
|
|
RUNLOOP_STATE_MENU_ITERATE,
|
|
|
|
RUNLOOP_STATE_END,
|
|
|
|
RUNLOOP_STATE_QUIT
|
|
|
|
};
|
|
|
|
|
2021-10-14 19:22:07 +00:00
|
|
|
enum poll_type_override_t
|
|
|
|
{
|
|
|
|
POLL_TYPE_OVERRIDE_DONTCARE = 0,
|
|
|
|
POLL_TYPE_OVERRIDE_EARLY,
|
|
|
|
POLL_TYPE_OVERRIDE_NORMAL,
|
|
|
|
POLL_TYPE_OVERRIDE_LATE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-09-21 16:38:53 +00:00
|
|
|
typedef struct runloop_ctx_msg_info
|
|
|
|
{
|
|
|
|
const char *msg;
|
|
|
|
unsigned prio;
|
|
|
|
unsigned duration;
|
|
|
|
bool flush;
|
|
|
|
} runloop_ctx_msg_info_t;
|
|
|
|
|
|
|
|
/* Contains the current retro_fastforwarding_override
|
|
|
|
* parameters along with any pending updates triggered
|
|
|
|
* by RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE */
|
|
|
|
typedef struct fastmotion_overrides
|
|
|
|
{
|
|
|
|
struct retro_fastforwarding_override current;
|
|
|
|
struct retro_fastforwarding_override next;
|
|
|
|
bool pending;
|
|
|
|
} fastmotion_overrides_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned priority;
|
|
|
|
float duration;
|
|
|
|
char str[128];
|
|
|
|
bool set;
|
|
|
|
} runloop_core_status_msg_t;
|
|
|
|
|
|
|
|
/* Contains all callbacks associated with
|
|
|
|
* core options.
|
|
|
|
* > At present there is only a single
|
|
|
|
* callback, 'update_display' - but we
|
|
|
|
* may wish to add more in the future
|
|
|
|
* (e.g. for directly informing a core of
|
|
|
|
* core option value changes, or getting/
|
|
|
|
* setting extended/non-standard option
|
|
|
|
* value data types) */
|
|
|
|
typedef struct core_options_callbacks
|
|
|
|
{
|
|
|
|
retro_core_options_update_display_callback_t update_display;
|
|
|
|
} core_options_callbacks_t;
|
|
|
|
|
2021-10-14 19:15:11 +00:00
|
|
|
#ifdef HAVE_RUNAHEAD
|
|
|
|
typedef bool(*runahead_load_state_function)(const void*, size_t);
|
|
|
|
#endif
|
|
|
|
|
2021-09-21 16:38:53 +00:00
|
|
|
struct runloop
|
|
|
|
{
|
2021-10-14 20:02:09 +00:00
|
|
|
retro_time_t core_runtime_last;
|
|
|
|
retro_time_t core_runtime_usec;
|
2021-10-13 15:37:24 +00:00
|
|
|
retro_time_t frame_limit_minimum_time;
|
|
|
|
retro_time_t frame_limit_last_time;
|
2021-10-14 19:15:11 +00:00
|
|
|
retro_usec_t frame_time_last; /* int64_t alignment */
|
2021-09-21 16:38:53 +00:00
|
|
|
|
2021-10-14 19:15:11 +00:00
|
|
|
struct retro_core_t current_core; /* uint64_t alignment */
|
|
|
|
#if defined(HAVE_RUNAHEAD)
|
|
|
|
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
|
|
|
|
struct retro_core_t secondary_core; /* uint64_t alignment */
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2021-10-14 20:02:09 +00:00
|
|
|
bool *load_no_content_hook;
|
2021-10-15 14:13:21 +00:00
|
|
|
struct string_list *subsystem_fullpaths;
|
2021-10-14 19:15:11 +00:00
|
|
|
struct retro_callbacks retro_ctx; /* ptr alignment */
|
|
|
|
msg_queue_t msg_queue; /* ptr alignment */
|
|
|
|
retro_input_state_t input_state_callback_original; /* ptr alignment */
|
|
|
|
#ifdef HAVE_RUNAHEAD
|
|
|
|
function_t retro_reset_callback_original; /* ptr alignment */
|
|
|
|
function_t original_retro_deinit; /* ptr alignment */
|
|
|
|
function_t original_retro_unload; /* ptr alignment */
|
|
|
|
runahead_load_state_function
|
|
|
|
retro_unserialize_callback_original; /* ptr alignment */
|
|
|
|
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
|
|
|
|
struct retro_callbacks secondary_callbacks; /* ptr alignment */
|
|
|
|
#endif
|
|
|
|
#endif
|
2021-09-21 16:38:53 +00:00
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
slock_t *msg_queue_lock;
|
|
|
|
#endif
|
|
|
|
size_t msg_queue_size;
|
|
|
|
|
2021-10-15 14:13:21 +00:00
|
|
|
struct retro_subsystem_rom_info
|
|
|
|
subsystem_data_roms[SUBSYSTEM_MAX_SUBSYSTEMS]
|
|
|
|
[SUBSYSTEM_MAX_SUBSYSTEM_ROMS]; /* ptr alignment */
|
2021-09-21 16:38:53 +00:00
|
|
|
core_option_manager_t *core_options;
|
2021-10-15 14:13:21 +00:00
|
|
|
core_options_callbacks_t core_options_callback;/* ptr alignment */
|
2021-09-21 16:38:53 +00:00
|
|
|
|
|
|
|
retro_keyboard_event_t key_event; /* ptr alignment */
|
|
|
|
retro_keyboard_event_t frontend_key_event; /* ptr alignment */
|
|
|
|
|
|
|
|
rarch_system_info_t system; /* ptr alignment */
|
|
|
|
struct retro_frame_time_callback frame_time; /* ptr alignment */
|
|
|
|
struct retro_audio_buffer_status_callback audio_buffer_status; /* ptr alignment */
|
|
|
|
unsigned pending_windowed_scale;
|
|
|
|
unsigned max_frames;
|
|
|
|
unsigned audio_latency;
|
2021-10-14 20:18:14 +00:00
|
|
|
unsigned fastforward_after_frames;
|
2021-09-21 16:38:53 +00:00
|
|
|
|
|
|
|
fastmotion_overrides_t fastmotion_override; /* float alignment */
|
2021-10-14 20:18:14 +00:00
|
|
|
enum rarch_core_type current_core_type;
|
|
|
|
enum rarch_core_type explicit_current_core_type;
|
2021-10-14 19:22:07 +00:00
|
|
|
enum poll_type_override_t core_poll_type_override;
|
2021-09-21 16:38:53 +00:00
|
|
|
|
2021-10-15 14:13:21 +00:00
|
|
|
char runtime_content_path_basename[8192];
|
|
|
|
char current_library_name[256];
|
|
|
|
char current_library_version[256];
|
|
|
|
char current_valid_extensions[256];
|
|
|
|
char subsystem_path[256];
|
|
|
|
#ifdef HAVE_SCREENSHOTS
|
|
|
|
char max_frames_screenshot_path[PATH_MAX_LENGTH];
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
|
|
|
char runtime_shader_preset_path[PATH_MAX_LENGTH];
|
|
|
|
#endif
|
|
|
|
char runtime_content_path[PATH_MAX_LENGTH];
|
|
|
|
char runtime_core_path[PATH_MAX_LENGTH];
|
|
|
|
|
2021-09-21 16:38:53 +00:00
|
|
|
bool missing_bios;
|
|
|
|
bool force_nonblock;
|
|
|
|
bool paused;
|
|
|
|
bool idle;
|
|
|
|
bool focused;
|
|
|
|
bool slowmotion;
|
|
|
|
bool fastmotion;
|
|
|
|
bool shutdown_initiated;
|
|
|
|
bool core_shutdown_initiated;
|
|
|
|
bool core_running;
|
|
|
|
bool perfcnt_enable;
|
|
|
|
bool game_options_active;
|
|
|
|
bool folder_options_active;
|
|
|
|
bool autosave;
|
|
|
|
#ifdef HAVE_CONFIGFILE
|
|
|
|
bool overrides_active;
|
|
|
|
#endif
|
|
|
|
bool remaps_core_active;
|
|
|
|
bool remaps_game_active;
|
|
|
|
bool remaps_content_dir_active;
|
|
|
|
#ifdef HAVE_SCREENSHOTS
|
|
|
|
bool max_frames_screenshot;
|
|
|
|
#endif
|
2021-09-28 11:48:49 +00:00
|
|
|
#ifdef HAVE_RUNAHEAD
|
|
|
|
bool has_variable_update;
|
2021-10-14 19:15:11 +00:00
|
|
|
bool input_is_dirty;
|
2021-09-28 11:48:49 +00:00
|
|
|
#endif
|
2021-10-14 19:47:35 +00:00
|
|
|
bool is_sram_load_disabled;
|
|
|
|
bool is_sram_save_disabled;
|
|
|
|
bool use_sram;
|
|
|
|
bool ignore_environment_cb;
|
|
|
|
bool core_set_shared_context;
|
2021-10-14 20:18:14 +00:00
|
|
|
bool has_set_core;
|
2021-09-21 16:38:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct runloop runloop_state_t;
|
|
|
|
|
|
|
|
/* Time to exit out of the main loop?
|
|
|
|
* Reasons for exiting:
|
|
|
|
* a) Shutdown environment callback was invoked.
|
|
|
|
* b) Quit key was pressed.
|
|
|
|
* c) Frame count exceeds or equals maximum amount of frames to run.
|
|
|
|
* d) Video driver no longer alive.
|
|
|
|
* e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better)
|
|
|
|
*/
|
|
|
|
#define RUNLOOP_TIME_TO_EXIT(quit_key_pressed) (runloop_state.shutdown_initiated || quit_key_pressed || !is_alive BSV_MOVIE_IS_EOF(p_rarch) || ((runloop_state.max_frames != 0) && (frame_count >= runloop_state.max_frames)) || runloop_exec)
|
|
|
|
|
|
|
|
RETRO_BEGIN_DECLS
|
|
|
|
|
2021-10-15 12:32:07 +00:00
|
|
|
runloop_state_t *runloop_state_get_ptr(void);
|
|
|
|
|
2021-09-21 16:38:53 +00:00
|
|
|
RETRO_END_DECLS
|
|
|
|
|
|
|
|
#endif
|