1 /******************************************************************************* 2 * Common RSP plugin specifications: version #1.2 created by zilmar * 3 * Revised 2014 by Iconoclast for more compliance, portability and readability. * 4 * * 5 * All questions or suggestions should go through the EmuTalk plugin forum. * 6 * http://www.emutalk.net/forums/showforum.php?f=31 * 7 *******************************************************************************/ 8 9 #ifndef _RSP_H_INCLUDED__ 10 #define _RSP_H_INCLUDED__ 11 12 #include "my_types.h" 13 14 #if defined(__cplusplus) 15 extern "C" { 16 #endif 17 18 #define PLUGIN_TYPE_RSP 1 19 #define PLUGIN_TYPE_GFX 2 20 #define PLUGIN_TYPE_AUDIO 3 21 #define PLUGIN_TYPE_CONTROLLER 4 22 23 #ifndef PLUGIN_API_VERSION 24 #define PLUGIN_API_VERSION 0x0102 25 #endif 26 27 /* old names from the original specification file */ 28 #define hInst hinst 29 #define MemorySwapped MemoryBswaped 30 31 /* 32 * Declare RSP_INFO structure instance as: `RSP_INFO RSP_INFO_NAME;' 33 * ... for the ability to use the below convenience macros. 34 * 35 * Doing the traditional `RSP_INFO rsp_info' declaration has also worked but 36 * requires accessing the RCP registers in a less portable way, for example: 37 * `*(rsp_info).MI_INTR_REG |= MI_INTR_MASK_SP;' 38 * versus 39 * `GET_RCP_REG(MI_INTR_REG) |= MI_INTR_MASK_SP;'. 40 */ 41 #ifndef RSP_INFO_NAME 42 #ifdef M64P_PLUGIN_API 43 #define RSP_INFO_NAME RSP_info 44 #else 45 #define RSP_INFO_NAME RCP_info_SP 46 #endif 47 #define GET_RSP_INFO(member) ((RSP_INFO_NAME).member) 48 #define GET_RCP_REG(member) (*(RSP_INFO_NAME).member) 49 #endif 50 51 typedef struct { 52 i32 left; 53 i32 top; 54 i32 right; 55 i32 bottom; 56 } winapi_rect; 57 58 typedef struct { 59 p_void hdc; 60 int fErase; 61 winapi_rect rcPaint; 62 int fRestore; 63 int fIncUpdate; 64 u8 rgbReserved[32]; 65 } winapi_paintstruct; 66 67 typedef struct { 68 u16 Version; /* Set to PLUGIN_API_VERSION. */ 69 u16 Type; /* Set to PLUGIN_TYPE_RSP. */ 70 char Name[100]; /* plugin title, to help the user select plugins */ 71 72 /* If the plugin supports these memory options, then set them to true. */ 73 int NormalMemory; /* a normal byte array */ 74 int MemorySwapped; /* a normal byte array choosing the client-side, 75 native hardware's endian over the MIPS target's */ 76 } PLUGIN_INFO; 77 78 #if !defined(M64P_PLUGIN_API) 79 typedef struct { 80 p_void hInst; 81 int MemorySwapped; 82 83 pu8 RDRAM; /* CPU-RCP dynamic RAM (sensitive to MemorySwapped flag) */ 84 pu8 DMEM; /* high 4K of SP cache memory (sensitive to MemorySwapped flag) */ 85 pu8 IMEM; /* low 4K of SP cache memory (sensitive to MemorySwapped flag) */ 86 87 pu32 MI_INTR_REG; 88 89 pu32 SP_MEM_ADDR_REG; 90 pu32 SP_DRAM_ADDR_REG; 91 pu32 SP_RD_LEN_REG; 92 pu32 SP_WR_LEN_REG; 93 pu32 SP_STATUS_REG; 94 pu32 SP_DMA_FULL_REG; 95 pu32 SP_DMA_BUSY_REG; 96 pu32 SP_PC_REG; /* This was supposed to be defined AFTER semaphore. */ 97 pu32 SP_SEMAPHORE_REG; 98 #if 0 99 pu32 SP_PC_REG; /* CPU-mapped between SP and DP command buffer regs */ 100 #endif 101 pu32 DPC_START_REG; 102 pu32 DPC_END_REG; 103 pu32 DPC_CURRENT_REG; 104 pu32 DPC_STATUS_REG; 105 pu32 DPC_CLOCK_REG; 106 pu32 DPC_BUFBUSY_REG; 107 pu32 DPC_PIPEBUSY_REG; 108 pu32 DPC_TMEM_REG; 109 110 p_func CheckInterrupts; 111 p_func ProcessDList; 112 p_func ProcessAList; 113 p_func ProcessRdpList; 114 p_func ShowCFB; 115 } RSP_INFO; 116 #endif 117 118 typedef struct { 119 /* menu */ 120 /* Items should have an ID between 5001 and 5100. */ 121 p_void hRSPMenu; 122 void (*ProcessMenuItem)(int ID); 123 124 /* break points */ 125 int UseBPoints; 126 char BPPanelName[20]; 127 p_func Add_BPoint; 128 void (*CreateBPPanel)(p_void hDlg, winapi_rect rcBox); 129 p_func HideBPPanel; 130 void (*PaintBPPanel)(winapi_paintstruct ps); 131 p_void ShowBPPanel; 132 void (*RefreshBpoints)(p_void hList); 133 void (*RemoveBpoint)(p_void hList, int index); 134 p_void RemoveAllBpoint; 135 136 /* RSP command window */ 137 p_func Enter_RSP_Commands_Window; 138 } RSPDEBUG_INFO; 139 140 typedef struct { 141 p_func UpdateBreakPoints; 142 p_func UpdateMemory; 143 p_func UpdateR4300iRegisters; 144 p_func Enter_BPoint_Window; 145 p_func Enter_R4300i_Commands_Window; 146 p_func Enter_R4300i_Register_Window; 147 p_func Enter_RSP_Commands_Window; 148 p_func Enter_Memory_Window; 149 } DEBUG_INFO; 150 151 /****************************************************************************** 152 * name : CloseDLL 153 * optional : no 154 * call time: when the emulator is shutting down or chooses to free memory 155 * input : none 156 * output : none 157 *******************************************************************************/ 158 EXPORT void CALL CloseDLL(void); 159 160 /****************************************************************************** 161 * name : DllAbout 162 * optional : yes 163 * call time: upon a request to see information about the plugin (e.g., authors) 164 * input : a pointer to the window that called this function 165 * output : none 166 *******************************************************************************/ 167 EXPORT void CALL DllAbout(p_void hParent); 168 169 /****************************************************************************** 170 * name : DllConfig 171 * optional : yes 172 * call time: upon a request to configure the plugin (e.g., change settings) 173 * input : a pointer to the window that called this function 174 * output : none 175 *******************************************************************************/ 176 EXPORT void CALL DllConfig(p_void hParent); 177 178 /****************************************************************************** 179 * name : DllTest 180 * optional : yes 181 * call time: upon a request to test the plugin (e.g., system capabilities) 182 * input : a pointer to the window that called this function 183 * output : none 184 *******************************************************************************/ 185 EXPORT void CALL DllTest(p_void hParent); 186 187 /****************************************************************************** 188 * name : DoRspCycles 189 * optional : no 190 * call time: when the R4300 CPU alternates control to execute on the RSP 191 * input : number of cycles meant to be executed (for segmented execution) 192 * output : The number of cycles executed also was intended for cycle-timing 193 * attempts, much like Project64 itself originally was, and requires 194 * individual experiment. This value is ignored if the RSP CPU flow 195 * was halted when the function completed. In-depth debate: 196 * http://www.emutalk.net/showthread.php?t=43088 197 *******************************************************************************/ 198 EXPORT u32 CALL DoRspCycles(u32 Cycles); 199 200 /****************************************************************************** 201 * name : GetDllInfo 202 * optional : no 203 * call time: during the enumeration of valid plugins the emulator can load 204 * input : a pointer to a PLUGIN_INFO stucture used to determine support 205 * output : none 206 *******************************************************************************/ 207 EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); 208 209 /****************************************************************************** 210 * name : GetRspDebugInfo 211 * optional : yes 212 * call time: when the emulator requests information about what the RSP plugin 213 * is and is not programmed to debug 214 * input : a pointer to a RSPDEBUG_INFO stucture to determine capabilities 215 * output : none 216 *******************************************************************************/ 217 EXPORT void CALL GetRspDebugInfo(RSPDEBUG_INFO * RSPDebugInfo); 218 219 /****************************************************************************** 220 * name : InitiateRSP 221 * optional : no 222 * call time: after the emulator has successfully loaded the plugin but needs 223 * more information about it before proceeding to start emulation 224 * input : a RSP_INFO structure mostly for setting up the RCP memory map 225 * output : none 226 *******************************************************************************/ 227 EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, pu32 CycleCount); 228 229 /****************************************************************************** 230 * name : InitiateRSPDebugger 231 * optional : yes 232 * call time: after plugin load, when the emulator is ready to supply an 233 * informational structure useful to the RSP plugin for integrating 234 * its debugger, if any, with the rest of the emulator 235 * input : a DEBUG_INFO structure offering debugger integration information 236 * output : none 237 *******************************************************************************/ 238 EXPORT void CALL InitiateRSPDebugger(DEBUG_INFO DebugInfo); 239 240 /****************************************************************************** 241 * name : RomClosed 242 * optional : no 243 * call time: when unloading the ROM (sometimes when emulation ends) 244 * input : none 245 * output : none 246 *******************************************************************************/ 247 EXPORT void CALL RomClosed(void); 248 249 /* 250 * required?? in version #1.2 of the RSP plugin spec 251 * Have not tested a #1.2 implementation yet so shouldn't document them yet. 252 * 253 * Most of these functions were made to inhibit private plugin distribution 254 * from Project64 in its commercial state, and there is no documentation of 255 * these in the source to Project64 2.x as of yet. 256 */ 257 #if (PLUGIN_API_VERSION >= 0x0102) && !defined(M64P_PLUGIN_API) 258 EXPORT void CALL RomOpen(void); 259 EXPORT void CALL EnableDebugging(int Enabled); 260 EXPORT void CALL PluginLoaded(void); 261 #endif 262 263 /************ profiling **************/ 264 #define Default_ProfilingOn 0 265 #define Default_IndvidualBlock 0 266 #define Default_ShowErrors 0 267 #define Default_AudioHle 0 268 269 #define InterpreterCPU 0 270 #define RecompilerCPU 1 271 272 #if defined(__cplusplus) 273 } 274 #endif 275 276 #endif 277