Commits

Anonymous committed 4e71bf0

started bringing in old-api code

Comments (0)

Files changed (6)

 //
 //****************************************************************
 
-//#define NOSSE
-
 #ifndef NOSSE
 #include <xmmintrin.h>
 #endif
+
 #include <math.h>
 #include "Gfx #1.3.h"
 #include "3dmath.h"
   __asm
   {
     mov     eax, dword ptr [r]  
-    mov     ecx, dword ptr [m1]
-    mov     edx, dword ptr [m2]
+      mov     ecx, dword ptr [m1]
+      mov     edx, dword ptr [m2]
 
-    movaps  xmm0,[edx]
-    movaps  xmm1,[edx+16]
-    movaps  xmm2,[edx+32]
-    movaps  xmm3,[edx+48]
+      movaps  xmm0,[edx]
+      movaps  xmm1,[edx+16]
+      movaps  xmm2,[edx+32]
+      movaps  xmm3,[edx+48]
 
 // r[0][0],r[0][1],r[0][2],r[0][3]
 
-    movaps  xmm4,xmmword ptr[ecx]
-    movaps  xmm5,xmm4
-    movaps  xmm6,xmm4
-    movaps  xmm7,xmm4
+      movaps  xmm4,xmmword ptr[ecx]
+      movaps  xmm5,xmm4
+      movaps  xmm6,xmm4
+      movaps  xmm7,xmm4
 
-   shufps  xmm4,xmm4,00000000b
-   shufps  xmm5,xmm5,01010101b
-   shufps  xmm6,xmm6,10101010b
-   shufps  xmm7,xmm7,11111111b
-   
-   mulps   xmm4,xmm0
-   mulps   xmm5,xmm1
-   mulps   xmm6,xmm2
-   mulps   xmm7,xmm3
-   
-   addps   xmm4,xmm5
-   addps   xmm4,xmm6
-   addps   xmm4,xmm7
-   
-   movaps  xmmword ptr[eax],xmm4
-   
+      shufps  xmm4,xmm4,00000000b
+      shufps  xmm5,xmm5,01010101b
+      shufps  xmm6,xmm6,10101010b
+      shufps  xmm7,xmm7,11111111b
+
+      mulps   xmm4,xmm0
+      mulps   xmm5,xmm1
+      mulps   xmm6,xmm2
+      mulps   xmm7,xmm3
+
+      addps   xmm4,xmm5
+      addps   xmm4,xmm6
+      addps   xmm4,xmm7
+
+      movaps  xmmword ptr[eax],xmm4
+
 // r[1][0],r[1][1],r[1][2],r[1][3]
 
-   movaps  xmm4,xmmword ptr[ecx+16]
-   movaps  xmm5,xmm4
-   movaps  xmm6,xmm4
-   movaps  xmm7,xmm4
-   
-   shufps  xmm4,xmm4,00000000b
-   shufps  xmm5,xmm5,01010101b
-   shufps  xmm6,xmm6,10101010b
-   shufps  xmm7,xmm7,11111111b
-   
-   mulps   xmm4,xmm0
-   mulps   xmm5,xmm1
-   mulps   xmm6,xmm2
-   mulps   xmm7,xmm3
-   
-   addps   xmm4,xmm5
-   addps   xmm4,xmm6
-   addps   xmm4,xmm7
-   
-   movaps  xmmword ptr[eax+16],xmm4
-   
-   
+      movaps  xmm4,xmmword ptr[ecx+16]
+      movaps  xmm5,xmm4
+      movaps  xmm6,xmm4
+      movaps  xmm7,xmm4
+
+      shufps  xmm4,xmm4,00000000b
+      shufps  xmm5,xmm5,01010101b
+      shufps  xmm6,xmm6,10101010b
+      shufps  xmm7,xmm7,11111111b
+
+      mulps   xmm4,xmm0
+      mulps   xmm5,xmm1
+      mulps   xmm6,xmm2
+      mulps   xmm7,xmm3
+
+      addps   xmm4,xmm5
+      addps   xmm4,xmm6
+      addps   xmm4,xmm7
+
+      movaps  xmmword ptr[eax+16],xmm4
+
+
 // r[2][0],r[2][1],r[2][2],r[2][3]
 
-   movaps  xmm4,xmmword ptr[ecx+32]
-   movaps  xmm5,xmm4
-   movaps  xmm6,xmm4
-   movaps  xmm7,xmm4
-  
-   shufps  xmm4,xmm4,00000000b
-   shufps  xmm5,xmm5,01010101b
-   shufps  xmm6,xmm6,10101010b
-   shufps  xmm7,xmm7,11111111b
-  
-   mulps   xmm4,xmm0
-   mulps   xmm5,xmm1
-   mulps   xmm6,xmm2
-   mulps   xmm7,xmm3
-  
-   addps   xmm4,xmm5
-   addps   xmm4,xmm6
-   addps   xmm4,xmm7
-  
-   movaps  xmmword ptr[eax+32],xmm4
-  
+      movaps  xmm4,xmmword ptr[ecx+32]
+      movaps  xmm5,xmm4
+      movaps  xmm6,xmm4
+      movaps  xmm7,xmm4
+
+      shufps  xmm4,xmm4,00000000b
+      shufps  xmm5,xmm5,01010101b
+      shufps  xmm6,xmm6,10101010b
+      shufps  xmm7,xmm7,11111111b
+
+      mulps   xmm4,xmm0
+      mulps   xmm5,xmm1
+      mulps   xmm6,xmm2
+      mulps   xmm7,xmm3
+
+      addps   xmm4,xmm5
+      addps   xmm4,xmm6
+      addps   xmm4,xmm7
+
+      movaps  xmmword ptr[eax+32],xmm4
+
 // r[3][0],r[3][1],r[3][2],r[3][3]
 
-   movaps  xmm4,xmmword ptr[ecx+48]
-   movaps  xmm5,xmm4
-   movaps  xmm6,xmm4
-   movaps  xmm7,xmm4
-  
-   shufps  xmm4,xmm4,00000000b
-   shufps  xmm5,xmm5,01010101b
-   shufps  xmm6,xmm6,10101010b
-   shufps  xmm7,xmm7,11111111b
-  
-   mulps   xmm4,xmm0
-   mulps   xmm5,xmm1
-   mulps   xmm6,xmm2
-   mulps   xmm7,xmm3
-  
-   addps   xmm4,xmm5
-   addps   xmm4,xmm6
-   addps   xmm4,xmm7
-  
-   movaps  xmmword ptr[eax+48],xmm4
-   }
+      movaps  xmm4,xmmword ptr[ecx+48]
+      movaps  xmm5,xmm4
+      movaps  xmm6,xmm4
+      movaps  xmm7,xmm4
+
+      shufps  xmm4,xmm4,00000000b
+      shufps  xmm5,xmm5,01010101b
+      shufps  xmm6,xmm6,10101010b
+      shufps  xmm7,xmm7,11111111b
+
+      mulps   xmm4,xmm0
+      mulps   xmm5,xmm1
+      mulps   xmm6,xmm2
+      mulps   xmm7,xmm3
+
+      addps   xmm4,xmm5
+      addps   xmm4,xmm6
+      addps   xmm4,xmm7
+
+      movaps  xmmword ptr[eax+48],xmm4
+    }
 #endif // _WIN32
-}
-
-
-
-void math_init()
-{
-#ifndef _DEBUG
-  int IsSSE = FALSE;
-#if defined(__GNUC__) && !defined(NO_ASM) && !defined(NOSSE)
-  int edx, eax;
-  #if defined(__x86_64__)
-  asm volatile(" cpuid;        "
-    : "=a"(eax), "=d"(edx)
-    : "0"(1)
-    : "rbx", "rcx"
-    );
-  #else
-  asm volatile(" push %%ebx;   "
-    " push %%ecx;   "
-    " cpuid;        "
-    " pop %%ecx;    "
-    " pop %%ebx;    "
-    : "=a"(eax), "=d"(edx)
-    : "0"(1)
-    :
-  );
-  #endif
-    // Check for SSE
-  if (edx & (1 << 25))
-    IsSSE = TRUE;
-#elif !defined(NO_ASM) && !defined(NOSSE)
-  DWORD dwEdx;
-  __try
-  {
-    __asm 
-    {
-      mov  eax,1
-      cpuid
-      mov dwEdx,edx
-    }  
-  }
-  __except(EXCEPTION_EXECUTE_HANDLER)
-  {
-    return;
   }
 
-  if (dwEdx & (1<<25)) 
+
+
+  void math_init()
   {
-    if (dwEdx & (1<<24))
-    {      
-      __try
+#ifndef _DEBUG
+    int IsSSE = FALSE;
+    int edx, eax;
+    GLIDE64_TRY
+    {
+#if defined(__GNUC__) && !defined(NO_ASM) && !defined(NOSSE)
+  #if defined(__x86_64__)
+      asm volatile(" cpuid;        "
+        : "=a"(eax), "=d"(edx)
+        : "0"(1)
+        : "rbx", "rcx"
+        );
+  #else
+      asm volatile(" push %%ebx;   "
+        " push %%ecx;   "
+        " cpuid;        "
+        " pop %%ecx;    "
+        " pop %%ebx;    "
+        : "=a"(eax), "=d"(edx)
+        : "0"(1)
+        :
+      );
+  #endif
+    }
+    GLIDE64_CATCH
+      { return; }
+    // Check for SSE
+    if (edx & (1 << 25))
+      IsSSE = TRUE;
+#elif !defined(NO_ASM) && !defined(NOSSE)
+    DWORD dwEdx;
+    __try
+    {
+      __asm 
       {
-        __asm xorps xmm0, xmm0
-        IsSSE = TRUE;
+        mov  eax,1
+          cpuid
+          mov dwEdx,edx
+        }  
       }
       __except(EXCEPTION_EXECUTE_HANDLER)
       {
         return;
       }
-    }
-  }
+
+      if (dwEdx & (1<<25)) 
+      {
+        if (dwEdx & (1<<24))
+        {      
+          __try
+          {
+            __asm xorps xmm0, xmm0
+              IsSSE = TRUE;
+          }
+          __except(EXCEPTION_EXECUTE_HANDLER)
+          {
+            return;
+          }
+        }
+      }
 #endif // _WIN32
-  if (IsSSE)
-  {
-    MulMatrices = MulMatricesSSE;
-    LOG("3DNOW! detected.\n");
-  }
+      if (IsSSE)
+      {
+        MulMatrices = MulMatricesSSE;
+        LOG("3DNOW! detected.\n");
+      }
 
 #endif //_DEBUG
-}
+    }
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */
+#include "Gfx #1.3.h"
 #include "Config.h"
 #include "m64p.h"
 #include "rdp.h"
 
+#ifndef OLDAPI
+
 static m64p_handle video_general_section;
 static m64p_handle video_glide64_section;
 
     if (ConfigOpenSection("Video-General", &video_general_section) != M64ERR_SUCCESS ||
         ConfigOpenSection("Video-Glide64", &video_glide64_section) != M64ERR_SUCCESS)
     {
-        WriteLog(M64MSG_ERROR, "Could not open configuration");
+        ERRLOG("Could not open configuration");
         return FALSE;
     }
     ConfigSetDefaultBool(video_general_section, "Fullscreen", false, "Use fullscreen mode if True, or windowed mode if False");
 
 BOOL Config_ReadInt(const char *itemname, const char *desc, int def_value, int create, int isBoolean)
 {
-    WriteLog(M64MSG_VERBOSE, "Getting value %s", itemname);
+    VLOG("Getting value %s", itemname);
     if (isBoolean)
     {
         ConfigSetDefaultBool(video_glide64_section, itemname, def_value, desc);
     }
 
 }
+#else
+
+// Resolutions, MUST be in the correct order (SST1VID.H)
+wxUint32 resolutions[0x18][2] = {
+  { 320, 200 },
+  { 320, 240 },
+  { 400, 256 },
+  { 512, 384 },
+  { 640, 200 },
+  { 640, 350 },
+  { 640, 400 },
+  { 640, 480 },
+  { 800, 600 },
+  { 960, 720 },
+  { 856, 480 },
+  { 512, 256 },
+  { 1024, 768 },
+  { 1280, 1024 },
+  { 1600, 1200 },
+  { 400, 300 },
+
+  // 0x10
+  { 1152, 864 },
+  { 1280, 960 },
+  { 1600, 1024 },
+  { 1792, 1344 },
+  { 1856, 1392 },
+  { 1920, 1440 },
+  { 2048, 1536 },
+  { 2048, 2048 }
+};
+
+
+BOOL Config_Open()
+{
+  INI_Open();
+  if(INI_FindSection("SETTINGS",FALSE) == FALSE) {
+    INI_Close();
+    ERRLOG("Could not open configuration");
+    return FALSE;
+  }
+  return TRUE;
+}
+
+int Config_ReadScreenInt(const char *itemname) {
+  int res_data = Config_ReadInt("resolution", NULL, 7, FALSE, FALSE);
+  if(!strcmp("ScreenWidth", itemname))
+    return resolutions[res_data][0];
+  else if(!strcmp("ScreenHeight", itemname))
+    return resolutions[res_data][1];
+  else return FALSE;
+}
+
+BOOL Config_ReadInt(const char *itemname, const char *desc, int def_value, int create, int isBoolean) {
+    VLOG("Getting value %s", itemname);
+    int z = INI_ReadInt(itemname, def_value, FALSE);
+    if(isBoolean) z=(z && 1);
+    return z;
+}
+
+#endif
 
 #ifdef TEXTURE_FILTER
 wxUint32 texfltr[] = {
 #define _GFX_H_INCLUDED__
 
 #include "winlnxdefs.h"
-#include "m64p_types.h"
-#include "m64p_plugin.h"
 #include "m64p.h"
 
 #include <stdio.h>
 extern int64 perf_next;
 #endif
 
-#ifdef LOGGING
+//#ifdef LOGGING
 //extern std::ofstream loga;
-//#define LOG(x) loga.open("log.txt",std::ios::app); loga << x; loga.flush(); loga.close();
+//#define LOG(X) loga.open("log.txt",std::ios::app); loga << (...); loga.flush(); loga.close();
 
-#define LOG(x) WriteLog(M64MSG_VERBOSE, x);
-
-#else
-#define LOG(x) WriteLog(M64MSG_VERBOSE, x);
-#endif
-
+//#else
+  #ifndef OLD_API
+    #define LOG(...) WriteLog(M64MSG_INFO, __VA_ARGS__)
+    #define VLOG(...) WriteLog(M64MSG_VERBOSE, __VA_ARGS__)
+    #define WARNLOG(...) WriteLog(M64MSG_WARNING, __VA_ARGS__)
+    #define ERRLOG(...) WriteLog(M64MSG_ERROR, __VA_ARGS__)
+  #else
+    #define LOG(...) printf(__VA_ARGS__)
+    #define VLOG(...)
+     #define WARNLOG(...) printf(__VA_ARGS__)
+    #define ERRLOG(X, ...) str.Printf(_T(X), __VA_ARGS__); wxMessageBox(str, _T("Error"), wxOK | wxICON_EXCLAMATION, GFXWindow)
+    #define ERRLOG(X) str.Printf(_T(X)); wxMessageBox(str, _T("Error"), wxOK | wxICON_EXCLAMATION, GFXWindow)
+  #endif
+//#endif
 
 #ifdef RDP_LOGGING
 extern int log_open;
 
 #include "m64p.h"
 
-#include "m64p_types.h"
-#include "m64p_plugin.h"
-#include "m64p_config.h"
-#include "m64p_vidext.h"
 #include "Ini.h"
 #include "Gfx #1.3.h"
 #include <limits.h>
     }
    
     //strncat (path, "Glide64.ini", PATH_MAX - strlen(path));
-    WriteLog(M64MSG_INFO, "opening %s\n", path);
+    LOG("opening %s\n", path);
     // Open the file
     ini = fopen (path, "rb");
     if (ini == NULL)
     {
-        WriteLog(M64MSG_ERROR, "Could not find Glide64.ini!");
+        ERRLOG("Could not find Glide64.ini!");
         return FALSE;
         /*
         ini = fopen (path, "w+b");
 
 #endif
 
-// Resolutions, MUST be in the correct order (SST1VID.H)
-wxUint32 resolutions[0x18][2] = {
-  { 320, 200 },
-  { 320, 240 },
-  { 400, 256 },
-  { 512, 384 },
-  { 640, 200 },
-  { 640, 350 },
-  { 640, 400 },
-  { 640, 480 },
-  { 800, 600 },
-  { 960, 720 },
-  { 856, 480 },
-  { 512, 256 },
-  { 1024, 768 },
-  { 1280, 1024 },
-  { 1600, 1200 },
-  { 400, 300 },
-
-  // 0x10
-  { 1152, 864 },
-  { 1280, 960 },
-  { 1600, 1024 },
-  { 1792, 1344 },
-  { 1856, 1392 },
-  { 1920, 1440 },
-  { 2048, 1536 },
-  { 2048, 2048 }
-};
-
 // ref rate
 // 60=0x0, 70=0x1, 72=0x2, 75=0x3, 80=0x4, 90=0x5, 100=0x6, 85=0x7, 120=0x8, none=0xff
 
 static void (*l_DebugCallback)(void *, int, const char *) = NULL;
 static void *l_DebugCallContext = NULL;
 
+#ifndef OLDAPI
 void WriteLog(m64p_msg_level level, const char *msg, ...)
 {
   char buf[1024];
     l_DebugCallback(l_DebugCallContext, level, buf);
   }
 }
-
+#endif
 
 void ReadSettings ()
 {
   //  LOG("ReadSettings\n");
   if (!Config_Open())
   {
-    WriteLog(M64MSG_ERROR, "Could not open configuration!");
+    ERRLOG("Could not open configuration!");
     return;
   }
 
 
 #ifdef LOGGING
   sprintf (out_buf, "hstart: %d, hend: %d, vstart: %d, vend: %d\n", hstart, hend, vstart, vend);
-  LOG (out_buf);
+  VLOG (out_buf);
   sprintf (out_buf, "size: %d x %d\n", (int)rdp.vi_width, (int)rdp.vi_height);
-  LOG (out_buf);
+  VLOG (out_buf);
 #endif
 
   rdp.scale_x = (float)settings.res_x / rdp.vi_width;
       grRenderBuffer( GR_BUFFER_BACKBUFFER );
     }
     
-    WriteLog(M64MSG_INFO, "tbuf_size %gMb\n", tbuf_size/1024.0f/1024);
+    LOG("tbuf_size %gMb\n", tbuf_size/1024.0f/1024);
     rdp.texbufs[0].tmu = GR_TMU0;
     rdp.texbufs[0].begin = voodoo.tex_min_addr[GR_TMU0];
     rdp.texbufs[0].end = rdp.texbufs[0].begin+tbuf_size;
 
   OPEN_RDP_LOG ();  // doesn't matter if opens again; it will check for it
   OPEN_RDP_E_LOG ();
-  LOG ("InitGfx ()\n");
+  VLOG ("InitGfx ()\n");
 
   debugging = FALSE;
   rdp_reset ();
 
   if (fb_hwfbe_enabled)
   {
-    WriteLog(M64MSG_INFO, "fb_hwfbe_enabled\n");
+    LOG("fb_hwfbe_enabled\n");
     
     char strSstWinOpenExt[] ="grSstWinOpenExt";
     GRWINOPENEXT grSstWinOpenExt = (GRWINOPENEXT)grGetProcAddress(strSstWinOpenExt);
 
   if (!gfx_context)
   {
-    WriteLog(M64MSG_ERROR, "Error setting display mode");
+    ERRLOG("Error setting display mode");
     //    grSstWinClose (gfx_context);
     grGlideShutdown ();
     return FALSE;
 
   // get the # of TMUs available
   grGet (GR_NUM_TMU, 4, (FxI32*)&voodoo.num_tmu);
-  WriteLog(M64MSG_INFO, "num_tmu %d\n", voodoo.num_tmu);
+  LOG("num_tmu %d\n", voodoo.num_tmu);
   // get maximal texture size
   grGet (GR_MAX_TEXTURE_SIZE, 4, (FxI32*)&voodoo.max_tex_size);
   voodoo.sup_large_tex = (voodoo.max_tex_size > 256 && !(settings.hacks & hack_PPL));
 
 void ReleaseGfx ()
 {
-  LOG("ReleaseGfx ()\n");
+  VLOG("ReleaseGfx ()\n");
 
   // Restore gamma settings
   if (voodoo.gamma_correction)
 
 EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front)
 {
-  LOG("CALL ReadScreen2 ()\n");
+  VLOG("CALL ReadScreen2 ()\n");
   *width = settings.res_x;
   *height = settings.res_y;
   if (dest)
         }
       }
       // LOG ("ReadScreen. not in the fullscreen!\n");
-      WriteLog(M64MSG_WARNING, "[Glide64] Cannot save screenshot in windowed mode?\n");
+      WARNLOG("[Glide64] Cannot save screenshot in windowed mode?\n");
 
       return;
     }
       // Unlock the frontbuffer
       grLfbUnlock (GR_LFB_READ_ONLY, GR_BUFFER_FRONTBUFFER);
     }
-    LOG ("ReadScreen. Success.\n");
+    VLOG ("ReadScreen. Success.\n");
   }
 }
 
 EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
                                    void (*DebugCallback)(void *, int, const char *))
 {
-  LOG("CALL PluginStartup ()\n")
+  VLOG("CALL PluginStartup ()\n");
     l_DebugCallback = DebugCallback;
     l_DebugCallContext = Context;
     ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreLibHandle, "ConfigOpenSection");
         !ConfigGetParamInt   || !ConfigGetParamFloat   || !ConfigGetParamBool   || !ConfigGetParamString ||
         !ConfigGetSharedDataFilepath || !ConfigGetUserConfigPath || !ConfigGetUserDataPath || !ConfigGetUserCachePath)
     {
-        WriteLog(M64MSG_ERROR, "Couldn't connect to Core configuration functions");
+        ERRLOG("Couldn't connect to Core configuration functions");
         return M64ERR_INCOMPATIBLE;
     }
 
         !CoreVideo_SetCaption || !CoreVideo_ToggleFullScreen || !CoreVideo_GL_GetProcAddress ||
         !CoreVideo_GL_SetAttribute || !CoreVideo_GL_SwapBuffers)
     {
-        WriteLog(M64MSG_ERROR, "Couldn't connect to Core video functions");
+        ERRLOG("Couldn't connect to Core video functions");
         return M64ERR_INCOMPATIBLE;
     }
 
     }
     else
     {
-        WriteLog(M64MSG_ERROR, "Couldn't find Glide64.ini");
+        ERRLOG("Couldn't find Glide64.ini");
         return M64ERR_FILES;
     }
 }
 
 EXPORT m64p_error CALL PluginShutdown(void)
 {
-  LOG("CALL PluginShutdown ()\n");
+  VLOG("CALL PluginShutdown ()\n");
     return M64ERR_SUCCESS;
 }
 
 EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion, int *APIVersion, const char **PluginNamePtr, int *Capabilities)
 {
-  LOG("CALL PluginGetVersion ()\n");
+  VLOG("CALL PluginGetVersion ()\n");
     /* set version info */
     if (PluginType != NULL)
         *PluginType = M64PLUGIN_GFX;
 *******************************************************************/
 EXPORT void CALL CaptureScreen ( char * Directory )
 {
-  LOG("CALL CaptureScreen ()\n");
+  VLOG("CALL CaptureScreen ()\n");
   capture_screen = 1;
   strcpy (capture_path, Directory);
 }
 //#warning ChangeWindow unimplemented
 EXPORT void CALL ChangeWindow (void)
 {
-  LOG ("CALL ChangeWindow()\n");
+  VLOG ("CALL ChangeWindow()\n");
 }
 
 /******************************************************************
 *******************************************************************/
 EXPORT void CALL CloseDLL (void)
 {
-  LOG ("CALL CloseDLL ()\n");
+  VLOG ("CALL CloseDLL ()\n");
 
 #ifdef ALTTAB_FIX
   if (hhkLowLevelKybd)
 *******************************************************************/
 EXPORT void CALL DllTest ( HWND hParent )
 {
-  LOG("CALL DllTest ()\n");
+  VLOG("CALL DllTest ()\n");
 }
 
 /******************************************************************
 *******************************************************************/
 EXPORT void CALL DrawScreen (void)
 {
-  LOG ("CALL DrawScreen ()\n");
+  VLOG ("CALL DrawScreen ()\n");
 }
 
 /******************************************************************
 *******************************************************************/
 EXPORT void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo )
 {
-  LOG ("CALL GetDllInfo ()\n");
+  VLOG ("CALL GetDllInfo ()\n");
 
   PluginInfo->Version = 0x0103;     // Set to 0x0103
   PluginInfo->Type  = PLUGIN_TYPE_GFX;  // Set to PLUGIN_TYPE_GFX
 
 EXPORT BOOL CALL InitiateGFX (GFX_INFO Gfx_Info)
 {
-  LOG ("CALL InitiateGFX (*)\n");
+  VLOG ("CALL InitiateGFX (*)\n");
   // Do *NOT* put this in rdp_reset or it could be set after the screen is initialized
   voodoo.num_tmu = 2;
 
 *******************************************************************/
 EXPORT void CALL MoveScreen (int xpos, int ypos)
 {
-  LOG ("CALL MoveScreen");
+  VLOG ("CALL MoveScreen");
 }
 
 
 
 EXPORT void CALL RomClosed (void)
 {
-  LOG ("CALL RomClosed ()\n");
+  VLOG ("CALL RomClosed ()\n");
 
   CLOSE_RDP_LOG ();
   CLOSE_RDP_E_LOG ();
     BMASK = WMASK;
 #ifdef LOGGING
   sprintf (out_buf, "Detected RDRAM size: %08lx\n", BMASK);
-  LOG (out_buf);
+  VLOG (out_buf);
 #endif
 }
 
 *******************************************************************/
 EXPORT int CALL RomOpen (void)
 {
-  LOG ("CALL RomOpen ()\n");
+  VLOG ("CALL RomOpen ()\n");
 
   if (fullscreen && evoodoo)
     ReleaseGfx ();
     grSstSelect (0);
   }
   const char *extensions = grGetString (GR_EXTENSION);
-  WriteLog(M64MSG_INFO, "extensions '%s'\n", extensions);
+  LOG("extensions '%s'\n", extensions);
   if (!fullscreen)
   {
     grGlideShutdown ();
 EXPORT void CALL ShowCFB (void)
 {
   no_dlist = TRUE;
-  LOG ("CALL ShowCFB ()\n");
+  VLOG ("CALL ShowCFB ()\n");
 }
 
 EXPORT void CALL SetRenderingCallback(void (*callback)())
 {
-  printf("CALL SetRenderingCallback (*)\n");
+  VLOG("CALL SetRenderingCallback (*)\n");
     renderCallback = callback;
 }
 
 wxUint32 update_screen_count = 0;
 EXPORT void CALL UpdateScreen (void)
 {
-  // printf("Rendercallback is %p\n", renderCallback);
-  LOG("CALL UpdateScreen()");
+  // VLOG("Rendercallback is %p\n", renderCallback);
+  VLOG("CALL UpdateScreen()");
 #ifdef LOG_KEY
   if (CheckKeyPressed(G64_VK_SPACE, 0x0001))
   {
 #endif
   char out_buf[512];
   sprintf (out_buf, "UpdateScreen (). distance: %d\n", (int)(*gfx.VI_ORIGIN_REG) - (int)((*gfx.VI_WIDTH_REG) << 2));
-  LOG (out_buf);
+  VLOG (out_buf);
   //  LOG ("UpdateScreen ()\n");
 
   wxUint32 width = (*gfx.VI_WIDTH_REG) << 1;
 
     if (!InitGfx (FALSE))
     {
-      LOG ("FAILED!!!\n");
+      VLOG ("FAILED!!!\n");
       return;
     }
     fullscreen = TRUE;
     {
       if (fb_hwfbe_enabled && !(settings.hacks&hack_RE2) && !evoodoo)
         grAuxBufferExt( GR_BUFFER_AUXBUFFER );
-      LOG ("BUFFER SWAPPED\n");
+      VLOG ("BUFFER SWAPPED\n");
       grBufferSwap (settings.vsync);
       fps_count ++;
       if (*gfx.VI_STATUS_REG&0x08) //gamma correction is used
   INI_FindSection ("UCODE");
   FRDP("ucode = %s\n", str);
   int uc = INI_ReadInt (str, -2, 0);
-  WriteLog(M64MSG_INFO, "ucode = %d\n", uc);
+  LOG("ucode = %d\n", uc);
 
   if (uc == -2 && ucode_error_report)
   {
     settings.ucode = Config_ReadInt ("ucode", "Force microcode", 0, FALSE, FALSE);
 
     ReleaseGfx ();
-    WriteLog(M64MSG_ERROR, "Error: uCode crc not found in INI, using currently selected uCode\n\n%08lx", (unsigned long)uc_crc);
+    ERRLOG("Error: uCode crc not found in INI, using currently selected uCode\n\n%08lx", (unsigned long)uc_crc);
 
     ucode_error_report = FALSE; // don't report any more ucode errors from this game
   }
     settings.ucode = Config_ReadInt ("ucode", "Force microcode", 0, FALSE, FALSE);
 
     ReleaseGfx ();
-    WriteLog(M64MSG_ERROR, "Error: Unsupported uCode!\n\ncrc: %08lx", (unsigned long)uc_crc);
+    ERRLOG("Error: Unsupported uCode!\n\ncrc: %08lx", (unsigned long)uc_crc);
 
     ucode_error_report = FALSE; // don't report any more ucode errors from this game
   }
 //but it works only on windows, because
 //I don't know, how to initialize GFXWindow on other OS
 #ifdef __WINDOWS__
-  LOG ("drawNoFullscreenMessage ()\n");
+  VLOG ("drawNoFullscreenMessage ()\n");
   if (rdp.window_changed)
   {
     rdp.window_changed = FALSE;
   }
 #endif
 
-  LOG ("ProcessDList ()\n");
+  VLOG ("ProcessDList ()\n");
 
   if (!fullscreen)
   {
       }
 #endif
     }
-    WriteLog(M64MSG_ERROR, "The GFX plugin caused an exception and has been disabled.");
+    ERRLOG("The GFX plugin caused an exception and has been disabled.");
     exception = TRUE;
     return;
   }
     int rem = SrcOffs & 3;
     if (rem == 0)
     {
-        int *pSrc = (int *) ((uintptr_t) gfx.RDRAM + SrcOffs);
+        int *pSrc = (int *) (wxPtrToUInt(gfx.RDRAM) + SrcOffs);
         for (unsigned int x = 0; x < cnt; x++)
         {
             int s1 = *pSrc++;
     else
     {
         // set source pointer to 4-byte aligned RDRAM location before the start
-        int *pSrc = (int *) ((uintptr_t) gfx.RDRAM + (SrcOffs & 0xfffffffc));
+        int *pSrc = (int *) (wxPtrToUInt(gfx.RDRAM) + (SrcOffs & 0xfffffffc));
         // do the first partial 32-bit word
         int s0 = *pSrc++;
         BYTESWAP1(s0)
   //Helps to fix Vigilante 8 jpeg backgrounds and logos
   wxUint32 offs = rdp.timg.addr + (ul_s << rdp.tiles[tile].size >> 1);
   // wxUIntPtr dst = wxPtrToUInt(rdp.tmem)+(rdp.tiles[tile].t_mem<<3);
-  int * pDst = (int *) ((uintptr_t)rdp.tmem+(rdp.tiles[tile].t_mem<<3));
+  int * pDst = (int *) (wxPtrToUInt(rdp.tmem)+(rdp.tiles[tile].t_mem<<3));
   wxUint32 cnt = lr_s-ul_s+1;
   if (rdp.tiles[tile].size == 3)
     cnt <<= 1;
     if (height == 0)
       return;
 
-    int * pDst = (int *) ((uintptr_t)rdp.tmem+(rdp.tiles[tile].t_mem<<3));
-    int * pEnd = (int *) ((uintptr_t)rdp.tmem+4096 - (wid_64<<3));
+    int * pDst = (int *) (wxPtrToUInt(rdp.tmem)+(rdp.tiles[tile].t_mem<<3));
+    int * pEnd = (int *) (wxPtrToUInt(rdp.tmem)+4096 - (wid_64<<3));
     for (unsigned int y = 0; y < height; y++)
     {
         if (pDst > pEnd) break;
 
 EXPORT void CALL FBRead(wxUint32 addr)
 {
-  LOG ("FBRead ()\n");
+  VLOG ("FBRead ()\n");
 
   if (cpu_fb_ignore)
     return;
 *******************************************************************/
 EXPORT void CALL FBWrite(wxUint32 addr, wxUint32 size)
 {
-  LOG ("FBWrite ()\n");
+  VLOG ("FBWrite ()\n");
   if (cpu_fb_ignore)
     return;
   if (cpu_fb_read_called)
 #endif
 EXPORT void CALL FBGetFrameBufferInfo(void *p)
 {
-  LOG ("FBGetFrameBufferInfo ()\n");
+  VLOG ("FBGetFrameBufferInfo ()\n");
   FrameBufferInfo * pinfo = (FrameBufferInfo *)p;
   memset(pinfo,0,sizeof(FrameBufferInfo)*6);
   if (!(settings.frame_buffer&fb_get_info))
 
 void CALL ProcessRDPList(void)
 {
-  LOG ("ProcessRDPList ()\n");
+  VLOG ("ProcessRDPList ()\n");
   LRDP("ProcessRDPList ()\n");
-  printf("fullscreen = %d\n", fullscreen);
+  LOG("fullscreen = %d\n", fullscreen);
   /* {
     if (!fullscreen)
       drawNoFullscreenMessage();