Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/octoshock/git.h
2 views
1
#ifndef _GIT_H
2
#define _GIT_H
3
4
#include <string>
5
6
#include "octoshock.h"
7
8
#include "video.h"
9
#include "file.h"
10
11
class CDIF;
12
13
typedef struct
14
{
15
const char *extension; // Example ".nes"
16
const char *description; // Example "iNES Format ROM Image"
17
} FileExtensionSpecStruct;
18
19
#include "file.h"
20
21
enum
22
{
23
MDFN_ROTATE0 = 0,
24
MDFN_ROTATE90,
25
MDFN_ROTATE180,
26
MDFN_ROTATE270
27
};
28
29
typedef enum
30
{
31
VIDSYS_NONE, // Can be used internally in system emulation code, but it is an error condition to let it continue to be
32
// after the Load() or LoadCD() function returns!
33
VIDSYS_PAL,
34
VIDSYS_PAL_M, // Same timing as NTSC, but uses PAL-style colour encoding
35
VIDSYS_NTSC,
36
VIDSYS_SECAM
37
} VideoSystems;
38
39
typedef enum
40
{
41
GMT_CART, // Self-explanatory!
42
GMT_ARCADE, // VS Unisystem, PC-10...
43
GMT_DISK, // Famicom Disk System, mostly
44
GMT_CDROM, // PC Engine CD, PC-FX
45
GMT_PLAYER // Music player(NSF, HES, GSF)
46
} GameMediumTypes;
47
48
#ifdef WANT_DEBUGGER
49
// #ifdef WANT_DEBUGGER
50
// typedef struct DebuggerInfoStruct;
51
// #else
52
#include "debug.h"
53
54
#endif
55
56
typedef enum
57
{
58
IDIT_BUTTON, // 1-bit
59
IDIT_BUTTON_CAN_RAPID, // 1-bit
60
61
IDIT_X_AXIS, // (mouse) 16-bits, signed - in-screen/window range: [0.0, nominal_width)
62
IDIT_Y_AXIS, // (mouse) 16-bits, signed - in-screen/window range: [0.0, nominal_height)
63
64
IDIT_X_AXIS_REL, // (mouse) 32-bits, signed
65
IDIT_Y_AXIS_REL, // (mouse) 32-bits, signed
66
67
IDIT_BYTE_SPECIAL,
68
69
IDIT_BUTTON_ANALOG, // 16-bits, 0 - 32767
70
71
IDIT_RUMBLE, // 16-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...
72
// It's a rather special case of game module->driver code communication.
73
} InputDeviceInputType;
74
75
76
#define IDIT_BUTTON_ANALOG_FLAG_SQLR 0x00000001 // Denotes analog data that may need to be scaled to ensure a more squareish logical range(for emulated
77
// analog sticks).
78
79
typedef struct
80
{
81
const char *SettingName; // No spaces, shouldbe all a-z0-9 and _. Definitely no ~!
82
const char *Name;
83
const int ConfigOrder; // Configuration order during in-game config process, -1 for no config.
84
const InputDeviceInputType Type;
85
const char *ExcludeName; // SettingName of a button that can't be pressed at the same time as this button
86
// due to physical limitations.
87
88
const char *RotateName[3]; // 90, 180, 270
89
unsigned Flags;
90
} InputDeviceInputInfoStruct;
91
92
typedef struct
93
{
94
const char *ShortName;
95
const char *FullName;
96
const char *Description;
97
98
//struct InputPortInfoStruct *PortExpanderDeviceInfo;
99
const void *PortExpanderDeviceInfo; // DON'T USE, IT'S NOT IMPLEMENTED PROPERLY CURRENTLY.
100
int NumInputs; // Usually just the number of buttons....OR if PortExpanderDeviceInfo is non-NULL, it's the number of input
101
// ports this port expander device provides.
102
const InputDeviceInputInfoStruct *IDII;
103
} InputDeviceInfoStruct;
104
105
typedef struct
106
{
107
const char *ShortName;
108
const char *FullName;
109
int NumTypes; // Number of unique input devices available for this input port
110
InputDeviceInfoStruct *DeviceInfo;
111
const char *DefaultDevice; // Default device for this port.
112
} InputPortInfoStruct;
113
114
typedef struct
115
{
116
int InputPorts;
117
const InputPortInfoStruct *Types;
118
} InputInfoStruct;
119
120
struct MemoryPatch;
121
122
typedef struct
123
{
124
// Pitch(32-bit) must be equal to width and >= the "fb_width" specified in the MDFNGI struct for the emulated system.
125
// Height must be >= to the "fb_height" specified in the MDFNGI struct for the emulated system.
126
// The framebuffer pointed to by surface->pixels is written to by the system emulation code.
127
MDFN_Surface *surface;
128
129
// Will be set to TRUE if the video pixel format has changed since the last call to Emulate(), FALSE otherwise.
130
// Will be set to TRUE on the first call to the Emulate() function/method
131
bool VideoFormatChanged;
132
133
// Set by the system emulation code every frame, to denote the horizontal and vertical offsets of the image, and the size
134
// of the image. If the emulated system sets the elements of LineWidths, then the width(w) of this structure
135
// is ignored while drawing the image.
136
MDFN_Rect DisplayRect;
137
138
// Pointer to an array of int32, number of elements = fb_height, set by the driver code. Individual elements written
139
// to by system emulation code. If the emulated system doesn't support multiple screen widths per frame, or if you handle
140
// such a situation by outputting at a constant width-per-frame that is the least-common-multiple of the screen widths, then
141
// you can ignore this. If you do wish to use this, you must set all elements every frame.
142
int32 *LineWidths;
143
144
// TODO
145
bool *IsFMV;
146
147
// Set(optionally) by emulation code. If InterlaceOn is true, then assume field height is 1/2 DisplayRect.h, and
148
// only every other line in surface (with the start line defined by InterlacedField) has valid data
149
// (it's up to internal Mednafen code to deinterlace it).
150
bool InterlaceOn;
151
bool InterlaceField;
152
153
// Skip rendering this frame if true. Set by the driver code.
154
int skip;
155
156
//
157
// If sound is disabled, the driver code must set SoundRate to false, SoundBuf to NULL, SoundBufMaxSize to 0.
158
159
// 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.
160
// Will be set to TRUE on the first call to the Emulate() function/method
161
bool SoundFormatChanged;
162
163
// Sound rate. Set by driver side.
164
double SoundRate;
165
166
// Pointer to sound buffer, set by the driver code, that the emulation code should render sound to.
167
// Guaranteed to be at least 500ms in length, but emulation code really shouldn't exceed 40ms or so. Additionally, if emulation code
168
// generates >= 100ms,
169
// DEPRECATED: Emulation code may set this pointer to a sound buffer internal to the emulation module.
170
int16 *SoundBuf;
171
172
// Maximum size of the sound buffer, in frames. Set by the driver code.
173
int32 SoundBufMaxSize;
174
175
// Number of frames currently in internal sound buffer. Set by the system emulation code, to be read by the driver code.
176
int32 SoundBufSize;
177
int32 SoundBufSizeALMS; // SoundBufSize value at last MidSync(), 0
178
// if mid sync isn't implemented for the emulation module in use.
179
180
// Number of cycles that this frame consumed, using MDFNGI::MasterClock as a time base.
181
// Set by emulation code.
182
int64 MasterCycles;
183
int64 MasterCyclesALMS; // MasterCycles value at last MidSync(), 0
184
// if mid sync isn't implemented for the emulation module in use.
185
186
// Current sound volume(0.000...<=volume<=1.000...). If, after calling Emulate(), it is still != 1, Mednafen will handle it internally.
187
// Emulation modules can handle volume themselves if they like, for speed reasons. If they do, afterwards, they should set its value to 1.
188
double SoundVolume;
189
190
// Current sound speed multiplier. Set by the driver code. If, after calling Emulate(), it is still != 1, Mednafen will handle it internally
191
// 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
192
// performance possible. HOWEVER, emulation modules must make sure the value is in a range(with minimum and maximum) that their code can handle
193
// before they try to handle it.
194
double soundmultiplier;
195
196
// True if we want to rewind one frame. Set by the driver code.
197
bool NeedRewind;
198
199
// Sound reversal during state rewinding is normally done in mednafen.cpp, but
200
// individual system emulation code can also do it if this is set, and clear it after it's done.
201
// (Also, the driver code shouldn't touch this variable)
202
bool NeedSoundReverse;
203
204
} EmulateSpecStruct;
205
206
207
208
typedef struct
209
{
210
/* Private functions to Mednafen. Do not call directly
211
from the driver code, or else bad things shall happen. Maybe. Probably not, but don't
212
do it(yet)!
213
*/
214
// Short system name, lowercase a-z, 0-9, and _ are the only allowable characters!
215
const char *shortname;
216
217
// Full system name. Preferably English letters, but can be UTF8
218
const char *fullname;
219
220
// Pointer to an array of FileExtensionSpecStruct, with the last entry being { NULL, NULL } to terminate the list.
221
// This list is used to make best-guess choices, when calling the TestMagic*() functions would be unreasonable, such
222
// 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.
223
const FileExtensionSpecStruct *FileExtensions;
224
225
#ifdef WANT_DEBUGGER
226
DebuggerInfoStruct *Debugger;
227
#else
228
void *Debugger;
229
#endif
230
InputInfoStruct *InputInfo;
231
232
//
233
// Returns 1 on successful load.
234
// throws exception on fatal error.
235
//
236
// DEPRECATED: Return 0 on fatal error.
237
// DEPRECATED: Return -1 on unrecognized format.
238
//
239
// fp's stream position is guaranteed to be 0 when this function is called.
240
//
241
int (*Load)(MDFNFILE *fp);
242
243
//
244
// Return true if the file is a recognized type, false if not.
245
//
246
// fp's stream position is guaranteed to be 0 when this function is called.
247
//
248
bool (*TestMagic)(MDFNFILE *fp);
249
250
//
251
// (*CDInterfaces).size() is guaranteed to be >= 1.
252
void (*LoadCD)(std::vector<CDIF *> *CDInterfaces);
253
bool (*TestMagicCD)(std::vector<CDIF *> *CDInterfaces);
254
255
void (*CloseGame)(void);
256
257
void (*SetLayerEnableMask)(uint64 mask); // Video
258
const char *LayerNames;
259
260
void (*SetChanEnableMask)(uint64 mask); // Audio(TODO, placeholder)
261
const char *ChanNames;
262
263
//
264
// InstallReadPatch and RemoveReadPatches should be non-NULL(even if only pointing to dummy functions) if the emulator module supports
265
// read-substitution and read-substitution-with-compare style(IE Game Genie-style) cheats.
266
//
267
// See also "SubCheats" global stuff in mempatcher.h.
268
//
269
void (*InstallReadPatch)(uint32 address, uint8 value, int compare); // Compare is >= 0 when utilized.
270
void (*RemoveReadPatches)(void);
271
uint8 (*MemRead)(uint32 addr);
272
273
bool SaveStateAltersState; // true for bsnes and some libco-style emulators, false otherwise.
274
// Main save state routine, called by the save state code in state.cpp.
275
// When saving, load is set to 0. When loading, load is set to the version field of the save state being loaded.
276
// data_only is true when the save state data is temporary, such as being saved into memory for state rewinding.
277
278
void (*Emulate)(EmulateSpecStruct *espec);
279
void (*SetInput)(int port, const char *type, void *ptr);
280
281
void (*DoSimpleCommand)(int cmd);
282
283
// Time base for EmulateSpecStruct::MasterCycles
284
// MasterClock must be >= MDFN_MASTERCLOCK_FIXED(1.0)
285
// All or part of the fractional component may be ignored in some timekeeping operations in the emulator to prevent integer overflow,
286
// so it is unwise to have a fractional component when the integral component is very small(less than say, 10000).
287
#define MDFN_MASTERCLOCK_FIXED(n) ((int64)((double)(n) * (1LL << 32)))
288
int64 MasterClock;
289
290
// Nominal frames per second * 65536 * 256, truncated.
291
// May be deprecated in the future due to many systems having slight frame rate programmability.
292
uint32 fps;
293
294
// multires is a hint that, if set, indicates that the system has fairly programmable video modes(particularly, the ability
295
// to display multiple horizontal resolutions, such as the PCE, PC-FX, or Genesis). In practice, it will cause the driver
296
// code to set the linear interpolation on by default.
297
//
298
// lcm_width and lcm_height are the least common multiples of all possible
299
// resolutions in the frame buffer as specified by DisplayRect/LineWidths(Ex for PCE: widths of 256, 341.333333, 512,
300
// lcm = 1024)
301
//
302
// nominal_width and nominal_height specify the resolution that Mednafen should display
303
// the framebuffer image in at 1x scaling, scaled from the dimensions of DisplayRect, and optionally the LineWidths array
304
// passed through espec to the Emulate() function.
305
//
306
bool multires;
307
308
int lcm_width;
309
int lcm_height;
310
311
void *dummy_separator; //
312
313
int nominal_width;
314
int nominal_height;
315
316
int fb_width; // Width of the framebuffer(not necessarily width of the image). MDFN_Surface width should be >= this.
317
int fb_height; // Height of the framebuffer passed to the Emulate() function(not necessarily height of the image)
318
319
int soundchan; // Number of output sound channels. Only values of 1 and 2 are currently supported.
320
321
322
int rotated;
323
324
uint8 *name; /* Game name, UTF8 encoding */
325
uint8 MD5[16];
326
uint8 GameSetMD5[16]; /* A unique ID for the game set this CD belongs to, only used in PC-FX emulation. */
327
bool GameSetMD5Valid; /* True if GameSetMD5 is valid. */
328
329
uint8 StateMD5[16]; // ID to use in save state naming and netplay session IDs, if
330
bool StateMD5Valid; // StateMD5Valid is true(useful for systems with multiple BIOS revisions, e.g. PS1).
331
332
int soundrate; /* For Ogg Vorbis expansion sound wacky support. 0 for default. */
333
334
VideoSystems VideoSystem;
335
GameMediumTypes GameType;
336
337
//int DiskLogicalCount; // A single double-sided disk would be 2 here.
338
//const char *DiskNames; // Null-terminated.
339
340
const char *cspecial; /* Special cart expansion: DIP switches, barcode reader, etc. */
341
342
std::vector<const char *>DesiredInput; // Desired input device for the input ports, NULL for don't care
343
344
// For mouse relative motion.
345
double mouse_sensitivity;
346
347
348
//
349
// For absolute coordinates(IDIT_X_AXIS and IDIT_Y_AXIS), usually mapped to a mouse(hence the naming).
350
//
351
float mouse_scale_x, mouse_scale_y;
352
float mouse_offs_x, mouse_offs_y;
353
} MDFNGI;
354
#endif
355
356