451ab91e |
1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | * Mupen64plus-core - m64p_plugin.h * |
3 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * |
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 | |
39 | /***** Structures *****/ |
40 | typedef struct { |
41 | unsigned char * RDRAM; |
42 | unsigned char * DMEM; |
43 | unsigned char * IMEM; |
44 | |
45 | unsigned int * MI_INTR_REG; |
46 | |
47 | unsigned int * SP_MEM_ADDR_REG; |
48 | unsigned int * SP_DRAM_ADDR_REG; |
49 | unsigned int * SP_RD_LEN_REG; |
50 | unsigned int * SP_WR_LEN_REG; |
51 | unsigned int * SP_STATUS_REG; |
52 | unsigned int * SP_DMA_FULL_REG; |
53 | unsigned int * SP_DMA_BUSY_REG; |
54 | unsigned int * SP_PC_REG; |
55 | unsigned int * SP_SEMAPHORE_REG; |
56 | |
57 | unsigned int * DPC_START_REG; |
58 | unsigned int * DPC_END_REG; |
59 | unsigned int * DPC_CURRENT_REG; |
60 | unsigned int * DPC_STATUS_REG; |
61 | unsigned int * DPC_CLOCK_REG; |
62 | unsigned int * DPC_BUFBUSY_REG; |
63 | unsigned int * DPC_PIPEBUSY_REG; |
64 | unsigned int * DPC_TMEM_REG; |
65 | |
66 | void (*CheckInterrupts)(void); |
67 | void (*ProcessDlistList)(void); |
68 | void (*ProcessAlistList)(void); |
69 | void (*ProcessRdpList)(void); |
70 | void (*ShowCFB)(void); |
71 | } RSP_INFO; |
72 | |
73 | typedef struct { |
74 | unsigned char * HEADER; /* This is the rom header (first 40h bytes of the rom) */ |
75 | unsigned char * RDRAM; |
76 | unsigned char * DMEM; |
77 | unsigned char * IMEM; |
78 | |
79 | unsigned int * MI_INTR_REG; |
80 | |
81 | unsigned int * DPC_START_REG; |
82 | unsigned int * DPC_END_REG; |
83 | unsigned int * DPC_CURRENT_REG; |
84 | unsigned int * DPC_STATUS_REG; |
85 | unsigned int * DPC_CLOCK_REG; |
86 | unsigned int * DPC_BUFBUSY_REG; |
87 | unsigned int * DPC_PIPEBUSY_REG; |
88 | unsigned int * DPC_TMEM_REG; |
89 | |
90 | unsigned int * VI_STATUS_REG; |
91 | unsigned int * VI_ORIGIN_REG; |
92 | unsigned int * VI_WIDTH_REG; |
93 | unsigned int * VI_INTR_REG; |
94 | unsigned int * VI_V_CURRENT_LINE_REG; |
95 | unsigned int * VI_TIMING_REG; |
96 | unsigned int * VI_V_SYNC_REG; |
97 | unsigned int * VI_H_SYNC_REG; |
98 | unsigned int * VI_LEAP_REG; |
99 | unsigned int * VI_H_START_REG; |
100 | unsigned int * VI_V_START_REG; |
101 | unsigned int * VI_V_BURST_REG; |
102 | unsigned int * VI_X_SCALE_REG; |
103 | unsigned int * VI_Y_SCALE_REG; |
104 | |
105 | void (*CheckInterrupts)(void); |
106 | } GFX_INFO; |
107 | |
108 | typedef struct { |
109 | unsigned char * RDRAM; |
110 | unsigned char * DMEM; |
111 | unsigned char * IMEM; |
112 | |
113 | unsigned int * MI_INTR_REG; |
114 | |
115 | unsigned int * AI_DRAM_ADDR_REG; |
116 | unsigned int * AI_LEN_REG; |
117 | unsigned int * AI_CONTROL_REG; |
118 | unsigned int * AI_STATUS_REG; |
119 | unsigned int * AI_DACRATE_REG; |
120 | unsigned int * AI_BITRATE_REG; |
121 | |
122 | void (*CheckInterrupts)(void); |
123 | } AUDIO_INFO; |
124 | |
125 | typedef struct { |
126 | int Present; |
127 | int RawData; |
128 | int Plugin; |
129 | } CONTROL; |
130 | |
131 | typedef union { |
132 | unsigned int Value; |
133 | struct { |
134 | unsigned R_DPAD : 1; |
135 | unsigned L_DPAD : 1; |
136 | unsigned D_DPAD : 1; |
137 | unsigned U_DPAD : 1; |
138 | unsigned START_BUTTON : 1; |
139 | unsigned Z_TRIG : 1; |
140 | unsigned B_BUTTON : 1; |
141 | unsigned A_BUTTON : 1; |
142 | |
143 | unsigned R_CBUTTON : 1; |
144 | unsigned L_CBUTTON : 1; |
145 | unsigned D_CBUTTON : 1; |
146 | unsigned U_CBUTTON : 1; |
147 | unsigned R_TRIG : 1; |
148 | unsigned L_TRIG : 1; |
149 | unsigned Reserved1 : 1; |
150 | unsigned Reserved2 : 1; |
151 | |
152 | signed X_AXIS : 8; |
153 | signed Y_AXIS : 8; |
154 | }; |
155 | } BUTTONS; |
156 | |
157 | typedef struct { |
158 | CONTROL *Controls; /* A pointer to an array of 4 controllers .. eg: |
159 | CONTROL Controls[4]; */ |
160 | } CONTROL_INFO; |
161 | |
162 | /* common plugin function pointer types */ |
163 | typedef void (*ptr_RomClosed)(void); |
164 | typedef int (*ptr_RomOpen)(void); |
165 | #if defined(M64P_PLUGIN_PROTOTYPES) |
166 | EXPORT int CALL RomOpen(void); |
167 | EXPORT void CALL RomClosed(void); |
168 | #endif |
169 | |
170 | /* video plugin function pointer types */ |
171 | typedef void (*ptr_ChangeWindow)(void); |
172 | typedef int (*ptr_InitiateGFX)(GFX_INFO Gfx_Info); |
173 | typedef void (*ptr_MoveScreen)(int x, int y); |
174 | typedef void (*ptr_ProcessDList)(void); |
175 | typedef void (*ptr_ProcessRDPList)(void); |
176 | typedef void (*ptr_ShowCFB)(void); |
177 | typedef void (*ptr_UpdateScreen)(void); |
178 | typedef void (*ptr_ViStatusChanged)(void); |
179 | typedef void (*ptr_ViWidthChanged)(void); |
180 | typedef void (*ptr_ReadScreen2)(void *dest, int *width, int *height, int front); |
181 | typedef void (*ptr_SetRenderingCallback)(void (*callback)(int)); |
182 | typedef void (*ptr_ResizeVideoOutput)(int width, int height); |
183 | #if defined(M64P_PLUGIN_PROTOTYPES) |
184 | EXPORT void CALL ChangeWindow(void); |
185 | EXPORT int CALL InitiateGFX(GFX_INFO Gfx_Info); |
186 | EXPORT void CALL MoveScreen(int x, int y); |
187 | EXPORT void CALL ProcessDList(void); |
188 | EXPORT void CALL ProcessRDPList(void); |
189 | EXPORT void CALL ShowCFB(void); |
190 | EXPORT void CALL UpdateScreen(void); |
191 | EXPORT void CALL ViStatusChanged(void); |
192 | EXPORT void CALL ViWidthChanged(void); |
193 | EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front); |
194 | EXPORT void CALL SetRenderingCallback(void (*callback)(int)); |
195 | EXPORT void CALL ResizeVideoOutput(int width, int height); |
196 | #endif |
197 | |
198 | /* frame buffer plugin spec extension */ |
199 | typedef struct |
200 | { |
201 | unsigned int addr; |
202 | unsigned int size; |
203 | unsigned int width; |
204 | unsigned int height; |
205 | } FrameBufferInfo; |
206 | typedef void (*ptr_FBRead)(unsigned int addr); |
207 | typedef void (*ptr_FBWrite)(unsigned int addr, unsigned int size); |
208 | typedef void (*ptr_FBGetFrameBufferInfo)(void *p); |
209 | #if defined(M64P_PLUGIN_PROTOTYPES) |
210 | EXPORT void CALL FBRead(unsigned int addr); |
211 | EXPORT void CALL FBWrite(unsigned int addr, unsigned int size); |
212 | EXPORT void CALL FBGetFrameBufferInfo(void *p); |
213 | #endif |
214 | |
215 | /* audio plugin function pointers */ |
216 | typedef void (*ptr_AiDacrateChanged)(int SystemType); |
217 | typedef void (*ptr_AiLenChanged)(void); |
218 | typedef int (*ptr_InitiateAudio)(AUDIO_INFO Audio_Info); |
219 | typedef void (*ptr_ProcessAList)(void); |
220 | typedef void (*ptr_SetSpeedFactor)(int percent); |
221 | typedef void (*ptr_VolumeUp)(void); |
222 | typedef void (*ptr_VolumeDown)(void); |
223 | typedef int (*ptr_VolumeGetLevel)(void); |
224 | typedef void (*ptr_VolumeSetLevel)(int level); |
225 | typedef void (*ptr_VolumeMute)(void); |
226 | typedef const char * (*ptr_VolumeGetString)(void); |
227 | #if defined(M64P_PLUGIN_PROTOTYPES) |
228 | EXPORT void CALL AiDacrateChanged(int SystemType); |
229 | EXPORT void CALL AiLenChanged(void); |
230 | EXPORT int CALL InitiateAudio(AUDIO_INFO Audio_Info); |
231 | EXPORT void CALL ProcessAList(void); |
232 | EXPORT void CALL SetSpeedFactor(int percent); |
233 | EXPORT void CALL VolumeUp(void); |
234 | EXPORT void CALL VolumeDown(void); |
235 | EXPORT int CALL VolumeGetLevel(void); |
236 | EXPORT void CALL VolumeSetLevel(int level); |
237 | EXPORT void CALL VolumeMute(void); |
238 | EXPORT const char * CALL VolumeGetString(void); |
239 | #endif |
240 | |
241 | /* input plugin function pointers */ |
242 | typedef void (*ptr_ControllerCommand)(int Control, unsigned char *Command); |
243 | typedef void (*ptr_GetKeys)(int Control, BUTTONS *Keys); |
244 | typedef void (*ptr_InitiateControllers)(CONTROL_INFO ControlInfo); |
245 | typedef void (*ptr_ReadController)(int Control, unsigned char *Command); |
246 | typedef void (*ptr_SDL_KeyDown)(int keymod, int keysym); |
247 | typedef void (*ptr_SDL_KeyUp)(int keymod, int keysym); |
248 | #if defined(M64P_PLUGIN_PROTOTYPES) |
249 | EXPORT void CALL ControllerCommand(int Control, unsigned char *Command); |
250 | EXPORT void CALL GetKeys(int Control, BUTTONS *Keys); |
251 | EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo); |
252 | EXPORT void CALL ReadController(int Control, unsigned char *Command); |
253 | EXPORT void CALL SDL_KeyDown(int keymod, int keysym); |
254 | EXPORT void CALL SDL_KeyUp(int keymod, int keysym); |
255 | #endif |
256 | |
257 | /* RSP plugin function pointers */ |
258 | typedef unsigned int (*ptr_DoRspCycles)(unsigned int Cycles); |
259 | typedef void (*ptr_InitiateRSP)(RSP_INFO Rsp_Info, unsigned int *CycleCount); |
260 | #if defined(M64P_PLUGIN_PROTOTYPES) |
261 | EXPORT unsigned int CALL DoRspCycles(unsigned int Cycles); |
262 | EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, unsigned int *CycleCount); |
263 | #endif |
264 | |
265 | #ifdef __cplusplus |
266 | } |
267 | #endif |
268 | |
269 | #endif /* M64P_PLUGIN_H */ |
270 | |
271 | |