Difference between revisions of "Mupen64Plus v2.0 Plugin API"

From Mupen64Plus Wiki
Jump to: navigation, search
(Created page with "Mupen64Plus v2.0 API = Mupen64Plus v2.0 Plugin API = This section lists all of the functions which are exported by the plugins. The front-...")
 
(No difference)

Latest revision as of 22:48, 21 July 2015

Mupen64Plus v2.0 API

Mupen64Plus v2.0 Plugin API

This section lists all of the functions which are exported by the plugins. The front-end application should only use the PluginStartup, PluginShutdown, and PluginGetVersion functions. All other functions will only be called from the core.

Common Plugin API

These functions are present in all of the plugins.

Prototype m64p_error PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context, void (*DebugCallback)(void *Context, int level, const char *Message))
Input Parameters CoreLibHandle Dynamic library handle (defined in m64p_types.h) corresponding with the core mupen64plus library.

Context Pointer which will be passed back to the DebugCallback function. Can be NULL.
DebugCallback Pointer to function in front-end for receiving debug information and warnings from the plugin. This function must be thread-safe. Can be NULL.

Requirements This function must be called before any other plugin functions. The Core library must already be started before calling this function. This function must be called before attaching the plugin to the core.
Usage This function initializes plugin for use by allocating memory, creating data structures, and loading the configuration data. This function may return M64ERR_INCOMPATIBLE if an older core library is used with a newer plugin.


Prototype m64p_error PluginShutdown(void)
Requirements This plugin should be detached from the core before calling this function.
Usage This function destroys data structures and releases memory allocated by the plugin library.


Prototype m64p_error PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion, int *APIVersion, const char **PluginNamePtr, int *Capabilities)
Input Parameters PluginType Pointer to an enumerated type to store the plugin type of this plugin.

PluginVersion Pointer to an integer to store the version number of this plugin. Version number 2.1.3 would be stored as 0x00020103.
APIVersion Pointer to an integer to store the version number of the Core-Plugin API for this type of plugin used by this plugin.
PluginNamePtr Pointer to a const character pointer to receive the name of this plugin. The const char * which is returned must point to a persistent string (ie, not stored on the stack).
Capabilities Pointer to an integer to store a logically-or'd set of flags which specify the capabilities of the plugin which were built into the library during compilation. These are currently only defined for the core, so this will always return 0 for a plugin.

Usage This function retrieves version information from the plugin. This function is the same for the core library and the plugins, so that a front-end may examine all shared libraries in a directory and determine their types. Any of the input parameters may be set to NULL and this function will succeed but won't return the corresponding information.

Video Plugin API

Mupen64Plus v2.0 Video Plugin API

void ChangeWindow(void); Toggle Fullscreen/Windowed mode
BOOL InitiateGFX(GFX_INFO Gfx_Info); Called during CoreAttachPlugin to send info about the emulator core to the graphics plugin and start up the graphics sub-system. This should create the rendering window and the OpenGL context.
void MoveScreen(int xpos, int ypos); This function is called in response to the emulator receiving a WM_MOVE, passing the xpos and ypos from that message.
void ProcessDList(void); Process high-level graphics D-list. (not currently used)
void ProcessRDPList(void); Process low-level graphics D-list.
void RomClosed(void); Called after the emulator is stopped.
int RomOpen(void); Called just before the emulator begins executing a ROM. ***changed*** - this function now returns an int (boolean)
void ShowCFB (void); Called from the RSP plugin to signal a condition to the video plugin.
void UpdateScreen(void); This function is called in response to a VSync condition if the VI bit in MI_INTR_REG is set
void ViStatusChanged(void); This function is called to notify the video plugin that the ViStatus registers value has been changed.
void ViWidthChanged(void); This function is called to notify the video plugin that the ViWidth registers value has been changed.
void ReadScreen2(void *dest, int *width, int *height, int front); This function reads the pixels of the frame buffer that is either currently displayed (front != 0) or being drawn (front == 0)
void SetRenderingCallback(void (*callback)(int bScreenRedrawn)); Allows the core to register a callback function that will be called by the graphics plugin just before the the frame buffers are swapped. ***changed*** - as of video api v2.1.0, the callback function must take a single int (boolean) parameter, which tells the core whether or not the screen has been redrawn since the last time the callback was called. This is used to prevent screenshots from containing OSD text.
void ResizeVideoOutput(int width, int height); ***new*** function added in video api v2.2.0 This function notifies the video plugin that the output video window has changed size. If resizing is supported, the video plugin should update its internal state to reflect the new window size, and then call the ResizeWindow function in the Video Extension API.
void FBRead(unsigned int addr) Read data from frame buffer into emulated RAM space
void FBWrite(unsigned int addr, unsigned int size) Write data from emulated RAM space into frame buffer
void FBGetFrameBufferInfo(void *p) Get some information about the frame buffer

Remove From Older Video API

void CaptureScreen (char * Directory);
void CloseDLL(void);
void DllAbout(HWND hParent);
void DllConfig(HWND hParent);
void DllTest(HWND hParent);
void DrawScreen(void);
void GetDllInfo(PLUGIN_INFO *PluginInfo);
void ReadScreen(void **dest, int *width, int *height);
void SetConfigDir(char *configDir);

typedef struct {...} PLUGIN_INFO

Audio Plugin API

Mupen64Plus v2.0 Audio Plugin API

void AiDacrateChanged(int SystemType); This function is called to notify the audio plugin that the AiDacrate register's value has been changed.
void AiLenChanged(void); This function is called to notify the audio plugin that the AiLen register's value has been changed.
BOOL InitiateAudio(AUDIO_INFO Audio_Info); Called during CoreAttachPlugin to send info about the emulator core to the audio plugin.
void ProcessAList(void); Signal that there is an A-list to be processed. (not currently used)
int RomOpen(void); Called just before the emulator begins executing a ROM. ***changed*** - this function now returns an int (boolean)
void RomClosed(void); Called after the emulator is stopped.
void SetSpeedFactor(int percent); Called when the emulator playback speed changes.
void VolumeUp(void);

void VolumeDown(void);

Increase or decrease volume level
int VolumeGetLevel(void); Get current volume level in percentage, between 0 and 100. ***NEW***
void VolumeSetLevel(int level); Set current volume level. level must be between 0 and 100. ***NEW***
void VolumeMute(void); Toggle between audio muted and un-muted
const char * VolumeGetString(void); Return a string describing the current volume level

Remove From Older Audio API

DWORD AiReadLength(void);
void AiUpdate(BOOL Wait);
void CloseDLL(void);
void DllAbout(HWND hParent);
void DllConfig(HWND hParent);
void DllTest(HWND hParent);
void GetDllInfo(PLUGIN_INFO *PluginInfo);
BOOL PauseAudio(BOOL Pause);
void SetConfigDir(char *configDir);

typedef struct {...} PLUGIN_INFO

Input Plugin API

Mupen64Plus v2.0 Input Plugin API

void ControllerCommand(int Control, BYTE * Command); Process the raw data that has just been sent to a specific controller.
void GetKeys(int Control, BUTTONS * Keys); Get the current state of the controller's buttons
void InitiateControllers(CONTROL_INFO ControlInfo); Setup controller data structures
void ReadController(int Control, BYTE *Command); Process the raw data in the pif ram that is about to be read. (not currently used)
int RomOpen(void); Called just before the emulator begins executing a ROM. ***changed*** - this function now returns an int (boolean)
void RomClosed(void); Called after the emulator is stopped.
void SDL_KeyDown(int keymod, int keysym); Pass a SDL_KEYDOWN-style message to the input plugin
void SDL_KeyUp(int keymod, int keysym); Pass a SDL_KEYUP-style message to the input plugin

Remove From Older Input API

void CloseDLL(void);
void DllAbout(HWND hParent);
void DllConfig(HWND hParent);
void DllTest(HWND hParent);
void GetDllInfo(PLUGIN_INFO *PluginInfo);
void SetConfigDir(char *configDir);
void WM_KeyDown(WPARAM wParam, LPARAM lParam);
void WM_KeyUp(WPARAM wParam, LPARAM lParam);

typedef struct {...} PLUGIN_INFO

RSP Plugin API

Mupen64Plus v2.0 RSP Plugin API

DWORD DoRspCycles(DWORD Cycles); Process pending RSP tasks.
void InitiateRSP(RSP_INFO Rsp_Info, DWORD *CycleCount); Called during CoreAttachPlugin to send info about the emulator core to the audio plugin.
void RomClosed(void); Called after the emulator is stopped.

Remove From Older RSP API

void CloseDLL(void);
void DllAbout(HWND hParent);
void DllConfig(HWND hParent);
void DllTest(HWND hParent);
void GetDllInfo(PLUGIN_INFO *PluginInfo);
void GetRspDebugInfo(RSPDEBUG_INFO * RSPDebugInfo);
void InitiateRSPDebugger(DEBUG_INFO DebugInfo);

typedef struct {...} PLUGIN_INFO
typedef struct {...} RSPDEBUG_INFO
typedef struct {...} DEBUG_INFO