ecsv avatar ecsv committed 25f4611

Compile with TEXTURE_FILTER support
The support for TEXTURE_FILTER is the start to get GlideHQ working. Remaining
work items are:
* Setting the correct path for HighRes textures
* Config support for ghq_fltr
* Config support for ghq_cmpr
* Config support for ghq_enht
* Config support for ghq_hirs
* Fixing random crashes

Comments (0)

Files changed (4)

src/Glide64/Main.cpp

 static void (*l_DebugCallback)(void *, int, const char *) = NULL;
 static void *l_DebugCallContext = NULL;
 
-#ifdef TEXTURE_FILTER
-
-#ifdef _WIN32
-#define PATH_MAX _MAX_PATH
-#endif
-
-#ifdef __APPLE__
-#include <mach-o/dyld.h>
-#endif
-
-char pluginPath[PATH_MAX];
-
-static void PluginPath()
-{
-  unsigned int size = sizeof(pluginPath);
-  
-  #ifdef __APPLE__
-  if(_NSGetExecutablePath(pluginPath, &size) != 0) return;
-  #else
-    #ifdef _WIN32
-    GetModuleFileName (NULL, pluginPath, PATH_MAX);
-    #else
-      #ifdef __FreeBSD__
-      int n = readlink("/proc/curproc/files", pluginPath, PATH_MAX);
-      #else
-      int n = readlink("/proc/self/exe", pluginPath, PATH_MAX);
-      #endif
-      if (n == -1) strcpy(pluginPath, "./");
-      else
-      {
-        char pluginPath2[PATH_MAX];
-        int i;
-
-        pluginPath[n] = '\0';
-        strcpy(pluginPath2, pluginPath);
-        for (i=strlen(pluginPath2)-1; i>0; i--)
-        {
-          if(pluginPath2[i] == '/') break;
-        }
-        if(i == 0) strcpy(pluginPath, "./");
-        else
-        {
-          DIR *dir;
-          struct dirent *entry;
-          int gooddir = 0;
-
-          pluginPath2[i+1] = '\0';
-          dir = opendir(pluginPath2);
-          while((entry = readdir(dir)) != NULL)
-          {
-            if(!strcmp(entry->d_name, "plugins"))
-              gooddir = 1;
-          }
-          closedir(dir);
-          if(!gooddir) strcpy(pluginPath, "./");
-        }
-      }      
-    #endif
-  #endif
-
-    // Find the previous backslash
-  int i;
-  for (i=strlen(pluginPath)-1; i>0; i--)
-  {
-#ifdef _WIN32
-    if (pluginPath[i] == '\\')
-#else // _WIN32
-      if (pluginPath[i] == '/')
-#endif // _WIN32
-        break;
-  }
-  if (pluginPath == 0) return;
-  pluginPath[i+1] = 0;
-
-}
-#endif
 void _ChangeSize ()
 {
   rdp.scale_1024 = settings.scr_res_x / 1024.0f;
 
 int InitGfx ()
 {
+  wchar_t romname[256];
   if (fullscreen)
     ReleaseGfx ();
 
 
       ghq_dmptex_toggle_key = 0;
 
+      swprintf(romname, 256, L"%hs", rdp.RomName);
+      romname[256] = '\0';
       settings.ghq_use = (int)ext_ghq_init(voodoo.max_tex_size, // max texture width supported by hardware
         voodoo.max_tex_size, // max texture height supported by hardware
         voodoo.sup_32bit_tex?32:16, // max texture bpp supported by hardware
         options,
         settings.ghq_cache_size * 1024*1024, // cache texture to system memory
-        pluginPath.wchar_str(), // plugin path
-        rdp.RomName.wchar_str(), // name of ROM. must be no longer than 256 characters
-        #warning pluginpath needed for GlideHQ support
+#warning TODO actual user HQ directory needs to be specified
+        L".",
+        romname, // name of ROM. must be no longer than 256 characters
         DisplayLoadProgress);
     }
   }
     mutexProcessDList = new wxMutex(wxMUTEX_DEFAULT);
   wxImage::AddHandler(new wxPNGHandler);
   wxImage::AddHandler(new wxJPEGHandler);
-  PluginPath();
   return true;
 }
 

src/Glide64/TexCache.cpp

   cache->f_mirror_t = FALSE;
   cache->f_wrap_s = FALSE;
   cache->f_wrap_t = FALSE;
-  //TODO-port: uncommment next line
-//  cache->is_hires_tex = FALSE;
+  cache->is_hires_tex = FALSE;
 #ifdef TEXTURE_FILTER
   cache->ricecrc    = texinfo[id].ricecrc;
 #endif

src/Glide64/rdp.h

 extern wxUint32 frame_count; // frame counter
 
 //GlideHQ support
-#warning GlideHQ Disabled!
-// #define TEXTURE_FILTER
+#define TEXTURE_FILTER
 #ifdef TEXTURE_FILTER
-#include "Ext_TxFilter.h"
+#include "../GlideHQ/Ext_TxFilter.h"
 #endif
 
 #define MAX_CACHE   1024*4

src/GlideHQ/Ext_TxFilter.cpp

 #include <stdlib.h>
 #include "Ext_TxFilter.h"
 
-typedef boolean (*txfilter_init)(int maxwidth, int maxheight, int maxbpp,
-                                 int options, int cachesize,
-                                 wchar_t *path, wchar_t *ident,
-                                 dispInfoFuncExt callback);
+extern "C"{
 
-typedef void (*txfilter_shutdown)(void);
+boolean txfilter_init(int maxwidth, int maxheight, int maxbpp,
+                      int options, int cachesize,
+                      wchar_t *path, wchar_t *ident,
+                      dispInfoFuncExt callback);
 
-typedef boolean (*txfilter_filter)(unsigned char *src, int srcwidth, int srcheight, unsigned short srcformat,
-                                   uint64 g64crc, GHQTexInfo *info);
+void txfilter_shutdown(void);
 
-typedef boolean (*txfilter_hirestex)(uint64 g64crc, uint64 r_crc64, unsigned short *palette, GHQTexInfo *info);
+boolean txfilter(unsigned char *src, int srcwidth, int srcheight, unsigned short srcformat,
+                 uint64 g64crc, GHQTexInfo *info);
 
-typedef uint64 (*txfilter_checksum)(unsigned char *src, int width, int height, int size, int rowStride, unsigned char *palette);
+boolean txfilter_hirestex(uint64 g64crc, uint64 r_crc64, unsigned short *palette, GHQTexInfo *info);
 
-typedef boolean (*txfilter_dmptx)(unsigned char *src, int width, int height, int rowStridePixel, unsigned short gfmt, unsigned short n64fmt, uint64 r_crc64);
+uint64 txfilter_checksum(unsigned char *src, int width, int height, int size, int rowStride, unsigned char *palette);
 
-typedef boolean (*txfilter_reloadhirestex)();
+boolean txfilter_dmptx(unsigned char *src, int width, int height, int rowStridePixel, unsigned short gfmt, unsigned short n64fmt, uint64 r_crc64);
 
-static struct {
-  TXHMODULE lib;
-  txfilter_init init;
-  txfilter_shutdown shutdown;
-  txfilter_filter filter;
-  txfilter_hirestex hirestex;
-  txfilter_checksum checksum;
-  txfilter_dmptx dmptx;
-  txfilter_reloadhirestex reloadhirestex;
-} txfilter;
+boolean txfilter_reloadhirestex();
+
+}
 
 void ext_ghq_shutdown(void)
 {
-  if (txfilter.shutdown)
-    (*txfilter.shutdown)();
-
-  if (txfilter.lib) {
-    DLCLOSE(txfilter.lib);
-    memset(&txfilter, 0, sizeof(txfilter));
-  }
+  txfilter_shutdown();
 }
 
 boolean ext_ghq_init(int maxwidth, int maxheight, int maxbpp, int options, int cachesize,
 {
   boolean bRet = 0;
 
-  if (!txfilter.lib) {
-    wchar_t curpath[MAX_PATH];
-    wcscpy(curpath, path);
-#ifdef WIN32
-#ifdef GHQCHK
-    wcscat(curpath, L"\\ghqchk.dll");
-#else
-    wcscat(curpath, L"\\GlideHQ.dll");
-#endif
-    txfilter.lib = DLOPEN(curpath);
-#else
-    char cbuf[MAX_PATH];
-#ifdef GHQCHK
-    wcscat(curpath, L"/ghqchk.so");
-#else
-    wcscat(curpath, L"/GlideHQ.so");
-#endif
-    wcstombs(cbuf, curpath, MAX_PATH);
-    txfilter.lib = DLOPEN(cbuf);
-#endif
-  }
-
-  if (txfilter.lib) {
-    if (!txfilter.init)
-      txfilter.init = (txfilter_init)DLSYM(txfilter.lib, "txfilter_init");
-    if (!txfilter.shutdown)
-      txfilter.shutdown = (txfilter_shutdown)DLSYM(txfilter.lib, "txfilter_shutdown");
-    if (!txfilter.filter)
-      txfilter.filter = (txfilter_filter)DLSYM(txfilter.lib, "txfilter");
-    if (!txfilter.hirestex)
-      txfilter.hirestex = (txfilter_hirestex)DLSYM(txfilter.lib, "txfilter_hirestex");
-    if (!txfilter.checksum)
-      txfilter.checksum = (txfilter_checksum)DLSYM(txfilter.lib, "txfilter_checksum");
-    if (!txfilter.dmptx)
-      txfilter.dmptx = (txfilter_dmptx)DLSYM(txfilter.lib, "txfilter_dmptx");
-    if (!txfilter.reloadhirestex)
-      txfilter.reloadhirestex = (txfilter_reloadhirestex)DLSYM(txfilter.lib, "txfilter_reloadhirestex");
-  }
-
-  if (txfilter.init && txfilter.shutdown && txfilter.filter &&
-      txfilter.hirestex && txfilter.checksum /*&& txfilter.dmptx && txfilter.reloadhirestex */)
-    bRet = (*txfilter.init)(maxwidth, maxheight, maxbpp, options, cachesize, path, ident, callback);
-  else
-    ext_ghq_shutdown();
+  bRet = txfilter_init(maxwidth, maxheight, maxbpp, options, cachesize, path, ident, callback);
 
   return bRet;
 }
 {
   boolean ret = 0;
 
-  if (txfilter.filter)
-    ret = (*txfilter.filter)(src, srcwidth, srcheight, srcformat,
-                             g64crc, info);
+  ret = txfilter(src, srcwidth, srcheight, srcformat,
+                 g64crc, info);
 
   return ret;
 }
 {
   boolean ret = 0;
 
-  if (txfilter.hirestex)
-    ret = (*txfilter.hirestex)(g64crc, r_crc64, palette, info);
+  ret = txfilter_hirestex(g64crc, r_crc64, palette, info);
 
   return ret;
 }
 {
   uint64 ret = 0;
 
-  if (txfilter.checksum)
-    ret = (*txfilter.checksum)(src, width, height, size, rowStride, palette);
+  ret = txfilter_checksum(src, width, height, size, rowStride, palette);
 
   return ret;
 }
 {
   boolean ret = 0;
 
-  if (txfilter.dmptx)
-    ret = (*txfilter.dmptx)(src, width, height, rowStridePixel, gfmt, n64fmt, r_crc64);
+  ret = txfilter_dmptx(src, width, height, rowStridePixel, gfmt, n64fmt, r_crc64);
 
   return ret;
 }
 {
   boolean ret = 0;
 
-  if (txfilter.reloadhirestex)
-    ret = (*txfilter.reloadhirestex)();
+  ret = txfilter_reloadhirestex();
 
   return ret;
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.