Index: trunk/src/opengl/glide/swlibs/LICENSE.TXT
===================================================================
--- trunk/src/opengl/glide/swlibs/LICENSE.TXT	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/LICENSE.TXT	(revision 2887)
@@ -0,0 +1,259 @@
+$Id: LICENSE.TXT,v 1.1 2000-02-25 00:34:51 sandervl Exp $
+@c This is an additional Odin license agreement.
+@c It supercedes the main Odin license, but is only valid in 
+@c the source directory and any of it's subdirectories in which it is present.
+3DFX GLIDE Source Code General Public License
+
+
+1. PREAMBLE
+
+	This license is for software that provides a 3D graphics application 
+	program interface (API).The license is intended to offer terms similar
+	to some standard General Public Licenses designed to foster open 
+	standards and unrestricted accessibility to source code. Some of these
+	licenses require that, as a condition of the license of the software, 
+	any derivative works (that is, new software which is a work containing
+	the original program or a portion of it) must be available for general
+	use, without restriction other than for a minor transfer fee, and that
+	the source code for such derivative works must likewise be made 
+	available. The only restriction is that such derivative works must be
+	subject to the same General Public License terms as the original work. 
+
+	This 3dfx GLIDE Source Code General Public License differs from the
+	standard licenses of this type in that it does not require the entire
+	derivative work to be made available under the terms of this license
+	nor is the recipient required to make available the source code for
+	the entire derivative work. Rather, the license is limited to only the
+	identifiable portion of the derivative work that is derived from the
+	licensed software. The precise terms and conditions for copying, 
+	distribution and modification follow.
+
+
+2. DEFINITIONS
+
+	2.1 This License applies to any program (or other "work") which 
+	contains a notice placed by the copyright holder saying it may be 
+	distributed under the terms of this 3dfx GLIDE Source Code General 
+	Public License. 
+
+	2.2 The term "Program" as used in this Agreement refers to 3DFX's 
+	GLIDE source code and object code and any Derivative Work.
+
+	2.3 "Derivative Work" means, for the purpose of the License, that 
+	portion of any work that contains the Program or the identifiable 
+	portion of a work that is derived from the Program, either verbatim or
+	with modifications and/or translated into another language, and that 
+	performs 3D graphics API operations. It does not include any other 
+	portions of a work.
+
+	2.4 "Modifications of the Program" means any work, which includes a
+	Derivative Work, and includes the whole of such work.
+
+	2.5 "License" means this 3dfx GLIDE Source Code General Public License.
+
+	2.6 The "Source Code" for a work means the preferred form of the work
+	for making modifications to it. For an executable work, complete source
+	code means all the source code for all modules it contains, any
+	associated interface definition files, and the scripts used to control
+	compilation and installation of the executable work.
+
+	2.7 "3dfx" means 3dfx Interactive, Inc.
+
+
+3. LICENSED ACTIVITIES
+
+	3.1 COPYING - You may copy and distribute verbatim copies of the 
+	Program's Source Code as you receive it, in any medium, subject to the
+	provision of section 3.3 and provided also that:
+
+		(a) you conspicuously and appropriately publish on each copy
+	an appropriate copyright notice (3dfx Interactive, Inc. 1999), a notice
+	that recipients who wish to copy, distribute or modify the Program can
+	only do so subject to this License, and a disclaimer of warranty as
+	set forth in section 5;
+
+		(b) keep intact all the notices that refer to this License and
+	to the absence of any warranty; and
+ 
+		(c) do not make any use of the GLIDE trademark without the prior
+	written permission of 3dfx, and 
+
+		(d) give all recipients of the Program a copy of this License
+	along with the Program or instructions on how to easily receive a copy
+	of this License.
+
+
+	3.2 MODIFICATION OF THE PROGRAM/DERIVATIVE WORKS - You may modify your
+	copy or copies of the Program or any portion of it, and copy and
+	distribute such modifications subject to the provisions of section 3.3
+	and provided that you also meet all of the following conditions: 
+
+		(a) you conspicuously and appropriately publish on each copy
+	of a Derivative Work an appropriate copyright notice, a notice that
+	recipients who wish to copy, distribute or modify the Derivative Work
+	can only do so subject to this License, and a disclaimer of warranty
+	as set forth in section 5;
+
+		(b) keep intact all the notices that refer to this License and
+	to the absence of any warranty; and
+ 
+		(c) give all recipients of the Derivative Work a copy of this
+	License along with the Derivative Work or instructions on how to easily
+	receive a copy of this License.
+
+		(d) You must cause the modified files of the Derivative Work
+	to carry prominent notices stating that you changed the files and the
+	date of any change. 
+
+		(e) You must cause any Derivative Work that you distribute or
+	publish to be licensed at no charge to all third parties under the
+	terms of this License. 
+
+		(f) You do not make any use of the GLIDE trademark without the 
+	prior written permission of 3dfx.
+		
+		(g) If the Derivative Work normally reads commands 
+	interactively when run, you must cause it, when started running for
+	such interactive use, to print or display an announcement as follows:
+
+	"COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED THIS 
+	SOFTWARE IS FREE AND PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, 
+	EITHER EXPRESSED OR IMPLIED. THERE IS NO RIGHT TO USE THE GLIDE 
+	TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX INTERACTIVE, 
+	INC. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A FULL TEXT OF THE
+	DISTRIBUTION AND NON-WARRANTY PROVISIONS (REQUEST COPY FROM 
+	INFO@3DFX.COM)."
+
+		(h) The requirements of this section 3.2 do not apply to the
+	modified work as a whole but only to the Derivative Work. It is not
+	the intent of this License to claim rights or contest your rights to
+	work written entirely by you; rather, the intent is to exercise the
+	right to control the distribution of Derivative Works. 
+
+
+	3.3 DISTRIBUTION 
+
+		(a) All copies of the Program or Derivative Works which are
+	distributed must include in the file headers the following language
+	verbatim:
+
+	"THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED 
+	ONLY PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO 
+	RIGHT TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 
+	3DFX INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM 
+	THE DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC (info@3dfx.com). 
+	THIS PROGRAM. IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+	EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+	FULL TEXT OF THE NON-WARRANTY PROVISIONS.
+
+	USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+	RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS
+	IN TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+	AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+	SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+	THE UNITED STATES.
+
+	COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED"
+
+		(b) You may distribute the Program or a Derivative Work in
+	object code or executable form under the terms of Sections 3.1 and 3.2
+	provided that you also do one of the following: 
+
+			(1) Accompany it with the complete corresponding
+	machine-readable source code, which must be distributed under the 
+	terms of Sections 3.1 and 3.2; or,
+ 
+			(2) Accompany it with a written offer, valid for at
+	least three years, to give any third party, for a charge no more than
+	your cost of physically performing source distribution, a complete
+	machine-readable copy of the corresponding source code, to be 
+	distributed under the terms of Sections 3.1 and 3.2 on a medium 
+	customarily used for software interchange; or,
+ 
+			(3) Accompany it with the information you received as
+	to the offer to distribute corresponding source code. (This alternative
+	is allowed only for noncommercial distribution and only if you received
+	the program in object code or executable form with such an offer, in
+	accord with Subsection 3.3(b)(2) above.)
+ 
+		(c) The source code distributed need not include anything
+	that is normally distributed (in either source or binary form) with
+	the major components (compiler, kernel, and so on) of the operating
+	system on which the executable runs, unless that component itself
+	accompanies the executable code.
+ 
+		(d) If distribution of executable code or object code is made
+	by offering access to copy from a designated place, then offering
+	equivalent access to copy the source code from the same place counts
+	as distribution of the source code, even though third parties are not
+	compelled to copy the source along with the object code. 
+
+		(e) Each time you redistribute the Program or any Derivative
+	Work, the recipient automatically receives a license from 3dfx and
+	successor licensors to copy, distribute or modify the Program and
+	Derivative Works subject to the terms and conditions of the License.
+	You may not impose any further restrictions on the recipients' 
+	exercise of the rights granted herein. You are not responsible for
+	enforcing compliance by third parties to this License.
+ 
+		(f) You may not make any use of the GLIDE trademark without 
+	the prior written permission of 3dfx.
+
+		(g) You may not copy, modify, sublicense, or distribute the
+	Program or any Derivative Works except as expressly provided under
+	this License. Any attempt otherwise to copy, modify, sublicense or
+	distribute the Program or any Derivative Works is void, and will
+	automatically terminate your rights under this License. However,
+	parties who have received copies, or rights, from you under this
+	License will not have their licenses terminated so long as such
+	parties remain in full compliance.
+
+ 
+4. MISCELLANEOUS
+
+	4.1 Acceptance of this License is voluntary. By using, modifying or
+	distributing the Program or any Derivative Work, you indicate your 
+	acceptance of this License to do so, and all its terms and conditions
+	for copying, distributing or modifying the Program or works based on
+	it. Nothing else grants you permission to modify or distribute the
+	Program or Derivative Works and doing so without acceptance of this
+	License is in violation of the U.S. and international copyright laws.
+
+	4.2 If the distribution and/or use of the Program or Derivative Works
+	is restricted in certain countries either by patents or by copyrighted
+	interfaces, the original copyright holder who places the Program under
+	this License may add an explicit geographical distribution limitation
+	excluding those countries, so that distribution is permitted only in
+	or among countries not thus excluded. In such case, this License
+	incorporates the limitation as if written in the body of this License.
+
+	4.3 This License is to be construed according to the laws of the 
+	State of California and you consent to personal jurisdiction in the
+	State of California in the event it is necessary to enforce the
+	provisions of this License.
+
+
+5. NO WARRANTIES
+
+	5.1 TO THE EXTENT PERMITTED BY APPLICABLE LAW, THERE IS NO WARRANTY
+	FOR THE PROGRAM. OR DERIVATIVE WORKS THE COPYRIGHT HOLDERS AND/OR
+	OTHER PARTIES PROVIDE THE PROGRAM AND ANY DERIVATIVE WORKS"AS IS"
+	WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+	FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY
+	AND PERFORMANCE OF THE PROGRAM AND ANY DERIVATIVE WORK IS WITH YOU.
+	SHOULD THE PROGRAM OR ANY DERIVATIVE WORK PROVE DEFECTIVE, YOU ASSUME
+	THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+	5.2 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL 3DFX
+	INTERACTIVE, INC., OR ANY OTHER COPYRIGHT HOLDER, OR ANY OTHER PARTY
+	WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM OR DERIVATIVE WORKS AS
+	PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
+	SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
+	INABILITY TO USE THE PROGRAM OR DERIVATIVE WORKS (INCLUDING BUT NOT
+	LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES
+	SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM OR
+	DERIVATIVE WORKS TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
+	HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+	DAMAGES.
+
Index: trunk/src/opengl/glide/swlibs/fxmisc/3dfx.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/3dfx.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/3dfx.h	(revision 2887)
@@ -0,0 +1,124 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:50 $
+*/
+#ifndef __3DFX_H__
+#define __3DFX_H__
+
+/*
+** basic data types
+*/
+typedef unsigned char   FxU8;
+typedef signed   char   FxI8;
+typedef unsigned short  FxU16;
+typedef signed   short  FxI16;
+typedef signed   long   FxI32;
+typedef unsigned long   FxU32;
+typedef int             FxBool;
+typedef float           FxFloat;
+typedef double          FxDouble;
+
+/*
+** color types
+*/
+typedef unsigned long                FxColor_t;
+typedef struct { float r, g, b, a; } FxColor4;
+
+/*
+** fundamental types
+*/
+#define FXTRUE    1
+#define FXFALSE   0
+
+/*
+** helper macros
+*/
+#define FXUNUSED( a ) ((void)(a))
+#define FXBIT( i )    ( 1L << (i) )
+
+/*
+** export macros
+*/
+
+#if defined(__MSC__) || defined(_MSC_VER)
+#  if defined (MSVC16)
+#    define FX_ENTRY 
+#    define FX_CALL
+#  else
+#    define FX_ENTRY extern
+#    define FX_CALL  __stdcall
+#  endif
+#elif defined(__OS2__) && !defined(__WIN32OS2__)
+#  define FX_ENTRY extern
+#  define FX_CALL  _System
+#elif defined(__WATCOMC__)
+#  define FX_ENTRY extern
+#  define FX_CALL  __stdcall
+#elif defined (__IBMC__) || defined (__IBMCPP__)
+   /*  IBM Visual Age C/C++: */
+#  define FX_ENTRY extern
+#  define FX_CALL  __stdcall
+#elif defined(__DJGPP__)
+#  define FX_ENTRY extern
+#  define FX_CALL
+#elif defined(__unix__)
+#  define FX_ENTRY extern
+#  define FX_CALL
+#elif defined(__MWERKS__)
+#  if macintosh
+#    define FX_ENTRY extern
+#    define FX_CALL
+#  else /* !macintosh */
+#    error "Unknown MetroWerks target platform"
+#  endif /* !macintosh */
+#else
+#  warning define FX_ENTRY & FX_CALL for your compiler
+#  define FX_ENTRY extern
+#  define FX_CALL
+#endif
+
+/*
+** x86 compiler specific stuff
+*/
+#if defined(__BORLANDC_)
+#  define REALMODE
+
+#  define REGW( a, b ) ((a).x.b)
+#  define REGB( a, b ) ((a).h.b)
+#  define INT86( a, b, c ) int86(a,b,c)
+#  define INT86X( a, b, c, d ) int86x(a,b,c,d)
+
+#  define RM_SEG( a ) FP_SEG( a )
+#  define RM_OFF( a ) FP_OFF( a )
+#elif defined(__WATCOMC__)
+#  undef FP_SEG
+#  undef FP_OFF
+
+#  define REGW( a, b ) ((a).w.b)
+#  define REGB( a, b ) ((a).h.b)
+#  define INT86( a, b, c ) int386(a,b,c)
+#  define INT86X( a, b, c, d ) int386x(a,b,c,d)
+
+#  define RM_SEG( a )  ( ( ( ( FxU32 ) (a) ) & 0x000F0000 ) >> 4 )
+#  define RM_OFF( a )  ( ( FxU16 ) (a) )
+#endif
+
+#endif /* !__3DFX_H__ */
Index: trunk/src/opengl/glide/swlibs/fxmisc/atsc.asm
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/atsc.asm	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/atsc.asm	(revision 2887)
@@ -0,0 +1,70 @@
+;; THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+;; PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+;; TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+;; INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+;; DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+;; THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+;; EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+;; FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+;; 
+;; USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+;; RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+;; TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+;; AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+;; SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+;; THE UNITED STATES.  
+;; 
+;; COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+	
+;; 
+;; Assembly Function for reading the Time Stamp Counter
+;;
+TITLE  utsc.asm
+.586P
+;include listing.inc
+if @Version gt 510
+.model FLAT, C
+else
+_TEXT   SEGMENT PARA USE32 PUBLIC 'CODE'
+_TEXT   ENDS
+_DATA   SEGMENT DWORD USE32 PUBLIC 'DATA'
+_DATA   ENDS
+CONST   SEGMENT DWORD USE32 PUBLIC 'CONST'
+CONST   ENDS
+_BSS    SEGMENT DWORD USE32 PUBLIC 'BSS'
+_BSS    ENDS
+_TLS    SEGMENT DWORD USE32 PUBLIC 'TLS'
+_TLS    ENDS
+FLAT    GROUP _DATA, CONST, _BSS
+        ASSUME  CS: FLAT, DS: FLAT, SS: FLAT
+endif
+
+; some useful floating load and store macros <ala gmt>
+flds    TEXTEQU <fld  DWORD PTR>
+fsubs   TEXTEQU <fsub DWORD PTR>
+fmuls   TEXTEQU <fmul DWORD PTR>
+fstsp   TEXTEQU <fstp DWORD PTR>
+
+_DATA   SEGMENT
+One     DD      03f800000r
+Dummy   DD  ?
+_DATA   ENDS
+
+_TEXT           SEGMENT
+
+;;  Fxu32 tscReadTSC( void ) 
+;;  Reads the pentium time stamp counter and returns
+;;  the low 32bits 
+
+        align 4
+    PUBLIC  tscReadTSC
+    tscReadTSC PROC NEAR   
+
+        .586
+    rdtsc                   ; Read the time stamp counter 
+
+    ret
+    tscReadTSC ENDP
+
+_TEXT ENDS
+END
Index: trunk/src/opengl/glide/swlibs/fxmisc/fx64.c
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fx64.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fx64.c	(revision 2887)
@@ -0,0 +1,153 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:50 $
+*/
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <fx64.h>
+
+#ifndef NATIVE_64_SUPPORT
+
+FxI64  i64_one  = { 0, 1 };
+FxI64  i64_zero = { 0, 0 };
+
+static FxBool fx64_cf;
+
+FxBool __FX_ADD32( FxU32 a, FxU32 b );
+#pragma aux __FX_ADD32 = \
+   "mov fx64_cf, 0" \
+   "add eax, edx"   \
+   "adc fx64_cf, 0" \
+   parm [eax] [edx] \
+   value [eax];
+
+FxI64 __FX_AND64( FxI64 a, FxI64 b )
+{
+   FxI64 result;
+
+   result.hi = a.hi & b.hi;
+   result.lo = a.lo & b.lo;
+
+   return result;
+}
+
+FxI64 __FX_CREATE64( FxI32 a, FxU32 b )
+{
+   FxI64 result;
+
+   result.hi = a;
+   result.lo = b;
+
+   return result;
+}
+
+/*
+** __FX_MUL64
+**
+** The following code is NOT a full 64-bit multiply.  It only computes
+** the low order 64-bits of the product since this is all our hardware
+** needs.
+*/
+FxI64 __FX_MUL64( FxI64 a, FxI64 b )
+{
+   FxI64 result = { 0, 0 };
+
+   FXUNUSED( a );
+   FXUNUSED( b );
+
+   puts( "__FX_MUL64:  not implemented" );
+   exit( 1 );
+   return result;
+}
+
+FxI64 __FX_OR64( FxI64 a, FxI64 b )
+{
+   FxI64 result;
+
+   result.hi = a.hi | b.hi;
+   result.lo = a.lo | b.lo;
+
+   return result;
+}
+
+FxI64 __FX_COMP64( FxI64 a )
+{
+   FxI64 result;
+
+   result.hi = ~a.hi;
+   result.lo = ~a.lo;
+
+   return result;
+}
+
+float __FX_64TOFLOAT( FxI64 a )
+{
+   double hi, lo;
+
+   hi = a.hi * 4294967296.0;	// 2**32
+   lo = ( float ) a.lo;
+   return (float)(hi + lo);
+}
+
+FxI64 __FX_FLOATTO64( float f )
+{
+    int n;
+    FxU32 data;
+    FxI64 result;
+
+    data = *(FxU32 *)&f;		// get into integer register
+    n = (data>>23) & 0xFF;		// peel off exponent
+    n = 150 - n;			// compute shift amount
+    data |= 0x800000;			// add in the hidden bit
+    result.hi = 0;
+    result.lo = (data&0xFFFFFF);
+    if (n > 0) {			// need to shift right, < 2**23
+	if (n > 31) n = 31;
+	result.lo >>= n;
+    }
+    else {
+	n = -n;
+	if (n > 63) n = 63;
+        result = FX_SHL64( result, n );
+    }
+    // negate after shift, this rounds down instead of to zero
+    if (data & 0x80000000)
+      result = FX_NEG64(result);
+    return result;
+}
+
+
+int __FX_CMP64( FxI64 a, FxI64 b )
+{
+   if ( a.hi < b.hi )
+      return -1;
+   if ( a.hi > b.hi )
+      return 1;
+   if ( a.lo < b.lo )
+      return -1;
+   else if ( a.lo > b.lo )
+      return 1;
+   return 0;
+}
+
+#endif
+
Index: trunk/src/opengl/glide/swlibs/fxmisc/fx64.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fx64.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fx64.h	(revision 2887)
@@ -0,0 +1,275 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:51 $
+*/
+#ifndef __FX64_H__
+#define __FX64_H__
+
+#include "3dfx.h"
+
+/*
+** first figure out what compiler/os we are using and what is supported
+*/
+
+#if (__IBMCPP__ >= 360)
+#define _MSC_VER
+#endif
+
+/*
+** WATCOMC
+*/
+#if defined(__WATCOMC__)
+   #define FX_BIT64(n) ( FX_SHL64( i64_one, n ) )
+/*
+** GCC
+*/
+#elif defined(__GNUC__)
+   typedef signed long long FxI64;
+   typedef unsigned long long FxU64;
+   #define NATIVE_64_SUPPORT 1
+   #define FX_MASK64(n) (0xFFFFFFFFFFFFFFFFLL >> (64-(n)))
+   #define FX_BIT64(n) (((FxI64)1) << (n))
+/*
+** Microsoft C
+*/
+#elif defined(_MSC_VER)
+   typedef signed __int64 FxI64;
+   typedef unsigned __int64 FxU64;
+
+   #define FX_MASK64(n) (0xFFFFFFFFFFFFFFFF >> (64-(n)))
+   #define FX_BIT64(n) (((FxI64)1) << (n))
+   #define NATIVE_64_SUPPORT 1
+
+#elif (__IBMCPP__ < 360)
+
+   #define NATIVE_64_SUPPORT 0
+
+#endif
+
+/*
+** The following code is for systems with native 64-bit data types
+*/
+#ifdef NATIVE_64_SUPPORT
+
+#define FX_ADD64( a, b )	 ((a) + (b))
+#define FX_AND64( a, b )	 ((a) & (b))
+#define FX_CMP64( a, b )	 error
+#define FX_COMP64( a )		 (~(a))
+#define FX_CREATE64( a, b ) ( (((FxI64) (a)) << 32) | (b) )
+#define FX_COPY32( a, b )	 a = (b)
+#define FX_EQ064( a )		 ( (a) == 0 )
+#define FX_LO64(a)		    ((FxI32)(a))
+#define FX_HI64(a)		    ((FxI32)FX_SHR64(a,32))
+#define FX_MUL32( a, b )    (( FxI64 )(  ( FxI64 ) (a) * ( FxI64 ) (b) ) )
+#define FX_MUL64( a, b )	 ((a) * (b))
+#define FX_NEG64( a )		 (-(a))
+#define FX_OR64( a, b )		 ((a) | (b))
+#define FX_SET64( a, b, c ) a = (c) | (((FxI64)(b))<<32)
+#define FX_SHL64( a, n )	 ((a) << (n))             // n < 64
+#define FX_SHR64( a, n )	 ((a) >> (n))             // n < 64
+#define FX_SUB64( a, b ) 	 ((a) - (b))
+#define FX_XOR64( a, b )	 ((a) ^ (b))
+#define FX_FLOATTO64( a )	 ((FxI64)(a))
+#define FX_64TOFLOAT( a )	 (float)(a)
+#define FX_64TODBL( a )		 (double)(a)
+
+/*
+** The following code is for Watcom C
+*/
+#else
+
+typedef struct
+{
+  FxI32 hi;
+  FxU32 lo;
+} FxI64;
+
+typedef struct
+{
+  FxU32 hi;
+  FxU32 lo;
+} FxU64;
+
+extern FxI64 i64_one;
+extern FxI64 i64_zero;
+
+#define FX_ADD64( a, b )  ( __FX_ADD64( (a).hi, (a).lo, (b).hi, (b).lo ) )
+#define FX_AND64( a, b )  ( __FX_AND64( a, b ) )
+#define FX_CMP64( a, b )  ( __FX_CMP64( a, b ) )
+#define FX_COMP64( a )	  ( __FX_COMP64( a ) )
+#define FX_CREATE64( a, b ) ( __FX_CREATE64( a, b ) )
+#define FX_COPY32( a, b ) ( a = __FX_32TO64( (b) ) )
+#define FX_EQ064( a )		( ( (a).lo == 0 ) && ( (a).hi == 0 ) )
+#define FX_HI64( a )      ( (a).hi )
+#define FX_LO64( a )      ( (a).lo )
+#define FX_MASK64( n )    ( __FX_MASK64( n ) )
+#define FX_MUL32( a, b )  ( __FX_MUL32( (a), (b) ) )
+#define FX_MUL64( a, b )  ( __FX_MUL64( (a), (b) ) )
+#define FX_NEG64( a )     ( __FX_NEG64( (a).hi, (a).lo ) )
+#define FX_OR64( a, b )   ( __FX_OR64( a, b ) )
+#define FX_SET64( a, b, c ) {(a).hi = b; (a).lo = c;}
+#define FX_SHL64( a, n )  ( __FX_SHL64( (a).hi, (a).lo, n ) )
+#define FX_SHR64( a, n )  ( __FX_SHR64( (a).hi, (a).lo, n ) )
+#define FX_SUB64( a, b )  ( __FX_SUB64( (a).hi, (a).lo, (b).hi, (b).lo ) )
+#define FX_FLOATTO64( a ) ( __FX_FLOATTO64((a)) )
+#define FX_64TOFLOAT( a )   ( __FX_64TOFLOAT((a)) )
+
+/*
+** The following functions are implemented as inline assembly
+*/
+FxI64 __FX_ADD64( FxI32 a_hi, FxU32 a_lo, FxI32 b_hi, FxU32 b_lo );
+FxI64 __FX_32TO64( FxI32 value );
+FxI64 __FX_MASK64( int n );
+FxI64 __FX_MUL32( FxI32 a, FxI32 b );
+FxI64 __FX_NEG64( FxI32 hi, FxU32 lo );
+FxI64 __FX_SHL64( FxI32 hi, FxU32 lo, int n );
+FxI64 __FX_SHR64( FxI32 hi, FxU32 lo, int n );
+FxI64 __FX_SUB64( FxI32 a_hi, FxU32 a_lo, FxI32 b_hi, FxU32 b_lo );
+
+/*
+** The following functions are implemented as C functions
+*/
+FxI64 __FX_AND64( FxI64 a, FxI64 b );
+int   __FX_CMP64( FxI64 a, FxI64 b );
+FxI64 __FX_COMP64( FxI64 a );
+FxI64 __FX_CREATE64( FxI32 a, FxU32 b );
+FxI64 __FX_FLOATTO64( float a );
+FxI64 __FX_MUL64( FxI64 a, FxI64 b );
+FxI64 __FX_OR64( FxI64 a, FxI64 b );
+float __FX_64TOFLOAT( FxI64 );
+
+#pragma aux __FX_32TO64 = \
+   "cdq" \
+   "mov [esi], edx" \
+   "mov [esi+4], eax" \
+   parm [eax] \
+   modify [edx] \
+   value struct struct;
+
+#pragma aux __FX_ADD64 = \
+   "add  eax, ecx" \
+   "adc  edx, ebx" \
+   "mov  [esi], edx" \
+   "mov  [esi+4], eax" \
+   parm [edx] [eax] [ebx] [ecx] \
+   value struct struct;
+
+#pragma aux __FX_MUL32 = \
+   "imul  edx" \
+   "mov   [esi], edx" \
+   "mov   [esi+4], eax" \
+   parm [edx] [eax] \
+   value struct struct;
+
+#pragma aux __FX_SUB64 = \
+   "sub  eax, ecx" \
+   "sbb  edx, ebx" \
+   "mov  [esi], edx" \
+   "mov  [esi+4], eax" \
+   parm [edx] [eax] [ebx] [ecx] \
+   value struct struct;
+
+#pragma aux __FX_SHL64 = \
+   "cmp  cl, 32" \
+   "jl   SHL_LT32" \
+   "sub  cl, 32" \
+   "mov  edx, eax " \
+   "mov  eax, 0 " \
+   "shl  edx, cl" \
+   "jmp SHL_DONE" \
+   "SHL_LT32:" \
+   "shld edx, eax, cl" \
+   "sal  eax, cl" \
+   "SHL_DONE:" \
+   "mov  [esi], edx" \
+   "mov  [esi+4], eax" \
+   parm [edx] [eax] [cx] \
+   value struct struct;
+
+#pragma aux __FX_SHR64 = \
+   "cmp  cl, 32" \
+   "jl   SHR_LT32" \
+   "sub  cl, 32 " \
+   "mov  eax, edx" \
+   "test edx, 080000000h" \
+   "jz  SHR_GE32_POSITIVE" \
+   "SHR_GE32_NEGATIVE:" \
+   "mov  edx, 0FFFFFFFFh" \
+   "or   eax, 080000000h" \
+   "sar  eax, cl" \
+   "jmp  SHR_DONE" \
+   "SHR_GE32_POSITIVE:" \
+   "mov  edx, 0" \
+   "shr  eax, cl" \
+   "jmp  SHR_DONE" \
+   "SHR_LT32: " \
+   "shrd eax, edx, cl" \
+   "sar  edx, cl" \
+   "SHR_DONE: " \
+   "mov  [esi], edx" \
+   "mov  [esi+4], eax" \
+   parm [edx] [eax] [cx] \
+   value struct struct;
+
+#pragma aux __FX_NEG64 = \
+   "neg eax" \
+   "adc edx, 0" \
+   "neg edx" \
+   "mov [esi], edx" \
+   "mov [esi+4], eax" \
+   parm [edx] [eax] \
+   value struct struct;
+
+#pragma aux __FX_MASK64 = \
+   "mov edx, 64" \
+   "sub edx, ecx" \
+   "mov ecx, edx" \
+   "mov edx, 0ffffffffh" \
+   "mov eax, 0ffffffffh" \
+   "cmp  cl, 32" \
+   "jl   M64_LT32" \
+   "sub  cl, 32 " \
+   "mov  eax, edx" \
+   "mov  edx, 0" \
+   "shr  eax, cl" \
+   "jmp  M64_DONE" \
+   "M64_LT32: " \
+   "shrd eax, edx, cl" \
+   "shr  edx, cl" \
+   "M64_DONE: " \
+   "mov  [esi], edx" \
+   "mov  [esi+4], eax" \
+   modify [edx eax] \
+   parm [ecx] \
+   value struct struct;
+
+#endif /* __WATCOMC__ */
+
+/*
+** The following is shared between NATIVE64 and Watcom
+*/
+
+// a | -(a & (1 << n))  branchless, but may not be good implement for PC
+// for constant n, does &, -, |
+#define FX_SGNEXT64( a, n ) (FX_OR64((a), FX_NEG64(FX_AND64((a), FX_SHL64(FX_CREATE64(0,1), (n))))))
+
+#endif /* __FX64_H__ */
+
Index: trunk/src/opengl/glide/swlibs/fxmisc/fxdll.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fxdll.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fxdll.h	(revision 2887)
@@ -0,0 +1,145 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:51 $
+*/
+/* preprocessor defines for libraries to support DLL creation */
+
+/* in header file, use FX_ENTRY return-type FX_CALL function-name ( ... ) */
+/* in source file, use FX_EXPORT return-type FX_CSTYLE function-name (... ) */
+
+/* in source file, set FX_DLL_DEFINITION, include this file, then include
+   header file for library. */
+
+/* we need to use two macros per declaration/definition because MSVC
+   requires __stdcall and __declspec( dllexport ) be in different parts
+   of the prototype! */
+
+/* I use two sets in case we need to control declarations and definitions
+   differently.  If it turns out we don't, it should be easy to do a search
+   and replace to eliminate one set */
+
+/* NOTE: this header file may be included more than once, and FX_DLL_DEFINITION
+   may have changed, so we do not protect this with an #fndef __FXDLL_H__
+   statement like we normally would. */
+
+
+#ifdef FX_ENTRY
+#undef FX_ENTRY
+#endif
+
+#ifdef FX_CALL
+#undef FX_CALL
+#endif
+
+#ifdef FX_EXPORT
+#undef FX_EXPORT
+#endif
+
+#ifdef FX_CSTYLE
+#undef FX_CSTYLE
+#endif
+
+#if defined(_WIN32)
+#if defined(FX_DLL_DEFINITION)
+  #if defined(FX_DLL_ENABLE)
+    #if defined(__MSC__)
+      #ifndef KERNEL
+        #define FX_ENTRY __declspec( dllexport )
+        #define FX_EXPORT __declspec( dllexport )
+      #else
+        #define FX_ENTRY
+        #define FX_EXPORT
+     #endif /* #ifndef KERNEL */
+     #define FX_CALL __stdcall
+     #define FX_CSTYLE __stdcall
+
+    #elif defined(__WATCOMC__)
+      #define FX_ENTRY
+      #define FX_CALL __stdcall __export
+
+      #define FX_EXPORT
+      #define FX_CSTYLE __stdcall __export
+
+    #else /* compiler */
+      #error define FX_ENTRY,FX_CALL & FX_EXPORT,FX_CSTYLE for your compiler
+    #endif /* compiler */
+
+  #else /* FX_DLL_ENABLE */
+    #define FX_ENTRY
+    #define FX_CALL __stdcall
+
+    #define FX_EXPORT
+    #define FX_CSTYLE __stdcall
+  #endif /* FX_DLL_ENABLE */
+
+#else /* FX_DLL_DEFINITION */
+  #define FX_ENTRY extern
+  #define FX_CALL __stdcall
+#endif /* FX_DLL_DEFINITION */
+
+#elif defined(__WIN32OS2__)
+
+  #define FX_ENTRY 
+  #define FX_EXPORT
+  #define FX_CALL __stdcall
+  #define FX_CSTYLE __stdcall
+
+#elif defined(__OS2__)
+
+  #define FX_ENTRY 
+  #define FX_EXPORT
+  #define FX_CALL _System
+  #define FX_CSTYLE _System
+
+#endif
+
+/*
+ * We don't want any of this DLL junk for DJGPP or UNIX
+ * so undo what is done above.
+ */
+#if defined(__DJGPP__) || defined(__unix__)
+  #ifdef FX_CALL
+    #undef FX_CALL
+  #endif
+
+  #ifdef FX_CSTYLE
+    #undef FX_CSTYLE
+  #endif
+
+  #ifdef FX_EXPORT
+    #undef FX_EXPORT
+  #endif
+
+  #ifdef FX_ENTRY
+    #undef FX_ENTRY
+  #endif
+
+  #define FX_CALL
+  #define FX_CSTYLE 
+  #define FX_EXPORT
+  #define FX_ENTRY 
+#endif
+
+#if defined (MSVC16)
+  #undef FX_CALL
+  #define FX_CALL
+#endif
+
Index: trunk/src/opengl/glide/swlibs/fxmisc/fxglob.c
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fxglob.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fxglob.c	(revision 2887)
@@ -0,0 +1,162 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:51 $
+*/
+
+/*
+	xnglob.c
+
+	The globulate function below takes an NT command line and expands
+	wildcards according to POSIX.2 rules. It returns 0 on success, or -1
+	on failure. The reason that *argv is always globbed on is to convert
+	any backslashes in the program name to slashes. The deglobulate
+	function below it merely frees the memory associated with the
+	previously run globulate.
+*/
+
+#ifdef WIN32
+
+#include <windows.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "glob.h"
+#include "fxglob.h"
+
+static signed int globulated_argi;
+signed int globulated_argc;
+char **globulated_argv;
+
+signed int globulate (signed int argi, signed int argc, char **argv)
+{
+	glob_t gl;
+	signed int ret, a;
+
+	if (argi <= 0 || argc < argi || argv == NULL || (ret = glob(*argv, GLOB_NOCHECK, NULL, &gl)) != 0)
+		ret = -1;
+	else
+	{
+		for (a = argi; a < argc; ++a)
+		{
+			if ((ret = glob(argv[a], GLOB_NOCHECK|GLOB_APPEND|GLOB_SHQUOTE, NULL, &gl)) != 0)
+			{
+				ret = -1;
+				goto globfree_gl;
+			}
+		}
+		if ((globulated_argv = malloc((argi + gl.gl_pathc + 1) * sizeof *globulated_argv)) == NULL)
+		{
+			ret = -1;
+			goto globfree_gl;
+		}
+		if ((*globulated_argv = malloc(strlen(*(gl.gl_pathv)) + 1)) == NULL)
+		{
+			ret = -1;
+			goto globfree_gl;
+		}
+		(void) strcpy(*globulated_argv, *(gl.gl_pathv));
+		for (a = 1; a < argi; ++a)
+			globulated_argv[a] = argv[a];
+		globulated_argc = gl.gl_pathc - 1;
+		for (a = 0; a < globulated_argc; ++a)
+		{
+			if ((globulated_argv[a + argi] = malloc(strlen(gl.gl_pathv[a + 1]) + 1)) == NULL)
+			{
+				while (a--)
+					free(globulated_argv[a + argi]);
+				free(*globulated_argv);
+				ret = -1;
+				goto globfree_gl;
+			}
+			(void) strcpy(globulated_argv[a + argi], gl.gl_pathv[a + 1]);
+		}
+		globulated_argv[a + argi] = NULL;
+		globulated_argc += argi;
+		globulated_argi = argi;
+		ret = 0;
+globfree_gl:
+		globfree(&gl);
+	}
+	return ret;
+}
+
+void deglobulate (void)
+{
+	for (globulated_argi = globulated_argc - globulated_argi; globulated_argi--; )
+		free(globulated_argv[--globulated_argc]);
+	free(*globulated_argv);
+	free(globulated_argv);
+}
+
+static WIN32_FIND_DATA fdata;
+static int valid;
+
+// GMT: POSIX emulation routines
+HANDLE opendir(char *path)
+{
+    HANDLE h;
+
+    h = FindFirstFile(path,&fdata);
+    if (h == INVALID_HANDLE_VALUE) {
+        printf("error: FindFirstFile failed - %d\n",GetLastError());
+    }
+    else valid = 1;
+    return h;
+}
+
+char *readdir(HANDLE h)
+{
+    if (!valid) {			// if no valid filename
+    	if (!FindNextFile(h,&fdata))	// find the next one
+	    return 0;			// if none, return 0
+    }
+    valid = 0;
+	// !!!TURBO HACKLAND
+	strlwr( fdata.cFileName );
+    return fdata.cFileName;
+}
+
+int closedir(HANDLE h)
+{
+    int rv = FindClose(h);
+    if (!rv)
+    	printf("error: FindClose failed - %d\n",GetLastError());
+    return rv;	
+}
+
+void fxGlobify( int *argc, char ***argv )
+{
+	// There's this upper/lower case pattern matching problem...
+	// !!!DANGER! FIRE-BREATHING ROBO-HACK
+	int index;
+	for( index = 1; index < *argc; index++ )
+	{
+		strlwr( (*argv)[index] );
+	}
+
+	if ( globulate( 1, *argc, *argv ) == 0 )
+	{
+		*argc = globulated_argc;
+		*argv = globulated_argv;
+	}
+}
+
+#endif
Index: trunk/src/opengl/glide/swlibs/fxmisc/fxglob.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fxglob.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fxglob.h	(revision 2887)
@@ -0,0 +1,33 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $ Revision: $
+** $ Date: $
+**
+*/
+
+
+#ifndef _FXGLOB_H_
+#define _FXGLOB_H_
+
+
+void fxGlobify( int *argc, char ***argv );
+
+
+#endif
Index: trunk/src/opengl/glide/swlibs/fxmisc/fximg.c
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fximg.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fximg.c	(revision 2887)
@@ -0,0 +1,1923 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:51 $
+**
+*/
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include "3dfx.h"
+#include "fximg.h"
+#include "fxos.h"
+
+/*
+** PRIVATE GLOBAL DATA
+*/
+
+char *imgErrorString = "No error.";
+
+/*
+** PRIVATE UTILITY FUNCTIONS
+*/
+
+/* _fixStream
+**
+** Summary: UNPUBLISHED - change mode for input / output streams so that
+**          they are are in binary mode for dos apps.
+*/
+#if defined( __DOS__ ) || defined( WIN32 )
+/* 
+** On dos-compatible platforms, iostreams must be set to binary( untranslated )
+** mode
+*/
+#include <fcntl.h>
+#include <io.h>
+void _fixStream( FILE *stream )
+{
+	setmode( fileno( stream ), O_BINARY );
+}
+#else
+/*
+** Otherwise do nothing
+*/
+#define _fixStream( X ) X = X
+#endif
+
+
+/* _imgStrUpr
+**
+** Summary: UNPUBLISHED - upper case the provided string in place.
+**          Provided because strupr isn't provided in all clib implementations.
+*/
+void _imgStrUpr( char *str )
+{
+    FxU32 index;
+    for ( index = 0; index < strlen( str ); index++ )
+    {
+		if ( str[index] >= 'a' && str[index] <= 'z' )
+		{
+	    	str[index] -= 'a' - 'A';
+		}
+    }
+}
+
+/* _imgIsLittleEndian
+**
+** UNPUBLISHED - returns FXTRUE if the host architecture
+**               stores memory in little endian format
+*/
+FxBool _imgIsLittleEndian( void )
+{
+    unsigned long x = 0x0000FFFF;
+    return( *((char *)&x)?FXTRUE:FXFALSE );
+}
+
+/* _imgTxDecodeColorFormat
+**
+** UNPUBLISHED - returns the integer color format give in a tdf color format
+**
+*/
+imgTxColorFormat _imgTxDecodeColorFormat( char * String )
+{
+  if(!strcmp(String,"true") ||
+     !strcmp(String,"TRUE"))
+    return txColorTrue;
+  else if(!strcmp(String,"i8") ||
+	  !strcmp(String,"I8"))
+    return txColorI_8;
+  else if(!strcmp(String,"a8") ||
+	  !strcmp(String,"A8"))
+    return txColorA_8;
+  else if(!strcmp(String,"ai44") ||
+	  !strcmp(String,"AI44"))
+    return txColorAI_44;
+  else if(!strcmp(String,"yiq") ||
+	  !strcmp(String,"YIQ"))
+    return txColorYIQ;
+  else if(!strcmp(String,"rgb332") ||
+	  !strcmp(String,"RGB332"))
+    return txColorRGB_332;
+  else if(!strcmp(String,"rgb565") ||
+	  !strcmp(String,"RGB565"))
+    return txColorRGB_565;
+  else if(!strcmp(String,"argb8332") ||
+	  !strcmp(String,"ARGB8332"))
+    return txColorARGB_8332;
+  else if(!strcmp(String,"argb1555") ||
+	  !strcmp(String,"ARGB1555"))
+    return txColorARGB_1555;
+  else if(!strcmp(String,"ayiq8422") ||
+	  !strcmp(String,"AYIQ8422"))
+    return txColorAYIQ_8422;
+  else if(!strcmp(String,"argb4444") ||
+	  !strcmp(String,"ARGB4444"))
+    return txColorARGB_4444;
+  else if(!strcmp(String,"ai88") ||
+	  !strcmp(String,"AI88"))
+    return txColorAI_88;
+  else if(!strcmp(String,"argb8888") ||
+	  !strcmp(String,"ARGB8888"))
+    return txColorARGB_8888;
+  else
+    return txColorUnknown;
+}
+
+/* _imgMSBReplicate
+**
+** Summary: UNPUBLISHED - Replicates the msb's of the input value to fill
+**                        in an 8-bit color channel;
+*/
+#define _imgMSBReplicate( COLOR, LEFT_SHIFT, RIGHT_SHIFT ) (COLOR << LEFT_SHIFT) | (COLOR >> RIGHT_SHIFT)
+
+/* _imgGuessType
+**
+** Summary: UNPUBLISHED - read the first word of an image file stream
+**          determine the file type.
+*/
+FxBool _imgGuessType( FILE *stream, ImgType *type )
+{
+    FxU32 cookie = 0;
+    int   c;
+    
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad File Handle";
+		return FXFALSE;
+    }
+    
+    if ( ( c = fgetc( stream ) ) == EOF )
+    {
+		imgErrorString = "Unexpected end of file";
+		return FXFALSE;
+    }
+    
+    cookie = (c << 8);
+    
+    if ( ( c = fgetc( stream ) ) == EOF )
+    {
+		imgErrorString = "Unexpected end of file";
+		return FXFALSE;
+    }
+    
+    cookie |= c;
+    
+    switch( cookie )
+    {
+      	case ('P' << 8) | '9': // SBI
+			*type = IMG_SBI;
+			break;
+      	case ('P' << 8) | '6': // PPM
+			*type = IMG_P6;
+			break;
+      	case ('3' << 8) | 'd': // 3df
+      	case ('3' << 8) | 'D': // 3df
+			*type = IMG_3DF;
+			break;
+      	case 0xDA01:
+			*type = IMG_RGT;
+			break;
+      	case 'EL':
+	  cookie = 0;
+	  if ( ( c = fgetc( stream ) ) == EOF )
+	    {
+	      imgErrorString = "Unexpected end of file";
+	      return FXFALSE;
+	    }
+	  cookie = (cookie << 8) | c;
+	  if ( ( c = fgetc( stream ) ) == EOF )
+	    {
+	      imgErrorString = "Unexpected end of file";
+	      return FXFALSE;
+	    }
+	  cookie = (cookie << 8) | c;
+	  if (cookie == 'RS')
+	    *type = IMG_SRLE;
+	  break;
+      	default: // Might Be TGA
+			if ( ( c = fgetc( stream ) ) == EOF )
+			{
+	    		imgErrorString = "Unexpected end of file";
+	    		return FXFALSE;
+			}
+			cookie <<= 8;
+			cookie |= c;
+	
+			if ( (cookie & 0x00FFFF) == 0x0002 ) *type = IMG_TGA32;
+			else *type = IMG_UNKNOWN;
+			break;
+    }
+    return FXTRUE;
+}
+
+
+/* _imgReadSbiHeader
+**
+** Summary: UNPUBLISHED - read header and fill in header info
+*/
+FxBool _imgReadSbiHeader( FILE *stream, SbiInfo *info )
+{
+    char buffer[256];
+    FxU32 state = 1;
+    FxBool done = FXFALSE;
+    
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+    
+    while( !done && fgets( buffer, 256, stream ) )
+    {
+		char *token;
+	
+		if ( buffer[0] == '#' ) continue;
+		for (token = strtok( buffer, " \t\n\r" );
+			token != NULL;
+			token = strtok( NULL, " \t\n\r" ))
+		switch( state )
+	    	{
+	      		case 1: // YOrigin
+					if ( token[1] == '+' ) info->yOrigin = 1;
+					else if ( token[1] == '-' )	info->yOrigin = 0;
+					else
+					{
+		    			imgErrorString = "Error parsing y-origin.";
+		    			return FXFALSE;
+					}
+					state++;
+					break;
+	      		case 2:   // Width
+					info->width = atoi( token );
+					state++;
+					break;
+	      		case 3: // height
+					info->height = atoi( token );
+					state++;
+					break;
+	     	 	case 4: // 'R'
+					if ( token[0] != 'R' )
+					{
+		    			imgErrorString = "Error parsing R color channel.";
+		    			return FXFALSE;
+					}
+					state++;
+					break;
+	      		case 5: // Red Channel
+					info->redBits = atoi( token );
+					state++;
+					break;
+	      		case 6: // 'G'
+					if ( token[0] != 'G' )
+					{
+		    			imgErrorString = "Error parsing G color channel.";
+		    			return FXFALSE;
+					}
+					state++;
+					break;
+	      		case 7: // Green Channel
+					info->greenBits = atoi( token );
+					state++;
+					break;
+	      		case 8: // 'B'
+					if ( token[0] != 'B' )
+					{
+		    			imgErrorString = "Error parsing B color channel.";
+		    			return FXFALSE;
+					}
+					state++;
+					break;
+	      		case 9: // Blue Channel                             
+					info->blueBits = atoi( token );
+					done = FXTRUE;
+					state++;
+					break;
+	      		default:
+					break;
+	    	}
+    }
+    
+    if ( state < 10 )
+    {
+		imgErrorString = "Read error before end of header.";
+		return FXFALSE;
+    }
+    
+    info->sizeInBytes = info->width * info->height * 4;
+    
+    return FXTRUE;
+}
+
+/* _imgReadP6Header
+**
+** Summary: UNPUBLISHED - read header and fill in header info
+*/
+FxBool _imgReadP6Header( FILE *stream,  P6Info *info )
+{
+    char buffer[256];
+    FxU32 state = 1;
+    FxBool done = FXFALSE;
+    
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+    
+    while( !done && fgets( buffer, 256, stream ) )
+    {
+		char *token;
+	
+		if ( buffer[0] == '#' ) continue;
+		for (token = strtok( buffer, " \t\n\r" );
+			token != NULL;
+			token = strtok( NULL, " \t\n\r" ))
+	    	switch( state )
+	    	{
+	     		case 1:   // Width
+					info->width = atoi( token );
+					state++;
+					break;
+	      		case 2: // height
+					info->height = atoi( token );
+					state++;
+					break;
+	      		case 3: // Color Depth
+					info->colorChannelMax = atoi( token );
+					if ( info->colorChannelMax != 255 )
+					{
+		    			imgErrorString = "Unsupported max color value.  Must be 255.";
+		    			return FXFALSE;
+					}
+					state++;
+					done = FXTRUE;
+					break;
+	      		default:
+					imgErrorString = "General parse error reading header.";
+					return FXFALSE;
+					break;
+	    	}
+    }
+    
+    if ( state < 4 )
+    {
+		imgErrorString = "Read error before end of header.";
+		return FXFALSE;
+    }
+    
+    info->sizeInBytes = info->width * info->height * 4;
+    
+    return FXTRUE;
+}
+
+/* _imgReadTGAHeader
+**
+** Summary: UNPUBLISHED - read header and fill in header info
+*/
+FxBool _imgReadTGAHeader( FILE *stream, TgaInfo *info )
+{
+    struct {
+		FxU8 CMapStartLo;
+		FxU8 CMapStartHi;
+		FxU8 CMapLengthLo;
+		FxU8 CMapLengthHi;
+		FxU8 CMapDepth;
+		FxU8 XOffSetLo;
+		FxU8 XOffSetHi;
+		FxU8 YOffSetLo;
+		FxU8 YOffSetHi;
+		FxU8 WidthLo;
+		FxU8 WidthHi;
+		FxU8 HeightLo;
+		FxU8 HeightHi;
+		FxU8 PixelDepth;
+		FxU8 ImageDescriptor;
+    } partialTGAHeader;
+    
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+    
+    if ( fread( &partialTGAHeader, 1, 15, stream ) != 15 )
+    {
+	  	imgErrorString = "Unexpected end of file.";
+		return FXFALSE;
+    }
+    
+    info->width  = partialTGAHeader.WidthHi << 8 | partialTGAHeader.WidthLo;
+    info->height = partialTGAHeader.HeightHi << 8 | partialTGAHeader.HeightLo;
+    info->yOrigin = 0x01 & partialTGAHeader.ImageDescriptor;
+    info->sizeInBytes = info->width * info->height * 4;
+    
+    return FXTRUE;
+}
+
+/* _imgWriteTGAHeader
+**
+** Summary: UNPUBLISHED - write header
+*/
+FxBool _imgWriteTGAHeader( FILE *stream, const TgaInfo *info ) {
+
+    struct {
+		FxU8 IDLength;
+		FxU8 ColorMapType;
+		FxU8 ImgType;
+		FxU8 CMapStartLo;
+		FxU8 CMapStartHi;
+		FxU8 CMapLengthLo;
+		FxU8 CMapLengthHi;
+		FxU8 CMapDepth;
+		FxU8 XOffSetLo;
+		FxU8 XOffSetHi;
+		FxU8 YOffSetLo;
+		FxU8 YOffSetHi;
+		FxU8 WidthLo;
+		FxU8 WidthHi;
+		FxU8 HeightLo;
+		FxU8 HeightHi;
+		FxU8 PixelDepth;
+		FxU8 ImageDescriptor;
+    } tgaHeader;
+    
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+	
+	tgaHeader.IDLength         = 0;
+	tgaHeader.ColorMapType     = 0;
+	tgaHeader.ImgType          = 0x2;
+	tgaHeader.CMapStartLo      = 0;
+	tgaHeader.CMapStartHi      = 0;
+	tgaHeader.CMapLengthLo     = 0;
+	tgaHeader.CMapLengthHi     = 0;
+	tgaHeader.CMapDepth        = 0;
+	tgaHeader.XOffSetLo        = 0;
+	tgaHeader.XOffSetHi        = 0;
+	tgaHeader.YOffSetLo        = 0;
+	tgaHeader.YOffSetHi        = 0;
+	tgaHeader.WidthHi          = (FxU8)(info->width >> 8) & 0xFF;
+	tgaHeader.WidthLo          = (FxU8)info->width & 0xFF;
+	tgaHeader.HeightHi         = (FxU8)(info->height >> 8) & 0xFF;
+	tgaHeader.HeightLo         = (FxU8)info->height & 0xFF;
+	tgaHeader.PixelDepth       = 32;
+	tgaHeader.ImageDescriptor  = info->yOrigin ? ( 0x1 ) : ( 0x0 );	
+	    
+
+	if ( fwrite( &tgaHeader, 1, 18, stream ) != 18 ) {
+		imgErrorString = "TGA Header stream write error.";
+		return FXFALSE;
+	}
+
+	return FXTRUE;
+}
+    
+/* _imgReadRGTHeader
+**
+** Summary: UNPUBLISHED - read header and fill in header info
+*/
+FxBool _imgReadRGTHeader( FILE *stream, RgtInfo *info )
+{
+    const FxU16 ITYPE_RLE      = 0x01;
+    const FxU16 ITYPE_NCC      = 0x02;
+    const FxU16 ITYPE_BGR      = 0x04;
+    const FxU16 ITYPE_RGT      = 0x08;
+    
+    struct {
+		FxU8 typeLo;
+		FxU8 typeHi;
+		FxU8 dimLo;
+		FxU8 dimHi;
+		FxU8 sizeXLo;
+		FxU8 sizeXHi;
+		FxU8 sizeYLo;
+		FxU8 sizeYHi;
+		FxU8 sizeZLo;
+		FxU8 sizeZHigh;
+    } partialRGTHeader;
+    
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+    
+    if ( fread( &partialRGTHeader, 1, 10, stream ) != 10 )
+    {
+		imgErrorString = "Unexpected end of file.";
+		return FXFALSE;
+    }
+    
+    info->width = partialRGTHeader.sizeXHi << 8 | partialRGTHeader.sizeXLo;
+    info->height = partialRGTHeader.sizeYHi << 8 | partialRGTHeader.sizeYLo;
+    info->sizeInBytes = info->width * info->height * 4;
+    info->rle = partialRGTHeader.typeHi & ITYPE_RLE;
+    info->bgr = partialRGTHeader.typeHi & ITYPE_BGR;
+    info->rgb = partialRGTHeader.typeHi & ITYPE_RGT;
+    info->ncc = partialRGTHeader.typeHi & ITYPE_NCC;
+    
+    return FXTRUE;
+}
+
+/* _imgRead3DFHeader
+**
+** Summary: UNPUBLISHED - read header and fill in header info
+*/
+FxBool _imgRead3DFHeader( FILE *stream, TdfInfo *info ) {
+	FxBool done = FXFALSE;
+    char buffer[256];
+	FxU32 state = 0;
+	float tempFloat;
+
+    if ( stream == NULL ) {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+
+    while( !done && fgets( buffer, 256, stream ) ) {
+		char *token;
+	
+		if ( buffer[0] == '#' ) continue;
+		for (token = strtok( buffer, " \t\n\r" );
+			token != NULL;
+			token = strtok( NULL, " \t\n\r" ))
+	    	switch( state )	{
+				case  0:   // 'f'
+					if ( token[0] != 'f' ) {
+						imgErrorString = "Bad cookie( \"3df\" ).";
+						return FXFALSE;
+					}
+					state++;
+					break;
+				case  1:   // Version
+					if ( sscanf( token, 
+							     "v%f", 
+							     &tempFloat ) == 0 ) {	
+						imgErrorString = "Couldn't determine version of 3DF file.";
+						return FXFALSE;
+					}
+					info->version = tempFloat;
+					state++;
+					break;
+				case  2:  // Color Format
+					if ( (info->colorFormat = _imgTxDecodeColorFormat( token ))==txColorUnknown ) {
+						imgErrorString = "3DF Unknown color format.";
+						return FXFALSE;
+					} 
+					state++;
+					break;
+				case  3:  // "lod"
+					if ( strcmp( token, "lod" ) ) {
+						imgErrorString = "Bad lod range identifier.";
+						return FXFALSE;
+					}
+					state++;
+					break;
+				case  4:  // "range:"
+					if ( strcmp( token, "range:" ) ) {
+						imgErrorString = "Bad lod range identifier.";
+						return FXFALSE;
+					}
+					state++;
+					break;
+				case  5:  // lodMin
+					info->lodMin = atoi( token );
+					state++;
+					break;
+				case  6:  // lodMax
+					info->lodMax = atoi( token );
+					state++;
+					break;
+				case  7:  // "aspect"
+					if ( strcmp( token , "aspect" ) ) {	
+						imgErrorString = "Bad aspect ratio identifier.";
+						return FXFALSE;
+					}
+					state++;
+					break;
+				case  8:  // "ratio:"
+					if ( strcmp( token, "ratio:" ) ) {	
+						imgErrorString = "Bad aspect ratio identifier.";
+						return FXFALSE;
+					}
+					state++;
+					break;
+				case  9:  // aspectWidth
+					info->aspectWidth = atoi( token );
+					state++;
+					break;
+				case 10:  // aspectHeight
+					info->aspectHeight = atoi( token );
+					done = FXTRUE;
+					break;
+				default:
+					imgErrorString = "General parse error reading header.";
+					return FXFALSE;
+					break;
+	    	}
+    }
+    
+    if ( state != 10 ) {
+		imgErrorString = "Read error before end of header.";
+		return FXFALSE;
+    }
+
+	if ( info->lodMin > info->lodMax ) {
+		imgErrorString = "3DF Format Error.  lodMin must be <= lodMax.";
+		return FXFALSE;
+	}
+
+	// Calculate Width and Height with All Mipmaps
+	if ( info->aspectWidth < info->aspectHeight ) {
+		FxU32 lod;
+		info->height = info->lodMax;
+		info->width = info->lodMax / info->aspectHeight;
+		for ( lod = info->lodMax / 2; lod >= info->lodMin; lod /= 2 ) {
+			info->width += lod > 1 ? lod / info->aspectHeight : 1;
+		}
+	} else {
+		FxU32 lod;
+		info->width = info->lodMax;
+		info->height = info->lodMax / info->aspectWidth;
+		for ( lod = info->lodMax / 2; lod >= info->lodMin; lod /= 2 ) {
+			info->height += lod > 1 ? lod / info->aspectWidth : 1;
+		}
+	}
+
+	info->sizeInBytes = info->width * info->height * 4;
+
+    return FXTRUE;
+}
+
+
+/* _imgRead3DFData
+**
+** Summary: UNPUBLISHED - read data from a 3DF file.
+**          when the texuslib has an owner, and it
+**          is reliably maintained, this will be
+**          converted over to calls to the library.
+*/
+/* Read in data from a 3DF file. */
+FxBool _imgRead3DFData( FILE *stream, const TdfInfo *info, ImgData *data )
+{
+	FxBool doVerticalDisplay;
+	ImgData *destPtr, *destOrigin;
+	FxU32 xBound, yBound;
+	FxU32 lod;
+
+	struct { 
+		FxU8  yRGB[16];
+		FxI16 iRGB[4][3];
+		FxI16 qRGB[4][3];
+	} imgYIQTable;
+
+	if ( stream == NULL ) {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+	}  
+
+  	/* Read in the YIQ decompression table, if necessary. */
+  	if( (info->colorFormat == txColorYIQ) || (info->colorFormat == txColorAYIQ_8422) ) {
+		FxU32 index;
+		for( index=0; index < 16; index++ ) {
+            getc( stream );
+			imgYIQTable.yRGB[index] = (FxU8) getc( stream );
+		}
+		for( index=0; index < 4;index++ ) {	
+			FxI16 msb = (FxI16) ( getc( stream ) & 0xFF ) << 8;
+			FxI16 lsb = (FxI16) ( getc( stream ) & 0xFF );
+			imgYIQTable.iRGB[index][0] = msb | lsb;
+			msb = (FxI16) ( getc( stream ) & 0xFF ) << 8;
+			lsb = (FxI16) ( getc( stream ) & 0xFF );
+			imgYIQTable.iRGB[index][1] = msb | lsb;
+			msb = (FxI16) ( getc( stream ) & 0xFF ) << 8;
+			lsb = (FxI16) ( getc( stream ) & 0xFF );
+			imgYIQTable.iRGB[index][2] = msb | lsb;
+		}
+		for( index=0; index < 4;index++ ) {	
+			FxI16 msb = (FxI16) ( getc( stream ) & 0xFF ) << 8;
+			FxI16 lsb = (FxI16) ( getc( stream ) & 0xFF );
+			imgYIQTable.qRGB[index][0] = msb | lsb;
+			msb = (FxI16) ( getc( stream ) & 0xFF ) << 8;
+			lsb = (FxI16) ( getc( stream ) & 0xFF );
+			imgYIQTable.qRGB[index][1] = msb | lsb;
+			msb = (FxI16) ( getc( stream ) & 0xFF ) << 8;
+			lsb = (FxI16) ( getc( stream ) & 0xFF );
+			imgYIQTable.qRGB[index][2] = msb | lsb;
+		}
+		if ( feof( stream ) ) {
+			imgErrorString = "Unexpected end of file reading YIQ Table.";
+			return FXFALSE;
+		}
+	}
+
+	/* Read in the Image One mipmap level at a time */
+
+	doVerticalDisplay = (info->aspectHeight <= info->aspectWidth ) ? FXTRUE : FXFALSE;
+
+	destPtr = destOrigin = data;
+	if ( doVerticalDisplay ) {
+		yBound = info->lodMax / info->aspectWidth;
+		xBound = info->lodMax;	
+	} else { 
+		yBound = info->lodMax;
+		xBound = info->lodMax / info->aspectHeight;
+	}
+
+	for ( lod = info->lodMax; lod >= info->lodMin; lod /= 2 )	{
+		FxU32 x, y;
+		switch( info->colorFormat )	{
+			case txColorTrue:        /* True color, 24-bit color (RGB) + 8-bit alpha.               */
+			case txColorARGB_8888:   /* 8-bits of Alpha, Red, Green, and Blue.  Not yet supported.  */
+				for ( y = 0; y < yBound; y++ ) {
+					for( x = 0; x < xBound; x++ ) {
+						FxU8 r, g, b, a;
+						a = getc( stream );
+						r = getc( stream );
+						g = getc( stream );
+						b = getc( stream );
+						*destPtr++ = b;
+						*destPtr++ = g;
+						*destPtr++ = r;
+						*destPtr++ = a;
+					}
+					destPtr += (info->width - xBound) * 4;
+				}
+				break;
+			case txColorI_8:         /* 8-bit intensity.                                            */
+	        		                 /* For this, an intensity is calculated by averaging the       */
+	                		         /* RG and B channels, and placed back into all three channels  */
+			                         /* so that outputs of TGA's and PPM's will look okay.          */
+				for ( y = 0; y < yBound; y++ ) {
+					for ( x = 0; x < xBound; x++ ) {
+						FxU8 intensity;
+						intensity = getc( stream );
+						*destPtr++ = intensity;
+						*destPtr++ = intensity;
+						*destPtr++ = intensity;
+						*destPtr++ = intensity;
+					}
+					destPtr += (info->width - xBound) * 4;
+				}
+				break;
+			case txColorA_8: /* 8-bit alpha. */
+				for ( y = 0; y < yBound; y++ ) {
+					for ( x = 0; x < xBound; x++ ) {
+						FxU8 alpha;
+						alpha = getc( stream );
+						*destPtr++ = alpha;
+						*destPtr++ = alpha;
+						*destPtr++ = alpha;
+						*destPtr++ = alpha;
+					}
+					destPtr += (info->width - xBound) * 4;
+				}
+				break;
+			case txColorARGB_1555:
+				for ( y = 0; y < yBound; y++ ) {
+					for ( x = 0; x < xBound; x++ ) {
+						FxU16 color;
+						FxU8  a,r,g,b;
+						color = ( 0xFF & getc( stream ) ) << 8;
+						color |= ( 0xFF & getc( stream ) );
+						a = ( color >> 15 ) & 0x01;
+						r = ( color >> 10 ) & 0x1F;
+						g = ( color >> 5  ) & 0x1F;
+						b =   color         & 0x1F;
+
+						*destPtr++ = _imgMSBReplicate( b, 3, 2);
+						*destPtr++ = _imgMSBReplicate( g, 3, 2);
+  						*destPtr++ = _imgMSBReplicate( r, 3, 2);
+						*destPtr++ = a ? 0x0 : 0xFF;
+					}
+					destPtr += (info->width - xBound) * 4;
+				}
+				break;
+			case txColorARGB_4444:
+				for ( y = 0; y < yBound; y++ ) {
+					for ( x = 0; x < xBound; x++ ) {
+						FxU16 color;
+						FxU8  a,r,g,b;
+						color = ( 0xFF & getc( stream ) ) << 8;
+						color |= ( 0xFF & getc( stream ) );
+						a = ( color >> 12 ) & 0x0F;
+						r = ( color >> 8  ) & 0x0F;
+						g = ( color >> 4  ) & 0x0F;
+						b = ( color >> 0  ) & 0x0F;
+
+						*destPtr++ = _imgMSBReplicate( b, 4, 0 );
+						*destPtr++ = _imgMSBReplicate( g, 4, 0 );
+  						*destPtr++ = _imgMSBReplicate( r, 4, 0 );
+						*destPtr++ = _imgMSBReplicate( a, 4, 0 );
+					}
+					destPtr += (info->width - xBound) * 4;
+				}
+				break;
+			case txColorRGB_565:
+				for ( y = 0; y < yBound; y++ ) {
+					for ( x = 0; x < xBound; x++ ) {
+						FxU16 color;
+						FxU8  r,g,b;
+						color = ( 0xFF & getc( stream ) ) << 8;
+						color |= ( 0xFF & getc( stream ) );
+						r = ( color >> 11 ) & 0x1F;
+						g = ( color >> 5 ) &  0x3F;
+						b = ( color >> 0 ) &  0x1F;
+
+						*destPtr++ = _imgMSBReplicate( b, 3, 2 );
+						*destPtr++ = _imgMSBReplicate( g, 2, 4);
+  						*destPtr++ = _imgMSBReplicate( r, 3, 2);
+						*destPtr++ = 0x0; // Alpha
+					}
+					destPtr += (info->width - xBound) * 4;
+				}
+				break;
+			case txColorAI_44:
+			default:
+				imgErrorString = "Unhandled 3df color format.";
+				return FXFALSE;	
+		}
+		if ( doVerticalDisplay ) { 
+			destPtr = destOrigin + ( yBound * info->width * 4 );
+		} else {
+			destPtr = destOrigin + (xBound * 4);
+		}
+		destOrigin = destPtr;
+		if ( yBound > 1 ) yBound /= 2;
+		if ( xBound > 1 ) xBound /= 2;
+	}
+	
+#if 0
+	case txColorAI_44:       /* 4-bit alpha, 4-bit intensity.                               */
+	                         /* For this conversion, the alpha is shredded to four bits,    */
+                                 /* the intensities are averaged and then shredded into four    */
+                                 /* bits, and then the intensity is placed into all three       */
+                                 /* color channels.                                             */
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Read in both alpha and intensity. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor = tmpChar;
+	      
+	      /* Extract the alpha portion. */
+	      Image->AlphaChannel[index] = (tmpColor & 0xf0);
+
+	      /* Extract the color portion. */
+	      Image->RedChannel[index] = 
+	      Image->GreenChannel[index] = 
+	      Image->BlueChannel[index] = ((tmpColor & 0x0f)<<4);
+	    }
+	  
+	  break;
+
+	case txColorYIQ:         /* Narrow-channel, compressed color.                           */
+	  /* Get a copy of the YIQ table so that it doesn't have to be dereferenced
+	     every single time it's used. */
+	  YIQTable = Image->YIQTable;
+	  
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Get the YIQ pixel into a temporary value. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor = (tmpChar & 0xff);
+	      
+	      /* Rip out YIQ from that pixel. */
+	      y = tmpColor >> 4;
+	      i = (tmpColor >> 2) & 0x3;
+	      q = (tmpColor >> 0) & 0x3;
+
+	      /* Convert the colors back out. */
+	      r = YIQTable.yRGB[y] + YIQTable.iRGB[i][0] + YIQTable.qRGB[q][0];
+	      g = YIQTable.yRGB[y] + YIQTable.iRGB[i][1] + YIQTable.qRGB[q][1];
+	      b = YIQTable.yRGB[y] + YIQTable.iRGB[i][2] + YIQTable.qRGB[q][2];
+
+	      /* Clamp the values. */
+	      if( r < 0 ) r = 0; else if ( r > 0xff ) r = 0xff;
+	      if( g < 0 ) g = 0; else if ( g > 0xff ) g = 0xff;
+	      if( b < 0 ) b = 0; else if ( b > 0xff ) b = 0xff;
+
+	      /* Stick the values into the image structure. */
+	      Image->RedChannel[index] = (unsigned char)r;
+	      Image->GreenChannel[index] = (unsigned char)g;
+	      Image->BlueChannel[index] = (unsigned char)b;
+	      
+	      /* Make up something for alpha. */
+	      Image->AlphaChannel[index] = 0xff;
+	    }
+
+	  break;
+
+	case txColorRGB_332:     /* 3-bit red, 3-bit green, 2-bit blue.                         */
+                                 /* Shred bits off of the color channels, and tip the alpha     */
+                                 /* channel up to 0xff.                                         */
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Combine the whole color into one byte. */
+	      fread(&tmpChar,1,1,ImageFile);
+
+	      /* Rip the byte apart into colors. */
+	      Image->RedChannel[index] = (tmpChar & 0xe0);
+	      Image->GreenChannel[index] = (tmpChar & 0x1c)<<3;
+	      Image->BlueChannel[index] = (tmpChar & 0x03)<<6;
+
+	      /* Make up something for alpha. */
+	      Image->AlphaChannel[index] = 0xff;
+	    }
+	  
+	  break;
+	case txColorRGB_565:     /* 5-bit red, 6-bit green, 5-bit blue.                         */
+                                 /* Shred bits off of the color channels, and tip the alpha     */
+                                 /* channel up to 0xff.                                         */
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Read both bytes into a tmp color. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor = (tmpChar & 0xff)<<8;
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor |= (tmpChar & 0xff);
+	  
+	      /* Rip the short apart into colors. */
+	      Image->RedChannel[index] = (tmpColor & 0xf800)>>8;
+	      Image->GreenChannel[index] = (tmpColor & 0x07e0)>>3;
+	      Image->BlueChannel[index] = (tmpColor & 0x001f)<<3;
+	      
+	      /* Make up something for alpha. */
+	      Image->AlphaChannel[index] = 0xff;
+	    }
+	  
+	  break;
+	case txColorARGB_8332:   /* 8-bit alpha, 3-bit red, 3-bit green, 2-bit blue.            */
+                                 /* Nothing but shredding.                                      */
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Read both bytes into a tmp color. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor = (tmpChar & 0xff)<<8;
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor |= (tmpChar & 0xff);
+	      
+	      /* Read out the alpha. */
+	      Image->AlphaChannel[index] = ((tmpColor & 0xff00)>>8);
+
+	      /* Rip the byte apart into colors. */
+	      Image->RedChannel[index] = (tmpColor & 0xe0);
+	      Image->GreenChannel[index] = (tmpColor & 0x1c)<<3;
+	      Image->BlueChannel[index] = (tmpColor & 0x03)<<6;
+	    }
+	  
+	  break;
+	case txColorARGB_1555:   /* 1-bit alpha, 5-bit red, 5-bit green, 5-bit blue.            */
+	                         /* Nothing but shredding.                                      */
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Read both bytes into a tmp color. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor = (tmpChar & 0xff)<<8;
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor |= (tmpChar & 0xff);
+
+	      /* Rip the color apart. */
+	      Image->AlphaChannel[index] = (tmpColor & 0x8000)>>8;
+	      Image->RedChannel[index] = (tmpColor & 0x7c00)>>7;
+	      Image->GreenChannel[index] = (tmpColor & 0x03e0)>>2;
+	      Image->BlueChannel[index] = (tmpColor & 0x001f)<<3;
+	    }
+	  
+	  break;
+
+	case txColorAYIQ_8422:   /* 8-bit alpha + narrow-channel compressed color.              */
+	  /* Get a copy of the YIQ table so that it doesn't have to be dereferenced
+	     every single time it's used. */
+	  YIQTable = Image->YIQTable;
+	  
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Get alpha from the first byte. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      (Image->AlphaChannel[index]) = (unsigned char)tmpChar;
+	      
+	      /* Get the YIQ pixel into a temporary value. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor = (tmpChar & 0xff);
+
+	      /* Rip out YIQ from that pixel. */
+	      y = tmpColor >> 4;
+	      i = (tmpColor >> 2) & 0x3;
+	      q = (tmpColor >> 0) & 0x3;
+
+	      /* Convert the colors back out. */
+	      r = YIQTable.yRGB[y] + YIQTable.iRGB[i][0] + YIQTable.qRGB[q][0];
+	      g = YIQTable.yRGB[y] + YIQTable.iRGB[i][1] + YIQTable.qRGB[q][1];
+	      b = YIQTable.yRGB[y] + YIQTable.iRGB[i][2] + YIQTable.qRGB[q][2];
+
+	      /* Clamp the values. */
+	      if( r < 0 ) r = 0; else if ( r > 0xff ) r = 0xff;
+	      if( g < 0 ) g = 0; else if ( g > 0xff ) g = 0xff;
+	      if( b < 0 ) b = 0; else if ( b > 0xff ) b = 0xff;
+
+	      /* Stick the values into the image structure. */
+	      Image->RedChannel[index] = (unsigned char)r;
+	      Image->GreenChannel[index] = (unsigned char)g;
+	      Image->BlueChannel[index] = (unsigned char)b;
+	      
+	      /* Make up something for alpha. */
+	      Image->AlphaChannel[index] = 0xff;
+	    }
+
+	  break;
+	case txColorARGB_4444:   /* 4-bit alpha, 4-bit red, 4-bit green, 4-bit blue.            */
+	                         /* Nothing but shredding.                                      */
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Read both bytes into a tmp color. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor = (tmpChar & 0xff)<<8;
+	      fread(&tmpChar,1,1,ImageFile);
+	      tmpColor |= (tmpChar & 0xff);
+
+	      /* Rip that color apart. */
+	      Image->AlphaChannel[index] = (tmpColor & 0xf000)>>8;
+	      Image->RedChannel[index] = (tmpColor & 0x0f00)>>4;
+	      Image->GreenChannel[index] = (tmpColor & 0x00f0);
+	      Image->BlueChannel[index] = (tmpColor & 0x000f)<<4;
+	    }
+	  
+	  break;
+	case txColorAI_88:       /* 8-bit alpha, 8-bit itensity.                                */
+	                         /* Same as txColorAI_44, minus the shredding.                  */
+	  /* Loop through the entire image. */
+	  for(index=0;index<((Image->Width)*(Image->Height));index++)
+	    {
+	      /* Grab alpha from the first byte. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      (Image->AlphaChannel[index]) = (tmpChar & 0xff);
+	      
+	      /* And grab the intensity from the second byte. */
+	      fread(&tmpChar,1,1,ImageFile);
+	      Image->RedChannel[index] =
+	      Image->GreenChannel[index] =
+	      Image->BlueChannel[index] = (tmpChar & 0xff);
+	    }
+	  
+	  break;
+	}
+    }
+  
+  /* Close the file. */
+  fclose(ImageFile);
+#endif
+
+  return FXTRUE;
+}
+
+
+
+/* _imgReadTGAData
+**
+** Summary: UNPUBLISHED - read data from a TGA file
+** TGA is BGRA
+*/
+FxBool _imgReadTGAData( FILE *stream, const TgaInfo *info, ImgData *data )
+{
+	FxI32 y, y0, y1, dy, scanlineLength;
+	const int bytesPerPixel = 4;
+
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+
+	if ( info->height == 0 ) return FXTRUE;
+
+	if ( info->yOrigin == 0 )
+	{
+		dy = -1;
+		y0 = info->height - 1;
+		y1 = -1;
+	}
+	else
+	{
+		dy = 1;
+		y0 = 0;
+		y1 = info->height;
+	}
+
+	scanlineLength = info->width * bytesPerPixel;
+
+	for ( y = y0; y != y1; y += dy )
+	{
+		if ( fread( data + scanlineLength * y, 1, scanlineLength, stream ) !=
+			 (FxU32) scanlineLength )
+		{
+			imgErrorString = "Unexpected end of file";
+			return FXFALSE;
+		}
+	}
+    
+    return FXTRUE;
+}
+
+
+
+/* _imgWriteTGAData
+**
+** Summary: UNPUBLISHED - write data out to a tga
+** TGA is BGRA
+*/
+FxBool _imgWriteTGAData( FILE *stream, const TgaInfo *info, const ImgData *data )
+{
+	FxI32 y, scanlineLength;
+	const int bytesPerPixel = 4;
+
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+
+	scanlineLength = info->width * bytesPerPixel;
+
+	for ( y = info->height - 1; y >= 0; y-- )
+	{
+		if ( fwrite( data + scanlineLength * y, 1, scanlineLength, stream ) !=
+			 (FxU32) scanlineLength )
+		{
+			imgErrorString = "TGA stream write error.";
+			return FXFALSE;
+		}
+	}
+    
+    return FXTRUE;
+}
+
+/* _imgReadRGTData
+**
+** Summary: UNPUBLISHED - read data from an RGT file ( rgt's are bottom up )
+** RGT is RGBA in memory (low byte to high byte), or ABGR in a register
+*/
+FxBool _imgReadRGTData( FILE *stream, const RgtInfo *info, ImgData *data )
+{
+	FxU32 scanlineSize = info->width * 4;
+	FxU32 x,y;
+    
+    if ( stream == NULL ) {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+
+	if ( info->ncc != 0 ) {	
+		imgErrorString = "Compressed RGT's not yet supported.";
+		return FXFALSE;
+	}
+
+	// load rgt, rgt's are bottom up
+	for ( y = 0; y < info->height; y++ ) {
+		ImgData *scanlineBuffer = data + scanlineSize * ( (info->height-1) - y );
+		if ( fread( scanlineBuffer, 1, scanlineSize, stream ) != scanlineSize )	{
+			imgErrorString = "Unexpected end of file.";
+			return FXFALSE;
+		}
+	}
+
+	if ( info->rgb ) {
+		fprintf(stderr," (RGB->BGR)"); fflush(stderr);
+		for ( y = 0; y < info->height; y++ ) {
+			for ( x = 0; x < info->width; x++ ) {
+				ImgData swap;
+				swap = data[2];
+				data[2] = data[0];
+				data[0] = swap;
+				data += 4;
+			}
+		}
+
+	}
+
+    return FXTRUE;
+}
+
+/* _imgReadSbiData
+**
+** Summary: UNPUBLISHED - read data from an SBI file
+*/
+FxBool _imgReadSbiData( FILE *stream, const SbiInfo *info, ImgData *data )
+{
+    FxI32 y, y0, y1, dy;
+    FxU32 x;
+    FxU32 rShift, gShift, bShift, rMask, gMask, bMask;
+	FxU32 rRightShift, rLeftShift;
+	FxU32 gRightShift, gLeftShift;
+	FxU32 bRightShift, bLeftShift;
+	FxU32 scanlineWidth;
+	ImgData *baseOfData;
+    
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+    
+    bShift = 0;
+    gShift = info->blueBits;
+    rShift = gShift + info->greenBits;
+
+    rMask = (FxU32) ~0;
+    rMask >>= sizeof( FxU32 ) * 8 - info->redBits;
+	rLeftShift = 8 - info->redBits;
+	rRightShift = info->redBits - rLeftShift;
+    
+    gMask = (FxU32) ~0;
+    gMask >>= sizeof( FxU32 ) * 8 - info->greenBits;
+	gLeftShift = 8 - info->greenBits;
+	gRightShift = info->greenBits - gLeftShift;
+    
+    bMask = (FxU32) ~0;
+    bMask >>= sizeof( FxU32 ) * 8 - info->blueBits;
+	bLeftShift = 8 - info->blueBits;
+	bRightShift = info->blueBits - bLeftShift;
+
+	scanlineWidth = info->width * 4;
+	baseOfData = data;
+
+    if ( info->yOrigin == 0 )
+    {
+		y0 = info->height - 1;
+		y1 = -1;
+		dy = -1;
+    }
+    else
+    {
+		y0 = 0;
+		y1 = info->height;
+		dy = 1;
+    }
+    
+    for( y = y0; y != y1; y += dy )
+    {
+		//point data at apropriate scanline
+		data = baseOfData + y * scanlineWidth;
+
+		for ( x = 0; x < info->width; x++ )
+		{
+	    	int r, g, b;
+	    	int inchar;
+	    	FxU32 color;
+	    
+	    	color = getc( stream );
+	    	if ( (inchar = getc( stream ))==EOF )
+	    	{
+				imgErrorString = "Unexpected end of file.";
+				return FXFALSE;
+	    	}
+	    	color |= (inchar << 8);
+	    
+	    	// Get sig bits
+	    	r = (color >> rShift ) & rMask;
+	    	g = (color >> gShift ) & gMask;
+	    	b = (color >> bShift ) & bMask;
+	    
+	    	// Expand to 8 bits/color
+			// Current implementation is only meaningful if 
+			// using more than 4Bits/Channel color precision.....
+			// Needs to be fixed, but this is much, much faster....
+	    	*data++ = _imgMSBReplicate( b, bLeftShift, bRightShift );
+	    	*data++ = _imgMSBReplicate( g, gLeftShift, gRightShift );
+	    	*data++ = _imgMSBReplicate( r, rLeftShift, rRightShift );
+	    	data++; // Blank A
+		}
+    }
+    return FXTRUE;
+}
+
+/* _imgReadP6Data
+**
+** Summary: UNPUBLISHED - read data from a PPM
+** PPM is RGB
+** Memory format is B - G - R - A
+*/
+FxBool _imgReadP6Data( FILE *stream, const P6Info *info, ImgData *data )
+{
+    FxU32 numPixels;
+    
+    numPixels = info->width * info->height;
+
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+    
+	// Read in image data
+    for( ;numPixels;numPixels-- )
+    {
+		int r, g, b;
+		r = getc( stream );
+		g = getc( stream );
+		b = getc( stream );
+		if ( b == EOF )
+		{
+	    	imgErrorString = "Unexpected end of file.";
+	    	return FXFALSE;
+		}
+		*data++ = (ImgData)b;
+		*data++ = (ImgData)g;
+		*data++ = (ImgData)r;
+		data++; // A
+    }
+
+    return FXTRUE;
+}
+
+/* _imgReadSRLEHeader
+**
+** Summary: UNPUBLISHED - read header and fill in header info
+** The simple rle format is intended for glide test programs image comparison
+** The file format is as follows:
+** 4 bytes file signature
+** 2 bytes image width
+** 2 bytes image height
+** 1 byte  image depth
+** 1 byte  compression method (1 for rle compression)
+** image data
+**
+** The image data started with a control byte and followed by pixel data
+** Each control byte has two parts. Bit 7 (msb) equals to 1 indicates a run,
+** 0 indicates a literal string. Bit 6 - 0 id the counter. It is zero based.
+*/
+FxBool _imgReadSRLEHeader( FILE *stream,  SrleInfo *info )
+{
+    FxU16 tmp16;
+    FxU8  tmp8;
+    
+    if ( stream == NULL )
+    {
+      imgErrorString = "Bad file handle.";
+      return FXFALSE;
+    }
+    
+    fread(&tmp16, sizeof(FxU16), 1, stream);
+    info->width = tmp16;
+    fread(&tmp16, sizeof(FxU16), 1, stream);
+    info->height = tmp16;
+    fread(&tmp8, sizeof(FxU8), 1, stream);
+    info->pixelsize = tmp8 / 8;
+    fread(&tmp8 , sizeof(FxU8), 1, stream);
+    info->c_type = tmp8;
+    
+    info->sizeInBytes = info->width * info->height * 4;
+    
+    return FXTRUE;
+}
+
+/* _imgReadSRLE
+**
+** Summary: UNPUBLISHED - read data from a simple rle format
+*/
+FxBool _imgReadSRLEData( FILE *stream, const SrleInfo *info, ImgData *data )
+{
+    int   numPixels;
+    FxU16 color;
+    FxU8  r,g,b,a;
+    FxU8  ctl, repeat, run;
+    FxBool flag;
+    
+    numPixels = info->width * info->height;
+
+    if ( stream == NULL )
+    {
+      imgErrorString = "Bad file handle.";
+      return FXFALSE;
+    }
+
+    while (numPixels) {
+      ctl = getc( stream );
+      flag = ctl & 0x80;
+      run = repeat = (ctl & 0x7f) + 1;
+      numPixels -= repeat;
+      while (repeat) {
+	switch (info->pixelsize) 
+	  {
+	  case 2:
+	    if (((flag) && (repeat == run)) || (!flag))
+	      fread(&color,2,1,stream);
+	    r = ( color >> 11 ) & 0x1F;
+	    g = ( color >> 5 ) &  0x3F;
+	    b = ( color >> 0 ) &  0x1F;
+
+	    *data++ = _imgMSBReplicate( b, 3, 2 );
+	    *data++ = _imgMSBReplicate( g, 2, 4);
+	    *data++ = _imgMSBReplicate( r, 3, 2);
+	    *data++ = 0x0;
+	    break;
+	  case 4:
+	    if (((flag) && (repeat == run)) || (!flag)) {
+	      a = getc( stream );
+	      r = getc( stream );
+	      g = getc( stream );
+	      b = getc( stream );
+	    }
+	    *data++ = b;
+	    *data++ = g;
+	    *data++ = r;
+	    *data++ = a;
+	    break;
+	  }
+	repeat--;
+      }
+      if (numPixels < 0)
+	return FXFALSE;
+    }
+    return FXTRUE;
+}
+
+/* _imgWriteP6Header
+**
+** Summary: UNPUBLISHED - write out formatted header for a P6
+*/
+FxBool _imgWriteP6Header( FILE *stream, const P6Info *info )
+{
+	imgErrorString = "Image write error.";
+	if ( 0 > fprintf( stream, "P6\n" ) ) return FXFALSE;
+	if ( 0 > fprintf( stream, "# PPM Comment\n", info->width ) ) return FXFALSE;
+	if ( 0 > fprintf( stream, "%d ", info->width ) ) return FXFALSE;
+	if ( 0 > fprintf( stream, "%d\n", info->height ) ) return FXFALSE;
+	if ( 0 > fprintf( stream, "255\n" ) ) return FXFALSE;
+	imgErrorString = "No error.";
+	return FXTRUE;
+}
+
+/* _imgWriteSbiHeader
+**
+** Summary: UNPUBLISHED - write out formatted header for an SBI
+*/
+FxBool _imgWriteSbiHeader( FILE *stream, const SbiInfo *info )
+{
+	imgErrorString = "Image write error.";
+	if ( 0 > fprintf( stream, "P9\n" ) ) return FXFALSE;
+	if ( 0 > !fprintf( stream, "Y%c\n", info->yOrigin? '+' : '-' ) ) return FXFALSE;
+	if ( 0 > !fprintf( stream, "%d ", info->width ) ) return FXFALSE;
+	if ( 0 > !fprintf( stream, "%d\n", info->height ) ) return FXFALSE;
+	if ( 0 > !fprintf( stream, "R %d ", info->redBits ) ) return FXFALSE;
+	if ( 0 > !fprintf( stream, "G %d ", info->greenBits ) ) return FXFALSE;
+	if ( 0 > !fprintf( stream, "B %d\n", info->blueBits ) ) return FXFALSE;
+	imgErrorString = "No Error.";
+	return FXTRUE;
+}
+
+/* _imgWriteP6Data
+**
+** Summary: UNPUBLISHED - write P6 image data
+*/
+FxBool _imgWriteP6Data( FILE *stream, const P6Info *info, const ImgData *data )
+{
+	FxU32 dataSize = info->width * info->height * 4;
+	const ImgData *dataEnd  = data + dataSize;
+
+	while( data < dataEnd )
+	{
+		ImgData r, g, b;
+		b = *data++;
+		g = *data++;
+		r = *data++;
+		data++;
+
+		putc( r, stream );
+		putc( g, stream );
+		if ( putc( b, stream ) == EOF )
+		{
+			imgErrorString = "Image write error.";
+			return FXFALSE;
+		}
+	}
+	return FXTRUE;
+}
+
+/* _imgWriteSbiData
+**
+** Summary: UNPUBLISHED - write sbi image data
+*/
+FxBool _imgWriteSbiData( FILE *stream, const SbiInfo *info, const ImgData *data )
+{
+	// convert each pixel, then write it out as two byte-writes
+	FxU32 x;
+	FxU32 y;
+	FxU32 sbiPixel;
+
+	FxI32 scanlineIncrement;
+
+	if ( info->yOrigin == 0 ) // Lower
+	{
+		scanlineIncrement = (4 * (-(long)info->width)) + 1;
+		// point at beginning of last SL
+		data = data + (( info->height - 2 ) * info->width * 4);
+	}
+	else // upper
+	{
+		scanlineIncrement = 0;
+	}
+
+	imgErrorString = "Image write error.";
+	for( y = 0; y < info->height; y++ )
+	{
+		for( x = 0; x < info->width; x++ )
+		{
+			FxU32 r, g, b;
+			b =  *data++ & 0xF8;
+			g =  *data++ & 0xFC;
+			r =  *data++ & 0xF8;
+			data++;
+			sbiPixel = (r << 8) | (g << 3) | (b >> 3);
+			
+			if ( putc( sbiPixel, stream ) == EOF ) return FXFALSE;
+			if ( putc( sbiPixel >> 8, stream ) == EOF ) return FXFALSE;
+		}
+		data += scanlineIncrement;
+	}
+	imgErrorString = "No error.";
+	return FXTRUE;
+}
+
+
+/* _imgWriteSbiDataWide
+**
+** Summary: UNPUBLISHED - write sbi image data
+*/
+FxBool _imgWriteSbiDataWide( FILE *stream, const SbiInfo *info, const ImgData *data, FxU32 slWidth )
+{
+	// convert each pixel, then write it out as two byte-writes
+	FxU32 x;
+	FxU32 y;
+	FxU32 sbiPixel;
+
+	FxI32 scanlineIncrement;
+
+	if ( info->yOrigin == 0 ) // Lower
+	{
+		scanlineIncrement = (4 * slWidth) + 1;
+		// point at beginning of last SL
+		data = data + (( info->height - 2 ) * info->width * 4);
+	}														 
+	else // upper
+	{
+		scanlineIncrement = (slWidth * 4) - (4*info->width);
+	}
+
+	imgErrorString = "Image write error.";
+	for( y = 0; y < info->height; y++ )
+	{
+		for( x = 0; x < info->width; x++ )
+		{
+			FxU32 r, g, b;
+			b =  *data++ & 0xF8;
+			g =  *data++ & 0xFC;
+			r =  *data++ & 0xF8;
+			data++;
+
+			sbiPixel = (r << 8) | (g << 3) | (b >> 3);
+			
+			if ( putc( sbiPixel, stream ) == EOF ) return FXFALSE;
+			if ( putc( sbiPixel >> 8, stream ) == EOF ) return FXFALSE;
+		}
+		data += scanlineIncrement;
+	}
+	imgErrorString = "No error.";
+	return FXTRUE;
+}
+
+
+/*
+** PUBLIC INTERFACE
+*/
+
+/*
+** PUBLIC DATA
+*/
+
+const char *imgTypeString[] = 
+{ 
+	"UNKNOWN", 
+	"SBI", 
+	"Binary PPM", 
+	"3DF", 
+	"RGT", 
+	"TGA32" 
+};
+
+const char *imgTxColorFormatNames[] =
+{
+  "unknown",
+  "true",
+  "i8",
+  "a8",
+  "ai44",
+  "yiq",
+  "rgb332",
+  "rgb565",
+  "argb8332",
+  "argb1555",
+  "ayiq8422",
+  "argb4444",
+  "ai88",
+  "argb8888"
+};
+
+
+/* imgGetErrorString
+**
+** Summary: Get a pointer to the buffer that contains a string describing
+**          the most recent error in the  Image Library
+**
+** Returns: Point to an error description string.  Probably a bad idea to write
+**         to this address as it will likely be a static string.
+*/
+const char *imgGetErrorString( void )
+{
+    return imgErrorString;
+}
+
+/* imgReadInfo
+**
+** Summary: Fill the Info union and return the proper image type
+**
+** Parameters: info - pointer to an ImgInfo structure including type
+**             stream - pointer file stream
+**
+** Returns: FXTRUE if header read in correctly.
+**          FXFALSE if header not read, error described
+**                  in string obtainable by sbiGetErrorString();
+*/
+FxBool imgReadInfo( FILE *stream, ImgInfo *info )
+{
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+    
+	_fixStream( stream );
+	info->any.data = NULL;
+
+    // Determine the Type of File and Fill The Appropriate Header Structure
+    if ( _imgGuessType( stream, &info->any.type ) == FXFALSE ) return FXFALSE;
+
+    switch( info->any.type )
+    {
+    	case IMG_SBI:
+			return _imgReadSbiHeader( stream, &(info->sbiInfo) );
+      	case IMG_RGT:
+			return _imgReadRGTHeader( stream, &(info->rgtInfo) );
+      	case IMG_TGA32:
+			return _imgReadTGAHeader( stream, &(info->tgaInfo) );
+    	case IMG_P6:
+			return _imgReadP6Header( stream, &(info->p6Info) );
+      	case IMG_3DF:
+			return _imgRead3DFHeader( stream, &(info->tdfInfo) );
+      	case IMG_SRLE:
+			return _imgReadSRLEHeader( stream, &(info->srleInfo) );
+      	case IMG_UNKNOWN:
+      	default:
+			imgErrorString = "Unknown image file format.";
+			break;
+    }
+	return FXFALSE;
+}
+
+/* imgReadData
+**
+** Summary: Read all of the image data from an image stream given
+**          that the header has already been read by imgReadInfo.
+**
+** Parameters: stream - a readable file stream
+**             info - pointer to filled info structure (except data)
+**					- if data is NULL then we malloc data large enough
+** Returns: FXTRUE if data was read successfully
+**          FXFALSE if an error occured, reason may be
+**          obtained with imgGetErrorString().
+*/
+FxBool imgReadData( FILE *stream, ImgInfo *info )
+{
+    if ( stream == NULL )
+    {
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+    }
+    
+	_fixStream( stream );
+
+	// if data pointer is NULL then malloc something big enough
+    if ( info->any.data == NULL ) {
+		info->any.data = (ImgData*) malloc( info->any.sizeInBytes );
+	    if ( info->any.data == NULL ) {
+			imgErrorString = "Malloc failed.";
+			return FXFALSE;
+		}
+    }
+
+    switch( info->any.type )
+    {
+    	case IMG_TGA32:
+			return _imgReadTGAData( stream, &(info->tgaInfo), info->any.data );
+    	case IMG_RGT:
+			return _imgReadRGTData( stream, &(info->rgtInfo), info->any.data );
+    	case IMG_3DF:
+			return _imgRead3DFData( stream, &(info->tdfInfo), info->any.data );
+    	case IMG_SBI:
+			return _imgReadSbiData( stream, &(info->sbiInfo), info->any.data );
+    	case IMG_P6:
+			return _imgReadP6Data( stream, &(info->p6Info), info->any.data );
+    	case IMG_SRLE:
+			return _imgReadSRLEData( stream, &(info->srleInfo), info->any.data );
+    	case IMG_UNKNOWN:
+      default:
+		imgErrorString = "Unknown file type.";
+      break;
+    }
+	return FXFALSE;
+}
+
+/* imgWriteImage
+**
+** Summary: Write out an image file in the format specified by *type.
+**
+** Parameters: stream - a writeable file stream
+** 		       info - pointer to initialized image info struct appropriate
+**                       to type described in *type
+** 		       type - desired image type to write
+** 		       data - pointer to 32BPP xRGB data in linear memory storage
+**
+** Returns: FXTRUE if data was written sucessfully
+**          FXFALSE if an error occured, reason may be
+**          obtained with imgGetErrorString().
+*/
+
+
+FxBool imgWriteImage( FILE *stream, const ImgInfo *info, const ImgType type, const ImgData *data )
+{
+	// Try to catch obvious bugs.
+	if ( stream == NULL )
+	{
+		imgErrorString = "Bad file handle.";
+		return FXFALSE;
+	}
+
+	_fixStream( stream );
+
+	if ( data == NULL )
+	{
+		imgErrorString = "Bad data pointer.";
+		return FXFALSE;
+	}
+
+	switch( type )
+	{
+		case IMG_SBI:
+			if ( !_imgWriteSbiHeader( stream, &(info->sbiInfo) ) )
+			{
+				imgErrorString = "Couldn't write SBI info.";
+				return FXFALSE;
+			}
+			return _imgWriteSbiData( stream, &(info->sbiInfo), data );
+		case IMG_P6:
+			if ( !_imgWriteP6Header( stream, &(info->p6Info)) )
+			{
+				imgErrorString = "Couldn't write P6 info.";
+				return FXFALSE;
+			}
+			return _imgWriteP6Data( stream, &(info->p6Info), data );
+		case IMG_RGT:
+			imgErrorString = "RGT writes unimplemented.";
+			break;
+		case IMG_TGA32:
+			if ( !_imgWriteTGAHeader( stream, &(info->tgaInfo)) )
+			{
+				imgErrorString = "Couldn't write tga info.";
+				return FXFALSE;
+			}
+			return _imgWriteTGAData( stream, &(info->tgaInfo), data );
+			break;
+		case IMG_UNKNOWN:
+		default:
+			imgErrorString = "Can't write unknown format.";
+			break;
+	}
+	
+	return FXFALSE;
+}
+
+// returns a 3-letter abbreviation for the image type
+const char *imgTypeName( const ImgInfo *info )
+{
+	switch( info->any.type ) {
+	    case IMG_UNKNOWN:	return "???";
+	    case IMG_P6:		return "ppm";
+	    case IMG_SBI:		return "sbi";
+	    case IMG_3DF:		return "3df";
+	    case IMG_TGA32:		return "tga";
+	    case IMG_SRLE:		return "srle";
+	    case IMG_RGT:
+	       	if (info->rgtInfo.rle) return "rle";
+	    	if (info->rgtInfo.bgr) return "bgr";
+	    	if (info->rgtInfo.rgb) return "rgb";
+	    	if (info->rgtInfo.ncc) return "ncc";
+
+		default:			return "ERR";
+    }
+}
+
+//----------------------------------------------------------------------
+// high level routine: reads an image file thru a search path
+// exits upon failure, prints out trace messages
+//----------------------------------------------------------------------
+FxBool imgReadFile(const char *filename, ImgInfo *info)
+{
+	const char *prefix;
+	FILE *file;
+
+	file = fxFopenPath(filename,READ_ATTRIBS, getenv(IMAGE_PATH), &prefix);
+	if (file == NULL) {
+		fprintf(stderr,"Error: can't open input file %s\n",filename);
+		exit(2);
+	}
+	if ( imgReadInfo( file, info ) == FXFALSE ) {
+		fprintf(stderr,"Error: reading info for %s, %s\n",filename,imgGetErrorString());
+		exit(2);
+	}
+	fprintf(stderr,"Loading %s image file ", imgTypeName(info));
+	if (prefix) {					// if there's a path prefix
+	    char buf[1024], *p;
+	    strcpy(buf,prefix);			// copy and replace semicolon
+	    if (p = strchr(buf,';')) *p = '\0';
+	    fprintf(stderr,buf);
+	    fprintf(stderr,"/");
+	}
+	fprintf (stderr,"%s (%dx%d) ...", filename, info->any.width,info->any.height);
+	fflush(stderr);
+
+	if ( imgReadData( file, info ) == FXFALSE ) {
+		fprintf(stderr, "\nError: reading data for %s, %s\n",filename,imgGetErrorString());
+		exit(4);
+	}
+	fclose(file);
+	fprintf(stderr," done.\n");
+	fflush(stderr);
+	return FXTRUE;
+}
+
+//----------------------------------------------------------------------
+// high level routine: writes an image file
+// exits upon failure, prints out trace messages
+//----------------------------------------------------------------------
+FxBool imgWriteFile(const char *filename, const ImgInfo *info, const ImgType type, const ImgData *data)
+{
+    FxBool retval;
+    ImgInfo tempInfo = *info;		// make a local copy
+    FILE *file;
+
+    file = fopen(filename,WRITE_ATTRIBS);
+    if (file == NULL) {
+	fprintf(stderr,"Error: can't open output file %s\n",filename);
+	exit(2);
+    }
+    tempInfo.any.type = type;		// set the new type
+    fprintf(stderr,"Storing %s image file %s (%dx%d) ...",
+		imgTypeName(&tempInfo), filename, info->any.width,info->any.height);
+    fflush(stderr);
+
+    retval = imgWriteImage( file, info, type, data );
+    fclose(file);
+    fprintf(stderr,retval ? " done.\n" : " aborted.\n");
+    fflush(stderr);
+    return retval;
+}
Index: trunk/src/opengl/glide/swlibs/fxmisc/fximg.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fximg.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fximg.h	(revision 2887)
@@ -0,0 +1,172 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:52 $
+**
+*/
+
+#ifndef _FXIMG_H_
+#define _FXIMG_H_
+
+#ifdef __DOS__
+#define READ_ATTRIBS "rb"
+#define WRITE_ATTRIBS "wb"
+#elif defined( _WIN32 )
+#define READ_ATTRIBS "rb"
+#define WRITE_ATTRIBS "wb"
+#else
+#define READ_ATTRIBS "r"
+#define WRITE_ATTRIBS "w" 
+#endif
+
+#define IMAGE_PATH "PATH_IMAGE"
+
+typedef enum imgTxColorFormatEnum
+{
+  txColorUnknown,              /* Color format has not yet been specified.                    */
+  txColorTrue,                 /* True color, 24-bit color (RGB) + 8-bit alpha.               */
+  txColorI_8,                  /* 8-bit intensity.                                            */
+  txColorA_8,                  /* 8-bit alpha.                                                */
+  txColorAI_44,                /* 4-bit alpha, 4-bit intensity.                               */
+  txColorYIQ,                  /* Narrow-channel, compressed color.                           */
+  txColorRGB_332,              /* 3-bit red, 3-bit green, 2-bit blue.                         */
+  txColorRGB_565,              /* 5-bit red, 6-bit green, 5-bit blue.                         */
+  txColorARGB_8332,            /* 8-bit alpha, 3-bit red, 3-bit green, 2-bit blue.            */
+  txColorARGB_1555,            /* 1-bit alpha, 5-bit red, 5-bit green, 5-bit blue.            */
+  txColorAYIQ_8422,            /* 8-bit alpha + narrow-channel compressed color.              */
+  txColorARGB_4444,            /* 4-bit alpha, 4-bit red, 4-bit green, 4-bit blue.            */
+  txColorAI_88,                /* 8-bit alpha, 8-bit intensity.                               */
+  txColorARGB_8888             /* 8-bits of Alpha, Red, Green, and Blue.  Not yet supported.  */
+} imgTxColorFormat;     
+
+
+typedef enum { TOP, BOTTOM } YOriginT;
+typedef enum { IMG_UNKNOWN, IMG_SBI, IMG_P6, IMG_3DF, IMG_RGT, IMG_TGA32 , IMG_SRLE } ImgType;
+
+extern const char *imgTxColorFormatNames[];
+extern const char *imgTypeString[];
+
+// Internal Memory Format BGRA ( Least Sig Byte -> Most Sig Byte )
+// Memory image has it's origin in the upper left always.
+typedef unsigned char ImgData;
+
+typedef struct 
+{
+    ImgType  type;
+    FxU32    width;
+    FxU32    height;
+    FxU32    sizeInBytes;
+    ImgData  *data;
+    FxU32    yOrigin;     // 0 - Lower 1 - Upper
+    FxU32    redBits;
+    FxU32    greenBits;
+    FxU32    blueBits;
+} SbiInfo;
+
+typedef struct
+{
+    ImgType  type;
+    FxU32 width;
+    FxU32 height;
+    FxU32 sizeInBytes;
+    ImgData  *data;
+    FxU32 colorChannelMax;
+} P6Info;
+
+typedef struct
+{
+    ImgType  type;
+    FxU32 width;
+    FxU32 height;
+    FxU32 sizeInBytes;
+    ImgData  *data;
+	float version;
+	FxU32 colorFormat;
+	FxU32 lodMin;
+	FxU32 lodMax;
+	FxU32 aspectWidth;
+	FxU32 aspectHeight;
+} TdfInfo;
+
+typedef struct
+{
+    ImgType  type;
+    FxU32 width;
+    FxU32 height;
+    FxU32 sizeInBytes;
+    ImgData  *data;
+    FxU32 rle;
+    FxU32 bgr;
+    FxU32 rgb;
+    FxU32 ncc;
+} RgtInfo;
+
+typedef struct
+{
+    ImgType  type;
+    FxU32 width;
+    FxU32 height;
+    FxU32 sizeInBytes;
+    ImgData  *data;
+    FxU32 yOrigin;   // 0 - Lower Left, 1 - Upper Left
+} TgaInfo;
+
+typedef struct
+{
+    ImgType  type;
+    FxU32 width;
+    FxU32 height;
+    FxU32 sizeInBytes;
+    ImgData  *data;
+    FxU32 pixelsize;
+    FxU32 c_type;
+} SrleInfo;
+
+typedef struct
+{
+    ImgType  type;
+    FxU32 width;
+    FxU32 height;
+    FxU32 sizeInBytes;
+    ImgData  *data;
+} AnyInfo;
+
+// This is the only structure intended to be referenced
+// by a user.
+typedef union
+{
+    AnyInfo any;
+    SbiInfo sbiInfo;
+    P6Info  p6Info;
+    TdfInfo tdfInfo;
+    RgtInfo rgtInfo;
+    TgaInfo tgaInfo;
+    SrleInfo srleInfo;
+} ImgInfo;
+
+const char *imgGetErrorString( void );
+const char *imgTypeName( const ImgInfo *info );
+FxBool imgReadInfo( FILE *stream, ImgInfo *info );
+FxBool imgReadData( FILE *stream, ImgInfo *info );
+FxBool imgReadFile(const char *filename, ImgInfo *info);
+FxBool imgWriteImage( FILE *stream, const ImgInfo *info, const ImgType type, const ImgData *data);
+FxBool imgWriteFile( const char *filename, const ImgInfo *info, const ImgType type, const ImgData *data);
+
+#endif
Index: trunk/src/opengl/glide/swlibs/fxmisc/fxmemmap.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fxmemmap.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fxmemmap.h	(revision 2887)
@@ -0,0 +1,66 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:52 $
+*/
+#ifndef _FX_MEMMAP_H_
+#define _FX_MEMMAP_H_
+
+/*
+ * DeviceIoControl service table control codes for communication with
+ * fxmemmap vxd. The codes here must match those in fxmemmap.asm.
+ * ESPECIALLY fxmajor_ver and fx_minor_ver!!!
+ */
+
+#define   FX_MAJOR_VER          1
+#define   FX_MINOR_VER          4
+
+#define   DIOC_CLOSEHANDLE     -1     
+#define   DIOC_GETVERSIONDWORD  0   
+#define   GETAPPVERSIONDWORD    1   
+#define   GETLINEARADDR         2   
+#define   GETLDTSELECTOR        3
+#define   FREELDTSELECTOR       4
+#define   GETLINEARADDR_AUTO    5 /* Watches for & handles PASSTHRU,
+                                     Otherwise identical to 2 */
+#define   GETMSR                6 /* Get the contents of an MSR */
+#define   SETMSR                7
+#define   DECREMENTMUTEX        8
+#define   SETPASSTHROUGHBASE    9
+#define   SETADDRPERM           10
+
+/* FxMemmap Int 2F API Codes */
+#define   PROCMAPPHYS              1UL
+#define   PROCGETMSR               2UL
+#define   PROCSETMSR               3UL
+#define   PROCGETVERSION           4UL
+#define   PROCUNMAPPHYS            5UL
+#define   PROCMAPPHYS16            6UL
+#define   PROCGETMSR16             7UL
+#define   PROCSETMSR16             8UL   
+#define   PROCGETVERSION16         9UL
+#define   PROCUNMAPPHYS16          10UL  /* NOT YET IMPLEMENTED */
+#define   PROCINCREMENTMUTEX16     11UL
+#define   PROCDECREMENTMUTEX16     12UL
+#define   PROCSETPASSTHROUGHBASE16 13UL
+#define   PROCOUTPUTDEBUGSTRING16  14UL
+#define   PROCSETADDRPERM16        15UL
+
+#endif /* _FX_MEMMAP_H_ */
Index: trunk/src/opengl/glide/swlibs/fxmisc/fxos.c
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fxos.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fxos.c	(revision 2887)
@@ -0,0 +1,127 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Revision: 1.1 $
+** $Date: 2000-02-25 00:33:53 $
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef WIN32
+#include <windows.h>
+#include <fxos.h>
+
+void sleep(int secs)
+{
+    GdiFlush();
+    Sleep(secs * 1000);
+}
+
+int fxGethostname(char *name, int n)
+{
+    return (int)GetComputerName((LPTSTR)name,(LPDWORD)&n);
+}
+#else
+#include <fxos.h>
+#endif
+
+/* return current time in seconds (floating point)      */
+float fxTime(void)
+{
+#if defined ( __sparc__ ) || defined ( __DJGPP__ )
+/* times returns 0 in BSD Unix, so we use ftime instead */
+#   include <sys/types.h>
+#   include <sys/timeb.h>
+    struct timeb tb;
+    static time_t once;                 // saves first time value
+
+    ftime(&tb);
+    if (once == 0)                      // stash away first call
+        once = tb.time;                 // as float is not big enough
+    return (tb.time - once) + tb.millitm * .001;
+    
+#else
+#if defined ( WIN32 ) || ( __DOS__ )
+#   include <time.h>
+#   define times(a) clock()
+#   define HZ   CLOCKS_PER_SEC
+#else
+#   include <sys/types.h>
+#   include <sys/times.h>
+#   include <sys/param.h>
+    struct tms foo;
+#endif
+    return times(&foo)/(float)HZ;
+#endif
+}
+
+/* returns elapsed time in seconds */
+float timer(int flag)
+{
+    static float starttime,endtime;
+
+    if (flag == 0)
+        starttime = endtime = fxTime();
+    else
+        endtime = fxTime();
+    return endtime - starttime;
+}
+
+
+//----------------------------------------------------------------------
+// open a file thru a search path, first search in the current directory
+// and then go thru the semicolon separated search path
+// returns the file handle and the path prefix that was used (if one)
+//----------------------------------------------------------------------
+FILE *fxFopenPath(const char *filename, const char *mode, const char *path, const char **pprefix)
+{
+    char *psemi;
+    FILE *file;
+
+    // first try and open up the file in the current directory
+    if (pprefix) *pprefix = NULL;
+    if (file = fopen(filename,mode))
+        return file;
+    if (path == NULL)
+        return NULL;
+
+    while (*path) {             // for each chunk of the search path
+        char nameWithPath[1024];
+        psemi = strchr(path,';');               // find the next semicolon
+        if (psemi) {                            // if one, copy up to it
+            strncpy(nameWithPath,path,psemi-path);
+            nameWithPath[psemi-path] = '\0';
+        }
+        else                                    // else copy entire path
+            strcpy(nameWithPath,path);
+        strcat(nameWithPath,"/");               // add directory separator
+        strcat(nameWithPath,filename);          // add filename
+        if (pprefix) *pprefix = path;           // save the prefix
+        if (file = fopen(nameWithPath,mode))
+            return file;
+        path = psemi;                           // advance to next path element
+        if (path)
+            path++;                             // if one, then skip semicolon
+        else
+            break;                              // else all done
+    }
+    return file;
+}
Index: trunk/src/opengl/glide/swlibs/fxmisc/fxos.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fxos.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fxos.h	(revision 2887)
@@ -0,0 +1,53 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $ Revision: $
+** $ Date: $
+**
+*/
+
+
+#ifndef _FXOS_H_
+#define _FXOS_H_
+
+#include <stdio.h>
+
+#   ifdef __cplusplus
+extern "C" {
+#   endif
+
+#   ifdef WIN32
+void sleep(int secs);
+#define gethostname fxGethostname
+
+int gethostname(char *name, int namelen);
+
+#   endif
+
+float fxTime(void);
+float timer(int flag);
+
+FILE *fxFopenPath(const char *filename, const char *mode,
+					const char *path, const char **pprefix);
+
+#   ifdef __cplusplus
+}
+#   endif
+
+#endif
Index: trunk/src/opengl/glide/swlibs/fxmisc/fxver.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/fxver.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/fxver.h	(revision 2887)
@@ -0,0 +1,111 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+** $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/src/opengl/glide/swlibs/fxmisc/fxver.h,v 1.1 2000-02-25 00:33:53 sandervl Exp $
+** $Log: fxver.h,v $
+** Revision 1.1  2000-02-25 00:33:53  sandervl
+** Created swlibs dir
+**
+** 
+** 1     3/16/99 8:00p Sapphire
+*/
+
+#ifndef __FXVER_H__
+#define __FXVER_H__
+
+#define ID(id)     id
+
+/* ----- Symbols ----- */
+#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 */
+
+/* ----- VS_VERSION.dwFileFlags ----- */
+#define VS_FF_DEBUG             0x00000001L
+#define VS_FF_PRERELEASE        0x00000002L
+#define VS_FF_PATCHED           0x00000004L
+#define VS_FF_PRIVATEBUILD      0x00000008L
+#define VS_FF_INFOINFERRED      0x00000010L
+#define VS_FF_SPECIALBUILD      0x00000020L
+
+/* ----- VS_VERSION.dwFileOS ----- */
+#define VOS_UNKNOWN             0x00000000L
+#define VOS_DOS                 0x00010000L
+#define VOS_OS216               0x00020000L
+#define VOS_OS232               0x00030000L
+#define VOS_NT                  0x00040000L
+
+#define VOS__BASE               0x00000000L
+#define VOS__WINDOWS16          0x00000001L
+#define VOS__PM16               0x00000002L
+#define VOS__PM32               0x00000003L
+#define VOS__WINDOWS32          0x00000004L
+
+#define VOS_DOS_WINDOWS16       0x00010001L
+#define VOS_DOS_WINDOWS32       0x00010004L
+#define VOS_OS216_PM16          0x00020002L
+#define VOS_OS232_PM32          0x00030003L
+#define VOS_NT_WINDOWS32        0x00040004L
+
+/* ----- VS_VERSION.dwFileType ----- */
+#define VFT_UNKNOWN             0x00000000L
+#define VFT_APP                 0x00000001L
+#define VFT_DLL                 0x00000002L
+#define VFT_DRV                 0x00000003L
+#define VFT_FONT                0x00000004L
+#define VFT_VXD                 0x00000005L
+#define VFT_STATIC_LIB          0x00000007L
+
+/* ----- VS_VERSION.dwFileSubtype for VFT_WINDOWS_DRV ----- */
+#define VFT2_UNKNOWN            0x00000000L
+#define VFT2_DRV_PRINTER        0x00000001L
+#define VFT2_DRV_KEYBOARD       0x00000002L
+#define VFT2_DRV_LANGUAGE       0x00000003L
+#define VFT2_DRV_DISPLAY        0x00000004L
+#define VFT2_DRV_MOUSE          0x00000005L
+#define VFT2_DRV_NETWORK        0x00000006L
+#define VFT2_DRV_SYSTEM         0x00000007L
+#define VFT2_DRV_INSTALLABLE    0x00000008L
+#define VFT2_DRV_SOUND          0x00000009L
+#define VFT2_DRV_COMM           0x0000000AL
+#define VFT2_DRV_INPUTMETHOD    0x0000000BL
+
+
+/* default is nodebug */
+#ifndef DEBUG
+#define VER_DEBUG                   0
+#else
+#define VER_DEBUG                   VS_FF_DEBUG
+#endif
+
+/* default is privatebuild */
+#ifndef OFFICIAL
+#define VER_PRIVATEBUILD            VS_FF_PRIVATEBUILD
+#else
+#define VER_PRIVATEBUILD            0
+#endif
+
+/* default is prerelease */
+#ifndef FINAL
+#define VER_PRERELEASE              VS_FF_PRERELEASE
+#else
+#define VER_PRERELEASE              0
+#endif
+
+#endif /* __FXVER_H__ */
Index: trunk/src/opengl/glide/swlibs/fxmisc/linutil.c
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/linutil.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/linutil.c	(revision 2887)
@@ -0,0 +1,75 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <termios.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include "linutil.h"
+
+static init_done=0;
+static struct termios save_termdata;
+
+static void reset_term() {
+  if (tcsetattr(0, 0, &save_termdata)<0)
+    fprintf(stderr, "Failed to reset termio data for stdin\n");
+}
+
+static void do_init() {
+  struct termios termdata;
+
+  if (tcgetattr(0, &termdata)<0) {
+    fprintf(stderr, "Failed to get termio data for stdin\n");
+    return;
+  }  
+  save_termdata=termdata;
+  cfmakeraw(&termdata);
+  if (tcsetattr(0, 0, &termdata)<0) {
+    fprintf(stderr, "Failed to set termio data for stdin\n");
+    return;
+  }
+  atexit(reset_term);
+  init_done=1;
+}
+
+int lin_kbhit() {
+  fd_set set;
+  struct timeval to;
+
+  if (!init_done) do_init();
+  FD_ZERO(&set);
+  FD_SET(0, &set);
+  to.tv_sec=0;
+  to.tv_usec=0;
+  if (select(1, &set, 0, 0, &to)<1) return 0;
+  return 1;
+}
+
+char lin_getch() {
+  char c;
+
+  if (!init_done) do_init();
+  read(0, &c, 1);
+  return c;
+}
+
Index: trunk/src/opengl/glide/swlibs/fxmisc/linutil.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/linutil.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/linutil.h	(revision 2887)
@@ -0,0 +1,29 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+#ifndef _LINUTIL_H_
+#define _LINUTIL_H_
+
+extern int lin_kbhit();
+extern char lin_getch();
+
+#define kbhit lin_kbhit
+#define getch lin_getch
+
+#endif
Index: trunk/src/opengl/glide/swlibs/fxmisc/makefile.unix
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/makefile.unix	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/makefile.unix	(revision 2887)
@@ -0,0 +1,38 @@
+#
+# THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+# PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+# TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+# INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+# DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+# THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+# EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+# FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+# 
+# USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+# RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+# TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+# AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+# SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+# THE UNITED STATES.  
+# 
+# COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+#
+# $Revision: 1.1 $
+# $Date: 2000-02-25 00:33:53 $
+
+# local defines, options, includes
+LCDEFS  = 
+LCOPTS  =
+
+# sources
+HEADERS             = 3dfx.h fx64.h fxdll.h fximg.h fxglob.h fxos.h fxver.h \
+			linutil.h
+INSTALL_DESTINATION = $(BUILD_ROOT_SWLIBS)
+CFILES              = fx64.c fximg.c fxos.c linutil.c
+        
+# targets
+LIBRARIES = libfxmisc.a
+
+include $(BUILD_ROOT_SWLIBS)/include/make/3dfx.mak
+
+
Index: trunk/src/opengl/glide/swlibs/fxmisc/tsc.c
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/tsc.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/tsc.c	(revision 2887)
@@ -0,0 +1,113 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <3dfx.h>
+#include <tsc.h>
+
+static FxU32 tsc_histogram[TSC_MAX_CLOCKS];
+
+FxU32        tsc_begin, tsc_end;
+static FxU32 tsc_bias;
+
+void 
+tscInit( void ) {
+   FxU32 test = 100;
+   int   i;
+   
+
+   for ( i = 0; i < 10; i++ )
+   {
+     tscBegin();
+     tsc_end = tscReadTSC();
+     if ( ( tsc_end - tsc_begin ) < test )
+        test = tsc_end - tsc_begin;
+   }
+   tsc_bias = test;
+}
+
+/*
+** timing routines
+*/
+void tscStoreDelta( void )
+{
+   FxU32 value = tsc_end - tsc_begin;
+
+   if ( value < TSC_MAX_CLOCKS && value > tsc_bias )
+      tsc_histogram[value-tsc_bias]++;
+}
+
+void tscPrintHistogram( void )
+{
+   float total = 0.0F;
+   int   i;
+
+   for ( i = 0; i < TSC_MAX_CLOCKS; i++ )
+      total += tsc_histogram[i];
+
+   for ( i = 0; i < TSC_MAX_CLOCKS; i++ )
+   {
+      float percent = ( tsc_histogram[i] * 100.0F ) / total;
+
+      if ( percent > 1.0 )
+      {
+         printf( "%04d: %3.2f\n", i, percent );
+      }
+   }
+}
+
+FxU32 
+tscGetMostFrequent(void) {
+  float total = 0.0F;
+  int   i;
+  float
+    maxPercent = 0.f;
+  FxU32
+    mostFrequentClockCount;
+  
+  for ( i = 0; i < TSC_MAX_CLOCKS; i++ )
+    total += tsc_histogram[i];
+  
+  for ( i = 0; i < TSC_MAX_CLOCKS; i++ ) {
+    float percent = ( tsc_histogram[i] * 100.0F ) / total;
+    
+    if ( percent > maxPercent ) {
+      maxPercent = percent;
+      mostFrequentClockCount = i;
+    }
+  }
+  return mostFrequentClockCount;
+}
+
+FxU32 *tscGetHistogram( void )
+{
+   return tsc_histogram;
+}
+
+void tscResetHistogram(void)
+{
+  int i;
+  
+  for (i = 0; i < TSC_MAX_CLOCKS; i++)
+    tsc_histogram[i] = 0;
+}
+ 
Index: trunk/src/opengl/glide/swlibs/fxmisc/tsc.h
===================================================================
--- trunk/src/opengl/glide/swlibs/fxmisc/tsc.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/fxmisc/tsc.h	(revision 2887)
@@ -0,0 +1,61 @@
+/* 
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+#ifndef __TSC_H__
+#define __TSC_H__
+
+#ifndef __3DFX_H__
+#  include <3dfx.h>
+#endif
+
+/*
+** timing routines
+*/
+#define TSC_MAX_CLOCKS 5000
+
+extern FxU32 tsc_begin, tsc_end;
+
+FxU32 *tscGetHistogram( void );
+FxU32  tscGetMostFrequent(void);
+void   tscInit( void );
+FxU32  tscReadTSC( void );
+void   tscPrintHistogram( void );
+void   tscStoreDelta();
+void   tscResetHistogram(void);
+
+#define tscBegin() \
+          tsc_begin = tscReadTSC();
+#define tscEnd() \
+          tsc_end = tscReadTSC(); \
+          tscStoreDelta();
+
+#if defined(__WATCOMC__)
+#pragma aux tscReadTSC = \
+   ".586" \
+   "rdtsc" \
+   modify [edx eax] \
+   value [eax];
+
+#elif defined(__MSC__)
+FxU32 tscReadTSC(void);
+#else
+#error "TSC:  unsupported compiler"
+#endif
+
+#endif
Index: trunk/src/opengl/glide/swlibs/pcilib/fxdpmi2.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxdpmi2.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxdpmi2.c	(revision 2887)
@@ -0,0 +1,233 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <conio.h>
+
+#include <3dfx.h>
+#define FX_DLL_DEFINITION
+#include <fxdll.h>
+#include "fxpci.h"
+#include "pcilib.h"
+
+#include <fxdpmi.h>
+#include <fxmemmap.h>
+
+/* Callback declarations */
+static FxBool pciInitializeDPMI(void);
+static FxBool pciShutdownDPMI(void);
+static const char* pciIdentifierDPMI(void);
+
+static FxU8  pciPortInByteDPMI(FxU16 port);
+static FxU16 pciPortInWordDPMI(FxU16 port);
+static FxU32 pciPortInLongDPMI(FxU16 port);
+  
+static FxBool pciPortOutByteDPMI(FxU16 port, FxU8 data);
+static FxBool pciPortOutWordDPMI(FxU16 port, FxU16 data);
+static FxBool pciPortOutLongDPMI(FxU16 port, FxU32 data);
+
+static FxBool pciMapLinearDPMI(FxU32 busNumber, FxU32 physAddr,
+                             FxU32* linearAddr, FxU32* length);
+static FxBool pciUnmapLinearDPMI(FxU32 linearAddr, FxU32 length);
+
+static FxBool pciSetPermissionDPMI(const FxU32 addrBase, const FxU32 addrLen,
+                                 const FxBool writePermP);
+
+static FxBool pciMsrGetDPMI(MSRInfo* in, MSRInfo* out);
+static FxBool pciMsrSetDPMI(MSRInfo* in, MSRInfo* out);
+
+static FxBool pciOutputStringDPMI(const char* msg);
+static FxBool pciSetPassThroughBaseDPMI(FxU32* baseAddr, FxU32 baseAddrLen);
+
+static char pciIdent[] = "@#% fxPCI for DOS";
+
+static const FxPlatformIOProcs __ioProcsDPMI = {
+  pciInitializeDPMI,
+  pciShutdownDPMI,
+  pciIdentifierDPMI,
+
+  pciPortInByteDPMI,
+  pciPortInWordDPMI,
+  pciPortInLongDPMI,
+  
+  pciPortOutByteDPMI,
+  pciPortOutWordDPMI,
+  pciPortOutLongDPMI,
+
+  pciMapLinearDPMI,
+  pciUnmapLinearDPMI,
+  pciSetPermissionDPMI,
+
+  pciMsrGetDPMI,
+  pciMsrSetDPMI,
+
+  pciOutputStringDPMI,
+  pciSetPassThroughBaseDPMI
+};
+const FxPlatformIOProcs* ioProcsDPMI = &__ioProcsDPMI;
+
+FxBool 
+pciPlatformInit(void)
+{
+  gCurPlatformIO = ioProcsDPMI;
+  return FXTRUE;
+}
+
+/* Basic platform init/shutdown stuff */
+static FxBool
+pciInitializeDPMI(void)
+{
+  return FXTRUE;
+}
+
+static FxBool
+pciShutdownDPMI(void)
+{
+  return FXTRUE;
+}
+
+static const char* 
+pciIdentifierDPMI(void)
+{
+  return pciIdent;
+}
+
+/* Device address space management stuff */
+
+static FxBool
+pciMapLinearDPMI(FxU32 busNumber, FxU32 physical_addr,
+               FxU32 *linear_addr, FxU32 *length)
+{
+  FxBool onWindows;
+
+  /*  
+  **  First, check to see if we're a DOS app under Windows, and if
+  **  so, then check to see if there's already an app connected to
+  **  the VXD.
+  *
+  * NB: To be compatible w/ the 'previous' pci libraries this is only
+  * done the first time that we're mapping a board otherwise it will
+  * fail on the vxd ref count because any previous mappings bump the
+  * reference count.  
+  */
+  {
+    static FxBool didVxdCheck = FXFALSE;
+
+    if (!didVxdCheck) {
+      DpmiCheckVxd((FxBool *) &onWindows, &pciVxdVer);
+      didVxdCheck = FXTRUE;
+
+      if (onWindows) {
+        if (BYTE1(pciVxdVer) != FX_MAJOR_VER || BYTE0(pciVxdVer) < FX_MINOR_VER) {
+          pciErrorCode = PCI_ERR_WRONGVXD;
+          return FXFALSE;
+        }
+          
+        if (VXDREFCOUNT(pciVxdVer) > 0) {
+          pciErrorCode = PCI_ERR_VXDINUSE;
+          return FXFALSE;
+        }
+      }
+    }
+  }
+
+  /* If we got here, it's OK to map the memory */
+  *linear_addr = DpmiMapPhysicalToLinear( physical_addr, *length );
+
+  return FXTRUE;
+}
+
+static FxBool
+pciUnmapLinearDPMI( FxU32 linear_addr, FxU32 length ) 
+{
+  DpmiUnmapMemory(linear_addr, length);
+}
+
+/* Platform port io stuff */
+static FxU8
+pciPortInByteDPMI(FxU16 port)
+{
+  return inp(port);
+}
+
+static FxU16
+pciPortInWordDPMI(FxU16 port)
+{
+  return inpw(port);
+}
+
+static FxU32
+pciPortInLongDPMI(FxU16 port)
+{
+  return inpd(port);
+}
+  
+static FxBool
+pciPortOutByteDPMI(FxU16 port, FxU8 data)
+{
+  return outp(port, data);
+}
+
+static FxBool
+pciPortOutWordDPMI(FxU16 port, FxU16 data)
+{
+  return outpw(port, data);
+}
+
+static FxBool
+pciPortOutLongDPMI(FxU16 port, FxU32 data)
+{
+  return outpd(port, data);
+}
+
+static FxBool 
+pciMsrGetDPMI(MSRInfo* in, MSRInfo* out)
+{
+  return DpmiGetMSR((FxU32)in, (FxU32)out);
+}
+
+static FxBool 
+pciMsrSetDPMI(MSRInfo* in, MSRInfo* out)
+{
+  return DpmiSetMSR((FxU32)in, (FxU32)out);
+}
+
+/* Platform utilities. */
+static FxBool
+pciOutputStringDPMI(const char* msg)
+{
+  return DpmiOutputDebugString(msg);
+}
+
+static FxBool
+pciSetPermissionDPMI(const FxU32 addrBase, const FxU32 addrLen,
+                   const FxBool writePermP)
+{
+  return DpmiLinearRangeSetPermission(addrBase, addrLen, writePermP);
+}
+
+static FxBool
+pciSetPassThroughBaseDPMI(FxU32* baseAddr, FxU32 baseAddrLen)
+{
+  return DpmiSetPassThroughBase(baseAddr, baseAddrLen);
+}
+
Index: trunk/src/opengl/glide/swlibs/pcilib/fxinfo.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxinfo.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxinfo.c	(revision 2887)
@@ -0,0 +1,862 @@
+/*
+ ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+ ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+ ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+ ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+ ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+ ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+ ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+ ** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+ ** 
+ ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+ ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+ ** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+ ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+ ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+ ** THE UNITED STATES.  
+ ** 
+ ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+ **
+ **
+ ** $Revision: 1.1 $ 
+ ** $Date: 2000-02-25 00:33:54 $ 
+ **
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <3dfx.h>
+#define FX_DLL_DEFINITION
+#include <fxdll.h>
+#include "fxpci.h"
+#include "pcilib.h"
+
+const char *
+pciGetClassName( FxU32 class_code, FxU32 deviceID)
+{
+  switch( class_code ) {
+    /* Pre-Class Code Devices        */
+  case 0x000000:  return "old style non-VGA device";
+  case 0x000100:  return "old style VGA-compatible device";
+    /* Mass Storage Controllers */
+  case 0x010000:  return "SCSI bus controller";
+  case 0x010100:  return "IDE Controller";
+  case 0x010200:  return "floppy Controller";
+  case 0x010300:  return "IPI bus controller";
+  case 0x010400:  return "RAID controller";
+  case 0x018000:  return "mass storage controller";
+    /* Network Controllers */
+  case 0x020000:  return "ethernet controller";
+  case 0x020100:  return "token ring controller";
+  case 0x020200:  return "FDDI controller";
+  case 0x020300:  return "ATM controller";
+  case 0x028000:  return "network controller";
+    /* Display Adapters */
+  case 0x030000:  return "VGA-compatible display controller";
+  case 0x030001:  return "8514-compatible display controller";
+  case 0x030101:  return "XGA-compatible display controller";
+  case 0x038000:  return "display controller";
+    /* Multimedia Adapters */
+  case 0x040000:  return "video multimedia adapter";
+  case 0x040100:  return "audio multimedia adapter";
+  case 0x048000:  return "multimedia adapter";
+    /* Memory Controllers */
+  case 0x050000:  return "RAM controller";
+  case 0x050100:  return "Flash controller";
+  case 0x058000:  return "memory controller";
+    /* Bridges */
+  case 0x060000:  
+    switch(deviceID) {
+    case 0x84c4:    return "450KX/GX (Orion)";
+    case 0x1237:    return "440FX (Natoma)";
+    case 0x1250:    return "430HX (Triton II)";
+    case 0x7030:    return "430VX (Triton II)";
+    case 0x1235:    return "430MX (Triton Mobile)";
+    case 0x122d:    return "430FX (Triton)";
+    case 0x04a3:    return "430NX/LX (Neptune/Mercury)";
+    default:        return "Host bridge";
+    }
+  case 0x060100:  return "ISA bridge";
+  case 0x060200:  return "EISA bridge";
+  case 0x060300:  return "MCA bridge";
+  case 0x060400:  return "PCI-toPCI bridge";
+  case 0x060500:  return "PCMCIA bridge";
+  case 0x060600:  return "NuBus bridge";
+  case 0x060700:  return "CardBus bridge";
+  case 0x068000:  return "bridge";
+    /* Communications Devices */
+  case 0x070000:  return "XT-compatible serial controller";
+  case 0x070001:  return "16450-compatible serial controller";
+  case 0x070002:  return "16550-compatible serial controller";
+  case 0x070100:  return "parallel port";
+  case 0x070101:  return "bidirectional parallel port";
+  case 0x070102:  return "ECP 1.X compliant parallel port";
+  case 0x078000:  return "communications device";
+    /* Generic System Peripherals */
+  case 0x080000:  return "8259 PIC";
+  case 0x080001:  return "ISA PIC";
+  case 0x080002:  return "EISA PIC";
+  case 0x080100:  return "8237 DMA controller";
+  case 0x080101:  return "ISA DMA controller";
+  case 0x080102:  return "EISA DMA controller";
+  case 0x080200:  return "8254 system timer";
+  case 0x080201:  return "ISA system timer";
+  case 0x080202:  return "EISA system timer";
+  case 0x080300:  return "generic RTC controller";
+  case 0x080301:  return "ISA RTC controller";
+  case 0x088000:  return "system peripheral";
+    /* Input Devices */
+  case 0x090000:  return "keyboard controller";
+  case 0x090100:  return "pen digitizer";
+  case 0x090200:  return "mouse controller";
+  case 0x098000:  return "input device";
+    /* Docking Stations */
+  case 0x0A0000:  return "generic docking station";
+  case 0x0A8000:  return "docking station";
+    /* Processors */
+  case 0x0B0000:  return "386";
+  case 0x0B0100:  return "486";
+  case 0x0B0200:  return "Pentium";
+  case 0x0B1000:  return "Alpha";
+  case 0x0B2000:  return "PowerPC";
+  case 0x0B4000:  return "co-processor";
+    /* Serial Bus Controllers */
+  case 0x0C0000:  return "FireWire( IEEE 1394 )";
+  case 0x0C0100:  return "ACCESS.bus";
+  case 0x0C0200:  return "SSA";
+  case 0x0C0300:  return "USB";
+  case 0x0C0400:  return "FibreChannel";
+  default:                return "???";
+  }
+} /* end pciGetClassName() */
+  
+
+
+const char *
+pciGetVendorName( FxU16 vendor_id )
+{
+  /* These come vrom http://www.pcisig.com/siginfo */
+  switch( vendor_id ) {
+  case 0x1002:    return "ATI TECHNOLOGIES INC";
+  case 0x1003:    return "ULSI SYSTEMS";
+  case 0x1004:    return "VLSI TECHNOLOGY INC";
+  case 0x1006:    return "REPLY GROUP";
+  case 0x1007:    return "NETFRAME SYSTEMS INC";
+  case 0x100a:    return "PHOENIX TECHNOLOGIES";
+  case 0x100b:    return "NATIONAL SEMICONDUCTOR CORPORATION";
+  case 0x100c:    return "TSENG LABS INC";
+  case 0x100d:    return "AST COMPUTER";
+  case 0x100e:    return "WEITEK";
+  case 0x1010:    return "VIDEO LOGIC LTD";
+  case 0x1011:    return "DIGITAL EQUIPMENT CORPORATION";
+  case 0x1012:    return "MICRONICS COMPUTERS INC";
+  case 0x1013:    return "CIRRUS LOGIC";
+  case 0x1014:    return "IBM";
+  case 0x1015:    return "LSI LOGIC CORPORATION";
+  case 0x1016:    return "ICL PERSONAL SYSTEMS";
+  case 0x1017:    return "SPEA SOFTWARE AG";
+  case 0x1018:    return "UNISYS CORPORATION";
+  case 0x101a:    return "AT&T GIS (NCR)";
+  case 0x101b:    return "VITESSE SEMICONDUCTOR";
+  case 0x101e:    return "AMERICAN MEGATRENDS";
+  case 0x101f:    return "PICTURETEL";
+  case 0x1020:    return "HITACHI COMPUTER PRODUCTS";
+  case 0x1021:    return "OKI ELECTRIC INDUSTRY CO. LTD.";
+  case 0x1022:    return "ADVANCED MICRO DEVICES";
+  case 0x1023:    return "TRIDENT MICROSYSTEMS";
+  case 0x1025:    return "ACER INCORPORATED";
+  case 0x1028:    return "DELL COMPUTER CORPORATION";
+  case 0x102b:    return "MATROX GRAPHICS, INC.";
+  case 0x102c:    return "CHIPS AND TECHNOLOGIES";
+  case 0x102d:    return "WYSE TECHNOLOGY";
+  case 0x102e:    return "OLIVETTI ADVANCED TECHNOLOGY";
+  case 0x102f:    return "Toshiba";
+  case 0x1030:    return "TMC RESEARCH";
+  case 0x1031:    return "MIRO COMPUTER PRODUCTS AG";
+  case 0x1033:    return "NEC Corporation";
+  case 0x1034:    return "FRAMATOME CONNECTORS USA INC.";
+  case 0x1035:    return "INDUSTRIAL TECHNOLOGY RESEARCH INSTITUTE";
+  case 0x1036:    return "FUTURE DOMAIN CORP.";
+  case 0x1037:    return "HITACHI MICRO SYSTEMS";
+  case 0x1038:    return "AMP, INC";
+  case 0x1039:    return "SILICON INTEGRATED SYSTEMS";
+  case 0x103a:    return "SEIKO EPSON CORPORATION";
+  case 0x103b:    return "TATUNG CO. OF AMERICA";
+  case 0x103c:    return "HEWLETT PACKARD";
+  case 0x103e:    return "SOLLIDAY ENGINEERING";
+  case 0x103f:    return "SYNOPSYS/LOGIC MODELING GROUP";
+  case 0x1040:    return "ACCELGRAPHICS INC.";
+  case 0x1042:    return "PC TECHNOLOGY INC";
+  case 0x1043:    return "ASUSTEK COMPUTER, INC.";
+  case 0x1044:    return "DISTRIBUTED PROCESSING TECHNOLOGY";
+  case 0x1045:    return "OPTI INC.";
+  case 0x1046:    return "IPC CORPORATION, LTD.";
+  case 0x1047:    return "GENOA SYSTEMS CORP";
+  case 0x1048:    return "ELSA GMBH";
+  case 0x1049:    return "FOUNTAIN TECHNOLOGIES, INC.";
+  case 0x104a:    return "SGS THOMSON MICROELECTRONICS";
+  case 0x104b:    return "BUSLOGIC";
+  case 0x104c:    return "TEXAS INSTRUMENTS";
+  case 0x104d:    return "SONY CORPORATION";
+  case 0x104e:    return "OAK TECHNOLOGY, INC";
+  case 0x104f:    return "CO-TIME COMPUTER LTD";
+  case 0x1050:    return "WINBOND ELECTRONICS CORP";
+  case 0x1051:    return "ANIGMA, INC.";
+  case 0x1053:    return "YOUNG MICRO SYSTEMS";
+  case 0x1054:    return "HITACHI, LTD";
+  case 0x1057:    return "MOTOROLA";
+  case 0x1058:    return "ETRI";
+  case 0x1059:    return "TEKNOR MICROSYSTEMS";
+  case 0x105a:    return "PROMISE TECHNOLOGY, INC.";
+  case 0x105b:    return "FOXCONN INTERNATIONAL, INC.";
+  case 0x105c:    return "WIPRO INFOTECH LIMITED";
+  case 0x105d:    return "NUMBER 9 VISUAL TECHNOLOGY";
+  case 0x105e:    return "VTECH COMPUTERS LTD";
+  case 0x105f:    return "INFOTRONIC AMERICA INC";
+  case 0x1060:    return "UNITED MICROELECTRONICS";
+  case 0x1061:    return "I.I.T.";
+  case 0x1062:    return "MASPAR COMPUTER CORP";
+  case 0x1063:    return "OCEAN OFFICE AUTOMATION";
+  case 0x1064:    return "ALCATEL CIT";
+  case 0x1065:    return "TEXAS MICROSYSTEMS";
+  case 0x1066:    return "PICOPOWER TECHNOLOGY";
+  case 0x1067:    return "MITSUBISHI ELECTRONICS";
+  case 0x1068:    return "DIVERSIFIED TECHNOLOGY";
+  case 0x1069:    return "MYLEX CORPORATION";
+  case 0x106a:    return "ATEN RESEARCH INC";
+  case 0x106b:    return "APPLE COMPUTER INC.";
+  case 0x106c:    return "HYUNDAI ELECTRONICS AMERICA";
+  case 0x106d:    return "SEQUENT COMPUTER SYSTEMS";
+  case 0x106e:    return "DFI, INC";
+  case 0x106f:    return "CITY GATE DEVELOPMENT LTD";
+  case 0x1070:    return "DAEWOO TELECOM LTD";
+  case 0x1071:    return "MITAC";
+  case 0x1072:    return "GIT CO LTD";
+  case 0x1073:    return "YAMAHA CORPORATION";
+  case 0x1074:    return "NEXGEN MICROSYSTEMS";
+  case 0x1075:    return "ADVANCED INTEGRATION RES.";
+  case 0x1077:    return "Q LOGIC";
+  case 0x1078:    return "CYRIX CORPORATION";
+  case 0x1079:    return "I-BUS";
+  case 0x107a:    return "NETWORTH";
+  case 0x107b:    return "GATEWAY 2000";
+  case 0x107c:    return "LG ELECTRONICS";
+  case 0x107d:    return "LEADTEK RESEARCH INC.";
+  case 0x107e:    return "INTERPHASE CORPORATION";
+  case 0x107f:    return "DATA TECHNOLOGY CORPORATION";
+  case 0x1080:    return "CYPRESS SEMICONDUCTOR";
+  case 0x1081:    return "RADIUS, INC.";
+  case 0x1083:    return "FOREX COMPUTER CORPORATION";
+  case 0x1084:    return "PARADOR";
+  case 0x1085:    return "TULIP COMPUTERS INT.B.V.";
+  case 0x1086:    return "J. BOND COMPUTER SYSTEMS";
+  case 0x1088:    return "MICROCOMPUTER SYSTEMS (M) SON";
+  case 0x108a:    return "BIT 3 COMPUTER";
+  case 0x108c:    return "OAKLEIGH SYSTEMS INC.";
+  case 0x108d:    return "OLICOM";
+  case 0x108e:    return "SUN MICROSYSTEMS COMPUTER CORP.";
+  case 0x108f:    return "SYSTEMSOFT";
+  case 0x1090:    return "ENCORE COMPUTER CORPORATION";
+  case 0x1091:    return "INTERGRAPH CORPORATION";
+  case 0x1092:    return "DIAMOND MULTIMEDIA SYSTEMS";
+  case 0x1093:    return "NATIONAL INSTRUMENTS";
+  case 0x1094:    return "FIRST INT'L COMPUTERS";
+  case 0x1095:    return "CMD TECHNOLOGY INC";
+  case 0x1096:    return "ALACRON";
+  case 0x1097:    return "APPIAN/ETMA";
+  case 0x1098:    return "QUANTUM DESIGNS (H.K.) LTD";
+  case 0x1099:    return "SAMSUNG ELECTRONICS CO., LTD";
+  case 0x109a:    return "PACKARD BELL";
+  case 0x109b:    return "GEMLIGHT COMPUTER LTD.";
+  case 0x109c:    return "MEGACHIPS CORPORATION";
+  case 0x109d:    return "ZIDA TECHNOLOGIES LTD.";
+  case 0x109e:    return "BROOKTREE CORPORATION";
+  case 0x109f:    return "TRIGEM COMPUTER INC.";
+  case 0x10a0:    return "MEIDENSHA CORPORATION";
+  case 0x10a1:    return "JUKO ELECTRONICS IND. CO. LTD";
+  case 0x10a2:    return "QUANTUM CORPORATION";
+  case 0x10a4:    return "GLOBE MANUFACTURING SALES";
+  case 0x10a6:    return "RACAL INTERLAN";
+  case 0x10a7:    return "INFORMTECH INDUSTRIAL LTD.";
+  case 0x10a8:    return "SIERRA SEMICONDUCTOR";
+  case 0x10a9:    return "SILICON GRAPHICS";
+  case 0x10aa:    return "ACC MICROELECTRONICS";
+  case 0x10ab:    return "DIGICOM";
+  case 0x10ac:    return "HONEYWELL, INC.";
+  case 0x10ad:    return "SYMPHONY LABS";
+  case 0x10ae:    return "CORNERSTONE IMAGING";
+  case 0x10af:    return "MICRO COMPUTER SYSYTEMS INC";
+  case 0x10b0:    return "CARDEXPERT TECHNOLOGY";
+  case 0x10b1:    return "CABLETRON SYSTEMS INC";
+  case 0x10b2:    return "RAYTHEON COMPANY";
+  case 0x10b3:    return "DATABOOK INC";
+  case 0x10b4:    return "STB SYSTEMS INC";
+  case 0x10b5:    return "PLX TECHNOLOGY, INC.";
+  case 0x10b6:    return "MADGE NETWORKS";
+  case 0x10b7:    return "3COM CORPORATION";
+  case 0x10b8:    return "STANDARD MICROSYSTEMS";
+  case 0x10ba:    return "MITSUBISHI ELECTRIC CORP.";
+  case 0x10bb:    return "DAPHA ELECTRONICS CORPORATION";
+  case 0x10bc:    return "ADVANCED LOGIC RESEARCH";
+  case 0x10bd:    return "SURECOM TECHNOLOGY";
+  case 0x10be:    return "TSENGLABS INTERNATIONAL CO.";
+  case 0x10bf:    return "MOST INC";
+  case 0x10c0:    return "BOCA RESEARCH INC.";
+  case 0x10c1:    return "ICM CO., LTD.";
+  case 0x10c2:    return "AUSPEX SYSTEMS INC.";
+  case 0x10c3:    return "SAMSUNG SEMICONDUCTOR , INC.";
+  case 0x10c4:    return "AWARD SOFTWARE";
+  case 0x10c5:    return "XEROX CORPORATION";
+  case 0x10c6:    return "RAMBUS INC.";
+  case 0x10c8:    return "NEOMAGIC CORPORATION";
+  case 0x10c9:    return "DATAEXPERT CORPORATION";
+  case 0x10ca:    return "FUJITSU MICROELECTR., INC.";
+  case 0x10cb:    return "OMRON CORPORATION";
+  case 0x10cc:    return "MENTOR ARC INC";
+  case 0x10cd:    return "ADVANCED SYSTEM PRODUCTS, INC";
+  case 0x10cf:    return "CITICORP TTI";
+  case 0x10d0:    return "FUJITSU LIMITED";
+  case 0x10d1:    return "FUTUREPLUS SYSTEMS CORP.";
+  case 0x10d2:    return "MOLEX INCORPORATED";
+  case 0x10d3:    return "JABIL CIRCUIT INC";
+  case 0x10d4:    return "HUALON MICROELECTRONICS";
+  case 0x10d5:    return "AUTOLOGIC INC.";
+  case 0x10d6:    return "CETIA";
+  case 0x10d7:    return "BCM ADVANCED RESEARCH";
+  case 0x10d8:    return "ADVANCED PERIPHERALS LABS";
+  case 0x10d9:    return "MACRONIX, INC.";
+  case 0x10da:    return "COMPAQ IPG-AUSTIN";
+  case 0x10db:    return "ROHM LSI SYSTEMS, INC.";
+  case 0x10dc:    return "CERN/ECP/EDU";
+  case 0x10dd:    return "EVANS & SUTHERLAND";
+  case 0x10de:    return "NVIDIA CORPORATION";
+  case 0x10df:    return "EMULEX CORPORATION";
+  case 0x10e0:    return "INTEGRATED MICRO SOLUTIONS INC.";
+  case 0x10e1:    return "TEKRAM TECHNOLOGY CO.,LTD.";
+  case 0x10e2:    return "APTIX CORPORATION";
+  case 0x10e3:    return "NEWBRIDGE MICROSYSTEMS";
+  case 0x10e4:    return "TANDEM COMPUTERS";
+  case 0x10e5:    return "MICRO INDUSTRIES CORPORATION";
+  case 0x10e6:    return "GAINBERY COMPUTER PRODUCTS INC.";
+  case 0x10e7:    return "VADEM";
+  case 0x10e8:    return "APPLIED MICRO CIRCUITS CORPORATION";
+  case 0x10e9:    return "ALPS ELECTRIC CO. LTD.";
+  case 0x10ea:    return "INTEGRAPHICS SYSTEMS";
+  case 0x10eb:    return "ARTISTS GRAPHICS";
+  case 0x10ec:    return "REALTEK SEMICONDUCTOR CO., LTD.";
+  case 0x10ed:    return "ASCII CORPORATION";
+  case 0x10ee:    return "XILINX, INC.";
+  case 0x10ef:    return "RACORE COMPUTER PRODUCTS, INC.";
+  case 0x10f0:    return "PERITEK CORPORATION";
+  case 0x10f1:    return "TYAN COMPUTER";
+  case 0x10f2:    return "ACHME COMPUTER INC.";
+  case 0x10f3:    return "ALARIS, INC.";
+  case 0x10f4:    return "S-MOS SYSTEMS";
+  case 0x10f5:    return "NKK CORPORATION";
+  case 0x10f6:    return "CREATIVE ELECTRONIC SYSTEMS SA";
+  case 0x10f7:    return "MATSUSHITA ELECTRIC INDUSTRIAL CO., LTD.";
+  case 0x10f8:    return "ALTOS INDIA LTD";
+  case 0x10f9:    return "PC DIRECT";
+  case 0x10fa:    return "TRUEVISION";
+  case 0x10fb:    return "THESYS GES. F. MIKROELEKTRONIK MGH";
+  case 0x10fc:    return "I-O DATA DEVICE, INC.";
+  case 0x10fd:    return "SOYO COMPUTER, INC";
+  case 0x10fe:    return "FAST MULTIMEDIA AG";
+  case 0x10ff:    return "NCUBE";
+  case 0x1100:    return "JAZZ MULTIMEDIA";
+  case 0x1101:    return "INITIO CORPORATION";
+  case 0x1102:    return "CREATIVE LABS";
+  case 0x1103:    return "TRIONES TECHNOLOGIES, INC.";
+  case 0x1104:    return "RASTEROPS CORP.";
+  case 0x1105:    return "SIGMA DESIGNS, INC";
+  case 0x1106:    return "VIA TECHNOLOGIES, INC.";
+  case 0x1107:    return "STRATUS COMPUTER";
+  case 0x1108:    return "PROTEON, INC.";
+  case 0x1109:    return "COGENT DATA TECHNOLOGIES, INC.";
+  case 0x110a:    return "SIEMENS NIXDORF AG";
+  case 0x110b:    return "CHROMATIC RESEARCH INC.";
+  case 0x110c:    return "MINI-MAX TECHNOLOGY, INC.";
+  case 0x110d:    return "ZNYX ADVANCED SYSTEMS";
+  case 0x110e:    return "CPU TECHNOLOGY";
+  case 0x110f:    return "ROSS TECHNOLOGY";
+  case 0x1111:    return "SANTA CRUZ OPERATION";
+  case 0x1112:    return "RNS";
+  case 0x1113:    return "ACCTON TECHNOLOGY CORPORATION";
+  case 0x1114:    return "ATMEL CORPORATION";
+  case 0x1116:    return "DATA TRANSLATION";
+  case 0x1117:    return "DATACUBE, INC";
+  case 0x1118:    return "BERG ELECTRONICS";
+  case 0x1119:    return "VORTEX COMPUTERSYSTEME GMBH";
+  case 0x111a:    return "EFFICIENT NETWORKS, INC";
+  case 0x111b:    return "LITTON GCS";
+  case 0x111c:    return "TRICORD SYSTEMS";
+  case 0x111d:    return "INTEGRATED DEVICE TECH";
+  case 0x111e:    return "WESTERN DIGITAL";
+  case 0x111f:    return "PRECISION DIGITAL IMAGES";
+  case 0x1120:    return "EMC CORPORATION";
+  case 0x1121:    return "ZILOG";
+  case 0x1122:    return "MULTI-TECH SYSTEMS, INC.";
+  case 0x1123:    return "EXCELLENT DESIGN, INC.";
+  case 0x1124:    return "LEUTRON VISION AG";
+  case 0x1127:    return "FORE SYSTEMS INC";
+  case 0x1129:    return "FIRMWORKS";
+  case 0x112a:    return "HERMES ELECTRONICS COMPANY, LTD.";
+  case 0x112b:    return "LINOTYPE - HELL AG";
+  case 0x112c:    return "ZENITH DATA SYSTEMS";
+  case 0x112d:    return "RAVICAD";
+  case 0x112f:    return "IMAGING TECHNOLOGY, INC";
+  case 0x1130:    return "COMPUTERVISION";
+  case 0x1131:    return "PHILIPS SEMICONDUCTORS";
+  case 0x1132:    return "MITEL CORP.";
+  case 0x1133:    return "EICON TECHNOLOGY CORPORATION";
+  case 0x1134:    return "MERCURY COMPUTER SYSTEMS";
+  case 0x1135:    return "FUJI XEROX CO LTD";
+  case 0x1136:    return "MOMENTUM DATA SYSTEMS";
+  case 0x1137:    return "CISCO SYSTEMS INC";
+  case 0x1138:    return "ZIATECH CORPORATION";
+  case 0x1139:    return "DYNAMIC PICTURES, INC";
+  case 0x113a:    return "FWB INC";
+  case 0x113b:    return "NETWORK COMPUTING DEVICES";
+  case 0x113c:    return "CYCLONE MICROSYSTEMS, INC.";
+  case 0x113d:    return "LEADING EDGE PRODUCTS INC";
+  case 0x113e:    return "SANYO ELECTRIC CO";
+  case 0x113f:    return "EQUINOX SYSTEMS, INC.";
+  case 0x1140:    return "INTERVOICE INC";
+  case 0x1141:    return "CREST MICROSYSTEM INC";
+  case 0x1142:    return "ALLIANCE SEMICONDUCTOR CORPORATION";
+  case 0x1143:    return "NETPOWER, INC";
+  case 0x1144:    return "VICKERS, INC.";
+  case 0x1145:    return "WORKBIT CORPORATION";
+  case 0x1146:    return "FORCE COMPUTERS";
+  case 0x1147:    return "INTERFACE CORP";
+  case 0x1148:    return "SYSKONNECT";
+  case 0x1149:    return "WIN SYSTEM CORPORATION";
+  case 0x114a:    return "VMIC";
+  case 0x114b:    return "CANOPUS CO., LTD";
+  case 0x114c:    return "ANNABOOKS";
+  case 0x114d:    return "IC CORPORATION";
+  case 0x114e:    return "NIKON SYSTEMS INC";
+  case 0x114f:    return "DIGI INTERNATIONAL";
+  case 0x1150:    return "THINKING MACHINES CORP";
+  case 0x1151:    return "JAE ELECTRONICS INC.";
+  case 0x1152:    return "MEGATEK";
+  case 0x1153:    return "LAND WIN ELECTRONIC CORP";
+  case 0x1154:    return "MELCO INC";
+  case 0x1155:    return "PINE TECHNOLOGY LTD";
+  case 0x1156:    return "PERISCOPE ENGINEERING";
+  case 0x1157:    return "AVSYS CORPORATION";
+  case 0x1158:    return "VORAX R & D INC";
+  case 0x1159:    return "MUTECH CORP";
+  case 0x115a:    return "HARLEQUIN LTD";
+  case 0x115b:    return "PARALLAX GRAPHICS";
+  case 0x115c:    return "PHOTRON LTD.";
+  case 0x115d:    return "Netaccess";
+  case 0x115f:    return "MAXTOR CORPORATION";
+  case 0x1160:    return "MEGASOFT INC";
+  case 0x1161:    return "PFU LIMITED";
+  case 0x1162:    return "OA LABORATORY CO LTD";
+  case 0x1163:    return "RENDITION";
+  case 0x1164:    return "ADVANCED PERIPHERALS TECH";
+  case 0x1165:    return "IMAGRAPH CORPORATION";
+  case 0x1166:    return "Ross Computer";
+  case 0x1167:    return "MUTOH INDUSTRIES INC";
+  case 0x1168:    return "THINE ELECTRONICS INC";
+  case 0x1169:    return "CENTRE FOR DEV. OF ADVANCED COMPUTING";
+  case 0x116a:    return "POLARIS COMMUNICATIONS";
+  case 0x116b:    return "CONNECTWARE INC";
+  case 0x116c:    return "INTELLIGENT RESOURCES INTEGRATED SYSTEMS";
+  case 0x116e:    return "ELECTRONICS FOR IMAGING";
+  case 0x116f:    return "WORKSTATION TECHNOLOGY";
+  case 0x1170:    return "INVENTEC CORPORATION";
+  case 0x1171:    return "LOUGHBOROUGH SOUND IMAGES PLC";
+  case 0x1172:    return "ALTERA CORPORATION";
+  case 0x1173:    return "ADOBE SYSTEMS, INC";
+  case 0x1174:    return "BRIDGEPORT MACHINES";
+  case 0x1175:    return "MITRON COMPUTER INC.";
+  case 0x1176:    return "SBE INCORPORATED";
+  case 0x1177:    return "SILICON ENGINEERING";
+  case 0x1178:    return "ALFA, INC.";
+  case 0x1179:    return "TOSHIBA AMERICA INFO SYSTEMS";
+  case 0x117a:    return "A-TREND TECHNOLOGY";
+  case 0x117b:    return "L G ELECTRONICS, INC.";
+  case 0x117c:    return "ATTO TECHNOLOGY";
+  case 0x117d:    return "BECTON DICKINSON";
+  case 0x117e:    return "T/R SYSTEMS";
+  case 0x117f:    return "INTEGRATED CIRCUIT SYSTEMS";
+  case 0x1180:    return "RICOH CO LTD";
+  case 0x1183:    return "FUJIKURA LTD";
+  case 0x1184:    return "FORKS INC";
+  case 0x1185:    return "DATAWORLD INT'L LTD";
+  case 0x1186:    return "D-LINK SYSTEM INC";
+  case 0x1187:    return "ADVANCED TECHNOLOGY LABORATORIES, INC.";
+  case 0x1188:    return "SHIMA SEIKI MANUFACTURING LTD.";
+  case 0x1189:    return "MATSUSHITA ELECTRONICS CO LTD";
+  case 0x118a:    return "HILEVEL TECHNOLOGY";
+  case 0x118b:    return "HYPERTEC PTY LIMITED";
+  case 0x118c:    return "COROLLARY, INC";
+  case 0x118d:    return "BITFLOW INC";
+  case 0x118e:    return "HERMSTEDT GMBH";
+  case 0x118f:    return "GREEN LOGIC";
+  case 0x1191:    return "ARTOP ELECTRONIC CORP";
+  case 0x1192:    return "DENSAN COMPANY LTD";
+  case 0x1193:    return "Cabletron";
+  case 0x1194:    return "TOUCAN TECHNOLOGY";
+  case 0x1195:    return "RATOC SYSTEM INC";
+  case 0x1196:    return "HYTEC ELECTRONICS LTD";
+  case 0x1197:    return "GAGE APPLIED SCIENCES, INC.";
+  case 0x1198:    return "LAMBDA SYSTEMS INC";
+  case 0x1199:    return "ATTACHMATE CORPORATION";
+  case 0x119a:    return "MIND SHARE, INC.";
+  case 0x119b:    return "OMEGA MICRO INC.";
+  case 0x119c:    return "INFORMATION TECHNOLOGY INST.";
+  case 0x119d:    return "BUG, INC.";
+  case 0x119e:    return "FUJITSU MICROELECTRONICS LTD.";
+  case 0x119f:    return "BULL HN INFORMATION SYSTEMS";
+  case 0x11a1:    return "HAMAMATSU PHOTONICS K.K.";
+  case 0x11a2:    return "SIERRA RESEARCH AND TECHNOLOGY";
+  case 0x11a3:    return "DEURETZBACHER GMBH & CO. ENG. KG";
+  case 0x11a4:    return "BARCO GRAPHICS NV";
+  case 0x11a5:    return "MICROUNITY SYSTEMS ENG. INC";
+  case 0x11a6:    return "PURE DATA LTD.";
+  case 0x11a7:    return "POWER COMPUTING CORP.";
+  case 0x11a8:    return "SYSTECH CORP.";
+  case 0x11a9:    return "INNOSYS";
+  case 0x11aa:    return "ACTEL";
+  case 0x11ab:    return "GALILEO TECHNOLOGY LTD.";
+  case 0x11ac:    return "CANON INFO. SYS. RESEARCH AUST.";
+  case 0x11ad:    return "LITE-ON COMMUNICATIONS INC";
+  case 0x11ae:    return "SCITEX CORPORATION";
+  case 0x11af:    return "PRO-LOG CORPORATION";
+  case 0x11b0:    return "V3 SEMICONDUCTOR INC.";
+  case 0x11b1:    return "APRICOT COMPUTERS";
+  case 0x11b2:    return "EASTMAN KODAK";
+  case 0x11b3:    return "BARR SYSTEMS INC.";
+  case 0x11b4:    return "LEITCH TECHNOLOGY INTERNATIONAL";
+  case 0x11b5:    return "RADSTONE TECHNOLOGY PLC";
+  case 0x11b6:    return "UNITED VIDEO CORP";
+  case 0x11b8:    return "XPOINT TECHNOLOGIES, INC";
+  case 0x11b9:    return "PATHLIGHT TECHNOLOGY INC";
+  case 0x11ba:    return "VIDEOTRON CORP";
+  case 0x11bb:    return "PYRAMID TECHNOLOGY";
+  case 0x11bc:    return "NETWORK PERIPHERALS INC";
+  case 0x11bd:    return "PINNACLE SYSTEMS INC.";
+  case 0x11be:    return "INTERNATIONAL MICROCIRCUITS INC";
+  case 0x11bf:    return "ASTRODESIGN, INC.";
+  case 0x11c1:    return "AT&T MICROELECTRONICS";
+  case 0x11c2:    return "SAND MICROELECTRONICS";
+  case 0x11c4:    return "DOCUMENT TECHNOLOGIES, INC";
+  case 0x11c5:    return "SHIVA CORPORATION";
+  case 0x11c6:    return "DAINIPPON SCREEN MFG. CO. LTD";
+  case 0x11c7:    return "D.C.M. DATA SYSTEMS";
+  case 0x11c8:    return "DOLPHIN INTERCONNECT SOLUTIONS AS";
+  case 0x11c9:    return "MAGMA";
+  case 0x11ca:    return "LSI SYSTEMS, INC";
+  case 0x11cb:    return "SPECIALIX RESEARCH LTD";
+  case 0x11cc:    return "MICHELS & KLEBERHOFF COMPUTER GMBH";
+  case 0x11cd:    return "HAL COMPUTER SYSTEMS, INC.";
+  case 0x11ce:    return "Netaccess";
+  case 0x11cf:    return "PIONEER ELECTRONIC CORPORATION";
+  case 0x11d0:    return "LOCKHEED MARTIN FEDERAL SYSTEMS-MANASSAS";
+  case 0x11d1:    return "AURAVISION";
+  case 0x11d2:    return "INTERCOM INC.";
+  case 0x11d3:    return "TRANCELL SYSTEMS INC";
+  case 0x11d4:    return "ANALOG DEVICES";
+  case 0x11d5:    return "IKON CORPORATION";
+  case 0x11d6:    return "TEKELEC TELECOM";
+  case 0x11d7:    return "TRENTON TECHNOLOGY, INC.";
+  case 0x11d8:    return "IMAGE TECHNOLOGIES DEVELOPMENT";
+  case 0x11d9:    return "TEC CORPORATION";
+  case 0x11da:    return "NOVELL";
+  case 0x11db:    return "SEGA ENTERPRISES LTD";
+  case 0x11dc:    return "QUESTRA CORPORATION";
+  case 0x11dd:    return "CROSFIELD ELECTRONICS LIMITED";
+  case 0x11de:    return "ZORAN CORPORATION";
+  case 0x11df:    return "NEW WAVE PDG";
+  case 0x11e1:    return "GEC PLESSEY SEMI INC.";
+  case 0x11e2:    return "SAMSUNG INFORMATION SYSTEMS AMERICA";
+  case 0x11e3:    return "QUICKLOGIC CORPORATION";
+  case 0x11e4:    return "SECOND WAVE INC";
+  case 0x11e5:    return "IIX CONSULTING";
+  case 0x11e6:    return "MITSUI-ZOSEN SYSTEM RESEARCH";
+  case 0x11e8:    return "DIGITAL PROCESSING SYSTEMS INC.";
+  case 0x11ea:    return "ELSAG BAILEY";
+  case 0x11eb:    return "FORMATION INC.";
+  case 0x11ec:    return "CORECO INC";
+  case 0x11ed:    return "MEDIAMATICS";
+  case 0x11ee:    return "DOME IMAGING SYSTEMS INC";
+  case 0x11ef:    return "NICOLET TECHNOLOGIES B.V.";
+  case 0x11f0:    return "COMPU-SHACK GMBH";
+  case 0x11f1:    return "SYMBIOS LOGIC INC";
+  case 0x11f2:    return "PICTURE TEL JAPAN K.K.";
+  case 0x11f3:    return "KEITHLEY METRABYTE";
+  case 0x11f4:    return "KINETIC SYSTEMS CORPORATION";
+  case 0x11f5:    return "COMPUTING DEVICES INTERNATIONAL";
+  case 0x11f6:    return "POWERMATIC DATA SYSTEMS LTD";
+  case 0x11f7:    return "SCIENTIFIC ATLANTA";
+  case 0x11f8:    return "PMC-SIERRA INC";
+  case 0x11f9:    return "I-CUBE INC";
+  case 0x11fa:    return "KASAN ELECTRONICS COMPANY, LTD.";
+  case 0x11fb:    return "DATEL INC";
+  case 0x11fd:    return "HIGH STREET CONSULTANTS";
+  case 0x11fe:    return "COMTROL CORPORATION";
+  case 0x11ff:    return "SCION CORPORATION";
+  case 0x1200:    return "CSS CORPORATION";
+  case 0x1201:    return "VISTA CONTROLS CORP";
+  case 0x1202:    return "NETWORK GENERAL CORP.";
+  case 0x1203:    return "BAYER CORPORATION, AGFA DIVISION";
+  case 0x1204:    return "LATTICE SEMICONDUCTOR CORPORATION";
+  case 0x1205:    return "ARRAY CORPORATION";
+  case 0x1206:    return "AMDAHL CORPORATION";
+  case 0x1208:    return "PARSYTEC GMBH";
+  case 0x1209:    return "SCI SYSTEMS INC";
+  case 0x120a:    return "SYNAPTEL";
+  case 0x120b:    return "ADAPTIVE SOLUTIONS";
+  case 0x120d:    return "COMPRESSION LABS, INC.";
+  case 0x120e:    return "CYCLADES CORPORATION";
+  case 0x120f:    return "ESSENTIAL COMMUNICATIONS";
+  case 0x1210:    return "HYPERPARALLEL TECHNOLOGIES";
+  case 0x1211:    return "BRAINTECH INC";
+  case 0x1212:    return "KINGSTON TECHNOLOGY CORP.";
+  case 0x1213:    return "APPLIED INTELLIGENT SYSTEMS, INC.";
+  case 0x1214:    return "PERFORMANCE TECHNOLOGIES, INC.";
+  case 0x1215:    return "INTERWARE CO., LTD";
+  case 0x1216:    return "PURUP PREPRESS A/S";
+  case 0x1217:    return "02 MICRO, INC.";
+  case 0x1218:    return "HYBRICON CORP.";
+  case 0x1219:    return "FIRST VIRTUAL CORPORATION";
+  case 0x121a:    return "3DFX INTERACTIVE, INC.";
+  case 0x121b:    return "ADVANCED TELECOMM MODULES";
+  case 0x121c:    return "NIPPON TEXACO, LTD.";
+  case 0x121d:    return "LIPPERT AUTOMATIONSTECHNIK GMBH";
+  case 0x121e:    return "CSPI";
+  case 0x121f:    return "ARCUS TECHNOLOGY, INC.";
+  case 0x1220:    return "ARIEL CORPORATION";
+  case 0x1221:    return "CONTEC CO., LTD";
+  case 0x1222:    return "ANCOR COMMUNICATIONS, INC.";
+  case 0x1223:    return "HEURIKON/COMPUTER PRODUCTS";
+  case 0x1224:    return "INTERACTIVE IMAGES";
+  case 0x1225:    return "POWER I/O, INC.";
+  case 0x1227:    return "TECH-SOURCE";
+  case 0x1228:    return "NORSK ELEKTRO OPTIKK A/S";
+  case 0x1229:    return "DATA KINESIS INC.";
+  case 0x122a:    return "INTEGRATED TELECOM";
+  case 0x122b:    return "LG INDUSTRIAL SYSTEMS CO., LTD";
+  case 0x122c:    return "SICAN GMBH";
+  case 0x122d:    return "AZTECH SYSTEM LTD";
+  case 0x122e:    return "XYRATEX";
+  case 0x122f:    return "ANDREW CORPORATION";
+  case 0x1230:    return "FISHCAMP ENGINEERING";
+  case 0x1231:    return "WOODWARD McCOACH, INC.";
+  case 0x1232:    return "GPT LIMITED";
+  case 0x1233:    return "BUS-TECH, INC.";
+  case 0x1234:    return "TECHNICAL CORP.";
+  case 0x1235:    return "RISQ MODULAR SYSTEMS, INC.";
+  case 0x1236:    return "Sigma Designs Corporation";
+  case 0x1237:    return "ALTA TECHNOLOGY CORPORATION";
+  case 0x1238:    return "ADTRAN";
+  case 0x1239:    return "3DO COMPANY";
+  case 0x123a:    return "VISICOM LABORATORIES, INC.";
+  case 0x123b:    return "SEEQ TECHNOLOGY, INC.";
+  case 0x123c:    return "CENTURY SYSTEMS, INC.";
+  case 0x123d:    return "ENGINEERING DESIGN TEAM, INC.";
+  case 0x123e:    return "SIMUTECH, INC.";
+  case 0x123f:    return "C-CUBE MICROSYSTEMS";
+  case 0x1240:    return "MARATHON TECHNOLOGIES CORP.";
+  case 0x1241:    return "DSC COMMUNICATIONS";
+  case 0x1243:    return "DELPHAX";
+  case 0x1244:    return "AVM AUDIOVISUELLES MKTG & COMPUTER GMBH";
+  case 0x1245:    return "A.P.D., S.A.";
+  case 0x1246:    return "DIPIX TECHNOLOGIES, INC.";
+  case 0x1247:    return "XYLON RESEARCH, INC.";
+  case 0x1248:    return "CENTRAL DATA CORPORATION";
+  case 0x1249:    return "SAMSUNG ELECTRONICS CO., LTD.";
+  case 0x124a:    return "AEG ELECTROCOM GMBH";
+  case 0x124b:    return "GREENSPRING COMPUTERS INC.";
+  case 0x124c:    return "SOLITRON TECHNOLOGIES, INC.";
+  case 0x124d:    return "STALLION TECHNOLOGIES, INC.";
+  case 0x124e:    return "CYLINK";
+  case 0x124f:    return "INFORTREND TECHNOLOGY, INC.";
+  case 0x1250:    return "HITACHI MICROCOMPUTER SYSTEM LTD";
+  case 0x1251:    return "VLSI SOLUTION OY";
+  case 0x1253:    return "GUZIK TECHNICAL ENTERPRISES";
+  case 0x1254:    return "LINEAR SYSTEMS LTD.";
+  case 0x1255:    return "OPTIBASE LTD";
+  case 0x1256:    return "PERCEPTIVE SOLUTIONS, INC.";
+  case 0x1257:    return "VERTEX NETWORKS, INC.";
+  case 0x1258:    return "GILBARCO, INC.";
+  case 0x1259:    return "ALLIED TELESYN INTERNATIONAL";
+  case 0x125a:    return "ABB POWER SYSTEMS";
+  case 0x125b:    return "ASIX ELECTRONICS CORPORATION";
+  case 0x125c:    return "AURORA TECHNOLOGIES, INC.";
+  case 0x125d:    return "ESS TECHNOLOGY";
+  case 0x125e:    return "SPECIALVIDEO ENGINEERING SRL";
+  case 0x125f:    return "CONCURRENT TECHNOLOGIES, INC.";
+  case 0x1260:    return "HARRIS SEMICONDUCTOR";
+  case 0x1261:    return "MATSUSHITA-KOTOBUKI ELECTRONICS INDUSTRIES, ";
+  case 0x1262:    return "ES COMPUTER COMPANY, LTD.";
+  case 0x1263:    return "SONIC SOLUTIONS";
+  case 0x1264:    return "AVAL NAGASAKI CORPORATION";
+  case 0x1265:    return "CASIO COMPUTER CO., LTD.";
+  case 0x1266:    return "MICRODYNE CORPORATION";
+  case 0x1267:    return "S. A. TELECOMMUNICATIONS";
+  case 0x1268:    return "TEKTRONIX";
+  case 0x1269:    return "THOMSON-CSF/TTM";
+  case 0x126a:    return "LEXMARK INTERNATIONAL, INC.";
+  case 0x126b:    return "ADAX, INC.";
+  case 0x126c:    return "NORTHERN TELECOM";
+  case 0x126d:    return "SPLASH TECHNOLOGY, INC.";
+  case 0x126e:    return "SUMITOMO METAL INDUSTRIES, LTD.";
+  case 0x126f:    return "SILICON MOTION, INC.";
+  case 0x1270:    return "OLYMPUS OPTICAL CO., LTD.";
+  case 0x1271:    return "GW INSTRUMENTS";
+  case 0x1272:    return "TELEMATICS";
+  case 0x1273:    return "HUGHES NETWORK SYSTEMS";
+  case 0x1274:    return "ENSONIQ";
+  case 0x1275:    return "NETWORK APPLIANCE CORPORATION";
+  case 0x1276:    return "SWITCHED NETWORK TECHNOLOGIES, INC.";
+  case 0x1277:    return "COMSTREAM";
+  case 0x1278:    return "TRANSTECH PARALLEL SYSTEMS LTD.";
+  case 0x1279:    return "TRANSMETA CORPORATION";
+  case 0x127a:    return "ROCKWELL INTERNATIONAL";
+  case 0x127b:    return "PIXERA CORPORATION";
+  case 0x127c:    return "CROSSPOINT SOLUTIONS, INC.";
+  case 0x127d:    return "VELA RESEARCH";
+  case 0x127e:    return "WINNOV, L.P.";
+  case 0x127f:    return "FUJIFILM";
+  case 0x1280:    return "PHOTOSCRIPT GROUP LTD.";
+  case 0x1281:    return "YOKOGAWA ELECTRIC CORPORATION";
+  case 0x1282:    return "DAVICOM SEMICONDUCTOR, INC.";
+  case 0x1283:    return "INTEGRATED TECHNOLOGY EXPRESS, INC.";
+  case 0x1284:    return "SAHARA NETWORKS, INC.";
+  case 0x1285:    return "PLATFORM TECHNOLOGIES, INC.";
+  case 0x1286:    return "MAZET GMBH";
+  case 0x1287:    return "M-PACT, INC.";
+  case 0x1288:    return "TIMESTEP CORPORATION";
+  case 0x1289:    return "AVC TECHNOLOGY, INC.";
+  case 0x128a:    return "ASANTE TECHNOLOGIES, INC.";
+  case 0x128b:    return "TRANSWITCH CORPORATION";
+  case 0x128c:    return "RETIX CORPORATION";
+  case 0x128d:    return "G2 NETWORKS, INC.";
+  case 0x128e:    return "SAMHO MULTI TECH LTD.";
+  case 0x128f:    return "TATENO DENNOU, INC.";
+  case 0x1290:    return "SORD COMPUTER CORPORATION";
+  case 0x1291:    return "NCS COMPUTER ITALIA";
+  case 0x1292:    return "TRITECH MICROELECTRONICS  INTERNATIONAL PTE. ";
+  case 0x1293:    return "MEDIA REALITY TECHNOLOGY";
+  case 0x1294:    return "RHETOREX, INC.";
+  case 0x1295:    return "IMAGENATION CORPORATION";
+  case 0x1296:    return "KOFAX IMAGE PRODUCTS";
+  case 0x1297:    return "HOLCO ENT CO, LTD/SHUTTLE COMPUTER";
+  case 0x1298:    return "SPELLCASTER TELECOMMUNICATIONS INC.";
+  case 0x1299:    return "KNOWLEDGE TECHNOLOGY LAB.";
+  case 0x129a:    return "VMETRO, INC.";
+  case 0x129b:    return "IMAGE ACCESS";
+  case 0x129c:    return "JAYCOR";
+  case 0x129d:    return "COMPCORE MULTIMEDIA, INC.";
+  case 0x129e:    return "VICTOR COMPANY OF JAPAN, LTD.";
+  case 0x129f:    return "OEC MEDICAL SYSTEMS, INC.";
+  case 0x12a0:    return "ALLEN- BRADLEY COMPANY";
+  case 0x12a1:    return "SIMPACT ASSOCIATES, INC.";
+  case 0x12a2:    return "NEWGEN SYSTEMS CORPORATION";
+  case 0x12a3:    return "LUCENT TECHNOLOGIES";
+  case 0x12a4:    return "NTT ELECTRONICS TECHNOLOGY COMPANY";
+  case 0x12a5:    return "VISION DYNAMICS LTD.";
+  case 0x12a6:    return "SCALABLE NETWORKS, INC.";
+  case 0x12a7:    return "AMO GMBH";
+  case 0x12a8:    return "NEWS DATACOM";
+  case 0x12a9:    return "XIOTECH CORPORATION";
+  case 0x12aa:    return "SDL COMMUNIATIONS, INC.";
+  case 0x12ab:    return "YUAN YUAN ENTERPRISE CO., LTD.";
+  case 0x12ac:    return "MEASUREX CORPORATION";
+  case 0x12ad:    return "MULTIDATA GMBH";
+  case 0x12ae:    return "Alteon Networks Inc.";
+  case 0x12af:    return "TDK USA Corp";
+  case 0x12b0:    return "Jorge Scientific Corp";
+  case 0x12b1:    return "GammaLink";
+  case 0x12b2:    return "General Signal Networks";
+  case 0x12b3:    return "Inter-Face Co Ltd";
+  case 0x12b4:    return "FutureTel Inc";
+  case 0x12b5:    return "Granite Systems Inc.";
+  case 0x12b6:    return "NATURAL MICROSYSTEMS";
+  case 0x12b7:    return "ACUMEN";
+  case 0x12b8:    return "Korg";
+  case 0x12b9:    return "US Robotics";
+  case 0x12ba:    return "PMC Sierra";
+  case 0x12bb:    return "NIPPON UNISOFT CORPORATION";
+  case 0x12bc:    return "ARRAY MICROSYSTEMS";
+  case 0x12bd:    return "COMPUTERM CORP.";
+  case 0x12be:    return "Anchor Chips";
+  case 0x12bf:    return "Fujifilm Microdevices";
+  case 0x12c0:    return "INFIMED";
+  case 0x12c1:    return "GMM Research Corp";
+  case 0x12c2:    return "Mentec Limited";
+  case 0x12c3:    return "Holtek Microelectronics Inc";
+  case 0x12c4:    return "Connect Tech Inc";
+  case 0x12c5:    return "PICTURE ELEMENTS";
+  case 0x12c6:    return "Mitani Corporation";
+  case 0x12c7:    return "Dialogic Corp";
+  case 0x12c8:    return "G Force Co, Ltd";
+  case 0x12c9:    return "Gigi Operations";
+  case 0x12ca:    return "Integrated Computing Engines";
+  case 0x12cb:    return "ANTEX ELECTRONICS CORPORATION";
+  case 0x12cc:    return "PLUTO TECHNOLOGIES INTERNATIONAL";
+  case 0x12cd:    return "Aims Lab";
+  case 0x12ce:    return "NETSPEED INC.";
+  case 0x12cf:    return "PROPHET SYSTEMS, INC.";
+  case 0x12d0:    return "GDE SYSTEMS, INC.";
+  case 0x12d1:    return "PSITECH";
+  case 0x12d2:    return "Nvidia/SGS Thomson";
+  case 0x12d3:    return "Vingmed Sound A/S";
+  case 0x12d4:    return "DGM&S";
+  case 0x12d5:    return "Equator Technologies";
+  case 0x12d6:    return "Analogic Corp";
+  case 0x12d7:    return "Biotronic SRL";
+  case 0x12d8:    return "PERICOM SEMICONDUCTOR";
+  case 0x12d9:    return "Aculab PLC";
+  case 0x12da:    return "True Time";
+  case 0x12db:    return "Annapolis Micro Systems, Inc";
+  case 0x12dc:    return "Symicron Computer Connumiaction Ltd.";
+  case 0x12dd:    return "Management Graphics";
+  case 0x12de:    return "Rainbow Technologies";
+  case 0x12df:    return "SBS Technologies Inc";
+  case 0x12e0:    return "Chase Research";
+  case 0x12e1:    return "Nintendo Co, Ltd";
+  case 0x12e2:    return "Datum Inc. Bancomm-Timing Division";
+  case 0x12e3:    return "Imation Corp - Medical Imaging Systems";
+  case 0x12e4:    return "Brooktrout Technology Inc";
+  case 0x12e5:    return "Apex Inc";
+  case 0x12e6:    return "Cirel Systems";
+  case 0x12e7:    return "SUNSGROUP CORPORATION";
+  case 0x12e8:    return "CRISC Corp";
+  case 0x12e9:    return "GE Spacenet";
+  case 0x12ea:    return "Zuken";
+  case 0x12eb:    return "AUREAL SEMICONDUCTOR";
+  case 0x12ec:    return "3A INTERNATIONAL, INC.";
+  case 0x12ed:    return "Optivision Inc.";
+  case 0x12ee:    return "Orange Micro";
+  case 0x12ef:    return "Vienna Systems";
+  case 0x12f0:    return "PENTEK";
+  case 0x12f1:    return "Sorenson Vision Inc";
+  case 0x12f2:    return "GAMMAGRAPHX, INC.";
+  case 0x12f3:    return "XING INC.";
+  case 0x12f4:    return "Megatel";
+  case 0x12f5:    return "Forks";
+  case 0x12f6:    return "Dawson France";
+  case 0x12f7:    return "COGNEX";
+  case 0x3d3d:    return "3DLABS LIMITED";
+  case 0x3d:      return "LOCKHEED MARTIN";
+  case 0x4005:    return "AVANCE LOGIC INC";
+  case 0x4680:    return "UMAX Computer Corp";
+  case 0x4754:    return "TRITECH MICROELECTRONICS";
+  case 0x5333:    return "S3 INC.";
+  case 0x8086:    return "Intel Corp.";
+  case 0x8888:    return "SILICON MAGIC";
+  case 0x8e0e:    return "COMPUTONE CORPORATION";
+  case 0x9004:    return "ADAPTEC";
+  case 0xc0fe:    return "MOTION ENGINEERING, INC.";
+  case 0xe11:     return "COMPAQ COMPUTER CORP.";
+  case 0xedd8:    return "ARK LOGIC INC";
+  default:                return "???";
+  }
+} /* end pciGetVendorName() */
+
Index: trunk/src/opengl/glide/swlibs/pcilib/fxlinux.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxlinux.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxlinux.c	(revision 2887)
@@ -0,0 +1,377 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <3dfx.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+
+/* There are a few minor differences for portio between libc5 and
+ * glibc2 
+ * libc5: unistd.h (included above) has the declaration of
+ *        iopl() and asm/io.h has the declarations of inb, inw, inl and such.
+ * glibc2: sys/io.h has the declaration of iopl() and includes
+ *         asm/io.h for us */
+#if __GNU_LIBRARY__ <= 5
+#include <asm/io.h>
+#else
+#include <sys/io.h>
+#endif
+
+#include <fcntl.h>
+#include "fxpci.h"
+#include "pcilib.h"
+
+static const char* pciIdentifyLinux(void);
+static FxBool pciOutputStringLinux(const char *msg);
+static FxBool pciInitializeLinux(void);
+static FxBool pciShutdownLinux(void);
+static FxBool pciMapLinearLinux(FxU32, FxU32 physical_addr, FxU32 *linear_addr,
+				FxU32 *length);
+static FxBool pciUnmapLinearLinux(FxU32 linear_addr, FxU32 length);
+static FxBool pciSetPermissionLinux(const FxU32, const FxU32, const FxBool);
+static FxU8 pciPortInByteLinux(unsigned short port);
+static FxU16 pciPortInWordLinux(unsigned short port);
+static FxU32 pciPortInLongLinux(unsigned short port);
+static FxBool pciPortOutByteLinux(unsigned short port, FxU8 data);
+static FxBool pciPortOutWordLinux(unsigned short port, FxU16 data);
+static FxBool pciPortOutLongLinux(unsigned short port, FxU32 data);
+static FxBool pciMsrGetLinux(MSRInfo *, MSRInfo *);
+static FxBool pciMsrSetLinux(MSRInfo *, MSRInfo *);
+static FxBool pciSetPassThroughBaseLinux(FxU32 *, FxU32);
+
+const FxPlatformIOProcs ioProcsLinux = {
+  pciInitializeLinux,
+  pciShutdownLinux,
+  pciIdentifyLinux,
+
+  pciPortInByteLinux,
+  pciPortInWordLinux,
+  pciPortInLongLinux,
+
+  pciPortOutByteLinux,
+  pciPortOutWordLinux,
+  pciPortOutLongLinux,
+
+  pciMapLinearLinux,
+  pciUnmapLinearLinux,
+  pciSetPermissionLinux,
+
+  pciMsrGetLinux,
+  pciMsrSetLinux,
+
+  pciOutputStringLinux,
+  pciSetPassThroughBaseLinux
+};
+
+static const FxU32 PCI_VENDOR_ID_LINUX = 0x0;
+static const FxU32 PCI_DEVICE_ID_LINUX = 0x2;
+static const FxU32 PCI_COMMAND_LINUX = 0x4;
+static const FxU32 PCI_BASE_ADDRESS_0_LINUX = 0x10;
+static const FxU32 SST1_PCI_INIT_ENABLE_LINUX = 0x40;
+static const FxU32 SST1_PCI_BUS_SNOOP0_LINUX = 0x44;
+static const FxU32 SST1_PCI_BUS_SNOOP1_LINUX = 0x48;
+
+static int linuxDevFd=-1;
+
+struct pioData {
+  short port;
+  short size;
+  int device;
+  void *value;
+};
+
+FxBool
+pciPlatformInit(void)
+{
+  gCurPlatformIO = &ioProcsLinux;
+  return FXTRUE;
+}
+
+FxBool 
+hasDev3DfxLinux(void) 
+{
+  if (linuxDevFd==-1) return FXFALSE;
+  return FXTRUE;
+}
+
+FxU32
+pciFetchRegisterLinux( FxU32 cmd, FxU32 size, FxU32 device) 
+{
+  struct pioData desc;
+  char cval;
+  short sval;
+  int ival;
+
+  if (linuxDevFd==-1) return -1;
+  desc.port=cmd;
+  desc.size=size;
+  desc.device=device;
+  switch (size) {
+  case 1:
+    desc.value=&cval;
+    break;
+  case 2:
+    desc.value=&sval;
+    break;
+  case 4:
+    desc.value=&ival;
+    break;
+  default:
+    return 0;
+  }
+  if (ioctl(linuxDevFd, _IOR('3', 3, sizeof(struct pioData)), &desc)==-1)
+    return 0;
+  switch (size) {
+  case 1:
+    return cval;
+  case 2:
+    return sval;
+  case 4:
+    return ival;
+  default:
+    return 0;
+  }
+}
+
+FxBool
+pciUpdateRegisterLinux(FxU32 cmd, FxU32 data, FxU32 size, FxU32 device) 
+{
+  struct pioData desc;
+
+  if (linuxDevFd==-1) return -1;
+  desc.port=cmd;
+  desc.size=size;
+  desc.device=device;
+  desc.value=&data;
+  if (ioctl(linuxDevFd, _IOW('3', 4, sizeof(struct pioData)), &desc)==-1)
+    return FXFALSE;
+  return FXTRUE;
+}
+
+int 
+getNumDevicesLinux(void) 
+{
+  if (linuxDevFd==-1) return -1;
+  return ioctl(linuxDevFd, _IO('3', 2));
+}
+
+static const char*
+pciIdentifyLinux(void)
+{
+  return "fxPCI for Linux";
+}
+
+static FxBool 
+pciOutputStringLinux(const char *msg) 
+{
+  printf(msg);
+  return FXTRUE;
+}
+
+static FxBool 
+pciInitializeLinux(void)
+{
+  if (!getenv("SST_NO_DEV3DFX")) linuxDevFd=open("/dev/3dfx", O_RDWR, 0);
+  if (linuxDevFd==-1) {
+    if (iopl(3)<0) {
+      pciErrorCode = PCI_ERR_NO_IO_PERM;
+      return FXFALSE;
+    }
+  }
+  return FXTRUE;
+}
+
+static FxBool 
+pciShutdownLinux(void)
+{
+  if (linuxDevFd>=0) {
+    close(linuxDevFd);
+  } else {
+    iopl(0);
+  }
+  return FXTRUE;
+}
+
+static FxBool 
+pciMapLinearLinux(FxU32 bus, FxU32 physical_addr,
+		  FxU32 *linear_addr, FxU32 *length) 
+{
+  int fd;
+  if (linuxDevFd!=-1) {
+    fd=linuxDevFd;
+  } else {
+    if ((fd=open("/dev/mem", O_RDWR))<0) {
+      pciErrorCode=PCI_ERR_NO_MEM_PERM;
+      return FXFALSE;
+    }
+  }
+  if (((*linear_addr)=(FxU32)mmap(0, *length, PROT_READ|PROT_WRITE,
+				  MAP_SHARED, fd, physical_addr))<0) {
+    if (fd!=linuxDevFd) close(fd);
+    return FXFALSE;
+  }
+  if (fd!=linuxDevFd) close(fd);
+  return FXTRUE;
+}
+
+static FxBool
+pciUnmapLinearLinux(FxU32 linear_addr, FxU32 length) 
+{
+  munmap((void*)linear_addr, length);
+  return FXTRUE;
+}
+
+static FxBool
+pciSetPermissionLinux(const FxU32 addrBase, const FxU32 addrLen, 
+		      const FxBool writePermP)
+{
+  return FXTRUE;
+}
+
+static FxU8 
+pciPortInByteLinux(unsigned short port) 
+{
+  char tmp;
+  struct pioData desc;
+
+  if (linuxDevFd==-1) {
+    tmp=inb(port);
+    /* fprintf(stderr, "Read byte at %x got %d\n", port, tmp); */
+    return tmp;
+  }
+  desc.port=port;
+  desc.size=sizeof(tmp);
+  desc.value=&tmp;
+  /* fprintf(stderr, "Read byte desc at %x tmp at %x\n", &desc, &tmp); */
+  ioctl(linuxDevFd, _IOR(0, 0, sizeof(struct pioData)), &desc);
+  /* fprintf(stderr, "Got byte %d versus %d\n", tmp, inb(port)); */
+  return tmp;
+}
+
+static FxU16 
+pciPortInWordLinux(unsigned short port) 
+{
+  short tmp;
+  struct pioData desc;
+
+  if (linuxDevFd==-1) {
+    tmp=inw(port);
+    /* fprintf(stderr, "Read word at %x got %x\n", port, tmp); */
+    return tmp;
+  }
+  desc.port=port;
+  desc.size=sizeof(tmp);
+  desc.value=&tmp;
+  /* fprintf(stderr, "Read word desc at %x tmp at %x\n", &desc, &tmp); */
+  ioctl(linuxDevFd, _IOR(0, 0, sizeof(struct pioData)), &desc);
+  /* fprintf(stderr, "Got word %d versus %d\n", tmp, inw(port)); */
+  return tmp;
+}
+
+static FxU32 
+pciPortInLongLinux(unsigned short port) 
+{
+  int tmp;
+  struct pioData desc;
+
+  if (linuxDevFd==-1) {
+    tmp=inl(port);
+    /* fprintf(stderr, "Read long at %x got %x\n", port, tmp); */
+    return tmp;
+  }
+  desc.port=port;
+  desc.size=sizeof(tmp);
+  desc.value=&tmp;
+  /* fprintf(stderr, "Read long desc at %x tmp at %x\n", &desc, &tmp); */
+  ioctl(linuxDevFd, _IOR(0, 0, sizeof(struct pioData)), &desc);
+  /* fprintf(stderr, "Got long %x versus %x\n", tmp, inl(port)); */
+  return tmp;
+}
+
+static FxBool 
+pciPortOutByteLinux(unsigned short port, FxU8 data) 
+{
+  struct pioData desc;
+  /* fprintf(stderr, "write byte=%d desc at %x data at %x\n", data,
+      &desc, &data); */
+  if (linuxDevFd==-1) {
+    outb(data, port);
+    return FXTRUE;
+  }
+  desc.port=port;
+  desc.size=sizeof(data);
+  desc.value=&data;
+  return ioctl(linuxDevFd, _IOW(0, 1, sizeof(struct pioData)), &desc)!=-1;
+}
+
+static FxBool 
+pciPortOutWordLinux(unsigned short port, FxU16 data) 
+{
+  struct pioData desc;
+  /* fprintf(stderr, "write word=%x to port=%x desc at %x data at %x\n", 
+	  data, port, &desc, &data); */
+  if (linuxDevFd==-1) {
+    outw(data, port);
+    return FXTRUE;
+  }
+  desc.port=port;
+  desc.size=sizeof(data);
+  desc.value=&data;
+  return ioctl(linuxDevFd, _IOW(0, 1, sizeof(struct pioData)), &desc)!=-1;
+}
+
+static FxBool 
+pciPortOutLongLinux(unsigned short port, FxU32 data) 
+{
+  struct pioData desc;
+  /* fprintf(stderr, "write long=%x to port=%x desc at %x data at %x\n", 
+	  data, port, &desc, &data); */
+  if (linuxDevFd==-1) {
+    outl(data, port);
+    return FXTRUE;
+  }
+  desc.port=port;
+  desc.size=sizeof(data);
+  desc.value=&data;
+  return ioctl(linuxDevFd, _IOW(0, 1, sizeof(struct pioData)), &desc)!=-1;
+}
+
+static FxBool
+pciMsrGetLinux(MSRInfo *in, MSRInfo *out)
+{
+  return FXTRUE;
+}
+
+static FxBool
+pciMsrSetLinux(MSRInfo *in, MSRInfo *out)
+{
+  return FXTRUE;
+}
+
+static FxBool
+pciSetPassThroughBaseLinux(FxU32 *baseAddr, FxU32 baseAddrLen)
+{
+  return FXTRUE;
+}
Index: trunk/src/opengl/glide/swlibs/pcilib/fxlinux.h
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxlinux.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxlinux.h	(revision 2887)
@@ -0,0 +1,33 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+#ifndef _FXLINUX_H_
+#define _FXLINUX_H_
+
+int getNumDevicesLinux(void);
+
+FxBool pciPlatformInit(void);
+
+FxBool hasDev3DfxLinux(void);
+
+FxU32 pciFetchRegisterLinux( FxU32 cmd, FxU32 size, FxU32 device);
+
+int pciUpdateRegisterLinux(FxU32 cmd, FxU32 data, FxU32 size, FxU32 device);
+
+#endif
Index: trunk/src/opengl/glide/swlibs/pcilib/fxmsr.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxmsr.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxmsr.c	(revision 2887)
@@ -0,0 +1,531 @@
+/*
+ ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+ ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+ ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+ ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+ ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+ ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+ ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+ ** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+ ** 
+ ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+ ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+ ** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+ ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+ ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+ ** THE UNITED STATES.  
+ ** 
+ ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+ **
+ **
+ ** $Revision: 1.1 $ 
+ ** $Date: 2000-02-25 00:33:55 $ 
+ **
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <3dfx.h>
+#define FX_DLL_DEFINITION
+#include <fxdll.h>
+#include <fxmemmap.h>
+#include "fxpci.h"
+#include "pcilib.h"
+
+#if __WIN32__
+#include <windows.h>
+#include "fxw32.h"
+#elif defined(__DOS32__)
+#include <fxdpmi.h>
+#endif
+
+/*---------------------------------------------------------------------------
+**
+**  MTRR Code
+**
+**  It's possible that this code belongs elsewhere, but since it
+**  communicates with the VXD, it needs to be in here for now.  If at
+**  some later date, we rearchitecth the whole VXD thing, then we
+**  should revisit this code and find a good place for it.
+*----------------------------------------------------------------------------*/
+
+#define MTRR_VALID         0x800
+#define MTRR_BASE_FIRST    0x200
+#define MTRR_MASK_FIRST    0x201
+#define MTRR_BASE_LAST     0x20e
+#define MTRR_MASK_LAST     0x20f
+
+/* NB: Although the intel docs say that the last 2 mtrr's are reserved for
+ * os use only win9x doesn't play nice and claims entries in the 'user' range.
+ * To make things as happy as possible we search the entire mtrr range.
+ */
+#define MTRR_FIRST         0
+#define MTRR_LAST          7
+
+/* AMD K6 has only two MTRRs */
+#define MTRR_LAST_AMDK6    1
+
+#define MTRRPHYSBASE2MSR(mtrr)  ((mtrr << 1) + MTRR_BASE_FIRST)
+#define MTRRPHYSMASK2MSR(mtrr)  ((mtrr << 1) + MTRR_MASK_FIRST)
+#define MSR2MTRR(msr)  (((msr) - 0x201) >> 1)
+
+/*
+**  A Note On MTRRs:
+**
+**  MTRRs are special cases of MSRs (model specific registers).  They
+**  work in pairs, specified as follows (the number is the MSR number):
+*/
+#define MTRR_PHYSBASE_0    0x200
+#define MTRR_PHYSMASK_0    0x201
+#define MTRR_PHYSBASE_1    0x202
+#define MTRR_PHYSMASK_1    0x203
+#define MTRR_PHYSBASE_2    0x204
+#define MTRR_PHYSMASK_2    0x205
+#define MTRR_PHYSBASE_3    0x206
+#define MTRR_PHYSMASK_3    0x207
+#define MTRR_PHYSBASE_4    0x208
+#define MTRR_PHYSMASK_4    0x209
+#define MTRR_PHYSBASE_5    0x20a
+#define MTRR_PHYSMASK_5    0x20b
+
+/*
+** The MTRRs of the AMD K6 are not compatible to the MTRRs on Intel
+** processors. There are two MTRRs which are in a single MSR.
+*/
+
+#define MTRR_MSR_AMDK6     0xC0000085
+
+/*
+**  So, the PHYSBASE_N is the base address for a particular MTRR and
+**  uses a whole MSR.  It has the type encoded in the bottom three
+**  nibbles (12 bits).
+**
+**  The PHYSMASK_N is the physical mask for a particular MTRR and uses
+**  the MSR immediately following the MSR which specifies the physical
+**  base and type.
+**
+**  See the headers of the functions genPhysBase and genPhysMask to
+**  find out how to generate the PhysBase value and the PhysMask
+**  value.  If you want to see the place from which this information
+**  was obtained, refer to the document Pentium(r) Pro Family
+**  Developer's Manual Volume 3: Operating System Writer's Guide,
+**  Chpater 11:  Memory Cache Control.  Note that the terms PhysBase
+**  and PhysMask come from there.
+*/
+
+/* genPhysBase - Generate PhysBase 
+**
+**  MTRRPhysBase:
+**  Bits 7:0     Memory Type
+**  Bits 11:8    Reserved
+**  Bits 35:12   PhysBase
+**  Bits 63:36   Reserved
+**
+**  The Intel P6 documentation pines away about how the PhysBase field
+**  of this register contains an integer power of two multiple of
+**  0x1000, but guess what?  The number (if it has a legal value) is
+**  already set up that way, so, we just leave it TF alone, and then
+**  OR in the type (the types specified in fxpci.h match the Intel
+**  P6 mem types indentically).  
+*/
+static FxBool 
+genPhysBase(FxU32 physBaseAddress, PciMemType type, FxU32 *physBase) 
+{
+  FxBool
+    ret = FXFALSE;
+
+  /* Validate type */
+  switch (type) {
+  case PciMemTypeUncacheable:
+  case PciMemTypeWriteCombining:
+  case PciMemTypeWriteThrough:
+  case PciMemTypeWriteProtected:
+  case PciMemTypeWriteback:
+    break;
+  default:
+    /* Invalid Type */
+    return ret;
+    break;
+  }
+
+  /* Validate base address -- make sure it's on a 4K boundary */
+  if (physBaseAddress & 0xfff) { 
+    /* Invalid start address */
+    return ret;
+  }
+
+  /* 
+  **  We now have a valid size and type.
+  **  Generate the MTRR value for PhysBase.
+  */
+  *physBase = physBaseAddress | type;
+
+  return (ret = FXTRUE);
+
+} /* genPhysBase */
+
+/*  genPhysMask - Generate PhysMask:
+**
+**  MTRRPhysMask:
+**  Bits 10:0    Reserved
+**  Bit  11      Valid
+**  Bits 35:12   PhysMask
+**  Bits 63:36   Reserved
+**
+**  The PhysMask field works as follows:
+**  from Bit 12 to bit 35, there are N zeros, and m ones, where n is
+**  the power of two to multiply by 4069 to get the size you want,
+**  and m is 35 - n.   i.e.:
+**
+**  size = 2^n * 0x1000
+**  m = 35 - m
+**
+**  Since we have the lowBit from above, we know which power of 2
+**  the size is, so we simply need to shift it right by 12 to see
+**  how many of the bits between 12 an 35 are 0.  We then shift
+**  0xffffffff left by that many bits to get the right mask.
+**
+*/
+static FxBool
+genPhysMask(FxU32 physSize, FxU32 *physMask)
+{
+  FxBool
+    ret = FXFALSE;
+
+  FxU32
+    bitRes,
+    lowBit;
+
+  /*
+  **  Validate size
+  **
+  **  Size must be an integer power of 2, and it must be greater than
+  **  4K (4096d, 1000h, 10000o, 1000000000000b :-)
+  */
+
+  /* Do it this way instead of a mask, so we find zero if it's there */
+  if (physSize < 0x1000) {
+    /* invalid size */
+    return ret;
+  }
+    
+  /*
+  ** Make sure it's an integer power of 2:
+  ** Any power of 2 (except 0) ANDed with its
+  ** integer predecessor is always 0.
+  */ 
+  if (physSize & (physSize - 1)) {
+    return ret;
+  }
+
+  /* Find the lowest bit set in physSize */
+  lowBit = 11;
+  do {
+    ++lowBit;    
+    bitRes = (physSize >> lowBit) & 1;
+  } while ((bitRes == 0) && (lowBit < 0x20));
+
+  
+  /* See above for explanation of 0x800 (2**11) */
+  *physMask =  (0xffffffff << lowBit) | MTRR_VALID;  
+  
+  return (ret = FXTRUE);
+
+} /* genPhysMask */
+
+/* Computes bit pattern to program into a K6-style MTRR based on the desired
+** memory range base address, size, and type. Returns FXFALSE if memory type
+** unsupported, block size out of range, or block size not power of 2, or
+** base address not multiple of block size.
+*/
+
+static FxBool
+genMTRRvalAmdK6(FxU32 physBaseAddress, FxU32 physSize, PciMemType type, FxU32 *MTRRval)
+{
+   FxBool retVal = FXFALSE;
+   FxU32 memTypeBits = 0;
+   FxU32 physAddrMask;
+
+   /* Validate memory type */
+
+   if (type == PciMemTypeUncacheable) {
+      memTypeBits = 0x1;
+   }
+   else if (type == PciMemTypeWriteCombining) {
+      memTypeBits = 0x2;
+   }
+   else {
+      return retVal;
+   }
+
+   /* Validate memory range size */
+
+   if (physSize < 128*1024) {         /* make sure size >= 128 K */ 
+      return retVal;
+   }
+
+   if (physSize & (physSize - 1)) {   /* make sure size is power of two */
+      return retVal;
+   }
+
+   /* Validate base address */
+
+   if (physBaseAddress % physSize) {  /* make sure base is multiple of size */
+      return retVal;
+   }
+
+   /* Convert the range size into a mask */
+
+   physAddrMask = 0x7FFF;
+   physSize >>=18;            /* 128K --> 0, 256K --> 1, etc */
+   while (physSize) {
+      physAddrMask <<= 1;
+      physSize     >>= 1;
+   }
+
+   /* Now mask: 128K => 7FFF, 256K => 7FFE, 512K => 7FFC, ... , 4G => 0000 */
+
+   *MTRRval = (((physBaseAddress >> 17) & 0x7FFF) << 17) |
+              (physAddrMask & 0x7FFF) << 2        |
+              memTypeBits;
+
+   retVal = FXTRUE;
+
+   return retVal;
+}
+
+/*
+**  pciFindMTRRMatch - find an MTRR that matches this one.
+**
+**  We return the MTRR number which is a special-case MSR calculated
+**  in the following manner:
+**
+**  (matchBaseMSR - baseMTRR0) >> 2
+*/
+FX_EXPORT FxBool FX_CSTYLE
+pciFindMTRRMatch(FxU32 physBaseAddress, FxU32 physSize,
+                 PciMemType type, FxU32 *mtrrNum)
+{
+  FxBool
+    res,
+    foundMSR = FXFALSE,
+    rVal = FXFALSE;
+
+  FxU32
+    lMTRR,
+    physBase, physMask;
+
+  MSRInfo
+    inS, outS;
+
+  /* Get PhysBase */
+  res = genPhysBase(physBaseAddress, type, &physBase);
+
+  if (res == FXFALSE)
+    return rVal;
+
+  /* Get PhysMask */
+  res = genPhysMask(physSize, &physMask);
+
+  if (res == FXFALSE)
+    return rVal;
+  
+  inS.msrNum = MTRR_BASE_FIRST;
+
+  lMTRR = 0;
+
+  do {
+    DOGETMSR(inS,outS);
+
+    if (outS.msrLo == physBase) {
+      inS.msrNum++;
+
+      DOGETMSR(inS, outS);
+
+      if (outS.msrLo == physMask) {
+        *mtrrNum = MSR2MTRR(inS.msrNum);
+        foundMSR = FXTRUE;
+      }
+    }
+    inS.msrNum++;
+  } while (!foundMSR && (inS.msrNum <= MTRR_BASE_LAST));
+
+  if (foundMSR)
+    rVal = FXTRUE;
+
+  return rVal;  
+} /* pciFindMTRRMatch */
+
+/*
+**  pciFindFreeMTRR - find an MTRR that matches this one.
+**
+**  We return the MTRR number which is a special-case MSR calculated
+**  in the following manner:
+**
+**  (freeBaseMSR - baseMTRR0) >> 2
+**
+**  NOTE:  This routine will return the lowest-numbered free MTRR
+*/
+FX_EXPORT FxBool FX_CSTYLE
+pciFindFreeMTRR(FxU32 *mtrrNum)
+{
+  FxBool
+    foundFree = FXFALSE;
+
+  MSRInfo
+    inS, outS;
+
+  for (
+       inS.msrNum = MTRR_BASE_FIRST + 1;
+       (inS.msrNum < MTRR_BASE_LAST + 1) && !foundFree;
+       inS.msrNum += 2
+       ) {
+
+    DOGETMSR(inS, outS);
+
+    if ((outS.msrLo & 0x800) == 0) {
+      foundFree = FXTRUE;
+      *mtrrNum = MSR2MTRR(inS.msrNum);
+    }
+  }
+
+  return foundFree;
+} /* pciFindFreeMTRR */
+
+/*
+**  pciSetMTRR - set up a specified MTRR based on physical address, physical
+**               size, and type.
+**
+**  NOTE:  A zero for the physical size results in the MTRR being
+**  cleared. 
+**
+*/
+FX_EXPORT FxBool FX_CSTYLE
+pciSetMTRR(FxU32 mtrrNum, FxU32 physBaseAddr, FxU32 physSize,
+           PciMemType type)
+{
+  FxBool
+    res, 
+    rVal = FXFALSE;
+
+  FxU32
+    physBase, physMask;
+
+  MSRInfo
+    inS, outS;
+
+  if (mtrrNum > MTRR_LAST)
+    return rVal;
+
+
+  inS.msrNum = MTRRPHYSBASE2MSR(mtrrNum);
+
+  if (physSize == 0) {
+    /* Clear the MTRR */
+    
+    inS.msrLo = 0x0;
+    inS.msrHi = 0x0;
+
+
+    DOSETMSR(inS, outS);
+
+    inS.msrNum++;
+
+    DOSETMSR(inS, outS);
+    
+  } else {
+    /* Generate masks and set the MTRR */
+
+    res = genPhysBase(physBaseAddr, type, &physBase);
+    if (res == FXFALSE)
+      return rVal;
+
+    res = genPhysMask(physSize, &physMask);
+    
+    inS.msrLo = physBase;
+    inS.msrHi = 0x0;
+    
+    DOSETMSR(inS, outS);
+
+    inS.msrNum++;
+    inS.msrLo = physMask;
+    inS.msrHi = 0xf;
+    
+    DOSETMSR(inS, outS);
+  }
+
+  rVal = FXTRUE;
+
+  return rVal;
+} /* pciSetMTRR */  
+
+/*
+**  pciSetMTRRAmdK6 - set up the specified K6-style MTRR based on physical
+**                    address, physical size, and type.
+**
+**  NOTE:  A zero for the physical size results in the MTRR being
+**  cleared. 
+**
+*/
+FX_EXPORT FxBool FX_CSTYLE
+pciSetMTRRAmdK6(FxU32 mtrrNum, FxU32 physBaseAddr, FxU32 physSize,
+                PciMemType type)
+{
+  FxBool
+    res, 
+    rVal = FXFALSE;
+
+  FxU32
+    MTRRval;
+
+  MSRInfo
+    inS, outS;
+
+  if (mtrrNum > MTRR_LAST_AMDK6)
+    return rVal;
+
+  inS.msrNum = MTRR_MSR_AMDK6;   /* One MSR for both MTRRs */
+
+  if (physSize == 0) {  /* size of 0 implies clear MTRR */
+
+     DOGETMSR (inS, outS);
+
+     inS.msrHi = outS.msrHi;
+     inS.msrLo = outS.msrLo;
+
+     if (mtrrNum) {
+        inS.msrHi = 0x0;   /* clear MTRR 1 */
+     }
+     else {
+        inS.msrLo = 0x0;   /* clear MTRR 0 */
+     }
+
+     DOSETMSR (inS, outS);
+  } else {
+     /* Generate masks and set the MTRR */
+     res = genMTRRvalAmdK6(physBaseAddr, physSize, type, &MTRRval);
+
+     if (res == FXFALSE)
+       return rVal;
+
+     DOGETMSR (inS, outS);
+
+     inS.msrHi = outS.msrHi;
+     inS.msrLo = outS.msrLo;
+
+     if (mtrrNum) {
+        inS.msrHi = MTRRval;   /* program MTRR 1 */
+     }
+     else {
+        inS.msrLo = MTRRval;   /* program MTRR 0 */
+     }
+
+     DOSETMSR (inS, outS);
+  }
+
+  rVal = FXTRUE;
+
+  return rVal;
+} /* pciSetMTRRAmdK6 */  
+
Index: trunk/src/opengl/glide/swlibs/pcilib/fxnt.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxnt.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxnt.c	(revision 2887)
@@ -0,0 +1,375 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <windows.h>
+#include <winioctl.h>
+
+#include <gpioctl.h>
+#include <fxptl.h>
+
+#include <3dfx.h>
+#define FX_DLL_DEFINITION
+#include <fxdll.h>
+
+#include "fxpci.h"
+#include "pcilib.h"
+#include "fxw32.h"
+
+/* ------------------------------------------------------------- */
+/* Memmap and portio through Microsoft's sample mapmem miniport  */
+
+static HANDLE hGpdFile;
+
+/* Callback declarations */
+static FxBool pciInitializeNT(void);
+static FxBool pciShutdownNT(void);
+static const char* pciIdentifierNT(void);
+
+static FxU8  pciPortInByteNT(FxU16 port);
+static FxU16 pciPortInWordNT(FxU16 port);
+static FxU32 pciPortInLongNT(FxU16 port);
+  
+static FxBool pciPortOutByteNT(FxU16 port, FxU8 data);
+static FxBool pciPortOutWordNT(FxU16 port, FxU16 data);
+static FxBool pciPortOutLongNT(FxU16 port, FxU32 data);
+
+static FxBool pciMapLinearNT(FxU32 busNumber, FxU32 physAddr,
+                             FxU32* linearAddr, FxU32* length);
+static FxBool pciUnmapLinearNT(FxU32 linearAddr, FxU32 length);
+
+static FxBool pciSetPermissionNT(const FxU32 addrBase, const FxU32 addrLen,
+                                 const FxBool writePermP);
+
+static FxBool pciMsrGetNT(MSRInfo* in, MSRInfo* out);
+static FxBool pciMsrSetNT(MSRInfo* in, MSRInfo* out);
+
+static FxBool pciOutputStringNT(const char* msg);
+static FxBool pciSetPassThroughBaseNT(FxU32* baseAddr, FxU32 baseAddrLen);
+
+static char pciIdent[] = "@#% fxPCI for Windows NT";
+
+static const FxPlatformIOProcs __ioProcsNT = {
+  pciInitializeNT,
+  pciShutdownNT,
+  pciIdentifierNT,
+
+  pciPortInByteNT,
+  pciPortInWordNT,
+  pciPortInLongNT,
+  
+  pciPortOutByteNT,
+  pciPortOutWordNT,
+  pciPortOutLongNT,
+
+  pciMapLinearNT,
+  pciUnmapLinearNT,
+  pciSetPermissionNT,
+
+  pciMsrGetNT,
+  pciMsrSetNT,
+
+  pciOutputStringNT,
+  pciSetPassThroughBaseNT
+};
+const FxPlatformIOProcs* ioProcsNT = &__ioProcsNT;
+
+/* Basic platform init/shutdown stuff */
+static FxBool
+pciInitializeNT(void)
+{
+  hGpdFile = INVALID_HANDLE_VALUE;
+  hMemmapFile = INVALID_HANDLE_VALUE;
+
+  hGpdFile = CreateFile("\\\\.\\GpdDev", 
+                        GENERIC_READ | GENERIC_WRITE,
+                        FILE_SHARE_READ | FILE_SHARE_WRITE,
+                        NULL, 
+                        OPEN_EXISTING, 
+                        0, 
+                        NULL);
+  if (hGpdFile == INVALID_HANDLE_VALUE) {
+    pciErrorCode = PCI_ERR_GENPORT;
+    return FXFALSE;
+  }
+  
+  hMemmapFile = CreateFile("\\\\.\\MAPMEM", 
+                           GENERIC_READ | GENERIC_WRITE,
+                           0, 
+                           NULL, 
+                           OPEN_EXISTING,
+                           FILE_ATTRIBUTE_NORMAL, 
+                           NULL);
+  if (hMemmapFile == INVALID_HANDLE_VALUE) {
+    pciErrorCode = PCI_ERR_MAPMEMDRV;
+    return FXFALSE;
+  }  
+  
+  return FXTRUE;
+}
+
+static FxBool
+pciShutdownNT(void)
+{
+  if (hGpdFile != INVALID_HANDLE_VALUE) CloseHandle(hGpdFile);
+  if (hMemmapFile != INVALID_HANDLE_VALUE) CloseHandle(hMemmapFile);
+
+  return FXTRUE;
+}
+
+static const char* 
+pciIdentifierNT(void)
+{
+  return pciIdent;
+}
+
+/* Device address space management stuff */
+
+static FxBool
+pciMapLinearNT(FxU32 busNumber, FxU32 physical_addr,
+               FxU32 *linear_addr, FxU32 *length)
+{
+  FxU32 cbReturned;
+  PHYSICAL_MEMORY_INFO pmi;
+  
+  pmi.InterfaceType       = PCIBus;
+  pmi.BusNumber           = busNumber;
+  pmi.BusAddress.HighPart = 0x00000000;
+  pmi.BusAddress.LowPart  = physical_addr;
+  pmi.AddressSpace        = 0;
+  pmi.Length              = *length;
+  
+  if(!DeviceIoControl(hMemmapFile,
+                      (FxU32)IOCTL_MAPMEM_MAP_USER_PHYSICAL_MEMORY,
+                      &pmi, sizeof(PHYSICAL_MEMORY_INFO),
+                      linear_addr, sizeof(PVOID),
+                      &cbReturned, NULL)) {
+    pciErrorCode = PCI_ERR_MAPMEM;
+    return FXFALSE;
+  }
+
+  return FXTRUE;
+}
+
+static FxBool
+pciUnmapLinearNT(FxU32 linear_addr, FxU32 length) 
+{
+  FxU32                cbReturned;
+  
+  return DeviceIoControl(hMemmapFile,
+                         (FxU32)IOCTL_MAPMEM_UNMAP_USER_PHYSICAL_MEMORY,
+                         &linear_addr, sizeof(PVOID),
+                         NULL, 0,
+                         &cbReturned, NULL);
+}
+
+/* Platform port io stuff */
+
+FxU8 
+pciPortInByteNT (unsigned short port)
+{
+  BOOL   IoctlResult;
+  LONG   IoctlCode;
+  ULONG  PortNumber;
+  UCHAR  DataBuffer;
+  ULONG  DataLength;
+  ULONG  ReturnedLength;
+
+  IoctlCode = IOCTL_GPD_READ_PORT_UCHAR;
+  PortNumber = port;
+  DataLength = sizeof(DataBuffer);
+
+  IoctlResult = DeviceIoControl(hGpdFile, IoctlCode,
+                                &PortNumber, sizeof(PortNumber), 
+                                &DataBuffer, DataLength,
+                                &ReturnedLength, NULL); 
+
+  if (IoctlResult && ReturnedLength == DataLength)
+    return DataBuffer;
+  else
+    return FXFALSE;
+} /* pioInByte */
+
+FxU16
+pciPortInWordNT (unsigned short port)
+{
+  BOOL   IoctlResult;
+  LONG   IoctlCode;
+  ULONG  PortNumber;
+  USHORT DataBuffer;
+  ULONG  DataLength;
+  ULONG  ReturnedLength;
+
+  IoctlCode = IOCTL_GPD_READ_PORT_USHORT;
+  PortNumber = port;
+  DataLength = sizeof(DataBuffer);
+
+  IoctlResult = DeviceIoControl(hGpdFile, IoctlCode, 
+                                &PortNumber, sizeof(PortNumber), 
+                                &DataBuffer, DataLength,
+                                &ReturnedLength, NULL); 
+  
+  if (IoctlResult && ReturnedLength == DataLength)
+    return DataBuffer;
+  else
+    return FXFALSE;
+} /* pioInWord */
+
+FxU32
+pciPortInLongNT (unsigned short port)
+{
+  BOOL   IoctlResult;
+  LONG   IoctlCode;
+  ULONG  PortNumber;
+  ULONG  DataBuffer;
+  ULONG  DataLength;
+  ULONG  ReturnedLength;
+
+  IoctlCode = IOCTL_GPD_READ_PORT_ULONG;
+  PortNumber = port;
+  DataLength = sizeof(DataBuffer);
+
+  IoctlResult = DeviceIoControl(hGpdFile, IoctlCode, 
+                                &PortNumber, sizeof(PortNumber),
+                                &DataBuffer, DataLength, 
+                                &ReturnedLength, NULL);
+
+  if (IoctlResult && ReturnedLength == DataLength)
+    return DataBuffer;
+  else
+    return FXFALSE;
+} /* pioInLong */
+
+FxBool
+pciPortOutByteNT (unsigned short port, FxU8 data)
+{
+  LONG                IoctlCode;
+  GENPORT_WRITE_INPUT InputBuffer;
+  ULONG               DataLength;
+  ULONG               ReturnedLength;
+
+  IoctlCode = IOCTL_GPD_WRITE_PORT_UCHAR;
+  InputBuffer.PortNumber = port;
+  InputBuffer.CharData = (UCHAR) data;
+  DataLength = (offsetof(GENPORT_WRITE_INPUT, CharData) +
+                sizeof(InputBuffer.CharData));
+
+  return DeviceIoControl(hGpdFile, IoctlCode, 
+                         &InputBuffer, DataLength,
+                         NULL, 0, 
+                         &ReturnedLength, NULL);
+} /* pioOutByte */
+
+FxBool
+pciPortOutWordNT (unsigned short port, FxU16 data)
+{
+  LONG                IoctlCode;
+  GENPORT_WRITE_INPUT InputBuffer;
+  ULONG               DataLength;
+  ULONG               ReturnedLength;
+
+  IoctlCode = IOCTL_GPD_WRITE_PORT_USHORT;
+  InputBuffer.PortNumber = port;
+  InputBuffer.ShortData = (USHORT) data;
+  DataLength = (offsetof(GENPORT_WRITE_INPUT, ShortData) +
+                sizeof(InputBuffer.ShortData));
+
+  return DeviceIoControl(hGpdFile, IoctlCode, 
+                         &InputBuffer, DataLength,
+                         NULL, 0, 
+                         &ReturnedLength, NULL);
+} /* pioOutWord */
+
+FxBool
+pciPortOutLongNT (unsigned short port, FxU32 data)
+{
+  LONG                IoctlCode;
+  GENPORT_WRITE_INPUT InputBuffer;
+  ULONG               DataLength;
+  ULONG               ReturnedLength;
+
+  IoctlCode = IOCTL_GPD_WRITE_PORT_ULONG;
+  InputBuffer.PortNumber = port;
+  InputBuffer.LongData = (ULONG) data;
+  DataLength = (offsetof(GENPORT_WRITE_INPUT, LongData) +
+                sizeof(InputBuffer.LongData));
+
+  return DeviceIoControl(hGpdFile, IoctlCode, 
+                         &InputBuffer, DataLength,
+                         NULL, 0, 
+                         &ReturnedLength, NULL);
+} /* pioOutLong */
+
+static FxBool 
+pciMsrGetNT(MSRInfo* in, MSRInfo* out)
+{
+  ULONG retLen;
+
+  return DeviceIoControl(hMemmapFile, (FxU32)IOCTL_MAPMEM_GET_MSR,
+                         in, sizeof(*in),
+                         out, sizeof(*out),
+                         &retLen, NULL);
+}
+
+static FxBool 
+pciMsrSetNT(MSRInfo* in, MSRInfo* out)
+{
+  ULONG retLen;
+
+  return DeviceIoControl(hMemmapFile, (FxU32)IOCTL_MAPMEM_SET_MSR,
+                         in, sizeof(*in),
+                         out, sizeof(*out),
+                         &retLen, NULL);
+}
+
+/* Platform utilities. */
+static FxBool
+pciOutputStringNT(const char* msg)
+{
+  FxBool retVal = FXTRUE;
+
+  if (pciLibraryInitialized) {
+    OutputDebugString(msg);
+  } else {
+    pciErrorCode = PCI_ERR_NOTOPEN;
+    retVal = FXFALSE;
+  }
+
+  return retVal;
+}
+
+static FxBool
+pciSetPermissionNT(const FxU32 addrBase, const FxU32 addrLen,
+                   const FxBool writePermP)
+{
+  return FXFALSE;
+}
+
+static FxBool
+pciSetPassThroughBaseNT(FxU32* baseAddr, FxU32 baseAddrLen)
+{
+  return FXFALSE;
+}
+
+
+
Index: trunk/src/opengl/glide/swlibs/pcilib/fxos2.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxos2.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxos2.c	(revision 2887)
@@ -0,0 +1,864 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+
+#define INCL_DOS
+#define INCL_DOSDEVIOCTL
+#define INCL_DOSPROCESS
+#define INCL_DOSMODULEMGR
+#define INCL_DOSDEVICES
+#include <os2.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <types.h>
+////#include <unistd.h>
+#include <io.h>
+#include <ctype.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "3dfx.h"
+#include "fxpci.h"
+#include "pcilib.h"
+
+#ifdef __WIN32OS2__
+#define FX_CSTYLE __stdcall
+#else
+#define FX_CSTYLE _System
+#endif
+
+#pragma pack(1)
+
+#ifdef DEBUG
+#define DEBUGMSG(x) printf x
+#else
+#define DEBUGMSG(x)
+#endif
+
+#define PCI_VENDOR_ID_OS2 0x0
+#define PCI_DEVICE_ID_OS2 0x2
+#define PCI_COMMAND_OS2 0x4
+#define PCI_REVISION_ID_OS2 0x8
+#define PCI_BASE_ADDRESS_0_OS2 0x10
+#define PCI_BASE_ADDRESS_1_OS2 0x14
+#define SST1_PCI_INIT_ENABLE_OS2 0x40
+#define SST1_PCI_BUS_SNOOP0_OS2 0x44
+#define SST1_PCI_BUS_SNOOP1_OS2 0x48
+#define SST1_PCI_SPECIAL1_OS2 0x40
+#define SST1_PCI_SPECIAL2_OS2 0x44
+#define SST1_PCI_SPECIAL3_OS2 0x48
+#define SST1_PCI_SPECIAL4_OS2 0x54
+
+#define PCI_VENDOR_ID_3DFX 0x121a
+#define PCI_DEVICE_ID_3DFX_VOODOO  1
+#define PCI_DEVICE_ID_3DFX_VOODOO2 2
+#define PCI_DEVICE_ID_3DFX_BANSHEE 3
+#define PCI_DEVICE_ID_3DFX_VOODOO3 5
+#define PCI_VENDOR_ID_ALLIANCE 0x1142
+#define PCI_DEVICE_ID_ALLIANCE_AT3D 0x643d
+
+static const char* pciIdentifyOS2(void);
+static FxBool pciOutputStringOS2(const char *msg);
+static FxBool pciInitializeOS2(void);
+static FxBool pciShutdownOS2(void);
+static FxBool pciMapLinearOS2(FxU32, FxU32 physical_addr, FxU32 *linear_addr,
+				FxU32 *length);
+static FxBool pciUnmapLinearOS2(FxU32 linear_addr, FxU32 length);
+static FxBool pciSetPermissionOS2(const FxU32, const FxU32, const FxBool);
+static FxU8 pciPortInByteOS2(unsigned short port);
+static FxU16 pciPortInWordOS2(unsigned short port);
+static FxU32 pciPortInLongOS2(unsigned short port);
+static FxBool pciPortOutByteOS2(unsigned short port, FxU8 data);
+static FxBool pciPortOutWordOS2(unsigned short port, FxU16 data);
+static FxBool pciPortOutLongOS2(unsigned short port, FxU32 data);
+static FxBool pciMsrGetOS2(MSRInfo *, MSRInfo *);
+static FxBool pciMsrSetOS2(MSRInfo *, MSRInfo *);
+static FxBool pciSetPassThroughBaseOS2(FxU32 *, FxU32);
+
+const FxPlatformIOProcs ioProcsOS2 = {
+  pciInitializeOS2,
+  pciShutdownOS2,
+  pciIdentifyOS2,
+
+  pciPortInByteOS2,
+  pciPortInWordOS2,
+  pciPortInLongOS2,
+
+  pciPortOutByteOS2,
+  pciPortOutWordOS2,
+  pciPortOutLongOS2,
+
+  pciMapLinearOS2,
+  pciUnmapLinearOS2,
+  pciSetPermissionOS2,
+
+  pciMsrGetOS2,
+  pciMsrSetOS2,
+
+  pciOutputStringOS2,
+  pciSetPassThroughBaseOS2
+};
+
+static int linuxDevFd=-1;
+
+typedef struct pioData_t {
+  short port;
+  short size;
+  int device;
+  void *value;
+} ;
+
+struct cardInfo_t {
+        int vendor;
+        int type;
+        ULONG addr0;
+        ULONG addr1;
+        PULONG laddr0;
+        PULONG laddr1;
+        unsigned char bus;
+        unsigned char dev;
+};
+
+struct pci_dev
+{
+   unsigned char bus;
+   unsigned char devfn;
+};
+
+typedef struct pioData_t pioData;
+typedef struct cardInfo_t cardInfo;
+
+#define MAXCARDS 16
+
+static HFILE hOemHlp;
+static HFILE hTestCfg;
+static HFILE hScreenDD;
+
+static cardInfo cards[MAXCARDS];
+static int numCards = 0;
+
+static UINT os2_pci_query( HFILE hOemHlp, USHORT usDeviceID, USHORT usVendorID, UCHAR ucIndex, PUCHAR pucBus, PUCHAR pucDevFn )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     UCHAR  ucSubFunction;
+     USHORT usDeviceID;
+     USHORT usVendorID;
+     UCHAR  ucIndex;
+     } pcifindreq;
+  struct
+     {
+     UCHAR ucRC;
+     UCHAR ucBus;
+     UCHAR ucDevFunc;
+     } pcifindrep;
+
+  pcifindreq.ucSubFunction = 1;          // find pci device
+  pcifindreq.usDeviceID    = usDeviceID; // pci device
+  pcifindreq.usVendorID    = usVendorID; // pci vendor
+  pcifindreq.ucIndex       = ucIndex;    // entry
+
+  memset( &pcifindrep, 0, sizeof(pcifindrep) );
+
+  cbParmLenMax = sizeof(pcifindreq);
+  cbDataLenMax = sizeof(pcifindrep);
+
+  rc = DosDevIOCtl( hOemHlp, IOCTL_OEMHLP, OEMHLP_PCI, 
+                    &pcifindreq, cbParmLenMax, &cbParmLenMax,
+                    &pcifindrep, cbDataLenMax, &cbDataLenMax);
+
+  if ( pcifindrep.ucRC == 0 )
+     {
+     *pucBus = pcifindrep.ucBus;
+     *pucDevFn = pcifindrep.ucDevFunc;
+     return TRUE;
+     }
+
+  return FALSE;
+}
+
+static void os2_pci_read( HFILE hOemHlp, UCHAR ucBus, UCHAR ucDevFn, UCHAR ucIndex, PULONG pulData, UCHAR ucSize )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     UCHAR ucSubFunction;
+     UCHAR ucBus;
+     UCHAR ucDevFunc;
+     UCHAR ucCfgReg;
+     UCHAR ucSize;
+     } pcireadreq;
+  struct
+     {
+     UCHAR ucRC;
+     ULONG ulData;
+     } pcireadrep;
+
+  pcireadreq.ucSubFunction = 3;    // read pci device
+  pcireadreq.ucBus     = ucBus;
+  pcireadreq.ucDevFunc = ucDevFn;
+  pcireadreq.ucCfgReg  = ucIndex;
+  pcireadreq.ucSize    = ucSize;
+
+  rc = DosDevIOCtl( hOemHlp, IOCTL_OEMHLP, OEMHLP_PCI, 
+                    &pcireadreq, sizeof(pcireadreq), &cbParmLenMax,
+                    &pcireadrep, sizeof(pcireadrep), &cbDataLenMax);
+
+  *pulData = pcireadrep.ulData;
+}
+
+static void os2_pci_write( HFILE hOemHlp, UCHAR ucBus, UCHAR ucDevFn, UCHAR ucIndex, ULONG ulData, UCHAR ucSize )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     UCHAR ucSubFunction;
+     UCHAR ucBus;
+     UCHAR ucDevFunc;
+     UCHAR ucCfgReg;
+     UCHAR ucSize;
+     ULONG ulData;
+     } pciwritereq;
+  struct
+     {
+     UCHAR ucRC;
+     ULONG ulData;
+     } pciwriterep;
+
+  pciwritereq.ucSubFunction = 4;    // write pci device
+  pciwritereq.ucBus     = ucBus;
+  pciwritereq.ucDevFunc = ucDevFn;
+  pciwritereq.ucCfgReg  = ucIndex;
+  pciwritereq.ucSize    = ucSize;
+  pciwritereq.ulData    = ulData;
+
+  rc = DosDevIOCtl( hOemHlp, IOCTL_OEMHLP, OEMHLP_PCI, 
+                    &pciwritereq, sizeof(pciwritereq), &cbParmLenMax,
+                    &pciwriterep, sizeof(pciwriterep), &cbDataLenMax);
+}
+
+static struct pci_dev *pci_find_device(int vendor, int device, char index, struct pci_dev *dev)
+{
+  UINT bFound;
+
+  bFound = os2_pci_query( hOemHlp, device, vendor, index, &dev->bus, &dev->devfn );
+
+  return bFound ? dev : 0;
+}
+
+static void pci_read_config_dword(unsigned int bus, unsigned int devfn, char index, PULONG pulDest)
+{
+  os2_pci_read( hOemHlp, bus, devfn, index, pulDest, 4 );
+}
+
+static void pci_read_config_word(unsigned int bus, unsigned int devfn, char index, PUSHORT pusDest)
+{
+   ULONG ulDest;
+   os2_pci_read( hOemHlp, bus, devfn, index, &ulDest, 4 );
+   *pusDest = (USHORT)ulDest;
+}
+
+static void pci_read_config_byte(unsigned int bus, unsigned int devfn, char index, PUCHAR pucDest)
+{
+   ULONG ulDest;
+   os2_pci_read( hOemHlp, bus, devfn, index, &ulDest, 4 );
+   *pucDest = (UCHAR)ulDest;
+}
+
+static void pci_write_config_dword(unsigned int bus, unsigned int devfn, char index, ULONG ulDest)
+{
+  os2_pci_write( hOemHlp, bus, devfn, index, ulDest, 4 );
+}
+
+static FxU32 mmap_allocate( ULONG ulAddr )
+{
+  ULONG cbParmLenMax;
+  APIRET rc;
+  struct
+     {
+     ULONG ulPacketLength;
+     ULONG ulPhysicalAddress;
+     ULONG ulMemorySize;
+     ULONG ulLinearAddress;
+     ULONG ulLinearFlags;
+     } memmapreq;
+
+  memmapreq.ulPacketLength = sizeof(memmapreq);
+  memmapreq.ulPhysicalAddress = ulAddr;
+  memmapreq.ulMemorySize = 0x1000000;
+  memmapreq.ulLinearAddress = 0;
+  memmapreq.ulLinearFlags = 0x410;
+
+  cbParmLenMax = sizeof(memmapreq);
+
+  rc = DosDevIOCtl( hScreenDD, SCREENDD_CATEGORY, SCREENDD_GETLINEARACCESS, 
+                    &memmapreq, cbParmLenMax, &cbParmLenMax,
+                    0, 0, 0);
+
+  return memmapreq.ulLinearAddress;
+}
+
+int _System io_init1(void)
+{
+   return 0;
+}
+
+int _System io_exit1(void)
+{
+   return 0;
+}
+
+char _System c_inb1 ( short sPort )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     USHORT usPort;
+     USHORT usSize;
+     } ioreq;
+  struct
+     {
+     LONG lValue;
+     } iorep;
+
+  ioreq.usPort = (USHORT) sPort;
+  ioreq.usSize = sizeof(CHAR);
+
+  memset( &iorep, 0, sizeof(iorep) );
+
+  cbParmLenMax = sizeof(ioreq);
+  cbDataLenMax = sizeof(iorep);
+
+  rc = DosDevIOCtl( hTestCfg, IOCTL_TESTCFG_SYS, TESTCFG_SYS_ISSUEINIOINSTR, 
+                    &ioreq, cbParmLenMax, &cbParmLenMax,
+                    &iorep, cbDataLenMax, &cbDataLenMax);
+
+  return (CHAR) iorep.lValue;
+}
+
+short _System c_inw1 ( short sPort )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     USHORT usPort;
+     USHORT usSize;
+     } ioreq;
+  struct
+     {
+     LONG lValue;
+     } iorep;
+
+  ioreq.usPort = (USHORT) sPort;
+  ioreq.usSize = sizeof(SHORT);
+
+  memset( &iorep, 0, sizeof(iorep) );
+
+  cbParmLenMax = sizeof(ioreq);
+  cbDataLenMax = sizeof(iorep);
+
+  rc = DosDevIOCtl( hTestCfg, IOCTL_TESTCFG_SYS, TESTCFG_SYS_ISSUEINIOINSTR, 
+                    &ioreq, cbParmLenMax, &cbParmLenMax,
+                    &iorep, cbDataLenMax, &cbDataLenMax);
+
+  return (SHORT) iorep.lValue;
+}
+
+long _System c_inl1 ( short sPort )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     USHORT usPort;
+     USHORT usSize;
+     } ioreq;
+  struct
+     {
+     LONG lValue;
+     } iorep;
+
+  ioreq.usPort = (USHORT) sPort;
+  ioreq.usSize = sizeof(LONG);
+
+  memset( &iorep, 0, sizeof(iorep) );
+
+  cbParmLenMax = sizeof(ioreq);
+  cbDataLenMax = sizeof(iorep);
+
+  rc = DosDevIOCtl( hTestCfg, IOCTL_TESTCFG_SYS, TESTCFG_SYS_ISSUEINIOINSTR, 
+                    &ioreq, cbParmLenMax, &cbParmLenMax,
+                    &iorep, cbDataLenMax, &cbDataLenMax);
+
+  return iorep.lValue;
+}
+
+void _System c_outb1 ( short sPort, char cValue )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     USHORT usPort;
+     USHORT usSize;
+     } ioreq;
+  struct
+     {
+     LONG lValue;
+     } iorep;
+
+  ioreq.usPort = (USHORT) sPort;
+  ioreq.usSize = sizeof(CHAR);
+
+  iorep.lValue = (LONG) cValue;
+
+  cbParmLenMax = sizeof(ioreq);
+  cbDataLenMax = sizeof(iorep);
+
+  rc = DosDevIOCtl( hTestCfg, IOCTL_TESTCFG_SYS, TESTCFG_SYS_ISSUEOUTIOINSTR, 
+                    &ioreq, cbParmLenMax, &cbParmLenMax,
+                    &iorep, cbDataLenMax, &cbDataLenMax);
+}
+
+void _System c_outw1 ( short sPort, short sValue )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     USHORT usPort;
+     USHORT usSize;
+     } ioreq;
+  struct
+     {
+     LONG lValue;
+     } iorep;
+
+  ioreq.usPort = (USHORT) sPort;
+  ioreq.usSize = sizeof(SHORT);
+
+  iorep.lValue = (LONG) sValue;
+
+  cbParmLenMax = sizeof(ioreq);
+  cbDataLenMax = sizeof(iorep);
+
+  rc = DosDevIOCtl( hTestCfg, IOCTL_TESTCFG_SYS, TESTCFG_SYS_ISSUEOUTIOINSTR, 
+                    &ioreq, cbParmLenMax, &cbParmLenMax,
+                    &iorep, cbDataLenMax, &cbDataLenMax);
+}
+
+void _System c_outl1 ( short sPort, long lValue )
+{
+  ULONG cbParmLenMax, cbDataLenMax;
+  APIRET rc;
+  struct
+     {
+     USHORT usPort;
+     USHORT usSize;
+     } ioreq;
+  struct
+     {
+     LONG lValue;
+     } iorep;
+
+  ioreq.usPort = (USHORT) sPort;
+  ioreq.usSize = sizeof(LONG);
+
+  iorep.lValue = (LONG) lValue;
+
+  cbParmLenMax = sizeof(ioreq);
+  cbDataLenMax = sizeof(iorep);
+
+  rc = DosDevIOCtl( hTestCfg, IOCTL_TESTCFG_SYS, TESTCFG_SYS_ISSUEOUTIOINSTR, 
+                    &ioreq, cbParmLenMax, &cbParmLenMax,
+                    &iorep, cbDataLenMax, &cbDataLenMax);
+}
+
+static void findCardType(int vendor, int device)
+{
+	struct pci_dev dev = {0};
+	char index = 0;
+
+	while (numCards < MAXCARDS && pci_find_device(vendor, device, index, &dev)) {
+		pci_read_config_dword(dev.bus, dev.devfn, PCI_BASE_ADDRESS_0_OS2, &cards[numCards].addr0);
+		pci_read_config_dword(dev.bus, dev.devfn, PCI_BASE_ADDRESS_1_OS2, &cards[numCards].addr1);
+		cards[numCards].bus = dev.bus;
+		cards[numCards].dev = dev.devfn;
+		cards[numCards].addr0 &= ~0xF;
+		cards[numCards].addr1 &= ~0xF;
+		cards[numCards].vendor = vendor;
+		cards[numCards].type = device;
+
+		DEBUGMSG(("3dfx: board vendor %x type %x located at %x/%x bus %x dev %x\n",
+		    vendor, device, cards[numCards].addr0, cards[numCards].addr1, cards[numCards].bus, cards[numCards].dev));
+
+		++numCards;
+		++index;
+	}
+}
+
+static int findCards(void)
+{
+	numCards = 0;
+	findCardType(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO);
+	findCardType(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO2);
+	findCardType(PCI_VENDOR_ID_ALLIANCE, 0x643d);
+	findCardType(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE);
+	findCardType(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3);
+	return numCards;
+}
+
+FxBool
+pciPlatformInit(void)
+{
+  gCurPlatformIO = &ioProcsOS2;
+  return FXTRUE;
+}
+
+FxBool 
+hasDev3DfxOS2(void) 
+{
+  if (numCards==0) return FXFALSE;
+  return FXTRUE;
+}
+
+static int doQueryFetchOS2(pioData *desc)
+{
+	int retval;
+	UCHAR retchar;
+	USHORT retword;
+	ULONG retlong;
+
+	if (desc->device < 0 || desc->device >= numCards)
+		return -1;
+	switch (desc->port) {
+	case PCI_VENDOR_ID_OS2:
+		if (desc->size != 2)
+			return -1;
+		memcpy(desc->value, &cards[desc->device].vendor, desc->size);
+		return 0;
+	case PCI_DEVICE_ID_OS2:
+		if (desc->size != 2)
+			return -1;
+		memcpy(desc->value, &cards[desc->device].type, desc->size);
+		return 0;
+	case PCI_BASE_ADDRESS_0_OS2:
+		if (desc->size != 4)
+			return -1;
+		memcpy(desc->value, &cards[desc->device].addr0, desc->size);
+		return 0;
+	case PCI_BASE_ADDRESS_1_OS2:
+		if (desc->size != 4)
+			return -1;
+		memcpy(desc->value, &cards[desc->device].addr1, desc->size);
+		return 0;
+	case SST1_PCI_SPECIAL1_OS2:
+		if (desc->size != 4)
+			return -1;
+		break;
+	case PCI_REVISION_ID_OS2:
+		if (desc->size != 1)
+			return -1;
+		break;
+	case SST1_PCI_SPECIAL4_OS2:
+		if (desc->size != 4)
+			return -1;
+		break;
+	default:
+		return -1;
+	}
+	switch (desc->size) {
+	case 1:
+		pci_read_config_byte(cards[desc->device].bus, cards[desc->device].dev, desc->port, &retchar);
+		memcpy(desc->value, &retchar, 1);
+		break;
+	case 2:
+		pci_read_config_word(cards[desc->device].bus, cards[desc->device].dev, desc->port, &retword);
+		memcpy(desc->value, &retword, 2);
+		break;
+	case 4:
+		pci_read_config_dword(cards[desc->device].bus, cards[desc->device].dev, desc->port, &retlong);
+		memcpy(desc->value, &retlong, 4);
+		break;
+	default:
+		return -1;
+	}
+	return 0;
+}
+
+FxU32
+pciFetchRegisterOS2( FxU32 cmd, FxU32 size, FxU32 device) 
+{
+  pioData desc;
+  char cval;
+  short sval;
+  int ival;
+
+  if (numCards==0) return -1;
+  desc.port=cmd;
+  desc.size=size;
+  desc.device=device;
+  switch (size) {
+  case 1:
+    desc.value=&cval;
+    break;
+  case 2:
+    desc.value=&sval;
+    break;
+  case 4:
+    desc.value=&ival;
+    break;
+  default:
+    return 0;
+  }
+  if (doQueryFetchOS2(&desc)==-1)
+    return 0;
+  switch (size) {
+  case 1:
+    return cval;
+  case 2:
+    return sval;
+  case 4:
+    return ival;
+  default:
+    return 0;
+  }
+}
+
+static int doQueryUpdateOS2(pioData *desc)
+{
+	ULONG retval;
+	ULONG preval;
+	int mask;
+	UCHAR retchar;
+	USHORT retword;
+	ULONG retlong;
+
+	if (desc->device < 0 || desc->device >= numCards)
+		return -1;
+	switch (desc->port) {
+	case PCI_COMMAND_OS2:
+		if (desc->size != 2)
+			return -1;
+		break;
+	case SST1_PCI_SPECIAL1_OS2:
+		if (desc->size != 4)
+			return -1;
+		break;
+	case SST1_PCI_SPECIAL2_OS2:
+		if (desc->size != 4)
+			return -1;
+		break;
+	case SST1_PCI_SPECIAL3_OS2:
+		if (desc->size != 4)
+			return -1;
+		break;
+	case SST1_PCI_SPECIAL4_OS2:
+		if (desc->size != 4)
+			return -1;
+		break;
+	default:
+		return -1;
+	}
+	pci_read_config_dword(cards[desc->device].bus, cards[desc->device].dev, desc->port & ~0x3, &retval);
+	switch (desc->size) {
+	case 1:
+		memcpy(&retchar, desc->value, 1);
+		preval = retchar << (8 * (desc->port & 0x3));
+		mask = 0xFF << (8 * (desc->port & 0x3));
+		break;
+	case 2:
+		memcpy(&retword, desc->value, 2);
+		preval = retword << (8 * (desc->port & 0x3));
+		mask = 0xFFFF << (8 * (desc->port & 0x3));
+		break;
+	case 4:
+		memcpy(&retlong, desc->value, 4);
+		preval = retlong;
+		mask = ~0;
+		break;
+	default:
+		return -1;
+	}
+	retval = (retval & ~mask) | preval;
+	pci_write_config_dword(cards[desc->device].bus, cards[desc->device].dev, desc->port, retval);
+	return 0;
+}
+
+FxBool
+pciUpdateRegisterOS2(FxU32 cmd, FxU32 data, FxU32 size, FxU32 device) {
+  pioData desc;
+
+  if (numCards==0) return -1;
+  desc.port=cmd;
+  desc.size=size;
+  desc.device=device;
+  desc.value=&data;
+  if (doQueryUpdateOS2(&desc)==-1)
+    return FXFALSE;
+  return FXTRUE;
+}
+
+int 
+getNumDevicesOS2(void) 
+{
+  if (numCards==0) return -1;
+  return numCards;
+}
+
+static const char*
+pciIdentifyOS2(void)
+{
+  return "fxPCI for OS2";
+}
+
+static FxBool 
+pciOutputStringOS2(const char *msg) 
+{
+  printf(msg);
+  return FXTRUE;
+}
+
+static FxBool 
+pciInitializeOS2(void)
+{
+  ULONG ulAction;
+
+  io_init1();
+
+  DosOpen("OEMHLP$", &hOemHlp, &ulAction, 0, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYREADWRITE, 0L);
+  DosOpen("TESTCFG$", &hTestCfg, &ulAction, 0, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE, 0L );
+  DosOpen("SCREEN$", &hScreenDD, &ulAction, 0, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE, 0L );
+  findCards();
+  if (numCards==0) {
+     pciErrorCode = PCI_ERR_NO_IO_PERM;
+     return FXFALSE;
+  }
+  return FXTRUE;
+}
+
+static FxBool 
+pciShutdownOS2(void)
+{
+  DosClose( hTestCfg );
+  DosClose( hScreenDD );
+  DosClose( hOemHlp );
+  io_exit1();
+  return FXTRUE;
+}
+
+static FxBool 
+pciMapLinearOS2(FxU32 bus, FxU32 physical_addr, FxU32 *linear_addr, FxU32 *length) 
+{
+  *linear_addr = mmap_allocate(physical_addr);
+  return FXTRUE;
+}
+
+static FxBool
+pciUnmapLinearOS2(FxU32 linear_addr, FxU32 length) 
+{
+  return FXTRUE;
+}
+
+static FxBool
+pciSetPermissionOS2(const FxU32 addrBase, const FxU32 addrLen, const FxBool writePermP)
+{
+  return FXTRUE;
+}
+
+static FxU8 
+pciPortInByteOS2(unsigned short port) 
+{
+  return c_inb1(port);
+}
+
+static FxU16 
+pciPortInWordOS2(unsigned short port) 
+{
+  return c_inw1(port);
+}
+
+static FxU32 
+pciPortInLongOS2(unsigned short port) 
+{
+  return c_inl1(port);
+}
+
+static FxBool 
+pciPortOutByteOS2(unsigned short port, FxU8 data) 
+{
+  c_outb1(port,data);
+  return FXTRUE;
+}
+
+static FxBool 
+pciPortOutWordOS2(unsigned short port, FxU16 data) 
+{
+  c_outw1(port,data);
+  return FXTRUE;
+}
+
+static FxBool 
+pciPortOutLongOS2(unsigned short port, FxU32 data) 
+{
+  c_outl1(port,data);
+  return FXTRUE;
+}
+
+static FxBool
+pciMsrGetOS2(MSRInfo *in, MSRInfo *out)
+{
+  return FXTRUE;
+}
+
+static FxBool
+pciMsrSetOS2(MSRInfo *in, MSRInfo *out)
+{
+  return FXTRUE;
+}
+
+static FxBool
+pciSetPassThroughBaseOS2(FxU32 *baseAddr, FxU32 baseAddrLen)
+{
+  return FXTRUE;
+}
+
+FxBool FX_CSTYLE pciFindFreeMTRR(FxU32 *mtrrNum)
+{
+  return FXFALSE;
+}
+
+FxBool FX_CSTYLE pciSetMTRR(FxU32 mtrrNum, FxU32 physBaseAddr, FxU32 physSize, PciMemType type)
+{
+  return FXTRUE;
+}
+
+FxBool FX_CSTYLE pciFindMTRRMatch(FxU32 physBaseAddress, FxU32 physSize, PciMemType type, FxU32 *mtrrNum)
+{
+  return FXFALSE;
+}
+
Index: trunk/src/opengl/glide/swlibs/pcilib/fxos2.h
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxos2.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxos2.h	(revision 2887)
@@ -0,0 +1,77 @@
+/* 
+ * THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+ * PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+ * TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+ * INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+ * DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+ * THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+ * EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+ * FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+ * 
+ * USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+ * RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+ * TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+ * AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+ * SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+ * THE UNITED STATES.  
+ * 
+ * COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+ */
+
+#ifndef _FXOS2_H_
+#define _FXOS2_H_
+
+//#define FX_MAJOR_VER 0
+//#define FX_MINOR_VER 0
+
+//extern FxU32 PCI_VENDOR_ID_LINUX;
+//extern FxU32 PCI_DEVICE_ID_LINUX;
+//extern FxU32 PCI_COMMAND_LINUX;
+//extern FxU32 PCI_BASE_ADDRESS_0_LINUX;
+//extern FxU32 SST1_PCI_INIT_ENABLE_LINUX;
+//extern FxU32 SST1_PCI_BUS_SNOOP0_LINUX;
+//extern FxU32 SST1_PCI_BUS_SNOOP1_LINUX;
+
+FxBool
+hasDev3DfxOS2(void);
+
+FxBool 
+pciInitializeOS2(void);
+
+FxBool
+pciCloseOS2( void );
+
+FxU8 
+pioInByte(unsigned short port);
+
+FxU16 
+pioInWord(unsigned short port);
+
+FxU32 
+pioInLong(unsigned short port);
+
+FxBool 
+pioOutByte(unsigned short port, FxU8 data);
+
+FxBool 
+pioOutWord(unsigned short port, FxU16 data);
+
+FxBool 
+pioOutLong(unsigned short port, FxU32 data);
+
+FxBool 
+pciMapPhysicalToLinearOS2( FxU32 *linear_addr, FxU32 physical_addr,
+			FxU32 *length );
+void 
+pciUnmapPhysicalOS2( FxU32 linear_addr, FxU32 length );
+
+int
+getNumDevicesOS2(void);
+
+FxU32
+pciFetchRegisterOS2( FxU32 cmd, FxU32 size, FxU32 device);
+
+int
+pciUpdateRegisterOS2(FxU32 cmd, FxU32 data, FxU32 size, FxU32 device);
+
+#endif
Index: trunk/src/opengl/glide/swlibs/pcilib/fxpci.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxpci.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxpci.c	(revision 2887)
@@ -0,0 +1,839 @@
+/*
+ ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+ ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+ ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+ ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+ ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+ ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+ ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+ ** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+ ** 
+ ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+ ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+ ** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+ ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+ ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+ ** THE UNITED STATES.  
+ ** 
+ ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+ **
+ **
+ ** $Revision: 1.1 $ 
+ ** $Date: 2000-02-25 00:33:56 $ 
+ **
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <3dfx.h>
+#define FX_DLL_DEFINITION
+#include <fxdll.h>
+#include <fxmemmap.h>
+#include "fxpci.h"
+#include "pcilib.h"
+#ifdef __linux__
+#include "fxlinux.h"
+#endif
+#ifdef __OS2__
+#include "fxos2.h"
+#endif
+
+/* PRIVATE DATA (within the library) */
+FxU32   pciVxdVer = 0;
+FxU32   pciErrorCode = PCI_ERR_NOERR;
+FxBool  pciLibraryInitialized  = FXFALSE;
+PciHwcCallbacks pciHwcCallbacks = { 1 };
+
+const FxPlatformIOProcs* gCurPlatformIO = NULL;
+
+/* 
+ * linear Address Map List
+ *
+ * This is the new way we keep track of boards which are already mapped 
+ */
+static struct {
+  FxU32
+    device_bus_func_number;
+  struct {
+    FxBool
+    mapped;
+    FxU32 
+    addr;
+  } addrList[MAX_PCI_BASEADDRESSES];
+} linearAddressMapList[MAX_PCI_DEVICES];
+
+typedef struct _PCIErr {
+  FxU32 code;
+  char *string;
+} PCIErr, *PCIErrPtr;
+
+static PCIErr pciError[] = {
+  {PCI_ERR_NOERR, "No errors.\n"},
+  {PCI_ERR_WINRTINIT, "WinRT initialization failure.\n" },
+  {PCI_ERR_MEMMAPVXD, "Memmap VxD initialization failure.\n" },
+  {PCI_ERR_MAPMEMDRV, "Mapmem driver initialization failure.\n" },
+  {PCI_ERR_GENPORT, "Genport I/O initialization failure.\n" },
+  {PCI_ERR_NO_BUS, "No PCI Bus detected.\n"},
+  {PCI_ERR_NOTOPEN, "PCI library not open.\n" },
+  {PCI_ERR_NOTOPEN2, "Closing unopened PCI library.\n" },
+  {PCI_ERR_NOTOPEN3, "pciGetConfigData() on unopened library.\n" }, 
+  {PCI_ERR_OUTOFRANGE, "Device_number is out of range.\n" },
+  {PCI_ERR_NODEV, "Cannot read from a non-existant device.\n" },
+  {PCI_ERR_NODEV2, "Cannot update config regs from non-existant device.\n" },
+  {PCI_ERR_WRITEONLY, "Cannot read a WRITE_ONLY register.\n" },
+  {PCI_ERR_READONLY, "Cannot write a READ_ONLY register.\n" },
+  {PCI_ERR_PHARLAP, "Phar Lap returned an error trying to map memory.\n" },
+  {PCI_ERR_WRONGVXD, "Expected VxD version V%d.%d, got V%d.%d\n"},
+  {PCI_ERR_MEMMAP, "Memmap returned an error trying to map memory.\n" },
+  {PCI_ERR_MAPMEM, "Mapmem returned an error trying to map memory.\n" },
+  {PCI_ERR_WINRT, "Winrt returned an error trying to map memory.\n" },
+  {PCI_ERR_VXDINUSE, "Mutual exclusion prohibits this\n" },
+  {PCI_ERR_NO_IO_PERM, "Permission denied.\n"
+   "Couldn't change I/O priveledge level.\n"},
+  {PCI_ERR_NO_MEM_PERM, "Permission denied.\n"
+   "Couldn't access memory mapp.\n"}
+};
+
+/* -------------------------------------------------- */
+/* Port IO subroutines - each layer has it's own      */
+FX_ENTRY FxU8 FX_CALL
+pioInByte ( unsigned short port )
+{
+  FxU8 data;
+
+  if (pciHwcCallbacks.pioInByte)
+    data = pciHwcCallbacks.pioInByte(port);
+  if (pciHwcCallbacks.doHW)
+    data = _pioInByte( port );
+  return data;
+}
+
+FX_ENTRY FxU16 FX_CALL
+pioInWord ( unsigned short port )
+{
+  FxU16 data;
+
+  if (pciHwcCallbacks.pioInWord)
+    data = pciHwcCallbacks.pioInWord(port);
+  if (pciHwcCallbacks.doHW)
+    data = _pioInWord( port );
+  return data;
+}
+
+FX_ENTRY FxU32 FX_CALL
+pioInLong ( unsigned short port )
+{
+  FxU32 data;
+
+  if (pciHwcCallbacks.pioInLong)
+    data = pciHwcCallbacks.pioInLong(port);
+  if (pciHwcCallbacks.doHW)
+    data = _pioInLong( port );
+  return data;
+}
+
+FX_ENTRY FxBool FX_CALL
+pioOutByte ( unsigned short port, FxU8 data )
+{
+  if (pciHwcCallbacks.pioOutByte)
+    pciHwcCallbacks.pioOutByte(port,data);
+  if (pciHwcCallbacks.doHW)
+    _pioOutByte( port, data );
+  return FXTRUE;
+}
+
+FX_ENTRY FxBool FX_CALL
+pioOutWord ( unsigned short port, FxU16 data )
+{
+  if (pciHwcCallbacks.pioOutWord)
+    pciHwcCallbacks.pioOutWord(port,data);
+  if (pciHwcCallbacks.doHW)
+    _pioOutWord( port, data );
+  return FXTRUE;
+}
+
+FX_ENTRY FxBool FX_CALL
+pioOutLong ( unsigned short port, FxU32 data )
+{
+  if (pciHwcCallbacks.pioOutLong)
+    pciHwcCallbacks.pioOutLong(port,data);
+  if (pciHwcCallbacks.doHW)
+    _pioOutLong( port, data );
+  return FXTRUE;
+}
+
+static PciRegister    baseAddresses[MAX_PCI_BASEADDRESSES];
+static FxU32          vendorIDs[MAX_PCI_DEVICES];
+static FxU32          configMechanism     = 0;
+static FxBool         busDetected         = FXFALSE;
+static FxBool         deviceExists[MAX_PCI_DEVICES];
+
+/* PRIVATE FUNCTIONS */
+FxU32
+_pciCreateConfigAddress( FxU32 bus_number, FxU32 device_number,  
+                         FxU32 function_number, FxU32 register_offset )
+{ 
+  FxU32 retval = CONFIG_ADDRESS_ENABLE_BIT;
+  
+  retval |= ( bus_number & 0xFF ) << 16;
+  retval |= ( device_number & 0x1F ) << 11;
+  retval |= ( function_number & 0x7 ) << 8;
+  retval |= ( register_offset & 0xFC );
+  return retval;
+} /* _pciCreateConfigAddress */
+
+
+
+FxU16 
+_pciCreateConfigSpaceMapping( FxU32 device_number, FxU32
+                              register_offset )
+{
+
+  FxU16 retval = 0;
+  retval |= ( device_number & 0xFF ) << 8;
+  retval |= ( register_offset & 0xFC );
+  retval += CONFIG_MAPPING_OFFSET;
+  return retval;
+} /* _pciCreateConfigSpaceMapping */
+
+
+
+FX_ENTRY FxU32 FX_CALL
+_pciFetchRegister( FxU32 offset, FxU32 size_in_bytes, 
+                   FxU32 device_number, FxU32 config_mechanism  )
+{ 
+  FxU32 retval;
+  FxU32 slot, bus;
+  
+  bus  = device_number >> 5;
+  slot = device_number & 0x1f;
+  
+  if ( config_mechanism == 1 ) {
+    pioOutLong( CONFIG_ADDRESS_PORT, _pciCreateConfigAddress( bus, slot, 0, offset ) );
+    retval = pioInLong( CONFIG_DATA_PORT );
+    retval >>= 8 * ( offset & 0x3 );
+  } else {                      /* config mechanism 2 */
+    pioOutByte( CONFIG_ADDRESS_PORT, CONFIG_MAPPING_ENABLE_BYTE );
+    retval = pioInLong( _pciCreateConfigSpaceMapping( device_number, offset ) ); 
+    retval >>= 8 * ( offset & 0x3 );
+    pioOutByte( CONFIG_ADDRESS_PORT, CONFIG_MAPPING_DISABLE_BYTE );
+  }
+  
+  switch( size_in_bytes ) {
+  case 1:
+    retval &= 0xFF;
+    break;
+  case 2:
+    retval &= 0xFFFF;
+    break;
+  default:                      /* 4 bytes */
+    break;
+  }
+  
+  return retval;
+} /* _pciFetchRegister */
+
+
+
+FX_ENTRY void FX_CALL
+_pciUpdateRegister( FxU32 offset, FxU32 data, FxU32 size_in_bytes,  
+                    FxU32 device_number, FxU32 config_mechanism  ) 
+{
+  FxU32
+    regval =  _pciFetchRegister( offset & ( ~0x3 ), 4,
+                                 device_number, config_mechanism );
+  FxU32 mask = (FxU32) ~0l;
+  FxU32 bus, slot;
+  
+  bus  = device_number >> 5;
+  slot = device_number & 0x1f;
+  
+  switch( size_in_bytes ) {
+  case 1:
+    mask &= 0xFF;
+    data &= 0xFF;
+    break;
+  case 2:
+    mask &= 0xFFFF;
+    data &= 0xFFFF;
+    break;
+  case 4:
+  default:
+    break;
+  }
+  
+  data <<= 8 * ( offset & 0x03 );
+  mask <<= 8 * ( offset & 0x03 );
+  
+  regval = ( regval & ~mask ) | data;
+  
+  if ( config_mechanism == 1 ) {
+    pioOutLong( CONFIG_ADDRESS_PORT, _pciCreateConfigAddress( bus, slot, 0, offset ) );
+    pioOutLong( CONFIG_DATA_PORT, regval );
+  } else {                      /* config mechanism 2 */
+    pioOutByte( CONFIG_ADDRESS_PORT, CONFIG_MAPPING_ENABLE_BYTE );
+    pioOutLong( _pciCreateConfigSpaceMapping( device_number, offset ), regval );
+    pioOutByte( CONFIG_ADDRESS_PORT, CONFIG_MAPPING_DISABLE_BYTE );
+  }
+  
+  return;
+} /* _pciUpdateRegister */
+
+static FxU32 
+find_mapped_address(FxU32 device_bus_func_number, FxU32 addrNum) 
+{
+  FxU32 
+    i,
+    retVal = 0x00UL;
+
+  for(i = 0; i < MAX_PCI_DEVICES; i++) {
+    if (linearAddressMapList[i].device_bus_func_number == device_bus_func_number) {
+      retVal = linearAddressMapList[i].addrList[addrNum].addr;
+
+      break;
+    }
+  }
+
+  return retVal;
+}
+
+static void 
+set_mapped_address(FxU32 device_bus_func_number, FxU32 addrNum, FxU32 value) 
+{
+  FxU32 i;
+  
+  for(i = 0; i < MAX_PCI_DEVICES; i++) {
+    if (linearAddressMapList[i].device_bus_func_number == device_bus_func_number) {
+      FxU32 j;
+
+      linearAddressMapList[i].addrList[addrNum].mapped = (value != 0x00UL);
+      linearAddressMapList[i].addrList[addrNum].addr = value;
+
+      for(j = 0; j < MAX_PCI_BASEADDRESSES; j++) {
+        if (linearAddressMapList[i].addrList[j].mapped) break;
+      }
+      if (j == MAX_PCI_BASEADDRESSES) linearAddressMapList[i].device_bus_func_number = 0x00UL;
+
+      break;
+    }
+  }
+  if (i != MAX_PCI_DEVICES) return;
+
+  for(i = 0; i < MAX_PCI_DEVICES; i++) {
+    if (linearAddressMapList[i].device_bus_func_number == 0) {
+      linearAddressMapList[i].device_bus_func_number = device_bus_func_number;
+
+      linearAddressMapList[i].addrList[addrNum].mapped = (value != 0x00UL);
+      linearAddressMapList[i].addrList[addrNum].addr = value;
+
+      break;
+    }
+  }
+}
+
+/* PUBLIC DATA  */
+
+PciRegister PCI_VENDOR_ID       = { 0x0,  2, READ_ONLY };
+PciRegister PCI_DEVICE_ID       = { 0x2,  2, READ_ONLY };
+PciRegister PCI_COMMAND         = { 0x4,  2, READ_WRITE };
+PciRegister PCI_STATUS          = { 0x6,  2, READ_WRITE };
+PciRegister PCI_REVISION_ID     = { 0x8,  1, READ_ONLY };
+PciRegister PCI_CLASS_CODE      = { 0x9,  3, READ_ONLY };
+PciRegister PCI_CACHE_LINE_SIZE = { 0xC,  1, READ_WRITE };
+PciRegister PCI_LATENCY_TIMER   = { 0xD,  1, READ_WRITE };
+PciRegister PCI_HEADER_TYPE     = { 0xE,  1, READ_ONLY };
+PciRegister PCI_BIST            = { 0xF,  1, READ_WRITE };
+PciRegister PCI_BASE_ADDRESS_0  = { 0x10, 4, READ_WRITE };
+PciRegister PCI_BASE_ADDRESS_1  = { 0x14, 4, READ_WRITE };
+PciRegister PCI_IO_BASE_ADDRESS = { 0x18, 4, READ_WRITE };
+PciRegister PCI_SUBVENDOR_ID    = { 0x2C, 4, READ_ONLY };
+PciRegister PCI_SUBSYSTEM_ID    = { 0x2E, 4, READ_ONLY };
+PciRegister PCI_ROM_BASE_ADDRESS= { 0x30, 4, READ_WRITE };
+PciRegister PCI_CAP_PTR         = { 0x34, 4, READ_WRITE };
+PciRegister PCI_INTERRUPT_LINE  = { 0x3C, 1, READ_WRITE };
+PciRegister PCI_INTERRUPT_PIN   = { 0x3D, 1, READ_ONLY };
+PciRegister PCI_MIN_GNT         = { 0x3E, 1, READ_ONLY };
+PciRegister PCI_MAX_LAT         = { 0x3F, 1, READ_ONLY };
+PciRegister PCI_FAB_ID          = { 0x40, 1, READ_ONLY };
+PciRegister PCI_CONFIG_STATUS   = { 0x4C, 4, READ_WRITE };
+PciRegister PCI_CONFIG_SCRATCH  = { 0x50, 4, READ_WRITE };
+PciRegister PCI_AGP_CAP_ID      = { 0x54, 4, READ_ONLY };
+PciRegister PCI_AGP_STATUS      = { 0x58, 4, READ_ONLY };
+PciRegister PCI_AGP_CMD         = { 0x5C, 4, READ_WRITE };
+PciRegister PCI_ACPI_CAP_ID     = { 0x60, 4, READ_ONLY };
+PciRegister PCI_CNTRL_STATUS    = { 0x64, 4, READ_WRITE };
+
+/* sst1 definitions left in for compatability */
+PciRegister PCI_SST1_INIT_ENABLE = { 0x40, 4, READ_WRITE }; 
+PciRegister PCI_SST1_BUS_SNOOP_0 = { 0x44, 4, READ_WRITE }; 
+PciRegister PCI_SST1_BUS_SNOOP_1 = { 0x48, 4, READ_WRITE }; 
+PciRegister PCI_SST1_CFG_STATUS  = { 0x4C, 4, READ_WRITE };
+
+/* PUBLIC FUNCTIONS */
+
+FX_ENTRY const char * FX_CALL
+pciGetErrorString( void )
+{
+  static char vxdErrString[120];
+  if (pciErrorCode == PCI_ERR_WRONGVXD) {
+    sprintf(vxdErrString, "Expected VXD version V%d.%d, got V%d.%d\n",
+            FX_MAJOR_VER, FX_MINOR_VER,
+            BYTE1(pciVxdVer), BYTE0(pciVxdVer));
+    return vxdErrString;
+  }
+  return pciError[pciErrorCode].string;
+} /* pciGetErrorString */
+
+
+
+FX_ENTRY FxU32 FX_CALL
+pciGetErrorCode( void )
+{
+  return pciError[pciErrorCode].code;
+} /* pciGetErrorCode */
+
+
+FX_EXPORT FxBool FX_CSTYLE
+pciOpenEx( PciHwcCallbacks *cb )
+{
+  pciHwcCallbacks = *cb;
+  return pciOpen();
+}
+
+// internal routine for scanning the PCI bus the first time during a pciOpen
+static void
+sampleVendorID(int deviceNumber, int configMode)
+{
+  FxU32 regVal;
+
+  // set the global mode: this routine is used to determine which mode works
+  configMechanism = configMode;
+  regVal = _pciFetchRegister( PCI_VENDOR_ID.regAddress,
+                              PCI_VENDOR_ID.sizeInBytes, 
+                              deviceNumber, configMode );
+  regVal &= 0xFFFF;
+
+  if ( regVal != 0xFFFF ) {
+    busDetected = FXTRUE;
+    vendorIDs[deviceNumber] = regVal;
+  } else {
+    vendorIDs[deviceNumber] = 0;
+  }
+}
+
+FxBool
+pciOpenMyOS(void)
+{
+  int numDevices, deviceNumber;
+
+#ifdef __linux__
+  numDevices=getNumDevicesLinux();
+#endif
+#ifdef __OS2__
+  numDevices=getNumDevicesOS2();
+#endif
+  for (deviceNumber=0; deviceNumber < MAX_PCI_DEVICES; deviceNumber++) {
+    if (deviceNumber<numDevices) {
+      busDetected=FXTRUE;
+      configMechanism=1;
+      deviceExists[deviceNumber] = FXTRUE;
+      vendorIDs[deviceNumber] = 0x121a;
+    }
+    else deviceExists[deviceNumber] = FXFALSE;
+  }
+  if (numDevices) {
+    pciLibraryInitialized=FXTRUE;
+  } else {
+    pciLibraryInitialized=FXFALSE;
+  }      
+  return pciLibraryInitialized;
+}
+
+FX_EXPORT FxBool FX_CSTYLE
+pciOpen( void )
+{
+  int deviceNumber;
+  
+  if ( pciLibraryInitialized ) return FXTRUE;
+  
+  baseAddresses[0] = PCI_BASE_ADDRESS_0;
+  baseAddresses[1] = PCI_BASE_ADDRESS_1;
+  baseAddresses[2] = PCI_IO_BASE_ADDRESS;
+  baseAddresses[3] = PCI_ROM_BASE_ADDRESS;
+  
+  busDetected = FXFALSE;
+  if (pciHwcCallbacks.doHW) {
+    if (!pciPlatformInit() ||
+        (gCurPlatformIO == NULL) ||
+        !pciInitializeDDio()) return FXFALSE;
+  }
+  /*
+  **      Scan All PCI device numbers
+  */ 
+
+#ifdef __linux__
+  if (hasDev3DfxLinux()) return pciOpenMyOS();
+#endif
+#ifdef __OS2__
+  if (hasDev3DfxOS2()) return pciOpenMyOS();
+#endif
+  
+  for ( deviceNumber = 0; deviceNumber < MAX_PCI_DEVICES; deviceNumber++ ) {
+    FxU32 regVal;
+    FxU32 slot;
+    FxU32 bus;
+        
+    sampleVendorID(deviceNumber,1);
+
+    bus =   deviceNumber >> 5;
+    slot = (deviceNumber & 0x1f);
+
+    pioOutLong( CONFIG_ADDRESS_PORT, 
+                _pciCreateConfigAddress( bus, slot, 0, 0x0 ) );
+    regVal = pioInLong( CONFIG_DATA_PORT );
+
+    if ( ( regVal & 0xFFFF ) != 0xFFFF ) {
+      busDetected = FXTRUE;
+      configMechanism = 1;
+      deviceExists[deviceNumber] = FXTRUE;
+      vendorIDs[deviceNumber] = regVal & 0xffff;
+    } else {
+      deviceExists[deviceNumber] = FXFALSE;
+    }
+
+  }
+  
+  if ( !busDetected )  { 
+    /* Try Configuration Mechanism 2 (only 16 devices) */
+    /* Since Configuration Mech#2 is obsolete this does not
+       support multiple busses */
+
+    for ( deviceNumber = 0; deviceNumber < 16; deviceNumber++ ) {
+      sampleVendorID(deviceNumber,2);
+    }
+  }
+  
+  if ( busDetected ) {
+    pciLibraryInitialized = FXTRUE;
+  } else {
+    pciErrorCode = PCI_ERR_NO_BUS;
+    return FXFALSE;
+  }    
+  
+  return FXTRUE;
+} /* pciOpen */
+
+FX_EXPORT FxBool FX_CSTYLE
+pciClose( void )
+{
+  if ( !pciLibraryInitialized ) {
+    pciErrorCode = PCI_ERR_NOTOPEN2;
+    return FXFALSE;
+  }
+  pciLibraryInitialized = FXFALSE;
+
+  return pciCloseDDio();
+}
+
+
+FX_EXPORT FxBool FX_CSTYLE
+pciDeviceExists( FxU32 device_number ) {
+  if ( !pciLibraryInitialized ) {
+    pciErrorCode = PCI_ERR_NOTOPEN;
+    return FXFALSE;
+  }
+  if ( device_number >= MAX_PCI_DEVICES ) return FXFALSE;
+  return vendorIDs[device_number];
+} /* pciDeviceExists */
+
+
+
+FX_EXPORT FxBool FX_CSTYLE
+pciGetConfigData( PciRegister reg, FxU32 device_bus_func_number, FxU32 *data ) 
+{
+  int device_number = (device_bus_func_number) & 0xFFF;
+  
+  if ( !pciLibraryInitialized ) {
+    pciErrorCode = PCI_ERR_NOTOPEN3;
+    return FXFALSE;
+  }
+  if ( device_number >= MAX_PCI_DEVICES ) {
+    pciErrorCode = PCI_ERR_OUTOFRANGE;
+    return FXFALSE;
+  }
+  
+  if ( !vendorIDs[device_number] ) {
+    pciErrorCode = PCI_ERR_NODEV;
+    return FXFALSE;
+  }
+  
+  if ( reg.rwFlag == WRITE_ONLY ) {
+    pciErrorCode = PCI_ERR_WRITEONLY;
+    return FXFALSE;
+  }
+
+#ifdef __linux__  
+  if (hasDev3DfxLinux()) {
+    *data = pciFetchRegisterLinux(reg.regAddress, reg.sizeInBytes,
+				  device_bus_func_number);
+    return FXTRUE;
+  }
+#endif
+#ifdef __OS2__  
+  if (hasDev3DfxOS2()) {
+    *data = pciFetchRegisterOS2(reg.regAddress, reg.sizeInBytes,
+				  device_bus_func_number);
+    return FXTRUE;
+  }
+#endif
+  *data = _pciFetchRegister( reg.regAddress, reg.sizeInBytes,
+                             device_bus_func_number, configMechanism );
+  
+  return FXTRUE;
+} /* pciGetConfigData */
+
+
+
+FX_EXPORT FxBool FX_CSTYLE
+pciSetConfigData( PciRegister reg, FxU32 device_bus_func_number, FxU32 *data ) 
+{
+  int device_number = (device_bus_func_number) & 0xFFF;
+  
+  if ( !pciLibraryInitialized ) {
+    pciErrorCode = PCI_ERR_NOTOPEN3;
+    return FXFALSE;
+  }
+  if ( device_number >= MAX_PCI_DEVICES ) {
+    pciErrorCode = PCI_ERR_OUTOFRANGE;
+    return FXFALSE;
+  }
+  
+  if ( !vendorIDs[device_number] ) {
+    pciErrorCode = PCI_ERR_NODEV2;
+    return FXFALSE;
+  }       
+  
+  if ( reg.rwFlag == READ_ONLY ) {
+    pciErrorCode = PCI_ERR_READONLY;
+    return FXFALSE;
+  }
+
+#ifdef __linux__
+  if (hasDev3DfxLinux()) {
+    return pciUpdateRegisterLinux(reg.regAddress, *data, reg.sizeInBytes,
+				  device_bus_func_number);
+  }
+#endif
+#ifdef __OS2__
+  if (hasDev3DfxOS2()) {
+    return pciUpdateRegisterOS2(reg.regAddress, *data, reg.sizeInBytes,
+				  device_bus_func_number);
+  }
+#endif
+  _pciUpdateRegister( reg.regAddress, *data, reg.sizeInBytes,
+                      device_bus_func_number, configMechanism );
+  
+  return FXTRUE;
+} /* pciSetConfigData */
+
+
+FX_EXPORT FxBool FX_CSTYLE
+pciFindCardMulti(FxU32 vendorID, FxU32 deviceID, 
+                 FxU32 *devNum, FxU32 cardNum) 
+{
+  FxU32 deviceNumber;
+  
+  /*      1) open the PCI device and scan it for devices */
+  if (!pciOpen()) return FXFALSE;
+  
+  /*      2) scan the existing devices for a match */
+  for ( deviceNumber = 0; deviceNumber < MAX_PCI_DEVICES; deviceNumber++ ) {
+    if (pciDeviceExists(deviceNumber)) {
+      FxU32 
+        vID, dID;
+      FxBool
+        matchP = FXFALSE;
+
+      pciGetConfigData( PCI_VENDOR_ID, deviceNumber, &vID );
+      pciGetConfigData( PCI_DEVICE_ID, deviceNumber, &dID );
+
+      if (deviceID == 0xFFFF)   /* if special value */
+        dID = deviceID;         /* then force a match */
+
+      matchP = ((vID == vendorID) && (dID == deviceID));
+      if (matchP) {
+        if (cardNum == 0) {
+          *devNum = deviceNumber;
+          return FXTRUE;
+        }
+      }
+
+      /* single board SLI hack! - jeske */
+      if ((vID == _3DFX_PCI_ID) && (dID == 0x0002)) {
+        pciGetConfigData( PCI_VENDOR_ID, deviceNumber | (1 << 13), &vID);
+        pciGetConfigData( PCI_DEVICE_ID, deviceNumber | (1 << 13), &dID);
+        
+        if ((vID == vendorID) && (dID == deviceID)) {
+          matchP = FXTRUE;
+          if (cardNum == 0) {
+            *devNum = deviceNumber | (1 << 13); /* stuff in function 1 */
+            return FXTRUE;
+          }
+        }
+      }
+      /* end of single board SLI hack! - jeske */
+
+      if (matchP) cardNum--;
+    }
+  }
+  return FXFALSE;         /* didn't find the card, return false */
+} /* pciFindCardMulti */
+
+
+
+FX_EXPORT FxBool FX_CSTYLE
+pciFindCard(FxU32 vendorID, FxU32 deviceID, FxU32 *devNum) {
+  return pciFindCardMulti(vendorID, deviceID, devNum, 0);
+} /* pciFindCard */
+
+
+
+/*----------------------------------------------------------------------
+  find and map a PCI card into virtual memory using the following 4
+  steps: 
+      1) open the PCI device and scan it for devices 
+      2) scan the existing devices for a vendorId, deviceId, cardNum match
+      3) find the current physcial address of the card
+      4) map the physical memory to virtual memory
+      ----------------------------------------------------------------------*/
+FX_EXPORT FxU32 * FX_CSTYLE
+pciMapCardMulti(FxU32 vendorID, FxU32 deviceID, 
+                FxI32 length, 
+                FxU32 *devNum,
+                FxU32 cardNum, FxU32 addressNum)
+{
+  FxU32 
+    physAddress, 
+    virtAddress;
+  
+  /* 1) open the PCI device and scan it for devices
+   * 2) scan the existing devices for a match
+   */
+  if (!pciFindCardMulti(vendorID, deviceID, devNum, cardNum)) return NULL;
+  if (addressNum > MAX_PCI_BASEADDRESSES) return NULL;
+
+  /* 3) find the current physcial address of the card */
+  pciGetConfigData( baseAddresses[addressNum], *devNum, &physAddress );
+  if (length <= 0) return (FxU32*)length;
+
+  /* Mask the memory type information bits off.
+   *   [0]: Memory type indicator (0 memory/1 i/o)
+   *  [12]: Type
+   *    00: 32 bits wide and mapable anywhere
+   *    01: 32 bits wide, mapped < 1meg
+   *    10: 64 bits wide and mappable anywhere
+   *    11: reserved
+   *   [3]: Prefetcable
+   */
+  physAddress &= ~0xF;
+
+  /* 4) have we mapped this device before? */
+  virtAddress = find_mapped_address(*devNum, addressNum);
+  if (virtAddress == 0x00UL) {
+    /* 5) map the physical memory to virtual memory 
+     *
+     * NB: Some systems (notably nt) require a bus # in addition to the
+     * physical address in order to map a device. pciMapPhysicalToLinear
+     * has an implicit bus0 which works most of the time, but fails
+     * across pci bridges and to agp devices. Anyway, recall that the
+     * deviceNumber is a tuple w/ the following internal structure:
+     *
+     *   device_number[0:4]   = slot
+     *   device_number[5:12]  = bus
+     *   device_number[13:15] = function 
+     */
+    if (!pciMapPhysicalDeviceToLinear(&virtAddress, 
+                                      ((*devNum >> 5UL) & 0xFFUL), physAddress,                                     
+                                      (FxU32*) &length)) {
+      
+      virtAddress = 0x00UL;
+    }
+    set_mapped_address(*devNum, addressNum, virtAddress);
+  }
+
+  return (FxU32*)virtAddress;
+} /* pciMapCardMulti */
+
+
+FX_EXPORT FxU32 * FX_CSTYLE
+pciMapCard(FxU32 vendorID, FxU32 deviceID,
+           FxI32 length, FxU32 *devNum, FxU32 addressNum)
+{
+  return pciMapCardMulti(vendorID, deviceID, length, devNum, 0, addressNum);
+} /* pciMapCard */
+
+FX_EXPORT FxBool FX_CSTYLE
+pciMapPhysicalToLinear( FxU32 *linear_addr, FxU32 physical_addr,
+                        FxU32 *length ) 
+{ 
+  return pciMapPhysicalDeviceToLinear(linear_addr, 
+                                      0x00UL, physical_addr,
+                                      length);
+} /* pciMapPhysicalToLinear */
+
+FX_ENTRY FxBool FX_CALL 
+pciMapPhysicalDeviceToLinear(FxU32 *linear_addr, 
+                             FxU32 busNumber, FxU32 physical_addr,
+                             FxU32 *length)
+{
+  return pciMapLinearDD(busNumber, physical_addr,
+                        linear_addr, length);
+}
+
+
+FX_EXPORT void FX_CSTYLE
+pciUnmapPhysical( FxU32 linear_addr, FxU32 length ) 
+{
+  int i,j;
+  
+  for (i = 0; i < MAX_PCI_DEVICES; i++) {
+    for (j = 0; j < MAX_PCI_BASEADDRESSES; j++) {
+      if(linearAddressMapList[i].addrList[j].addr == linear_addr) { 
+        linearAddressMapList[i].addrList[j].addr = 0x00UL;
+        linearAddressMapList[i].addrList[j].mapped = FXFALSE;
+
+        break;
+      }
+    }
+  }
+
+  if (i != MAX_PCI_DEVICES) pciUnmapLinearDD(linear_addr, length);
+}
+
+FX_EXPORT FxBool FX_CSTYLE
+pciSetPassThroughBase(FxU32* baseAddr, FxU32 baseAddrLen)
+{
+  FxBool retVal;
+
+  if (pciLibraryInitialized) {
+    retVal = pciSetPassThroughBaseDD(baseAddr, baseAddrLen);
+  } else {
+    pciErrorCode = PCI_ERR_NOTOPEN;
+    retVal = FXFALSE;
+  }
+
+  return retVal;
+}
+
+FX_EXPORT FxBool FX_CSTYLE
+pciOutputDebugString(const char* msg)
+{
+  return pciOutputDebugStringDD(msg);
+}
+
+FX_EXPORT FxBool FX_CSTYLE
+pciLinearRangeSetPermission(const FxU32 addrBase, const FxU32 addrLen, const FxBool writeableP)
+{
+  return pciLinearRangeSetPermissionDD(addrBase, addrLen, writeableP);
+}
+
Index: trunk/src/opengl/glide/swlibs/pcilib/fxpci.h
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxpci.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxpci.h	(revision 2887)
@@ -0,0 +1,247 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+**
+** $Revision: 1.1 $ 
+** $Date: 2000-02-25 00:33:56 $ 
+**
+*/
+
+#ifndef _FXPCI_H_
+#define _FXPCI_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define _3DFX_PCI_ID 0x121A
+
+/* jeske - 10/14/98
+ * This old assumption dosn't work anymore, because now a device_number
+ * is defined as:
+ *
+ * device_number[0:4]   = slot
+ * device_number[5:12]  = bus
+ * device_number[13:15] = function
+ *
+ * OLD ASSUMPTION:
+ *   16 Busses ( of possible 256, I am making the 
+ *               assumption that busses are numbered 
+ *               in increasing order and that no
+ *               PC will have more than 16 busses )
+ *   32 Slots Per Bus
+ *
+ *   Device Number = Bus Number * 32 + Slot Number     <== wrong, see above....
+ */
+#  define MAX_PCI_DEVICES 512
+
+/* baseAddr0, baseAddr1, ioBaseAddr, romBaseAddr */
+#define MAX_PCI_BASEADDRESSES           4
+
+typedef int PciMemType;
+#define PciMemTypeUncacheable           0
+#define PciMemTypeWriteCombining        1
+#define PciMemTypeWriteThrough          4
+#define PciMemTypeWriteProtected        5
+#define PciMemTypeWriteback             6
+
+typedef enum {
+    READ_ONLY,
+    WRITE_ONLY,
+    READ_WRITE
+} PciIOFlag;
+
+typedef struct {
+    FxU32              regAddress;
+    FxU32              sizeInBytes;
+    PciIOFlag          rwFlag;
+} PciRegister;
+
+#ifndef KERNEL
+extern PciRegister PCI_VENDOR_ID;     
+extern PciRegister PCI_DEVICE_ID;     
+extern PciRegister PCI_COMMAND;       
+extern PciRegister PCI_STATUS;
+extern PciRegister PCI_REVISION_ID;
+extern PciRegister PCI_CLASS_CODE;
+extern PciRegister PCI_CACHE_LINE_SIZE;
+extern PciRegister PCI_LATENCY_TIMER;
+extern PciRegister PCI_HEADER_TYPE;
+extern PciRegister PCI_BIST;
+extern PciRegister PCI_BASE_ADDRESS_0;
+extern PciRegister PCI_BASE_ADDRESS_1;
+extern PciRegister PCI_IO_BASE_ADDRESS;
+extern PciRegister PCI_SUBVENDOR_ID;
+extern PciRegister PCI_SUBSYSTEM_ID;
+extern PciRegister PCI_ROM_BASE_ADDRESS;
+extern PciRegister PCI_CAP_PTR;
+extern PciRegister PCI_INTERRUPT_LINE;
+extern PciRegister PCI_INTERRUPT_PIN;
+extern PciRegister PCI_MIN_GNT;
+extern PciRegister PCI_MAX_LAT;
+extern PciRegister PCI_FAB_ID;
+extern PciRegister PCI_CONFIG_STATUS;
+extern PciRegister PCI_CONFIG_SCRATCH;
+extern PciRegister PCI_AGP_CAP_ID;
+extern PciRegister PCI_AGP_STATUS;
+extern PciRegister PCI_AGP_CMD;
+extern PciRegister PCI_ACPI_CAP_ID;
+extern PciRegister PCI_CNTRL_STATUS;
+
+extern PciRegister PCI_SST1_INIT_ENABLE; // 0x40
+extern PciRegister PCI_SST1_BUS_SNOOP_0; // 0x44
+extern PciRegister PCI_SST1_BUS_SNOOP_1; // 0x48
+extern PciRegister PCI_SST1_CFG_STATUS;  // 0x4C
+
+#endif /* #ifndef KERNEL */
+
+/* a structure that contains callback procs  */
+typedef struct {
+    FxBool doHW;
+    FxU8 (*pioInByte) (FxU16 port);
+    FxU16 (*pioInWord) (FxU16 port);
+    FxU32 (*pioInLong) (FxU16 port);
+    void (*pioOutByte) (FxU16 port,FxU8 data);
+    void (*pioOutWord) (FxU16 port,FxU16 data);
+    void (*pioOutLong) (FxU16 port,FxU32 data);
+} PciHwcCallbacks;
+
+FX_ENTRY const char * FX_CALL
+pciGetErrorString( void );
+
+FX_ENTRY FxU32 FX_CALL
+pciGetErrorCode( void );
+
+FX_ENTRY FxU8 FX_CALL
+pioInByte ( unsigned short port );              /* inp */
+
+FX_ENTRY FxU16 FX_CALL
+pioInWord ( unsigned short port );              /* inpw */
+
+FX_ENTRY FxU32 FX_CALL
+pioInLong ( unsigned short port );              /* inpd */
+
+FX_ENTRY FxBool FX_CALL
+pioOutByte ( unsigned short port, FxU8 data );  /* outp */
+
+FX_ENTRY FxBool FX_CALL
+pioOutWord ( unsigned short port, FxU16 data ); /* outpw */
+
+FX_ENTRY FxBool FX_CALL
+pioOutLong ( unsigned short port, FxU32 data ); /* outpd */
+
+
+FX_ENTRY FxBool FX_CALL
+pciOpen( void );
+
+FX_ENTRY FxBool FX_CALL
+pciOpenEx( PciHwcCallbacks * );
+
+FX_ENTRY FxBool FX_CALL
+pciClose( void );
+
+FX_ENTRY FxBool FX_CALL 
+pciDeviceExists( FxU32 device_number );
+
+FX_ENTRY FxBool FX_CALL 
+pciGetConfigData( PciRegister reg, FxU32 device_number, FxU32 *data );
+
+FX_ENTRY FxBool FX_CALL 
+pciSetConfigData( PciRegister reg, FxU32 device_number, FxU32 *data );
+
+/* NB: This routine makes the implicit assumption that the device was
+ * on bus0 which would not work across pci bridges or on agp devices.   
+ */
+FX_ENTRY FxBool FX_CALL 
+pciMapPhysicalToLinear(FxU32 *linear_addr, FxU32 physical_addr,FxU32 *length);
+
+FX_ENTRY FxBool FX_CALL 
+pciMapPhysicalDeviceToLinear(FxU32 *linear_addr, 
+                             FxU32 busNumber, FxU32 physical_addr,
+                             FxU32 *length);
+
+FX_ENTRY void   FX_CALL 
+pciUnmapPhysical( FxU32 linear_addr, FxU32 length );
+
+const char *
+pciGetVendorName( FxU16 vendor_id );
+const char *
+pciGetClassName( FxU32 class_code , FxU32 deviceID);
+
+FX_ENTRY FxBool FX_CALL 
+pciFindCard(FxU32 vendorID, FxU32 deviceID, FxU32 *devNum);
+
+FX_ENTRY FxBool FX_CALL 
+pciFindCardMulti(FxU32 vID, FxU32 dID, FxU32 *devNum, FxU32 cardNum);
+
+FX_ENTRY FxU32 * FX_CALL 
+pciMapCard(FxU32 vID, FxU32 dID, FxI32 len, FxU32 *devNo, FxU32 addrNo);
+
+FX_ENTRY FxU32 * FX_CALL
+pciMapCardMulti(FxU32 vID,FxU32 dID,FxI32 l,FxU32 *dNo,FxU32 cNo,FxU32 aNo);
+
+FX_ENTRY FxBool FX_CALL
+pciFindMTRRMatch(FxU32 pBaseAddrs, FxU32 psz, PciMemType type, FxU32 *mtrrNum);
+
+FX_ENTRY FxBool FX_CALL
+pciFindFreeMTRR(FxU32 *mtrrNum);
+
+FX_ENTRY FxBool FX_CALL
+pciSetMTRR(FxU32 mtrrNo, FxU32 pBaseAddr, FxU32 psz, PciMemType type);
+
+FX_ENTRY FxBool FX_CALL
+pciSetMTRRAmdK6(FxU32 mtrrNo, FxU32 pBaseAddr, FxU32 psz, PciMemType type);
+
+FX_ENTRY FxBool FX_CALL
+pciSetPassThroughBase(FxU32* pBaseAddr, FxU32 baseAddrLen);
+
+FX_ENTRY FxBool FX_CALL
+pciOutputDebugString(const char* debugMsg);
+
+FX_ENTRY FxBool FX_CALL
+pciLinearRangeSetPermission(const FxU32 addrBase, const FxU32 addrLen, const FxBool writeableP);
+
+#define PCI_ERR_NOERR           0
+#define PCI_ERR_WINRTINIT       1
+#define PCI_ERR_MEMMAPVXD       2
+#define PCI_ERR_MAPMEMDRV       3
+#define PCI_ERR_GENPORT         4
+#define PCI_ERR_NO_BUS          5
+#define PCI_ERR_NOTOPEN         6
+#define PCI_ERR_NOTOPEN2        7
+#define PCI_ERR_NOTOPEN3        8
+#define PCI_ERR_OUTOFRANGE      9
+#define PCI_ERR_NODEV           10
+#define PCI_ERR_NODEV2          11
+#define PCI_ERR_WRITEONLY       12
+#define PCI_ERR_READONLY        13
+#define PCI_ERR_PHARLAP         14
+#define PCI_ERR_WRONGVXD        15
+#define PCI_ERR_MEMMAP          16
+#define PCI_ERR_MAPMEM          17
+#define PCI_ERR_WINRT           18
+#define PCI_ERR_VXDINUSE        19
+#define PCI_ERR_NO_IO_PERM      20
+#define PCI_ERR_NO_MEM_PERM     21
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FXPCI_H_ */
Index: trunk/src/opengl/glide/swlibs/pcilib/fxphrlap.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxphrlap.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxphrlap.c	(revision 2887)
@@ -0,0 +1,289 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+
+#include <stdlib.h>
+#include <i86.h>
+#include <dos.h>
+#include <pharlap.h>
+#include <hw386.h>
+#include <fxpci.h>
+#include <pcilib.h>
+#include "fxphrlap.h"
+
+#define PHARLAP_INTERRUPT 0x21
+#define PHARLAP_UNSPECIFIED_ERROR 1
+
+static char pciIdent[] = "@#% fxPCI for PHARLAP";
+
+FxBool pciInitializeDDio(void)
+{
+    if (pciIdent[0]);
+    return(FXTRUE);
+}
+    
+/*
+** pciPhrlapGetSegmentLinearBase (_dx_tolinear)
+*/
+int pciPhrlapGetSegmentLinearBase( USHORT selector, ULONG* lin_addrp )
+{
+  union REGS r;
+
+  /*
+  ** Phar Lap 2508h - Get Segment Linear Base Address
+  */
+  r.w.ax = 0x2508;
+
+  /*
+  ** BX segment selector
+  */
+  r.w.bx = (unsigned short) selector;
+  int386( PHARLAP_INTERRUPT, &r, &r );
+
+  if ( r.w.cflag )
+  {
+    return PHARLAP_UNSPECIFIED_ERROR;
+  }
+
+  else
+  {
+    /*
+    ** ECX linear base address of segment
+    */
+    *lin_addrp = (ULONG) r.x.ecx;
+    return 0;
+  }
+}
+
+/*
+** pciPhrlapMapPhysMemEndSegment (_dx_map_phys)
+*/
+int pciPhrlapMapPhysMemEndSegment( USHORT selector, ULONG phys_addr, ULONG page_cnt, ULONG* offsetp )
+{
+  union REGS r;
+  struct SREGS sr;
+
+  /*
+  ** Phar Lap 250ah - Map Physical Memory at End of Segment
+  */
+  r.w.ax = 0x250a;
+
+  /*
+  ** ES  segment selector in the LDT of segment to modify
+  ** EBX physical base address of memory to map, must be a multiple of four kilobytes
+  ** ECX number of physical 4-KB memory pages to map
+  */
+  r.x.ebx = (unsigned int) phys_addr;
+  r.x.ecx = (unsigned int) page_cnt;
+  segread( &sr );
+  sr.es = selector;
+  int386x( PHARLAP_INTERRUPT, &r, &r, &sr );
+
+  if ( r.w.cflag )
+  {
+    /*
+    ** EAX error code
+    */
+    return r.x.eax;
+  }
+
+  else
+  {
+    /*
+    ** EAX offset in segment of mapped memory
+    */
+    *offsetp = (ULONG) r.x.eax;
+    return 0;
+  }
+}
+
+/*
+** pciPhrlapGetConfigInfo (_dx_config_inf)
+*/
+void pciPhrlapGetConfigInfo( CONFIG_INF* configp, UCHAR* swf_namep )
+{
+  union REGS r;
+
+  /*
+  ** Phar Lap 2526h - Get Configuration Information
+  */
+  r.w.ax = 0x2526;
+
+  /*
+  ** EBX 512 byte configuration buffer
+  ** ECX 256 byte buffer for name and path of 386 | VMM swap file
+  */
+  r.x.ebx = (unsigned int) configp;
+  r.x.ecx = (unsigned int) swf_namep;
+  int386( PHARLAP_INTERRUPT, &r, &r );
+}
+
+/*
+** pciPhrlapReadPageTableEntry (_dx_rd_ptinfn)
+*/
+int pciPhrlapReadPageTableEntry( ULONG linadr, ULONG* ptep, ULONG* ptinfp )
+{
+  union REGS r;
+
+  /*
+  ** Phar Lap 252bh/9 - Read Page Table Entry and Associated Information
+  */
+  r.w.ax = 0x252b;
+  r.h.bh = 0x9;
+  r.h.bl = 0x0;     /* select linear */
+
+  /*
+  ** ECX linear address to read PTE for
+  */
+  r.x.ecx = linadr;
+  int386( PHARLAP_INTERRUPT, &r, &r );
+
+  if ( r.w.cflag )
+  {
+    /*
+    ** EAX error code
+    */
+    return r.x.eax;
+  }
+
+  else
+  {
+    /*
+    ** EAX page table entry
+    ** EBX additional page table information
+    */
+    *ptep = (ULONG) r.x.eax;
+    *ptinfp = (ULONG) r.x.ebx;
+    return 0;
+  }
+}
+
+/*
+** pciPhrlapWritePageTableEntry (_dx_wr_ptinfn)
+*/
+int pciPhrlapWritePageTableEntry( ULONG linadr, ULONG pte, ULONG ptinf )
+{
+  union REGS r;
+
+  /*
+  ** Phar Lap 252bh/10 - Write Page Table Entry and Associated Information
+  */
+  r.w.ax = 0x252b;
+  r.h.bh = 0xa;
+  r.h.bl = 0x0;     /* select linear */
+
+  /*
+  ** ECX linear address to read PTE for
+  ** ESI page table entry
+  ** EDI additional page table information
+  */
+  r.x.ecx = linadr;
+  r.x.esi = pte;
+  r.x.edi = ptinf;
+
+  int386( PHARLAP_INTERRUPT, &r, &r );
+
+  if ( r.w.cflag )
+  {
+    /*
+    ** EAX error code
+    */
+    return r.x.eax;
+  }
+
+  else
+  {
+    return 0;
+  }
+}
+
+FX_EXPORT FxBool FX_CSTYLE
+pciMapPhysicalToLinear( FxU32 *linear_addr, FxU32 physical_addr,
+                       FxU32 *length ) 
+{ 
+    CONFIG_INF config;          /* information about Phar Lap environment */
+    ULONG DevPageCount;         /* page count of device memory */
+    ULONG LinBase;              /* linear base address of ds segment */
+    ULONG pDev;                 /* linear ptr where device is mapped */
+    UINT DevSize;               /* page-aligned size of device memory */
+    ULONG pDevPage;             /* linear scan ptr thru device pages */
+    ULONG pte;                  /* page table entry */
+    ULONG pti;                  /* page table info */
+        
+    if ( !pciLibraryInitialized ) {
+	pciErrorCode = PCI_ERR_NOTOPEN;
+	return FXFALSE;
+    }
+
+    pciPhrlapGetConfigInfo( &config, (UCHAR*) &config );
+    DevPageCount = ((ULONG) *length) >> 12; /* 4 KB pages */
+    if ( pciPhrlapMapPhysMemEndSegment( config.c_ds_sel, physical_addr, DevPageCount, (ULONG*) linear_addr ) != 0 )
+      {
+        pciErrorCode = PCI_ERR_PHARLAP;
+        return FXFALSE;
+      }
+    /* This is per TNT DOS-Extender SDK 8.0 Release Notes */
+    /* pciPhrlapReadPageTableEntry & pciPhrlapWritePageTableEntry are not
+       supported under DPMI. */
+    /* xxx PE_PCD is supposed to be set by the DPMI map device in memory call--
+       do we need to use DPMI's versions of these or are we ok?
+       There doesn't seem to be corresponding calls for DPMI */
+    if ( !config.c_dpmif )
+    {
+        if ( pciPhrlapGetSegmentLinearBase( config.c_ds_sel, &LinBase ) != 0 )
+          {
+            pciErrorCode = PCI_ERR_PHARLAP;
+            return FXFALSE;
+          }
+        pDev = *linear_addr + LinBase;
+        DevSize = (UINT) *length;
+        /* Touch every page 0x1000 = 4 KB pages */
+        for ( pDevPage = pDev; pDevPage - pDev < DevSize; pDevPage += 0x1000 )
+          {
+            if ( pciPhrlapReadPageTableEntry( pDevPage, &pte, &pti ) != 0 )
+              {
+                pciErrorCode = PCI_ERR_PHARLAP;
+                return FXFALSE;
+              }
+            pte |= PE_PCD;
+            if ( pciPhrlapWritePageTableEntry( pDevPage, pte, pti ) != 0 )
+              {
+                pciErrorCode = PCI_ERR_PHARLAP;
+                return FXFALSE;
+              }
+          }
+    }
+}
+
+
+void pciUnmapPhysicalDD( FxU32 linear_addr, FxU32 length ) 
+{
+    return;
+}
+
+FX_EXPORT FxBool FX_CSTYLE
+pciClose( void )
+{
+    if ( !pciLibraryInitialized ) {
+        pciErrorCode = PCI_ERR_NOTOPEN2;
+        return FXFALSE;
+    }
+    pciLibraryInitialized = FXFALSE;
+    return FXTRUE;
+}
Index: trunk/src/opengl/glide/swlibs/pcilib/fxphrlap.h
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxphrlap.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxphrlap.h	(revision 2887)
@@ -0,0 +1,29 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+
+#ifndef _FXPHRLAP_H_
+#define _FXPHRLAP_H_
+
+int pciPhrlapGetSegmentLinearBase( USHORT selector, ULONG* lin_addrp );
+int pciPhrlapMapPhysMemEndSegment( USHORT selector, ULONG phys_addr, ULONG page_cnt, ULONG* offsetp );
+void pciPhrlapGetConfigInfo( CONFIG_INF* configp, UCHAR* swp_namep );
+int pciPhrlapReadPageTableEntry( ULONG linadr, ULONG* ptep, ULONG* ptinfp );
+int pciPhrlapWritePageTableEntry( ULONG linadr, ULONG pte, ULONG ptinf );
+#endif /* _FXPHRLAP_H_ */
Index: trunk/src/opengl/glide/swlibs/pcilib/fxvxd.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxvxd.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxvxd.c	(revision 2887)
@@ -0,0 +1,313 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+#include <stdlib.h>
+#include <stdio.h>
+
+#define WIN32_LEANER_AND_MEANER
+#include <windows.h>
+#include <conio.h>
+
+#include <3dfx.h>
+#define FX_DLL_DEFINITION
+#include <fxdll.h>
+#include <fxmemmap.h>
+#include "fxpci.h"
+#include "pcilib.h"
+#include "fxw32.h"
+
+/* Callback declarations */
+static FxBool pciInitialize9x(void);
+static FxBool pciShutdown9x(void);
+static const char* pciIdentifier9x(void);
+
+static FxU8  pciPortInByte9x(FxU16 port);
+static FxU16 pciPortInWord9x(FxU16 port);
+static FxU32 pciPortInLong9x(FxU16 port);
+  
+static FxBool pciPortOutByte9x(FxU16 port, FxU8 data);
+static FxBool pciPortOutWord9x(FxU16 port, FxU16 data);
+static FxBool pciPortOutLong9x(FxU16 port, FxU32 data);
+
+static FxBool pciMapLinear9x(FxU32 busNumber, FxU32 physAddr,
+                             FxU32* linearAddr, FxU32* length);
+static FxBool pciUnmapLinear9x(FxU32 linearAddr, FxU32 length);
+
+static FxBool pciSetPermission9x(const FxU32 addrBase, const FxU32 addrLen,
+                                 const FxBool writePermP);
+
+static FxBool pciMsrGet9x(MSRInfo* in, MSRInfo* out);
+static FxBool pciMsrSet9x(MSRInfo* in, MSRInfo* out);
+
+static FxBool pciOutputString9x(const char* msg);
+static FxBool pciSetPassThroughBase9x(FxU32* baseAddr, FxU32 baseAddrLen);
+
+static char pciIdent[] = "@#% fxPCI for Windows 9x";
+
+static const FxPlatformIOProcs __ioProcs9x = {
+  pciInitialize9x,
+  pciShutdown9x,
+  pciIdentifier9x,
+
+  pciPortInByte9x,
+  pciPortInWord9x,
+  pciPortInLong9x,
+  
+  pciPortOutByte9x,
+  pciPortOutWord9x,
+  pciPortOutLong9x,
+
+  pciMapLinear9x,
+  pciUnmapLinear9x,
+  pciSetPermission9x,
+
+  pciMsrGet9x,
+  pciMsrSet9x,
+
+  pciOutputString9x,
+  pciSetPassThroughBase9x
+};
+const FxPlatformIOProcs* ioProcs9x = &__ioProcs9x;
+
+/* Basic platform init/shutdown stuff */
+static FxBool
+pciInitialize9x(void)
+{
+  hMemmapFile = CreateFile("\\\\.\\FXMEMMAP.VXD", 0, 0, NULL, 0,
+                           FILE_FLAG_DELETE_ON_CLOSE, NULL);
+  if ( hMemmapFile == INVALID_HANDLE_VALUE ) {
+    pciErrorCode = PCI_ERR_MEMMAPVXD;
+    return FXFALSE;
+  }
+
+  return FXTRUE;
+}
+
+static FxBool
+pciShutdown9x(void)
+{
+  FxBool
+    retVal = (hMemmapFile != INVALID_HANDLE_VALUE);
+
+  if (retVal) CloseHandle( hMemmapFile );
+  return retVal;
+}
+
+static const char* 
+pciIdentifier9x(void)
+{
+  return pciIdent;
+}
+
+/* Device address space management stuff */
+
+static FxBool
+pciMapLinear9x(FxU32 busNumber, FxU32 physical_addr,
+               FxU32 *linear_addr, FxU32 *length)
+{
+  FxU32 nret;
+  FxU32 Physical [2];         /* Physical address[0] & size[1] */
+  FxU32 Linear [2];           /* Linear address[0] & size[1] */
+  LPDWORD pPhysical = Physical;
+  LPDWORD pLinear = Linear;
+  
+  Physical[0] = physical_addr;
+  Physical[1] = *length;
+  
+  if ( !pciLibraryInitialized ) {
+    pciErrorCode = PCI_ERR_NOTOPEN;
+    return FXFALSE;
+  }
+  
+#ifndef DIRECTX
+  /*
+   * Check version:
+   * The policy is that major and minor versions must match, and
+   * further that the reference count is less than or equal to one. 
+   */
+  DeviceIoControl(hMemmapFile, GETAPPVERSIONDWORD, NULL, 0, &pciVxdVer, 
+                  sizeof(pciVxdVer), &nret, NULL);
+  if (HIBYTE(pciVxdVer) != FX_MAJOR_VER || LOBYTE(pciVxdVer) < FX_MINOR_VER) {
+    pciErrorCode = PCI_ERR_WRONGVXD;
+    return FXFALSE;
+  }
+  
+#if 0
+  /* Check for mutual exclusion. Turned off everywhere for now because
+   * the DirectDraw driver does not bother to do anything w/ the mutex
+   * so no one else knows whether or not the hw is taken. Mmmm.... whacked.
+   */
+  if (VXDREFCOUNT(pciVxdVer) > 1) {
+    pciErrorCode = PCI_ERR_VXDINUSE;
+    return FXFALSE;
+  }
+#endif
+#endif /* !DIRECTX */
+  
+  /* Map physical to linear */
+  /* xxx - returns 0 in Linear if fails, but really should
+     check return value, 0 is suceess, -1 is failure. */
+  
+#ifndef DIRECTX
+  /* Stuff added to auto-switch passthru using fxmemmap */
+  if (getenv("SST_DUALHEAD") == NULL) {
+    DeviceIoControl(hMemmapFile, GETLINEARADDR_AUTO, 
+                    &pPhysical, sizeof(pPhysical), 
+                    &pLinear, sizeof(pLinear), 
+                    &nret, NULL);
+  } else 
+#endif /* !DIRECTX */
+  {
+    DeviceIoControl(hMemmapFile, GETLINEARADDR, 
+                    &pPhysical, sizeof(pPhysical), 
+                    &pLinear, sizeof(pLinear), 
+                    &nret, NULL);
+  }
+  
+  *linear_addr = Linear[0];
+  
+  if ( nret == 0 ) {
+    pciErrorCode = PCI_ERR_MEMMAP;
+    return FXFALSE;
+  }
+
+  return FXTRUE;
+}
+
+static FxBool
+pciUnmapLinear9x( FxU32 linear_addr, FxU32 length ) 
+{
+  FxU32 nret;
+  
+  return DeviceIoControl(hMemmapFile, DECREMENTMUTEX,
+                         NULL, 0, 
+                         NULL, 0,
+                         &nret, NULL);
+}
+
+/* Platform port io stuff */
+static FxU8
+pciPortInByte9x(FxU16 port)
+{
+  return _inp(port);
+}
+
+static FxU16
+pciPortInWord9x(FxU16 port)
+{
+  return _inpw(port);
+}
+
+static FxU32
+pciPortInLong9x(FxU16 port)
+{
+  return _inpd(port);
+}
+  
+static FxBool
+pciPortOutByte9x(FxU16 port, FxU8 data)
+{
+  return _outp(port, data);
+}
+
+static FxBool
+pciPortOutWord9x(FxU16 port, FxU16 data)
+{
+  return _outpw(port, data);
+}
+
+static FxBool
+pciPortOutLong9x(FxU16 port, FxU32 data)
+{
+  return _outpd(port, data);
+}
+
+static FxBool pciMsrGet9x(MSRInfo* in, MSRInfo* out)
+{
+  FxU32 nret; 
+
+  return DeviceIoControl( hMemmapFile, GETMSR, 
+                          in, sizeof(*in), 
+                          out, sizeof(*out), 
+                          &nret, NULL); 
+}
+
+static FxBool pciMsrSet9x(MSRInfo* in, MSRInfo* out)
+{
+  FxU32 nret; 
+
+  return DeviceIoControl( hMemmapFile, SETMSR, 
+                          in, sizeof(*in), 
+                          out, sizeof(*out), 
+                          &nret, NULL); 
+}
+
+/* Platform utilities. */
+static FxBool
+pciOutputString9x(const char* msg)
+{
+  FxBool retVal = FXTRUE;
+
+  if (pciLibraryInitialized) {
+    OutputDebugString(msg);
+  } else {
+    pciErrorCode = PCI_ERR_NOTOPEN;
+    retVal = FXFALSE;
+  }
+
+  return retVal;
+}
+
+/* Ganked from vmm.h */
+#define PC_USER         0x00040000  /* make the pages ring 3 accessible */
+
+static FxBool
+pciSetPermission9x(const FxU32 addrBase, const FxU32 addrLen,
+                   const FxBool writePermP)
+{
+  FxU32 vxdParamArray[] = {
+    addrBase,
+    addrLen,
+    0
+  };
+  FxU32 nRet = 0;
+  
+  /* Set the user accessable bit. We don't dork w/ the
+   * rest of the bits.
+   */
+  vxdParamArray[2] = (writePermP ? PC_USER : 0);
+  
+  return DeviceIoControl(hMemmapFile, SETADDRPERM,
+                         vxdParamArray, sizeof(vxdParamArray),
+                         NULL, 0,
+                         &nRet, NULL);
+}
+
+static FxBool
+pciSetPassThroughBase9x(FxU32* baseAddr, FxU32 baseAddrLen)
+{
+  FxU32 vxdParams[] = { (FxU32)baseAddr, baseAddrLen };
+  FxU32 nRet = 0;
+  
+  return DeviceIoControl(hMemmapFile, SETPASSTHROUGHBASE, 
+                         vxdParams, sizeof(vxdParams),
+                         NULL, 0, 
+                         &nRet, NULL);
+}
+
Index: trunk/src/opengl/glide/swlibs/pcilib/fxw32.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxw32.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxw32.c	(revision 2887)
@@ -0,0 +1,68 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+*/
+#include <stdlib.h>
+#include <stdio.h>
+
+#define WIN32_LEANER_AND_MEANER
+#include <windows.h>
+
+#include <3dfx.h>
+#define FX_DLL_DEFINITION
+#include <fxdll.h>
+#include <fxmemmap.h>
+#include "fxpci.h"
+#include "pcilib.h"
+
+#include "fxw32.h"
+
+/* Stuff shared across all usable win32 platforms */
+HANDLE hMemmapFile;
+
+FxBool 
+pciPlatformInit(void)
+{
+  OSVERSIONINFO
+    osInfo;
+  FxBool
+    retVal;
+
+  osInfo.dwOSVersionInfoSize = sizeof(osInfo);
+  retVal = GetVersionEx(&osInfo);
+  if (retVal) {
+    switch(osInfo.dwPlatformId) {
+    case VER_PLATFORM_WIN32_WINDOWS:
+      gCurPlatformIO = ioProcs9x;
+      break;
+
+    case VER_PLATFORM_WIN32_NT:
+      gCurPlatformIO = ioProcsNT;
+      break;
+
+    default:
+    case VER_PLATFORM_WIN32s:
+      gCurPlatformIO = NULL;
+      break;
+    }
+
+    retVal = (gCurPlatformIO != NULL);
+  }
+
+  return retVal;
+}
Index: trunk/src/opengl/glide/swlibs/pcilib/fxw32.h
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/fxw32.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/fxw32.h	(revision 2887)
@@ -0,0 +1,40 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+**
+** $Revision: 1.1 $ 
+** $Date: 2000-02-25 00:33:57 $ 
+**
+*/
+
+#ifndef __FX_W32_H__
+#define __FX_W32_H__
+
+#define WIN32_LEANER_AND_MEANER
+#include <windows.h>
+
+#include "pcilib.h"
+
+/* Stuff shared across all usable win32 platforms */
+extern HANDLE hMemmapFile;
+
+extern const FxPlatformIOProcs* ioProcsNT;
+extern const FxPlatformIOProcs* ioProcs9x;
+
+#endif /* __FX_W32_H__ */
Index: trunk/src/opengl/glide/swlibs/pcilib/makefile
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/makefile	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/makefile	(revision 2887)
@@ -0,0 +1,43 @@
+# $Id: makefile,v 1.1 2000-02-25 00:33:57 sandervl Exp $
+#
+# PD-Win32 API
+#
+#       Glide makefile
+#
+
+PDWIN32_INCLUDE = ..\..\..\..\..\include
+PDWIN32_LIB = ..\..\..\..\..\lib
+PDWIN32_BIN = ..\..\..\..\..\bin
+PDWIN32_TOOLS = ..\..\..\..\..\tools\bin
+
+TARGET=pcilib
+
+!include $(PDWIN32_INCLUDE)/pdwin32.mk
+!include ..\..\sst1\3dfx.mak
+
+CINCLUDE=-I..\..\sst1\incsrc;..\fxmisc;..\..\sst1\init\initvg;..\..\sst1\glide;..\..\sst1\texus;..\..\sst1\init
+
+CFLAGS = $(CFLAGS) $(CINCLUDE)
+CXXFLAGS = $(CXXFLAGS) $(CINCLUDE)
+
+OBJS = fxos2.obj fxpci.obj sst1_pci.obj fxinfo.obj
+
+all: $(TARGET).lib
+
+$(TARGET).lib: $(OBJS)
+	$(RM) $(TARGET).lib
+	$(ILIB) $(ILIBFLAGS) $(TARGET).lib $(OBJS) ,,
+
+dep:
+    $(DEPEND) -I$(PDWIN32_INCLUDE);$(PDWIN32_INCLUDE)\win $(CINCLUDE) \
+        *.c *.cpp *.h *.asm *.inc $(PDWIN32_INCLUDE)\*.h \
+        ..\..\sst1\incsrc\*.h ..\fxmisc\*.h ..\..\sst1\init\initvg\*.h ..\..\sst1\glide*.h ..\..\sst1\texus\*.h ..\..\sst1\init\*.h 
+
+!ifndef NODEP
+!include .depend
+!endif
+
+clean:
+    $(RM) *.obj *.pch
+    $(RM) *.lib
+
Index: trunk/src/opengl/glide/swlibs/pcilib/makefile.os2
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/makefile.os2	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/makefile.os2	(revision 2887)
@@ -0,0 +1,8 @@
+include "\glide\3dfxos2.mak"
+
+OBJS = fxos2.obj fxpci.obj sst1_pci.obj fxinfo.obj
+
+all: $(OBJS)
+
+clean:
+        del *.obj
Index: trunk/src/opengl/glide/swlibs/pcilib/makefile.unix
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/makefile.unix	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/makefile.unix	(revision 2887)
@@ -0,0 +1,36 @@
+#
+# THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+# PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+# TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+# INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+# DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+# THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+# EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+# FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+# 
+# USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+# RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+# TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+# AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+# SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+# THE UNITED STATES.  
+# 
+# COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+#
+# $Revision: 1.1 $
+# $Date: 2000-02-25 00:33:57 $
+
+# local defines, options, includes
+
+# sources
+HEADERS             = fxpci.h sst1_pci.h
+PRIVATE_HEADERS     += pcilib.h
+INSTALL_DESTINATION = $(BUILD_ROOT_SWLIBS)
+EXTPCIFILES = fxlinux.c
+CFILES              = fxpci.c fxinfo.c fxmsr.c sst1_pci.c $(EXTPCIFILES)
+#FX_DLL_COMPILE      = 1
+
+# targets
+LIBRARIES = libfxpci.a
+
+include $(BUILD_ROOT_SWLIBS)/include/make/3dfx.mak
Index: trunk/src/opengl/glide/swlibs/pcilib/pcilib.bat
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/pcilib.bat	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/pcilib.bat	(revision 2887)
@@ -0,0 +1,54 @@
+rem THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+rem PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+rem TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+rem INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+rem DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+rem THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+rem EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+rem FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+rem 
+rem USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+rem RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+rem TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+rem AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+rem SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+rem THE UNITED STATES.  
+rem 
+rem COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+
+rem
+rem   This batch file compiles with watcom for DOS2 env.
+rem
+rem   This is an example of the commands that are needed to
+rem   build this lib
+rem
+rem   You will need to modify this file to adopt to your
+rem   build environment
+
+
+rem This sets up the watcom compiler vars
+rem you probably need to change these for you development env
+
+set WATCOM=c:\watcom
+set PATH=%PATH%;c:watcom\binnt;c:\watcom\binw
+set INCLUDE=c:\watcom\h;c:\watcom\h\nt;..\..\include
+
+rem
+rem if you want to build for Win32 instead of DOS
+rem change bt=NT and copy the glide library from WIN32
+rem Change NT to DOS4G on link line
+rem
+
+SET WCC386= -otexan -I..\..\include -D__DOS32__ -w4 -e25 -7 -fp5 -zq -5r -ei -mf -bt#dos      
+wcc386 fxpci.c
+wcc386 sst1_pci.c
+
+create tmp.lnk
+echo +fxpci.obj  >> tmp.lnk
+echo +sst1_pci.obj >> tmp.lnk
+
+wlib -b -c -n -q -p=512 fxpci @tmp.lnk
+del tmp.lnk
+
+copy fxpci.lib ..\..\lib
+
Index: trunk/src/opengl/glide/swlibs/pcilib/pcilib.h
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/pcilib.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/pcilib.h	(revision 2887)
@@ -0,0 +1,122 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+**
+** $Revision: 1.1 $ 
+** $Date: 2000-02-25 00:33:57 $ 
+**
+*/
+
+#ifndef _PCILIB_H_
+#define _PCILIB_H_
+
+#define CONFIG_ADDRESS_PORT 0xCF8
+#define CONFIG_DATA_PORT    0xCFC
+#define CONFIG_ADDRESS_ENABLE_BIT 0x80000000UL
+
+#define CONFIG_MAPPING_ENABLE_BYTE 0x80
+#define CONFIG_MAPPING_DISABLE_BYTE 0x00
+
+#define CONFIG_SPACE_ENABLE_PORT 0xCF8
+#define FORWARD_REGISTER_PORT    0xCFA
+#define CONFIG_MAPPING_OFFSET    0xC000
+
+#define PCI_INTERRUPT  0x1A
+#define PCI_FUNC_CODE  0xB1
+#define PCI_PHYS_ADDR  0x000FFE6E
+
+#define BYTE0(a) ((a) & 0xff)
+#define BYTE1(a) (((a) >> 8) & 0xff)
+#define VXDREFCOUNT(a) (((a) >> 16) & 0xff)
+
+typedef struct {
+  FxU32
+    msrNum,                     /* Which MSR? */
+    msrLo, msrHi;               /* MSR Values  */
+} MSRInfo;
+
+/* PRIVATE DATA */
+extern FxU32   pciVxdVer;
+extern FxU32   pciErrorCode;
+extern FxBool  pciLibraryInitialized;
+extern PciHwcCallbacks pciHwcCallbacks;
+
+typedef struct {
+  /* Platform specific init/shutdown stuff. */
+  FxBool (*ioInit)(void);
+  FxBool (*ioShutdown)(void);
+  const char* (*ioIdent)(void);
+
+  /* Port i/o */
+  FxU8  (*portInByte)(FxU16 port);
+  FxU16 (*portInWord)(FxU16 port);
+  FxU32 (*portInLong)(FxU16 port);
+  
+  FxBool (*portOutByte)(FxU16 port, FxU8 data);
+  FxBool (*portOutWord)(FxU16 port, FxU16 data);
+  FxBool (*portOutLong)(FxU16 port, FxU32 data);
+
+  /* Platform device address management */
+  FxBool (*addrMap)(FxU32 busNumber, FxU32 physAddr,
+                    FxU32* linearAddr, FxU32* length);
+  FxBool (*addrUnmap)(FxU32 linearAddr, FxU32 length);
+
+  /* Optional things that a platform may or maynot support and clients
+   * should not rely on the call to suceed.  
+   */
+  FxBool (*addrSetPermission)(const FxU32 addrBase, const FxU32 addrLen,
+                              const FxBool writePermP);
+
+  FxBool (*msrGet)(MSRInfo* in, MSRInfo* out);
+  FxBool (*msrSet)(MSRInfo* in, MSRInfo* out);
+
+  FxBool (*utilOutputString)(const char* msg);
+  FxBool (*utilSetPassThroughBase)(FxU32* baseAddr, FxU32 baseAddrLen);
+} FxPlatformIOProcs;
+
+extern const FxPlatformIOProcs* gCurPlatformIO;
+
+#define pciInitializeDDio             (*gCurPlatformIO->ioInit)
+#define pciCloseDDio                  (*gCurPlatformIO->ioShutdown)
+#define pciPlatformIdentifier         (*gCurPlatformIO->ioIdent)
+
+#define pciMapLinearDD                (*gCurPlatformIO->addrMap)
+#define pciUnmapLinearDD              (*gCurPlatformIO->addrUnmap)
+#define pciLinearRangeSetPermissionDD (*gCurPlatformIO->addrSetPermission)
+
+#define pciOutputDebugStringDD        (*gCurPlatformIO->utilOutputString)
+#define pciSetPassThroughBaseDD       (*gCurPlatformIO->utilSetPassThroughBase)
+
+#define _pioInByte                    (*gCurPlatformIO->portInByte)
+#define _pioInWord                    (*gCurPlatformIO->portInWord)
+#define _pioInLong                    (*gCurPlatformIO->portInLong)
+
+#define _pioOutByte                   (*gCurPlatformIO->portOutByte)
+#define _pioOutWord                   (*gCurPlatformIO->portOutWord)
+#define _pioOutLong                   (*gCurPlatformIO->portOutLong)
+
+#define DOGETMSR(__in, __out)         (*gCurPlatformIO->msrGet)(&(__in), &(__out))
+#define DOSETMSR(__in, __out)         (*gCurPlatformIO->msrSet)(&(__in), &(__out))
+
+/* One should be defined per real platform (currently dos/win32) to
+ * setup the platform function pointer struct.  
+ */
+extern FxBool pciPlatformInit(void);
+
+#endif /* _PCILIB_H_ */
Index: trunk/src/opengl/glide/swlibs/pcilib/sst1_pci.c
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/sst1_pci.c	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/sst1_pci.c	(revision 2887)
@@ -0,0 +1,37 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+**
+** $Revision: 1.1 $ 
+** $Date: 2000-02-25 00:33:58 $ 
+**
+*/
+
+#include <3dfx.h>
+#include <fxpci.h>
+#include "sst1_pci.h"
+
+const PciRegister SST1_PCI_INIT_ENABLE = { 0x40, 4, READ_WRITE }; 
+const PciRegister SST1_PCI_BUS_SNOOP_0 = { 0x44, 4, WRITE_ONLY }; 
+const PciRegister SST1_PCI_BUS_SNOOP_1 = { 0x48, 4, WRITE_ONLY }; 
+const PciRegister SST1_PCI_CFG_STATUS  = { 0x4C, 4, READ_WRITE }; 
+
+const PciRegister SST1_PCI_VCLK_ENABLE = { 0xc0, 4, WRITE_ONLY };
+const PciRegister SST1_PCI_VCLK_DISABLE= { 0xe0, 4, WRITE_ONLY };
+
Index: trunk/src/opengl/glide/swlibs/pcilib/sst1_pci.h
===================================================================
--- trunk/src/opengl/glide/swlibs/pcilib/sst1_pci.h	(revision 2887)
+++ trunk/src/opengl/glide/swlibs/pcilib/sst1_pci.h	(revision 2887)
@@ -0,0 +1,43 @@
+/*
+** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
+** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
+** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
+** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 
+** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 
+** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
+** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
+** FULL TEXT OF THE NON-WARRANTY PROVISIONS.  
+** 
+** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
+** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
+** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
+** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
+** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
+** THE UNITED STATES.  
+** 
+** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
+**
+**
+** $Revision: 1.1 $ 
+** $Date: 2000-02-25 00:33:58 $ 
+**
+*/
+
+#ifndef _SST1_PCI_H_
+#define _SST1_PCI_H_
+
+#ifndef _FXPCI_H_
+#include <fxpci.h>
+#endif
+
+extern const PciRegister SST1_PCI_INIT_ENABLE; // 0x40
+extern const PciRegister SST1_PCI_BUS_SNOOP_0; // 0x44
+extern const PciRegister SST1_PCI_BUS_SNOOP_1; // 0x48
+extern const PciRegister SST1_PCI_CFG_STATUS;  // 0x4C
+
+extern const PciRegister SST1_PCI_VCLK_ENABLE;
+extern const PciRegister SST1_PCI_VCLK_DISABLE;
+#endif
+
+
+
