1 #ifndef _GIT_H
2 #define _GIT_H
3 
4 #include <string.h>
5 
6 #include "video/surface.h"
7 
8 #include "state.h"
9 
10 typedef enum
11 {
12  IDIT_BUTTON,		// 1-bit
13  IDIT_BUTTON_CAN_RAPID, // 1-bit
14  IDIT_BUTTON_BYTE, // 8-bits, Button as a byte instead of a bit.
15  IDIT_X_AXIS,	   // (mouse) 32-bits, signed, fixed-point: 1.15.16 - in-screen/window range: [0.0, nominal_width)
16  IDIT_Y_AXIS,	   // (mouse) 32-bits, signed, fixed-point: 1.15.16 - in-screen/window range: [0.0, nominal_height)
17  IDIT_X_AXIS_REL,  // (mouse) 32-bits, signed
18  IDIT_Y_AXIS_REL,  // (mouse) 32-bits, signed
19  IDIT_BYTE_SPECIAL,
20  IDIT_BUTTON_ANALOG, // 32-bits, 0 - 32767
21  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...
22 		// May extend to 16-bit each in the future.
23 		// It's also rather a special case of game module->driver code communication.
24 } InputDeviceInputType;
25 
26 typedef struct
27 {
28 	const char *SettingName;	// No spaces, shouldbe all a-z0-9 and _. Definitely no ~!
29 	const char *Name;
30 	/*const InputDeviceInputVB VirtButton;*/
31         const int ConfigOrder;          // Configuration order during in-game config process, -1 for no config.
32 	const InputDeviceInputType Type;
33 	const char *ExcludeName;	// SettingName of a button that can't be pressed at the same time as this button
34 					// due to physical limitations.
35 
36 	const char *RotateName[3];	// 90, 180, 270
37 	//const char *Rotate180Name;
38 	//const char *Rotate270Name;
39 } InputDeviceInputInfoStruct;
40 
41 typedef struct
42 {
43  const char *ShortName;
44  const char *FullName;
45  const char *Description;
46 
47  //struct InputPortInfoStruct *PortExpanderDeviceInfo;
48  const void *PortExpanderDeviceInfo;	// DON'T USE, IT'S NOT IMPLEMENTED PROPERLY CURRENTLY.
49  int NumInputs; // Usually just the number of buttons....OR if PortExpanderDeviceInfo is non-NULL, it's the number of input
50 		// ports this port expander device provides.
51  const InputDeviceInputInfoStruct *IDII;
52 } InputDeviceInfoStruct;
53 
54 typedef struct
55 {
56  const char *ShortName;
57  const char *FullName;
58  int NumTypes; // Number of unique input devices available for this input port
59  InputDeviceInfoStruct *DeviceInfo;
60  const char *DefaultDevice;	// Default device for this port.
61 } InputPortInfoStruct;
62 
63 typedef struct
64 {
65  int InputPorts;
66  const InputPortInfoStruct *Types;
67 } InputInfoStruct;
68 
69 struct MemoryPatch;
70 
71 struct CheatFormatStruct
72 {
73  const char *FullName;		//"Game Genie", "GameShark", "Pro Action Catplay", etc.
74  const char *Description;	// Whatever?
75 };
76 
77 struct CheatFormatInfoStruct
78 {
79  unsigned NumFormats;
80 
81  struct CheatFormatStruct *Formats;
82 };
83 
84 // Miscellaneous system/simple commands(power, reset, dip switch toggles, coin insert, etc.)
85 // (for DoSimpleCommand() )
86 enum
87 {
88  MDFN_MSC_RESET = 0x01,
89  MDFN_MSC_POWER = 0x02,
90 
91  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.
92 };
93 
94 typedef struct
95 {
96 	// Pitch(32-bit) must be equal to width and >= the "fb_width" specified in the MDFNGI struct for the emulated system.
97 	// Height must be >= to the "fb_height" specified in the MDFNGI struct for the emulated system.
98 	// The framebuffer pointed to by surface->pixels is written to by the system emulation code.
99 	struct MDFN_Surface *surface;
100 
101 	// Will be set to TRUE if the video pixel format has changed since the last call to Emulate(), FALSE otherwise.
102 	// Will be set to TRUE on the first call to the Emulate() function/method
103 	bool VideoFormatChanged;
104 
105 	// Set by the system emulation code every frame, to denote the horizontal and vertical offsets of the image, and the size
106 	// of the image.  If the emulated system sets the elements of LineWidths, then the horizontal offset(x) and width(w) of this structure
107 	// are ignored while drawing the image.
108 	MDFN_Rect DisplayRect;
109 
110 	// Pointer to an array of MDFN_Rect, number of elements = fb_height, set by the driver code.  Individual MDFN_Rect structs written
111 	// to by system emulation code.  If the emulated system doesn't support multiple screen widths per frame, or if you handle
112 	// such a situation by outputting at a constant width-per-frame that is the least-common-multiple of the screen widths, then
113 	// you can ignore this.  If you do wish to use this, you must set all elements every frame.
114 	MDFN_Rect *LineWidths;
115 
116 	// Skip rendering this frame if true.  Set by the driver code.
117 	int skip;
118 
119 	//
120 	// If sound is disabled, the driver code must set SoundRate to false, SoundBuf to NULL, SoundBufMaxSize to 0.
121 
122         // 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.
123         // Will be set to TRUE on the first call to the Emulate() function/method
124 	bool SoundFormatChanged;
125 
126 	// Sound rate.  Set by driver side.
127 	double SoundRate;
128 
129 	// Maximum size of the sound buffer, in frames.  Set by the driver code.
130 	int32 SoundBufMaxSize;
131 
132 	// Number of frames currently in internal sound buffer.  Set by the system emulation code, to be read by the driver code.
133 	int32 SoundBufSize;
134 	int32 SoundBufSizeALMS;	// SoundBufSize value at last MidSync(), 0
135 				// if mid sync isn't implemented for the emulation module in use.
136 
137 	// Number of cycles that this frame consumed, using MDFNGI::MasterClock as a time base.
138 	// Set by emulation code.
139 	int64 MasterCycles;
140 	int64 MasterCyclesALMS;	// MasterCycles value at last MidSync(), 0
141 				// if mid sync isn't implemented for the emulation module in use.
142 } EmulateSpecStruct;
143 
144 #define MDFN_MASTERCLOCK_FIXED(n)	((int64)((double)(n) * (1LL << 32)))
145 
146 typedef struct
147 {
148  // Time base for EmulateSpecStruct::MasterCycles
149  int64 MasterClock;
150 
151  uint32 fps; // frames per second * 65536 * 256, truncated
152 
153  int lcm_width;
154  int lcm_height;
155 
156  int nominal_width;
157  int nominal_height;
158 
159  int fb_width;		// Width of the framebuffer(not necessarily width of the image).  MDFN_Surface width should be >= this.
160  int fb_height;		// Height of the framebuffer passed to the Emulate() function(not necessarily height of the image)
161 
162  int soundchan; 	// Number of output sound channels.
163 
164 
165  int rotated;
166 
167  int soundrate;  /* For Ogg Vorbis expansion sound wacky support.  0 for default. */
168 } MDFNGI;
169 
170 #ifdef __cplusplus
171 extern "C" {
172 #endif
173 int StateAction(StateMem *sm, int load, int data_only);
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif
179