2015-01-09 17:40:33 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2015 - 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 __RETROARCH_RUNLOOP_H
|
|
|
|
#define __RETROARCH_RUNLOOP_H
|
|
|
|
|
2015-03-21 00:59:47 +00:00
|
|
|
#include <setjmp.h>
|
2015-11-27 22:39:43 +00:00
|
|
|
|
2015-11-09 00:53:17 +00:00
|
|
|
#include <rthreads/async_job.h>
|
2015-11-27 22:39:43 +00:00
|
|
|
|
2015-03-15 01:47:23 +00:00
|
|
|
#include "libretro.h"
|
2015-03-21 00:59:47 +00:00
|
|
|
#include "core_info.h"
|
|
|
|
#include "core_options.h"
|
|
|
|
#include "driver.h"
|
2015-06-20 21:42:30 +00:00
|
|
|
#include "dynamic.h"
|
2015-06-25 10:22:38 +00:00
|
|
|
#include "system.h"
|
2015-08-05 12:36:35 +00:00
|
|
|
#include "performance.h"
|
2015-03-15 01:47:23 +00:00
|
|
|
|
2015-01-09 17:40:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-11-30 20:42:59 +00:00
|
|
|
enum runloop_ctl_state
|
2015-09-26 10:57:52 +00:00
|
|
|
{
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_IS_IDLE = 0,
|
2015-12-01 02:46:56 +00:00
|
|
|
RUNLOOP_CTL_GET_WINDOWED_SCALE,
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_SET_WINDOWED_SCALE,
|
|
|
|
RUNLOOP_CTL_SET_IDLE,
|
|
|
|
RUNLOOP_CTL_CHECK_IDLE_STATE,
|
|
|
|
RUNLOOP_CTL_GET_CONTENT_PATH,
|
|
|
|
RUNLOOP_CTL_SET_CONTENT_PATH,
|
|
|
|
RUNLOOP_CTL_CLEAR_CONTENT_PATH,
|
|
|
|
RUNLOOP_CTL_SET_LIBRETRO_PATH,
|
|
|
|
RUNLOOP_CTL_IS_SLOWMOTION,
|
|
|
|
RUNLOOP_CTL_SET_SLOWMOTION,
|
|
|
|
RUNLOOP_CTL_IS_PAUSED,
|
|
|
|
RUNLOOP_CTL_SET_PAUSED,
|
|
|
|
RUNLOOP_CTL_SET_MAX_FRAMES,
|
|
|
|
RUNLOOP_CTL_SET_FRAME_LIMIT_LAST_TIME,
|
|
|
|
RUNLOOP_CTL_CLEAR_STATE,
|
|
|
|
RUNLOOP_CTL_STATE_FREE,
|
|
|
|
RUNLOOP_CTL_GLOBAL_FREE,
|
|
|
|
RUNLOOP_CTL_SET_CORE_SHUTDOWN,
|
|
|
|
RUNLOOP_CTL_SET_EXEC,
|
2015-11-30 20:56:35 +00:00
|
|
|
RUNLOOP_CTL_SET_PERFCNT_ENABLE,
|
|
|
|
RUNLOOP_CTL_UNSET_PERFCNT_ENABLE,
|
|
|
|
RUNLOOP_CTL_IS_PERFCNT_ENABLE,
|
2015-11-30 22:29:46 +00:00
|
|
|
RUNLOOP_CTL_DATA_DEINIT,
|
2015-09-26 13:24:05 +00:00
|
|
|
/* Checks for state changes in this frame. */
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_CHECK_STATE,
|
|
|
|
RUNLOOP_CTL_CHECK_MOVIE,
|
2015-09-26 12:57:46 +00:00
|
|
|
/* Checks if movie is being played. */
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_CHECK_MOVIE_PLAYBACK,
|
|
|
|
RUNLOOP_CTL_CHECK_MOVIE_INIT,
|
2015-09-26 12:57:46 +00:00
|
|
|
/* Checks if movie is being recorded. */
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_CHECK_MOVIE_RECORD,
|
2015-09-26 12:57:46 +00:00
|
|
|
/* Checks if slowmotion toggle/hold was being pressed and/or held. */
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_CHECK_SLOWMOTION,
|
|
|
|
RUNLOOP_CTL_CHECK_PAUSE_STATE,
|
2015-11-28 23:15:51 +00:00
|
|
|
/* Initializes message queue. */
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_MSG_QUEUE_INIT,
|
2015-11-28 23:15:51 +00:00
|
|
|
/* Deinitializes message queue. */
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_MSG_QUEUE_DEINIT,
|
2015-11-28 23:29:41 +00:00
|
|
|
/* Initializes dummy core. */
|
2015-11-30 20:35:50 +00:00
|
|
|
RUNLOOP_CTL_PREPARE_DUMMY
|
2015-09-26 10:57:52 +00:00
|
|
|
};
|
|
|
|
|
2015-11-18 02:25:23 +00:00
|
|
|
typedef struct rarch_dir_list
|
|
|
|
{
|
|
|
|
struct string_list *list;
|
|
|
|
size_t ptr;
|
|
|
|
} rarch_dir_list_t;
|
|
|
|
|
|
|
|
typedef struct rarch_dir
|
|
|
|
{
|
|
|
|
/* Used on reentrancy to use a savestate dir. */
|
|
|
|
char savefile[PATH_MAX_LENGTH];
|
|
|
|
char savestate[PATH_MAX_LENGTH];
|
|
|
|
char systemdir[PATH_MAX_LENGTH];
|
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
char osk_overlay[PATH_MAX_LENGTH];
|
|
|
|
#endif
|
|
|
|
rarch_dir_list_t filter_dir;
|
|
|
|
} rarch_dir_t;
|
|
|
|
|
|
|
|
typedef struct rarch_path
|
|
|
|
{
|
|
|
|
char gb_rom[PATH_MAX_LENGTH];
|
|
|
|
char bsx_rom[PATH_MAX_LENGTH];
|
|
|
|
char sufami_rom[2][PATH_MAX_LENGTH];
|
|
|
|
/* Config associated with global "default" config. */
|
|
|
|
char config[PATH_MAX_LENGTH];
|
|
|
|
char append_config[PATH_MAX_LENGTH];
|
|
|
|
char input_config[PATH_MAX_LENGTH];
|
|
|
|
#ifdef HAVE_FILE_LOGGER
|
|
|
|
char default_log[PATH_MAX_LENGTH];
|
|
|
|
#endif
|
|
|
|
/* Config file associated with per-core configs. */
|
|
|
|
char core_specific_config[PATH_MAX_LENGTH];
|
|
|
|
} rarch_path_t;
|
|
|
|
|
2015-08-03 18:15:46 +00:00
|
|
|
typedef struct rarch_resolution
|
|
|
|
{
|
|
|
|
unsigned idx;
|
|
|
|
unsigned id;
|
|
|
|
} rarch_resolution_t;
|
2015-03-15 01:47:23 +00:00
|
|
|
|
2015-08-03 18:15:46 +00:00
|
|
|
/* All run-time- / command line flag-related globals go here. */
|
|
|
|
|
|
|
|
typedef struct global
|
2015-03-15 01:47:23 +00:00
|
|
|
{
|
2015-07-27 15:18:10 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
core_info_list_t *list;
|
|
|
|
core_info_t *current;
|
|
|
|
} core_info;
|
2015-03-21 00:59:47 +00:00
|
|
|
|
|
|
|
uint32_t content_crc;
|
|
|
|
|
2015-11-18 02:25:23 +00:00
|
|
|
rarch_path_t path;
|
2015-07-27 15:18:10 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool input_descriptors;
|
|
|
|
bool save_path;
|
|
|
|
bool state_path;
|
|
|
|
bool libretro_device[MAX_USERS];
|
|
|
|
bool libretro;
|
|
|
|
bool libretro_directory;
|
|
|
|
bool verbosity;
|
|
|
|
|
|
|
|
bool netplay_mode;
|
|
|
|
bool username;
|
|
|
|
bool netplay_ip_address;
|
|
|
|
bool netplay_delay_frames;
|
|
|
|
bool netplay_ip_port;
|
|
|
|
|
|
|
|
bool ups_pref;
|
|
|
|
bool bps_pref;
|
|
|
|
bool ips_pref;
|
|
|
|
} has_set;
|
|
|
|
|
2015-03-21 00:59:47 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
bool overrides_active;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char base[PATH_MAX_LENGTH];
|
|
|
|
char savefile[PATH_MAX_LENGTH];
|
|
|
|
char savestate[PATH_MAX_LENGTH];
|
|
|
|
char cheatfile[PATH_MAX_LENGTH];
|
|
|
|
char ups[PATH_MAX_LENGTH];
|
|
|
|
char bps[PATH_MAX_LENGTH];
|
|
|
|
char ips[PATH_MAX_LENGTH];
|
|
|
|
} name;
|
2015-03-21 00:59:47 +00:00
|
|
|
|
|
|
|
/* A list of save types and associated paths for all content. */
|
|
|
|
struct string_list *savefiles;
|
|
|
|
|
|
|
|
/* For --subsystem content. */
|
|
|
|
char subsystem[PATH_MAX_LENGTH];
|
|
|
|
struct string_list *subsystem_fullpaths;
|
|
|
|
|
2015-11-18 02:25:23 +00:00
|
|
|
rarch_dir_t dir;
|
2015-03-21 00:59:47 +00:00
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool block_patch;
|
|
|
|
bool ups_pref;
|
|
|
|
bool bps_pref;
|
|
|
|
bool ips_pref;
|
|
|
|
} patch;
|
2015-03-21 00:59:47 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct retro_system_info info;
|
|
|
|
} menu;
|
|
|
|
#endif
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool load_disable;
|
|
|
|
bool save_disable;
|
|
|
|
bool use;
|
|
|
|
} sram;
|
2015-03-21 00:59:47 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_NETPLAY
|
|
|
|
/* Netplay. */
|
2015-07-27 15:18:10 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
char server[PATH_MAX_LENGTH];
|
|
|
|
bool enable;
|
|
|
|
bool is_client;
|
|
|
|
bool is_spectate;
|
|
|
|
unsigned sync_frames;
|
|
|
|
unsigned port;
|
|
|
|
} netplay;
|
2015-03-21 00:59:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Recording. */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char path[PATH_MAX_LENGTH];
|
|
|
|
char config[PATH_MAX_LENGTH];
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
|
|
|
|
uint8_t *gpu_buffer;
|
|
|
|
size_t gpu_width;
|
|
|
|
size_t gpu_height;
|
2015-04-15 10:42:36 +00:00
|
|
|
char output_dir[PATH_MAX_LENGTH];
|
|
|
|
char config_dir[PATH_MAX_LENGTH];
|
|
|
|
bool use_output_dir;
|
2015-03-21 00:59:47 +00:00
|
|
|
} record;
|
|
|
|
|
|
|
|
/* Settings and/or global state that is specific to
|
|
|
|
* a console-style implementation. */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
rarch_resolution_t current;
|
|
|
|
rarch_resolution_t initial;
|
|
|
|
uint32_t *list;
|
|
|
|
unsigned count;
|
|
|
|
bool check;
|
2015-07-06 05:29:51 +00:00
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
2015-03-21 00:59:47 +00:00
|
|
|
} resolutions;
|
|
|
|
|
|
|
|
unsigned gamma_correction;
|
|
|
|
unsigned char flicker_filter_index;
|
|
|
|
unsigned char soft_filter_index;
|
|
|
|
bool pal_enable;
|
|
|
|
bool pal60_enable;
|
|
|
|
} screen;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool system_bgm_enable;
|
|
|
|
} sound;
|
|
|
|
|
|
|
|
bool flickerfilter_enable;
|
|
|
|
bool softfilter_enable;
|
|
|
|
} console;
|
2015-11-09 00:53:17 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
async_job_t *async_jobs;
|
|
|
|
#endif
|
|
|
|
|
2015-07-27 15:18:10 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool main;
|
|
|
|
bool content;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool no_content;
|
|
|
|
enum rarch_core_type type;
|
|
|
|
} core;
|
|
|
|
} inited;
|
2015-03-21 00:59:47 +00:00
|
|
|
|
|
|
|
retro_keyboard_event_t frontend_key_event;
|
|
|
|
} global_t;
|
|
|
|
|
|
|
|
global_t *global_get_ptr(void);
|
|
|
|
|
2015-01-09 17:40:33 +00:00
|
|
|
/**
|
|
|
|
* rarch_main_iterate:
|
|
|
|
*
|
2015-01-09 23:59:05 +00:00
|
|
|
* Run Libretro core in RetroArch for one frame.
|
2015-01-09 17:40:33 +00:00
|
|
|
*
|
2015-01-09 23:59:05 +00:00
|
|
|
* Returns: 0 on successful run, 1 if we have to wait until button input in order
|
|
|
|
* to wake up the loop, -1 if we forcibly quit out of the RetroArch iteration loop.
|
2015-01-09 17:40:33 +00:00
|
|
|
**/
|
2015-11-28 02:05:37 +00:00
|
|
|
int rarch_main_iterate(unsigned *sleep_ms);
|
2015-01-09 17:40:33 +00:00
|
|
|
|
2015-03-15 01:47:23 +00:00
|
|
|
void rarch_main_msg_queue_push(const char *msg, unsigned prio,
|
|
|
|
unsigned duration, bool flush);
|
|
|
|
|
2015-06-30 23:49:32 +00:00
|
|
|
void rarch_main_msg_queue_push_new(uint32_t hash, unsigned prio,
|
|
|
|
unsigned duration, bool flush);
|
|
|
|
|
2015-03-15 01:47:23 +00:00
|
|
|
const char *rarch_main_msg_queue_pull(void);
|
|
|
|
|
2015-11-30 20:56:35 +00:00
|
|
|
bool *runloop_perfcnt_enabled(void);
|
|
|
|
|
2015-12-01 02:55:31 +00:00
|
|
|
void shader_dir_free(void);
|
|
|
|
|
|
|
|
bool shader_dir_init(void);
|
|
|
|
|
2015-11-30 20:42:59 +00:00
|
|
|
bool runloop_ctl(enum runloop_ctl_state state, void *data);
|
2015-08-05 11:06:44 +00:00
|
|
|
|
2015-11-30 14:35:57 +00:00
|
|
|
typedef int (*transfer_cb_t)(void *data, size_t len);
|
|
|
|
|
|
|
|
void rarch_main_data_iterate(void);
|
|
|
|
|
2015-01-09 17:40:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|