1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | * Mupen64plus-core - m64p_plugin.h * |
3 | * Mupen64Plus homepage: https://mupen64plus.org/ * |
4 | * Copyright (C) 2002 Hacktarux * |
5 | * Copyright (C) 2009 Richard Goedeken * |
6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * |
11 | * * |
12 | * This program is distributed in the hope that it will be useful, * |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 | * GNU General Public License for more details. * |
16 | * * |
17 | * You should have received a copy of the GNU General Public License * |
18 | * along with this program; if not, write to the * |
19 | * Free Software Foundation, Inc., * |
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
21 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
22 | |
23 | #if !defined(M64P_PLUGIN_H) |
24 | #define M64P_PLUGIN_H |
25 | |
26 | #include "m64p_types.h" |
27 | |
28 | #ifdef __cplusplus |
29 | extern "C" { |
30 | #endif |
31 | |
32 | /*** Controller plugin's ****/ |
33 | #define PLUGIN_NONE 1 |
34 | #define PLUGIN_MEMPAK 2 |
35 | #define PLUGIN_RUMBLE_PAK 3 /* not implemented for non raw data */ |
36 | #define PLUGIN_TRANSFER_PAK 4 /* not implemented for non raw data */ |
37 | #define PLUGIN_RAW 5 /* the controller plugin is passed in raw data */ |
38 | #define PLUGIN_BIO_PAK 6 |
39 | |
40 | /***** Structures *****/ |
41 | typedef struct { |
42 | unsigned char * RDRAM; |
43 | unsigned char * DMEM; |
44 | unsigned char * IMEM; |
45 | |
46 | unsigned int * MI_INTR_REG; |
47 | |
48 | unsigned int * SP_MEM_ADDR_REG; |
49 | unsigned int * SP_DRAM_ADDR_REG; |
50 | unsigned int * SP_RD_LEN_REG; |
51 | unsigned int * SP_WR_LEN_REG; |
52 | unsigned int * SP_STATUS_REG; |
53 | unsigned int * SP_DMA_FULL_REG; |
54 | unsigned int * SP_DMA_BUSY_REG; |
55 | unsigned int * SP_PC_REG; |
56 | unsigned int * SP_SEMAPHORE_REG; |
57 | |
58 | unsigned int * DPC_START_REG; |
59 | unsigned int * DPC_END_REG; |
60 | unsigned int * DPC_CURRENT_REG; |
61 | unsigned int * DPC_STATUS_REG; |
62 | unsigned int * DPC_CLOCK_REG; |
63 | unsigned int * DPC_BUFBUSY_REG; |
64 | unsigned int * DPC_PIPEBUSY_REG; |
65 | unsigned int * DPC_TMEM_REG; |
66 | |
67 | void (*CheckInterrupts)(void); |
68 | void (*ProcessDlistList)(void); |
69 | void (*ProcessAlistList)(void); |
70 | void (*ProcessRdpList)(void); |
71 | void (*ShowCFB)(void); |
72 | } RSP_INFO; |
73 | |
74 | typedef struct { |
75 | unsigned char * ; /* This is the rom header (first 40h bytes of the rom) */ |
76 | unsigned char * RDRAM; |
77 | unsigned char * DMEM; |
78 | unsigned char * IMEM; |
79 | |
80 | unsigned int * MI_INTR_REG; |
81 | |
82 | unsigned int * DPC_START_REG; |
83 | unsigned int * DPC_END_REG; |
84 | unsigned int * DPC_CURRENT_REG; |
85 | unsigned int * DPC_STATUS_REG; |
86 | unsigned int * DPC_CLOCK_REG; |
87 | unsigned int * DPC_BUFBUSY_REG; |
88 | unsigned int * DPC_PIPEBUSY_REG; |
89 | unsigned int * DPC_TMEM_REG; |
90 | |
91 | unsigned int * VI_STATUS_REG; |
92 | unsigned int * VI_ORIGIN_REG; |
93 | unsigned int * VI_WIDTH_REG; |
94 | unsigned int * VI_INTR_REG; |
95 | unsigned int * VI_V_CURRENT_LINE_REG; |
96 | unsigned int * VI_TIMING_REG; |
97 | unsigned int * VI_V_SYNC_REG; |
98 | unsigned int * VI_H_SYNC_REG; |
99 | unsigned int * VI_LEAP_REG; |
100 | unsigned int * VI_H_START_REG; |
101 | unsigned int * VI_V_START_REG; |
102 | unsigned int * VI_V_BURST_REG; |
103 | unsigned int * VI_X_SCALE_REG; |
104 | unsigned int * VI_Y_SCALE_REG; |
105 | |
106 | void (*CheckInterrupts)(void); |
107 | |
108 | /* The GFX_INFO.version parameter was added in version 2.5.1 of the core. |
109 | Plugins should ensure the core is at least this version before |
110 | attempting to read GFX_INFO.version. */ |
111 | unsigned int version; |
112 | /* SP_STATUS_REG and RDRAM_SIZE were added in version 2 of GFX_INFO.version. |
113 | Plugins should only attempt to read these values if GFX_INFO.version is at least 2. */ |
114 | |
115 | /* The RSP plugin should set (HALT | BROKE | TASKDONE) *before* calling ProcessDList. |
116 | It should not modify SP_STATUS_REG after ProcessDList has returned. |
117 | This will allow the GFX plugin to unset these bits if it needs. */ |
118 | unsigned int * SP_STATUS_REG; |
119 | const unsigned int * RDRAM_SIZE; |
120 | } GFX_INFO; |
121 | |
122 | typedef struct { |
123 | unsigned char * RDRAM; |
124 | unsigned char * DMEM; |
125 | unsigned char * IMEM; |
126 | |
127 | unsigned int * MI_INTR_REG; |
128 | |
129 | unsigned int * AI_DRAM_ADDR_REG; |
130 | unsigned int * AI_LEN_REG; |
131 | unsigned int * AI_CONTROL_REG; |
132 | unsigned int * AI_STATUS_REG; |
133 | unsigned int * AI_DACRATE_REG; |
134 | unsigned int * AI_BITRATE_REG; |
135 | |
136 | void (*CheckInterrupts)(void); |
137 | } AUDIO_INFO; |
138 | |
139 | typedef struct { |
140 | int Present; |
141 | int RawData; |
142 | int Plugin; |
143 | } CONTROL; |
144 | |
145 | typedef union { |
146 | unsigned int Value; |
147 | struct { |
148 | unsigned R_DPAD : 1; |
149 | unsigned L_DPAD : 1; |
150 | unsigned D_DPAD : 1; |
151 | unsigned U_DPAD : 1; |
152 | unsigned START_BUTTON : 1; |
153 | unsigned Z_TRIG : 1; |
154 | unsigned B_BUTTON : 1; |
155 | unsigned A_BUTTON : 1; |
156 | |
157 | unsigned R_CBUTTON : 1; |
158 | unsigned L_CBUTTON : 1; |
159 | unsigned D_CBUTTON : 1; |
160 | unsigned U_CBUTTON : 1; |
161 | unsigned R_TRIG : 1; |
162 | unsigned L_TRIG : 1; |
163 | unsigned Reserved1 : 1; |
164 | unsigned Reserved2 : 1; |
165 | |
166 | signed X_AXIS : 8; |
167 | signed Y_AXIS : 8; |
168 | }; |
169 | } BUTTONS; |
170 | |
171 | typedef struct { |
172 | CONTROL *Controls; /* A pointer to an array of 4 controllers .. eg: |
173 | CONTROL Controls[4]; */ |
174 | } CONTROL_INFO; |
175 | |
176 | /* common plugin function pointer types */ |
177 | typedef void (*ptr_RomClosed)(void); |
178 | typedef int (*ptr_RomOpen)(void); |
179 | #if defined(M64P_PLUGIN_PROTOTYPES) |
180 | EXPORT int CALL RomOpen(void); |
181 | EXPORT void CALL RomClosed(void); |
182 | #endif |
183 | |
184 | /* video plugin function pointer types */ |
185 | typedef void (*ptr_ChangeWindow)(void); |
186 | typedef int (*ptr_InitiateGFX)(GFX_INFO Gfx_Info); |
187 | typedef void (*ptr_MoveScreen)(int x, int y); |
188 | typedef void (*ptr_ProcessDList)(void); |
189 | typedef void (*ptr_ProcessRDPList)(void); |
190 | typedef void (*ptr_ShowCFB)(void); |
191 | typedef void (*ptr_UpdateScreen)(void); |
192 | typedef void (*ptr_ViStatusChanged)(void); |
193 | typedef void (*ptr_ViWidthChanged)(void); |
194 | typedef void (*ptr_ReadScreen2)(void *dest, int *width, int *height, int front); |
195 | typedef void (*ptr_SetRenderingCallback)(void (*callback)(int)); |
196 | typedef void (*ptr_ResizeVideoOutput)(int width, int height); |
197 | #if defined(M64P_PLUGIN_PROTOTYPES) |
198 | EXPORT void CALL ChangeWindow(void); |
199 | EXPORT int CALL InitiateGFX(GFX_INFO Gfx_Info); |
200 | EXPORT void CALL MoveScreen(int x, int y); |
201 | EXPORT void CALL ProcessDList(void); |
202 | EXPORT void CALL ProcessRDPList(void); |
203 | EXPORT void CALL ShowCFB(void); |
204 | EXPORT void CALL UpdateScreen(void); |
205 | EXPORT void CALL ViStatusChanged(void); |
206 | EXPORT void CALL ViWidthChanged(void); |
207 | EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front); |
208 | EXPORT void CALL SetRenderingCallback(void (*callback)(int)); |
209 | EXPORT void CALL ResizeVideoOutput(int width, int height); |
210 | #endif |
211 | |
212 | /* frame buffer plugin spec extension */ |
213 | typedef struct |
214 | { |
215 | unsigned int addr; |
216 | unsigned int size; |
217 | unsigned int width; |
218 | unsigned int height; |
219 | } FrameBufferInfo; |
220 | typedef void (*ptr_FBRead)(unsigned int addr); |
221 | typedef void (*ptr_FBWrite)(unsigned int addr, unsigned int size); |
222 | typedef void (*ptr_FBGetFrameBufferInfo)(void *p); |
223 | #if defined(M64P_PLUGIN_PROTOTYPES) |
224 | EXPORT void CALL FBRead(unsigned int addr); |
225 | EXPORT void CALL FBWrite(unsigned int addr, unsigned int size); |
226 | EXPORT void CALL FBGetFrameBufferInfo(void *p); |
227 | #endif |
228 | |
229 | /* audio plugin function pointers */ |
230 | typedef void (*ptr_AiDacrateChanged)(int SystemType); |
231 | typedef void (*ptr_AiLenChanged)(void); |
232 | typedef int (*ptr_InitiateAudio)(AUDIO_INFO Audio_Info); |
233 | typedef void (*ptr_ProcessAList)(void); |
234 | typedef void (*ptr_SetSpeedFactor)(int percent); |
235 | typedef void (*ptr_VolumeUp)(void); |
236 | typedef void (*ptr_VolumeDown)(void); |
237 | typedef int (*ptr_VolumeGetLevel)(void); |
238 | typedef void (*ptr_VolumeSetLevel)(int level); |
239 | typedef void (*ptr_VolumeMute)(void); |
240 | typedef const char * (*ptr_VolumeGetString)(void); |
241 | #if defined(M64P_PLUGIN_PROTOTYPES) |
242 | EXPORT void CALL AiDacrateChanged(int SystemType); |
243 | EXPORT void CALL AiLenChanged(void); |
244 | EXPORT int CALL InitiateAudio(AUDIO_INFO Audio_Info); |
245 | EXPORT void CALL ProcessAList(void); |
246 | EXPORT void CALL SetSpeedFactor(int percent); |
247 | EXPORT void CALL VolumeUp(void); |
248 | EXPORT void CALL VolumeDown(void); |
249 | EXPORT int CALL VolumeGetLevel(void); |
250 | EXPORT void CALL VolumeSetLevel(int level); |
251 | EXPORT void CALL VolumeMute(void); |
252 | EXPORT const char * CALL VolumeGetString(void); |
253 | #endif |
254 | |
255 | /* input plugin function pointers */ |
256 | typedef void (*ptr_ControllerCommand)(int Control, unsigned char *Command); |
257 | typedef void (*ptr_GetKeys)(int Control, BUTTONS *Keys); |
258 | typedef void (*ptr_InitiateControllers)(CONTROL_INFO ControlInfo); |
259 | typedef void (*ptr_ReadController)(int Control, unsigned char *Command); |
260 | typedef void (*ptr_SDL_KeyDown)(int keymod, int keysym); |
261 | typedef void (*ptr_SDL_KeyUp)(int keymod, int keysym); |
262 | typedef void (*ptr_RenderCallback)(void); |
263 | #if defined(M64P_PLUGIN_PROTOTYPES) |
264 | EXPORT void CALL ControllerCommand(int Control, unsigned char *Command); |
265 | EXPORT void CALL GetKeys(int Control, BUTTONS *Keys); |
266 | EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo); |
267 | EXPORT void CALL ReadController(int Control, unsigned char *Command); |
268 | EXPORT void CALL SDL_KeyDown(int keymod, int keysym); |
269 | EXPORT void CALL SDL_KeyUp(int keymod, int keysym); |
270 | EXPORT void CALL RenderCallback(void); |
271 | #endif |
272 | |
273 | /* RSP plugin function pointers */ |
274 | typedef unsigned int (*ptr_DoRspCycles)(unsigned int Cycles); |
275 | typedef void (*ptr_InitiateRSP)(RSP_INFO Rsp_Info, unsigned int *CycleCount); |
276 | #if defined(M64P_PLUGIN_PROTOTYPES) |
277 | EXPORT unsigned int CALL DoRspCycles(unsigned int Cycles); |
278 | EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, unsigned int *CycleCount); |
279 | #endif |
280 | |
281 | #ifdef __cplusplus |
282 | } |
283 | #endif |
284 | |
285 | #endif /* M64P_PLUGIN_H */ |
286 | |
287 | |
288 | |