forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrunloop.h
369 lines (288 loc) · 8.12 KB
/
runloop.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/* 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
#include <queues/message_queue.h>
#include <setjmp.h>
#include "libretro.h"
#include "core_info.h"
#include "core_options.h"
#include "driver.h"
#include "rewind.h"
#include "autosave.h"
#include "movie.h"
#include "cheats.h"
#ifdef __cplusplus
extern "C" {
#endif
/* All libretro runloop-related globals go here. */
typedef struct runloop
{
/* Lifecycle state checks. */
bool is_paused;
bool is_idle;
bool ui_companion_is_on_foreground;
bool is_slowmotion;
struct
{
struct
{
unsigned max;
} video;
struct
{
retro_time_t minimum_time;
retro_time_t last_time;
} limit;
} frames;
msg_queue_t *msg_queue;
} runloop_t;
typedef struct rarch_resolution
{
unsigned idx;
unsigned id;
} rarch_resolution_t;
/* All run-time- / command line flag-related globals go here. */
typedef struct global
{
bool verbosity;
bool perfcnt_enable;
bool force_fullscreen;
bool core_shutdown_initiated;
struct string_list *temporary_content;
core_info_list_t *core_info;
core_info_t *core_info_current;
uint32_t content_crc;
char gb_rom_path[PATH_MAX_LENGTH];
char bsx_rom_path[PATH_MAX_LENGTH];
char sufami_rom_path[2][PATH_MAX_LENGTH];
bool has_set_input_descriptors;
bool has_set_save_path;
bool has_set_state_path;
bool has_set_libretro_device[MAX_USERS];
bool has_set_libretro;
bool has_set_libretro_directory;
bool has_set_verbosity;
bool has_set_netplay_mode;
bool has_set_username;
bool has_set_netplay_ip_address;
bool has_set_netplay_delay_frames;
bool has_set_netplay_ip_port;
bool has_set_ups_pref;
bool has_set_bps_pref;
bool has_set_ips_pref;
bool overrides_active;
/* Config associated with global "default" config. */
char config_path[PATH_MAX_LENGTH];
char append_config_path[PATH_MAX_LENGTH];
char input_config_path[PATH_MAX_LENGTH];
#ifdef HAVE_FILE_LOGGER
char default_log_file[PATH_MAX_LENGTH];
#endif
char basename[PATH_MAX_LENGTH];
char fullpath[PATH_MAX_LENGTH];
/* 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;
char savefile_name[PATH_MAX_LENGTH];
char savestate_name[PATH_MAX_LENGTH];
char cheatfile_name[PATH_MAX_LENGTH];
/* Used on reentrancy to use a savestate dir. */
char savefile_dir[PATH_MAX_LENGTH];
char savestate_dir[PATH_MAX_LENGTH];
#ifdef HAVE_OVERLAY
char overlay_dir[PATH_MAX_LENGTH];
char osk_overlay_dir[PATH_MAX_LENGTH];
#endif
bool block_patch;
bool ups_pref;
bool bps_pref;
bool ips_pref;
char ups_name[PATH_MAX_LENGTH];
char bps_name[PATH_MAX_LENGTH];
char ips_name[PATH_MAX_LENGTH];
struct
{
unsigned windowed_scale;
} pending;
struct
{
struct retro_system_info info;
unsigned rotation;
bool shutdown;
unsigned performance_level;
bool block_extract;
bool force_nonblock;
bool no_content;
const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY];
char valid_extensions[PATH_MAX_LENGTH];
retro_keyboard_event_t key_event;
struct retro_disk_control_callback disk_control;
struct retro_camera_callback camera_callback;
struct retro_location_callback location_callback;
struct retro_frame_time_callback frame_time;
retro_usec_t frame_time_last;
core_option_manager_t *core_options;
struct retro_subsystem_info *special;
unsigned num_special;
struct retro_controller_info *ports;
unsigned num_ports;
} system;
#ifdef HAVE_MENU
struct
{
struct retro_system_info info;
bool bind_mode_keyboard;
} menu;
#endif
bool exec;
struct
{
/* Rewind support. */
state_manager_t *state;
size_t size;
bool frame_is_reverse;
} rewind;
struct
{
/* Movie playback/recording support. */
bsv_movie_t *movie;
char movie_path[PATH_MAX_LENGTH];
bool movie_playback;
bool eof_exit;
/* Immediate playback/recording. */
char movie_start_path[PATH_MAX_LENGTH];
bool movie_start_recording;
bool movie_start_playback;
bool movie_end;
} bsv;
bool sram_load_disable;
bool sram_save_disable;
bool use_sram;
/* Turbo support. */
bool turbo_frame_enable[MAX_USERS];
uint16_t turbo_enable[MAX_USERS];
unsigned turbo_count;
/* Autosave support. */
autosave_t **autosave;
unsigned num_autosave;
#ifdef HAVE_NETPLAY
/* Netplay. */
char netplay_server[PATH_MAX_LENGTH];
bool netplay_enable;
bool netplay_is_client;
bool netplay_is_spectate;
unsigned netplay_sync_frames;
unsigned netplay_port;
#endif
/* Recording. */
struct
{
char path[PATH_MAX_LENGTH];
char config[PATH_MAX_LENGTH];
bool enable;
unsigned width;
unsigned height;
uint8_t *gpu_buffer;
size_t gpu_width;
size_t gpu_height;
char output_dir[PATH_MAX_LENGTH];
char config_dir[PATH_MAX_LENGTH];
bool use_output_dir;
} record;
char title_buf[64];
struct
{
struct string_list *list;
size_t ptr;
} shader_dir;
struct
{
struct string_list *list;
size_t ptr;
} filter_dir;
cheat_manager_t *cheat;
bool block_config_read;
/* 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;
} resolutions;
unsigned gamma_correction;
unsigned char flicker_filter_index;
unsigned char soft_filter_index;
bool pal_enable;
bool pal60_enable;
} screen;
struct
{
unsigned mode;
bool system_bgm_enable;
} sound;
bool flickerfilter_enable;
bool softfilter_enable;
} console;
uint64_t lifecycle_state;
/* If this is non-NULL. RARCH_LOG and friends
* will write to this file. */
FILE *log_file;
bool main_is_init;
bool content_is_init;
bool error_in_init;
char error_string[PATH_MAX_LENGTH];
jmp_buf error_sjlj_context;
bool libretro_no_content;
bool libretro_dummy;
/* Config file associated with per-core configs. */
char core_specific_config_path[PATH_MAX_LENGTH];
retro_keyboard_event_t frontend_key_event;
} global_t;
runloop_t *rarch_main_get_ptr(void);
global_t *global_get_ptr(void);
/**
* rarch_main_iterate:
*
* Run Libretro core in RetroArch for one frame.
*
* 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.
**/
int rarch_main_iterate(void);
void rarch_main_msg_queue_push(const char *msg, unsigned prio,
unsigned duration, bool flush);
const char *rarch_main_msg_queue_pull(void);
void rarch_main_msg_queue_free(void);
void rarch_main_msg_queue_init(void);
void rarch_main_clear_state(void);
bool rarch_main_verbosity(void);
FILE *rarch_main_log_file(void);
bool rarch_main_is_idle(void);
void rarch_main_state_free(void);
void rarch_main_global_free(void);
#ifdef __cplusplus
}
#endif
#endif