Commits

Anonymous committed 9c0fd34

added GlideHQ

  • Participants
  • Parent commits ed6af97

Comments (0)

Files changed (69)

File GlideHQ/CB/BuildNo.cbp

+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+	<FileVersion major="1" minor="6" />
+	<Project>
+		<Option title="BuildNo" />
+		<Option pch_mode="2" />
+		<Option compiler="gcc" />
+		<Build>
+			<Target title="Debug">
+				<Option output="bin\BuildNo" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj\Debug\" />
+				<Option type="1" />
+				<Option compiler="gcc" />
+				<Compiler>
+					<Add option="-g" />
+				</Compiler>
+			</Target>
+			<Target title="Release">
+				<Option output="bin\BuildNo" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj\Release\" />
+				<Option type="1" />
+				<Option compiler="gcc" />
+				<Compiler>
+					<Add option="-O2" />
+				</Compiler>
+				<Linker>
+					<Add option="-s" />
+				</Linker>
+			</Target>
+		</Build>
+		<Compiler>
+			<Add option="-Wall" />
+			<Add option="-fexceptions" />
+		</Compiler>
+		<Unit filename="..\bldno.cpp" />
+		<Extensions>
+			<code_completion />
+			<envvars />
+			<debugger />
+			<lib_finder disable_auto="1" />
+		</Extensions>
+	</Project>
+</CodeBlocks_project_file>

File GlideHQ/CB/GlideHQ.cbp

+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+	<FileVersion major="1" minor="6" />
+	<Project>
+		<Option title="GlideHQ" />
+		<Option pch_mode="2" />
+		<Option compiler="gcc" />
+		<Build>
+			<Target title="Debug">
+				<Option output="bin\GlideHQ" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj\Debug\" />
+				<Option type="3" />
+				<Option compiler="gcc" />
+				<Option createDefFile="1" />
+				<Option createStaticLib="1" />
+				<Compiler>
+					<Add option="-Wall" />
+					<Add option="-g" />
+					<Add option="-DBUILD_DLL" />
+					<Add directory="..\inc" />
+				</Compiler>
+				<Linker>
+					<Add library="user32" />
+					<Add directory="..\lib" />
+				</Linker>
+			</Target>
+			<Target title="Release">
+				<Option output="bin\GlideHQ" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj\Release\" />
+				<Option type="3" />
+				<Option compiler="gcc" />
+				<Option createDefFile="1" />
+				<Option createStaticLib="1" />
+				<Compiler>
+					<Add option="-Wall" />
+					<Add option="-DBUILD_DLL" />
+					<Add option="-O2" />
+				</Compiler>
+				<Linker>
+					<Add option="-s" />
+					<Add library="user32" />
+				</Linker>
+			</Target>
+		</Build>
+		<Unit filename="..\Ext_TxFilter.cpp" />
+		<Unit filename="..\Ext_TxFilter.h" />
+		<Unit filename="main.cpp" />
+		<Unit filename="main.h" />
+		<Unit filename="..\TextureFilters.cpp" />
+		<Unit filename="..\TextureFilters.h" />
+		<Unit filename="..\TextureFilters_2xsai.cpp" />
+		<Unit filename="..\TextureFilters_2xsai.h" />
+		<Unit filename="..\TextureFilters_hq2x.cpp" />
+		<Unit filename="..\TextureFilters_hq2x.h" />
+		<Unit filename="..\TextureFilters_hq4x.cpp" />
+		<Unit filename="..\TextureFilters_hq4x.h" />
+		<Unit filename="..\TextureFilters_lq2x.h" />
+		<Unit filename="..\TxCache.cpp" />
+		<Unit filename="..\TxCache.h" />
+		<Unit filename="..\TxDbg.cpp" />
+		<Unit filename="..\TxDbg.h" />
+		<Unit filename="..\TxFilter.cpp" />
+		<Unit filename="..\TxFilter.h" />
+		<Unit filename="..\TxFilterExport.cpp" />
+		<Unit filename="..\TxHiResCache.cpp" />
+		<Unit filename="..\TxHiResCache.h" />
+		<Unit filename="..\TxImage.cpp" />
+		<Unit filename="..\TxImage.h" />
+		<Unit filename="..\TxInternal.h" />
+		<Unit filename="..\TxQuantize.cpp" />
+		<Unit filename="..\TxQuantize.h" />
+		<Unit filename="..\TxReSample.cpp" />
+		<Unit filename="..\TxReSample.h" />
+		<Unit filename="..\TxTexCache.cpp" />
+		<Unit filename="..\TxTexCache.h" />
+		<Unit filename="..\TxUtil.cpp" />
+		<Unit filename="..\TxUtil.h" />
+		<Extensions>
+			<code_completion />
+			<envvars />
+			<debugger />
+			<lib_finder disable_auto="1" />
+		</Extensions>
+	</Project>
+</CodeBlocks_project_file>

File GlideHQ/Ext_TxFilter.cpp

+/*
+ * Texture Filtering
+ * Version:  1.0
+ *
+ * Copyright (C) 2007  Hiroshi Morii   All Rights Reserved.
+ * Email koolsmoky(at)users.sourceforge.net
+ * Web   http://www.3dfxzone.it/koolsmoky
+ *
+ * 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.
+ */
+
+#include <memory.h>
+#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);
+
+typedef void (*txfilter_shutdown)(void);
+
+typedef boolean (*txfilter_filter)(unsigned char *src, int srcwidth, int srcheight, unsigned short srcformat,
+                                   uint64 g64crc, GHQTexInfo *info);
+
+typedef boolean (*txfilter_hirestex)(uint64 g64crc, uint64 r_crc64, unsigned short *palette, GHQTexInfo *info);
+
+typedef uint64 (*txfilter_checksum)(unsigned char *src, int width, int height, int size, int rowStride, unsigned char *palette);
+
+typedef boolean (*txfilter_dmptx)(unsigned char *src, int width, int height, int rowStridePixel, unsigned short gfmt, unsigned short n64fmt, uint64 r_crc64);
+
+typedef boolean (*txfilter_reloadhirestex)();
+
+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;
+
+void ext_ghq_shutdown(void)
+{
+  if (txfilter.shutdown)
+    (*txfilter.shutdown)();
+
+  if (txfilter.lib) {
+    DLCLOSE(txfilter.lib);
+    memset(&txfilter, 0, sizeof(txfilter));
+  }
+}
+
+boolean ext_ghq_init(int maxwidth, int maxheight, int maxbpp, int options, int cachesize,
+                     wchar_t *path, wchar_t *ident,
+                     dispInfoFuncExt callback)
+{
+  boolean bRet = 0;
+  printf(L"Ident is %ls\n", ident);
+  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();
+
+  return bRet;
+}
+
+boolean ext_ghq_txfilter(unsigned char *src, int srcwidth, int srcheight, unsigned short srcformat,
+                                uint64 g64crc, GHQTexInfo *info)
+{
+  boolean ret = 0;
+
+  if (txfilter.filter)
+    ret = (*txfilter.filter)(src, srcwidth, srcheight, srcformat,
+                             g64crc, info);
+
+  return ret;
+}
+
+boolean ext_ghq_hirestex(uint64 g64crc, uint64 r_crc64, unsigned short *palette, GHQTexInfo *info)
+{
+  boolean ret = 0;
+
+  if (txfilter.hirestex)
+    ret = (*txfilter.hirestex)(g64crc, r_crc64, palette, info);
+
+  return ret;
+}
+
+uint64 ext_ghq_checksum(unsigned char *src, int width, int height, int size, int rowStride, unsigned char *palette)
+{
+  uint64 ret = 0;
+
+  if (txfilter.checksum)
+    ret = (*txfilter.checksum)(src, width, height, size, rowStride, palette);
+
+  return ret;
+}
+
+boolean ext_ghq_dmptx(unsigned char *src, int width, int height, int rowStridePixel, unsigned short gfmt, unsigned short n64fmt, uint64 r_crc64)
+{
+  boolean ret = 0;
+
+  if (txfilter.dmptx)
+    ret = (*txfilter.dmptx)(src, width, height, rowStridePixel, gfmt, n64fmt, r_crc64);
+
+  return ret;
+}
+
+boolean ext_ghq_reloadhirestex()
+{
+  boolean ret = 0;
+
+  if (txfilter.reloadhirestex)
+    ret = (*txfilter.reloadhirestex)();
+
+  return ret;
+}

File GlideHQ/Ext_TxFilter.h

+/*
+ * Texture Filtering
+ * Version:  1.0
+ *
+ * Copyright (C) 2007  Hiroshi Morii   All Rights Reserved.
+ * Email koolsmoky(at)users.sourceforge.net
+ * Web   http://www.3dfxzone.it/koolsmoky
+ *
+ * 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.
+ */
+
+#ifndef __EXT_TXFILTER_H__
+#define __EXT_TXFILTER_H__
+
+#ifdef WIN32
+#include <windows.h>
+#define TXHMODULE HMODULE
+#define DLOPEN(a) LoadLibraryW(a)
+#define DLCLOSE(a) FreeLibrary(a)
+#define DLSYM(a, b) GetProcAddress(a, b)
+#define GETCWD(a, b) GetCurrentDirectoryW(a, b)
+#define CHDIR(a) SetCurrentDirectoryW(a)
+#else
+#include <iostream>
+#include <dlfcn.h> 
+#define MAX_PATH 4095
+#define TXHMODULE void*
+#define DLOPEN(a) dlopen(a, RTLD_LAZY|RTLD_GLOBAL)
+#define DLCLOSE(a) dlclose(a)
+#define DLSYM(a, b) dlsym(a, b)
+#define GETCWD(a, b) getcwd(b, a)
+#define CHDIR(a) chdir(a)
+#endif
+
+#ifdef __MSC__
+typedef __int64 int64;
+typedef unsigned __int64 uint64;
+#else
+typedef long long int64;
+typedef unsigned long long uint64;
+typedef unsigned char boolean;
+#endif
+
+#define NO_OPTIONS          0x00000000
+
+#define FILTER_MASK         0x000000ff
+#define NO_FILTER           0x00000000
+#define SMOOTH_FILTER_MASK  0x0000000f
+#define NO_SMOOTH_FILTER    0x00000000
+#define SMOOTH_FILTER_1     0x00000001
+#define SMOOTH_FILTER_2     0x00000002
+#define SMOOTH_FILTER_3     0x00000003
+#define SMOOTH_FILTER_4     0x00000004
+#define SHARP_FILTER_MASK   0x000000f0
+#define NO_SHARP_FILTER     0x00000000
+#define SHARP_FILTER_1      0x00000010
+#define SHARP_FILTER_2      0x00000020
+
+#define ENHANCEMENT_MASK    0x00000f00
+#define NO_ENHANCEMENT      0x00000000
+#define X2_ENHANCEMENT      0x00000100
+#define X2SAI_ENHANCEMENT   0x00000200
+#define HQ2X_ENHANCEMENT    0x00000300
+#define LQ2X_ENHANCEMENT    0x00000400
+#define HQ4X_ENHANCEMENT    0x00000500
+#define HQ2XS_ENHANCEMENT   0x00000600
+#define LQ2XS_ENHANCEMENT   0x00000700
+
+#define COMPRESSION_MASK    0x0000f000
+#define NO_COMPRESSION      0x00000000
+#define FXT1_COMPRESSION    0x00001000
+#define NCC_COMPRESSION     0x00002000
+#define S3TC_COMPRESSION    0x00003000
+
+#define HIRESTEXTURES_MASK  0x000f0000
+#define NO_HIRESTEXTURES    0x00000000
+#define GHQ_HIRESTEXTURES   0x00010000
+#define RICE_HIRESTEXTURES  0x00020000
+#define JABO_HIRESTEXTURES  0x00030000
+
+#define COMPRESS_TEX        0x00100000
+#define COMPRESS_HIRESTEX   0x00200000
+#define GZ_TEXCACHE         0x00400000
+#define GZ_HIRESTEXCACHE    0x00800000
+#define DUMP_TEXCACHE       0x01000000
+#define DUMP_HIRESTEXCACHE  0x02000000
+#define TILE_HIRESTEX       0x04000000
+#define UNDEFINED_0         0x08000000
+#define FORCE16BPP_HIRESTEX 0x10000000
+#define FORCE16BPP_TEX      0x20000000
+#define LET_TEXARTISTS_FLY  0x40000000 /* a little freedom for texture artists */
+#define DUMP_TEX            0x80000000
+
+#ifndef __GLIDE_H__ /* GLIDE3 */
+/* from 3Dfx Interactive Inc. glide.h */
+#define GR_TEXFMT_ALPHA_8           0x2
+#define GR_TEXFMT_INTENSITY_8       0x3
+
+#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
+#define GR_TEXFMT_P_8                0x5
+
+#define GR_TEXFMT_RGB_565            0xa
+#define GR_TEXFMT_ARGB_1555          0xb
+#define GR_TEXFMT_ARGB_4444          0xc
+#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
+
+/* from 3Dfx Interactive Inc. g3ext.h */
+#define GR_TEXFMT_ARGB_CMP_FXT1      0x11
+
+#define GR_TEXFMT_ARGB_8888          0x12
+
+#define GR_TEXFMT_ARGB_CMP_DXT1      0x16
+#define GR_TEXFMT_ARGB_CMP_DXT3      0x18
+#define GR_TEXFMT_ARGB_CMP_DXT5      0x1A
+#endif /* GLIDE3 */
+
+struct GHQTexInfo {
+  unsigned char *data;
+  int width;
+  int height;
+  unsigned short format;
+
+  int smallLodLog2;
+  int largeLodLog2;
+  int aspectRatioLog2;
+
+  int tiles;
+  int untiled_width;
+  int untiled_height;
+
+  unsigned char is_hires_tex;
+};
+
+/* Callback to display hires texture info.
+ * Gonetz <gonetz(at)ngs.ru>
+ *
+ * void DispInfo(const char *format, ...)
+ * {
+ *   va_list args;
+ *   char buf[INFO_BUF];
+ *
+ *   va_start(args, format);
+ *   vsprintf(buf, format, args);
+ *   va_end(args);
+ *
+ *   printf(buf);
+ * }
+ */
+#define INFO_BUF 4095
+typedef void (*dispInfoFuncExt)(const wchar_t *format, ...);
+
+#ifndef TXFILTER_DLL
+boolean ext_ghq_init(int maxwidth, /* maximum texture width supported by hardware */
+                     int maxheight,/* maximum texture height supported by hardware */
+                     int maxbpp,   /* maximum texture bpp supported by hardware */
+                     int options,  /* options */
+                     int cachesize,/* cache textures to system memory */
+                     wchar_t *path,   /* plugin directory. must be smaller than MAX_PATH */
+                     wchar_t *ident,  /* name of ROM. must be no longer than 64 in character. */
+                     dispInfoFuncExt callback /* callback function to display info */
+                     );
+
+void ext_ghq_shutdown(void);
+
+boolean ext_ghq_txfilter(unsigned char *src,        /* input texture */
+                         int srcwidth,              /* width of input texture */
+                         int srcheight,             /* height of input texture */
+                         unsigned short srcformat,  /* format of input texture */
+                         uint64 g64crc,             /* glide64 crc */
+                         GHQTexInfo *info           /* output */
+                         );
+
+boolean ext_ghq_hirestex(uint64 g64crc,             /* glide64 crc */
+                         uint64 r_crc64,            /* checksum hi:palette low:texture */
+                         unsigned short *palette,   /* palette for CI textures */
+                         GHQTexInfo *info           /* output */
+                         );
+
+uint64 ext_ghq_checksum(unsigned char *src, /* input texture */
+                        int width,          /* width of texture */
+                        int height,         /* height of texture */
+                        int size,           /* type of texture pixel */
+                        int rowStride,      /* row stride in bytes */
+                        unsigned char *palette /* palette */
+                        );
+
+boolean ext_ghq_dmptx(unsigned char *src,   /* input texture (must be in 3Dfx Glide format) */
+                      int width,            /* width of texture */
+                      int height,           /* height of texture */
+                      int rowStridePixel,   /* row stride of input texture in pixels */
+                      unsigned short gfmt,  /* glide format of input texture */
+                      unsigned short n64fmt,/* N64 format hi:format low:size */
+                      uint64 r_crc64        /* checksum hi:palette low:texture */
+                      );
+
+boolean ext_ghq_reloadhirestex();
+#endif /* TXFILTER_DLL */
+
+#endif /* __EXT_TXFILTER_H__ */

File GlideHQ/GlideHQ.rc

+/*
+ * Texture Filtering
+ * Version:  1.0
+ *
+ * Copyright (C) 2007  Hiroshi Morii   All Rights Reserved.
+ * Email koolsmoky(at)users.sourceforge.net
+ * Web   http://www.3dfxzone.it/koolsmoky
+ *
+ * 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.
+ */
+
+#include "bldno.h"
+
+#define ID(id)     id
+
+#define VS_FILE_INFO		ID(16)		/* Version stamp res type */
+#define VS_VERSION_INFO		ID(1)  		/* Version stamp res ID */
+#define VS_USER_DEFINED		ID(100)		/* User-defined res IDs */
+
+#define VOS_DOS_WINDOWS32       0x00010004L
+#define VFT_DLL                 0x00000002L
+#define VER_PRERELEASE              0
+#define VER_PRIVATEBUILD            0
+#define VER_DEBUG                   0
+
+#define VERSIONNAME             "GlideHQ.dll\0"
+#define PRODNAME                "GlideHQ\0"
+#define DESCRIPT                "Texture filtering DLL\0"
+#define COPYRIGHTSTR            "Copyright (C) 2007 Hiroshi Morii\0"
+#define CONTACTSTR              "Hiroshi Morii <koolsmoky@users.sourceforge.net> http://www.3dfxzone.it/koolsmoky\0"
+
+#define MANVERSION              1
+#define MANREVISION             02
+#define MINVERSION              00
+
+#define VERSIONSTR "1.02.00." BUILD_NUMBER_STR
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION MANVERSION, MANREVISION, 0, BUILD_NUMBER
+ PRODUCTVERSION MANVERSION, MANREVISION, 0, BUILD_NUMBER
+ FILEFLAGSMASK 0x0030003FL
+ FILEFLAGS (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
+
+ FILEOS VOS_DOS_WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904E4"
+        BEGIN
+            VALUE "FileDescription", DESCRIPT
+            VALUE "FileVersion", VERSIONSTR
+            VALUE "InternalName", VERSIONNAME
+            VALUE "LegalCopyright", COPYRIGHTSTR
+            VALUE "OriginalFilename", VERSIONNAME
+            VALUE "ProductName", PRODNAME
+            VALUE "ProductVersion", VERSIONSTR
+            VALUE "Contact", CONTACTSTR
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        /* the following line should be extended for localized versions */
+        VALUE "Translation", 0x409, 1252
+    END
+END

File GlideHQ/MSVS/BuildNo.vcproj

+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="BuildNo"
+	ProjectGUID="{4F7108EF-68E7-4BD3-9680-3957B9D2410F}"
+	RootNamespace="BuildNo"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+				CommandLine=""
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="$(OutDir)\$(ProjectName).exe &gt; ../bldno.h"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+				CommandLine=""
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="$(OutDir)\$(ProjectName).exe &gt; ../bldno.h"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\bldno.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

File GlideHQ/MSVS/GlideHQ.vcproj

+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="GlideHQ"
+	ProjectGUID="{2DADDAA5-0F57-46ED-A974-747908DDC7F3}"
+	RootNamespace="GlideHQ"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				UseUnicodeResponseFiles="true"
+				Optimization="0"
+				AdditionalIncludeDirectories="../../boost_1_34_1;../inc"
+				PreprocessorDefinitions="_WINDOWS,DEBUG,__MSC__,WIN32,_CRT_SECURE_NO_DEPRECATE,TXFILTER_DLL"
+				MinimalRebuild="true"
+				ExceptionHandling="2"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				FloatingPointModel="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkLibraryDependencies="false"
+				AdditionalDependencies="kernel32.lib user32.lib LIBCMTD.LIB LIBCPMTD.LIB libboost_filesystem-vc80-mt-sgd.lib dxtnd.lib libpngd.lib zlibd.lib"
+				OutputFile="D:\Games\N64\plugin\GlideHQ.dll "
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="../lib"
+				IgnoreAllDefaultLibraries="true"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeForWindows98="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="../../boost_1_34_1;../inc"
+				PreprocessorDefinitions="_WINDOWS,__MSC__,WIN32,_CRT_SECURE_NO_DEPRECATE,TXFILTER_DLL"
+				ExceptionHandling="2"
+				RuntimeLibrary="0"
+				FloatingPointModel="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkLibraryDependencies="false"
+				AdditionalDependencies="kernel32.lib user32.lib LIBCMT.LIB LIBCPMT.LIB libboost_filesystem-vc80-mt-s.lib dxtn.lib libpng.lib zlib.lib"
+				OutputFile="D:\Games\N64\plugin\GlideHQ.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="../lib"
+				IgnoreAllDefaultLibraries="true"
+				GenerateDebugInformation="false"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\Ext_TxFilter.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters_2xsai.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters_hq2x.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters_hq4x.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxCache.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxDbg.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxFilter.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxFilterExport.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxHiResCache.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxImage.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxQuantize.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxReSample.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxTexCache.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\TxUtil.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\Ext_TxFilter.h"
+				>
+			</File>
+			<File
+				RelativePath="..\Internal.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters_2xsai.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters_hq2x.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters_hq4x.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TextureFilters_lq2x.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TxCache.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TxDbg.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TxFilter.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TxHiResCache.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TxImage.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TxQuantize.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TxTexCache.h"
+				>
+			</File>
+			<File
+				RelativePath="..\TxUtil.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+			<File
+				RelativePath="..\GlideHQ.rc"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

File GlideHQ/Makefile.clang

+# This MUST be processed by GNU make
+#
+# Texture Filtering Linux Makefile
+# Version:  1.0
+#
+# Copyright (C) 2007  Hiroshi Morii   All Rights Reserved.
+# Email koolsmoky(at)users.sourceforge.net
+# Web   http://www.3dfxzone.it/koolsmoky
+#
+# 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:
+#       boost  1.41.0   (http://www.boost.org)  bjam --toolset=gcc link=static runtime-link=static variant=release,debug stage
+#       libpng 1.4.1    (http://www.libpng.org) static library
+#       zlib   1.2.3    (http://www.zlib.org)   static library
+#       tc     1.1+                             patched for ARGB input and ATI Radeon workaround
+# 
+
+#
+# GCC does not have SEH (structured exception handling)
+#
+
+.PHONY: all clean realclean
+
+DLLNAME = GlideHQ.so
+
+# libpng and zlib headers & libraries
+EXT_INC = ./inc
+EXT_LIB = ./lib
+
+# boost library & headers
+BOOST_INC = ## = ../boost_1_41_0
+BOOST_LIB = # = ../boost_1_41_0/stage/lib
+
+CC = /usr/local/bin/clang++ #g++
+CFLAGS += -Wall -W -pedantic -ansi -Wno-long-long
+CFLAGS += -O3 -ffast-math -funroll-loops
+#CFLAGS += -fexpensive-optimizations -march=k6
+CFLAGS += -I. -I$(EXT_INC) -I$(BOOST_INC)
+CFLAGS += -fPIC -DPIC
+#CFLAGS += -DTXFILTER_DLL
+
+ifdef DEBUG
+CFLAGS += -DDEBUG
+endif
+
+LD = g++
+LDFLAGS += -shared -lstdc++ -lpthread
+#LDLIBS = $(EXT_LIB)/libdxtn.a $(EXT_LIB)/libpng.a $(EXT_LIB)/libz.a $(BOOST_LIB)/libboost_filesystem-gcc42-mt-s.a $(BOOST_LIB)/libboost_system-gcc42-mt-s.a $(BOOST_LIB)/libboost_thread-gcc42-mt-s.a
+
+LDLIBS = $(EXT_LIB)/libdxtn.a -lpng -lboost_filesystem-mt -lboost_thread-mt -lboost_system-mt -lz
+
+RM = rm
+
+SOURCES = \
+	TxFilterExport.cpp \
+	TxFilter.cpp \
+	TxCache.cpp \
+	TxTexCache.cpp \
+	TxHiResCache.cpp \
+	TxQuantize.cpp \
+	TxUtil.cpp \
+	TextureFilters.cpp \
+	TextureFilters_2xsai.cpp \
+	TextureFilters_hq2x.cpp \
+	TextureFilters_hq4x.cpp \
+	TxImage.cpp \
+	TxReSample.cpp \
+	TxDbg.cpp
+
+OBJECTS = $(SOURCES:.cpp=.o)
+
+.cpp.o:
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+all: $(DLLNAME)
+
+$(DLLNAME): $(OBJECTS)
+	$(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS)
+
+$(OBJECTS): $(SOURCES) bldno.h
+
+bldno.h: bldno.exe
+	./$< > $@
+
+bldno.exe: bldno.cpp
+	$(CC) -o $@ $(CFLAGS) $<
+
+clean:
+	-$(RM) *.o
+
+realclean: clean
+	-$(RM) $(DLLNAME) bldno.exe bldno.h
+
+-include depend

File GlideHQ/Makefile.gcc

+# This MUST be processed by GNU make
+#
+# Texture Filtering Linux Makefile
+# Version:  1.0
+#
+# Copyright (C) 2007  Hiroshi Morii   All Rights Reserved.
+# Email koolsmoky(at)users.sourceforge.net
+# Web   http://www.3dfxzone.it/koolsmoky
+#
+# 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:
+#       boost  1.41.0   (http://www.boost.org)  bjam --toolset=gcc link=static runtime-link=static variant=release,debug stage
+#       libpng 1.4.1    (http://www.libpng.org) static library
+#       zlib   1.2.3    (http://www.zlib.org)   static library
+#       tc     1.1+                             patched for ARGB input and ATI Radeon workaround
+# 
+
+#
+# GCC does not have SEH (structured exception handling)
+#
+
+.PHONY: all clean realclean
+
+DLLNAME = GlideHQ.so
+
+# libpng and zlib headers & libraries
+EXT_INC = ./inc
+EXT_LIB = ./lib
+
+# boost library & headers
+BOOST_INC = ## = ../boost_1_41_0
+BOOST_LIB = # = ../boost_1_41_0/stage/lib
+
+CC = g++
+CFLAGS += -Wall -W -pedantic -ansi -Wno-long-long
+CFLAGS += -O3 -ffast-math -funroll-loops
+#CFLAGS += -fexpensive-optimizations -march=k6
+CFLAGS += -I. -I$(EXT_INC) -I$(BOOST_INC)
+CFLAGS += -fPIC -DPIC
+#CFLAGS += -DTXFILTER_DLL
+
+ifdef DEBUG
+CFLAGS += -DDEBUG
+endif
+
+LD = g++
+LDFLAGS += -shared -lstdc++ -lpthread
+#LDLIBS = $(EXT_LIB)/libdxtn.a $(EXT_LIB)/libpng.a $(EXT_LIB)/libz.a $(BOOST_LIB)/libboost_filesystem-gcc42-mt-s.a $(BOOST_LIB)/libboost_system-gcc42-mt-s.a $(BOOST_LIB)/libboost_thread-gcc42-mt-s.a
+
+LDLIBS = $(EXT_LIB)/libdxtn.a -lpng -lboost_filesystem-mt -lboost_thread-mt -lboost_system-mt -lz
+
+RM = rm
+
+SOURCES = \
+	TxFilterExport.cpp \
+	TxFilter.cpp \
+	TxCache.cpp \
+	TxTexCache.cpp \
+	TxHiResCache.cpp \
+	TxQuantize.cpp \
+	TxUtil.cpp \
+	TextureFilters.cpp \
+	TextureFilters_2xsai.cpp \
+	TextureFilters_hq2x.cpp \
+	TextureFilters_hq4x.cpp \
+	TxImage.cpp \
+	TxReSample.cpp \
+	TxDbg.cpp
+
+OBJECTS = $(SOURCES:.cpp=.o)
+
+.cpp.o:
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+all: $(DLLNAME)
+
+$(DLLNAME): $(OBJECTS)
+	$(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS)
+
+$(OBJECTS): $(SOURCES) bldno.h
+
+bldno.h: bldno.exe
+	./$< > $@
+
+bldno.exe: bldno.cpp
+	$(CC) -o $@ $(CFLAGS) $<
+
+clean:
+	-$(RM) *.o
+
+realclean: clean
+	-$(RM) $(DLLNAME) bldno.exe bldno.h
+
+-include depend

File GlideHQ/Makefile.vc8

+# This MUST be processed by GNU make
+#
+# Texture Filtering MSVC Makefile
+# Version:  1.0
+#
+# Copyright (C) 2007  Hiroshi Morii   All Rights Reserved.
+# Email koolsmoky(at)users.sourceforge.net
+# Web   http://www.3dfxzone.it/koolsmoky
+#
+# 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
+#
+#    Targets:
+#	all:		build everything
+#	clean:		remove object files
+#	realclean:	remove all generated files
+#
+#
+#  Requirements:
+#
+#    Compiler:
+#       Microsoft VisualC++ 8.0 (VS2005)
+#
+#    Libraries:
+#       boost  1.41.0   (http://www.boost.org)  bjam --toolset=msvc-8.0 link=static runtime-link=static variant=release,debug stage
+#       libpng 1.4.1    (http://www.libpng.org) built with /MT or /MTd switch
+#       zlib   1.2.3    (http://www.zlib.org)   built with /MT or /MTd switch
+#       tc     1.1+                             patched for ARGB input and ATI Radeon workaround
+#
+#       All libraries must be built with /MT or /MTd switch and statically linked.
+#       If you need any help feel free to drop me a line.
+#
+
+.PHONY: all clean realclean
+.SUFFIXES: .cpp .obj .rc .res
+
+# RESNAME = txfilter.res
+# DLLNAME = txfilter.dll
+# LIBNAME = txfilter.lib
+# EXPNAME = txfilter.exp
+RESNAME = GlideHQ.res
+DLLNAME = GlideHQ.dll
+LIBNAME = GlideHQ.lib
+EXPNAME = GlideHQ.exp
+
+# libpng and zlib headers & libraries
+EXT_INC = ./inc
+EXT_LIB = ./lib
+
+# boost library & headers
+BOOST_INC = ../boost_1_41_0
+BOOST_LIB = ../boost_1_41_0/stage/lib
+
+CC = cl
+AS = nasm
+LD = _link # change this to suite your build environment
+RC = rc
+
+UNLINK = $(RM) $(1)
+
+LDFLAGS = -nologo -dll -opt:WIN98 -machine:X86 -nodefaultlib
+
+ASFLAGS = -O6 -fwin32 -D__WIN32__ --prefix _
+ASFLAGS += $(CDEFS)
+
+CFLAGS  = -nologo -W3 -WX -D__MSC__ -DWIN32 -D_WINDOWS -D_WINDLL -EHa -D_CRT_SECURE_NO_DEPRECATE -DTXFILTER_DLL
+
+LDLIBS = user32.lib kernel32.lib
+ifdef DEBUG
+CFLAGS += -Zi -DDEBUG -MTd
+LDLIBS += $(EXT_LIB)/dxtnd.lib $(EXT_LIB)/libpngd.lib $(EXT_LIB)/zlibd.lib LIBCMTD.LIB LIBCPMTD.LIB $(BOOST_LIB)/libboost_filesystem-vc80-mt-sgd.lib $(BOOST_LIB)/libboost_system-vc80-mt-sgd.lib $(BOOST_LIB)/libboost_thread-vc80-mt-sgd.lib
+OPTFLAGS ?= -Od
+else
+CFLAGS += -DNDEBUG -GL -MT
+LDFLAGS += -ltcg:STATUS
+LDLIBS += $(EXT_LIB)/dxtn.lib $(EXT_LIB)/libpng.lib $(EXT_LIB)/zlib.lib LIBCMT.LIB LIBCPMT.LIB $(BOOST_LIB)/libboost_filesystem-vc80-mt-s.lib $(BOOST_LIB)/libboost_system-vc80-mt-s.lib $(BOOST_LIB)/libboost_thread-vc80-mt-s.lib
+OPTFLAGS ?= -O2
+endif
+
+CFLAGS += -I. -I$(EXT_INC) -I$(BOOST_INC)
+CFLAGS += $(CDEFS) $(OPTFLAGS)
+
+SOURCES = \
+	TxFilterExport.cpp \
+	TxFilter.cpp \
+	TxCache.cpp \
+	TxTexCache.cpp \
+	TxHiResCache.cpp \
+	TxQuantize.cpp \
+	TxUtil.cpp \
+	TextureFilters.cpp \
+	TextureFilters_2xsai.cpp \
+	TextureFilters_hq2x.cpp \
+	TextureFilters_hq4x.cpp \
+	TxImage.cpp \
+	TxReSample.cpp \
+	TxDbg.cpp
+
+
+OBJECTS = $(SOURCES:.cpp=.obj)
+
+.cpp.obj:
+	$(CC) -Fo$@ $(CFLAGS) -c $<
+
+.rc.res:
+	$(RC) -Fo$@ $(CDEFS) $<
+
+all: $(DLLNAME)
+
+$(DLLNAME): $(OBJECTS) $(RESNAME)
+	$(LD) -out:$@ $(LDFLAGS) $(OBJECTS) $(LDLIBS) $(RESNAME)
+
+$(OBJECTS): $(SOURCES) bldno.h
+
+bldno.h: bldno.exe
+	./$< > $@
+
+bldno.exe: bldno.cpp
+	$(CC) -o $@ $(CFLAGS) $<
+
+clean:
+	-$(RM) *.obj *.pdb $(RESNAME) bldno.h *.ilk
+
+realclean: clean
+	-$(RM) $(DLLNAME) $(LIBNAME) $(EXPNAME) bldno.exe

File GlideHQ/README.txt

+/*
+ * GlideHQ (Texture enhancer library for Glide64)
+ * Version:  1.5
+ *
+ * Copyright (C) 2007  Hiroshi Morii aka KoolSmoky   All Rights Reserved.
+ * Email koolsmoky(at)users.sourceforge.net
+ * Web   http://www.3dfxzone.it/koolsmoky
+ *
+ * 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.
+ */
+
+About:
+This is a realtime texture enhancer library with hi-resolution texture
+pack support for Glide64 (http://glide64.emuxhaven.net). Traditional and
+non-traditional techniques have been used to achieve speed and high image
+quality even on a 9 year old 3Dfx Voodoo2.
+
+Although the 3Dfx Glide3x texture format naming conventions are used, the
+library can be expanded for generic use.
+
+Supported:
+OS: 32bit Linux and MS Windows
+Enhancers: Hq4x, Hq2x, Hq2xS, Lq2x, Lq2xS, Super2xSai, x2
+Filters: Smooth (1,2,3,4), Sharp (1,2)
+Compressors: FXT1, S3TC
+Input formats:  GR_TEXFMT_ALPHA_8,
+                GR_TEXFMT_RGB_565,
+                GR_TEXFMT_ARGB_1555,
+                GR_TEXFMT_ARGB_4444,
+                GR_TEXFMT_ARGB_8888,
+                GR_TEXFMT_ALPHA_INTENSITY_44,
+                GR_TEXFMT_ALPHA_INTENSITY_88
+Output formats: Same as input unless compression or hires packs are used.
+Hires texture packs: Rice format (Jabo and GlideHQ format coming later)
+
+Acknowledgments:
+I hope you enjoy GlideHQ (texture enhancer library for Glide64). Greatest
+thanks to Gonetz for making this happen in his busy time. We've rushed
+everything to share the eye-candy with all of you N64 emulation fans. I
+would also like to thank a great friend of mine, Daniel Borca for providing
+the texture compression code, Maxim Stepin (hq2x 4x), and Derek Liauw Kie Fa
+(2xSaI) for the filtering engines, Rice for his N64 graphics plugin source
+code, and Mudlord for the hq2xS lq2xS code. GlideHQ also uses the boost C++
+libraries, zlib general purpose compression library, and the Portable Network
+Graphics library. Thanks to all the developers for making them available. And
+special thanks to the Glide64 beta testing crew. Without their feedbacks
+this library would not have seen daylight. Thank you all.
+
+The source code for GlideHQ is released in hopes that it will be improved.
+I know the coding is not on par after so much late night caffeine boosts.
+If you have suggestions or modifications, please feel free to post them on
+the Glide64 forum at emuxhaven.
+
+Porting the library to other platforms should not be so hard. The coding is
+done with cross platform compatibility in mind and will build with GCC and
+GNU make. Currently supported are 32bit Linux and MS Windows.
+
+If you are looking for driver updates for your 3Dfx Interactive Inc. gfx 
+card, grab them from the forums at http://www.3dfxzone.it/enboard/
+Unbelievable as it seems, drivers are still being updated after 6 years
+from 3Dfx's demise.
+
+I know N64 rules, anyone up for PSX? :))
+
+-KoolSmoky
+
+References:
+[1] R.W. Floyd & L. Steinberg, An adaptive algorithm for spatial grey scale,
+    Proceedings of the Society of Information Display 17, pp75-77, 1976
+[2] Ken Turkowski, Filters for Common Resampling Tasks, Apple Computer 1990
+    http://www.worldserver.com/turk/computergraphics/ResamplingFilters.pdf
+[3] Don P. Mitchell and Arun N. Netravali, Reconstruction Filters in Computer
+    Graphics, SIGGRAPH '88, Proceedings of the 15th annual conference on
+    Computer graphics and interactive techniques, pp221-228, 1988
+[4] J. F. Kaiser and W. A. Reed, Data smoothing using low-pass digital
+    filters, Rev. Sci. instrum. 48 (11), pp1447-1457, 1977
+[5] Maxim Stepin, hq4x Magnification Filter, http://www.hiend3d.com/hq4x.html
+[6] Derek Liauw Kie Fa, 2xSaI, http://elektron.its.tudelft.nl/~dalikifa
+[7] Dirk Stevens, Eagle engine http://www.retrofx.com/rfxtech.html
+[8] 3DFX_texture_compression_FXT1 and EXT_texture_compression_s3tc extension
+    specs from the OpenGL Extension Registry. http://oss.sgi.com/projects/
+    ogl-sample/registry/

File GlideHQ/TextureFilters.cpp

+/*
+Copyright (C) 2003 Rice1964
+
+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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+/* Copyright (C) 2007 Hiroshi Morii <koolsmoky(at)users.sourceforge.net>
+ * Modified for the Texture Filtering library
+ */
+
+#include <string.h>
+#include "TextureFilters.h"
+
+/************************************************************************/
+/* 2X filters                                                           */
+/************************************************************************/
+
+#define DWORD_MAKE(r, g, b, a)   ((uint32) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
+#define WORD_MAKE(r, g, b, a)   ((uint16) (((a) << 12) | ((r) << 8) | ((g) << 4) | (b)))
+
+// Basic 2x R8G8B8A8 filter with interpolation
+
+void Texture2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height)
+{
+  uint32 *pDst1, *pDst2;
+  uint32 *pSrc, *pSrc2;
+  uint32 nWidth = width;
+  uint32 nHeight = height;
+
+  uint32 b1;
+  uint32 g1;
+  uint32 r1;
+  uint32 a1;
+  uint32 b2;
+  uint32 g2;
+  uint32 r2;
+  uint32 a2;
+  uint32 b3;
+  uint32 g3;
+  uint32 r3;
+  uint32 a3;
+  uint32 b4;
+  uint32 g4;
+  uint32 r4;
+  uint32 a4;
+
+  uint32 xSrc;
+  uint32 ySrc;
+
+  for (ySrc = 0; ySrc < nHeight; ySrc++)
+  {
+    pSrc = (uint32*)(((uint8*)srcPtr)+ySrc*srcPitch);
+    pSrc2 = (uint32*)(((uint8*)srcPtr)+(ySrc+1)*srcPitch);
+    pDst1 = (uint32*)(((uint8*)dstPtr)+(ySrc*2)*dstPitch);
+    pDst2 = (uint32*)(((uint8*)dstPtr)+(ySrc*2+1)*dstPitch);
+
+    for (xSrc = 0; xSrc < nWidth; xSrc++)
+    {
+      b1 = (pSrc[xSrc]>>0)&0xFF;
+      g1 = (pSrc[xSrc]>>8)&0xFF;
+      r1 = (pSrc[xSrc]>>16)&0xFF;
+      a1 = (pSrc[xSrc]>>24)&0xFF;
+
+      if( xSrc<nWidth-1 )
+      {
+        b2 = (pSrc[xSrc+1]>>0)&0xFF;
+        g2 = (pSrc[xSrc+1]>>8)&0xFF;
+        r2 = (pSrc[xSrc+1]>>16)&0xFF;
+        a2 = (pSrc[xSrc+1]>>24)&0xFF;
+      }
+
+      if( ySrc<nHeight-1 )
+      {
+        b3 = (pSrc2[xSrc]>>0)&0xFF;
+        g3 = (pSrc2[xSrc]>>8)&0xFF;
+        r3 = (pSrc2[xSrc]>>16)&0xFF;
+        a3 = (pSrc2[xSrc]>>24)&0xFF;
+        if( xSrc<nWidth-1 )
+        {
+          b4 = (pSrc2[xSrc+1]>>0)&0xFF;
+          g4 = (pSrc2[xSrc+1]>>8)&0xFF;
+          r4 = (pSrc2[xSrc+1]>>16)&0xFF;
+          a4 = (pSrc2[xSrc+1]>>24)&0xFF;
+        }
+      }
+
+
+      // Pixel 1
+      pDst1[xSrc*2] = pSrc[xSrc];
+
+      // Pixel 2
+      if( xSrc<nWidth-1 )
+      {
+        pDst1[xSrc*2+1] = DWORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2);
+      }
+      else
+        pDst1[xSrc*2+1] = pSrc[xSrc];
+
+
+      // Pixel 3
+      if( ySrc<nHeight-1 )
+      {
+        pDst2[xSrc*2] = DWORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2);
+      }
+      else
+        pDst2[xSrc*2] = pSrc[xSrc];
+
+      // Pixel 4
+      if( xSrc<nWidth-1 )
+      {
+        if( ySrc<nHeight-1 )
+        {
+          pDst2[xSrc*2+1] = DWORD_MAKE((r1+r2+r3+r4)/4, (g1+g2+g3+g4)/4, (b1+b2+b3+b4)/4, (a1+a2+a3+a4)/4);
+        }
+        else
+        {
+          pDst2[xSrc*2+1] = DWORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2);
+        }
+      }
+      else
+      {
+        if( ySrc<nHeight-1 )
+        {
+          pDst2[xSrc*2+1] = DWORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2);
+        }
+        else
+          pDst2[xSrc*2+1] = pSrc[xSrc];
+      }
+    }
+  }
+}
+
+#if !_16BPP_HACK
+// Basic 2x R4G4B4A4 filter with interpolation
+void Texture2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height)
+{
+  uint16 *pDst1, *pDst2;
+  uint16 *pSrc, *pSrc2;
+  uint32 nWidth = width;
+  uint32 nHeight = height;
+
+  uint16 b1;
+  uint16 g1;
+  uint16 r1;
+  uint16 a1;
+  uint16 b2;
+  uint16 g2;
+  uint16 r2;
+  uint16 a2;
+  uint16 b3;
+  uint16 g3;
+  uint16 r3;
+  uint16 a3;
+  uint16 b4;
+  uint16 g4;
+  uint16 r4;
+  uint16 a4;
+
+  uint16 xSrc;
+  uint16 ySrc;
+
+  for (ySrc = 0; ySrc < nHeight; ySrc++)
+  {
+    pSrc = (uint16*)(((uint8*)srcPtr)+ySrc*srcPitch);
+    pSrc2 = (uint16*)(((uint8*)srcPtr)+(ySrc+1)*srcPitch);
+    pDst1 = (uint16*)(((uint8*)dstPtr)+(ySrc*2)*dstPitch);
+    pDst2 = (uint16*)(((uint8*)dstPtr)+(ySrc*2+1)*dstPitch);
+
+    for (xSrc = 0; xSrc < nWidth; xSrc++)
+    {
+      b1 = (pSrc[xSrc]>> 0)&0xF;
+      g1 = (pSrc[xSrc]>> 4)&0xF;
+      r1 = (pSrc[xSrc]>> 8)&0xF;
+      a1 = (pSrc[xSrc]>>12)&0xF;
+
+      if( xSrc<nWidth-1 )
+      {
+        b2 = (pSrc[xSrc+1]>> 0)&0xF;
+        g2 = (pSrc[xSrc+1]>> 4)&0xF;
+        r2 = (pSrc[xSrc+1]>> 8)&0xF;
+        a2 = (pSrc[xSrc+1]>>12)&0xF;
+      }
+
+      if( ySrc<nHeight-1 )
+      {
+        b3 = (pSrc2[xSrc]>> 0)&0xF;
+        g3 = (pSrc2[xSrc]>> 4)&0xF;
+        r3 = (pSrc2[xSrc]>> 8)&0xF;
+        a3 = (pSrc2[xSrc]>>12)&0xF;
+        if( xSrc<nWidth-1 )
+        {
+          b4 = (pSrc2[xSrc+1]>> 0)&0xF;
+          g4 = (pSrc2[xSrc+1]>> 4)&0xF;
+          r4 = (pSrc2[xSrc+1]>> 8)&0xF;
+          a4 = (pSrc2[xSrc+1]>>12)&0xF;
+        }
+      }
+
+      // Pixel 1
+      pDst1[xSrc*2] = pSrc[xSrc];
+
+      // Pixel 2
+      if( xSrc<nWidth-1 )
+      {
+        pDst1[xSrc*2+1] = WORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2);
+      }
+      else
+        pDst1[xSrc*2+1] = pSrc[xSrc];
+
+
+      // Pixel 3
+      if( ySrc<nHeight-1 )
+      {
+        pDst2[xSrc*2] = WORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2);
+      }
+      else
+        pDst2[xSrc*2] = pSrc[xSrc];
+
+      // Pixel 4
+      if( xSrc<nWidth-1 )
+      {
+        if( ySrc<nHeight-1 )
+        {
+          pDst2[xSrc*2+1] = WORD_MAKE((r1+r2+r3+r4)/4, (g1+g2+g3+g4)/4, (b1+b2+b3+b4)/4, (a1+a2+a3+a4)/4);
+        }
+        else
+        {
+          pDst2[xSrc*2+1] = WORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2);
+        }
+      }
+      else
+      {
+        if( ySrc<nHeight-1 )
+        {
+          pDst2[xSrc*2+1] = WORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2);
+        }
+        else
+          pDst2[xSrc*2+1] = pSrc[xSrc];
+      }
+    }
+  }
+}
+#endif /* !_16BPP_HACK */
+
+/*
+ * Sharp filters
+ * Hiroshi Morii <koolsmoky@users.sourceforge.net>
+ */
+void SharpFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter)
+{
+  // NOTE: for now we get away with copying the boundaries
+  //       filter the boundaries if we face problems
+
+  uint32 mul1, mul2, mul3, shift4;
+
+  uint32 x,y,z;
+  uint32 *_src1, *_src2, *_src3, *_dest;
+  uint32 val[4];
+  uint32 t1,t2,t3,t4,t5,t6,t7,t8,t9;
+
+  switch( filter )
+  {
+  case SHARP_FILTER_2:
+    mul1=1;
+    mul2=8;
+    mul3=12;
+    shift4=2;
+    break;
+  case SHARP_FILTER_1:
+  default:
+    mul1=1;
+    mul2=8;
+    mul3=16;
+    shift4=3;
+    break;
+  }
+
+  // setup rows
+  _src1 = src;
+  _src2 = _src1 + srcwidth;
+  _src3 = _src2 + srcwidth;
+  _dest = dest;
+
+  // copy the first row
+  memcpy(_dest, _src1, (srcwidth << 2));
+  _dest += srcwidth;
+  // filter 2nd row to 1 row before the last
+  for (y = 1; y < srcheight-1; y++) {
+    // copy the first pixel
+    _dest[0] = *_src2;
+    // filter 2nd pixel to 1 pixel before last
+    for (x = 1; x < srcwidth-1; x++) {
+      for (z=0; z<4; z++) {
+        t1 = *((uint8*)(_src1+x-1)+z);
+        t2 = *((uint8*)(_src1+x  )+z);
+        t3 = *((uint8*)(_src1+x+1)+z);
+        t4 = *((uint8*)(_src2+x-1)+z);
+        t5 = *((uint8*)(_src2+x  )+z);
+        t6 = *((uint8*)(_src2+x+1)+z);
+        t7 = *((uint8*)(_src3+x-1)+z);
+        t8 = *((uint8*)(_src3+x  )+z);
+        t9 = *((uint8*)(_src3+x+1)+z);
+        
+        if( (t5*mul2) > (t1+t3+t7+t9+t2+t4+t6+t8)*mul1 ) {
+          val[z]= ((t5*mul3) - (t1+t3+t7+t9+t2+t4+t6+t8)*mul1)>>shift4;
+          if (val[z] > 0xFF) val[z] = 0xFF;
+        } else {
+          val[z] = t5;
+        }
+      }
+      _dest[x] = val[0]|(val[1]<<8)|(val[2]<<16)|(val[3]<<24);
+    }
+    // copy the ending pixel
+    _dest[srcwidth-1] = *(_src3 - 1);
+    // next row
+    _src1 += srcwidth;
+    _src2 += srcwidth;
+    _src3 += srcwidth;
+    _dest += srcwidth;
+  }
+  // copy the last row
+  memcpy(_dest, _src2, (srcwidth << 2));
+}
+
+#if !_16BPP_HACK
+void SharpFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *dest, uint32 filter)
+{
+  // NOTE: for now we get away with copying the boundaries
+  //       filter the boundaries if we face problems
+
+  uint16 mul1, mul2, mul3, shift4;
+
+  uint32 x,y,z;
+  uint16 *_src1, *_src2, *_src3, *_dest;
+  uint16 val[4];
+  uint16 t1,t2,t3,t4,t5,t6,t7,t8,t9;
+
+  switch( filter ) {
+  case SHARP_FILTER_2:
+    mul1=1;
+    mul2=8;
+    mul3=12;
+    shift4=2;
+    break;
+  case SHARP_FILTER_1:
+  default:
+    mul1=1;
+    mul2=8;
+    mul3=16;
+    shift4=3;
+    break;
+  }
+
+  // setup rows
+  _src1 = src;
+  _src2 = _src1 + srcwidth;
+  _src3 = _src2 + srcwidth;
+  _dest = dest;
+
+  // copy the first row
+  memcpy(_dest, _src1, (srcwidth << 1));
+  _dest += srcwidth;
+  // filter 2nd row to 1 row before the last
+  for( y = 1; y < srcheight - 1; y++) {
+    // copy the first pixel
+    _dest[0] = *_src2;
+    // filter 2nd pixel to 1 pixel before last
+    for( x = 1; x < srcwidth - 1; x++) {
+      for( z = 0; z < 4; z++ ) {
+        /* Hiroshi Morii <koolsmoky@users.sourceforge.net>
+         * Read the entire 16bit pixel and then extract the A,R,G,B components.
+         */
+        uint32 shift = z << 2;
+        t1 = ((*((uint16*)(_src1+x-1))) >> shift) & 0xF;
+        t2 = ((*((uint16*)(_src1+x  ))) >> shift) & 0xF;
+        t3 = ((*((uint16*)(_src1+x+1))) >> shift) & 0xF;
+        t4 = ((*((uint16*)(_src2+x-1))) >> shift) & 0xF;
+        t5 = ((*((uint16*)(_src2+x  ))) >> shift) & 0xF;
+        t6 = ((*((uint16*)(_src2+x+1))) >> shift) & 0xF;
+        t7 = ((*((uint16*)(_src3+x-1))) >> shift) & 0xF;
+        t8 = ((*((uint16*)(_src3+x  ))) >> shift) & 0xF;
+        t9 = ((*((uint16*)(_src3+x+1))) >> shift) & 0xF;
+        
+        if( (t5*mul2) > (t1+t3+t7+t9+t2+t4+t6+t8)*mul1 ) {
+          val[z] = ((t5*mul3) - (t1+t3+t7+t9+t2+t4+t6+t8)*mul1)>>shift4;
+          if (val[z] > 0xF) val[z] = 0xF;
+        } else {
+          val[z] = t5;
+        }
+      }
+      _dest[x] = val[0]|(val[1]<<4)|(val[2]<<8)|(val[3]<<12);
+    }