Debian Codegraph @

mednafen/git.h

raw symbols SCIP
1 #ifndef _GIT_H
2 #define _GIT_H
3
4 #include <string>
5
6 typedef struct
7 {
8 const char *extension; // Example ".nes"
9 const char *description; // Example "iNES Format ROM Image"
10 } FileExtensionSpecStruct;
11
12 #include "file.h"
13 #include "video/surface.h"
14
15 enum
16 {
17 MDFN_ROTATE0 = 0,
18 MDFN_ROTATE90,
19 MDFN_ROTATE180,
20 MDFN_ROTATE270
21 };
22
23 typedef enum
24 {
25 VIDSYS_NONE, // Can be used internally in system emulation code, but it is an error condition to let it continue to be
26 // after the Load() or LoadCD() function returns!
27 VIDSYS_PAL,
28 VIDSYS_PAL_M, // Same timing as NTSC, but uses PAL-style colour encoding
29 VIDSYS_NTSC,
30 VIDSYS_SECAM
31 } VideoSystems;
32
33 typedef enum
34 {
35 GMT_CART, // Self-explanatory!
36 GMT_ARCADE, // VS Unisystem, PC-10...
37 GMT_DISK, // Famicom Disk System, mostly
38 GMT_CDROM, // PC Engine CD, PC-FX
39 GMT_PLAYER // Music player(NSF, HES, GSF)
40 } GameMediumTypes;
41
42 #include "state.h"
43 #include "settings-common.h"
44
45 typedef enum
46 {
47 IDIT_BUTTON, // 1-bit
48 IDIT_BUTTON_CAN_RAPID, // 1-bit
49 IDIT_BUTTON_BYTE, // 8-bits, Button as a byte instead of a bit.
50 IDIT_X_AXIS, // (mouse) 32-bits, signed, fixed-point: 1.15.16 - in-screen/window range: [0.0, nominal_width)
51 IDIT_Y_AXIS, // (mouse) 32-bits, signed, fixed-point: 1.15.16 - in-screen/window range: [0.0, nominal_height)
52 IDIT_X_AXIS_REL, // (mouse) 32-bits, signed
53 IDIT_Y_AXIS_REL, // (mouse) 32-bits, signed
54 IDIT_BYTE_SPECIAL,
55 IDIT_BUTTON_ANALOG, // 32-bits, 0 - 32767
56 IDIT_RUMBLE, // 32-bits, lower 8 bits are weak rumble(0-255), next 8 bits are strong rumble(0-255), 0=no rumble, 255=max rumble. Somewhat subjective, too...
57 // May extend to 16-bit each in the future.
58 // It's also rather a special case of game module->driver code communication.
59 } InputDeviceInputType;
60
61 typedef struct
62 {
63 const char *SettingName; // No spaces, shouldbe all a-z0-9 and _. Definitely no ~!
64 const char *Name;
65 /*const InputDeviceInputVB VirtButton;*/
66 const int ConfigOrder; // Configuration order during in-game config process, -1 for no config.
67 const InputDeviceInputType Type;
68 const char *ExcludeName; // SettingName of a button that can't be pressed at the same time as this button
69 // due to physical limitations.
70
71 const char *RotateName[3]; // 90, 180, 270
72 //const char *Rotate180Name;
73 //const char *Rotate270Name;
74 } InputDeviceInputInfoStruct;
75
76 typedef struct
77 {
78 const char *ShortName;
79 const char *FullName;
80 const char *Description;
81
82 //struct InputPortInfoStruct *PortExpanderDeviceInfo;
83 const void *PortExpanderDeviceInfo; // DON'T USE, IT'S NOT IMPLEMENTED PROPERLY CURRENTLY.
84 int NumInputs; // Usually just the number of buttons....OR if PortExpanderDeviceInfo is non-NULL, it's the number of input
85 // ports this port expander device provides.
86 const InputDeviceInputInfoStruct *IDII;
87 } InputDeviceInfoStruct;
88
89 typedef struct
90 {
91 const char *ShortName;
92 const char *FullName;
93 int NumTypes; // Number of unique input devices available for this input port
94 InputDeviceInfoStruct *DeviceInfo;
95 const char *DefaultDevice; // Default device for this port.
96 } InputPortInfoStruct;
97
98 typedef struct
99 {
100 int InputPorts;
101 const InputPortInfoStruct *Types;
102 } InputInfoStruct;
103
104 struct MemoryPatch;
105
106 struct CheatFormatStruct
107 {
108 const char *FullName; //"Game Genie", "GameShark", "Pro Action Catplay", etc.
109 const char *Description; // Whatever?
110
111 bool (*DecodeCheat)(const std::string& cheat_string, MemoryPatch* patch); // *patch should be left as initialized by MemoryPatch::MemoryPatch(), unless this is the
112 // second(or third or whatever) part of a multipart cheat.
113 //
114 // Will throw an std::exception(or derivative) on format error.
115 //
116 // Will return true if this is part of a multipart cheat.
117 };
118
119 struct CheatFormatInfoStruct
120 {
121 unsigned NumFormats;
122
123 CheatFormatStruct *Formats;
124 };
125
126 // Miscellaneous system/simple commands(power, reset, dip switch toggles, coin insert, etc.)
127 // (for DoSimpleCommand() )
128 enum
129 {
130 MDFN_MSC_RESET = 0x01,
131 MDFN_MSC_POWER = 0x02,
132
133 MDFN_MSC_INSERT_COIN = 0x07,
134
135 // If we ever support arcade systems, we'll abstract DIP switches differently...maybe.
136 MDFN_MSC_TOGGLE_DIP0 = 0x10,
137 MDFN_MSC_TOGGLE_DIP1,
138 MDFN_MSC_TOGGLE_DIP2,
139 MDFN_MSC_TOGGLE_DIP3,
140 MDFN_MSC_TOGGLE_DIP4,
141 MDFN_MSC_TOGGLE_DIP5,
142 MDFN_MSC_TOGGLE_DIP6,
143 MDFN_MSC_TOGGLE_DIP7,
144 MDFN_MSC_TOGGLE_DIP8,
145 MDFN_MSC_TOGGLE_DIP9,
146 MDFN_MSC_TOGGLE_DIP10,
147 MDFN_MSC_TOGGLE_DIP11,
148 MDFN_MSC_TOGGLE_DIP12,
149 MDFN_MSC_TOGGLE_DIP13,
150 MDFN_MSC_TOGGLE_DIP14,
151 MDFN_MSC_TOGGLE_DIP15,
152
153
154 // n of DISKn translates to is emulation module specific.
155 MDFN_MSC_INSERT_DISK0 = 0x20,
156 MDFN_MSC_INSERT_DISK1,
157 MDFN_MSC_INSERT_DISK2,
158 MDFN_MSC_INSERT_DISK3,
159 MDFN_MSC_INSERT_DISK4,
160 MDFN_MSC_INSERT_DISK5,
161 MDFN_MSC_INSERT_DISK6,
162 MDFN_MSC_INSERT_DISK7,
163 MDFN_MSC_INSERT_DISK8,
164 MDFN_MSC_INSERT_DISK9,
165 MDFN_MSC_INSERT_DISK10,
166 MDFN_MSC_INSERT_DISK11,
167 MDFN_MSC_INSERT_DISK12,
168 MDFN_MSC_INSERT_DISK13,
169 MDFN_MSC_INSERT_DISK14,
170 MDFN_MSC_INSERT_DISK15,
171
172 MDFN_MSC_INSERT_DISK = 0x30,
173 MDFN_MSC_EJECT_DISK = 0x31,
174
175 // This command should select the next disk or disk side in the set and use MDFN_DispMessage() to show which disk is selected.
176 // (If it's only allowed while a disk is ejected, or not, is emulation module specific.
177 MDFN_MSC_SELECT_DISK = 0x32,
178
179 MDFN_MSC__LAST = 0x3F // WARNING: Increasing(or having the enum'd value of a command greater than this :b) this will necessitate a change to the netplay protocol.
180 };
181
182 typedef struct
183 {
184 // Pitch(32-bit) must be equal to width and >= the "fb_width" specified in the MDFNGI struct for the emulated system.
185 // Height must be >= to the "fb_height" specified in the MDFNGI struct for the emulated system.
186 // The framebuffer pointed to by surface->pixels is written to by the system emulation code.
187 MDFN_Surface *surface;
188
189 // Will be set to TRUE if the video pixel format has changed since the last call to Emulate(), FALSE otherwise.
190 // Will be set to TRUE on the first call to the Emulate() function/method
191 bool VideoFormatChanged;
192
193 // Set by the system emulation code every frame, to denote the horizontal and vertical offsets of the image, and the size
194 // of the image. If the emulated system sets the elements of LineWidths, then the horizontal offset(x) and width(w) of this structure
195 // are ignored while drawing the image.
196 MDFN_Rect DisplayRect;
197
198 // Pointer to an array of MDFN_Rect, number of elements = fb_height, set by the driver code. Individual MDFN_Rect structs written
199 // to by system emulation code. If the emulated system doesn't support multiple screen widths per frame, or if you handle
200 // such a situation by outputting at a constant width-per-frame that is the least-common-multiple of the screen widths, then
201 // you can ignore this. If you do wish to use this, you must set all elements every frame.
202 MDFN_Rect *LineWidths;
203
204 // TODO
205 bool *IsFMV;
206
207 // Set(optionally) by emulation code. If InterlaceOn is true, then assume field height is 1/2 DisplayRect.h, and
208 // only every other line in surface (with the start line defined by InterlacedField) has valid data
209 // (it's up to internal Mednafen code to deinterlace it).
210 bool InterlaceOn;
211 bool InterlaceField;
212
213 // Skip rendering this frame if true. Set by the driver code.
214 int skip;
215
216 //
217 // If sound is disabled, the driver code must set SoundRate to false, SoundBuf to NULL, SoundBufMaxSize to 0.
218
219 // Will be set to TRUE if the sound format(only rate for now, at least) has changed since the last call to Emulate(), FALSE otherwise.
220 // Will be set to TRUE on the first call to the Emulate() function/method
221 bool SoundFormatChanged;
222
223 // Sound rate. Set by driver side.
224 double SoundRate;
225
226 // Pointer to sound buffer, set by the driver code, that the emulation code should render sound to.
227 // Guaranteed to be at least 500ms in length, but emulation code really shouldn't exceed 40ms or so. Additionally, if emulation code
228 // generates >= 100ms,
229 // DEPRECATED: Emulation code may set this pointer to a sound buffer internal to the emulation module.
230 int16 *SoundBuf;
231
232 // Maximum size of the sound buffer, in frames. Set by the driver code.
233 int32 SoundBufMaxSize;
234
235 // Number of frames currently in internal sound buffer. Set by the system emulation code, to be read by the driver code.
236 int32 SoundBufSize;
237 int32 SoundBufSizeALMS; // SoundBufSize value at last MidSync(), 0
238 // if mid sync isn't implemented for the emulation module in use.
239
240 // Number of cycles that this frame consumed, using MDFNGI::MasterClock as a time base.
241 // Set by emulation code.
242 int64 MasterCycles;
243 int64 MasterCyclesALMS; // MasterCycles value at last MidSync(), 0
244 // if mid sync isn't implemented for the emulation module in use.
245
246 // Current sound volume(0.000...<=volume<=1.000...). If, after calling Emulate(), it is still != 1, Mednafen will handle it internally.
247 // Emulation modules can handle volume themselves if they like, for speed reasons. If they do, afterwards, they should set its value to 1.
248 double SoundVolume;
249
250 // Current sound speed multiplier. Set by the driver code. If, after calling Emulate(), it is still != 1, Mednafen will handle it internally
251 // by resampling the audio. This means that emulation modules can handle(and set the value to 1 after handling it) it if they want to get the most
252 // performance possible. HOWEVER, emulation modules must make sure the value is in a range(with minimum and maximum) that their code can handle
253 // before they try to handle it.
254 double soundmultiplier;
255
256 // True if we want to rewind one frame. Set by the driver code.
257 bool NeedRewind;
258
259 // Sound reversal during state rewinding is normally done in mednafen.cpp, but
260 // individual system emulation code can also do it if this is set, and clear it after it's done.
261 // (Also, the driver code shouldn't touch this variable)
262 bool NeedSoundReverse;
263
264 } EmulateSpecStruct;
265
266 typedef enum
267 {
268 MODPRIO_INTERNAL_EXTRA_LOW = 0, // For "cdplay" module, mostly.
269
270 MODPRIO_INTERNAL_LOW = 10,
271 MODPRIO_EXTERNAL_LOW = 20,
272 MODPRIO_INTERNAL_HIGH = 30,
273 MODPRIO_EXTERNAL_HIGH = 40
274 } ModPrio;
275
276 class CDIF;
277
278 typedef struct
279 {
280 /* Private functions to Mednafen. Do not call directly
281 from the driver code, or else bad things shall happen. Maybe. Probably not, but don't
282 do it(yet)!
283 */
284 // Short system name, lowercase a-z, 0-9, and _ are the only allowable characters!
285 const char *shortname;
286
287 // Full system name. Preferably English letters, but can be UTF8
288 const char *fullname;
289
290 // Pointer to an array of FileExtensionSpecStruct, with the last entry being { NULL, NULL } to terminate the list.
291 // This list is used to make best-guess choices, when calling the TestMagic*() functions would be unreasonable, such
292 // as when scanning a ZIP archive for a file to load. The list may also be used in the future for GUI file open windows.
293 const FileExtensionSpecStruct *FileExtensions;
294
295 ModPrio ModulePriority;
296
297 void *Debugger;
298 InputInfoStruct *InputInfo;
299
300 // Returns 1 on successful load, 0 on fatal error(deprecated: -1 on unrecognized format)
301 int (*Load)(const char *name, MDFNFILE *fp);
302
303 // Return TRUE if the file is a recognized type, FALSE if not.
304 bool (*TestMagic)(const char *name, MDFNFILE *fp);
305
306 //
307 // (*CDInterfaces).size() is guaranteed to be >= 1.
308 int (*LoadCD)(std::vector<CDIF *> *CDInterfaces);
309 bool (*TestMagicCD)(std::vector<CDIF *> *CDInterfaces);
310
311 void (*CloseGame)(void);
312
313 void (*SetLayerEnableMask)(uint64 mask); // Video
314 const char *LayerNames;
315
316 void (*SetChanEnableMask)(uint64 mask); // Audio(TODO, placeholder)
317 const char *ChanNames;
318
319 void (*InstallReadPatch)(uint32 address);
320 void (*RemoveReadPatches)(void);
321 uint8 (*MemRead)(uint32 addr);
322
323 #ifdef WANT_NEW_API
324 CheatFormatInfoStruct *CheatFormatInfo;
325 #endif
326
327 bool SaveStateAltersState; // true for bsnes and some libco-style emulators, false otherwise.
328 // Main save state routine, called by the save state code in state.cpp.
329 // When saving, load is set to 0. When loading, load is set to the version field of the save state being loaded.
330 // data_only is true when the save state data is temporary, such as being saved into memory for state rewinding.
331 int (*StateAction)(StateMem *sm, int load, int data_only);
332
333 void (*Emulate)(EmulateSpecStruct *espec);
334 void (*SetInput)(int port, const char *type, void *ptr);
335
336 void (*DoSimpleCommand)(int cmd);
337
338 const MDFNSetting *Settings;
339
340 // Time base for EmulateSpecStruct::MasterCycles
341 #define MDFN_MASTERCLOCK_FIXED(n) ((int64)((double)(n) * (1LL << 32)))
342 int64 MasterClock;
343
344 uint32 fps; // frames per second * 65536 * 256, truncated
345
346 // multires is a hint that, if set, indicates that the system has fairly programmable video modes(particularly, the ability
347 // to display multiple horizontal resolutions, such as the PCE, PC-FX, or Genesis). In practice, it will cause the driver
348 // code to set the linear interpolation on by default.
349 //
350 // lcm_width and lcm_height are the least common multiples of all possible
351 // resolutions in the frame buffer as specified by DisplayRect/LineWidths(Ex for PCE: widths of 256, 341.333333, 512,
352 // lcm = 1024)
353 //
354 // nominal_width and nominal_height specify the resolution that Mednafen should display
355 // the framebuffer image in at 1x scaling, scaled from the dimensions of DisplayRect, and optionally the LineWidths array
356 // passed through espec to the Emulate() function.
357 //
358 bool multires;
359
360 int lcm_width;
361 int lcm_height;
362
363 void *dummy_separator; //
364
365 int nominal_width;
366 int nominal_height;
367
368 int fb_width; // Width of the framebuffer(not necessarily width of the image). MDFN_Surface width should be >= this.
369 int fb_height; // Height of the framebuffer passed to the Emulate() function(not necessarily height of the image)
370
371 int soundchan; // Number of output sound channels.
372
373
374 int rotated;
375
376 uint8 *name; /* Game name, UTF8 encoding */
377 int soundrate; /* For Ogg Vorbis expansion sound wacky support. 0 for default. */
378
379 VideoSystems VideoSystem;
380 GameMediumTypes GameType;
381
382 //int DiskLogicalCount; // A single double-sided disk would be 2 here.
383 //const char *DiskNames; // Null-terminated.
384
385 const char *cspecial; /* Special cart expansion: DIP switches, barcode reader, etc. */
386
387 std::vector<const char *>DesiredInput; // Desired input device for the input ports, NULL for don't care
388
389 double mouse_sensitivity;
390 } MDFNGI;
391 #endif