Core commit. Compile and run on the OpenPandora
[mupen64plus-pandora.git] / source / mupen64plus-core / src / api / m64p_plugin.h
CommitLineData
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
29extern "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 *****/
40typedef 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
73typedef 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
108typedef 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
125typedef struct {
126 int Present;
127 int RawData;
128 int Plugin;
129} CONTROL;
130
131typedef 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
157typedef 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 */
163typedef void (*ptr_RomClosed)(void);
164typedef int (*ptr_RomOpen)(void);
165#if defined(M64P_PLUGIN_PROTOTYPES)
166EXPORT int CALL RomOpen(void);
167EXPORT void CALL RomClosed(void);
168#endif
169
170/* video plugin function pointer types */
171typedef void (*ptr_ChangeWindow)(void);
172typedef int (*ptr_InitiateGFX)(GFX_INFO Gfx_Info);
173typedef void (*ptr_MoveScreen)(int x, int y);
174typedef void (*ptr_ProcessDList)(void);
175typedef void (*ptr_ProcessRDPList)(void);
176typedef void (*ptr_ShowCFB)(void);
177typedef void (*ptr_UpdateScreen)(void);
178typedef void (*ptr_ViStatusChanged)(void);
179typedef void (*ptr_ViWidthChanged)(void);
180typedef void (*ptr_ReadScreen2)(void *dest, int *width, int *height, int front);
181typedef void (*ptr_SetRenderingCallback)(void (*callback)(int));
182typedef void (*ptr_ResizeVideoOutput)(int width, int height);
183#if defined(M64P_PLUGIN_PROTOTYPES)
184EXPORT void CALL ChangeWindow(void);
185EXPORT int CALL InitiateGFX(GFX_INFO Gfx_Info);
186EXPORT void CALL MoveScreen(int x, int y);
187EXPORT void CALL ProcessDList(void);
188EXPORT void CALL ProcessRDPList(void);
189EXPORT void CALL ShowCFB(void);
190EXPORT void CALL UpdateScreen(void);
191EXPORT void CALL ViStatusChanged(void);
192EXPORT void CALL ViWidthChanged(void);
193EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front);
194EXPORT void CALL SetRenderingCallback(void (*callback)(int));
195EXPORT void CALL ResizeVideoOutput(int width, int height);
196#endif
197
198/* frame buffer plugin spec extension */
199typedef struct
200{
201 unsigned int addr;
202 unsigned int size;
203 unsigned int width;
204 unsigned int height;
205} FrameBufferInfo;
206typedef void (*ptr_FBRead)(unsigned int addr);
207typedef void (*ptr_FBWrite)(unsigned int addr, unsigned int size);
208typedef void (*ptr_FBGetFrameBufferInfo)(void *p);
209#if defined(M64P_PLUGIN_PROTOTYPES)
210EXPORT void CALL FBRead(unsigned int addr);
211EXPORT void CALL FBWrite(unsigned int addr, unsigned int size);
212EXPORT void CALL FBGetFrameBufferInfo(void *p);
213#endif
214
215/* audio plugin function pointers */
216typedef void (*ptr_AiDacrateChanged)(int SystemType);
217typedef void (*ptr_AiLenChanged)(void);
218typedef int (*ptr_InitiateAudio)(AUDIO_INFO Audio_Info);
219typedef void (*ptr_ProcessAList)(void);
220typedef void (*ptr_SetSpeedFactor)(int percent);
221typedef void (*ptr_VolumeUp)(void);
222typedef void (*ptr_VolumeDown)(void);
223typedef int (*ptr_VolumeGetLevel)(void);
224typedef void (*ptr_VolumeSetLevel)(int level);
225typedef void (*ptr_VolumeMute)(void);
226typedef const char * (*ptr_VolumeGetString)(void);
227#if defined(M64P_PLUGIN_PROTOTYPES)
228EXPORT void CALL AiDacrateChanged(int SystemType);
229EXPORT void CALL AiLenChanged(void);
230EXPORT int CALL InitiateAudio(AUDIO_INFO Audio_Info);
231EXPORT void CALL ProcessAList(void);
232EXPORT void CALL SetSpeedFactor(int percent);
233EXPORT void CALL VolumeUp(void);
234EXPORT void CALL VolumeDown(void);
235EXPORT int CALL VolumeGetLevel(void);
236EXPORT void CALL VolumeSetLevel(int level);
237EXPORT void CALL VolumeMute(void);
238EXPORT const char * CALL VolumeGetString(void);
239#endif
240
241/* input plugin function pointers */
242typedef void (*ptr_ControllerCommand)(int Control, unsigned char *Command);
243typedef void (*ptr_GetKeys)(int Control, BUTTONS *Keys);
244typedef void (*ptr_InitiateControllers)(CONTROL_INFO ControlInfo);
245typedef void (*ptr_ReadController)(int Control, unsigned char *Command);
246typedef void (*ptr_SDL_KeyDown)(int keymod, int keysym);
247typedef void (*ptr_SDL_KeyUp)(int keymod, int keysym);
248#if defined(M64P_PLUGIN_PROTOTYPES)
249EXPORT void CALL ControllerCommand(int Control, unsigned char *Command);
250EXPORT void CALL GetKeys(int Control, BUTTONS *Keys);
251EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo);
252EXPORT void CALL ReadController(int Control, unsigned char *Command);
253EXPORT void CALL SDL_KeyDown(int keymod, int keysym);
254EXPORT void CALL SDL_KeyUp(int keymod, int keysym);
255#endif
256
257/* RSP plugin function pointers */
258typedef unsigned int (*ptr_DoRspCycles)(unsigned int Cycles);
259typedef void (*ptr_InitiateRSP)(RSP_INFO Rsp_Info, unsigned int *CycleCount);
260#if defined(M64P_PLUGIN_PROTOTYPES)
261EXPORT unsigned int CALL DoRspCycles(unsigned int Cycles);
262EXPORT 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