Commits

Anonymous committed 25dd82f Draft

Minimum changes necessary to get Glide64 Napalm running on Mupen64Plus.

To build (after installing all deeps) run:

cd Glide64
APIDIR=/path/to/mupen64plus/source/mupen64plus-core/src/api make -f Makefile.gcc

Then copy Glide64.[dll/so/dynlib] to the plugin directory, and config/Glide64.ini to the config directory.

  • Participants
  • Parent commits 95430f8

Comments (0)

Files changed (10)

File Glide64/3dmath.cpp

 
 void math_init()
 {
-#ifndef _DEBUG
-  int iecx = 0, iedx = 0;
-
-  GLIDE64_TRY
-  {
-    DetectSIMD(0x0000001, &iedx, &iecx);
-  }
-  GLIDE64_CATCH
-  {
-    return;
-  }
-  if (iedx & 0x2000000) //SSE
-  {
-    MulMatrices = MulMatricesSSE;
-    TransformVector = TransformVectorSSE;
-    //InverseTransformVector = InverseTransformVectorSSE;
-    //NormalizeVector = NormalizeVectorSSE; /* not ready yet */
-    LOG("SSE detected.\n");
-  }
-  if (iedx & 0x4000000) // SSE2
-  {
-    LOG("SSE2 detected.\n");
-  }
-  if (iecx & 0x1) // SSE3
-  {
-    //DotProduct = DotProductSSE3; /* not ready yet */
-    LOG("SSE3 detected.\n");
-  }
-  // the 3dnow version is faster than sse
-  iecx = 0;
-  iedx = 0;
-  GLIDE64_TRY
-  {
-    DetectSIMD(0x80000001, &iedx, &iecx);
-  }
-  GLIDE64_CATCH
-  {
-    return;
-  }
-  if (iedx & 0x80000000) //3DNow!
-  {
-    MulMatrices = MulMatrices3DNOW;
-    TransformVector = TransformVector3DNOW;
-    InverseTransformVector = InverseTransformVector3DNOW;
-    //DotProduct = DotProduct3DNOW;  //not ready yet 
-    NormalizeVector = NormalizeVector3DNOW; // not ready yet 
-    LOG("3DNOW! detected.\n");
-  }
-#endif //_DEBUG
 }

File Glide64/DepthBufferRender.cpp

 static int right_x, right_dxdy, left_x, left_dxdy;
 static int left_z, left_dzdy;
 
-extern "C" int imul16(int x, int y);
-extern "C" int imul14(int x, int y);
-extern "C" int idiv16(int x, int y);
-
 __inline int iceil(int x)
 {
-  x +=  0xffff;
-  return (x >> 16);
+    x +=  0xffff;
+    return (x >> 16);
+}
+
+__inline int imul16(int x, int y)        // (x * y) >> 16
+{
+    return (((long long)x) * ((long long)y)) >> 16;
+}
+
+__inline int imul14(int x, int y)        // (x * y) >> 14
+{
+    return (((long long)x) * ((long long)y)) >> 14;
+}
+
+/*
+int idiv16(int x, int y);        // (x << 16) / y
+#pragma aux idiv16 = \
+    " mov   edx,eax    "\
+    " sar   edx,16     "\
+    " shl   eax,16     "\
+    " idiv  ebx        "\
+    parm [eax] [ebx] modify exact [eax edx] value [eax]
+*/
+__inline int idiv16(int x, int y)        // (x << 16) / y
+{
+    //x = (((long long)x) << 16) / ((long long)y);
+#if !defined(__GNUC__) && !defined(NO_ASM)
+  __asm {
+        mov   eax, x
+        mov   ebx, y
+        mov   edx,eax   
+        sar   edx,16
+        shl   eax,16    
+        idiv  ebx  
+        mov   x, eax
+    }
+#elif !defined(NO_ASM)
+    int reminder;
+    asm ("idivl %[divisor]"
+          : "=a" (x), "=d" (reminder)
+          : [divisor] "g" (y), "d" (x >> 16), "a" (x << 16));
+#endif
+    return x;
 }
 
 static void RightSection(void)

File Glide64/Gfx #1.3.h

 
 #ifndef _GFX_H_INCLUDED__
 #define _GFX_H_INCLUDED__
+#include "m64p.h"
 
 #include <wx/wx.h>
 #include <wx/dynlib.h>
 /* Plugin types */
 #define PLUGIN_TYPE_GFX				2
 
-#ifdef __WINDOWS__
-#define EXPORT					__declspec(dllexport)
-#define CALL						_cdecl
-#else
-#define EXPORT					extern
-#define CALL
-#endif
-
 /***** Structures *****/
 typedef struct {
 	wxUint16 Version;        /* Set to 0x0103 */
 	                          bswap on a dword (32 bits) boundry */
 } PLUGIN_INFO;
 
-typedef struct {
-	HWND hWnd;			/* Render window */
-	HWND hStatusBar;    /* if render window does not have a status bar then this is NULL */
-
-	int MemoryBswaped;    // If this is set to TRUE, then the memory has been pre
-	                       //   bswap on a dword (32 bits) boundry
-						   //	eg. the first 8 bytes are stored like this:
-	                       //        4 3 2 1   8 7 6 5
-
-	wxUint8 * HEADER;	// This is the rom header (first 40h bytes of the rom
-					// This will be in the same memory format as the rest of the memory.
-	wxUint8 * RDRAM;
-	wxUint8 * DMEM;
-	wxUint8 * IMEM;
-
-	wxUint32 * MI_INTR_REG;
-
-	wxUint32 * DPC_START_REG;
-	wxUint32 * DPC_END_REG;
-	wxUint32 * DPC_CURRENT_REG;
-	wxUint32 * DPC_STATUS_REG;
-	wxUint32 * DPC_CLOCK_REG;
-	wxUint32 * DPC_BUFBUSY_REG;
-	wxUint32 * DPC_PIPEBUSY_REG;
-	wxUint32 * DPC_TMEM_REG;
-
-	wxUint32 * VI_STATUS_REG;
-	wxUint32 * VI_ORIGIN_REG;
-	wxUint32 * VI_WIDTH_REG;
-	wxUint32 * VI_INTR_REG;
-	wxUint32 * VI_V_CURRENT_LINE_REG;
-	wxUint32 * VI_TIMING_REG;
-	wxUint32 * VI_V_SYNC_REG;
-	wxUint32 * VI_H_SYNC_REG;
-	wxUint32 * VI_LEAP_REG;
-	wxUint32 * VI_H_START_REG;
-	wxUint32 * VI_V_START_REG;
-	wxUint32 * VI_V_BURST_REG;
-	wxUint32 * VI_X_SCALE_REG;
-	wxUint32 * VI_Y_SCALE_REG;
-
-	void (*CheckInterrupts)( void );
-} GFX_INFO;
-
 extern GFX_INFO gfx;
 extern wxWindow * GFXWindow;
 extern bool no_dlist;
 *******************************************************************/
 EXPORT void CALL DllTest ( HWND hParent );
 
+EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
+                                     void (*DebugCallback)(void *, int, const char *));
+EXPORT m64p_error CALL PluginShutdown(void);
+EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion,    
+                                        int *APIVersion, const char **PluginNamePtr,
+                                        int *Capabilities);
 
-EXPORT void CALL ReadScreen(void **dest, int *width, int *height);
+EXPORT void CALL ReadScreen(void *dest, int *width, int *height);
+EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front);
 
 /******************************************************************
   Function: DrawScreen
   input:    none
   output:   none
 *******************************************************************/
-EXPORT void CALL RomOpen (void);
+EXPORT int CALL RomOpen (void);
 
 /******************************************************************
   Function: ShowCFB
   input:    path to config directory
   output:   none
 *******************************************************************/
-EXPORT void CALL SetConfigDir(char *configDir);
+EXPORT void CALL SetConfigDir(const char *configDir);
+
+/******************************************************************
+   NOTE: THIS HAS BEEN ADDED FOR MUPEN64PLUS AND IS NOT PART OF THE
+         ORIGINAL SPEC
+  Function: SetRenderingCallback
+  Purpose:  Allows emulator to register a callback function that will
+            be called by the graphics plugin just before the the
+            frame buffers are swapped.
+            This was added as a way for the emulator to draw emulator-
+            specific things to the screen, e.g. On-screen display.
+  input:    pointer to callback function. The function expects
+            to receive the current window width and height.
+  output:   none
+*******************************************************************/
+EXPORT void CALL SetRenderingCallback(void (*callback)());
 
 #if defined(__cplusplus)
 }

File Glide64/Main.cpp

 #include "FBtoScreen.h"
 #include "DepthBufferRender.h"
 
+#include "osal_dynamiclib.h"
+
 #ifdef TEXTURE_FILTER // Hiroshi Morii <koolsmoky@users.sourceforge.net>
 #include <stdarg.h>
 int  ghq_dmptex_toggle_key = 0;
 #endif
 
 GFX_INFO gfx;
+/* definitions of pointers to Core config functions */
+ptr_ConfigOpenSection      ConfigOpenSection = NULL;
+ptr_ConfigSetParameter     ConfigSetParameter = NULL;
+ptr_ConfigGetParameter     ConfigGetParameter = NULL;
+ptr_ConfigGetParameterHelp ConfigGetParameterHelp = NULL;
+ptr_ConfigSetDefaultInt    ConfigSetDefaultInt = NULL;
+ptr_ConfigSetDefaultFloat  ConfigSetDefaultFloat = NULL;
+ptr_ConfigSetDefaultBool   ConfigSetDefaultBool = NULL;
+ptr_ConfigSetDefaultString ConfigSetDefaultString = NULL;
+ptr_ConfigGetParamInt      ConfigGetParamInt = NULL;
+ptr_ConfigGetParamFloat    ConfigGetParamFloat = NULL;
+ptr_ConfigGetParamBool     ConfigGetParamBool = NULL;
+ptr_ConfigGetParamString   ConfigGetParamString = NULL;
+
+ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
+ptr_ConfigGetUserConfigPath     ConfigGetUserConfigPath = NULL;
+ptr_ConfigGetUserDataPath       ConfigGetUserDataPath = NULL;
+ptr_ConfigGetUserCachePath      ConfigGetUserCachePath = NULL;
+
+/* definitions of pointers to Core video extension functions */
+ptr_VidExt_Init                  CoreVideo_Init = NULL;
+ptr_VidExt_Quit                  CoreVideo_Quit = NULL;
+ptr_VidExt_ListFullscreenModes   CoreVideo_ListFullscreenModes = NULL;
+ptr_VidExt_SetVideoMode          CoreVideo_SetVideoMode = NULL;
+ptr_VidExt_SetCaption            CoreVideo_SetCaption = NULL;
+ptr_VidExt_ToggleFullScreen      CoreVideo_ToggleFullScreen = NULL;
+ptr_VidExt_GL_GetProcAddress     CoreVideo_GL_GetProcAddress = NULL;
+ptr_VidExt_GL_SetAttribute       CoreVideo_GL_SetAttribute = NULL;
+ptr_VidExt_GL_SwapBuffers        CoreVideo_GL_SwapBuffers = NULL;
 wxWindow * GFXWindow = NULL;
 
 int to_fullscreen = FALSE;
 int    capture_screen = 0;
 wxString capture_path;
 
+void (*renderCallback)() = NULL;
+
 wxString pluginPath;
 wxString iniPath;
 wxString iniName;
   input:    path to config directory
   output:   none
 *******************************************************************/
-EXPORT void CALL SetConfigDir(char *configDir)
+EXPORT void CALL SetConfigDir(const char *configDir)
 {
-  wxString dirName(configDir, wxConvUTF8);
-  wxString path = wxPathOnly(dirName);
-  if (wxDirExists(path))
-  {
-    iniName = path + wxT("/Glide64.ini");
-    iniPath = path;
-  }
+  iniName = wxString(configDir, wxConvUTF8);
+  iniPath = wxPathOnly(iniName);
 }
 
 static void PluginPath()
     char strSstWinOpenExt[] ="grSstWinOpenExt";
     GRWINOPENEXT grSstWinOpenExt = (GRWINOPENEXT)grGetProcAddress(strSstWinOpenExt);
     if (grSstWinOpenExt)
-      gfx_context = grSstWinOpenExt (wxPtrToUInt(gfx.hWnd),
+      gfx_context = grSstWinOpenExt ((FxU32)NULL,
       res_data,
       GR_REFRESH_60Hz,
       GR_COLORFORMAT_RGBA,
       1);   // 1 auxillary buffer
   }
   if (!gfx_context)
-    gfx_context = grSstWinOpen (wxPtrToUInt(gfx.hWnd),
+    gfx_context = grSstWinOpen ((FxU32)NULL,
     res_data,
     GR_REFRESH_60Hz,
     GR_COLORFORMAT_RGBA,
 }
 #endif
 
-void CALL ReadScreen(void **dest, int *width, int *height)
+void CALL ReadScreen(void *dest, int *width, int *height)
 {
   *width = settings.res_x;
   *height = settings.res_y;
   wxUint8 * buff = (wxUint8*)malloc(settings.res_x * settings.res_y * 3);
   wxUint8 * line = buff;
-  *dest = (void*)buff;
+  dest = (void*)buff;
 
   if (!fullscreen)
   {
   LOG ("ReadScreen. Success.\n");
 }
 
+void CALL ReadScreen2(void *dest, int *width, int *height, int front)
+{
+  ReadScreen(dest, width, height);
+}
+
+EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
+                                   void (*DebugCallback)(void *, int, const char *))
+{
+    ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreLibHandle, "ConfigOpenSection");
+    ConfigSetParameter = (ptr_ConfigSetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigSetParameter");
+    ConfigGetParameter = (ptr_ConfigGetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParameter");
+    ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultInt");
+    ConfigSetDefaultFloat = (ptr_ConfigSetDefaultFloat) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultFloat");
+    ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultBool");
+    ConfigSetDefaultString = (ptr_ConfigSetDefaultString) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultString");
+    ConfigGetParamInt = (ptr_ConfigGetParamInt) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamInt");
+    ConfigGetParamFloat = (ptr_ConfigGetParamFloat) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamFloat");
+    ConfigGetParamBool = (ptr_ConfigGetParamBool) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamBool");
+    ConfigGetParamString = (ptr_ConfigGetParamString) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamString");
+
+    ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) osal_dynlib_getproc(CoreLibHandle, "ConfigGetSharedDataFilepath");
+    ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) osal_dynlib_getproc(CoreLibHandle, "ConfigGetUserConfigPath");
+    ConfigGetUserDataPath = (ptr_ConfigGetUserDataPath) osal_dynlib_getproc(CoreLibHandle, "ConfigGetUserDataPath");
+    ConfigGetUserCachePath = (ptr_ConfigGetUserCachePath) osal_dynlib_getproc(CoreLibHandle, "ConfigGetUserCachePath");
+
+    if (!ConfigOpenSection   || !ConfigSetParameter    || !ConfigGetParameter ||
+        !ConfigSetDefaultInt || !ConfigSetDefaultFloat || !ConfigSetDefaultBool || !ConfigSetDefaultString ||
+        !ConfigGetParamInt   || !ConfigGetParamFloat   || !ConfigGetParamBool   || !ConfigGetParamString ||
+        !ConfigGetSharedDataFilepath || !ConfigGetUserConfigPath || !ConfigGetUserDataPath || !ConfigGetUserCachePath)
+    {
+        LOG("Couldn't connect to Core configuration functions\n");
+        return M64ERR_INCOMPATIBLE;
+    }
+
+    /* Get the core Video Extension function pointers from the library handle */
+    CoreVideo_Init = (ptr_VidExt_Init) osal_dynlib_getproc(CoreLibHandle, "VidExt_Init");
+    CoreVideo_Quit = (ptr_VidExt_Quit) osal_dynlib_getproc(CoreLibHandle, "VidExt_Quit");
+    CoreVideo_ListFullscreenModes = (ptr_VidExt_ListFullscreenModes) osal_dynlib_getproc(CoreLibHandle, "VidExt_ListFullscreenModes");
+    CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode) osal_dynlib_getproc(CoreLibHandle, "VidExt_SetVideoMode");
+    CoreVideo_SetCaption = (ptr_VidExt_SetCaption) osal_dynlib_getproc(CoreLibHandle, "VidExt_SetCaption");
+    CoreVideo_ToggleFullScreen = (ptr_VidExt_ToggleFullScreen) osal_dynlib_getproc(CoreLibHandle, "VidExt_ToggleFullScreen");
+    CoreVideo_GL_GetProcAddress = (ptr_VidExt_GL_GetProcAddress) osal_dynlib_getproc(CoreLibHandle, "VidExt_GL_GetProcAddress");
+    CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute) osal_dynlib_getproc(CoreLibHandle, "VidExt_GL_SetAttribute");
+    CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) osal_dynlib_getproc(CoreLibHandle, "VidExt_GL_SwapBuffers");
+
+    if (!CoreVideo_Init || !CoreVideo_Quit || !CoreVideo_ListFullscreenModes || !CoreVideo_SetVideoMode ||
+        !CoreVideo_SetCaption || !CoreVideo_ToggleFullScreen || !CoreVideo_GL_GetProcAddress ||
+        !CoreVideo_GL_SetAttribute || !CoreVideo_GL_SwapBuffers)
+    {
+        LOG("Couldn't connect to Core video functions\n");
+        return M64ERR_INCOMPATIBLE;
+    }
+
+    const char *configDir = ConfigGetSharedDataFilepath("Glide64.ini");
+    if (configDir)
+    {
+        SetConfigDir(configDir);
+        CoreVideo_Init();
+        return M64ERR_SUCCESS;
+    }
+    else
+    {
+        LOG("Couldn't find Glide64.ini\n");
+        return M64ERR_FILES;
+    }
+}
+
+EXPORT m64p_error CALL PluginShutdown(void)
+{
+    return M64ERR_SUCCESS;
+}
+
+EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion, 
+                                        int *APIVersion, const char **PluginNamePtr,
+                                        int *Capabilities)
+{
+    /* set version info */
+    if (PluginType != NULL)
+        *PluginType = M64PLUGIN_GFX;
+
+    if (PluginVersion != NULL)
+        *PluginVersion = 0x0103;
+
+    if (APIVersion != NULL)
+        *APIVersion = 0x020100;
+
+    if (PluginNamePtr != NULL)
+        *PluginNamePtr = "Glide64 Napalm WX Video Plugin";
+
+    if (Capabilities != NULL)
+    {
+        *Capabilities = 0;
+    }
+
+    return M64ERR_SUCCESS;
+}
+
 /******************************************************************
 Function: CaptureScreen
 Purpose:  This function dumps the current frame to a file
 input:    none
 output:   none
 *******************************************************************/
-void CALL RomOpen (void)
+int CALL RomOpen (void)
 {
   LOG ("RomOpen ()\n");
   no_dlist = true;
     grSetRomName (name);
   }
   // **
+  return true;
 }
 
 /******************************************************************
   }
 }
 
+EXPORT void CALL SetRenderingCallback(void (*callback)())
+{
+    renderCallback = callback;
+}
+
 /******************************************************************
 Function: UpdateScreen
 Purpose:  This function is called in response to a vsync of the

File Glide64/Makefile.gcc

 endif
 
 ifeq ($(OS), WINDOWS)
-DLLNAME = Glide64.dll
+  DLLNAME = Glide64.dll
 else
-DLLNAME = Glide64.so
+  ifeq ($(OS), MACOSX)
+    DLLNAME = Glide64.dylib
+  else
+    DLLNAME = Glide64.so
+  endif
 endif
 
 EXT_INC = ./inc
 EXT_LIB = ./lib
 
-CC = g++ 
+CC = g++ -m32
 STRIP = strip
 
 CFLAGS = -DBUILDING_DLL=1  -fexceptions 
-LDLIBS = -L"." -L"lib" `wx-config --libs` 
+LDLIBS = -L"." -L"lib" `wx-config --libs` `sdl-config --libs`
+ifeq ($(OS), MACOSX)
+LDLIBS += -framework OpenGL -framework GLUT
+endif
 
 ifeq ($(OS), Linux)
 CC += -V 4.2
 LDFLAGS = -shared -lstdc++ 
 CFLAGS += -D__unix__
-LDLIBS += $(EXT_LIB)/glide3x.so
 endif
 ifeq ($(OS), MACOSX)
 LDFLAGS = -dynamiclib -lstdc++ 
 CFLAGS += -D__unix__ -Dmacintosh
-LDLIBS += $(EXT_LIB)/glide3x.dylib
 endif
 ifeq ($(OS), WINDOWS)
 LDFLAGS = -shared -mwindows 
 CFLAGS += -D__WIN32__ -DWIN32 -D_WIN32
-LDLIBS += $(EXT_LIB)/glide3x.lib
 endif
 
 CFLAGS += -ffast-math -funroll-loops
 #CFLAGS += -fexpensive-optimizations -march=k6
-CFLAGS += -I. -I$(EXT_INC) `wx-config --cppflags`
+CFLAGS += -I. -I$(EXT_INC) -I"../Glitch64/"$(EXT_INC) `wx-config --cppflags` `sdl-config --cflags`
+
+# set mupen64plus core API header path
+ifneq ("$(APIDIR)","")
+  CFLAGS += "-I$(APIDIR)"
+else
+  TRYDIR = ../../../mupen64plus-core/src/api
+  ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
+    CFLAGS += -I$(TRYDIR)
+  else
+    TRYDIR = /usr/local/include/mupen64plus
+    ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
+      CFLAGS += -I$(TRYDIR)
+    else
+      TRYDIR = /usr/include/mupen64plus
+      ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
+        CFLAGS += -I$(TRYDIR)
+      else
+        $(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.)
+      endif
+    endif
+  endif
+endif
 
 ifdef DEBUG
 CFLAGS += -g -DDEBUG
 endif
 
-LD = g++
+LD = g++ -m32
 
 AS = nasm
 ifeq ($(OS), Linux)
   rdp.cpp \
   TexBuffer.cpp \
   TexCache.cpp \
-  Util.cpp
+  Util.cpp \
+  osal_dynamiclib_unix.c \
+  ../Glitch64/combiner.cpp \
+  ../Glitch64/geometry.cpp \
+  ../Glitch64/main.cpp \
+  ../Glitch64/textures.cpp \
+  ../Glitch64/vram.cpp
 
 OBJECTS = $(SOURCES:.cpp=.o)
 
 endif
 
 clean:
-	-$(RM) *.o
+	-$(RM) -f *.o ../Glitch64/*.o
 
 realclean: clean
-	-$(RM) $(DLLNAME) 
+	-$(RM) -f $(DLLNAME) 
 
 ostype:
 	echo $(OS)

File Glide64/m64p.h

+/******************************************************************************
+ * Glide64 - Glide video plugin for Nintendo 64 emulators.
+ * http://bitbucket.org/wahrhaft/mupen64plus-video-glide64/
+ *
+ * Copyright (C) 2010 Jon Ring
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef M64P_H
+#define M64P_H
+
+#include "m64p_types.h"
+#include "m64p_plugin.h"
+#include "m64p_config.h"
+#include "m64p_vidext.h"
+#include <stdio.h>
+
+void WriteLog(m64p_msg_level level, const char *msg, ...);
+
+//The Glide API originally used an integer to pick an enumerated resolution.
+//To accomodate arbitrary resolutions, pack it into a 32-bit struct
+//so we don't have to change function signatures
+union PackedScreenResolution
+{
+    struct 
+    {
+        int width : 16;
+        int height : 15;
+        int fullscreen : 1;
+    };
+    int resolution;
+};
+
+
+/* definitions of pointers to Core config functions */
+extern ptr_ConfigOpenSection      ConfigOpenSection;
+extern ptr_ConfigSetParameter     ConfigSetParameter;
+extern ptr_ConfigGetParameter     ConfigGetParameter;
+extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
+extern ptr_ConfigSetDefaultInt    ConfigSetDefaultInt;
+extern ptr_ConfigSetDefaultFloat  ConfigSetDefaultFloat;
+extern ptr_ConfigSetDefaultBool   ConfigSetDefaultBool;
+extern ptr_ConfigSetDefaultString ConfigSetDefaultString;
+extern ptr_ConfigGetParamInt      ConfigGetParamInt;
+extern ptr_ConfigGetParamFloat    ConfigGetParamFloat;
+extern ptr_ConfigGetParamBool     ConfigGetParamBool;
+extern ptr_ConfigGetParamString   ConfigGetParamString;
+
+extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
+extern ptr_ConfigGetUserConfigPath     ConfigGetUserConfigPath;
+extern ptr_ConfigGetUserDataPath       ConfigGetUserDataPath;
+extern ptr_ConfigGetUserCachePath      ConfigGetUserCachePath;
+
+
+extern ptr_VidExt_Init                  CoreVideo_Init;
+extern ptr_VidExt_Quit                  CoreVideo_Quit;
+extern ptr_VidExt_ListFullscreenModes   CoreVideo_ListFullscreenModes;
+extern ptr_VidExt_SetVideoMode          CoreVideo_SetVideoMode;
+extern ptr_VidExt_SetCaption            CoreVideo_SetCaption;
+extern ptr_VidExt_ToggleFullScreen      CoreVideo_ToggleFullScreen;
+extern ptr_VidExt_GL_GetProcAddress     CoreVideo_GL_GetProcAddress;
+extern ptr_VidExt_GL_SetAttribute       CoreVideo_GL_SetAttribute;
+extern ptr_VidExt_GL_SwapBuffers        CoreVideo_GL_SwapBuffers;
+
+#endif

File Glide64/osal_dynamiclib.h

+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *   Mupen64plus-core - osal/dynamiclib.h                                  *
+ *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
+ *   Copyright (C) 2009 Richard Goedeken                                   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#if !defined(OSAL_DYNAMICLIB_H)
+#define OSAL_DYNAMICLIB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "m64p_types.h"
+
+void *     osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #define OSAL_DYNAMICLIB_H */
+

File Glide64/osal_dynamiclib_unix.c

+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *   Mupen64plus-core - osal/dynamiclib_unix.c                             *
+ *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
+ *   Copyright (C) 2009 Richard Goedeken                                   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+
+#include "m64p_types.h"
+#include "osal_dynamiclib.h"
+
+void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName)
+{
+    if (pccProcedureName == NULL)
+        return NULL;
+
+    return dlsym(LibHandle, pccProcedureName);
+}
+
+

File Glide64/osal_dynamiclib_win32.c

+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *   Mupen64plus-ui-console - osal_dynamiclib_win32.c                      *
+ *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
+ *   Copyright (C) 2009 Richard Goedeken                                   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "m64p_types.h"
+#include "osal_dynamiclib.h"
+
+m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath)
+{
+    if (pLibHandle == NULL || pccLibraryPath == NULL)
+        return M64ERR_INPUT_ASSERT;
+
+    *pLibHandle = LoadLibrary(pccLibraryPath);
+
+    if (*pLibHandle == NULL)
+    {
+        char *pchErrMsg;
+        DWORD dwErr = GetLastError(); 
+        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);
+        fprintf(stderr, "LoadLibrary('%s') error: %s\n", pccLibraryPath, pchErrMsg);
+        LocalFree(pchErrMsg);
+        return M64ERR_INPUT_NOT_FOUND;
+    }
+
+    return M64ERR_SUCCESS;
+}
+
+void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName)
+{
+    if (pccProcedureName == NULL)
+        return NULL;
+
+    return GetProcAddress(LibHandle, pccProcedureName);
+}
+
+m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)
+{
+    int rval = FreeLibrary(LibHandle);
+
+    if (rval == 0)
+    {
+        char *pchErrMsg;
+        DWORD dwErr = GetLastError(); 
+        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);
+        fprintf(stderr, "FreeLibrary() error: %s\n", pchErrMsg);
+        LocalFree(pchErrMsg);
+        return M64ERR_INTERNAL;
+    }
+
+    return M64ERR_SUCCESS;
+}

File Glide64/rdp.cpp

 Plugin can return up to 6 frame buffer info
 ************************************************************************/
 ///*
-typedef struct
-{
-  wxUint32 addr;
-  wxUint32 size;
-  wxUint32 width;
-  wxUint32 height;
-} FrameBufferInfo;
 EXPORT void CALL FBGetFrameBufferInfo(void *p)
 {
   LOG ("FBGetFrameBufferInfo ()\n");