Commits

Anonymous committed 5150593 Merge

merged 2.0API code into main branch

Comments (0)

Files changed (42)

Glitch64/Makefile.clang

+# This MUST be processed by GNU make
+#
+# Glitch64 Makefile
+# Version:  1.0
+#
+# this 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, or (at your option)
+# any later version.
+#
+# this 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 GNU Make; see the file COPYING.  If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+#
+#  Available options:
+#
+#    Environment variables:
+#	DEBUG=1		enable debugging checks and messages
+#			default = no
+#
+#    Environment variables:
+#
+#    Targets:
+#	all:		build dynamic module
+#	clean:		remove object files
+#	realclean:	remove all generated files
+#
+#
+#  Requirements:
+#
+#    Compiler:
+#       GCC 4.2
+#
+#    Libraries:
+#       SDL 1.2 (http://www.libsdl.org)
+#
+
+.PHONY: all clean realclean
+
+OS=$(shell uname)
+ifeq ($(findstring MINGW,$(OS)),MINGW)
+OS := WINDOWS
+endif
+ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
+OS=WINDOWS
+endif
+ifeq ($(findstring WINNT,$(OS)),WINNT)
+OS=WINDOWS
+endif
+ifeq ($(OS),Darwin)
+OS=MACOSX
+endif
+
+ifeq ($(OS), WINDOWS)
+  DLLNAME = glide3x.dll
+else
+  ifeq ($(OS), MACOSX)
+    DLLNAME = glide3x.dylib
+  else
+    DLLNAME = glide3x.so
+  endif
+endif
+
+EXT_INC = ./inc
+EXT_LIB = ./lib
+
+CC = /usr/local/bin/clang++
+STRIP = strip
+CFLAGS += -DBUILDING_DLL=1 -fexceptions -fPIC -DPIC -I$(MPAPI_PATH)
+
+ifeq ($(OS), Linux)
+LDFLAGS += -shared -lstdc++
+CFLAGS += -D__unix__
+endif
+ifeq ($(OS), MACOSX)
+LDFLAGS += -dynamiclib -lstdc++ -undefined dynamic_lookup -install_name @executable_path/../lib/glide3x.dylib
+CFLAGS += -D__unix__ -Dmacintosh
+endif
+ifeq ($(OS), WINDOWS)
+LDFLAGS += -shared -mwindows 
+CFLAGS += -D__WIN32__ -DWIN32 -D_WIN32
+endif
+
+CFLAGS += -ffast-math -funroll-loops
+CFLAGS += -I. -I$(EXT_INC) `sdl-config --cflags`
+
+ifdef DEBUG
+CFLAGS += -g -DDEBUG
+endif
+
+LD = g++ #/usr/local/bin/clang++
+LDFLAGS2 = --out-implib=libglide3x.a
+
+LDLIBS = -L"." -L"lib" `sdl-config --libs`
+ifeq ($(OS), MACOSX)
+LDLIBS += -framework OpenGL -framework GLUT
+else
+LDLIBS += -lGL
+endif
+
+RM = rm
+
+SOURCES = \
+  combiner.cpp \
+  geometry.cpp \
+  main.cpp     \
+  textures.cpp \
+  vram.cpp
+
+OBJECTS = $(SOURCES:.cpp=.o)
+
+.cpp.o:
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+all: $(DLLNAME)
+
+$(DLLNAME): $(OBJECTS)
+	$(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS) --out-implib=libglide3x.a
+ifeq ($(OS), Linux)
+	$(STRIP) $@
+endif
+
+clean:
+	-$(RM) *.o
+
+realclean: clean
+	-$(RM) $(DLLNAME) 
+
+-include depend

Glitch64/Makefile.gcc

 EXT_INC = ./inc
 EXT_LIB = ./lib
 
-CC = g++ 
+CC = g++
 STRIP = strip
-CFLAGS = -DBUILDING_DLL=1  -fexceptions -fPIC -DPIC
+CFLAGS = -DBUILDING_DLL=1 -fexceptions -fPIC -DPIC -I$(MPAPI_PATH)
 
 ifeq ($(OS), Linux)
-LDFLAGS = -shared -lstdc++ 
+LDFLAGS = -shared -lstdc++
 CFLAGS += -D__unix__
 endif
 ifeq ($(OS), MACOSX)
-LDFLAGS = -dynamiclib -lstdc++ 
+LDFLAGS = -dynamiclib -lstdc++ -undefined dynamic_lookup -install_name @executable_path/../lib/glide3x.dylib
 CFLAGS += -D__unix__ -Dmacintosh
 endif
 ifeq ($(OS), WINDOWS)
 CFLAGS += -g -DDEBUG
 endif
 
-LD = g++
+LD = g++ #/usr/local/bin/clang++
 LDFLAGS2 = --out-implib=libglide3x.a
 
 LDLIBS = -L"." -L"lib" `sdl-config --libs`
 ifeq ($(OS), MACOSX)
 LDLIBS += -framework OpenGL -framework GLUT
+else
+LDLIBS += -lGL
 endif
 
 RM = rm
+/******************************************************************************
+ * 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_config.h"
+#include "m64p_vidext.h"
+
+extern ptr_ConfigOpenSection      ConfigOpenSection;
+extern ptr_ConfigGetParamInt      ConfigGetParamInt;
+extern ptr_ConfigGetParamBool     ConfigGetParamBool;
+
+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

Glitch64/main.cpp

 #include <stdint.h>
 #include <stdarg.h>
 #include <string.h>
-#include <SDL.h>
 #endif // _WIN32
 #include <stdlib.h>
 #include <stdio.h>
 #include "glide.h"
 #include "g3ext.h"
 #include "main.h"
+#include "m64p.h"
 
 #ifdef VPDEBUG
 #include <IL/il.h>
 #endif
 
+extern void (*renderCallback)();
+
 wrapper_config config = {0, 0, 0, 0};
 char ** _aResolutions = 0;
 int _numResolutions = 0;
 static texbuf_t texbufs[NB_TEXBUFS];
 static int texbuf_i;
 
-#ifndef _WIN32
-static SDL_Surface *m_pScreen;
-#endif // _WIN32
 unsigned short frameBuffer[2048*2048];
 unsigned short depthBuffer[2048*2048];
 
 #else // LOGGING
 #define OPEN_LOG()
 #define CLOSE_LOG()
-#define LOG
+//#define LOG
 #endif // LOGGING
 
 FX_ENTRY void FX_CALL
 
   if (!use_fbo) {
     int th = height;
-    if (th > screen_height)
+    if (th > screen_height)
       th = screen_height;
     maxy = th - maxy;
     miny = th - miny;
   color_texture = free_texture++;
   depth_texture = free_texture++;
 
-#ifdef _WIN32
-
-  PIXELFORMATDESCRIPTOR pfd;
-  memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
-  pfd.nSize      = sizeof(PIXELFORMATDESCRIPTOR);
-  pfd.nVersion   = 1;
-  pfd.dwFlags    = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_ACCELERATED  | PFD_DOUBLEBUFFER;
-  pfd.iPixelType = PFD_TYPE_RGBA;
-  pfd.iLayerType = PFD_MAIN_PLANE;
-  pfd.cColorBits = 32;
-  pfd.cDepthBits = 24;
-  pfd.cAuxBuffers = 1;
-
-  int pfm;
-#endif // _WIN32
-
   LOG("grSstWinOpen(%d, %d, %d, %d, %d, %d %d)\r\n", hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
 
 #ifdef _WIN32
   hwnd_win = (HWND)hWnd;
 #endif // _WIN32
   width = height = 0;
-  if (screen_resolution & 0x80000000)
+
+  m64p_handle video_general_section;
+  printf("&ConfigOpenSection is %p\n", &ConfigOpenSection);
+  if (ConfigOpenSection("Video-General", &video_general_section) != M64ERR_SUCCESS)
   {
-    switch (screen_resolution & ~0x80000000)
-    {
-    case GR_RESOLUTION_320x200:
-      width = 320;
-      height = 200;
-      break;
-    case GR_RESOLUTION_320x240:
-      width = 320;
-      height = 240;
-      break;
-    case GR_RESOLUTION_400x256:
-      width = 400;
-      height = 256;
-      break;
-    case GR_RESOLUTION_512x384:
-      width = 512;
-      height = 384;
-      break;
-    case GR_RESOLUTION_640x200:
-      width = 640;
-      height = 200;
-      break;
-    case GR_RESOLUTION_640x350:
-      width = 640;
-      height = 350;
-      break;
-    case GR_RESOLUTION_640x400:
-      width = 640;
-      height = 400;
-      break;
-    case GR_RESOLUTION_640x480:
-      width = 640;
-      height = 480;
-      break;
-    case GR_RESOLUTION_800x600:
-      width = 800;
-      height = 600;
-      break;
-    case GR_RESOLUTION_960x720:
-      width = 960;
-      height = 720;
-      break;
-    case GR_RESOLUTION_856x480:
-      width = 856;
-      height = 480;
-      break;
-    case GR_RESOLUTION_512x256:
-      width = 512;
-      height = 256;
-      break;
-    case GR_RESOLUTION_1024x768:
-      width = 1024;
-      height = 768;
-      break;
-    case GR_RESOLUTION_1280x1024:
-      width = 1280;
-      height = 1024;
-      break;
-    case GR_RESOLUTION_1600x1200:
-      width = 1600;
-      height = 1200;
-      break;
-    case GR_RESOLUTION_400x300:
-      width = 400;
-      height = 300;
-      break;
-    case GR_RESOLUTION_1152x864:
-      width = 1152;
-      height = 864;
-      break;
-    case GR_RESOLUTION_1280x960:
-      width = 1280;
-      height = 960;
-      break;
-    case GR_RESOLUTION_1600x1024:
-      width = 1600;
-      height = 1024;
-      break;
-    case GR_RESOLUTION_1792x1344:
-      width = 1792;
-      height = 1344;
-      break;
-    case GR_RESOLUTION_1856x1392:
-      width = 1856;
-      height = 1392;
-      break;
-    case GR_RESOLUTION_1920x1440:
-      width = 1920;
-      height = 1440;
-      break;
-    case GR_RESOLUTION_2048x1536:
-      width = 2048;
-      height = 1536;
-      break;
-    case GR_RESOLUTION_2048x2048:
-      width = 2048;
-      height = 2048;
-      break;
-    default:
-      display_warning("unknown SstWinOpen resolution : %x", screen_resolution);
-    }
-  }
-
-#ifdef _WIN32
-  if (screen_resolution & 0x80000000)
-  {
-    RECT clientRect, toolbarRect, statusbarRect;
-    ZeroMemory(&windowedRect, sizeof(RECT));
-    ZeroMemory(&clientRect, sizeof(RECT));
-    ZeroMemory(&toolbarRect, sizeof(RECT));
-    ZeroMemory(&statusbarRect, sizeof(RECT));
-    HWND hToolBar = FindWindowEx(hwnd_win, NULL, REBARCLASSNAME, NULL);
-    HWND hStatusBar = FindWindowEx(hwnd_win, NULL, STATUSCLASSNAME, NULL);
-    if (hStatusBar == NULL) hStatusBar = FindWindowEx(hwnd_win, NULL, "msctls_statusbar32", NULL); // 1964
-    if (hToolBar != NULL) GetWindowRect(hToolBar, &toolbarRect);
-    if (hStatusBar != NULL) GetWindowRect(hStatusBar, &statusbarRect);
-    viewport_offset = statusbarRect.bottom - statusbarRect.top;
-    GetWindowRect(hwnd_win, &windowedRect);
-    GetClientRect(hwnd_win, &clientRect);
-    windowedRect.right += (width - (clientRect.right - clientRect.left));
-    windowedRect.bottom += (height + (toolbarRect.bottom - toolbarRect.top) + (statusbarRect.bottom - statusbarRect.top) - (clientRect.bottom - clientRect.top));
-    SetWindowPos(hwnd_win, NULL, 0, 0, windowedRect.right - windowedRect.left,
-      windowedRect.bottom - windowedRect.top, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
-
-    TMU_SIZE = (config.vram_size - width * height * 4 * 3) / 2; // XXX - what about windows desktop usage?
-
-    fullscreen = 0;
-  }
-  else
-  {
-    static DEVMODE fullscreenMode;
-    int iModeNum = 0;
-    static int iCount = -1;
-
-    viewport_offset = 0;
-
-    if (iCount != screen_resolution) {
-      iCount = 0;
-      memset(&fullscreenMode, 0, sizeof(DEVMODE));
-      while (EnumDisplaySettings(NULL, iModeNum++, &fullscreenMode) != 0)
-      {
-        if (fullscreenMode.dmBitsPerPel == 32) {
-          if (iCount == screen_resolution) break;
-          iCount++;
-        }
-      }
-    }
-
-    width = fullscreenMode.dmPelsWidth;
-    height = fullscreenMode.dmPelsHeight;
-
-    TMU_SIZE = (config.vram_size - fullscreenMode.dmPelsWidth * fullscreenMode.dmPelsHeight * 4 * 3) / 2;
-
-    ZeroMemory(&windowedRect, sizeof(RECT));
-    GetWindowRect(hwnd_win, &windowedRect);
-
-    windowedExStyle = GetWindowLong(hwnd_win, GWL_EXSTYLE);
-    windowedStyle = GetWindowLong(hwnd_win, GWL_STYLE);
-
-    // primary monitor only
-    if (ChangeDisplaySettings( &fullscreenMode, CDS_FULLSCREEN ) != DISP_CHANGE_SUCCESSFUL)
-    {
-      display_warning("can't change to fullscreen mode");
-    }
-
-    windowedMenu = GetMenu(hwnd_win);
-    if (windowedMenu) SetMenu(hwnd_win, NULL);
-
-    HWND hStatusBar = FindWindowEx(hwnd_win, NULL, "msctls_statusbar32", NULL); // 1964
-    if (hStatusBar) ShowWindow(hStatusBar, SW_HIDE);
-
-    SetWindowLong(hwnd_win, GWL_STYLE, 0);
-    SetWindowLong(hwnd_win, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST);
-    SetWindowPos(hwnd_win, NULL, 0, 0, fullscreenMode.dmPelsWidth, fullscreenMode.dmPelsHeight, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW);
-
-    fullscreen = 1;
-  }
-
-  // save screen resolution for hwfbe, after resolution enumeration
-  screen_width = width;
-  screen_height = height;
-
-  if ((hDC = GetDC(hwnd_win)) == NULL)
-  {
-    display_warning("GetDC on main window failed");
-    return FXFALSE;
-  }
-
-  if ((pfm = ChoosePixelFormat(hDC, &pfd)) == 0) {
-    //printf("disabling auxiliary buffers\n");
-    pfd.cAuxBuffers = 0;
-    pfm = ChoosePixelFormat(hDC, &pfd);
-  }
-  if (pfm == 0)
-  {
-    display_warning("ChoosePixelFormat failed");
-    return FXFALSE;
-  }
-  if (SetPixelFormat(hDC, pfm, &pfd) == 0)
-  {
-    display_warning("SetPixelFormat failed");
-    return FXFALSE;
-  }
-
-  if ((hGLRC = wglCreateContext(hDC)) == 0)
-  {
-    display_warning("wglCreateContext failed!");
-    grSstWinClose(0);
-    return FXFALSE;
-  }
-
-  if (!wglMakeCurrent(hDC, hGLRC))
-  {
-    display_warning("wglMakeCurrent failed!");
-    grSstWinClose(0);
-    return FXFALSE;
-  }
-#else // _WIN32
-
-  // init sdl & gl
-  const SDL_VideoInfo *videoInfo;
-  Uint32 videoFlags = 0;
-  fullscreen = 0;
-
-  /* Initialize SDL */
-  printf("(II) Initializing SDL video subsystem...\n");
-  if(SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
-  {
-    printf("(EE) Error initializing SDL video subsystem: %s\n", SDL_GetError());
+    printf("Could not open video settings");
     return false;
   }
-
-  /* Video Info */
-  printf("(II) Getting video info...\n");
-  if(!(videoInfo = SDL_GetVideoInfo()))
-  {
-    printf("(EE) Video query failed: %s\n", SDL_GetError());
-    SDL_QuitSubSystem(SDL_INIT_VIDEO);
-    return false;
-  }
-
-  /* Setting the video mode */
-  videoFlags |= SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
-
-  if(videoInfo->hw_available)
-    videoFlags |= SDL_HWSURFACE;
-  else
-    videoFlags |= SDL_SWSURFACE;
-
-  if(videoInfo->blit_hw)
-    videoFlags |= SDL_HWACCEL;
-
-  //if (!(screen_resolution & 0x80000000))
-  //videoFlags |= SDL_FULLSCREEN;
-
-  if (screen_resolution & 0x80000000)
-      ;
-      else{
-      SDL_Rect** modes;
-      SDL_Surface *check_surface;
-      SDL_PixelFormat *fmt;
-      int iModeNum;
-      static int res_w = 0, res_h = 0;
-      static int iCount = -1;
-
-    check_surface = SDL_CreateRGBSurface(NULL, 0, 0, 32, 0, 0, 0, 0);
-
-   if (iCount != screen_resolution) {
-
-    fmt=check_surface->format;
-    modes = SDL_ListModes(fmt, SDL_FULLSCREEN|SDL_HWSURFACE);
-
-     for (iModeNum=0; modes[iModeNum]; ++iModeNum){
-         if (fmt->BitsPerPixel == 32) {
-         if (screen_resolution == iCount){
-         res_w = modes[iCount]-> w;
-         res_h = modes[iCount]-> h;
-         break;
-         }
-         iCount++;
-      }
-     }
-   }
-
-   SDL_FreeSurface(check_surface);
-
- width = res_w;
- height = res_h;
-
-      videoFlags |= SDL_FULLSCREEN;
-      fullscreen = 1;
-      }
-
+  width = ConfigGetParamInt(video_general_section, "ScreenWidth");
+  height = ConfigGetParamInt(video_general_section, "ScreenHeight");
+  fullscreen = ConfigGetParamBool(video_general_section, "Fullscreen");
 
   //viewport_offset = ((screen_resolution>>2) > 20) ? screen_resolution >> 2 : 20;
   // ZIGGY viewport_offset is WIN32 specific, with SDL just set it to zero
   viewport_offset = 0; //-10 //-20;
 
   // ZIGGY not sure, but it might be better to let the system choose
-  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-  SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
+  CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, 1);
+  CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, 16);
   //   SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
   //   SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
   //   SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
   //   SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
   //   SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
-  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
+  CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, 16);
 
   printf("(II) Setting video mode %dx%d...\n", width, height);
-  if(!(m_pScreen = SDL_SetVideoMode(width, height, 0, videoFlags)))
+  if(CoreVideo_SetVideoMode(width, height, 0, fullscreen ? M64VIDEO_FULLSCREEN : M64VIDEO_WINDOWED) != M64ERR_SUCCESS)
   {
-    printf("(EE) Error setting videomode %dx%d: %s\n", width, height, SDL_GetError());
-    SDL_QuitSubSystem(SDL_INIT_VIDEO);
+    printf("(EE) Error setting videomode %dx%d\n", width, height);
     return false;
   }
 
 # else // _DEBUG
   sprintf(caption, "Glide64");
 # endif // _DEBUG
-  SDL_WM_SetCaption(caption, caption);
+  CoreVideo_SetCaption(caption);
+
   glViewport(0, viewport_offset, width, height);
-#endif // _WIN32
   lfb_color_fmt = color_format;
   if (origin_location != GR_ORIGIN_UPPER_LEFT) display_warning("origin must be in upper left corner");
   if (nColBuffers != 2) display_warning("number of color buffer is not 2");
   remove_tex(0, 0xfffffff);
 #endif
 
-  //*/
+  // * /
 #ifdef _WIN32
   if (hGLRC)
   {
 #else
   //SDL_QuitSubSystem(SDL_INIT_VIDEO);
   //sleep(2);
-  m_pScreen = NULL;
 #endif
   return FXTRUE;
 }
 FX_ENTRY void FX_CALL
 grBufferSwap( FxU32 swap_interval )
 {
+//  printf("rendercallback is %p\n", renderCallback);
+  if(renderCallback)
+      (*renderCallback)();
   int i;
   LOG("grBufferSwap(%d)\r\n", swap_interval);
   //printf("swap\n");
     return;
   }
 
-#ifdef _WIN32
-  SwapBuffers(wglGetCurrentDC());
-#else // _WIN32
-  SDL_GL_SwapBuffers();
-#endif // _WIN32
+  CoreVideo_GL_SwapBuffers();
   for (i = 0; i < nb_fb; i++)
     fbs[i].buff_clear = 1;
 
 #endif
 }
 
+/*
+// #include <unistd.h>
+FX_ENTRY void FX_CALL
+grBufferSwap( FxU32 swap_interval )
+{
+  if(renderCallback)
+    (*renderCallback)();
+  int i;
+    WriteLog(M64MSG_VERBOSE, "grBufferSwap(%d)\r\n", swap_interval);
+  //printf("swap\n");
+  if (render_to_texture) {
+    display_warning("swap while render_to_texture\n");
+    return;
+  }
+  CoreVideo_GL_SwapBuffers();
+  for (i = 0; i < nb_fb; i++)
+    fbs[i].buff_clear = 1;
+
+  // VP debugging
+#ifdef VPDEBUG
+  dump_stop();
+  SDL_Event event;
+  while (SDL_PollEvent(&event)) {
+    switch (event.type) {
+    case SDL_KEYDOWN:
+      switch (event.key.keysym.sym) {
+        case 'd':
+          printf("Dumping !\n");
+          dump_start();
+          break;
+        case 'w': {
+          static int wireframe;
+          wireframe = !wireframe;
+          glPolygonMode(GL_FRONT_AND_BACK, wireframe? GL_LINE : GL_FILL);
+          break;
+        default:
+          break;
+        }
+      }
+      break;
+    }
+  }
+#endif
+}
+*/
+
+
+
 // frame buffer
 
 FX_ENTRY FxBool FX_CALL
 FX_ENTRY char ** FX_CALL
 grQueryResolutionsExt(FxI32 * Size)
 {
+  return 0;
+/*
 #ifdef _WIN32
   DEVMODE enumMode;
   int iModeNum = 0;
   *Size = _numResolutions;
   return _aResolutions;
 #endif // _WIN32
+*/
 }
 
 FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32* width, FxU32* height)
 {
+  return 0;
+/*
 #ifdef _WIN32
   static DEVMODE enumMode;
   int iModeNum = 0;
 
   return config.res; //!todo Unix functionality
 #endif // _WIN32
+*/
 }
 
 FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key)
 {
+  return 0;
+/*
 #ifdef _WIN32
   return (GetAsyncKeyState(key) & 0x8000);
 #else
     }
   }
 #endif
+*/
 }
 
 FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32 resolution, FxI32 vram, FxBool fbo, FxBool aniso)
   display_warning("grTexMultibaseAddress");
 }
 
-
+/*
 inline void MySleep(FxU32 ms)
 {
-#ifdef _WIN32
+#ifdef _WIN32
   Sleep(ms);
-#else
+#else
   SDL_Delay(ms);
 #endif
-}
-
+}
+*/
+
 #ifdef _WIN32
 static void CorrectGamma(LPVOID apGammaRamp)
 {
     SetDeviceGammaRamp(hdc, apGammaRamp);
     ReleaseDC(NULL, hdc);
   }
-}
+}
 #else
 static void CorrectGamma(const FxU16 aGammaRamp[3][256])
-{
-  int res = SDL_SetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]);
-  LOG("SDL_SetGammaRamp returned %d\r\n", res);
-}
+{
+  //TODO?
+  //int res = SDL_SetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]);
+  //LOG("SDL_SetGammaRamp returned %d\r\n", res);
+}
 #endif
 
 FX_ENTRY void FX_CALL
     aGammaRamp[1][i] = (FxU16)((green[i] << 8) & 0xFFFF);
     aGammaRamp[2][i] = (FxU16)((blue[i] << 8) & 0xFFFF);
   }
-  CorrectGamma(aGammaRamp);
-  MySleep(1000); //workaround for Mupen64
+  CorrectGamma(aGammaRamp);
+  //MySleep(1000); //workaround for Mupen64
 }
 
 FX_ENTRY void FX_CALL
 grGetGammaTableExt(FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue)
 {
-  LOG("grGetGammaTableExt()\r\n");
+  return;
+  //TODO?
+  /*
+  LOG("grGetGammaTableExt()\r\n");
   FxU16 aGammaRamp[3][256];
 #ifdef _WIN32
   HDC hdc = GetDC(NULL);
-  if (hdc == NULL)
+  if (hdc == NULL)
     return;
-  if (GetDeviceGammaRamp(hdc, aGammaRamp) == TRUE)
+  if (GetDeviceGammaRamp(hdc, aGammaRamp) == TRUE)
   {
     ReleaseDC(NULL, hdc);
 #else
-  if (SDL_GetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]) != -1)
+  if (SDL_GetGammaRamp(aGammaRamp[0], aGammaRamp[1], aGammaRamp[2]) != -1)
   {
-#endif
+#endif
     for (int i = 0; i < 256; i++)
     {
       red[i] = aGammaRamp[0][i] >> 8;
       blue[i] = aGammaRamp[2][i] >> 8;
     }
   }
+  */
 }
 
-FX_ENTRY void FX_CALL
-guGammaCorrectionRGB( FxFloat gammaR, FxFloat gammaG, FxFloat gammaB )
-{
-  LOG("guGammaCorrectionRGB()\r\n");
+FX_ENTRY void FX_CALL
+guGammaCorrectionRGB( FxFloat gammaR, FxFloat gammaG, FxFloat gammaB )
+{
+  LOG("guGammaCorrectionRGB()\r\n");
   if (!fullscreen)
     return;
   FxU16 aGammaRamp[3][256];
     aGammaRamp[1][i] = (((FxU16)((pow(i/255.0F, 1.0F/gammaG)) * 255.0F + 0.5F)) << 8) & 0xFFFF;
     aGammaRamp[2][i] = (((FxU16)((pow(i/255.0F, 1.0F/gammaB)) * 255.0F + 0.5F)) << 8) & 0xFFFF;
   }
-  CorrectGamma(aGammaRamp);
-}
+  CorrectGamma(aGammaRamp);
+}
 
 FX_ENTRY void FX_CALL
 grDitherMode( GrDitherMode_t mode )
   display_warning("grTexChromaRangeModeExt");
 }
 
+static void (*l_DebugCallback)(void *, int, const char *) = NULL;
+static void *l_DebugCallContext = NULL;
+
+void WriteLog(m64p_msg_level level, const char *msg, ...)
+{
+  char buf[1024];
+  va_list args;
+  va_start(args, msg);
+  vsnprintf(buf, 1023, msg, args);
+  buf[1023]='\0';
+  va_end(args);
+  if (l_DebugCallback)
+  {
+    l_DebugCallback(l_DebugCallContext, level, buf);
+  }
+}
+
 
 
 // VP debug
 #ifndef MAIN_H
 #define MAIN_H
 
+#include <m64p_types.h>
+
+#define LOG(...) WriteLog(M64MSG_VERBOSE, __VA_ARGS__)
+void WriteLog(m64p_msg_level level, const char *msg, ...);
+
+
 #ifndef _WIN32
 //#define VPDEBUG
 #endif
 #include "glext.h"
 #include "wglext.h"
 }
-#else
-#include <stdio.h>
-//#define printf(...)
-#define GL_GLEXT_PROTOTYPES
+#else
+#include <stdio.h>
+//#define printf(...)
+#define GL_GLEXT_PROTOTYPES
 #include <SDL_opengl.h>
 #endif // _WIN32
 #include "glide.h"
 void updateCombinera(int i);
 void remove_tex(unsigned int idmin, unsigned int idmax);
 void add_tex(unsigned int id);
-
+
 #ifdef _WIN32
 extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
 extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
 extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
 extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
 extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
-extern PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
+extern PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
 #endif
 
 extern int w_buffer_mode;
 #ifdef LOGGING
 void OPEN_LOG();
 void CLOSE_LOG();
-void LOG(const char *text, ...);
+//void LOG(const char *text, ...);
 #else // LOGGING
 #define OPEN_LOG()
 #define CLOSE_LOG()
-#define LOG
+//#define LOG
 #endif // LOGGING
 
 #endif
 //
 //****************************************************************
 
+//#define NOSSE
+
+#ifndef NOSSE
+#include <xmmintrin.h>
+#endif
+#include <math.h>
 #include "Gfx #1.3.h"
 #include "3dmath.h"
 
 
     // Fill tmp with four copies of leftrow[0]
     v4sf tmp = leftrow;
-    tmp = __builtin_ia32_shufps (tmp, tmp, 0);
+    tmp = _mm_shuffle_ps (tmp, tmp, 0);
     // Calculate the four first summands
     v4sf destrow = tmp * row0;
 
     // Fill tmp with four copies of leftrow[1]
     tmp = leftrow;
-    tmp = __builtin_ia32_shufps (tmp, tmp, 1 + (1 << 2) + (1 << 4) + (1 << 6));
+    tmp = _mm_shuffle_ps (tmp, tmp, 1 + (1 << 2) + (1 << 4) + (1 << 6));
     destrow += tmp * row1;
 
     // Fill tmp with four copies of leftrow[2]
     tmp = leftrow;
-    tmp = __builtin_ia32_shufps (tmp, tmp, 2 + (2 << 2) + (2 << 4) + (2 << 6));
+    tmp = _mm_shuffle_ps (tmp, tmp, 2 + (2 << 2) + (2 << 4) + (2 << 6));
     destrow += tmp * row2;
 
     // Fill tmp with four copies of leftrow[3]
     tmp = leftrow;
-    tmp = __builtin_ia32_shufps (tmp, tmp, 3 + (3 << 2) + (3 << 4) + (3 << 6));
+    tmp = _mm_shuffle_ps (tmp, tmp, 3 + (3 << 2) + (3 << 4) + (3 << 6));
     destrow += tmp * row3;
 
     __builtin_ia32_storeups(r[i], destrow);
 #ifdef UNIMP_LOG
     if (settings.log_unk)
     {
-      sprintf (out_buf, "COLOR combine not found: %08lx, #1: (%s-%s)*%s+%s, #2: (%s-%s)*%s+%s\n",
+      sprintf (out_buf, "COLOR combine not found: %08x, #1: (%s-%s)*%s+%s, #2: (%s-%s)*%s+%s\n",
         actual_combine,
         Mode0[rdp.cycle1&0xF], Mode1[(rdp.cycle1>>4)&0xF], Mode2[(rdp.cycle1>>8)&0x1F], Mode3[(rdp.cycle1>>13)&7],
         Mode0[rdp.cycle2&0xF], Mode1[(rdp.cycle2>>4)&0xF], Mode2[(rdp.cycle2>>8)&0x1F], Mode3[(rdp.cycle2>>13)&7]);
 #ifdef UNIMP_LOG
       if (settings.log_unk)
       {
-        sprintf (out_buf, "ALPHA combine not found: %08lx, #1: (%s-%s)*%s+%s, #2: (%s-%s)*%s+%s\n",
+        sprintf (out_buf, "ALPHA combine not found: %08x, #1: (%s-%s)*%s+%s, #2: (%s-%s)*%s+%s\n",
           actual_combine,
           Alpha0[(rdp.cycle1>>16)&7], Alpha1[(rdp.cycle1>>19)&7], Alpha2[(rdp.cycle1>>22)&7], Alpha3[(rdp.cycle1>>25)&7],
           Alpha0[(rdp.cycle2>>16)&7], Alpha1[(rdp.cycle2>>19)&7], Alpha2[(rdp.cycle2>>22)&7], Alpha3[(rdp.cycle2>>25)&7]);
   const char *extensions = grGetString (GR_EXTENSION);
   if (const char * extstr = strstr(extensions, "COMBINE")) {
     if (!strncmp(extstr, "COMBINE", 7)) {
-      LOG ("extensions ");
+      LOG ("extensions ");
       char strColorCombineExt[] = "grColorCombineExt";
-      cmb.grColorCombineExt = (GRCOLORCOMBINEEXT) grGetProcAddress(strColorCombineExt);
+      cmb.grColorCombineExt = (GRCOLORCOMBINEEXT) grGetProcAddress(strColorCombineExt);
       char strAlphaCombineExt[] = "grAlphaCombineExt";
-      cmb.grAlphaCombineExt = (GRCOLORCOMBINEEXT) grGetProcAddress(strAlphaCombineExt);
-      char strTexColorCombineExt[] = "grTexColorCombineExt";
+      cmb.grAlphaCombineExt = (GRCOLORCOMBINEEXT) grGetProcAddress(strAlphaCombineExt);
+      char strTexColorCombineExt[] = "grTexColorCombineExt";
       cmb.grTexColorCombineExt = (GRTEXCOLORCOMBINEEXT) grGetProcAddress(strTexColorCombineExt);
-      char strTexAlphaCombineExt[] = "grTexAlphaCombineExt";
+      char strTexAlphaCombineExt[] = "grTexAlphaCombineExt";
       cmb.grTexAlphaCombineExt = (GRTEXCOLORCOMBINEEXT) grGetProcAddress(strTexAlphaCombineExt);
-      char strConstantColorValueExt[] = "grConstantColorValueExt";
+      char strConstantColorValueExt[] = "grConstantColorValueExt";
       cmb.grConstantColorValueExt = (GRCONSTANTCOLORVALUEEXT) grGetProcAddress(strConstantColorValueExt);
       if (cmb.grColorCombineExt && cmb.grAlphaCombineExt &&
         cmb.grTexColorCombineExt && cmb.grTexAlphaCombineExt)
-/*
-* Glide64 - Glide video plugin for Nintendo 64 emulators.
-* Copyright (c) 2002  Dave2001
-* Copyright (c) 2003-2009  Sergey 'Gonetz' Lipski
-*
-* 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
-* 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-//****************************************************************
-//
-// Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64)
-// Project started on December 29th, 2001
-//
-// Authors:
-// Dave2001, original author, founded the project in 2001, left it in 2002
-// Gugaman, joined the project in 2002, left it in 2002
-// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
-// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
-//
-//****************************************************************
-//
-// To modify Glide64:
-// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
-// * Do NOT send me the whole project or file that you modified.  Take out your modified code sections, and tell me where to put them.  If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
-//
-//****************************************************************
-//
-// Glide64 dialogs
-// Created by Gonetz, 2008
-//
-//****************************************************************
-
-
-// -*- C++ -*- generated by wxGlade 0.6.3 on Tue Oct 07 22:39:28 2008
-
-#include "Gfx #1.3.h"
-#include "DepthBufferRender.h"
-#include "Config.h"
-#include <wx/file.h>
-#include <wx/dir.h>
-// begin wxGlade: ::extracode
-// end wxGlade
-
-
-
-ConfigNotebook::ConfigNotebook(wxWindow* parent, int id, const wxPoint& pos, const wxSize& size, long style):
-wxNotebook(parent, id, pos, size, 0)
-{
-  // begin wxGlade: ConfigNotebook::ConfigNotebook
-  //Basic settings panel
-  BasicSettingsPanel = new wxPanel(this, wxID_ANY);
-  BasicRenderingSizer_staticbox = new wxStaticBox(BasicSettingsPanel, -1, _("Rendering"));
-  OtherSizer_staticbox = new wxStaticBox(BasicSettingsPanel, -1, _("Other"));
-  SpeedSizer_staticbox = new wxStaticBox(BasicSettingsPanel, -1, _("Speed"));
-  TimeSizer_staticbox = new wxStaticBox(BasicSettingsPanel, -1, _("Time"));
-  OnScreenDisplaySizer_staticbox = new wxStaticBox(BasicSettingsPanel, -1, _("On screen display"));
-  WrapperSizer_staticbox = new wxStaticBox(BasicSettingsPanel, -1, _("OpenGL settings"));
-  WrapperFBOptionsSizer_staticbox = new wxStaticBox(BasicSettingsPanel, -1, _("Frame buffer emulation"));
-  lblResolution = new wxStaticText(BasicSettingsPanel, wxID_ANY, _("Windowed or\n3dfx card resolution:"));
-  const wxString cmbResolution_choices[] = {
-    wxT("320x200"),
-    wxT("320x240"),
-    wxT("400x256"),
-    wxT("512x384"),
-    wxT("640x200"),
-    wxT("640x350"),
-    wxT("640x400"),
-    wxT("640x480"),
-    wxT("800x600"),
-    wxT("960x720"),
-    wxT("856x480"),
-    wxT("512x256"),
-    wxT("1024x768"),
-    wxT("1280x1024"),
-    wxT("1600x1200"),
-    wxT("400x300"),
-    wxT("1152x864"),
-    wxT("1280x960"),
-    wxT("1600x1024"),
-    wxT("1792x1344"),
-    wxT("1856x1392"),
-    wxT("1920x1440"),
-    wxT("2048x1536"),
-    wxT("2048x2048")
-  };
-  cmbResolution = new wxComboBox(BasicSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 24, cmbResolution_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-  cbxVSync = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Vertical sync"));
-  cbxAdvancedSettings = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Show advanced emulation options"));
-  cbxTextureSettings = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Show texture enhancement options"));
-  lblScreenShotFormat = new wxStaticText(BasicSettingsPanel, wxID_ANY, _("Screenshot format:"));
-  cmbScreenShotFormat = new wxComboBox(BasicSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-  lang_id = settings.lang_id;
-  wxString strLanguage = _("Language: ");
-  wxString strLanguageName = lang_id == wxLANGUAGE_ENGLISH_US ? wxLocale::GetLanguageName(lang_id) : wxString(_("LANGUAGE_NAME"));
-  if (strLanguageName != wxT("LANGUAGE_NAME"))
-    strLanguage += strLanguageName;
-  else
-    strLanguage += wxLocale::GetLanguageName(lang_id);
-  btnLanguage = new wxButton(BasicSettingsPanel, wxID_Language, strLanguage);
-  cbxFPS = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("FPS counter"));
-  cbxVIS = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("VI/s counter"));
-  cbxPercent = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("% speed"));
-  cbxClockEnabled = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Clock enabled"));
-  cbxClock24 = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Clock is 24-hour"));
-  cbxTextTransparent = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Transparent text background"));
-  lblFSResolution = new wxStaticText(BasicSettingsPanel, wxID_ANY, _("Full screen\nresolution:"));
-  const wxString *cmbFSResolution_choices = NULL;
-  cmbFSResolution = new wxComboBox(BasicSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0, cmbFSResolution_choices, wxCB_DROPDOWN|wxCB_READONLY);
-  cbxAnisotropic = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Anisotropic filtering"));
-  cbxVRAM = new wxCheckBox(BasicSettingsPanel, wxID_VRAM, _("Autodetect "));
-  lblVRAM = new wxStaticText(BasicSettingsPanel, wxID_ANY, _("VRAM size"));
-  spinVRAM = new wxSpinCtrl(BasicSettingsPanel, wxID_ANY, wxT("128"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxTE_CENTRE, 32, 2000);
-  lblMb = new wxStaticText(BasicSettingsPanel, wxID_ANY, _("Mb"));
-  cbxFBO = new wxCheckBox(BasicSettingsPanel, wxID_ANY, _("Use frame buffer objects"));
-
-  //emulation settings panel
-  if (settings.advanced_options)
-  {
-    EmuSettingsPanel = new wxPanel(this, wxID_ANY);
-    if (romopen)
-      EmuSettingsBoxSizer_staticbox = new wxStaticBox(EmuSettingsPanel, -1, _("Current game emulation settings. Change with care!"));
-    else
-      EmuSettingsBoxSizer_staticbox = new wxStaticBox(EmuSettingsPanel, -1, _("Default emulation settings. Not recommended to change!"));
-    EmuSettingsLeftSizer_staticbox = new wxStaticBox(EmuSettingsPanel, -1, _("General options"));
-    FrameBufferSizer_staticbox = new wxStaticBox(EmuSettingsPanel, -1, _("Frame buffer emulation"));
-    DepthBufferSizer_staticbox = new wxStaticBox(EmuSettingsPanel, -1, _("Depth buffer emulation"));
-    lbFiltering = new wxStaticText(EmuSettingsPanel, wxID_ANY, _("Filtering mode:"));
-    const wxString cmbFiltering_choices[] = {
-      _("Automatic"),
-      _("Force Bilinear"),
-      _("Force Point-sampled")
-    };
-    cmbFiltering = new wxComboBox(EmuSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 3, cmbFiltering_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-    lbBufferSwap = new wxStaticText(EmuSettingsPanel, wxID_ANY, _("Buffer swapping method:"));
-    const wxString cmbBufferSwap_choices[] = {
-      _("Old"),
-      _("New"),
-      _("Hybrid")
-    };
-    cmbBufferSwap = new wxComboBox(EmuSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 3, cmbBufferSwap_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-    lblLOD = new wxStaticText(EmuSettingsPanel, wxID_ANY, _("LOD calculation:"));
-    const wxString cmbLOD_choices[] = {
-      _("off"),
-      _("fast"),
-      _("precise")
-    };
-    cmbLOD = new wxComboBox(EmuSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 3, cmbLOD_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-    lblAspect = new wxStaticText(EmuSettingsPanel, wxID_ANY, _("Aspect ratio:"));
-    const wxString cmbAspect_choices[] = {
-      _("4:3 (default)"),
-      _("Force 16:9"),
-      _("Stretch")
-    };
-    cmbAspect = new wxComboBox(EmuSettingsPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 3, cmbAspect_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-    cbxFog = new wxCheckBox(EmuSettingsPanel, wxID_ANY, _("Fog"));
-    cbxBuffer = new wxCheckBox(EmuSettingsPanel, wxID_ANY, _("Buffer clear on every frame"));
-    cbxFBEnable = new wxCheckBox(EmuSettingsPanel, wxID_FBEnable, _("Enable frame buffer emulation"));
-    cbxFBHWFBE = new wxCheckBox(EmuSettingsPanel, wxID_ANY, _("Hardware frame buffer emulation"));
-    cbxFBGetFBI = new wxCheckBox(EmuSettingsPanel, wxID_ANY, _("Get frame buffer info"));
-    cbxFBReadEveryFrame = new wxCheckBox(EmuSettingsPanel, wxID_ANY, _("Read every frame (slow!)"));
-    cbxFBasTex = new wxCheckBox(EmuSettingsPanel, wxID_ANY, _("Render N64 frame buffer as texture"));
-    cbxDetect = new wxCheckBox(EmuSettingsPanel, wxID_ANY, _("Detect CPU write to the N64 frame buffer"));
-    cbxFBDepthBuffer = new wxCheckBox(EmuSettingsPanel, wxID_ANY, _("Software depth buffer rendering"));
-  }
-
-#ifdef TEXTURE_FILTER
-  if (settings.texenh_options)
-  {
-    if (!fullscreen)
-    {
-      grGlideInit ();
-      grSstSelect (settings.card_id);
-    }
-    const char *extensions = grGetString (GR_EXTENSION);
-    if (strstr (extensions, "EVOODOO"))
-      evoodoo = 1;
-    else
-      evoodoo = 0;
-    if (strstr (extensions, "TEXFMT"))
-      voodoo.sup_32bit_tex = TRUE;
-    else
-      voodoo.sup_32bit_tex = FALSE;
-    if (!fullscreen)
-      grGlideShutdown ();
-
-    TexturePanel = new wxPanel(this, wxID_ANY);
-    EnhTexSizer_staticbox = new wxStaticBox(TexturePanel, -1, _("Texture enhancement"));
-    TextureRightSizer_staticbox = new wxStaticBox(TexturePanel, -1, _("Hi-resolution textures"));
-    CommonSizer_staticbox = new wxStaticBox(TexturePanel, -1, _("Common"));
-    PresetsSizer_staticbox = new wxStaticBox(TexturePanel, -1, _("Presets"));
-    EnhTexPerfTweaksSizer_staticbox = new wxStaticBox(TexturePanel, -1, _("Performance tweaks"));
-    HRTexPerfTweaksSizer_staticbox = new wxStaticBox(TexturePanel, -1, _("Performance tweaks"));
-    lblFilter = new wxStaticText(TexturePanel, wxID_ANY, _("Filter"));
-    const wxString cmbEnhFilter_choices[] = {
-      _("None"),
-      _("Smooth filtering 1"),
-      _("Smooth filtering 2"),
-      _("Smooth filtering 3"),
-      _("Smooth filtering 4"),
-      _("Sharp filtering 1"),
-      _("Sharp filtering 2")
-    };
-    cmbEnhFilter = new wxComboBox(TexturePanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 7, cmbEnhFilter_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-    lblEnhancement = new wxStaticText(TexturePanel, wxID_ANY, _("Enhancement"));
-    const wxString cmbEnhEnhancement_choices[] = {
-      _("None"),
-      _("Store"),
-      wxT("X2"),
-      wxT("X2SAI"),
-      wxT("HQ2X"),
-      wxT("HQ2XS"),
-      wxT("LQ2X"),
-      wxT("LQ2XS"),
-      wxT("HQ4X")
-    };
-    cmbEnhEnhancement = new wxComboBox(TexturePanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 9, cmbEnhEnhancement_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-    lblTexCache = new wxStaticText(TexturePanel, wxID_ANY, _("Texture cache"));
-    spinEnhCacheSize = new wxSpinCtrl(TexturePanel, wxID_ANY, wxT("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 300);
-    lblTexCacheMB = new wxStaticText(TexturePanel, wxID_ANY, _("Mbytes"));
-    cbxEnhIgnoreBG = new wxCheckBox(TexturePanel, wxID_ANY, _("Ignore Backgrounds"));
-    cbxEnhTexCompression = new wxCheckBox(TexturePanel, wxID_ANY, _("Apply texture compression"));
-    cbxEnhCompressCache = new wxCheckBox(TexturePanel, wxID_ANY, _("Compress texture cache"));
-    lblHrsFormat = new wxStaticText(TexturePanel, wxID_ANY, _("Format"));
-    const wxString cmbHrsFormat_choices[] = {
-      _("None"),
-      _("Rice format")
-    };
-    cmbHrsFormat = new wxComboBox(TexturePanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 2, cmbHrsFormat_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-    cbxHrsTile = new wxCheckBox(TexturePanel, wxID_ANY, _("Tile textures"));
-    cbxHrsForce16 = new wxCheckBox(TexturePanel, wxID_ANY, _("Force 16bpp textures"));
-    cbxHrsAltCRC = new wxCheckBox(TexturePanel, wxID_ANY, _("Alternative CRC calculation"));
-    cbxHrsTexCompression = new wxCheckBox(TexturePanel, wxID_ANY, _("Apply texture compression"));
-    cbxHrsCompressCache = new wxCheckBox(TexturePanel, wxID_ANY, _("Compress texture cache"));
-    cbxHrsLetFly = new wxCheckBox(TexturePanel, wxID_ANY, _("Use alpha channel fully"));
-    cbxHrsTexEdit = new wxCheckBox(TexturePanel, wxID_TexEdit, _("Texture dumping/editing mode"));
-    lblTexCompression = new wxStaticText(TexturePanel, wxID_ANY, _("Texture compression method"));
-    const wxString cmbTextureCompression_choices[] = {
-      wxT("S3TC"),
-      wxT("FXT1")
-    };
-    cmbTextureCompression = new wxComboBox(TexturePanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, evoodoo ? 1 : 2, cmbTextureCompression_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-    cbxSaveTexCache = new wxCheckBox(TexturePanel, wxID_ANY, _("Save texture cache to hard disk"));
-    btnPerformance = new wxButton(TexturePanel, wxID_Performance, _("Best performance"));
-    btnQuality = new wxButton(TexturePanel, wxID_Quality, _("Best texture quality"));
-  }
-#endif //TEXTURE_FILTER
-
-#ifndef _ENDUSER_RELEASE_
-  DebugPanel = new wxPanel(this, wxID_ANY);
-  DevSettingsSizer_staticbox = new wxStaticBox(DebugPanel, -1, _("Developers settings"));
-  DebugSizer_staticbox = new wxStaticBox(DebugPanel, -1, _("Debug/Misc"));
-  cbxAutoUcode = new wxCheckBox(DebugPanel, wxID_ANY, _("Autodetect Microcode"));
-  lblForceUcode = new wxStaticText(DebugPanel, wxID_ANY, _("Force Microcode:"));
-  const wxString cmbForceUcode_choices[] = {
-    wxT("0: RSP SW 2.0X (ex. Mario)"),
-    wxT("1: F3DEX 1.XX (ex. Star Fox)"),
-    wxT("2: F3DEX 2.XX (ex. Zelda OOT)"),
-    wxT("3: RSP SW 2.0D EXT (ex. Waverace)"),
-    wxT("4: RSP SW 2.0D EXT (ex. Shadows of the Empire)"),
-    wxT("5: RSP SW 2.0 (ex. Diddy Kong Racing)"),
-    wxT("6: S2DEX 1.XX (ex. Yoshi's Story)"),
-    wxT("7: RSP SW PD Perfect Dark"),
-    wxT("8: F3DEXBG 2.08 Conker's Bad Fur Day")
-  };
-  cmbForceUcode = new wxComboBox(DebugPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 9, cmbForceUcode_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-  cbxWireframe = new wxCheckBox(DebugPanel, wxID_ANY, _("Wireframe using:"));
-  const wxString cmbWireframe_choices[] = {
-    _("Original colors"),
-    _("Vertex colors"),
-    _("Red only")
-  };
-  cmbWireframe = new wxComboBox(DebugPanel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 3, cmbWireframe_choices, wxCB_DROPDOWN|wxCB_DROPDOWN|wxCB_READONLY);
-  cbxLog = new wxCheckBox(DebugPanel, wxID_ANY, _("Log to rdp.txt (SLOW)"));
-  cbxCombRed = new wxCheckBox(DebugPanel, wxID_ANY, _("Unknown combiners as red"));
-  cbxLogClear = new wxCheckBox(DebugPanel, wxID_ANY, _("Log clear every frame"));
-  cbxCmbLog = new wxCheckBox(DebugPanel, wxID_ANY, _("Combiner logging"));
-  cbxWindowLog = new wxCheckBox(DebugPanel, wxID_ANY, _("Run (+log) in window"));
-  cbxCmbLogClear = new wxCheckBox(DebugPanel, wxID_ANY, _("Cmb. clear every frame"));
-  cbxErrLog = new wxCheckBox(DebugPanel, wxID_ANY, _("Error log (rdp_e.txt)"));
-  cbxBilinearTexCache = new wxCheckBox(DebugPanel, wxID_ANY, _("Bilinear filter texture cache"));
-#endif //_ENDUSER_RELEASE_
-
-  set_properties();
-  do_layout();
-  // end wxGlade
-}
-
-
-BEGIN_EVENT_TABLE(ConfigNotebook, wxNotebook)
-// begin wxGlade: ConfigNotebook::event_table
-EVT_CHECKBOX(wxID_VRAM, ConfigNotebook::OnClickVRAM)
-EVT_CHECKBOX(wxID_FBEnable, ConfigNotebook::OnClickFB)
-EVT_BUTTON(wxID_Language, ConfigNotebook::OnLanguageSelect)
-#ifdef TEXTURE_FILTER
-EVT_BUTTON(wxID_Performance, ConfigNotebook::onPerformace)
-EVT_BUTTON(wxID_Quality, ConfigNotebook::onQuality)
-EVT_CHECKBOX(wxID_TexEdit, ConfigNotebook::OnClickTexEdit)
-#endif //TEXTURE_FILTER
-//    EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, ConfigNotebook::onPageChanged)
-//    EVT_NOTEBOOK_PAGE_CHANGING(wxID_ANY, ConfigNotebook::onPageChanging)
-// end wxGlade
-END_EVENT_TABLE();
-
-void ConfigNotebook::OnClickVRAM(wxCommandEvent &event)
-{
-  if (event.GetEventObject() == cbxVRAM)
-  {
-    bool enable = !cbxVRAM->GetValue();
-    if (enable)
-      spinVRAM->SetValue(settings.wrpVRAM);
-    else
-      spinVRAM->SetValue(_(" auto"));
-    spinVRAM->Enable(enable);
-    lblMb->Enable(enable);
-  }
-//      event.Skip();
-//      wxLogDebug(wxT("Event handler (ConfigNotebook::FrameBufferOnClick) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
-}
-
-void ConfigNotebook::OnClickFB(wxCommandEvent &event)
-{
-  if (event.GetEventObject() == cbxFBEnable)
-    cbxFBHWFBE->Enable(cbxFBEnable->GetValue());
-  //    event.Skip();
-  //    wxLogDebug(wxT("Event handler (ConfigNotebook::FrameBufferOnClick) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
-}
-
-static wxString GetTranslationsPath()
-{
-  if (!iniPath.IsEmpty())
-    return iniPath; //.BeforeLast(wxFileName::GetPathSeparator());
-  return pluginPath;
-}
-
-void ConfigNotebook::OnLanguageSelect(wxCommandEvent &event)
-{
-  if (event.GetEventObject() != btnLanguage)
-    event.Skip();
-  wxArrayString files;
-  size_t nbLangs = wxDir::GetAllFiles(GetTranslationsPath(), &files, wxString(wxT("Glide64_*.mo")), wxDIR_FILES);
-  if (nbLangs == 0)
-  {
-      wxMessageBox(wxT("No translation (Glide64_*.mo) files found.\nUsing default language."), wxT("Files not found"), wxOK|wxICON_EXCLAMATION);
-      settings.lang_id = wxLANGUAGE_ENGLISH_US;
-      return;
-  }
-  size_t i;
-  wxArrayInt aLangIds;
-  wxArrayString aLangNames;
-  const wxLanguageInfo * info = wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH_US);
-  aLangIds.Add(info->Language);
-  aLangNames.Add(info->Description);
-  for (i = 0; i < nbLangs; i++)
-  {
-    info = wxLocale::FindLanguageInfo(wxFileName(files[i]).GetName().AfterFirst('_'));
-    if (info && wxLocale::IsAvailable(info->Language)) {
-      //vLangInfos.push_back(LangInfo(info->Description, info->Language));
-      aLangIds.Add(info->Language);
-      aLangNames.Add(info->Description);
-    }
-  }
-  if (aLangIds.Count() == 1)
-  {
-      wxMessageBox(wxT("No translations supported by your OS found.\nUsing default language."), wxT("Files not found"), wxOK|wxICON_EXCLAMATION);
-      settings.lang_id = wxLANGUAGE_ENGLISH_US;
-      return;
-  }
-  int lng = wxGetSingleChoiceIndex (
-              _("Please choose language:"),
-              _("Language"),
-              aLangNames,
-              this
-            );
-  if (lng != -1 && lang_id != aLangIds[lng])
-  {
-    lang_id = aLangIds[lng];
-    wxString strLanguage(_("Press OK to change to "));
-    strLanguage += aLangNames[lng];
-    btnLanguage->wxButton::SetLabel(strLanguage);
-  }
-}
-
-#ifdef TEXTURE_FILTER
-void ConfigNotebook::onPerformace(wxCommandEvent &event)
-{
-  cbxEnhCompressCache->SetValue(true);
-  cbxHrsCompressCache->SetValue(true);
-  cbxEnhIgnoreBG->SetValue(true);
-  cbxHrsAltCRC->SetValue(true);
-  cbxHrsLetFly->SetValue(true);
-  cbxSaveTexCache->SetValue(true);
-  cmbTextureCompression->SetSelection(0);
-  cbxHrsTexCompression->SetValue(false);
-  cbxEnhTexCompression->SetValue(false);
-  cbxHrsTexEdit->SetValue(false);
-
-  if (voodoo.sup_32bit_tex)
-  {
-    cbxHrsTexCompression->SetValue(true);
-    cbxEnhTexCompression->SetValue(true);
-    cmbTextureCompression->SetSelection(1);
-  }
-  else
-  {
-    cbxHrsForce16->SetValue(true);
-  }
-  //    event.Skip();
-  //    wxLogDebug(wxT("Event handler (ConfigNotebook::onPerformace) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
-}
-
-
-void ConfigNotebook::onQuality(wxCommandEvent &event)
-{
-  cbxEnhCompressCache->SetValue(true);
-  cbxHrsCompressCache->SetValue(true);
-  cbxEnhIgnoreBG->SetValue(false);
-  cbxHrsTile->SetValue(false);
-  cbxHrsAltCRC->SetValue(true);
-  cbxHrsLetFly->SetValue(true);
-  cbxSaveTexCache->SetValue(true);
-  cmbTextureCompression->SetSelection(0);
-  cbxHrsTexCompression->SetValue(false);
-  cbxEnhTexCompression->SetValue(false);
-  cbxHrsTexEdit->SetValue(false);
-  cbxHrsForce16->SetValue(false);
-
-  if (!voodoo.sup_32bit_tex)
-  {
-    cbxHrsForce16->SetValue(true);
-  }
-  //    event.Skip();
-  //    wxLogDebug(wxT("Event handler (ConfigNotebook::onQuality) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
-}
-
-void ConfigNotebook::OnClickTexEdit(wxCommandEvent &event)
-{
-  if (event.GetEventObject() == cbxHrsTexEdit)
-  {
-    bool val = !cbxHrsTexEdit->GetValue();
-    cbxHrsAltCRC->Enable(val);
-    if (val)
-      cbxHrsAltCRC->SetValue(settings.ghq_hirs_altcrc>0);
-    else
-      cbxHrsAltCRC->SetValue(false);
-  }
-  //    event.Skip();
-  //    wxLogDebug(wxT("Event handler (ConfigNotebook::FrameBufferOnClick) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
-}
-#endif //TEXTURE_FILTER
-
-/*
-void ConfigNotebook::onPageChanged(wxNotebookEvent &event)
-{
-event.Skip();
-wxLogDebug(wxT("Event handler (ConfigNotebook::onPageChanged) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
-}
-
-
-void ConfigNotebook::onPageChanging(wxNotebookEvent &event)
-{
-event.Skip();
-wxLogDebug(wxT("Event handler (ConfigNotebook::onPageChanging) not implemented yet")); //notify the user that he hasn't implemented the event handler yet
-}
-*/
-
-// wxGlade: add ConfigNotebook event handlers
-
-
-void ConfigNotebook::set_properties()
-{
-  // begin wxGlade: ConfigNotebook::set_properties
-  //Basic panel
-  AddPage(BasicSettingsPanel, _("Basic settings"));
-  wxString tooltip = _("Resolution\nThis option selects the fullscreen resolution for 3dfx cards and windowed resolution for other cards\n(note again that for 3dfx cards the plugin must be in fullscreen mode to see anything).\n[Recommended: 640x480, 800x600, 1024x768]");
-  lblResolution->SetToolTip(tooltip);
-  cmbResolution->SetToolTip(tooltip);
-  cmbResolution->SetSelection(settings.res_data);
-  cbxVSync->SetToolTip(_("Vertical sync\nThis option will enable the vertical sync, which will prevent tearing.\nNote: this option will ONLY have effect if vsync is set to \"Software Controlled\".\n"));
-  cbxVSync->SetValue(settings.vsync>0);
-  tooltip = _("Select a format, in which screen shots will be saved");
-  lblScreenShotFormat->SetToolTip(tooltip);
-  cmbScreenShotFormat->SetToolTip(tooltip);
-  for (int f = 0; f < NumOfFormats; f++) {
-    cmbScreenShotFormat->Append(ScreenShotFormats[f].format);
-  }
-  cmbScreenShotFormat->SetSelection(settings.ssformat);
-  btnLanguage->SetToolTip(_("Language select:\nPress the button to invoke language selection dialog.\nSelected language will be activated after restart of the configuration dialog."));
-  cbxFPS->SetToolTip(_("FPS counter\nWhen this option is checked, a FPS (frames per second) counter will be shown\nin the lower left corner of the screen.\n[Recommended: your preference]"));
-  cbxFPS->SetValue((settings.show_fps&1) > 0);
-  cbxVIS->SetToolTip(_("VI/s counter\nWhen this option is checked, a VI/s (vertical interrupts per second) counter\nwill be shown in the lower left corner of the screen.  This is like the FPS\ncounter but will be consistent at 60 VI/s for full speed on NTSC (U) games and\n50 VI/s for full speed on PAL (E) ones.\n[Recommended: your preference]"));
-  cbxVIS->SetValue((settings.show_fps&2) > 0);
-  cbxPercent->SetToolTip(_("% speed\nThis displays a percentage of the actual N64 speed in the lower\nleft corner of the screen.\n[Recommended: your preference]"));
-  cbxPercent->SetValue((settings.show_fps&4) > 0);
-  cbxClockEnabled->SetToolTip(_("Clock enabled\nThis option will put a clock in the lower right corner of the screen, showing the current time.\n[Recommended: your preference]"));
-  cbxClockEnabled->SetValue(settings.clock>0);
-  cbxClock24->SetValue(settings.clock_24_hr>0);
-  cbxClock24->SetToolTip(_("Display hours as 24-hour clock.\n[Recommended: your preference]"));
-  cbxTextTransparent->SetToolTip(_("Transparent text background\nIf this is checked, all on-screen messages will have a transparent background.  Otherwise, it will have a solid black background.\n[Recommended: your preference]"));
-  cbxTextTransparent->SetValue((settings.show_fps&8) > 0);
-  cbxAdvancedSettings->SetValue(settings.advanced_options > 0);
-  cbxAdvancedSettings->SetToolTip(_("Enable \"Emulation settings\" panel. For experienced users only!\nIt shows default emulation settings when game is not loaded, or current game settings otherwise."));
-  cbxTextureSettings->SetValue(settings.texenh_options > 0);
-  cbxTextureSettings->SetToolTip(_("Enable \"Texture enhancement\" panel.\nIt shows various enhancement options for original textures as well as options for hi-resolution textures."));
-  tooltip = _("Full screen resolution:\nThis sets the full screen resolution for non-3dfx video cards.\nAll the resolutions that your video card/monitor support should be displayed.\n[Recommended: native (max) resolution of your monitor - unless performance becomes an issue]");
-  lblFSResolution->SetToolTip(tooltip);
-  cmbFSResolution->SetToolTip(tooltip);
-  cbxAnisotropic->SetToolTip(_("Anisotropic filtering:\nThis filter sharpens and brings out the details of textures that recede into the distance.\nWhen activated, it will use the max anisotropy your video card supports.\nHowever, this will override native way of texture filtering and may cause visual artifacts in some games.\n[Recommended: your preference, game dependant]"));
-  cbxVRAM->SetToolTip(_("Autodetect VRAM Size:\nSince OpenGL cannot do this reliably at the moment, the option to set this manually is available.\nIf checked, plugin will try to autodetect VRAM size.\nBut if this appears wrong, please uncheck and set it to correct value.\n[Recommended: on]"));
-  spinVRAM->SetMinSize(wxSize(55, 21));
-  cbxFBO->SetToolTip(_("Use frame buffer objects:\nChanges the way FB effects are rendered - with or without usage of the OpenGL Frame Buffer Objects (FBO) extension.\nThe choice depends on game and your video card. FBO off is good for NVIDIA cards, while for ATI cards, it's usually best that FBOs are turned on.\nAlso, some FB effects works only with one of the methods, no matter, which card you have.\nOn the whole, with FBO off, compatibility/ accuracy is a bit better (which is the case for Resident Evil 2).\nHowever, with FBO on with some systems, it can actually be a bit faster in cases.\n[Recommended: video card and game dependant]"));
-  char strConfigWrapperExt[] = "grConfigWrapperExt";
-  GRCONFIGWRAPPEREXT grConfigWrapperExt = (GRCONFIGWRAPPEREXT)grGetProcAddress(strConfigWrapperExt);
-  if (grConfigWrapperExt)
-  {
-    char strQueryResolutionsExt[] = "grQueryResolutionsExt";
-    GRQUERYRESOLUTIONSEXT grQueryResolutionsExt = (GRQUERYRESOLUTIONSEXT)grGetProcAddress(strQueryResolutionsExt);
-    if (grQueryResolutionsExt)
-    {
-      FxI32 size = 0;
-      char ** aRes = grQueryResolutionsExt(&size);
-      if (aRes && size)
-      {
-        for (int r = 0; r < size; r++) {
-          wxString res(aRes[r], wxConvUTF8);
-          cmbFSResolution->Append(res);
-        }
-        cmbFSResolution->SetSelection(settings.wrpResolution < size ? settings.wrpResolution : 0);
-      }
-    }
-#ifdef __WINDOWS__
-    cbxVRAM->SetValue(settings.wrpVRAM == 0);
-    if (cbxVRAM->GetValue())
-      spinVRAM->SetValue(_(" auto"));
-    else
-      spinVRAM->SetValue(settings.wrpVRAM);
-    spinVRAM->Enable(!cbxVRAM->GetValue());
-    lblMb->Enable(!cbxVRAM->GetValue());
-#else
-    cbxVRAM->SetValue(false);
-    cbxVRAM->Disable();
-    spinVRAM->SetValue(settings.wrpVRAM ? settings.wrpVRAM : 32);
-    spinVRAM->Enable(true);
-    lblMb->Enable(true);
-#endif
-    cbxFBO->SetValue(settings.wrpFBO > 0);
-    cbxAnisotropic->SetValue(settings.wrpAnisotropic > 0);
-  }
-  else
-  {
-    WrapperSizer_staticbox->Disable();
-    WrapperFBOptionsSizer_staticbox->Disable();
-    lblFSResolution->Disable();
-    cmbFSResolution->Disable();
-    cbxAnisotropic->Disable();
-    cbxVRAM->Disable();
-    lblVRAM->Disable();
-    spinVRAM->Disable();
-    lblMb->Disable();
-    cbxFBO->Disable();
-  }
-
-  //emulation settings panel
-  if (settings.advanced_options)
-  {
-    AddPage(EmuSettingsPanel, _("Emulation settings"));
-    tooltip = _("Filtering mode\nThere are three filtering modes possible:\n* Automatic filtering - filter exactly how the N64 specifies.\n* Point-sampled filtering - causes texels to appear square and sharp.\n* Bilinear filtering - interpolates the texture to make it appear more smooth.\n[Recommended: Automatic]");
-    lbFiltering->SetToolTip(tooltip);
-    cmbFiltering->SetToolTip(tooltip);
-    cmbFiltering->SetSelection(settings.filtering);
-    tooltip = _("Buffer swapping method\nThere are 3 buffer swapping methods:\n* old - swap buffers when vertical interrupt has occured.\n* new - swap buffers when set of conditions is satisfied. Prevents flicker on some games.\n* hybrid - mix of first two methods.\nCan prevent even more flickering then previous method, but also can cause artefacts.\nIf you have flickering problems in a game (or graphics that don't show),\ntry to change swapping method.\n[Recommended: new (hybrid for Paper Mario)]");
-    lbBufferSwap->SetToolTip(tooltip);
-    cmbBufferSwap->SetToolTip(tooltip);
-    cmbBufferSwap->SetSelection(settings.swapmode);
-    tooltip = _("Per-pixel level-of-detail calculation\nN64 uses special mechanism for mip-mapping, which nearly impossible to reproduce\ncorrectly on PC hardware. This option enables approximate emulation of this feature.\nFor example, it is required for the Peach/Bowser portrait's transition in Super Mario 64.\nThere are 3 modes:\n* off - LOD is not calculated\n* fast - fast imprecise LOD calculation.\n* precise - most precise LOD calculation possible, but more slow.\n[Recommended: your preference]");
-    lblLOD->SetToolTip(tooltip);
-    cmbLOD->SetToolTip(tooltip);
-    cmbLOD->SetSelection(settings.lodmode);
-    cmbAspect->SetSelection(settings.aspectmode);
-    tooltip = _("Aspect ratio of the output.\nMost N64 games use 4:3 aspect ratio, but some support widescreen too.\nYou may select appropriate aspect here and set widescreen mode in game settings.\nIn \"Stretch\" mode the output will be stretched to the entire screen,\nother modes may add black borders if necessary");
-    cmbAspect->SetToolTip(tooltip);
-    lblAspect->SetToolTip(tooltip);
-    cbxFog->SetToolTip(_("Fog enabled\nSets fog emulation on//off.\n[Recommended: on]"));
-    cbxFog->SetValue(settings.fog>0);
-    cbxBuffer->SetToolTip(_("Buffer clear on every frame\nForces the frame buffer to be cleared every frame drawn.\nUsually frame buffer clear is controlled by the game.\nHowever, in some cases it is not well emulated,\nand some garbage may be left on the screen.\nIn such cases, this option must be set on.\n[Recommended: on]"));
-    cbxBuffer->SetValue(settings.buff_clear>0);
-    cbxFBEnable->SetToolTip(_("Enable frame buffer emulation\nIf on, plugin will try to detect frame buffer usage and apply appropriate frame buffer emulation.\n[Recommended: on for games which use frame buffer effects]"));
-    cbxFBEnable->SetValue(fb_emulation_enabled);
-    cbxFBHWFBE->SetToolTip(_("Enable hardware frame buffer emulation\nIf this option is on, plugin will create auxilary frame buffers in video memory instead of copying\nframe buffer content into main memory. This allows plugin to run frame buffer effects without slowdown\nand without scaling image down to N64's native resolution. This feature is fully supported by\nVoodoo 4/5 cards and partially by Voodoo3 and Banshee. Modern cards also fully support it.\n[Recommended: on, if supported by your hardware]"));
-    cbxFBHWFBE->SetValue(((settings.frame_buffer&fb_hwfbe)>0));
-    cbxFBHWFBE->Enable(fb_emulation_enabled);
-    cbxFBGetFBI->SetToolTip(_("Get information about frame buffers\nThis is compatibility option. It must be set on for Mupen64 and off for 1964"));
-    cbxFBGetFBI->SetValue((settings.frame_buffer&fb_get_info)>0);
-    cbxFBReadEveryFrame->SetToolTip(_("Read every frame\nIn some games plugin can't detect frame buffer usage.\nIn such cases you need to enable this option to see frame buffer effects.\nEvery drawn frame will be read from video card -> it works very slow.\n[Recommended: mostly off (needed only for a few games)]"));
-    cbxFBReadEveryFrame->SetValue((settings.frame_buffer&fb_ref)>0);
-    cbxFBasTex->SetToolTip(_("Render N64 frame buffer as texture\nWhen this option is enabled, content of each N64 frame buffer is rendered\nas texture over the frame, rendered by the plugin. This prevents graphics lost,\nbut may cause slowdowns and various glitches in some games.\n[Recommended: mostly off]"));
-    cbxFBasTex->SetValue((settings.frame_buffer&fb_read_back_to_screen)>0);
-    cbxDetect->SetToolTip(_("Detect CPU write to the N64 frame buffer\nThis option works as the previous options, but the plugin is trying to detect,\nwhen game uses CPU writes to N64 frame buffer. The N64 frame buffer is rendered\nonly when CPU writes is detected. Use this option for those games, in which you\nsee still image or no image at all for some time with no reason.\n[Recommended: mostly off]"));
-    cbxDetect->SetValue((settings.frame_buffer&fb_cpu_write_hack)>0);
-    cbxFBDepthBuffer->SetToolTip(_("Enable depth buffer rendering\nThis option is used to fully emulate N64 depth buffer.\nIt is required for correct emulation of depth buffer based effects.\nHowever, it requires fast (>1GHz) CPU to work full speed.\n[Recommended: on for fast PC]"));
-    cbxFBDepthBuffer->SetValue((settings.frame_buffer&fb_depth_render)>0);
-  }
-
-#ifdef TEXTURE_FILTER
-  if (settings.texenh_options)
-  {
-    AddPage(TexturePanel, _("Texture enhancement"));
-    tooltip = _("Filters:\nApply a filter to either smooth or sharpen textures.\nThere are 4 different smoothing filters and 2 different sharpening filters.\nThe higher the number, the stronger the effect,\ni.e. \"Smoothing filter 4\" will have a much more noticeable effect than \"Smoothing filter 1\".\nBe aware that performance may have an impact depending on the game and/or the PC.\n[Recommended: your preference]");
-    lblFilter->SetToolTip(tooltip);
-    cmbEnhFilter->SetToolTip(tooltip);
-    cmbEnhFilter->SetSelection(settings.ghq_fltr);
-    tooltip = _("Texture enhancement:\n7 different filters are selectable here, each one with a distinctive look.\nBe aware of possible performance impacts.\n\nIMPORTANT: 'Store' mode - saves textures in cache 'as is'. It can improve performance in games, which load many textures.\nDisable 'Ignore backgrounds' option for better result.\n\n[Recommended: your preference]");
-    lblEnhancement->SetToolTip(tooltip);
-    cmbEnhEnhancement->SetToolTip(tooltip);
-    cmbEnhEnhancement->SetSelection(settings.ghq_enht);
-    tooltip = _("Texture cache size:\nEnhanced and filtered textures can be cached to aid performance.\nThis setting will adjust how much PC memory will be dedicated for texture cache.\nThis helps boost performance if there are subsequent requests for the same texture (usually the case).\nNormally, 128MB should be more than enough but there is a sweet spot for each game.\nSuper Mario may not need more than 32megs, but Conker streams a lot of textures,\nso setting 256+ megs can boost performance. Adjust accordingly if you are encountering speed issues.\n'0' disables cache.\n[Recommended: PC and game dependant]");
-    lblTexCache->SetToolTip(tooltip);
-    lblTexCacheMB->SetToolTip(tooltip);
-    spinEnhCacheSize->SetToolTip(tooltip);
-    spinEnhCacheSize->SetMinSize(wxSize(55, 21));
-    spinEnhCacheSize->SetValue(settings.ghq_cache_size);
-    cbxEnhIgnoreBG->SetToolTip(_("Ignore Backgrounds:\nIt is used to skip enhancement for long narrow textures, usually used for backgrounds.\nThis may save texture memory greatly and increase performance.\n[Recommended: on (off for 'Store' mode)]"));
-    cbxEnhIgnoreBG->SetValue(settings.ghq_enht_nobg>0);
-    tooltip = _("Texture compression:\nTextures will be compressed using selected texture compression method.\nThe overall compression ratio is about 1/6 for FXT1 and 1/4 for S3TC.\nIn addition to saving space on the texture cache,\nthe space occupied on the GFX hardware's texture RAM,\nby the enhanced textures, will be greatly reduced.\nThis minimizes texture RAM usage,\ndecreasing the number of texture swaps to the GFX hardware leading to performance gains.\nHowever, due to the nature of lossy compression of FXT1 and S3TC, using this option can sometimes lead to quality degradation of small size textures and color banding of gradient colored textures.\n[Recommended: off]");
-    cbxEnhTexCompression->SetToolTip(tooltip);
-    cbxHrsTexCompression->SetToolTip(tooltip);
-    cbxEnhTexCompression->SetValue(settings.ghq_enht_cmpr>0);
-    cbxEnhCompressCache->SetToolTip(_("Compress texture cache:\nMemory will be compressed so that more textures can be held in the texture cache.\nThe compression ratio varies with each texture,\nbut 1/5 of the original size would be a modest approximation.\nThey will be decompressed on-the-fly, before being downloaded to the gfx hardware.\nThis option will still help save memory space even when using texture compression.\n[Recommended: on]"));
-    cbxEnhCompressCache->SetValue(settings.ghq_enht_gz>0);
-    tooltip = _("Hi-res pack format:\nChoose which method is to be used for loading Hi-res texture packs.\nOnly Rice's format is available currently.\nLeave on \"None\" if you will not be needing to load hi-res packs.\n[Recommended: Rice's format. Default: \"None\"]");
-    lblHrsFormat->SetToolTip(tooltip);
-    cmbHrsFormat->SetToolTip(tooltip);
-    cmbHrsFormat->SetSelection(settings.ghq_hirs);
-    cbxHrsTile->SetToolTip(_("Tile textures:\nWhen on, wide texture will be split on several tiles to fit in one 256-width texture.\nThis tiled texture takes much less video memory space and thus overall performance will increase.\nHowever, corresponding polygons must be split too, and this is not polished yet\n- various issues are possible, including black lines and polygons distortions.\n[Recommended: off]"));
-    cbxHrsTile->SetValue(settings.ghq_hirs_tile>0);
-    cbxHrsForce16->SetToolTip(_("Force 16bpp textures:\nThe color of the textures will be reduced to 16bpp.\nThis is another space saver and performance enhancer.\nThis halves the space used on the texture cache and the GFX hardware's texture RAM.\nColor reduction is done so that the original quality is preserved as much as possible.\nDepending on the texture, this usually is hardly noticeable.\nSometimes though, it can be: skies are a good example.\n[Recommended: off]"));
-    cbxHrsForce16->SetValue(settings.ghq_hirs_f16bpp>0);
-    cbxHrsTexEdit->SetToolTip(_("Texture dumping mode:\nIn this mode, you have that ability to dump textures on screen to the appropriate folder.\nYou can also reload textures while the game is running to see how they look instantly - big time saver!\n\nHotkeys: \"R\" reloads hires textures from the texture pack - \"D\" toggles texture dumps on/off."));
-    cbxHrsTexEdit->SetValue(settings.ghq_hirs_dump>0);
-    cbxHrsAltCRC->SetToolTip(_("Alternative CRC calculation:\nThis option enables emulation of a palette CRC calculation bug in RiceVideo.\nIf some textures are not loaded, try to set this option on/off.\n[Recommended: texture pack dependant, mostly on]"));
-    cbxHrsAltCRC->SetValue(settings.ghq_hirs_altcrc>0 && settings.ghq_hirs_dump==0);
-    if (settings.ghq_hirs_dump)
-      cbxHrsAltCRC->Disable();
-    cbxHrsTexCompression->SetValue(settings.ghq_hirs_cmpr>0);
-    cbxHrsCompressCache->SetToolTip(_("Compress texture cache:\nWhen game started, plugin loads all its hi-resolution textures into PC memory.\nSince hi-resolution textures are usually large, the whole pack can take hundreds megabytes of memory.\nCache compression allows save memory space greatly.\nTextures will be decompressed on-the-fly, before being downloaded to the gfx hardware.\nThis option will still help save memory space even when using texture compression.\n[Recommended: on]"));
-    cbxHrsCompressCache->SetValue(settings.ghq_hirs_gz>0);
-    cbxHrsLetFly->SetToolTip(_("Use Alpha channel fully:\nWhen this option is off, 16bit rgba textures will be loaded using RiceVideo style\n- with 1bit for alpha channel.\nWhen it is on, GlideHQ will check, how alpha channel is used by the hires texture,\nand select most appropriate format for it.\nThis gives texture designers freedom to play with alpha, as they need,\nregardless of format of original N64 texture.\nFor older and badly designed texture packs it can cause unwanted black borders.\n[Recommended: texture pack dependant]"));
-    cbxHrsLetFly->SetValue(settings.ghq_hirs_let_texartists_fly>0);
-    cmbTextureCompression->SetSelection(settings.ghq_cmpr);
-    cbxSaveTexCache->SetToolTip(_("Save texture cache to HD:\n\nFor enhanced textures cache:\nThis will save all previously loaded and enhanced textures to HD.\nSo upon next game launch, all the textures will be instantly loaded, resulting in smoother performance.\n\nFor high-resolution textures cache:\nAfter creation, loading hi-res texture will take only a few seconds upon game launch,\nas opposed to the 5 -60 seconds a pack can take to load without this cache file.\nThe only downside here is upon any changes to the pack, the cache file will need to be manually deleted.\n\nSaved cache files go into a folder called \"Cache\" within the Plugins folder.\n\n[Highly Recommended: on]"));
-    cbxSaveTexCache->SetValue(settings.ghq_cache_save>0);
-    TexturePanel->SetMinSize(wxSize(526, 494));
-
-    if (!voodoo.sup_32bit_tex)
-    {
-      settings.ghq_cmpr = 0;
-      settings.ghq_enht_cmpr = settings.ghq_hirs_cmpr = FALSE;
-      settings.ghq_enht_f16bpp = settings.ghq_hirs_f16bpp = TRUE;
-      lblTexCompression->Disable();
-      cmbTextureCompression->SetSelection(0);
-      cmbTextureCompression->Disable();
-      cbxEnhTexCompression->SetValue(false);
-      cbxEnhTexCompression->Disable();
-      cbxHrsTexCompression->SetValue(false);
-      cbxHrsTexCompression->Disable();
-      cbxHrsForce16->SetValue(false);
-      cbxHrsForce16->Disable();
-    }
-  }
-#endif //TEXTURE_FILTER
-
-#ifndef _ENDUSER_RELEASE_
-  AddPage(DebugPanel, _("Debug"));
-  cbxAutoUcode->SetToolTip(_("Autodetect Microcode\nIf this option is checked, the microcode of the game\nwill be detected automatically from the INI, and\ntherefore it will not need to be set in this\nconfiguration dialog.\n[Recommended: on]"));
-  cbxAutoUcode->SetValue(settings.autodetect_ucode>0);
-  tooltip = _("Force Microcode\nThis option ONLY has an effect if Autodetect Microcode\nis unchecked, the crc from the game could not be\nfound in the INI, OR after the game has already started\nrunning. In any of those three cases, this will\nselect the microcode to use\n[Recommended: any, turn on Autodetect Microcode]");
-  lblForceUcode->SetToolTip(tooltip);
-  cmbForceUcode->SetToolTip(tooltip);
-  cmbForceUcode->SetSelection(settings.ucode);
-  cbxWireframe->SetToolTip(_("Wireframe\nThis option, when checked, makes it so that the plugin will draw only the\noutlines of objects.  The colors specified in the combo box to the right\ndetermines the color that the wireframes show up as.\n[Recommended: off]"));
-  cbxWireframe->SetValue(settings.wireframe>0);
-  cmbWireframe->SetToolTip(_("Wireframe Colors\nThis selects the colors to use for the wireframes (if wireframe mode is enabled).\nThere are 3 modes:\n* Original colors - draw exactly as it would normally, textures and all, only in wireframes.\n* Vertex colors - use the colors specified in the vertices to draw the wireframes with.\n* Red only - use a constant red color to draw the wireframes.\n[Recommended: Vertex colors]"));
-  cmbWireframe->SetSelection(settings.wfmode);
-  cbxLog->SetToolTip(_("Log to RDP.txt\nRECOMMENDED FOR DEBUGGING ONLY - this option, when checked, will log EVERY SINGLE\nCOMMAND the plugin processes to a file called RDP.txt in the current directory.\nThis is incredibly slow, so I recommend keeping it disabled.\n[Recommended: off]"));
-  cbxLog->SetValue(settings.logging>0);
-  cbxCombRed->SetToolTip(_("Unknown combiners as red\nObjects that use an unimplemented combine mode will show up as red instead of\nassuming texture with full alpha. Disable this option to remove the red stuff\nand at least have a guess at the correct combine mode.\n[Recommended: off]"));
-  cbxCombRed->SetValue(settings.unk_as_red>0);
-  cbxLogClear->SetToolTip(_("Log clear every frame\nRECOMMENDED FOR DEBUGGING ONLY - this option has no effect unless 'Log to RDP.txt'\nis checked. This will make it so that the log, RDP.txt, will be cleared at the\nbeginning of every frame.\n[Recommended: off]"));
-  cbxLogClear->SetValue(settings.log_clear>0);
-  cbxCmbLog->SetToolTip(_("Log unknown combiners\nRECOMMENDED FOR DEBUGGING ONLY - when checked, this option will cause every\nunimplemented combiner drawn to be logged to a file called Unimp.txt in the\ncurrent directory. This becomes slow when there are unimplemented combiners\non the screen, so I recommend keeping it disabled.\n[Recommended: off]"));
-  cbxCmbLog->SetValue(settings.log_unk>0);
-  cbxWindowLog->SetToolTip(_("Run and log in window\nRECOMMENDED FOR DEBUGGING ONLY - this option will make it so that the plugin will\nstill process dlists in windowed mode. This allows for logging to occur while not\nin fullscreen, possibly allowing you to debug a crash.\n[Recommended: off]"));
-  cbxWindowLog->SetValue(settings.run_in_window>0);
-  cbxCmbLogClear->SetToolTip(_("Clear unknown combiner log every frame\nRECOMMENDED FOR DEBUGGING ONLY - this option works much like 'Log clear every frame'\nexcept it clears the combiner log (Unimp.txt) instead of RDP.txt at the\nbeginning of each frame. Again, this option has no effect if 'combiner logging' is disabled.\n[Recommended: off]"));
-  cbxCmbLogClear->SetValue(settings.unk_clear>0);
-  cbxErrLog->SetValue(settings.elogging>0);
-  cbxBilinearTexCache->SetToolTip(_("Bilinear filter texture cache\nRECOMMENDED FOR DEBUGGING ONLY - when checked, this option will make the graphical\ndebugger texture cache use bilinear filtering as opposed to point-sampled filtering,\nwhich it will use otherwise. See 'Filtering mode' for descriptions of bilinear and\npoint-sampled filtering.\n[Recommended: off]"));
-  cbxBilinearTexCache->SetValue(settings.filter_cache>0);
-#endif //_ENDUSER_RELEASE_
-  // end wxGlade
-}
-
-
-void ConfigNotebook::do_layout()
-{
-  // begin wxGlade: ConfigNotebook::do_layout
-
-  //Basic panel
-    wxBoxSizer* ConfigMainSizer = new wxBoxSizer(wxVERTICAL);
-    wxStaticBoxSizer* OtherSizer = new wxStaticBoxSizer(OtherSizer_staticbox, wxVERTICAL);
-    wxBoxSizer* OtherOtherSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* ScreenShotFormatSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* ShowPanelsSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* ConfigUpperSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxStaticBoxSizer* OnScreenInfoSizer = new wxStaticBoxSizer(OnScreenDisplaySizer_staticbox, wxHORIZONTAL);
-    wxBoxSizer* InfoMainSizer = new wxBoxSizer(wxVERTICAL);
-    wxStaticBoxSizer* TimeSizer = new wxStaticBoxSizer(TimeSizer_staticbox, wxVERTICAL);
-    wxStaticBoxSizer* SpeedSizer = new wxStaticBoxSizer(SpeedSizer_staticbox, wxVERTICAL);
-    wxBoxSizer* BasicLeftSizer = new wxBoxSizer(wxVERTICAL);
-    wxStaticBoxSizer* BasicRenderingSizer = new wxStaticBoxSizer(BasicRenderingSizer_staticbox, wxVERTICAL);
-    wxStaticBoxSizer* WrapperSizer = new wxStaticBoxSizer(WrapperSizer_staticbox, wxVERTICAL);
-    wxStaticBoxSizer* WrapperFBOptionsSizer = new wxStaticBoxSizer(WrapperFBOptionsSizer_staticbox, wxVERTICAL);
-    wxBoxSizer* VRAMSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* FSResolutionSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* ResolutionSizer = new wxBoxSizer(wxHORIZONTAL);
-    ResolutionSizer->Add(lblResolution, 1, wxALIGN_CENTER_VERTICAL, 0);
-    ResolutionSizer->Add(20, 20, 0, 0, 0);
-    ResolutionSizer->Add(cmbResolution, 0, wxALIGN_CENTER_VERTICAL, 0);
-    BasicRenderingSizer->Add(ResolutionSizer, 0, wxTOP|wxBOTTOM, 10);
-    BasicRenderingSizer->Add(cbxVSync, 0, wxBOTTOM, 10);
-    FSResolutionSizer->Add(lblFSResolution, 1, wxALIGN_CENTER_VERTICAL, 0);
-    FSResolutionSizer->Add(20, 20, 0, 0, 0);
-    FSResolutionSizer->Add(cmbFSResolution, 0, 0, 0);
-    WrapperSizer->Add(FSResolutionSizer, 0, wxTOP|wxBOTTOM, 10);
-    WrapperSizer->Add(cbxAnisotropic, 0, wxBOTTOM, 10);
-    VRAMSizer->Add(cbxVRAM, 0, wxALIGN_CENTER_VERTICAL, 0);
-    VRAMSizer->Add(lblVRAM, 0, wxALIGN_CENTER_VERTICAL, 0);
-    VRAMSizer->Add(spinVRAM, 0, wxLEFT, 10);
-    VRAMSizer->Add(lblMb, 0, wxLEFT|wxALIGN_BOTTOM, 3);
-    WrapperSizer->Add(VRAMSizer, 0, wxBOTTOM|wxEXPAND, 10);
-    WrapperFBOptionsSizer->Add(cbxFBO, 0, wxTOP|wxBOTTOM, 10);
-    WrapperSizer->Add(WrapperFBOptionsSizer, 0, wxEXPAND, 0);
-    BasicRenderingSizer->Add(WrapperSizer, 0, wxEXPAND, 0);
-    BasicLeftSizer->Add(BasicRenderingSizer, 1, wxEXPAND, 0);
-    ConfigUpperSizer->Add(BasicLeftSizer, 1, wxLEFT|wxRIGHT|wxEXPAND, 10);
-    SpeedSizer->Add(cbxFPS, 0, wxTOP|wxBOTTOM, 10);
-    SpeedSizer->Add(cbxVIS, 0, wxBOTTOM, 10);
-    SpeedSizer->Add(cbxPercent, 0, wxBOTTOM, 10);
-    InfoMainSizer->Add(SpeedSizer, 0, wxALL|wxEXPAND, 10);
-    TimeSizer->Add(cbxClockEnabled, 0, wxTOP|wxBOTTOM, 10);
-    TimeSizer->Add(cbxClock24, 0, wxBOTTOM, 10);
-    InfoMainSizer->Add(TimeSizer, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 10);
-    InfoMainSizer->Add(cbxTextTransparent, 0, wxLEFT|wxTOP, 15);
-    OnScreenInfoSizer->Add(InfoMainSizer, 1, wxEXPAND, 0);
-    ConfigUpperSizer->Add(OnScreenInfoSizer, 1, wxLEFT|wxRIGHT|wxEXPAND, 10);
-    ConfigMainSizer->Add(ConfigUpperSizer, 1, wxEXPAND, 0);
-    ShowPanelsSizer->Add(cbxAdvancedSettings, 1, 0, 10);
-    ShowPanelsSizer->Add(cbxTextureSettings, 1, wxLEFT, 10);
-    OtherSizer->Add(ShowPanelsSizer, 0, wxTOP|wxBOTTOM|wxEXPAND, 10);
-    ScreenShotFormatSizer->Add(lblScreenShotFormat, 0, 0, 0);
-    ScreenShotFormatSizer->Add(20, 20, 0, 0, 0);
-    ScreenShotFormatSizer->Add(cmbScreenShotFormat, 0, 0, 0);
-    OtherOtherSizer->Add(ScreenShotFormatSizer, 1, wxALIGN_CENTER_VERTICAL, 0);
-    OtherOtherSizer->Add(btnLanguage, 1, wxLEFT, 10);
-    OtherSizer->Add(OtherOtherSizer, 0, wxEXPAND, 0);
-    ConfigMainSizer->Add(OtherSizer, 0, wxALL|wxEXPAND, 10);
-    BasicSettingsPanel->SetSizer(ConfigMainSizer);
-
-  //emulation settings panel
-  if (settings.advanced_options)
-  {
-    wxStaticBoxSizer* EmuSettingsBoxSizer = new wxStaticBoxSizer(EmuSettingsBoxSizer_staticbox, wxHORIZONTAL);
-    wxBoxSizer* EmuSettingsMainSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* EmuSettingsRightSizer = new wxBoxSizer(wxVERTICAL);
-    wxStaticBoxSizer* DepthBufferSizer = new wxStaticBoxSizer(DepthBufferSizer_staticbox, wxHORIZONTAL);
-    wxStaticBoxSizer* FrameBufferSizer = new wxStaticBoxSizer(FrameBufferSizer_staticbox, wxVERTICAL);
-    wxBoxSizer* HWFBESizer = new wxBoxSizer(wxHORIZONTAL);
-    wxStaticBoxSizer* EmuSettingsLeftSizer = new wxStaticBoxSizer(EmuSettingsLeftSizer_staticbox, wxVERTICAL);
-    wxBoxSizer* AspectSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* LODSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* SwappingSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* FilteringSizer = new wxBoxSizer(wxHORIZONTAL);
-    FilteringSizer->Add(lbFiltering, 0, 0, 0);
-    FilteringSizer->Add(20, 20, 0, 0, 0);
-    FilteringSizer->Add(cmbFiltering, 0, 0, 0);
-    EmuSettingsLeftSizer->Add(FilteringSizer, 1, wxTOP, 10);
-    SwappingSizer->Add(lbBufferSwap, 0, 0, 0);
-    SwappingSizer->Add(20, 20, 0, 0, 0);
-    SwappingSizer->Add(cmbBufferSwap, 0, 0, 0);
-    EmuSettingsLeftSizer->Add(SwappingSizer, 1, 0, 0);
-    LODSizer->Add(lblLOD, 0, 0, 0);
-    LODSizer->Add(20, 20, 0, 0, 0);
-    LODSizer->Add(cmbLOD, 0, 0, 0);
-    EmuSettingsLeftSizer->Add(LODSizer, 1, 0, 0);
-    AspectSizer->Add(lblAspect, 0, 0, 0);
-    AspectSizer->Add(20, 20, 0, 0, 0);
-    AspectSizer->Add(cmbAspect, 0, 0, 0);
-    EmuSettingsLeftSizer->Add(AspectSizer, 1, 0, 0);
-    EmuSettingsLeftSizer->Add(cbxFog, 1, 0, 0);
-    EmuSettingsLeftSizer->Add(cbxBuffer, 1, 0, 0);
-    EmuSettingsMainSizer->Add(EmuSettingsLeftSizer, 1, wxLEFT|wxRIGHT|wxEXPAND, 10);
-    FrameBufferSizer->Add(cbxFBEnable, 1, wxTOP|wxBOTTOM, 10);
-    HWFBESizer->Add(30, 20, 0, 0, 0);
-    HWFBESizer->Add(cbxFBHWFBE, 0, 0, 0);
-    FrameBufferSizer->Add(HWFBESizer, 0, wxBOTTOM, 10);
-    FrameBufferSizer->Add(cbxFBGetFBI, 1, wxBOTTOM, 10);
-    FrameBufferSizer->Add(cbxFBReadEveryFrame, 1, wxBOTTOM, 10);
-    FrameBufferSizer->Add(cbxFBasTex, 1, wxBOTTOM, 10);
-    FrameBufferSizer->Add(cbxDetect, 1, wxBOTTOM, 10);
-    EmuSettingsRightSizer->Add(FrameBufferSizer, 1, wxEXPAND, 0);
-    DepthBufferSizer->Add(cbxFBDepthBuffer, 0, wxTOP|wxBOTTOM, 10);
-    EmuSettingsRightSizer->Add(DepthBufferSizer, 0, wxTOP|wxEXPAND, 10);
-    EmuSettingsMainSizer->Add(EmuSettingsRightSizer, 1, wxLEFT|wxRIGHT|wxEXPAND, 10);
-    EmuSettingsBoxSizer->Add(EmuSettingsMainSizer, 1, wxTOP|wxBOTTOM|wxEXPAND, 10);
-    EmuSettingsPanel->SetSizer(EmuSettingsBoxSizer);
-  }
-
-#ifdef TEXTURE_FILTER
-  if (settings.texenh_options)
-  {
-    wxBoxSizer* TextureMainSizer = new wxBoxSizer(wxVERTICAL);
-    wxStaticBoxSizer* PresetsSizer = new wxStaticBoxSizer(PresetsSizer_staticbox, wxHORIZONTAL);
-    wxStaticBoxSizer* CommonSizer = new wxStaticBoxSizer(CommonSizer_staticbox, wxHORIZONTAL);
-    wxBoxSizer* TexCompressionSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* TexLeftSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxStaticBoxSizer* TextureRightSizer = new wxStaticBoxSizer(TextureRightSizer_staticbox, wxVERTICAL);
-    wxStaticBoxSizer* HRTexPerfTweaksSizer = new wxStaticBoxSizer(HRTexPerfTweaksSizer_staticbox, wxVERTICAL);
-    wxBoxSizer* FormatSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxStaticBoxSizer* EnhTexSizer = new wxStaticBoxSizer(EnhTexSizer_staticbox, wxVERTICAL);
-    wxStaticBoxSizer* EnhTexPerfTweaksSizer = new wxStaticBoxSizer(EnhTexPerfTweaksSizer_staticbox, wxVERTICAL);
-    wxBoxSizer* TexCacheSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* EnhSizer = new wxBoxSizer(wxHORIZONTAL);
-    wxBoxSizer* FilterSizer = new wxBoxSizer(wxHORIZONTAL);
-    FilterSizer->Add(lblFilter, 0, 0, 0);
-    FilterSizer->Add(20, 20, 0, 0, 0);
-    FilterSizer->Add(cmbEnhFilter, 0, 0, 0);
-    EnhTexSizer->Add(FilterSizer, 0, wxTOP|wxBOTTOM|wxEXPAND, 10);
-    EnhSizer->Add(lblEnhancement, 0, 0, 0);
-    EnhSizer->Add(20, 20, 0, 0, 0);
-    EnhSizer->Add(cmbEnhEnhancement, 0, 0, 0);
-    EnhTexSizer->Add(EnhSizer, 0, wxBOTTOM|wxEXPAND, 10);
-    TexCacheSizer->Add(lblTexCache, 0, 0, 0);
-    TexCacheSizer->Add(20, 20, 0, 0, 0);
-    TexCacheSizer->Add(spinEnhCacheSize, 0, 0, 0);
-    TexCacheSizer->Add(lblTexCacheMB, 0, wxLEFT|wxALIGN_BOTTOM, 4);
-    EnhTexSizer->Add(TexCacheSizer, 0, wxBOTTOM|wxEXPAND, 10);
-    EnhTexSizer->Add(cbxEnhCompressCache, 0, wxBOTTOM, 10);
-    EnhTexPerfTweaksSizer->Add(cbxEnhTexCompression, 0, wxTOP|wxBOTTOM, 10);
-    EnhTexPerfTweaksSizer->Add(cbxEnhIgnoreBG, 0, wxBOTTOM, 10);
-    EnhTexSizer->Add(EnhTexPerfTweaksSizer, 1, wxEXPAND, 0);
-    TexLeftSizer->Add(EnhTexSizer, 1, wxALL|wxEXPAND, 10);
-    FormatSizer->Add(lblHrsFormat, 0, 0, 0);
-    FormatSizer->Add(20, 20, 0, 0, 0);
-    FormatSizer->Add(cmbHrsFormat, 0, 0, 0);
-    TextureRightSizer->Add(FormatSizer, 0, wxTOP|wxBOTTOM|wxEXPAND, 10);
-    TextureRightSizer->Add(cbxHrsAltCRC, 0, wxBOTTOM, 10);
-    TextureRightSizer->Add(cbxHrsTexEdit, 0, wxBOTTOM, 10);
-    TextureRightSizer->Add(cbxHrsLetFly, 0, wxBOTTOM, 10);
-    TextureRightSizer->Add(cbxHrsCompressCache, 0, wxBOTTOM, 10);
-    HRTexPerfTweaksSizer->Add(cbxHrsTexCompression, 0, wxTOP|wxBOTTOM, 10);
-    HRTexPerfTweaksSizer->Add(cbxHrsForce16, 0, wxBOTTOM, 10);
-    HRTexPerfTweaksSizer->Add(cbxHrsTile, 0, wxBOTTOM, 10);
-    TextureRightSizer->Add(HRTexPerfTweaksSizer, 1, wxEXPAND, 0);
-    TexLeftSizer->Add(TextureRightSizer, 1, wxALL|wxEXPAND, 10);
-    TextureMainSizer->Add(TexLeftSizer, 1, wxEXPAND, 0);
-    TexCompressionSizer->Add(lblTexCompression, 0, wxALIGN_CENTER_VERTICAL, 0);
-    TexCompressionSizer->Add(20, 20, 0, 0, 0);
-    TexCompressionSizer->Add(cmbTextureCompression, 0, 0, 0);
-    CommonSizer->Add(TexCompressionSizer, 1, wxBOTTOM|wxEXPAND, 10);
-    CommonSizer->Add(cbxSaveTexCache, 1, wxLEFT|wxEXPAND, 15);
-    TextureMainSizer->Add(CommonSizer, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 10);
-    PresetsSizer->Add(btnPerformance, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0);
-    PresetsSizer->Add(60, 20, 0, 0, 0);
-    PresetsSizer->Add(btnQuality, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0);
-    TextureMainSizer->Add(PresetsSizer, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 10);
-    TexturePanel->SetSizer(TextureMainSizer);
-  }
-#endif //TEXTURE_FILTER
-
-#ifndef _ENDUSER_RELEASE_
-  wxBoxSizer* DebugMainSizer = new wxBoxSizer(wxVERTICAL);
-  wxStaticBoxSizer* DebugSizer = new wxStaticBoxSizer(DebugSizer_staticbox, wxVERTICAL);
-  wxGridSizer* DebugOptionsSizer = new wxGridSizer(4, 2, 0, 0);
-  wxStaticBoxSizer* DevSettingsSizer = new wxStaticBoxSizer(DevSettingsSizer_staticbox, wxVERTICAL);
-  wxBoxSizer* WireframeSizer = new wxBoxSizer(wxHORIZONTAL);
-  wxBoxSizer* ForceUcodeSizer = new wxBoxSizer(wxHORIZONTAL);
-  DevSettingsSizer->Add(cbxAutoUcode, 1, 0, 0);
-  ForceUcodeSizer->Add(lblForceUcode, 0, 0, 0);
-  ForceUcodeSizer->Add(20, 20, 0, 0, 0);
-  ForceUcodeSizer->Add(cmbForceUcode, 0, 0, 0);
-  DevSettingsSizer->Add(ForceUcodeSizer, 1, wxEXPAND, 0);
-  WireframeSizer->Add(cbxWireframe, 0, 0, 0);
-  WireframeSizer->Add(20, 20, 0, 0, 0);
-  WireframeSizer->Add(cmbWireframe, 0, 0, 0);
-  DevSettingsSizer->Add(WireframeSizer, 1, wxEXPAND, 0);
-  DebugMainSizer->Add(DevSettingsSizer, 1, wxALL|wxEXPAND, 10);
-  DebugOptionsSizer->Add(cbxLog, 0, wxTOP, 5);
-  DebugOptionsSizer->Add(cbxCombRed, 0, wxTOP, 5);
-  DebugOptionsSizer->Add(cbxLogClear, 0, 0, 10);
-  DebugOptionsSizer->Add(cbxCmbLog, 0, 0, 10);
-  DebugOptionsSizer->Add(cbxWindowLog, 0, 0, 10);
-  DebugOptionsSizer->Add(cbxCmbLogClear, 0, 0, 10);
-  DebugOptionsSizer->Add(cbxErrLog, 0, 0, 0);
-  DebugOptionsSizer->Add(cbxBilinearTexCache, 0, 0, 0);
-  DebugSizer->Add(DebugOptionsSizer, 1, wxEXPAND, 0);
-  DebugMainSizer->Add(DebugSizer, 1, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 10);
-  DebugPanel->SetSizer(DebugMainSizer);
-#endif //_ENDUSER_RELEASE_
-  // end wxGlade
-}
-
-void ConfigNotebook::SaveSettings()
-{
-  SETTINGS oldsettings = settings;
-  int is_advanced_changed = 0;
-  if (settings.advanced_options)
-  {
-    settings.filtering = cmbFiltering->GetSelection();
-    settings.aspectmode = cmbAspect->GetSelection();
-    settings.swapmode = cmbBufferSwap->GetSelection();
-    settings.fog = (int)cbxFog->GetValue();
-    settings.buff_clear = cbxBuffer->GetValue();
-    settings.lodmode = cmbLOD->GetSelection();
-
-    if (cbxFBEnable->GetValue()) settings.frame_buffer |= fb_emulation;
-    else settings.frame_buffer &= ~fb_emulation;
-    if (cbxFBHWFBE->GetValue()) settings.frame_buffer |= fb_hwfbe;
-    else settings.frame_buffer &= ~fb_hwfbe;
-    if (cbxFBReadEveryFrame->GetValue()) settings.frame_buffer |= fb_ref;
-    else settings.frame_buffer &= ~fb_ref;
-    if (cbxFBasTex->GetValue()) settings.frame_buffer |= fb_read_back_to_screen;
-    else settings.frame_buffer &= ~fb_read_back_to_screen;
-    if (cbxDetect->GetValue()) settings.frame_buffer |= fb_cpu_write_hack;
-    else settings.frame_buffer &= ~fb_cpu_write_hack;
-    if (cbxFBGetFBI->GetValue()) settings.frame_buffer |= fb_get_info;
-    else settings.frame_buffer &= ~fb_get_info;
-    if (cbxFBDepthBuffer->GetValue()) settings.frame_buffer |= fb_depth_render;
-    else settings.frame_buffer &= ~fb_depth_render;
-    is_advanced_changed = memcmp(&oldsettings, &settings, sizeof(SETTINGS));
-  }
-
-  settings.lang_id = lang_id;
-  settings.res_data = cmbResolution->GetSelection();
-  settings.scr_res_x = settings.res_x = resolutions[settings.res_data][0];
-  settings.scr_res_y = settings.res_y = resolutions[settings.res_data][1];
-  settings.vsync = (int)cbxVSync->GetValue();
-  settings.ssformat = cmbScreenShotFormat->GetSelection();
-  settings.show_fps =
-    (cbxFPS->GetValue()?1:0) |
-    (cbxVIS->GetValue()?2:0) |
-    (cbxPercent->GetValue()?4:0) |
-    (cbxTextTransparent->GetValue()?8:0);
-  settings.clock = (int)cbxClockEnabled->GetValue();
-  settings.clock_24_hr = (int)cbxClock24->GetValue();
-
-  settings.wrpResolution = cmbFSResolution->GetSelection();
-  settings.wrpVRAM = cbxVRAM->GetValue()? 0 : spinVRAM->GetValue();
-  settings.wrpFBO = cbxFBO->GetValue();
-  settings.wrpAnisotropic = cbxAnisotropic->GetValue();
-
-#ifdef TEXTURE_FILTER
-  if (settings.texenh_options)
-  {
-    settings.ghq_fltr = cmbEnhFilter->GetSelection();
-    settings.ghq_enht = cmbEnhEnhancement->GetSelection();
-    settings.ghq_cache_size = spinEnhCacheSize->GetValue();
-    settings.ghq_enht_nobg = (int)cbxEnhIgnoreBG->GetValue();
-    settings.ghq_enht_cmpr = (int)cbxEnhTexCompression->GetValue();
-    settings.ghq_enht_gz = (int)cbxEnhCompressCache->GetValue();
-    settings.ghq_hirs = cmbHrsFormat->GetSelection();
-    settings.ghq_hirs_tile = (int)cbxHrsTile->GetValue();
-    settings.ghq_hirs_f16bpp = (int)cbxHrsForce16->GetValue();
-    settings.ghq_hirs_dump = (int)cbxHrsTexEdit->GetValue();
-    settings.ghq_hirs_altcrc = (int)cbxHrsAltCRC->GetValue();
-    settings.ghq_hirs_cmpr = (int)cbxHrsTexCompression->GetValue();
-    settings.ghq_hirs_gz = (int)cbxHrsCompressCache->GetValue();
-    settings.ghq_hirs_let_texartists_fly = (int)cbxHrsLetFly->GetValue();
-    settings.ghq_cmpr = (int)cmbTextureCompression->GetSelection();
-    settings.ghq_cache_save = (int)cbxSaveTexCache->GetValue();
-  }
-#endif //TEXTURE_FILTER
-
-  settings.advanced_options = (int)cbxAdvancedSettings->GetValue();
-  settings.texenh_options = (int)cbxTextureSettings->GetValue();
-
-#ifndef _ENDUSER_RELEASE_
-  settings.autodetect_ucode = (int)cbxAutoUcode->GetValue();
-  settings.ucode = cmbForceUcode->GetSelection();
-  settings.wireframe = (int)cbxWireframe->GetValue();
-  settings.wfmode = cmbWireframe->GetSelection();
-  settings.logging = (int)cbxLog->GetValue();
-  settings.unk_as_red = (int)cbxCombRed->GetValue();
-  settings.log_clear = (int)cbxLogClear->GetValue();
-  settings.log_unk = (int)cbxCmbLog->GetValue();
-  settings.run_in_window = (int)cbxWindowLog->GetValue();
-  settings.unk_clear = (int)cbxCmbLogClear->GetValue();
-  settings.elogging = (int)cbxErrLog->GetValue();
-  settings.filter_cache = (int)cbxBilinearTexCache->GetValue();
-#endif //_ENDUSER_RELEASE_
-
-  if (memcmp(&oldsettings, &settings, sizeof(SETTINGS))) //check that settings were changed
-  {
-    if (romopen)
-    {
-      if (is_advanced_changed)
-      {
-        wxMessageDialog dialog( this, _T("Current game emulation settings changed. Save the settings permanently?\nSelect 'No' to use the settings without save."),
-          _T("Save settings"), wxNO_DEFAULT|wxYES_NO|wxICON_QUESTION);
-        WriteSettings (dialog.ShowModal() == wxID_YES);
-      }
-      else
-        WriteSettings (false);
-    }
-    else
-      WriteSettings (is_advanced_changed != 0);
-  }
-}
-
-Glide64ConfigDialog::Glide64ConfigDialog(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
-wxDialog(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE)
-{
-  // begin wxGlade: Glide64ConfigDialog::Glide64ConfigDialog
-  Config = new ConfigNotebook(this, wxID_ANY);
-  btnOK = new wxButton(this, wxID_OK, wxEmptyString);
-  btnCancel = new wxButton(this, wxID_CANCEL, wxEmptyString);
-
-  set_properties();
-  do_layout();
-  // end wxGlade
-}
-