1 /*  RetroArch - A frontend for libretro.
2  *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3  *  Copyright (C) 2011-2016 - Daniel De Matteis
4  *  Copyright (C) 2012-2015 - Michael Lelli
5  *
6  *  RetroArch is free software: you can redistribute it and/or modify it under the terms
7  *  of the GNU General Public License as published by the Free Software Found-
8  *  ation, either version 3 of the License, or (at your option) any later version.
9  *
10  *  RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  *  PURPOSE.  See the GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along with RetroArch.
15  *  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef _LIBRETRO_CORE_IMPL_H
19 #define _LIBRETRO_CORE_IMPL_H
20 
21 #include <boolean.h>
22 #include <libretro.h>
23 
24 #include <retro_common_api.h>
25 
26 #include "core_type.h"
27 #include "input/input_defines.h"
28 #include "disk_control_interface.h"
29 
30 RETRO_BEGIN_DECLS
31 
32 enum
33 {
34    /* Polling is performed before
35     * call to retro_run. */
36    POLL_TYPE_EARLY = 0,
37 
38    /* Polling is performed when requested. */
39    POLL_TYPE_NORMAL,
40 
41    /* Polling is performed on first call to
42     * retro_input_state per frame. */
43    POLL_TYPE_LATE
44 };
45 
46 typedef struct rarch_memory_descriptor
47 {
48    struct retro_memory_descriptor core;        /* uint64_t alignment */
49    size_t disconnect_mask;
50 } rarch_memory_descriptor_t;
51 
52 typedef struct rarch_memory_map
53 {
54    rarch_memory_descriptor_t *descriptors;
55    unsigned num_descriptors;
56 } rarch_memory_map_t;
57 
58 typedef struct rarch_system_info
59 {
60    struct retro_location_callback location_cb; /* ptr alignment */
61    disk_control_interface_t disk_control;      /* ptr alignment */
62    struct retro_system_info info;              /* ptr alignment */
63    rarch_memory_map_t mmaps;                   /* ptr alignment */
64    const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY];
65    struct
66    {
67       struct retro_subsystem_info *data;
68       unsigned size;
69    } subsystem;
70    struct
71    {
72       struct retro_controller_info *data;
73       unsigned size;
74    } ports;
75    unsigned rotation;
76    unsigned performance_level;
77    char valid_extensions[255];
78    bool load_no_content;
79    bool supports_vfs;
80 } rarch_system_info_t;
81 
82 typedef struct retro_ctx_input_state_info
83 {
84    retro_input_state_t cb;
85 } retro_ctx_input_state_info_t;
86 
87 typedef struct retro_ctx_cheat_info
88 {
89    const char *code;
90    unsigned index;
91    bool enabled;
92 } retro_ctx_cheat_info_t;
93 
94 typedef struct retro_ctx_api_info
95 {
96    unsigned version;
97 } retro_ctx_api_info_t;
98 
99 typedef struct retro_ctx_region_info
100 {
101   unsigned region;
102 } retro_ctx_region_info_t;
103 
104 typedef struct retro_ctx_controller_info
105 {
106    unsigned port;
107    unsigned device;
108 } retro_ctx_controller_info_t;
109 
110 typedef struct retro_ctx_memory_info
111 {
112    void *data;
113    size_t size;
114    unsigned id;
115 } retro_ctx_memory_info_t;
116 
117 typedef struct retro_ctx_load_content_info
118 {
119    struct retro_game_info *info;
120    const struct string_list *content;
121    const struct retro_subsystem_info *special;
122 } retro_ctx_load_content_info_t;
123 
124 typedef struct retro_ctx_serialize_info
125 {
126    const void *data_const;
127    void *data;
128    size_t size;
129 } retro_ctx_serialize_info_t;
130 
131 typedef struct retro_ctx_size_info
132 {
133    size_t size;
134 } retro_ctx_size_info_t;
135 
136 typedef struct retro_ctx_environ_info
137 {
138    retro_environment_t env;
139 } retro_ctx_environ_info_t;
140 
141 typedef struct retro_callbacks
142 {
143    retro_video_refresh_t frame_cb;
144    retro_audio_sample_t sample_cb;
145    retro_audio_sample_batch_t sample_batch_cb;
146    retro_input_state_t state_cb;
147    retro_input_poll_t poll_cb;
148 } retro_callbacks_t;
149 
150 #ifdef HAVE_REWIND
151 bool core_set_rewind_callbacks(void);
152 #endif
153 
154 #ifdef HAVE_NETWORKING
155 bool core_set_netplay_callbacks(void);
156 
157 bool core_unset_netplay_callbacks(void);
158 #endif
159 
160 bool core_set_poll_type(unsigned type);
161 
162 /* Runs the core for one frame. */
163 bool core_run(void);
164 
165 bool core_reset(void);
166 
167 bool core_serialize_size(retro_ctx_size_info_t *info);
168 
169 uint64_t core_serialization_quirks(void);
170 
171 bool core_serialize(retro_ctx_serialize_info_t *info);
172 
173 bool core_unserialize(retro_ctx_serialize_info_t *info);
174 
175 bool core_set_cheat(retro_ctx_cheat_info_t *info);
176 
177 bool core_reset_cheat(void);
178 
179 bool core_get_memory(retro_ctx_memory_info_t *info);
180 
181 /* Get system A/V information. */
182 bool core_get_system_info(struct retro_system_info *system);
183 
184 bool core_load_game(retro_ctx_load_content_info_t *load_info);
185 
186 bool core_set_controller_port_device(retro_ctx_controller_info_t *pad);
187 
188 bool core_has_set_input_descriptor(void);
189 
190 RETRO_END_DECLS
191 
192 #endif
193